1
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"git.rosy.net.cn/jx-callback/business/partner"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/mtwm"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -78,18 +77,26 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// 同步商品
|
i := 0
|
||||||
fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId))
|
for {
|
||||||
if len(fromFoodList) == 0 || fromFoodList == nil {
|
// 同步商品
|
||||||
return nil, fmt.Errorf("fromFoodList 为空")
|
fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i)
|
||||||
}
|
if len(fromFoodList) == 0 || fromFoodList == nil {
|
||||||
globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false))
|
return nil, fmt.Errorf("fromFoodList 为空")
|
||||||
if err1 != nil {
|
}
|
||||||
globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false))
|
globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(len(fromFoodList), false))
|
||||||
}
|
if err1 != nil {
|
||||||
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil {
|
globals.SugarLogger.Debugf("RetailListAll : %s", utils.Format4Output(err, false))
|
||||||
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
|
}
|
||||||
|
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
|
||||||
|
}
|
||||||
|
if len(fromFoodList) < 200 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -105,7 +112,7 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
|
|||||||
}
|
}
|
||||||
|
|
||||||
func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode string) (err []error) {
|
func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode string) (err []error) {
|
||||||
foodList, err1 := api.RetailListAll(poiCode)
|
foodList, err1 := api.RetailListAll(poiCode, 0)
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
return append(err, err1)
|
return append(err, err1)
|
||||||
}
|
}
|
||||||
@@ -156,7 +163,7 @@ type Skus struct {
|
|||||||
|
|
||||||
// BatchInitData 批量创建商品
|
// BatchInitData 批量创建商品
|
||||||
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error {
|
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error {
|
||||||
globals.SugarLogger.Debugf("===========[] %s", utils.Format4Output(fromSku[0], false))
|
globals.SugarLogger.Debugf("===========[] %d", len(fromSku))
|
||||||
foodDataList := make([]map[string]interface{}, len(fromSku))
|
foodDataList := make([]map[string]interface{}, len(fromSku))
|
||||||
for i, storeSku := range fromSku {
|
for i, storeSku := range fromSku {
|
||||||
foodData := make(map[string]interface{})
|
foodData := make(map[string]interface{})
|
||||||
@@ -178,10 +185,10 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
|||||||
foodData["min_order_count"] = storeSku.MinOrderCount
|
foodData["min_order_count"] = storeSku.MinOrderCount
|
||||||
foodData["unit"] = storeSku.Unit
|
foodData["unit"] = storeSku.Unit
|
||||||
//todo 增加商品必填属性
|
//todo 增加商品必填属性
|
||||||
attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name)
|
//attr := mtwm.SwitchAttr(toApi, vendorStoreID, int64(storeSku.TagID), 0, storeSku.Name)
|
||||||
if attr != "" {
|
//if attr != "" {
|
||||||
foodData["common_attr_value"] = attr
|
foodData["common_attr_value"] = storeSku.CommonAttrValue
|
||||||
}
|
//}
|
||||||
if storeSku.SecondaryCategoryCode != "" {
|
if storeSku.SecondaryCategoryCode != "" {
|
||||||
foodData["category_code"] = storeSku.SecondaryCategoryCode
|
foodData["category_code"] = storeSku.SecondaryCategoryCode
|
||||||
} else {
|
} else {
|
||||||
@@ -257,7 +264,7 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
|||||||
if len(foodDataList)%5 != 0 {
|
if len(foodDataList)%5 != 0 {
|
||||||
count += 1
|
count += 1
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debugf("===========[count] %d", count)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
if i == count-1 {
|
if i == count-1 {
|
||||||
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:])
|
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:])
|
||||||
|
|||||||
Reference in New Issue
Block a user