syncStoreSkuNew添加参数:causeFlag
This commit is contained in:
@@ -1130,7 +1130,7 @@ func ForceUpdateVendorPrice(ctx *jxcontext.Context, vendorID int, actType int, s
|
||||
subTask := tasksch.NewParallelTask("同步平台价格", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
_, err = cms.SyncStoreSkuNew2(ctx, task, vendorID, storeID, storeVendorIDMap[storeID], nil, storeSkuIDMap[storeID], nil, true, false, true)
|
||||
_, err = cms.SyncStoreSkuNew2(ctx, task, 0 /*model.SyncFlagPriceMask*/, vendorID, storeID, storeVendorIDMap[storeID], nil, storeSkuIDMap[storeID], nil, true, false, true)
|
||||
return retVal, err
|
||||
}, storeIDs)
|
||||
tasksch.HandleTask(subTask, task, true).Run()
|
||||
|
||||
@@ -1386,7 +1386,7 @@ func UpdateSkuNamesExPrefix(ctx *jxcontext.Context, nameIDs []int, exPrefix, fro
|
||||
if err == nil && len(skuList) > 0 {
|
||||
if skuList[0].ExPrefixBegin != nil {
|
||||
_, err = UpdateSkuName(ctx, nameID, payload)
|
||||
CurVendorSync.SyncStoresSkus2(ctx, nil, db, partner.GetSingleStoreVendorIDs(), nil, false, []int{skuList[0].ID}, nil, model.SyncFlagModifiedMask, true, true)
|
||||
CurVendorSync.SyncStoresSkus2(ctx, nil, 0, db, partner.GetSingleStoreVendorIDs(), nil, false, []int{skuList[0].ID}, nil, model.SyncFlagModifiedMask, true, true)
|
||||
} else {
|
||||
skuName := &model.SkuName{
|
||||
ExPrefix: exPrefix,
|
||||
@@ -1421,7 +1421,7 @@ func UpdateSkuNamesExPrefix(ctx *jxcontext.Context, nameIDs []int, exPrefix, fro
|
||||
for _, v := range skuList {
|
||||
skuIDs = append(skuIDs, v.ID)
|
||||
}
|
||||
CurVendorSync.SyncStoresSkus2(ctx, nil, db, partner.GetSingleStoreVendorIDs(), nil, false, skuIDs, nil, model.SyncFlagModifiedMask, true, true)
|
||||
CurVendorSync.SyncStoresSkus2(ctx, nil, 0, db, partner.GetSingleStoreVendorIDs(), nil, false, skuIDs, nil, model.SyncFlagModifiedMask, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, 0, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -846,7 +846,7 @@ func UpdateStoresSkusByBind(ctx *jxcontext.Context, parentTask tasksch.ITask, sk
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
if num > 0 {
|
||||
skuIDs := jxutils.IntMap2List(skuIDMap)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, parentTask, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, parentTask, 0, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -1317,7 +1317,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo
|
||||
skuIDs = append(skuIDs, v.SkuID)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, 0, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -2198,7 +2198,7 @@ func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int, isNeedSync bool) (
|
||||
}
|
||||
}
|
||||
if isNeedSync && len(skuIDs) > 0 {
|
||||
if _, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||
if _, err = CurVendorSync.SyncStoresSkus(ctx, nil, model.SyncFlagSaleMask, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,13 +411,14 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
|
||||
tasksch.NewParallelConfig().SetParallelCount(5).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
_, err = v.proxySyncStoreCategory(ctx, task, storeMap, nil, nil, false, isContinueWhenError)
|
||||
_, err = SyncStoreCategories(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, nil, isAsync, isContinueWhenError)
|
||||
return nil, err
|
||||
}, loopMapInfo.StoreMapList)
|
||||
t.AddChild(loopStoreTask).Run()
|
||||
_, err = loopStoreTask.GetResult(0)
|
||||
} else {
|
||||
_, err = v.proxySyncStoreCategory(ctx, t, loopMapInfo.StoreMapList[0], nil, nil, false, isContinueWhenError)
|
||||
storeMap := loopMapInfo.StoreMapList[0]
|
||||
_, err = SyncStoreCategories(ctx, t, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, nil, isAsync, isContinueWhenError)
|
||||
}
|
||||
}
|
||||
return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID)
|
||||
@@ -426,7 +427,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
|
||||
}
|
||||
|
||||
//
|
||||
func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("SyncStoresSkus2")
|
||||
isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
||||
task, hint, err := v.LoopStoresMap2(ctx, parentTask, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, false,
|
||||
@@ -445,7 +446,7 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.
|
||||
if setSyncStatus != 0 {
|
||||
dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus)
|
||||
}
|
||||
if _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil {
|
||||
if _, err = SyncStoreSkuNew(ctx, task, causeFlag, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, excludeSkuIDs, isAsync, isContinueWhenError); err != nil {
|
||||
globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err)
|
||||
}
|
||||
}
|
||||
@@ -462,24 +463,12 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, parentTask tasksch.
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
setSyncStatus := 0
|
||||
if isForce {
|
||||
setSyncStatus = model.SyncFlagStoreSkuModifiedMask
|
||||
}
|
||||
return v.SyncStoresSkus2(ctx, parentTask, db, vendorIDs, storeIDs, true, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func (v *VendorSync) proxySyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return SyncStoreCategories(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func (v *VendorSync) proxySyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return SyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, excludeSkuIDs, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func (v *VendorSync) proxyFullSyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return FullSyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, isAsync, isContinueWhenError)
|
||||
return v.SyncStoresSkus2(ctx, parentTask, causeFlag, db, vendorIDs, storeIDs, true, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
@@ -497,7 +486,7 @@ func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, v
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeMap := batchItemList[0].(*model.StoreMap)
|
||||
if syncDisabled || storeMap.Status > model.StoreStatusDisabled {
|
||||
if _, err = v.proxyFullSyncStoreSku(ctx, task, storeMap, excludeSkuIDs, false, isContinueWhenError); err != nil {
|
||||
if _, err = FullSyncStoreSkuNew(ctx, task, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, excludeSkuIDs, isAsync, isContinueWhenError); err != nil {
|
||||
globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err)
|
||||
}
|
||||
}
|
||||
@@ -822,7 +811,7 @@ func (v *VendorSync) ChangeStoreSkuSaleStatus(ctx *jxcontext.Context, storeID in
|
||||
}
|
||||
vendorIDs := partner.GetPurchasePlatformVendorIDs()
|
||||
dao.UpdateStoreSkuBindSyncStatusForSaleStatus(db, vendorIDs, storeID)
|
||||
v.SyncStoresSkus(ctx, nil, db, vendorIDs, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
v.SyncStoresSkus(ctx, nil, model.SyncFlagSaleMask, db, vendorIDs, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -145,11 +145,11 @@ func SyncStoreCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func SyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return SyncStoreSkuNew2(ctx, parentTask, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, excludeSkuIDs, false, isAsync, isContinueWhenError)
|
||||
func SyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return SyncStoreSkuNew2(ctx, parentTask, causeFlag, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, excludeSkuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
if singleStoreHandler != nil {
|
||||
if err = CreateStoreCategoryByStoreSku(ctx, vendorID, storeID, vendorStoreID, nameIDs, skuIDs); err != nil {
|
||||
@@ -164,7 +164,7 @@ func SyncStoreSkuNew2(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID
|
||||
_, err = SyncStoreCategories(ctx, task, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, false, isContinueWhenError)
|
||||
}
|
||||
case 1:
|
||||
err = syncStoreSkuNew(ctx, task, false, vendorID, storeID, nameIDs, skuIDs, excludeSkuIDs, useVendorPriceDirectly, isContinueWhenError)
|
||||
err = syncStoreSkuNew(ctx, task, causeFlag, false, vendorID, storeID, nameIDs, skuIDs, excludeSkuIDs, useVendorPriceDirectly, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
}, 2)
|
||||
@@ -192,9 +192,9 @@ func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
}
|
||||
case 1:
|
||||
if singleStoreHandler != nil {
|
||||
_, err = SyncStoreSkuNew(ctx, task, vendorID, storeID, vendorStoreID, nil, nil, excludeSkuIDs, false, isContinueWhenError)
|
||||
_, err = SyncStoreSkuNew(ctx, task, 0, vendorID, storeID, vendorStoreID, nil, nil, excludeSkuIDs, false, isContinueWhenError)
|
||||
} else {
|
||||
err = syncStoreSkuNew(ctx, task, true, vendorID, storeID, nil, nil, excludeSkuIDs, false, isContinueWhenError)
|
||||
err = syncStoreSkuNew(ctx, task, 0, true, vendorID, storeID, nil, nil, excludeSkuIDs, false, isContinueWhenError)
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
@@ -325,7 +325,7 @@ func isSkuLockTimeValid(sku *dao.StoreSkuSyncInfo) bool {
|
||||
return sku.LockTime != nil && time.Now().Sub(*sku.LockTime) < 0
|
||||
}
|
||||
|
||||
func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bool, vendorID, storeID int, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isContinueWhenError bool) (err error) {
|
||||
func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, causeFlag int, isFull bool, vendorID, storeID int, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isContinueWhenError bool) (err error) {
|
||||
db := dao.GetDB()
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeID, vendorID)
|
||||
if err != nil {
|
||||
|
||||
@@ -188,7 +188,7 @@ func syncStoreSku() {
|
||||
})
|
||||
errList.AddErr(err)
|
||||
|
||||
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, db, partner.GetMultiStoreVendorIDs(), nil, false, nil, []int{27379}, syncFlag, true, true)
|
||||
_, err = cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, partner.GetMultiStoreVendorIDs(), nil, false, nil, []int{27379}, syncFlag, true, true)
|
||||
// _, err = cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, db, partner.GetMultiStoreVendorIDs(), nil, false, []int{27379}, true, true)
|
||||
errList.AddErr(err)
|
||||
case 1:
|
||||
@@ -198,7 +198,7 @@ func syncStoreSku() {
|
||||
errList.AddErr(err)
|
||||
|
||||
SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID)
|
||||
taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, db, partner.GetSingleStoreVendorIDs(), nil, false, nil, nil, syncFlag, true, true)
|
||||
taskID, err2 := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, nil, 0, db, partner.GetSingleStoreVendorIDs(), nil, false, nil, nil, syncFlag, true, true)
|
||||
errList.AddErr(err2)
|
||||
SaveImportantTaskID(TaskNameSyncStoreSku, taskID)
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func (c *StoreSkuController) SyncStoresSkus() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, 0, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func (c *SyncController) SyncStoresSkus() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, nil, 0, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user