同步错误返回
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)))
|
updateList = append(updateList, calVendorPrice4StoreSku(batchedStoreSkuList[0], storeDetail.PricePercentagePackObj, int(storeDetail.PricePercentage)))
|
||||||
err = nil
|
err = nil
|
||||||
} else {
|
} else {
|
||||||
failedList = append(failedList, putils.GetErrMsg2FailedSyncSingleList(batchedStoreSkuList, err2)...)
|
failedList = append(failedList, putils.GetErrMsg2FailedSingleList(batchedStoreSkuList, err2)...)
|
||||||
}
|
}
|
||||||
if len(failedList) > 0 {
|
if len(failedList) > 0 {
|
||||||
task.AddErrMsg(failedList)
|
task.AddErrMsg(failedList)
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ type StoreSkuInfo struct {
|
|||||||
|
|
||||||
type StoreSkuInfoWithErr struct {
|
type StoreSkuInfoWithErr struct {
|
||||||
StoreSkuInfo *StoreSkuInfo
|
StoreSkuInfo *StoreSkuInfo
|
||||||
|
VendoreID int
|
||||||
|
StoreID int
|
||||||
|
SyncType string
|
||||||
ErrMsg string
|
ErrMsg string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||||
}
|
}
|
||||||
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.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
vendorSkuID = jxutils.GenFakeID()
|
vendorSkuID = jxutils.GenFakeID()
|
||||||
|
|||||||
@@ -294,12 +294,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.GetErrMsg2FailedSyncSingleList(storeSkuList, err)
|
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||||
} 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.SelectStoreSynSkuByFoodList(storeSkuList, failedFoodList)
|
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||||
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
// successList = putils.UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,13 +237,14 @@ func UnselectStoreSkuListByVendorSkuIDs(storeSkuList []*partner.StoreSkuInfo, ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
//美团api返回
|
//美团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)
|
foodMap := make(map[string]string)
|
||||||
if len(foodList) > 0 {
|
if len(foodList) > 0 {
|
||||||
for _, v := range foodList {
|
for _, v := range foodList {
|
||||||
foodMap[v.AppFoodCode] = v.ErrorMsg
|
foodMap[v.AppFoodCode] = v.ErrorMsg
|
||||||
}
|
}
|
||||||
for _, v := range storeSkuList {
|
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||||
|
for _, v := range storeSkuLists {
|
||||||
if foodMap[v.VendorSkuID] != "" {
|
if foodMap[v.VendorSkuID] != "" {
|
||||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: v,
|
StoreSkuInfo: v,
|
||||||
@@ -253,17 +254,8 @@ func SelectStoreSkuListByFoodList(storeSkuList []*partner.StoreSkuInfo, foodList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectedStoreSkuList
|
if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||||
}
|
for _, v := range storeSkuLists {
|
||||||
|
|
||||||
//美团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] != "" {
|
if foodMap[v.VendorSkuID] != "" {
|
||||||
storeSkuInfo := &partner.StoreSkuInfo{
|
storeSkuInfo := &partner.StoreSkuInfo{
|
||||||
SkuID: v.SkuID,
|
SkuID: v.SkuID,
|
||||||
@@ -281,6 +273,7 @@ func SelectStoreSynSkuByFoodList(storeSkuList []*dao.StoreSkuSyncInfo, foodList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return selectedStoreSkuList
|
return selectedStoreSkuList
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,29 +319,24 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
|
|||||||
return selectedStoreSkuList
|
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 err != nil {
|
||||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||||
|
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
|
||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuList[0],
|
StoreSkuInfo: storeSkuLists[0],
|
||||||
ErrMsg: errExt.ErrMsg(),
|
ErrMsg: errExt.ErrMsg(),
|
||||||
}
|
}
|
||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
}
|
}
|
||||||
}
|
if storeSkuLists, ok := storeSkuList.([]*dao.StoreSkuSyncInfo); ok {
|
||||||
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{
|
storeSkuInfo := &partner.StoreSkuInfo{
|
||||||
SkuID: storeSkuList[0].SkuID,
|
SkuID: storeSkuLists[0].SkuID,
|
||||||
VendorSkuID: storeSkuList[0].VendorSkuID,
|
VendorSkuID: storeSkuLists[0].VendorSkuID,
|
||||||
NameID: storeSkuList[0].NameID,
|
NameID: storeSkuLists[0].NameID,
|
||||||
VendorNameID: storeSkuList[0].VendorNameID,
|
VendorNameID: storeSkuLists[0].VendorNameID,
|
||||||
VendorPrice: storeSkuList[0].VendorPrice,
|
VendorPrice: storeSkuLists[0].VendorPrice,
|
||||||
Status: storeSkuList[0].Status,
|
Status: storeSkuLists[0].Status,
|
||||||
}
|
}
|
||||||
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
|
||||||
StoreSkuInfo: storeSkuInfo,
|
StoreSkuInfo: storeSkuInfo,
|
||||||
@@ -357,6 +345,7 @@ func GetErrMsg2FailedSyncSingleList(storeSkuList []*dao.StoreSkuSyncInfo, err er
|
|||||||
failedList = append(failedList, storeSkuInfoWithErr)
|
failedList = append(failedList, storeSkuInfoWithErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return failedList
|
return failedList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user