错误返回
This commit is contained in:
@@ -537,30 +537,31 @@ func CheckSkuDiffBetweenJxAndVendor(ctx *jxcontext.Context, vendorIDList []int,
|
||||
} else {
|
||||
filterStoreList := GetFilterStoreList(jxStoreInfoList.Stores, vendorMap, storeIDMap)
|
||||
diffData.InitData()
|
||||
//循环门店store
|
||||
taskFunc := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
jxStoreInfoListValue := batchItemList[0].(*StoreExt)
|
||||
storeID := jxStoreInfoListValue.ID
|
||||
storeIDStr := utils.Int2Str(storeID)
|
||||
storeName := jxStoreInfoListValue.Name
|
||||
jxSkuInfoDataSingle := &StoreSkuNamesInfo{}
|
||||
jxSkuInfoDataMulti := &StoreSkuNamesInfo{}
|
||||
if jxStoreInfoListValue.StoreMaps != nil {
|
||||
var filterJxSkuInfoMapSingle map[int]*StoreSkuNameExt
|
||||
var filterJxSkuInfoMapMulti map[int]*StoreSkuNameExt
|
||||
var multiFlag = false
|
||||
var singleFlag = false
|
||||
//循环平台vendor
|
||||
for _, vendorListValue := range jxStoreInfoListValue.StoreMaps {
|
||||
vendorID := int(utils.MustInterface2Int64(vendorListValue["vendorID"]))
|
||||
var flag = false
|
||||
if partner.IsMultiStore(vendorID) {
|
||||
if flag == false {
|
||||
jxSkuInfoDataMulti, _ = GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
if multiFlag == false {
|
||||
jxSkuInfoDataMulti, _ := GetStoreSkus(ctx, storeID, filterJxDepotUnSaleSkuIds, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
filterJxSkuInfoMapMulti = GetFilterJxSkuInfoMap(jxSkuInfoDataMulti.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
flag = true
|
||||
multiFlag = true
|
||||
}
|
||||
} else {
|
||||
if flag == false {
|
||||
jxSkuInfoDataSingle, _ = GetStoreSkus(ctx, storeID, []int{}, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
if singleFlag == false {
|
||||
jxSkuInfoDataSingle, _ := GetStoreSkus(ctx, storeID, []int{}, true, "", true, false, map[string]interface{}{}, 0, -1)
|
||||
filterJxSkuInfoMapSingle = GetFilterJxSkuInfoMap(jxSkuInfoDataSingle.SkuNames) //map[京西商品ID:StoreSkuNameExt]
|
||||
flag = true
|
||||
singleFlag = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +389,10 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vend
|
||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||
}, isContinueWhenError)
|
||||
if task != nil {
|
||||
task.SetFinishHook(func(task2 tasksch.ITask) {
|
||||
failedList := task2.GetErrMsg()
|
||||
fmt.Println(failedList)
|
||||
})
|
||||
err = makeSyncError(err)
|
||||
}
|
||||
return hint, err
|
||||
|
||||
@@ -31,6 +31,13 @@ var (
|
||||
subSensitiveWordRegexp = regexp.MustCompile(`[^\[\]\"\}]`)
|
||||
)
|
||||
|
||||
type ErrMsg struct {
|
||||
SkuID int
|
||||
StoreID int
|
||||
VendorID int
|
||||
Err string
|
||||
}
|
||||
|
||||
func CreateStoreCategoryByStoreSku(ctx *jxcontext.Context, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs []int) (err error) {
|
||||
globals.SugarLogger.Debugf("CreateStoreCategoryByStoreSku vendorID:%d, storeID:%d", vendorID, storeID)
|
||||
db := dao.GetDB()
|
||||
@@ -506,10 +513,15 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
for k, list := range [][]*partner.StoreSkuInfo{stockList /*, onlineList*/} {
|
||||
if len(list) > 0 {
|
||||
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品库存", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||
var successList []*partner.StoreSkuInfo
|
||||
if successList, err = storeSkuHandler.UpdateStoreSkusStock(ctx, storeID, vendorStoreID, batchedStoreSkuList); err == nil {
|
||||
successList = batchedStoreSkuList
|
||||
var failedList []*partner.StoreSkuInfoWithErr
|
||||
failedList, err = storeSkuHandler.UpdateStoreSkusStock(ctx, storeID, vendorStoreID, batchedStoreSkuList)
|
||||
if len(failedList) > 0 {
|
||||
for _, v := range failedList {
|
||||
fmt.Println(v.StoreSkuInfo, v.ErrMsg)
|
||||
}
|
||||
task.AddErrMsg(failedList)
|
||||
}
|
||||
successList := putils.UnselectStoreSkuListByVendorSkuIDs(batchedStoreSkuList, GetVendorSkuIDList(failedList))
|
||||
if k == 0 && len(successList) > 0 {
|
||||
updateStoreSku(dao.GetDB(), vendorID, bareSku2Sync(successList), model.SyncFlagStockMask)
|
||||
}
|
||||
@@ -528,10 +540,12 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
}
|
||||
if len(statusList) > 0 {
|
||||
_, err = putils.FreeBatchStoreSkuInfo(name, func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||
var successList []*partner.StoreSkuInfo
|
||||
if successList, err = storeSkuHandler.UpdateStoreSkusStatus(ctx, storeID, vendorStoreID, batchedStoreSkuList, status); err == nil {
|
||||
successList = batchedStoreSkuList
|
||||
var failedList []*partner.StoreSkuInfoWithErr
|
||||
failedList, err = storeSkuHandler.UpdateStoreSkusStatus(ctx, storeID, vendorStoreID, batchedStoreSkuList, status)
|
||||
if len(failedList) > 0 {
|
||||
task.AddErrMsg(failedList)
|
||||
}
|
||||
successList := putils.UnselectStoreSkuListByVendorSkuIDs(batchedStoreSkuList, GetVendorSkuIDList(failedList))
|
||||
if len(successList) > 0 {
|
||||
updateStoreSku(dao.GetDB(), vendorID, bareSku2Sync(successList), model.SyncFlagSaleMask)
|
||||
}
|
||||
@@ -541,7 +555,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
case 6:
|
||||
if len(priceList) > 0 {
|
||||
_, err = putils.FreeBatchStoreSkuInfo("更新门店商品价格", func(task tasksch.ITask, batchedStoreSkuList []*partner.StoreSkuInfo) (result interface{}, successCount int, err error) {
|
||||
var failedList []*tasksch.ErrMsg
|
||||
var failedList []*partner.StoreSkuInfoWithErr
|
||||
failedList, err = storeSkuHandler.UpdateStoreSkusPrice(ctx, storeID, vendorStoreID, batchedStoreSkuList)
|
||||
if len(failedList) > 0 {
|
||||
task.AddErrMsg(failedList)
|
||||
@@ -845,12 +859,12 @@ func MergeSkuSaleStatusWithStoreOpTime(sku *dao.StoreSkuSyncInfo, storeDetail *d
|
||||
return sku.MergedStatus
|
||||
}
|
||||
|
||||
func GetVendorSkuIDList(l []*tasksch.ErrMsg) (vendorSkuIDs []string) {
|
||||
func GetVendorSkuIDList(l []*partner.StoreSkuInfoWithErr) (vendorSkuIDs []string) {
|
||||
vendorSkuIDs2 := make([]string, len(l))
|
||||
if len(l) > 0 {
|
||||
vendorSkuIDs = make([]string, len(l))
|
||||
for k, v := range l {
|
||||
vendorSkuIDs[k] = v.VendorSkuID
|
||||
vendorSkuIDs2[k] = v.StoreSkuInfo.VendorSkuID
|
||||
}
|
||||
}
|
||||
return vendorSkuIDs
|
||||
return vendorSkuIDs2
|
||||
}
|
||||
|
||||
@@ -64,16 +64,10 @@ type ITask interface {
|
||||
GetLeafResult() (finishedItemCount, failedItemCount int)
|
||||
AddBatchErr(err error)
|
||||
AddErrMsg(failedList ...interface{})
|
||||
GetErrMsg() (failedList []*ErrMsg)
|
||||
GetErrMsg() (failedList []interface{})
|
||||
SetFinishHook(func(task ITask))
|
||||
json.Marshaler
|
||||
}
|
||||
type ErrMsg struct {
|
||||
SkuID int
|
||||
VendorSkuID string
|
||||
StoreID int
|
||||
VendorPrice int64
|
||||
Err string
|
||||
}
|
||||
|
||||
// type TaskError struct {
|
||||
// name string
|
||||
@@ -137,6 +131,7 @@ type BaseTask struct {
|
||||
ctx *jxcontext.Context
|
||||
isGetResultCalled bool
|
||||
FailedList []interface{}
|
||||
FinishHook func(task ITask)
|
||||
}
|
||||
|
||||
func (s TaskList) Len() int {
|
||||
@@ -364,7 +359,11 @@ func (t *BaseTask) Error() (errMsg string) {
|
||||
return errMsg
|
||||
}
|
||||
|
||||
func (t *BaseTask) GetErrMsg() (failedList []*ErrMsg) {
|
||||
func (t *BaseTask) SetFinishHook(hook func(task ITask)) {
|
||||
t.FinishHook = hook
|
||||
}
|
||||
|
||||
func (t *BaseTask) GetErrMsg() (failedList []interface{}) {
|
||||
t.locker.RLock()
|
||||
defer t.locker.RUnlock()
|
||||
if len(t.FailedList) == 0 {
|
||||
@@ -372,7 +371,7 @@ func (t *BaseTask) GetErrMsg() (failedList []*ErrMsg) {
|
||||
}
|
||||
if t.parent != nil {
|
||||
for _, v := range t.FailedList {
|
||||
failedList = append(failedList, v.(*ErrMsg))
|
||||
failedList = append(failedList, v)
|
||||
}
|
||||
}
|
||||
return failedList
|
||||
@@ -475,6 +474,7 @@ func (t *BaseTask) run(taskHandler func()) {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
|
||||
}
|
||||
}
|
||||
t.SetFinishHook(t.FinishHook)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ type StoreSkuInfo struct {
|
||||
Seq int `json:"seq,omitempty"`
|
||||
}
|
||||
|
||||
type StoreSkuInfoWithErr struct {
|
||||
StoreSkuInfo *StoreSkuInfo
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
type SkuInfo struct {
|
||||
StoreSkuInfo
|
||||
SkuName string
|
||||
@@ -129,9 +134,9 @@ type IPurchasePlatformStoreSkuHandler interface {
|
||||
|
||||
// 此接口要求实现为不限制批处理大小的
|
||||
GetStoreSkusBareInfo(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, vendorStoreID string, inStoreSkuList []*StoreSkuInfo) (outStoreSkuList []*StoreSkuInfo, err error)
|
||||
UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (successList []*StoreSkuInfo, err error)
|
||||
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo, status int) (successList []*StoreSkuInfo, err error)
|
||||
UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error)
|
||||
UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo, status int) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*StoreSkuInfo) (failedList []*StoreSkuInfoWithErr, err error)
|
||||
}
|
||||
|
||||
type ISingleStoreStoreSkuHandler interface {
|
||||
|
||||
@@ -166,7 +166,7 @@ func (p *PurchaseHandler) DeleteStoreSkus(ctx *jxcontext.Context, storeID int, v
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
vendorSkuIDs := partner.BareStoreSkuInfoList(storeSkuList).GetVendorSkuIDIntList()
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
var opResult *ebaiapi.BatchOpResult
|
||||
@@ -175,19 +175,24 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
opResult, err = api.EbaiAPI.SkuOnline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||
} else if len(vendorSkuIDs) == 1 {
|
||||
err = api.EbaiAPI.SkuOnlineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
return failedList, err
|
||||
}
|
||||
} else {
|
||||
if len(vendorSkuIDs) > 1 {
|
||||
opResult, err = api.EbaiAPI.SkuOffline(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs, nil, nil)
|
||||
} else if len(vendorSkuIDs) == 1 {
|
||||
err = api.EbaiAPI.SkuOfflineOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), vendorSkuIDs[0], "", "")
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
return failedList, err
|
||||
}
|
||||
}
|
||||
if err != nil && opResult != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
// failedList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func StoreSkuInfoList2Ebai(storeSkuList []*partner.StoreSkuInfo) (outList ebaiapi.ShopSkuInfoList) {
|
||||
@@ -203,7 +208,7 @@ func StoreSkuInfoList2Ebai(storeSkuList []*partner.StoreSkuInfo) (outList ebaiap
|
||||
return outList
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if len(storeSkuList) > 1 {
|
||||
opResult, err2 := api.EbaiAPI.SkuPriceUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||
@@ -211,24 +216,29 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
_, 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 {
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult2)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if len(storeSkuList) > 1 {
|
||||
opResult, err2 := api.EbaiAPI.SkuStockUpdateBatch(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList), ebaiapi.SkuIDTypeSkuID)
|
||||
if err = err2; err != nil && opResult != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
failedList = putils.SelectStoreSkuListByOpResult(storeSkuList, opResult)
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getFailedVendorSkuIDsFromOpResult(opResult))
|
||||
}
|
||||
} else if len(storeSkuList) == 1 {
|
||||
err = api.EbaiAPI.SkuStockUpdateOne(ctx.GetTrackInfo(), utils.Int2Str(storeID), StoreSkuInfoList2Ebai(storeSkuList)[0])
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func genSkuParamsFromStoreSkuInfo2(storeSku *dao.StoreSkuSyncInfo, isCreate bool) (params map[string]interface{}) {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package jd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -112,7 +110,7 @@ func getStrOutSkuIDs(l []*jdapi.StoreSkuBatchUpdateResponse, isSuccess bool) (ou
|
||||
return outSkuIDs
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
var skuVendibilityList []*jdapi.StockVendibility
|
||||
jdStatus := jxStoreSkuStatus2Jd(status)
|
||||
for _, v := range storeSkuList {
|
||||
@@ -124,16 +122,18 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").BatchUpdateVendibility(ctx.GetTrackInfo(), "", vendorStoreID, skuVendibilityList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
_, err = getAPI("").UpdateStationPrice(ctx.GetTrackInfo(), utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].VendorPrice))
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
} else {
|
||||
var skuPriceInfoList []*jdapi.SkuPriceInfo
|
||||
@@ -146,18 +146,18 @@ func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID i
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").UpdateVendorStationPrice(ctx.GetTrackInfo(), "", vendorStoreID, skuPriceInfoList)
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList := putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
fmt.Println(successList)
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
if len(storeSkuList) == 1 {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = getAPI("").UpdateCurrentQty(ctx.GetTrackInfo(), vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock)
|
||||
failedList = putils.GetErrMsg2FailedSingleList(storeSkuList, err)
|
||||
}
|
||||
} else {
|
||||
var skuStockList []*jdapi.SkuStock
|
||||
@@ -170,11 +170,12 @@ func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID i
|
||||
if globals.EnableJdStoreWrite {
|
||||
responseList, err2 := getAPI("").BatchUpdateCurrentQtys(ctx.GetTrackInfo(), "", vendorStoreID, skuStockList, ctx.GetUserName())
|
||||
if err = err2; isErrPartialFailed(err) {
|
||||
successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
failedList = putils.SelectStoreSkuListByResponseList(storeSkuList, responseList)
|
||||
// successList = putils.UnselectStoreSkuListBySkuIDs(storeSkuList, utils.StringSlice2Int(getStrOutSkuIDs(responseList, false)))
|
||||
}
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) SyncStoreProducts(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
|
||||
@@ -322,45 +322,48 @@ func storeSku2Mtwm(storeSkuList []*partner.StoreSkuInfo, updateType int) (skuLis
|
||||
return skuList
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo, status int) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
skuList := storeSku2Mtwm(storeSkuList, updateTypeStatus)
|
||||
mtwmStatus := skuStatusJX2Mtwm(status)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSellStatus(ctx.GetTrackInfo(), vendorStoreID, skuList, mtwmStatus)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*tasksch.ErrMsg, err error) {
|
||||
priceList := storeSku2Mtwm(storeSkuList, updateTypePrice)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeID, storeSkuList, failedFoodList)
|
||||
err = putils.GenPartialFailedErr(failedList, len(failedList))
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (successList []*partner.StoreSkuInfo, err error) {
|
||||
func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
priceList := storeSku2Mtwm(storeSkuList, updateTypePrice)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuPrice(ctx.GetTrackInfo(), vendorStoreID, priceList)
|
||||
if err = err2; err == nil {
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (failedList []*partner.StoreSkuInfoWithErr, err error) {
|
||||
stockList := storeSku2Mtwm(storeSkuList, updateTypeStock)
|
||||
if globals.EnableMtwmStoreWrite {
|
||||
failedFoodList, err2 := api.MtwmAPI.RetailSkuStock(ctx.GetTrackInfo(), vendorStoreID, stockList)
|
||||
if err = err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
if len(failedFoodList) > 0 {
|
||||
failedList = putils.SelectStoreSkuListByFoodList(storeSkuList, failedFoodList)
|
||||
}
|
||||
// if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
// successList = putils.UnselectStoreSkuListByVendorSkuIDs(storeSkuList, getAppFoodCodeList(failedFoodList))
|
||||
// }
|
||||
}
|
||||
}
|
||||
return successList, err
|
||||
return failedList, err
|
||||
}
|
||||
|
||||
func mtwmSkuStatus2Jx(mtwmSkuStatus int) (jxSkuStatus int) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
@@ -234,7 +236,8 @@ func UnselectStoreSkuListByVendorSkuIDs(storeSkuList []*partner.StoreSkuInfo, ve
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
func SelectStoreSkuListByFoodList(storeID int, storeSkuList []*partner.StoreSkuInfo, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*tasksch.ErrMsg) {
|
||||
//美团api返回
|
||||
func SelectStoreSkuListByFoodList(storeSkuList []*partner.StoreSkuInfo, foodList []*mtwmapi.AppFoodResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
foodMap := make(map[string]string)
|
||||
if len(foodList) > 0 {
|
||||
for _, v := range foodList {
|
||||
@@ -242,12 +245,9 @@ func SelectStoreSkuListByFoodList(storeID int, storeSkuList []*partner.StoreSkuI
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
if foodMap[v.VendorSkuID] != "" {
|
||||
foodFailed := &tasksch.ErrMsg{
|
||||
SkuID: v.SkuID,
|
||||
VendorSkuID: v.VendorSkuID,
|
||||
StoreID: storeID,
|
||||
VendorPrice: v.VendorPrice,
|
||||
Err: foodMap[v.VendorSkuID],
|
||||
foodFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: foodMap[v.VendorSkuID],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, foodFailed)
|
||||
}
|
||||
@@ -256,7 +256,8 @@ func SelectStoreSkuListByFoodList(storeID int, storeSkuList []*partner.StoreSkuI
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
func SelectStoreSkuListByOpResult(storeID int, storeSkuList []*partner.StoreSkuInfo, opResult *ebaiapi.BatchOpResult) (selectedStoreSkuList []*tasksch.ErrMsg) {
|
||||
//饿百api返回
|
||||
func SelectStoreSkuListByOpResult(storeSkuList []*partner.StoreSkuInfo, opResult *ebaiapi.BatchOpResult) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
opResultMap := make(map[int64]string)
|
||||
if len(opResult.FailedList) > 0 {
|
||||
for _, v := range opResult.FailedList {
|
||||
@@ -264,12 +265,9 @@ func SelectStoreSkuListByOpResult(storeID int, storeSkuList []*partner.StoreSkuI
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
if opResultMap[utils.Str2Int64(v.VendorSkuID)] != "" {
|
||||
opFailed := &tasksch.ErrMsg{
|
||||
SkuID: v.SkuID,
|
||||
VendorSkuID: v.VendorSkuID,
|
||||
StoreID: storeID,
|
||||
VendorPrice: v.VendorPrice,
|
||||
Err: opResultMap[utils.Str2Int64(v.VendorSkuID)],
|
||||
opFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: opResultMap[utils.Str2Int64(v.VendorSkuID)],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, opFailed)
|
||||
}
|
||||
@@ -278,6 +276,39 @@ func SelectStoreSkuListByOpResult(storeID int, storeSkuList []*partner.StoreSkuI
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
//京东api返回
|
||||
func SelectStoreSkuListByResponseList(storeSkuList []*partner.StoreSkuInfo, responseList []*jdapi.StoreSkuBatchUpdateResponse) (selectedStoreSkuList []*partner.StoreSkuInfoWithErr) {
|
||||
responseMap := make(map[string]string)
|
||||
if len(responseList) > 0 {
|
||||
for _, v := range responseList {
|
||||
responseMap[v.OutSkuID] = v.Msg
|
||||
}
|
||||
for _, v := range storeSkuList {
|
||||
if responseMap[utils.Int2Str(v.SkuID)] != "" {
|
||||
respFailed := &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: v,
|
||||
ErrMsg: responseMap[utils.Int2Str(v.SkuID)],
|
||||
}
|
||||
selectedStoreSkuList = append(selectedStoreSkuList, respFailed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return selectedStoreSkuList
|
||||
}
|
||||
|
||||
func GetErrMsg2FailedSingleList(storeSkuList []*partner.StoreSkuInfo, err error) (failedList []*partner.StoreSkuInfoWithErr) {
|
||||
failedList2 := make([]*partner.StoreSkuInfoWithErr, 1)
|
||||
if err != nil {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
failedList2[0] = &partner.StoreSkuInfoWithErr{
|
||||
StoreSkuInfo: storeSkuList[0],
|
||||
ErrMsg: errExt.ErrMsg(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return failedList2
|
||||
}
|
||||
|
||||
func UnselectStoreSkuSyncListByVendorSkuIDs(storeSkuList []*dao.StoreSkuSyncInfo, vendorSkuIDs []string) (selectedStoreSkuList []*dao.StoreSkuSyncInfo) {
|
||||
if len(vendorSkuIDs) > 0 {
|
||||
vendorSkuIDMap := jxutils.StringList2Map(vendorSkuIDs)
|
||||
|
||||
Reference in New Issue
Block a user