同步错误返回
This commit is contained in:
@@ -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)))
|
||||
err = nil
|
||||
} else {
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSyncSingleList(batchedStoreSkuList, err2)...)
|
||||
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(batchedStoreSkuList, err2)...)
|
||||
}
|
||||
if len(failedList) > 0 {
|
||||
task.AddErrMsg(failedList)
|
||||
|
||||
@@ -45,6 +45,9 @@ type StoreSkuInfo struct {
|
||||
|
||||
type StoreSkuInfoWithErr struct {
|
||||
StoreSkuInfo *StoreSkuInfo
|
||||
VendoreID int
|
||||
StoreID int
|
||||
SyncType string
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ func (p *PurchaseHandler) UpdateStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
_, err = api.EbaiAPI.SkuUpdate(ctx.GetTrackInfo(), strStoreID, utils.Str2Int64(storeSku.VendorSkuID), params)
|
||||
if err != nil {
|
||||
failedList = putils.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
utils.CallFuncAsync(func() {
|
||||
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))
|
||||
})
|
||||
} else {
|
||||
failedList = putils.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
} else {
|
||||
vendorSkuID = jxutils.GenFakeID()
|
||||
|
||||
@@ -294,12 +294,12 @@ func (p *PurchaseHandler) createOrUpdateStoreSkus(ctx *jxcontext.Context, storeI
|
||||
if len(foodDataList) == 1 {
|
||||
foodDataList[0]["skus"] = string(utils.MustMarshal(foodDataList[0]["skus"]))
|
||||
err = api.MtwmAPI.RetailInitData(ctx.GetTrackInfo(), vendorStoreID, utils.Int2Str(storeSkuList[0].SkuID), foodDataList[0])
|
||||
failedList = putils.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
} else if len(foodDataList) > 0 {
|
||||
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.SelectStoreSynSkuByFoodList(storeSkuList, failedFoodList)
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,47 +237,40 @@ func UnselectStoreSkuListByVendorSkuIDs(storeSkuList []*partner.StoreSkuInfo, ve
|
||||
}
|
||||
|
||||
//美团api返回
|
||||
func SelectStoreSkuListByFoodList(storeSkuList []*partner.StoreSkuInfo, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
foodMap := make(map[string]string)
|
||||
if len(foodList) > 0 {
|
||||
for _, v := range foodList {
|
||||
foodMap[v.AppFoodCode] = v.ErrorMsg
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
if foodMap[v.VendorSkuID] != "" {
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||
for _, v := range storeSkuLists {
|
||||
if foodMap[v.VendorSkuID] != "" {
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
//美团api返回
|
||||
func SelectStoreSynSkuByFoodList(storeSkuList []*dao.StoreSkuSyncInfo, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
foodMap := make(map[string]string)
|
||||
if len(foodList) > 0 {
|
||||
for _, v := range foodList {
|
||||
foodMap[v.AppFoodCode] = v.ErrorMsg
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
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,
|
||||
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],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuInfo,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,35 +319,31 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
func GetErrMsg2FailedSingleList(storeSkuList []*partner.StoreSkuInfo, err error) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||
func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||
if err != nil {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuList[0],
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuLists[0],
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
}
|
||||
return failedList
|
||||
}
|
||||
|
||||
func GetErrMsg2FailedSyncSingleList(storeSkuList []*dao.StoreSkuSyncInfo, err error) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||
if err != nil {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
storeSkuInfo := &partner.StoreSkuInfo{
|
||||
SkuID: storeSkuList[0].SkuID,
|
||||
VendorSkuID: storeSkuList[0].VendorSkuID,
|
||||
NameID: storeSkuList[0].NameID,
|
||||
VendorNameID: storeSkuList[0].VendorNameID,
|
||||
VendorPrice: storeSkuList[0].VendorPrice,
|
||||
Status: storeSkuList[0].Status,
|
||||
if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||
storeSkuInfo := &partner.StoreSkuInfo{
|
||||
SkuID: storeSkuLists[0].SkuID,
|
||||
VendorSkuID: storeSkuLists[0].VendorSkuID,
|
||||
NameID: storeSkuLists[0].NameID,
|
||||
VendorNameID: storeSkuLists[0].VendorNameID,
|
||||
VendorPrice: storeSkuLists[0].VendorPrice,
|
||||
Status: storeSkuLists[0].Status,
|
||||
}
|
||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuInfo,
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuInfo,
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
}
|
||||
failedList = append(failedList, storeSkuInfoWithErr)
|
||||
}
|
||||
}
|
||||
return failedList
|
||||
|
||||
Reference in New Issue
Block a user