This commit is contained in:
苏尹岚
2021-03-10 17:42:43 +08:00
parent a76e30bc35
commit acacc3b2de

View File

@@ -414,7 +414,13 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
dayCount = int(fromTimeT.Sub(toTimeT).Hours())/24 + 1 //查的几天
getStoreManageStateResult []*GetStoreManageStateResult
storeIDsPage []int
storeMapMaps map[int]*model.StoreMap
)
storeMapMaps = make(map[int]*model.StoreMap)
storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "")
for _, v := range storeMaps {
storeMapMaps[v.StoreID] = v
}
//权限
if permission.IsRoled(ctx) {
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
@@ -427,13 +433,11 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
}
} else {
for k, _ := range storeIDsMap {
storeDetail, _ := dao.GetStoreDetail(db, k, vendorID, "")
if storeDetail == nil || storeDetail.VendorStoreID == "" || storeDetail.VendorOrgCode == "" {
continue
}
if storeMapMaps[k] != nil {
storeIDs2 = append(storeIDs2, k)
}
}
}
storeIDs = nil
storeIDs = storeIDs2
}
@@ -443,12 +447,13 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
index2 = len(storeIDs) - 1
}
storeIDsPage = storeIDs[offset*pageSize : index2]
task := tasksch.NewParallelTask("GetStoreManageState", tasksch.NewParallelConfig().SetParallelCount(20).SetIsContinueWhenError(true), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
v := batchItemList[0].(int)
for _, v := range storeIDsPage {
// task := tasksch.NewParallelTask("GetStoreManageState", tasksch.NewParallelConfig().SetParallelCount(20).SetIsContinueWhenError(true), ctx,
// func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
// v := batchItemList[0].(int)
storeDetail, _ := dao.GetStoreDetail(db, v, vendorID, "")
if storeDetail == nil || storeDetail.VendorStoreID == "" || storeDetail.VendorOrgCode == "" {
return retVal, err
continue
}
result := &GetStoreManageStateResult{
StoreID: v,
@@ -460,14 +465,14 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
if result.CoverArea == 0 {
handler := partner.GetPurchasePlatformFromVendorID(vendorID)
if store, err := handler.ReadStore(ctx, storeDetail.VendorOrgCode, storeDetail.VendorStoreID); err == nil {
if storeMaps, err := dao.GetStoresMapList(db, []int{vendorID}, []int{v}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", ""); len(storeMaps) > 0 && err == nil {
if storeMapMaps[v] != nil {
if vendorID == model.VendorIDJD && store.DeliveryRangeType != model.DeliveryRangeTypePolygon {
storeMaps[0].CoverArea = math.Pi * utils.Str2Float64WithDefault(store.DeliveryRange, 0) * utils.Str2Float64WithDefault(store.DeliveryRange, 0) / float64(10000)
storeMapMaps[v].CoverArea = math.Pi * utils.Str2Float64WithDefault(store.DeliveryRange, 0) * utils.Str2Float64WithDefault(store.DeliveryRange, 0) / float64(10000)
} else {
storeMaps[0].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), vendorID)
storeMapMaps[v].CoverArea = CalculateCoverArea(strings.Split(store.DeliveryRange, ";"), vendorID)
}
dao.UpdateEntity(db, storeMaps[0], "CoverArea")
result.CoverArea = storeMaps[0].CoverArea
dao.UpdateEntity(db, storeMapMaps[v], "CoverArea")
result.CoverArea = storeMapMaps[v].CoverArea
}
}
}
@@ -492,7 +497,7 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
result.ActAmple = ample
//订单
refuseOrderCount := 0
orderList, err := dao.QueryOrdersForManageState(db, v, vendorID, model.OrderStatusCanceled, fromTimeT, toTimeT)
orderList, _ := dao.QueryOrdersForManageState(db, v, vendorID, model.OrderStatusCanceled, fromTimeT, toTimeT)
for _, v := range orderList {
if v.BindID == 0 {
refuseOrderCount++
@@ -506,14 +511,15 @@ func GetStoreManageState(ctx *jxcontext.Context, storeIDs []int, vendorID int, f
result.StoreScore = scoreResult.AvgPoiScore
}
}
retVal = []*GetStoreManageStateResult{result}
// retVal = []*GetStoreManageStateResult{result}
// getStoreManageStateResult = append(getStoreManageStateResult, result)
return retVal, err
}, storeIDsPage)
tasksch.HandleTask(task, nil, true).Run()
result, _ := task.GetResult(0)
for _, v := range result {
getStoreManageStateResult = append(getStoreManageStateResult, v.(*GetStoreManageStateResult))
// return retVal, err
// }, storeIDsPage)
// tasksch.HandleTask(task, nil, true).Run()
// result, _ := task.GetResult(0)
// for _, v := range result {
// getStoreManageStateResult = append(getStoreManageStateResult, v.(*GetStoreManageStateResult))
// }
}
return &model.PagedInfo{
TotalCount: len(storeIDs),