- EnableHaveRestStores
This commit is contained in:
@@ -286,9 +286,9 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
||||
// globals.SugarLogger.Debug(utils.Format4Output(sqlParams, false))
|
||||
// globals.SugarLogger.Debug(sql)
|
||||
var storeList []*StoreExt
|
||||
mapLimit := false
|
||||
if err = dao.GetRows(db, &storeList, sql, sqlParams...); err == nil {
|
||||
// globals.SugarLogger.Debugf("GetStores, len(storeList):%d", len(storeList))
|
||||
mapLimit := false
|
||||
var (
|
||||
mapLatitude, mapLongitude float64
|
||||
mapRadius int
|
||||
@@ -327,8 +327,9 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
||||
}
|
||||
}
|
||||
dao.Commit(db)
|
||||
|
||||
retVal.MapCenterLng, retVal.MapCenterLat = getMapCenter(retVal.Stores)
|
||||
if mapLimit {
|
||||
retVal.MapCenterLng, retVal.MapCenterLat = getMapCenter(retVal.Stores)
|
||||
}
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
@@ -512,6 +513,42 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
|
||||
return num, err
|
||||
}
|
||||
|
||||
func SetStoreStatus(ctx *jxcontext.Context, storeID, status int) (err error) {
|
||||
payload := map[string]interface{}{
|
||||
"status": status,
|
||||
}
|
||||
_, err = UpdateStore(ctx, storeID, payload, ctx.GetUserName())
|
||||
return err
|
||||
}
|
||||
|
||||
func EnableHaveRestStores(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
storeInfo, err := GetStores(ctx, "", map[string]interface{}{
|
||||
"statuss": string(utils.MustMarshal([]int{model.StoreStatusHaveRest})),
|
||||
}, 0, model.UnlimitedPageSize)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(storeInfo.Stores) == 0 {
|
||||
return "0", nil
|
||||
}
|
||||
|
||||
task := tasksch.NewParallelTask("EnableHaveRestStores", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*StoreExt)
|
||||
err = SetStoreStatus(ctx, store.ID, model.StoreStatusOpened)
|
||||
return nil, err
|
||||
}, storeInfo.Stores)
|
||||
tasksch.ManageTask(task).Run()
|
||||
if !isAsync {
|
||||
if _, err = task.GetResult(0); err == nil {
|
||||
hint = utils.Int2Str(len(storeInfo.Stores))
|
||||
}
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||
store := &storeExt.Store
|
||||
|
||||
@@ -98,5 +98,6 @@ func StartDailyWork() {
|
||||
|
||||
func doDailyWork() {
|
||||
globals.SugarLogger.Debug("doDailyWork")
|
||||
// cms.EnableHaveRestStores(jxcontext.AdminCtx, true, true)
|
||||
cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,21 @@ func (c *StoreController) DeleteStore() {
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 启用所有临时休息门店
|
||||
// @Description 启用所有临时休息门店
|
||||
// @Param token header string true "认证token"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /EnableHaveRestStores [put]
|
||||
func (c *StoreController) EnableHaveRestStores() {
|
||||
c.callEnableHaveRestStores(func(params *tStoreEnableHaveRestStoresParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = cms.EnableHaveRestStores(params.Ctx, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 创建京西门店
|
||||
// @Description 创建京西门店
|
||||
// @Param token header string true "认证token"
|
||||
|
||||
@@ -1078,6 +1078,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "EnableHaveRestStores",
|
||||
Router: `/EnableHaveRestStores`,
|
||||
AllowHTTPMethods: []string{"put"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetStoreCourierMaps",
|
||||
|
||||
Reference in New Issue
Block a user