- act.SyncAct中,当前逻辑要求传入活动的全部SKU信息(以便低层做一些判断,比如全部删除时要取消,所以暂时删除storeIDs与skuIDs这两个参数
This commit is contained in:
@@ -409,7 +409,7 @@ func CreateAct(ctx *jxcontext.Context, act *model.Act, vendorIDs []int, actRules
|
||||
}
|
||||
dao.Commit(db)
|
||||
|
||||
hint, err = SyncAct(ctx, nil, act.ID, nil, nil, nil, isAsync)
|
||||
hint, err = SyncAct(ctx, nil, act.ID, nil, isAsync)
|
||||
if !isAsync {
|
||||
hint = utils.Int2Str(act.ID)
|
||||
}
|
||||
@@ -564,7 +564,7 @@ func CancelAct(ctx *jxcontext.Context, actID int) (err error) {
|
||||
if err = DeleteActStoreSkuBind(ctx, db, actID, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = SyncAct(ctx, nil, actID, nil, nil, nil, false)
|
||||
_, err = SyncAct(ctx, nil, actID, nil, false)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -677,13 +677,14 @@ func DeleteActStoreSkuBind(ctx *jxcontext.Context, db *dao.DaoDB, actID int, act
|
||||
return err
|
||||
}
|
||||
|
||||
func SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actID int, vendorIDs, storeIDs, skuIDs []int, isAsync bool) (hint string, err error) {
|
||||
// todo 当前逻辑要求传入活动的全部SKU信息(以便低层做一些判断,比如全部删除时要取消,所以暂时删除storeIDs与skuIDs这两个参数
|
||||
func SyncAct(ctx *jxcontext.Context, parentTask tasksch.ITask, actID int, vendorIDs /*, storeIDs, skuIDs */ []int, isAsync bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
actMap, err := dao.GetActVendorInfo(db, actID, vendorIDs)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
actStoreSkuMap, err := dao.GetActStoreSkuVendorInfo(db, actID, nil, storeIDs, skuIDs)
|
||||
actStoreSkuMap, err := dao.GetActStoreSkuVendorInfo(db, actID, nil, nil, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -825,7 +826,7 @@ func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, skuIDs []int, isAsy
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
globals.SugarLogger.Debug(utils.Format4Output(pagedInfo, false))
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(pagedInfo, false))
|
||||
for _, v := range pagedInfo.Data {
|
||||
actMap[v.Act.ID] = &v.Act
|
||||
}
|
||||
@@ -858,7 +859,7 @@ func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, skuIDs []int, isAsy
|
||||
if len(deleteList) > 0 {
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(deleteList, false))
|
||||
if err = DeleteActStoreSkuBind(ctx, db, actID, deleteList); err == nil {
|
||||
if _, err = SyncAct(ctx, task, actID, nil, nil, skuIDs, false); err == nil {
|
||||
if _, err = SyncAct(ctx, task, actID, nil, false); err == nil {
|
||||
retVal = deleteList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,17 +193,15 @@ func (c *ActController) GetActStoreSkuInfo() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param actID formData int true "活动id"
|
||||
// @Param vendorIDs formData string false "厂商ID列表"
|
||||
// @Param storeIDs formData string false "门店ID列表"
|
||||
// @Param skuIDs formData string false "商品列表"
|
||||
// @Param isAsync formData bool false "是否异步"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /SyncAct [put]
|
||||
func (c *ActController) SyncAct() {
|
||||
c.callSyncAct(func(params *tActSyncActParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorIDs, storeIDs, skuIDs []int
|
||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs); err == nil {
|
||||
retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, vendorIDs, storeIDs, skuIDs, params.IsAsync)
|
||||
var vendorIDs /*, storeIDs, skuIDs*/ []int
|
||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs /*, params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs*/); err == nil {
|
||||
retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, vendorIDs, params.IsAsync)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
@@ -249,7 +247,7 @@ func (c *ActController) UpdateActStoreSkuBind() {
|
||||
dao.Commit(db)
|
||||
}()
|
||||
if err == nil {
|
||||
retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, nil, nil, nil, params.IsAsync)
|
||||
retVal, err = act.SyncAct(params.Ctx, nil, params.ActID, nil, params.IsAsync)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user