1
This commit is contained in:
@@ -906,39 +906,54 @@ type SetBoxPrice struct {
|
||||
BoxPrice float64 `json:"box_price"` // 打包价格
|
||||
}
|
||||
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []*SetBoxPrice) error {
|
||||
storeDetail, err := dao.GetStoreDetail(db, list[0].StoreId, model.VendorIDMTWM, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//storeSkuList, err := dao.GetStoresSkusInfo(db, []int{list[0].StoreId}, nil)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
api := getAPI(storeDetail.VendorOrgCode, list[0].StoreId, storeDetail.VendorStoreID)
|
||||
foodDataList := make([]map[string]interface{}, 0)
|
||||
func UpdateBoxPrice(ctx *jxcontext.Context, db *dao.DaoDB, list []int) error {
|
||||
for _, v := range list {
|
||||
storeDetail, err := dao.GetStoreDetail(db, v, model.VendorIDMTWM, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
foodDataList = append(foodDataList, map[string]interface{}{
|
||||
"app_spu_code": utils.Int2Str(v.SkuId),
|
||||
"skus": []map[string]interface{}{
|
||||
{
|
||||
"sku_id": utils.Int2Str(v.SkuId),
|
||||
"ladder_box_num": "1",
|
||||
"ladder_box_price": utils.Float64ToStr(v.BoxPrice),
|
||||
skuList, err := dao.GetStoreSkuBindList(db, v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(skuList) == model.NO {
|
||||
continue
|
||||
}
|
||||
|
||||
foodDataList := make([]map[string]interface{}, 0)
|
||||
for _, sl := range skuList {
|
||||
foodDataList = append(foodDataList, map[string]interface{}{
|
||||
"app_spu_code": utils.Int2Str(sl.SkuID),
|
||||
"skus": []map[string]interface{}{
|
||||
{
|
||||
"sku_id": utils.Int2Str(sl.SkuID),
|
||||
"ladder_box_num": "0",
|
||||
"ladder_box_price": "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
count := utils.Float64TwoInt(math.Ceil(float64(len(foodDataList)) / float64(50)))
|
||||
for i := 1; i <= count; i++ {
|
||||
if i == count {
|
||||
_, _ = api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*50:])
|
||||
} else {
|
||||
_, _ = api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*50:i*50])
|
||||
})
|
||||
}
|
||||
count := utils.Float64TwoInt(math.Ceil(float64(len(foodDataList)) / float64(200)))
|
||||
api := getAPI(storeDetail.VendorOrgCode, v, storeDetail.VendorStoreID)
|
||||
for i := 1; i <= count; i++ {
|
||||
if i == count {
|
||||
result, err := api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*200:])
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData1 err := %v", err)
|
||||
}
|
||||
if result != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData1 result := %s", utils.Format4Output(result, false))
|
||||
}
|
||||
} else {
|
||||
result, err := api.RetailBatchInitData(ctx.GetTrackInfo(), storeDetail.VendorStoreID, foodDataList[(i-1)*200:i*200])
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData2 err := %v", err)
|
||||
}
|
||||
if result != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData1 result := %s", utils.Format4Output(result, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user