1'
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package cms
|
package cms
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
beego "github.com/astaxie/beego/server/web"
|
beego "github.com/astaxie/beego/server/web"
|
||||||
@@ -52,49 +51,49 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromVendorStoreId, toStoreId
|
|||||||
//}
|
//}
|
||||||
case 2:
|
case 2:
|
||||||
// 同步分类
|
// 同步分类
|
||||||
fromCategoryList, err := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId))
|
//fromCategoryList, err := fromApi.RetailCatList(utils.Int2Str(fromVendorStoreId))
|
||||||
globals.SugarLogger.Debugf("err ============ %v", err)
|
//globals.SugarLogger.Debugf("err ============ %v", err)
|
||||||
for _, v := range fromCategoryList {
|
//for _, v := range fromCategoryList {
|
||||||
categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
// categoryErr := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||||
CategoryCode: v.Code,
|
// CategoryCode: v.Code,
|
||||||
Sequence: v.Sequence,
|
// Sequence: v.Sequence,
|
||||||
})
|
// })
|
||||||
if categoryErr != nil {
|
// if categoryErr != nil {
|
||||||
globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
// globals.SugarLogger.Debugf("err := RetailCatUpdate : %v", categoryErr)
|
||||||
}
|
// }
|
||||||
if v.Children != nil && len(v.Children) != 0 {
|
// if v.Children != nil && len(v.Children) != 0 {
|
||||||
for _, c := range v.Children {
|
// for _, c := range v.Children {
|
||||||
if err3 := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
// if err3 := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||||
CategoryNameOrigin: v.Name,
|
// CategoryNameOrigin: v.Name,
|
||||||
//CategoryCodeOrigin: v.Code,
|
// //CategoryCodeOrigin: v.Code,
|
||||||
//CategoryCode: v.Code,
|
// //CategoryCode: v.Code,
|
||||||
SecondaryCategoryCode: c.Code,
|
// SecondaryCategoryCode: c.Code,
|
||||||
SecondaryCategoryName: c.Name,
|
// SecondaryCategoryName: c.Name,
|
||||||
Sequence: c.Sequence,
|
// Sequence: c.Sequence,
|
||||||
}); err3 != nil {
|
// }); err3 != nil {
|
||||||
globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err3)
|
// globals.SugarLogger.Debugf("err := RetailCatUpdate Children : %v", err3)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
//i := offSet
|
i := offSet
|
||||||
//for {
|
for {
|
||||||
// // 同步商品
|
// 同步商品
|
||||||
// fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i)
|
fromFoodList, err1 := fromApi.RetailListAll(utils.Int2Str(fromVendorStoreId), i)
|
||||||
// if len(fromFoodList) == 0 || fromFoodList == nil {
|
if len(fromFoodList) == 0 || fromFoodList == nil {
|
||||||
// return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
|
return nil, fmt.Errorf("fromFoodList 为空 %s ,i:= %d", utils.Format4Output(err1, false), i)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID, i); err != nil {
|
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID, i); err != nil {
|
||||||
// globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
|
globals.SugarLogger.Debugf("BatchInitData : %s", utils.Format4Output(err, false))
|
||||||
// }
|
}
|
||||||
// if len(fromFoodList) < 100 {
|
if len(fromFoodList) < 100 {
|
||||||
// break
|
break
|
||||||
// }
|
}
|
||||||
// i++
|
i++
|
||||||
//}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -171,12 +170,12 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
|||||||
foodData[mtwmapi.KeyAppFoodCode] = time.Now().UnixNano() + int64(i*3)
|
foodData[mtwmapi.KeyAppFoodCode] = time.Now().UnixNano() + int64(i*3)
|
||||||
}
|
}
|
||||||
|
|
||||||
skus := []map[string]interface{}{
|
//skus := []map[string]interface{}{
|
||||||
map[string]interface{}{
|
// map[string]interface{}{
|
||||||
"sku_id": foodData[mtwmapi.KeyAppFoodCode],
|
// "sku_id": foodData[mtwmapi.KeyAppFoodCode],
|
||||||
},
|
// },
|
||||||
}
|
//}
|
||||||
foodData["skus"] = skus
|
foodData["skus"] = storeSku.SkuList
|
||||||
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount)
|
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount)
|
||||||
foodData["description"] = storeSku.Description
|
foodData["description"] = storeSku.Description
|
||||||
foodData["price"] = storeSku.Price
|
foodData["price"] = storeSku.Price
|
||||||
@@ -207,29 +206,29 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
|||||||
foodData["sequence"] = storeSku.Sequence
|
foodData["sequence"] = storeSku.Sequence
|
||||||
foodData["tag_id"] = storeSku.TagID
|
foodData["tag_id"] = storeSku.TagID
|
||||||
|
|
||||||
skusAttr := make([]*Skus, 0, 0)
|
//skusAttr := make([]*Skus, 0, 0)
|
||||||
if err := json.Unmarshal([]byte(storeSku.Skus), &skusAttr); err != nil {
|
//if err := json.Unmarshal([]byte(storeSku.Skus), &skusAttr); err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
//}
|
||||||
//skus2 := make([]*Skus, 0, 0)
|
////skus2 := make([]*Skus, 0, 0)
|
||||||
for i2 := 0; i2 < len(skusAttr); i2++ {
|
//for i2 := 0; i2 < len(skusAttr); i2++ {
|
||||||
if skusAttr[i2].Weight != "" && skusAttr[i2].WeightForUnit != "" {
|
// if skusAttr[i2].Weight != "" && skusAttr[i2].WeightForUnit != "" {
|
||||||
skusAttr[i2].WeightForUnit = ""
|
// skusAttr[i2].WeightForUnit = ""
|
||||||
}
|
// }
|
||||||
//skus2 = append(skus2, skusAttr[i2])
|
// //skus2 = append(skus2, skusAttr[i2])
|
||||||
skus[0]["spec"] = skusAttr[i2].Spec
|
// skus[0]["spec"] = skusAttr[i2].Spec
|
||||||
skus[0]["price"] = skusAttr[i2].Price
|
// skus[0]["price"] = skusAttr[i2].Price
|
||||||
skus[0]["stock"] = skusAttr[i2].Stock
|
// skus[0]["stock"] = skusAttr[i2].Stock
|
||||||
if skusAttr[i2].Upc != "" {
|
// if skusAttr[i2].Upc != "" {
|
||||||
skus[0]["upc"] = skusAttr[i2].Upc
|
// skus[0]["upc"] = skusAttr[i2].Upc
|
||||||
}
|
// }
|
||||||
skus[0]["ladder_box_num"] = skusAttr[i2].LadderBoxNum
|
// skus[0]["ladder_box_num"] = skusAttr[i2].LadderBoxNum
|
||||||
skus[0]["ladder_box_price"] = skusAttr[i2].BoxPrice
|
// skus[0]["ladder_box_price"] = skusAttr[i2].BoxPrice
|
||||||
if foodData["tag_id"] != nil {
|
// if foodData["tag_id"] != nil {
|
||||||
skus[0]["weight"] = skusAttr[i2].Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
// skus[0]["weight"] = skusAttr[i2].Weight // weight字段仅限服饰鞋帽、美妆、日用品、母婴、生鲜果蔬、生活超市下的便利店/超市门店品类的商家使用
|
||||||
}
|
// }
|
||||||
break
|
// break
|
||||||
}
|
//}
|
||||||
foodDataList[i] = foodData
|
foodDataList[i] = foodData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user