同步错误返回

This commit is contained in:
苏尹岚
2019-12-04 17:34:45 +08:00
parent 16a14e8b4d
commit 6d677bab43
6 changed files with 61 additions and 28 deletions

View File

@@ -237,7 +237,7 @@ func UnselectStoreSkuListByVendorSkuIDs(storeSkuList []*partner.StoreSkuInfo, ve
}
//美团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)
if len(foodList) > 0 {
for _, v := range foodList {
@@ -249,6 +249,9 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
foodFailed := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: v,
ErrMsg: foodMap[v.VendorSkuID],
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
}
@@ -268,6 +271,9 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
foodFailed := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: storeSkuInfo,
ErrMsg: foodMap[v.VendorSkuID],
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
}
@@ -278,7 +284,7 @@ func SelectStoreSkuListByFoodList(storeSkuList interface{}, foodList []*mtwmapi.
}
//饿百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)
if len(opResult.FailedList) > 0 {
for _, v := range opResult.FailedList {
@@ -289,6 +295,9 @@ func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult
opFailed := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: v,
ErrMsg: opResultMap[utils.Str2Int64(v.VendorSkuID)],
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
selectedStoreSkuList = append(selectedStoreSkuList, opFailed)
}
@@ -298,7 +307,7 @@ func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult
}
//京东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)
if len(responseList) > 0 {
for _, v := range responseList {
@@ -311,6 +320,9 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
respFailed := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: v,
ErrMsg: responseMap[utils.Int2Str(v.SkuID)],
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
selectedStoreSkuList = append(selectedStoreSkuList, respFailed)
}
@@ -319,13 +331,16 @@ func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, resp
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 errExt, ok := err.(*utils.ErrorWithCode); ok {
if storeSkuLists, ok := storeSkuList.([]*partner.StoreSkuInfo); ok {
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: storeSkuLists[0],
ErrMsg: errExt.ErrMsg(),
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
failedList = append(failedList, storeSkuInfoWithErr)
}
@@ -341,6 +356,9 @@ func GetErrMsg2FailedSingleList(storeSkuList interface{}, err error) (failedList
storeSkuInfoWithErr := &partner.StoreSkuInfoWithErr{
StoreSkuInfo: storeSkuInfo,
ErrMsg: errExt.ErrMsg(),
StoreID: storeID,
VendoreID: vendorID,
SyncType: syncType,
}
failedList = append(failedList, storeSkuInfoWithErr)
}