根据门店删活动
This commit is contained in:
@@ -1057,6 +1057,47 @@ func RefreshPageActs(ctx *jxcontext.Context, vendorIDs []int, createdFrom time.T
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func DeleteStoresFromAct(ctx *jxcontext.Context, vendorID int, actTypes, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
task := tasksch.NewParallelTask("将SKU从所有活动中删除", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
storeID := batchItemList[0].(int)
|
||||
acts, _ := dao.QueryActs(db, 0, 0, 50, 0, "", vendorID, []int{1}, actTypes, nil, storeID, nil, 0, utils.ZeroTimeValue, utils.ZeroTimeValue, time.Now().AddDate(0, -3, 0), time.Now())
|
||||
for _, v := range acts.Data {
|
||||
var actStoreSkuParam []*ActStoreSkuParam
|
||||
_, actStoreSkus, _ := dao.GetActStoreSkuVendorList(db, v.ID, []int{vendorID}, nil, nil, "", 0, 99999)
|
||||
for _, actStoreSku := range actStoreSkus {
|
||||
if actStoreSku.StoreID == storeID {
|
||||
aa := &ActStoreSkuParam{
|
||||
ActStoreSku: model.ActStoreSku{
|
||||
StoreID: storeID,
|
||||
SkuID: actStoreSku.SkuID,
|
||||
ActID: v.ID,
|
||||
},
|
||||
}
|
||||
actStoreSkuParam = append(actStoreSkuParam, aa)
|
||||
}
|
||||
}
|
||||
_, err = DeleteActStoreSkuBind(ctx, db, v.ID, actStoreSkuParam)
|
||||
if err == nil {
|
||||
_, err = SyncAct(ctx, nil, v.ID, nil, true)
|
||||
}
|
||||
}
|
||||
|
||||
return retVal, err
|
||||
}, storeIDs)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if isAsync {
|
||||
hint = task.GetID()
|
||||
} else {
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if err = err2; err == nil {
|
||||
hint = utils.Int2Str(len(resultList))
|
||||
}
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func DeleteSkusFromAct(ctx *jxcontext.Context, vendorID int, actTypes, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
actMap := make(map[int]*model.Act)
|
||||
|
||||
@@ -307,6 +307,27 @@ func (c *ActController) DeleteSkusFromAct() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 将门店从所有活动中删除
|
||||
// @Description 将门店从所有活动中删除
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeIDs query string true "门店ID列表"
|
||||
// @Param vendorID query int true "厂商ID"
|
||||
// @Param types query string false "活动类型列表"
|
||||
// @Param isAsync query bool false "是否异步"
|
||||
// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /DeleteStoresFromAct [delete]
|
||||
func (c *ActController) DeleteStoresFromAct() {
|
||||
c.callDeleteStoresFromAct(func(params *tActDeleteStoresFromActParams) (retVal interface{}, errCode string, err error) {
|
||||
var storeIDs, types []int
|
||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.Types, &types); err == nil {
|
||||
retVal, err = act.DeleteStoresFromAct(params.Ctx, params.VendorID, types, storeIDs, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 强制更新商品平台价
|
||||
// @Description 强制更新商品平台价
|
||||
// @Param token header string true "认证token"
|
||||
|
||||
@@ -43,6 +43,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||
beego.ControllerComments{
|
||||
Method: "DeleteStoresFromAct",
|
||||
Router: `/DeleteStoresFromAct`,
|
||||
AllowHTTPMethods: []string{"delete"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:ActController"],
|
||||
beego.ControllerComments{
|
||||
Method: "ForceUpdateVendorPrice",
|
||||
|
||||
Reference in New Issue
Block a user