- SyncStoresSkus与SyncStoresCategory添加isForce参数
This commit is contained in:
@@ -142,7 +142,7 @@ func SetStoreCategorySyncStatus2(db *dao.DaoDB, storeID int, catIDs []int, syncS
|
||||
}
|
||||
}()
|
||||
for _, vendorID := range CurVendorSync.SingleStoreVendorIDs {
|
||||
num2, err2 := dao.SetStoreCategorySyncStatus(db, vendorID, storeID, catIDs, syncStatus)
|
||||
num2, err2 := dao.SetStoreCategorySyncStatus(db, vendorID, []int{storeID}, catIDs, syncStatus)
|
||||
if err = err2; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -660,7 +660,7 @@ func SetStoreSkuSyncStatus2(db *dao.DaoDB, storeID int, vendorIDs, skuIDs []int,
|
||||
}
|
||||
}()
|
||||
for _, vendorID := range vendorIDs {
|
||||
num2, err2 := dao.SetStoreSkuSyncStatus(db, vendorID, storeID, skuIDs, syncStatus)
|
||||
num2, err2 := dao.SetStoreSkuSyncStatus(db, vendorID, []int{storeID}, skuIDs, syncStatus)
|
||||
if err = err2; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
db := dao.GetDB()
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -749,7 +749,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo
|
||||
skuIDs = append(skuIDs, v.SkuID)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
|
||||
@@ -351,13 +351,16 @@ func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []i
|
||||
})
|
||||
}
|
||||
|
||||
func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, isAsync bool) (hint string, err error) {
|
||||
func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("SyncStoresCategory")
|
||||
isManageIt := len(storeIDs) != 1
|
||||
return v.LoopStoresMap(ctx, db, fmt.Sprintf("同步门店分类信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
if handler := v.GetSingleStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||
if isForce {
|
||||
dao.SetStoreCategorySyncStatus(db, loopMapInfo.VendorID, storeIDs, nil, model.SyncFlagModifiedMask)
|
||||
}
|
||||
if len(loopMapInfo.StoreMapList) > 1 {
|
||||
loopStoreTask := tasksch.NewSeqTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
@@ -377,13 +380,16 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
|
||||
}
|
||||
|
||||
//
|
||||
func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, skuIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("SyncStoresSkus")
|
||||
isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
||||
return v.LoopStoresMap(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs,
|
||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
if handler := v.GetStoreHandler(loopMapInfo.VendorID); handler != nil {
|
||||
if isForce {
|
||||
dao.SetStoreSkuSyncStatus(db, loopMapInfo.VendorID, storeIDs, skuIDs, model.SyncFlagModifiedMask)
|
||||
}
|
||||
if len(loopMapInfo.StoreMapList) > 1 {
|
||||
loopStoreTask := tasksch.NewSeqTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), ctx,
|
||||
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
|
||||
@@ -277,7 +277,7 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, step int, isAsyn
|
||||
if err = dao.GetRows(db, &skuIDs, sql, sqlParams...); err != nil {
|
||||
return "", err
|
||||
}
|
||||
hint, err = cms.CurVendorSync.SyncStoresSkus(ctx, db, []int{model.VendorIDJD}, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
hint, err = cms.CurVendorSync.SyncStoresSkus(ctx, db, []int{model.VendorIDJD}, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ func TransformJdSpu2Sku(ctx *jxcontext.Context, skuNameIDs []int, count int, isA
|
||||
rootTask.AddChild(subTask).Run()
|
||||
if _, err = subTask.GetResult(0); err == nil {
|
||||
if len(skuIDs) > 0 {
|
||||
if _, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDJD, -1, skuIDs, model.SyncFlagStoreSkuModifiedMask); err == nil {
|
||||
if _, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDJD, nil, skuIDs, model.SyncFlagStoreSkuModifiedMask); err == nil {
|
||||
// time.Sleep(20 * time.Second)
|
||||
// _, err = cms.CurVendorSync.SyncStoresSkus(ctx, db, []int{model.VendorIDJD}, nil, skuIDs, false, isContinueWhenError)
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ func GetFullStoreSkus(db *DaoDB, vendorID, storeID int) (skus []*StoreSkuSyncInf
|
||||
return skus, err
|
||||
}
|
||||
|
||||
func SetStoreSkuSyncStatus(db *DaoDB, vendorID, storeID int, skuIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreSkuSyncStatus, storeID:%d, vendorID:%d", storeID, vendorID)
|
||||
func SetStoreSkuSyncStatus(db *DaoDB, vendorID int, storeIDs []int, skuIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreSkuSyncStatus, storeIDs:%v, vendorID:%d", storeIDs, vendorID)
|
||||
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := fmt.Sprintf(`
|
||||
@@ -237,9 +237,9 @@ func SetStoreSkuSyncStatus(db *DaoDB, vendorID, storeID int, skuIDs []int, syncS
|
||||
`, fieldPrefix)
|
||||
}
|
||||
sql += " WHERE 1 = 1"
|
||||
if storeID > 0 {
|
||||
sql += " AND t1.store_id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND t1.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(skuIDs) > 0 {
|
||||
sql += " AND t1.sku_id IN (" + GenQuestionMarks(len(skuIDs)) + ")"
|
||||
@@ -248,8 +248,8 @@ func SetStoreSkuSyncStatus(db *DaoDB, vendorID, storeID int, skuIDs []int, syncS
|
||||
return ExecuteSQL(db, sql, sqlParams...)
|
||||
}
|
||||
|
||||
func SetStoreCategorySyncStatus(db *DaoDB, vendorID, storeID int, catIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreCategorySyncStatus, storeID:%d, vendorID:%d", storeID, vendorID)
|
||||
func SetStoreCategorySyncStatus(db *DaoDB, vendorID int, storeIDs []int, catIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("SetStoreCategorySyncStatus, storeIDs:%v, vendorID:%d", storeIDs, vendorID)
|
||||
|
||||
fieldPrefix := ConvertDBFieldPrefix(model.VendorNames[vendorID])
|
||||
sql := fmt.Sprintf(`
|
||||
@@ -261,9 +261,9 @@ func SetStoreCategorySyncStatus(db *DaoDB, vendorID, storeID int, catIDs []int,
|
||||
syncStatus,
|
||||
}
|
||||
sql += " WHERE 1 = 1"
|
||||
if storeID > 0 {
|
||||
sql += " AND store_id = ?"
|
||||
sqlParams = append(sqlParams, storeID)
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
if len(catIDs) > 0 {
|
||||
sql += " AND category_id IN (" + GenQuestionMarks(len(catIDs)) + ")"
|
||||
|
||||
@@ -164,7 +164,7 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
||||
_, err = p.setStoreSkuSyncStatus(ctx, db, storeID, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
if err = p.DeleteRemoteCategories(ctx, rootTask, storeID, nil); err == nil {
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDEBAI, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDEBAI, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
case 3:
|
||||
err = p.SyncLocalStoreCategory(db, storeID, userName)
|
||||
@@ -202,7 +202,7 @@ func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTa
|
||||
_, err = p.setStoreSkuSyncStatus(ctx, db, storeID, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
if err = p.DeleteRemoteCategories(ctx, rootTask, storeID, nil); err == nil {
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDEBAI, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDEBAI, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
@@ -603,7 +603,7 @@ func (p *PurchaseHandler) updateLocalCatAsNew(db *dao.DaoDB, localCatMap map[str
|
||||
|
||||
func (p *PurchaseHandler) setStoreSkuSyncStatus(ctx *jxcontext.Context, db *dao.DaoDB, storeID int, skuIDs []int, syncStatus int) (num int64, err error) {
|
||||
globals.SugarLogger.Debugf("ebai setStoreSkuSyncStatus storeID:%d, userName:%s", storeID, ctx.GetUserName())
|
||||
return dao.SetStoreSkuSyncStatus(db, model.VendorIDEBAI, storeID, skuIDs, syncStatus)
|
||||
return dao.SetStoreSkuSyncStatus(db, model.VendorIDEBAI, []int{storeID}, skuIDs, syncStatus)
|
||||
}
|
||||
|
||||
func formatName(name string) string {
|
||||
|
||||
@@ -163,7 +163,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask tasksch.ITask, storeID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debugf("jd FullSyncStoreSkus, storeID:%d", storeID)
|
||||
db := dao.GetDB()
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDJD, storeID, nil, model.SyncFlagStoreSkuOnlyMask)
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDJD, []int{storeID}, nil, model.SyncFlagStoreSkuOnlyMask)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -346,10 +346,10 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
||||
err = nil
|
||||
}
|
||||
case 1:
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
if err = p.DeleteRemoteCategories(ctx, rootTask, storeID, nil); err == nil {
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDMTWM, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
case 3:
|
||||
_, err = p.SyncLocalStoreCategory(ctx, db, storeID, true, nil)
|
||||
@@ -477,10 +477,10 @@ func (p *PurchaseHandler) DeleteRemoteStoreSkus(ctx *jxcontext.Context, parentTa
|
||||
err = nil
|
||||
}
|
||||
case 1:
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
if err = p.DeleteRemoteCategories(ctx, rootTask, storeID, nil); err == nil {
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDMTWM, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDMTWM, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
|
||||
@@ -278,9 +278,9 @@ func (p *PurchaseHandler) FullSyncStoreSkus(ctx *jxcontext.Context, parentTask t
|
||||
func(rootTask *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDWSC, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreCategorySyncStatus(db, model.VendorIDWSC, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
case 1:
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDWSC, storeID, nil, model.SyncFlagNewMask)
|
||||
_, err = dao.SetStoreSkuSyncStatus(db, model.VendorIDWSC, []int{storeID}, nil, model.SyncFlagNewMask)
|
||||
case 2:
|
||||
_, err = p.SyncLocalStoreCategory(ctx, db, storeID, false)
|
||||
case 3:
|
||||
|
||||
@@ -131,8 +131,9 @@ func (c *StoreSkuController) UpdateStoreSkus() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param vendorIDs formData string true "厂商ID列表"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param skuIDs formData string false "SKU ID列表,缺省为全部"
|
||||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -144,7 +145,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, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ type SyncController struct {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param vendorIDs formData string true "厂商ID列表"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param skuIDs formData string false "SKU ID列表,缺省为全部"
|
||||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -30,7 +31,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, db, vendorIDs, storeIDs, skuIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
retVal, err = cms.CurVendorSync.SyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, skuIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -40,6 +41,7 @@ func (c *SyncController) SyncStoresSkus() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs formData string true "门店ID列表"
|
||||
// @Param vendorIDs formData string true "厂商ID列表"
|
||||
// @Param isForce formData bool false "是否强制(设置修改标志)"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -52,7 +54,7 @@ func (c *SyncController) SyncStoresCategory() {
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil {
|
||||
return retVal, "", err
|
||||
}
|
||||
retVal, err = cms.CurVendorSync.SyncStoresCategory(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync)
|
||||
retVal, err = cms.CurVendorSync.SyncStoresCategory(params.Ctx, db, vendorIDs, storeIDs, params.IsForce, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user