修改桑葚上传配置
This commit is contained in:
@@ -3,11 +3,14 @@ package cms
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"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/purchase/mtwm"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -54,20 +57,28 @@ func CopyOnStoreSkuToOther(ctx *jxcontext.Context, fromStoreId, toStoreId int, i
|
||||
return nil, err
|
||||
}
|
||||
if v.Children != nil && len(v.Children) != 0 {
|
||||
//for _, c := range v.Children {
|
||||
// if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
// CategoryCode: v.Code,
|
||||
// Sequence: v.Sequence,
|
||||
// }); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//}
|
||||
for _, c := range v.Children {
|
||||
if err := toApi.RetailCatUpdate(toStore.VendorStoreID, v.Name, &mtwmapi.Param4UpdateCat{
|
||||
CategoryCode: v.Code,
|
||||
SecondaryCategoryCode: c.Code,
|
||||
SecondaryCategoryName: c.Name,
|
||||
Sequence: c.Sequence,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case 3:
|
||||
// 同步商品
|
||||
|
||||
fromFoodList, err1 := fromApi.RetailListAll(fromStore.VendorStoreID)
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
}
|
||||
if err := BatchInitData(ctx, fromFoodList, toApi, toStore.VendorStoreID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -103,6 +114,45 @@ func LoadingStoreSkuList(ctx *jxcontext.Context, api *mtwmapi.API, poiCode strin
|
||||
return
|
||||
}
|
||||
|
||||
func LoadStoreCategoryList() {
|
||||
// BatchInitData 批量创建商品
|
||||
func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string) error {
|
||||
foodDataList := make([]map[string]interface{}, len(fromSku))
|
||||
for i, storeSku := range fromSku {
|
||||
foodData := make(map[string]interface{})
|
||||
foodDataList[i] = foodData
|
||||
foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode
|
||||
foodData["skus"] = storeSku.Skus
|
||||
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount)
|
||||
foodData["description"] = storeSku.Description
|
||||
foodData["price"] = storeSku.Price
|
||||
if storeSku.MinOrderCount != 0 {
|
||||
foodData["min_order_count"] = storeSku.MinOrderCount
|
||||
} else {
|
||||
foodData["min_order_count"] = 1
|
||||
}
|
||||
foodData["unit"] = storeSku.Unit
|
||||
attr := mtwm.SwitchAttr(int64(storeSku.TagID))
|
||||
if attr != "" {
|
||||
foodData["common_attr_value"] = attr
|
||||
}
|
||||
foodData["category_code"] = storeSku.CategoryCode
|
||||
foodData["category_name"] = storeSku.CategoryName
|
||||
foodData["is_sold_out"] = storeSku.IsSoldOut
|
||||
foodData["picture"] = storeSku.Picture
|
||||
foodData["picture_contents"] = storeSku.PictureContents
|
||||
foodData["sequence"] = storeSku.Sequence
|
||||
foodData["tag_id"] = storeSku.TagID
|
||||
}
|
||||
|
||||
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||
if err := err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err2 != nil && len(failedFoodList) == 0 {
|
||||
if errExt, ok := err2.(*utils.ErrorWithCode); ok {
|
||||
return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
foodData["min_order_count"] = 1
|
||||
}
|
||||
foodData["unit"] = storeSku.Unit
|
||||
attr := switchAttr(storeSku.VendorVendorCatID)
|
||||
attr := SwitchAttr(storeSku.VendorVendorCatID)
|
||||
if attr != "" {
|
||||
foodData["common_attr_value"] = attr
|
||||
}
|
||||
@@ -452,7 +452,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func switchAttr(vendorCatID int64) (attrs string) {
|
||||
func SwitchAttr(vendorCatID int64) (attrs string) {
|
||||
switch vendorCatID {
|
||||
case 200002727:
|
||||
return mtwmapi.MtwmSkuAttr200002727
|
||||
|
||||
Reference in New Issue
Block a user