同步错误返回
This commit is contained in:
@@ -23,9 +23,12 @@ import (
|
|||||||
|
|
||||||
type SyncErrResult struct {
|
type SyncErrResult struct {
|
||||||
SkuID int `json:"商品ID"`
|
SkuID int `json:"商品ID"`
|
||||||
|
StoreID int `json:"门店ID"`
|
||||||
|
VendorID int `json:"平台ID"`
|
||||||
VendorSkuID string `json:"平台商品ID"`
|
VendorSkuID string `json:"平台商品ID"`
|
||||||
NameID int `json:"商品nameID"`
|
NameID int `json:"商品nameID"`
|
||||||
VendorPrice int64 `json:"平台价"`
|
VendorPrice int64 `json:"平台价"`
|
||||||
|
SyncType string `json:"同步类型"`
|
||||||
ErrMsg string `json:"错误信息"`
|
ErrMsg string `json:"错误信息"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,9 +74,12 @@ var (
|
|||||||
ErrEntityNotExist = errors.New("找不到相应实体")
|
ErrEntityNotExist = errors.New("找不到相应实体")
|
||||||
SyncErrResultTitle = []string{
|
SyncErrResultTitle = []string{
|
||||||
"商品ID",
|
"商品ID",
|
||||||
|
"门店ID",
|
||||||
|
"平台ID",
|
||||||
"平台商品ID",
|
"平台商品ID",
|
||||||
"商品nameID",
|
"商品nameID",
|
||||||
"平台价",
|
"平台价",
|
||||||
|
"同步类型",
|
||||||
"错误信息",
|
"错误信息",
|
||||||
}
|
}
|
||||||
syncErrResultLock SyncErrResultLock
|
syncErrResultLock SyncErrResultLock
|
||||||
@@ -760,9 +766,12 @@ func WirteToExcelBySyncFailed(task tasksch.ITask, ctx *jxcontext.Context) (err e
|
|||||||
for _, vv := range v.([]*partner.StoreSkuInfoWithErr) {
|
for _, vv := range v.([]*partner.StoreSkuInfoWithErr) {
|
||||||
result := SyncErrResult{
|
result := SyncErrResult{
|
||||||
SkuID: vv.StoreSkuInfo.SkuID,
|
SkuID: vv.StoreSkuInfo.SkuID,
|
||||||
|
StoreID: vv.StoreID,
|
||||||
|
VendorID: vv.VendoreID,
|
||||||
VendorSkuID: vv.StoreSkuInfo.VendorSkuID,
|
VendorSkuID: vv.StoreSkuInfo.VendorSkuID,
|
||||||
NameID: vv.StoreSkuInfo.NameID,
|
NameID: vv.StoreSkuInfo.NameID,
|
||||||
VendorPrice: vv.StoreSkuInfo.VendorPrice,
|
VendorPrice: vv.StoreSkuInfo.VendorPrice,
|
||||||
|
SyncType: vv.SyncType,
|
||||||
ErrMsg: vv.ErrMsg,
|
ErrMsg: vv.ErrMsg,
|
||||||
}
|
}
|
||||||
syncErrResultLock.AppendData(result)
|
syncErrResultLock.AppendData(result)
|
||||||
@@ -775,7 +784,7 @@ func WirteToExcelBySyncFailed(task tasksch.ITask, ctx *jxcontext.Context) (err e
|
|||||||
}
|
}
|
||||||
sheetList1 = append(sheetList1, excelConf1)
|
sheetList1 = append(sheetList1, excelConf1)
|
||||||
if excelConf1 != nil {
|
if excelConf1 != nil {
|
||||||
downloadURL1, fileName1, err = jxutils.UploadExeclAndPushMsg(sheetList1, time.Now().Format("2006-01-02")+"同步错误返回")
|
downloadURL1, fileName1, err = jxutils.UploadExeclAndPushMsg(sheetList1, time.Now().Format("200601021504")+"同步错误返回")
|
||||||
baseapi.SugarLogger.Debug("WriteToExcel: download is [%v]", downloadURL1)
|
baseapi.SugarLogger.Debug("WriteToExcel: download is [%v]", downloadURL1)
|
||||||
} else {
|
} else {
|
||||||
baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess is nil!")
|
baseapi.SugarLogger.Debug("WriteToExcel: dataSuccess is nil!")
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
|||||||
updateList = append(updateList, calVendorPrice4StoreSku(batchedStoreSkuList[0], storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
updateList = append(updateList, calVendorPrice4StoreSku(batchedStoreSkuList[0], storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||||
err = nil
|
err = nil
|
||||||
} else {
|
} else {
|
||||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(batchedStoreSkuList, err2)...)
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(batchedStoreSkuList, err2, storeID, vendorID, "查询是否有该商品")...)
|
||||||
}
|
}
|
||||||
if len(failedList) > 0 {
|
if len(failedList) > 0 {
|
||||||
task.AddErrMsg(failedList)
|
task.AddErrMsg(failedList)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
if globals.EnableEbaiStoreWrite {
|
if globals.EnableEbaiStoreWrite {
|
||||||
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), params)
|
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDEBAI, "更新商品基础信息")
|
||||||
}
|
}
|
||||||
utils.CallFuncAsync(func() {
|
utils.CallFuncAsync(func() {
|
||||||
api.EbaiAPI.SkuShopCategoryMap(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
api.EbaiAPI.SkuShopCategoryMap(strStoreID, utils.Str2Int64(storeSku.VendorSkuID), "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
||||||
@@ -141,7 +141,7 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
api.EbaiAPI.SkuShopCategoryMap(strStoreID, vendorSkuID, "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
api.EbaiAPI.SkuShopCategoryMap(strStoreID, vendorSkuID, "", utils.Str2Int64(storeSku.VendorCatID), genSkuCatRank(storeSku))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDEBAI, "创建商品")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vendorSkuID = jxutils.GenFakeID()
|
vendorSkuID = jxutils.GenFakeID()
|
||||||
@@ -164,7 +164,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
opResult, err2 := api.EbaiAPI.SkuDelete(ctx.GetTrackInfo(), utils.Int2Str(storeID), partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList(), nil)
|
opResult, err2 := api.EbaiAPI.SkuDelete(ctx.GetTrackInfo(), utils.Int2Str(storeID), partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList(), nil)
|
||||||
if err = err2; err2 != nil && opResult != nil {
|
if err = err2; err2 != nil && opResult != nil {
|
||||||
// if len(storeSkuList) > len(opResult.FailedList) {
|
// if len(storeSkuList) > len(opResult.FailedList) {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "删除商品")
|
||||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
|||||||
opResult, err = api.EbaiAPI.SkuOnline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
opResult, err = api.EbaiAPI.SkuOnline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||||
} else if len(vendorSkuIDs) == 1 {
|
} else if len(vendorSkuIDs) == 1 {
|
||||||
err = api.EbaiAPI.SkuOnlineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
err = api.EbaiAPI.SkuOnlineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDEBAI, "更新商品状态")
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -189,12 +189,12 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
|||||||
opResult, err = api.EbaiAPI.SkuOffline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
opResult, err = api.EbaiAPI.SkuOffline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||||
} else if len(vendorSkuIDs) == 1 {
|
} else if len(vendorSkuIDs) == 1 {
|
||||||
err = api.EbaiAPI.SkuOfflineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
err = api.EbaiAPI.SkuOfflineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDEBAI, "更新商品状态")
|
||||||
return failedList, err
|
return failedList, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil && opResult != nil {
|
if err != nil && opResult != nil {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品状态")
|
||||||
// failedList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
// failedList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,12 +219,12 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
if len(storeSkuList) > 1 {
|
if len(storeSkuList) > 1 {
|
||||||
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||||
if err = err2; err != nil && opResult != nil {
|
if err = err2; err != nil && opResult != nil {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||||
}
|
}
|
||||||
} else if len(storeSkuList) == 1 {
|
} else if len(storeSkuList) == 1 {
|
||||||
opResult2, err := api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
opResult2, err := api.EbaiAPI.SkuPriceUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||||
if err != nil && opResult2 != nil {
|
if err != nil && opResult2 != nil {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult2)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult2, storeID, model.VendorIDEBAI, "更新商品价格")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,12 +236,12 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
|||||||
if len(storeSkuList) > 1 {
|
if len(storeSkuList) > 1 {
|
||||||
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||||
if err = err2; err != nil && opResult != nil {
|
if err = err2; err != nil && opResult != nil {
|
||||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult, storeID, model.VendorIDEBAI, "更新商品库存")
|
||||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||||
}
|
}
|
||||||
} else if len(storeSkuList) == 1 {
|
} else if len(storeSkuList) == 1 {
|
||||||
err = api.EbaiAPI.SkuStockUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
err = api.EbaiAPI.SkuStockUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDEBAI, "更新商品库存")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return failedList, err
|
return failedList, err
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
|||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||||
if err = err2; isErrPartialFailed(err) {
|
if err = err2; isErrPartialFailed(err) {
|
||||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList, storeID, model.VendorIDJD, "更新商品状态")
|
||||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
if len(storeSkuList) == 1 {
|
if len(storeSkuList) == 1 {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
_, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
_, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDJD, "更新商品价格")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||||
@@ -146,7 +146,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
|
responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
|
||||||
if err = err2; isErrPartialFailed(err) {
|
if err = err2; isErrPartialFailed(err) {
|
||||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList, storeID, model.VendorIDJD, "更新商品价格")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
|||||||
if len(storeSkuList) == 1 {
|
if len(storeSkuList) == 1 {
|
||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDJD, "更新商品库存")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var skuStockList []*jdapi.SkuStock
|
var skuStockList []*jdapi.SkuStock
|
||||||
@@ -170,7 +170,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
|||||||
if globals.EnableJdStoreWrite {
|
if globals.EnableJdStoreWrite {
|
||||||
responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
|
responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||||
if err = err2; isErrPartialFailed(err) {
|
if err = err2; isErrPartialFailed(err) {
|
||||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList, storeID, model.VendorIDJD, "更新商品库存")
|
||||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,7 +234,13 @@ func (p *PurchaseHandler) CreateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
|
|
||||||
// 对于多门店平台来说,storeSkuList中只有SkuID与VendorSkuID有意义
|
// 对于多门店平台来说,storeSkuList中只有SkuID与VendorSkuID有意义
|
||||||
func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isCreate bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*dao.StoreSkuSyncInfo, isCreate bool) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||||
|
var syncType string
|
||||||
foodDataList := make([]map[string]interface{}, len(storeSkuList))
|
foodDataList := make([]map[string]interface{}, len(storeSkuList))
|
||||||
|
if isCreate {
|
||||||
|
syncType = "创建商品"
|
||||||
|
} else {
|
||||||
|
syncType = "更新商品"
|
||||||
|
}
|
||||||
for i, storeSku := range storeSkuList {
|
for i, storeSku := range storeSkuList {
|
||||||
isNeedUpdatePrice := isCreate //storeSku.StoreSkuSyncStatus&( model.SyncFlagPriceMask| model.SyncFlagNewMask) != 0
|
isNeedUpdatePrice := isCreate //storeSku.StoreSkuSyncStatus&( model.SyncFlagPriceMask| model.SyncFlagNewMask) != 0
|
||||||
foodData := make(map[string]interface{})
|
foodData := make(map[string]interface{})
|
||||||
@@ -294,12 +300,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
|||||||
if len(foodDataList) == 1 {
|
if len(foodDataList) == 1 {
|
||||||
foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"]))
|
foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"]))
|
||||||
err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDMTWM, syncType)
|
||||||
} else if len(foodDataList) > 0 {
|
} else if len(foodDataList) > 0 {
|
||||||
failedFoodList, err2 := api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
failedFoodList, err2 := api.MtwmAPI.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, syncType)
|
||||||
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,7 +331,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
if globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
if len(storeSkuList) == 1 {
|
if len(storeSkuList) == 1 {
|
||||||
err = api.MtwmAPI.RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID)
|
err = api.MtwmAPI.RetailDelete(ctx.GetTrackInfo(), vendorStoreID, storeSkuList[0].VendorSkuID)
|
||||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err, storeID, model.VendorIDMTWM, "删除商品")
|
||||||
} else {
|
} else {
|
||||||
// todo 部分失败
|
// todo 部分失败
|
||||||
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, nil, nil, nil, nil, partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDList())
|
err = api.MtwmAPI.RetailCatSkuBatchDelete2(ctx.GetTrackInfo(), vendorStoreID, nil, nil, nil, nil, partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDList())
|
||||||
@@ -333,7 +339,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
|||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
myMap := make(map[string][]*mtwmapi.AppFoodResult)
|
myMap := make(map[string][]*mtwmapi.AppFoodResult)
|
||||||
json.Unmarshal([]byte(errExt.ErrMsg()), &myMap)
|
json.Unmarshal([]byte(errExt.ErrMsg()), &myMap)
|
||||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, myMap["retail_error_list"])
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, myMap["retail_error_list"], storeID, model.VendorIDMTWM, "批量删除商品")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +380,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
|||||||
failedFoodList, err2 := api.MtwmAPI.RetailSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
failedFoodList, err2 := api.MtwmAPI.RetailSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if len(failedFoodList) > 0 {
|
if len(failedFoodList) > 0 {
|
||||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品状态")
|
||||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -388,7 +394,7 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
|||||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if len(failedFoodList) > 0 {
|
if len(failedFoodList) > 0 {
|
||||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品价格")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,7 +407,7 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
|||||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(ctx.GetTrackInfo(), vendorStoreID, stockList)
|
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(ctx.GetTrackInfo(), vendorStoreID, stockList)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
if len(failedFoodList) > 0 {
|
if len(failedFoodList) > 0 {
|
||||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList, storeID, model.VendorIDMTWM, "更新商品库存")
|
||||||
}
|
}
|
||||||
// if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
// if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ func UnselectStoreSkuListByVendorSkuIDs(storeSkuList []*partner.StoreSkuInfo, ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
//美团api返回
|
//美团api返回
|
||||||
func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.AppFoodResult, storeID, vendorID int, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||||
foodMap := make(map[string]string)
|
foodMap := make(map[string]string)
|
||||||
if len(foodList) > 0 {
|
if len(foodList) > 0 {
|
||||||
for _, v := range foodList {
|
for _, v := range foodList {
|
||||||
@@ -249,6 +249,9 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
|
|||||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: v,
|
StoreSkuInfo: v,
|
||||||
ErrMsg: foodMap[v.VendorSkuID],
|
ErrMsg: foodMap[v.VendorSkuID],
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||||
}
|
}
|
||||||
@@ -268,6 +271,9 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
|
|||||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuInfo,
|
StoreSkuInfo: storeSkuInfo,
|
||||||
ErrMsg: foodMap[v.VendorSkuID],
|
ErrMsg: foodMap[v.VendorSkuID],
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||||
}
|
}
|
||||||
@@ -278,7 +284,7 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
|
|||||||
}
|
}
|
||||||
|
|
||||||
//饿百api返回
|
//饿百api返回
|
||||||
func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult *ebaiapi.BatchOpResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult *ebaiapi.BatchOpResult, storeID, vendorID int, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||||
opResultMap := make(map[int64]string)
|
opResultMap := make(map[int64]string)
|
||||||
if len(opResult.FailedList) > 0 {
|
if len(opResult.FailedList) > 0 {
|
||||||
for _, v := range opResult.FailedList {
|
for _, v := range opResult.FailedList {
|
||||||
@@ -289,6 +295,9 @@ func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult
|
|||||||
opFailed := &partner.StoreSkuInfoWithErr{
|
opFailed := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: v,
|
StoreSkuInfo: v,
|
||||||
ErrMsg: opResultMap[utils.Str2Int64(v.VendorSkuID)],
|
ErrMsg: opResultMap[utils.Str2Int64(v.VendorSkuID)],
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
selectedStoreSkuList = append(selectedStoreSkuList, opFailed)
|
selectedStoreSkuList = append(selectedStoreSkuList, opFailed)
|
||||||
}
|
}
|
||||||
@@ -298,7 +307,7 @@ func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
//京东api返回
|
//京东api返回
|
||||||
func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, responseList []*jdapi.StoreSkuBatchUpdateResponse) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, responseList []*jdapi.StoreSkuBatchUpdateResponse, storeID, vendorID int, syncType string) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||||
responseMap := make(map[string]string)
|
responseMap := make(map[string]string)
|
||||||
if len(responseList) > 0 {
|
if len(responseList) > 0 {
|
||||||
for _, v := range responseList {
|
for _, v := range responseList {
|
||||||
@@ -311,6 +320,9 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
|
|||||||
respFailed := &partner.StoreSkuInfoWithErr{
|
respFailed := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: v,
|
StoreSkuInfo: v,
|
||||||
ErrMsg: responseMap[utils.Int2Str(v.SkuID)],
|
ErrMsg: responseMap[utils.Int2Str(v.SkuID)],
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
selectedStoreSkuList = append(selectedStoreSkuList, respFailed)
|
selectedStoreSkuList = append(selectedStoreSkuList, respFailed)
|
||||||
}
|
}
|
||||||
@@ -319,13 +331,16 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
|
|||||||
return selectedStoreSkuList
|
return selectedStoreSkuList
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error) (failedList []*partner.StoreSkuInfoWithErr) {
|
func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error, storeID, vendorID int, syncType string) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuLists[0],
|
StoreSkuInfo: storeSkuLists[0],
|
||||||
ErrMsg: errExt.ErrMsg(),
|
ErrMsg: errExt.ErrMsg(),
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
}
|
}
|
||||||
@@ -341,6 +356,9 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error) (failedList
|
|||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuInfo,
|
StoreSkuInfo: storeSkuInfo,
|
||||||
ErrMsg: errExt.ErrMsg(),
|
ErrMsg: errExt.ErrMsg(),
|
||||||
|
StoreID: storeID,
|
||||||
|
VendoreID: vendorID,
|
||||||
|
SyncType: syncType,
|
||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user