diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 3e22fd5aa..3289462ed 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -3863,14 +3863,16 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { store := batchItemList[0].(*model.Store) storeSku, err := dao.GetStoresSkusInfo(db, []int{store.ID}, nil) + var storeSkuBindHiss []*model.StoreSkuBindHistory for _, v := range storeSku { storeSkuBindHis := &model.StoreSkuBindHistory{} storeSkuBindHis.StoreSkuBind = *v storeSkuBindHis.StoreSkuBindID = v.ID storeSkuBindHis.StoreSkuBind.ID = 0 storeSkuBindHis.SnapshotAt = utils.Time2Date(snapshotAt) - dao.CreateEntity(db, storeSkuBindHis) + storeSkuBindHiss = append(storeSkuBindHiss, storeSkuBindHis) } + dao.CreateMultiEntities(db, storeSkuBindHiss) return retVal, err }, storeList) tasksch.HandleTask(task, nil, true).Run() @@ -3882,3 +3884,8 @@ func BackUpStoreSkuBind(ctx *jxcontext.Context, isAsync, isContinueWhenError boo } return hint, err } + +func ReturnStoreSkuBind(ctx *jxcontext.Context, snapshotAt string, storeIDs, skuIDs []int)(err error) { + + return err +} diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 14aa3023b..5a9afac95 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -106,6 +106,10 @@ var ( cms.AutoSaleAtStr, } + backUpStoreSkuBindList = []string{ + "23:30:00", + } + importantTaskMap = &sync.Map{} cancelPayTimeOutOrderList = localjx.GetHalfHoursList() @@ -198,6 +202,9 @@ func Init() { ScheduleTimerFunc("CancelPayTimeOutOrder", func() { localjx.CancelPayTimeOutOrder(jxcontext.AdminCtx) }, cancelPayTimeOutOrderList) + ScheduleTimerFunc("BackUpStoreSkuBind", func() { + cms.BackUpStoreSkuBind(jxcontext.AdminCtx, true, true) + }, backUpStoreSkuBindList) } ScheduleTimerFunc("AutoSaleStoreSku", func() { cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) diff --git a/controllers/cms_store_sku.go b/controllers/cms_store_sku.go index 70d11c782..538b8543d 100644 --- a/controllers/cms_store_sku.go +++ b/controllers/cms_store_sku.go @@ -727,3 +727,23 @@ func (c *StoreSkuController) BackUpStoreSkuBind() { return retVal, "", err }) } + +// @Title 恢复门店商品表 +// @Description 恢复门店商品表 +// @Param token header string true "认证token" +// @Param snapshotAt formData string true "日期,格式2020-03-06 00:00:00" +// @Param storeIDs formData string true "门店列表" +// @Param skuIDs formData string true "商品列表" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /ReturnStoreSkuBind [post] +func (c *StoreSkuController) ReturnStoreSkuBind() { + c.callReturnStoreSkuBind(func(params *tStoreSkuReturnStoreSkuBindParams) (retVal interface{}, errCode string, err error) { + var storeIDs, skuIDs []int + if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs); err != nil { + return retVal, "", err + } + err = cms.ReturnStoreSkuBind(params.Ctx, params.SnapshotAt, storeIDs, skuIDs) + return retVal, "", err + }) +}