- fixed bug in updateStoreSkusWithoutSync

This commit is contained in:
gazebo
2018-10-25 08:42:49 +08:00
parent f525d659f8
commit 62ea34eb70
4 changed files with 15 additions and 6 deletions

View File

@@ -358,9 +358,9 @@ func updateStoreSkusWithoutSync(ctx *jxcontext.Context, storeID int, skuBindInfo
} }
} }
} }
if skuBind != nil && num == 1 { }
needSyncIDMap[skuBind.SkuID] = 1 if skuBind != nil && num == 1 {
} needSyncIDMap[skuBind.SkuID] = 1
} }
} }
} else { } else {

View File

@@ -55,8 +55,8 @@ const (
SyncFlagDeletedMask = 4 SyncFlagDeletedMask = 4
SyncFlagChangedMask = SyncFlagModifiedMask | SyncFlagNewMask | SyncFlagDeletedMask SyncFlagChangedMask = SyncFlagModifiedMask | SyncFlagNewMask | SyncFlagDeletedMask
SyncFlagSaleMask = 5 SyncFlagSaleMask = 8
SyncFlagPriceMask = 6 SyncFlagPriceMask = 16
) )
// const ( // const (

View File

@@ -53,6 +53,10 @@ type IOrderManager interface {
LoadWaybill(vendorWaybillID string, waybillVendorID int) (bill *model.Waybill, err error) LoadWaybill(vendorWaybillID string, waybillVendorID int) (bill *model.Waybill, err error)
} }
// purchase handler中
// 所有SyncRefresh开头的函数都必须自己清理sync_status标记
// 所有非以SyncRefresh开头的函数不用自己清理sync_status标记VendorSync统一处理
type IPurchasePlatformHandler interface { type IPurchasePlatformHandler interface {
GetStatusFromVendorStatus(vendorStatus string) int GetStatusFromVendorStatus(vendorStatus string) int
GetOrder(vendorOrderID string) (order *model.GoodsOrder, err error) GetOrder(vendorOrderID string) (order *model.GoodsOrder, err error)

View File

@@ -25,6 +25,9 @@ type tStoreSkuBindExt struct {
// 京东到家,以有库存表示关注(认领) // 京东到家,以有库存表示关注(认领)
func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, storeIDs []int, skuIDs []int, isAsync bool) (hint string, err error) { func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, storeIDs []int, skuIDs []int, isAsync bool) (hint string, err error) {
globals.SugarLogger.Debugf("jd SyncStoresSkus, storeIDs:%v, skuIDs:%v", storeIDs, skuIDs) globals.SugarLogger.Debugf("jd SyncStoresSkus, storeIDs:%v, skuIDs:%v", storeIDs, skuIDs)
if len(skuIDs) == 0 {
return "", nil
}
parallelCount := 1 parallelCount := 1
if len(skuIDs) < MaxSkuBatchSize { if len(skuIDs) < MaxSkuBatchSize {
@@ -57,7 +60,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
} }
if err = dao.GetRows(db, &storeSkus, sql, append(sqlParams, sqlWhereParams...)...); err == nil { if err = dao.GetRows(db, &storeSkus, sql, append(sqlParams, sqlWhereParams...)...); err == nil {
outStationNo := utils.Int2Str(storeID) outStationNo := utils.Int2Str(storeID)
task := tasksch.RunParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(MaxSkuBatchSize), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { task := tasksch.NewParallelTask("SyncStoresSkus inner", tasksch.NewParallelConfig().SetBatchSize(MaxSkuBatchSize), ctx.GetUserName(), func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
var skuPriceInfoList []*jdapi.SkuPriceInfo var skuPriceInfoList []*jdapi.SkuPriceInfo
var skuVendibilityList []*jdapi.StockVendibility var skuVendibilityList []*jdapi.StockVendibility
var skuStockList []*jdapi.SkuStock var skuStockList []*jdapi.SkuStock
@@ -95,6 +98,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
} }
if globals.EnableStoreWrite { if globals.EnableStoreWrite {
// todo 以下可以优化为并行操作 // todo 以下可以优化为并行操作
// globals.SugarLogger.Debug(utils.Format4Output(skuVendibilityList, false), utils.Format4Output(skuPriceInfoList, false), utils.Format4Output(skuStockList, false))
if len(skuVendibilityList) > 0 { if len(skuVendibilityList) > 0 {
_, err = api.JdAPI.BatchUpdateVendibility(outStationNo, "", skuVendibilityList, ctx.GetUserName()) _, err = api.JdAPI.BatchUpdateVendibility(outStationNo, "", skuVendibilityList, ctx.GetUserName())
} }
@@ -107,6 +111,7 @@ func (p *PurchaseHandler) SyncStoresSkus(ctx *jxcontext.Context, parentTask task
} }
return nil, err return nil, err
}, storeSkus) }, storeSkus)
t.AddChild(task).Run()
if _, err = task.GetResult(0); err == nil { if _, err = task.GetResult(0); err == nil {
sql := ` sql := `
UPDATE store_sku_bind t1 UPDATE store_sku_bind t1