同步错误返回
This commit is contained in:
@@ -102,7 +102,7 @@ func tryCatName2Code(originName string) (catCodeStr string) {
|
||||
return catCodeStr
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
level := 1
|
||||
if storeCat.ParentCatName != "" {
|
||||
level = 2
|
||||
@@ -151,27 +151,24 @@ func (p *PurchaseHandler) CreateStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
Sequence: storeCat.Seq,
|
||||
}
|
||||
err = api.MtwmAPI.RetailCatUpdate(vendorStoreID, catName, param4Update)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDMTWM, "创建修改分类")
|
||||
}
|
||||
if storeCat.CatSyncStatus&model.SyncFlagNewMask == 0 && // 修改分类名,但分类不存在
|
||||
p.IsErrCategoryNotExist(err) && originName != "" {
|
||||
storeCat.CatSyncStatus |= model.SyncFlagNewMask
|
||||
failedList, err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
err = p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
// storeCat.VendorCatID = utils.FilterEmoji(storeCat.Name)
|
||||
storeCat.VendorCatID = utils.Int2Str(storeCat.ID)
|
||||
}
|
||||
return failedList, err
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeCat *dao.SkuStoreCatInfo) (err error) {
|
||||
return p.CreateStoreCategory(ctx, storeID, vendorStoreID, storeCat)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID int, vendorStoreID, vendorCatID string, level int) (err error) {
|
||||
if false {
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
err = api.MtwmAPI.RetailCatDelete(vendorStoreID, tryCatName2Code(vendorCatID), vendorCatID)
|
||||
@@ -187,12 +184,9 @@ func (p *PurchaseHandler) DeleteStoreCategory(ctx *jxcontext.Context, storeID in
|
||||
} else {
|
||||
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, nil, nil, catCodes, []string{vendorCatID}, nil)
|
||||
}
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSingleList(nil, err, storeID, model.VendorIDMTWM, "删除分类")
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
return err
|
||||
}
|
||||
|
||||
// 门店商品
|
||||
@@ -313,7 +307,7 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||
if err = err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, syncType)
|
||||
failedList = SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, syncType)
|
||||
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
@@ -347,7 +341,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
myMap := make(map[string][]*mtwmapi.AppFoodResult)
|
||||
json.Unmarshal([]byte(errExt.ErrMsg()), &myMap)
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, myMap["retail_error_list"], storeID, model.VendorIDMTWM, "批量删除商品")
|
||||
failedList = SelectStoreSkuListByFoodList(storeSkuList, myMap["retail_error_list"], storeID, model.VendorIDMTWM, "批量删除商品")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +382,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, vendorOr
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品状态")
|
||||
failedList = SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品状态")
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
@@ -402,7 +396,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, vendorOrg
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品价格")
|
||||
failedList = SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品价格")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +409,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, vendorOrg
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(ctx.GetTrackInfo(), vendorStoreID, stockList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品库存")
|
||||
failedList = SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品库存")
|
||||
}
|
||||
//if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
@@ -533,3 +527,50 @@ func vendorSkuList2Jx(appFoodList []*mtwmapi.AppFood) (skuNameList []*partner.Sk
|
||||
func (p *PurchaseHandler) GetSensitiveWordRegexp() *regexp.Regexp {
|
||||
return sensitiveWordRegexp
|
||||
}
|
||||
|
||||
//美团api返回
|
||||
func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.AppFoodResult, storeID, vendorID int, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
foodMap := make(map[string]string)
|
||||
if len(foodList) > 0 {
|
||||
for _, v := range foodList {
|
||||
foodMap[v.AppFoodCode] = v.ErrorMsg
|
||||
}
|
||||
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||
for _, v := range storeSkuLists {
|
||||
if foodMap[v.VendorSkuID] != "" {
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
StoreID: storeID,
|
||||
VendoreID: vendorID,
|
||||
SyncType: syncType,
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||
for _, v := range storeSkuLists {
|
||||
if foodMap[v.VendorSkuID] != "" {
|
||||
storeSkuInfo := &partner.StoreSkuInfo{
|
||||
SkuID: v.SkuID,
|
||||
VendorSkuID: v.VendorSkuID,
|
||||
NameID: v.NameID,
|
||||
VendorNameID: v.VendorNameID,
|
||||
VendorPrice: v.VendorPrice,
|
||||
Status: v.Status,
|
||||
}
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuInfo,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
StoreID: storeID,
|
||||
VendoreID: vendorID,
|
||||
SyncType: syncType,
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user