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