This commit is contained in:
苏尹岚
2021-03-11 10:53:13 +08:00
parent 33f6a0f304
commit f79e750ace

View File

@@ -4,13 +4,10 @@ import (
"bytes"
"context"
"fmt"
"math"
"regexp"
"strings"
"time"
"git.rosy.net.cn/jx-callback/business/jxstore/report"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
"git.rosy.net.cn/jx-callback/business/partner/delivery"
"github.com/360EntSecGroup-Skylar/excelize"
@@ -1868,29 +1865,51 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
// }, storeMaps)
// tasksch.HandleTask(task, nil, true).Run()
// _, err = task.GetResult(0)
var (
storeMaps []*model.StoreMap
db = dao.GetDB()
)
storeMaps, err = dao.GetStoresMapList(db, []int{3}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
task := tasksch.NewParallelTask("uuuuu", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
storeMap := batchItemList[0].(*model.StoreMap)
if storeMap.CoverArea == 0 {
handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID)
if store, err := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID); err == nil {
if storeMap.VendorID == model.VendorIDJD && store.DeliveryRangeType != model.DeliveryRangeTypePolygon {
storeMap.CoverArea = math.Pi * utils.Str2Float64WithDefault(store.DeliveryRange, 0) * utils.Str2Float64WithDefault(store.DeliveryRange, 0) / float64(10000)
} else {
storeMap.CoverArea = report.CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), storeMap.VendorID)
// var (
// storeMaps []*model.StoreMap
// db = dao.GetDB()
// )
// storeMaps, err = dao.GetStoresMapList(db, []int{3}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
// task := tasksch.NewParallelTask("uuuuu", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
// storeMap := batchItemList[0].(*model.StoreMap)
// if storeMap.CoverArea == 0 {
// handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID)
// if store, err := handler.ReadStore(ctx, storeMap.VendorOrgCode, storeMap.VendorStoreID); err == nil {
// if storeMap.VendorID == model.VendorIDJD && store.DeliveryRangeType != model.DeliveryRangeTypePolygon {
// storeMap.CoverArea = math.Pi * utils.Str2Float64WithDefault(store.DeliveryRange, 0) * utils.Str2Float64WithDefault(store.DeliveryRange, 0) / float64(10000)
// } else {
// storeMap.CoverArea = report.CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), storeMap.VendorID)
// }
// dao.UpdateEntity(db, storeMap, "CoverArea")
// }
// }
// return retVal, err
// }, storeMaps)
// tasksch.HandleTask(task, nil, true).Run()
// _, err = task.GetResult(0)
skuIDMap := make(map[int]int)
order, _ := partner.CurOrderManager.LoadOrder("2105998332000452", 0)
for _, v := range order.Skus {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
skuIDMap[skuID] = 1
}
}
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(dao.GetDB(), 0, []int{0}, model.ActTypeAll, []int{103168}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
fmt.Println("actStoreSkuList111111111111111111", utils.Format4Output(actStoreSkuList, false))
if actStoreSkuMap := jxutils.NewActStoreSkuMap(actStoreSkuList, false); actStoreSkuMap != nil {
for _, v := range order.Skus {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
if actStoreSku := actStoreSkuMap.GetActStoreSku(103168, skuID, order.VendorID); actStoreSku != nil {
fmt.Println("actStoreSku11111111111111", utils.Format4Output(actStoreSku, false))
v.EarningPrice = actStoreSku.EarningPrice
if true { //v.StoreSubName != "" { // 之前这里为什么要加判断?
v.StoreSubID = actStoreSku.ActID
}
dao.UpdateEntity(db, storeMap, "CoverArea")
}
}
return retVal, err
}, storeMaps)
tasksch.HandleTask(task, nil, true).Run()
_, err = task.GetResult(0)
}
}
return err
}