添加是否异步等参数,区分菜市和果园的刷新时间
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,10 +24,16 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
startOpStoreTimeList = []string {
|
||||
startOpStoreTimeListJXCS = []string {
|
||||
"22:10:00",
|
||||
}
|
||||
endOpStoreTimeListJXCS = []string {
|
||||
"06:10:00",
|
||||
}
|
||||
startOpStoreTimeListJXGY = []string {
|
||||
"22:00:00",
|
||||
}
|
||||
endOpStoreTimeList = []string {
|
||||
endOpStoreTimeListJXGY = []string {
|
||||
"06:00:00",
|
||||
}
|
||||
vendorList = map[int]bool {
|
||||
@@ -72,7 +79,7 @@ func FilterSkuNameList(storeSkuNameList []*partner.SkuNameInfo) (filterStoreSkuN
|
||||
return filterStoreSkuNameList
|
||||
}
|
||||
|
||||
func StartOrEndOpStore(isStart bool, startTime, endTime int16) {
|
||||
func StartOrEndOpStore(isStart bool, startTime, endTime int16, isAsync, isContinueWhenError bool) (retVal interface{}, err error) {
|
||||
startProcessTime := time.Now().Unix()
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore start time: %v", time.Now())
|
||||
ctx := jxcontext.AdminCtx
|
||||
@@ -97,7 +104,7 @@ func StartOrEndOpStore(isStart bool, startTime, endTime int16) {
|
||||
vendorStoreID := utils.Interface2String(vendorListValue["vendorStoreID"])
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore storeID:%d vendorID:%d vendorStoreID:%s", storeID, vendorID, vendorStoreID)
|
||||
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
storeSkuNameList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, nil, storeID, vendorStoreID, nil)
|
||||
storeSkuNameList, err := singleStoreHandler.GetStoreSkusFullInfo(ctx, task, storeID, vendorStoreID, nil)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("StartOrEndOpStore GetStoreSkusFullInfo error:%v storeID:%d vendorID:%d vendorStoreID:%s", err, storeID, vendorID, vendorStoreID)
|
||||
} else {
|
||||
@@ -130,24 +137,40 @@ func StartOrEndOpStore(isStart bool, startTime, endTime int16) {
|
||||
}
|
||||
return retVal, err
|
||||
}
|
||||
task := tasksch.NewParallelTask("StartOrEndOpStore", nil, ctx, taskFunc, storeInfo.Stores)
|
||||
task := tasksch.NewParallelTask("StartOrEndOpStore", tasksch.NewParallelConfig().SetParallelCount(4), ctx, taskFunc, storeInfo.Stores)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
_, err = task.GetResult(0)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore tasksch error:%v", err)
|
||||
if isAsync {
|
||||
retVal = task.ID
|
||||
} else {
|
||||
_, err = task.GetResult(0)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore tasksch error:%v", err)
|
||||
}
|
||||
retVal = "1"
|
||||
}
|
||||
}
|
||||
endProcessTime := time.Now().Unix()
|
||||
diff := endProcessTime - startProcessTime
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore end time: %v", time.Now())
|
||||
baseapi.SugarLogger.Debugf("StartOrEndOpStore cost time: %d sec", diff)
|
||||
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func InitEx() {
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(true, 0, 0)
|
||||
}, startOpStoreTimeList)
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(false, 0, 0)
|
||||
}, endOpStoreTimeList)
|
||||
if globals.IsMainProductEnv() {
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(true, 0, 0, false, true)
|
||||
}, startOpStoreTimeListJXCS)
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(false, 0, 0, false, true)
|
||||
}, endOpStoreTimeListJXCS)
|
||||
} else {
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(true, 0, 0, false, true)
|
||||
}, startOpStoreTimeListJXGY)
|
||||
ScheduleTimerFunc(func() {
|
||||
StartOrEndOpStore(false, 0, 0, false, true)
|
||||
}, endOpStoreTimeListJXGY)
|
||||
}
|
||||
}
|
||||
@@ -275,16 +275,18 @@ func (c *TempOpController) TestIt() {
|
||||
|
||||
// @Title 开启或结束所有平台商店的额外时间
|
||||
// @Description 开启或结束所有平台商店的额外时间,并且修改所有商品库存为0或99999(开启:0 , 结束:99999)
|
||||
// @Param token header string true "认证token"
|
||||
// @Param startOrEndStore query bool true "开启或结束"
|
||||
// @Param startTime query int false "开始营业时间(格式:930代表早上9点30分)"
|
||||
// @Param endTime query int false "结束营业时间"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param startOrEndStore query bool true "开启或结束"
|
||||
// @Param startTime query int false "开始营业时间(格式:930代表早上9点30分)"
|
||||
// @Param endTime query int false "结束营业时间"
|
||||
// @Param isAsync query bool false "是否异步操作"
|
||||
// @Param isContinueWhenError query bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /TestStartOrEndOpStore [get]
|
||||
func (c *TempOpController) TestStartOrEndOpStore() {
|
||||
c.callTestStartOrEndOpStore(func(params *tTempopTestStartOrEndOpStoreParams) (retVal interface{}, errCode string, err error) {
|
||||
misc.StartOrEndOpStore(params.StartOrEndStore, int16(params.StartTime), int16(params.EndTime))
|
||||
retVal, err = misc.StartOrEndOpStore(params.StartOrEndStore, int16(params.StartTime), int16(params.EndTime), params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user