Merge remote-tracking branch 'origin/mark' into don
This commit is contained in:
@@ -1337,22 +1337,24 @@ func GetStoresVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, v
|
|||||||
task := tasksch.NewParallelTask("GetStoresVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("GetStoresVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
storeMap := batchItemList[0].(*model.StoreMap)
|
storeMap := batchItemList[0].(*model.StoreMap)
|
||||||
if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil {
|
if storeMap.VendorID != model.VendorIDWSC {
|
||||||
store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID)
|
if handler := partner.GetPurchasePlatformFromVendorID(storeMap.VendorID); handler != nil {
|
||||||
if err = err2; err == nil {
|
store, err2 := handler.ReadStore(ctx, storeMap.VendorStoreID)
|
||||||
retVal = []interface{}{&model.VendorStoreSnapshot{
|
if err = err2; err == nil {
|
||||||
StoreID: storeMap.StoreID,
|
retVal = []interface{}{&model.VendorStoreSnapshot{
|
||||||
VendorID: storeMap.VendorID,
|
StoreID: storeMap.StoreID,
|
||||||
VendorStoreID: storeMap.VendorStoreID,
|
VendorID: storeMap.VendorID,
|
||||||
|
VendorStoreID: storeMap.VendorStoreID,
|
||||||
|
|
||||||
Status: store.Status,
|
Status: store.Status,
|
||||||
OpenTime1: store.OpenTime1,
|
OpenTime1: store.OpenTime1,
|
||||||
CloseTime1: store.CloseTime1,
|
CloseTime1: store.CloseTime1,
|
||||||
OpenTime2: store.OpenTime2,
|
OpenTime2: store.OpenTime2,
|
||||||
CloseTime2: store.CloseTime2,
|
CloseTime2: store.CloseTime2,
|
||||||
|
|
||||||
DeliveryType: store.DeliveryType,
|
DeliveryType: store.DeliveryType,
|
||||||
}}
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
|
|||||||
@@ -2181,7 +2181,7 @@ func GetMissingStoreSkuFromOrder(ctx *jxcontext.Context, fromTime time.Time) (mi
|
|||||||
return missingList, err
|
return missingList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int, isNeedSync bool) (err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeSkuList, err := dao.GetAutoSaleStoreSku(db, storeIDs)
|
storeSkuList, err := dao.GetAutoSaleStoreSku(db, storeIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -2206,7 +2206,7 @@ func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(skuIDs) > 0 {
|
if isNeedSync && len(skuIDs) > 0 {
|
||||||
if _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
if _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ func (v *VendorSync) syncCategories(ctx *jxcontext.Context, parentTask tasksch.I
|
|||||||
|
|
||||||
func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
||||||
globals.SugarLogger.Debug(v.MultiStoreVendorIDs)
|
globals.SugarLogger.Debug(v.MultiStoreVendorIDs)
|
||||||
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步分类信息:%d", categoryID), isAsync, userName,
|
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步分类信息:%d", categoryID), isAsync, false,
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||||
vendorID := batchItemList[0].(int)
|
vendorID := batchItemList[0].(int)
|
||||||
var cats []*model.SkuCategory
|
var cats []*model.SkuCategory
|
||||||
@@ -191,7 +191,7 @@ func (v *VendorSync) SyncCategory(ctx *jxcontext.Context, db *dao.DaoDB, categor
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int, isAsync bool, userName string) (hint string, err error) {
|
||||||
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("分类重排序:%d", categoryID), isAsync, userName, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
hint, err = v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("分类重排序:%d", categoryID), isAsync, false, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||||
multiStoresHandler := v.GetMultiStoreHandler(batchItemList[0].(int))
|
multiStoresHandler := v.GetMultiStoreHandler(batchItemList[0].(int))
|
||||||
err2 := multiStoresHandler.ReorderCategories(db, categoryID, userName)
|
err2 := multiStoresHandler.ReorderCategories(db, categoryID, userName)
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
@@ -261,7 +261,8 @@ func (v *VendorSync) SyncSku(ctx *jxcontext.Context, db *dao.DaoDB, nameID, skuI
|
|||||||
|
|
||||||
func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
|
func (v *VendorSync) SyncSkus(ctx *jxcontext.Context, db *dao.DaoDB, nameIDs []int, skuIDs []int, isAsync, isContinueWhenError bool, userName string) (hint string, err error) {
|
||||||
globals.SugarLogger.Debugf("SyncSku trackInfo:%s, nameIDs:%v, skuIDs:%v, userName:%s", ctx.GetTrackInfo(), nameIDs, skuIDs, userName)
|
globals.SugarLogger.Debugf("SyncSku trackInfo:%s, nameIDs:%v, skuIDs:%v, userName:%s", ctx.GetTrackInfo(), nameIDs, skuIDs, userName)
|
||||||
return v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步商品信息, nameIDs:%v, skuIDs:%v", nameIDs, skuIDs), isAsync, userName,
|
isManagedIt := len(nameIDs) > 1 || len(skuIDs) > 1
|
||||||
|
return v.LoopMultiStoresVendors(ctx, db, fmt.Sprintf("同步商品信息, nameIDs:%v, skuIDs:%v", nameIDs, skuIDs), isAsync, isManagedIt,
|
||||||
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) {
|
||||||
var resultList []interface{}
|
var resultList []interface{}
|
||||||
vendorID := batchItemList[0].(int)
|
vendorID := batchItemList[0].(int)
|
||||||
@@ -575,9 +576,9 @@ func (v *VendorSync) LoopStoresMap(ctx *jxcontext.Context, db *dao.DaoDB, taskNa
|
|||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VendorSync) LoopMultiStoresVendors(ctx *jxcontext.Context, db *dao.DaoDB, taskName string, isAsync bool, userName string, handler tasksch.WorkFunc) (hint string, err error) {
|
func (v *VendorSync) LoopMultiStoresVendors(ctx *jxcontext.Context, db *dao.DaoDB, taskName string, isAsync bool, isManageIt bool, handler tasksch.WorkFunc) (hint string, err error) {
|
||||||
task := tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, v.MultiStoreVendorIDs)
|
task := tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, v.MultiStoreVendorIDs)
|
||||||
tasksch.HandleTask(task, nil, true).Run()
|
tasksch.HandleTask(task, nil, isManageIt).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
result, err2 := task.GetResult(0)
|
result, err2 := task.GetResult(0)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package misc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -18,6 +19,11 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SpecialTaskID = "Running"
|
||||||
|
TaskNameSyncStoreSku = "SyncStoreSku"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dailyWorkTimeList = []string{
|
dailyWorkTimeList = []string{
|
||||||
"21:00:00",
|
"21:00:00",
|
||||||
@@ -45,26 +51,34 @@ var (
|
|||||||
"00:01:00",
|
"00:01:00",
|
||||||
}
|
}
|
||||||
|
|
||||||
autoEnableStoreSkuTimeList = []string{
|
autoSaleStoreSkuTimeList = []string{
|
||||||
"7:00:00",
|
"20:50:00",
|
||||||
"8:00:00",
|
|
||||||
"9:00:00",
|
|
||||||
"10:00:00",
|
|
||||||
"11:00:00",
|
|
||||||
"12:00:00",
|
|
||||||
"13:00:00",
|
|
||||||
"14:00:00",
|
|
||||||
"15:00:00",
|
|
||||||
"16:00:00",
|
|
||||||
"17:00:00",
|
|
||||||
"18:00:00",
|
|
||||||
"19:00:00",
|
|
||||||
"20:00:00",
|
|
||||||
"21:00:00",
|
|
||||||
"22:00:00",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
importantTaskMap = &sync.Map{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func GetImportantTaskID(taskName string) string {
|
||||||
|
if value, ok := importantTaskMap.Load(taskName); ok {
|
||||||
|
return value.(string)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func SaveImportantTaskID(taskName, taskID string) {
|
||||||
|
importantTaskMap.Store(taskName, taskID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsImportantTaskRunning(taskName string) bool {
|
||||||
|
taskID := GetImportantTaskID(taskName)
|
||||||
|
if taskID == "" {
|
||||||
|
return false
|
||||||
|
} else if taskID == SpecialTaskID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return tasksch.IsTaskRunning(taskID)
|
||||||
|
}
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
if globals.IsProductEnv() {
|
if globals.IsProductEnv() {
|
||||||
ScheduleTimerFunc(doDailyWork, dailyWorkTimeList)
|
ScheduleTimerFunc(doDailyWork, dailyWorkTimeList)
|
||||||
@@ -89,18 +103,21 @@ func Init() {
|
|||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc(func() {
|
||||||
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
dao.UpdateActStatusByTime(dao.GetDB(), time.Now().Add(-48*time.Hour))
|
||||||
}, updateActStatusTimeList)
|
}, updateActStatusTimeList)
|
||||||
|
InitEx()
|
||||||
}
|
}
|
||||||
ScheduleTimerFunc(func() {
|
ScheduleTimerFunc(func() {
|
||||||
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil)
|
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)
|
||||||
}, autoEnableStoreSkuTimeList)
|
}, autoSaleStoreSkuTimeList)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doDailyWork() {
|
func doDailyWork() {
|
||||||
globals.SugarLogger.Debug("doDailyWork")
|
globals.SugarLogger.Debug("doDailyWork")
|
||||||
netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true)
|
netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true)
|
||||||
// cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true)
|
// cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true)
|
||||||
cms.CurVendorSync.SyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, false, false, true)
|
|
||||||
InitEx()
|
SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID)
|
||||||
|
taskID, _ := cms.CurVendorSync.SyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, false, true, true)
|
||||||
|
SaveImportantTaskID(TaskNameSyncStoreSku, taskID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -160,38 +159,20 @@ func StartOrEndOpStore(isStart bool, startTime, endTime int16, isAsync, isContin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InitEx() {
|
func InitEx() {
|
||||||
// if globals.IsMainProductEnv() {
|
startTimeList := startOpStoreTimeListJXCS
|
||||||
// ScheduleTimerFunc(func() {
|
stopTimeList := endOpStoreTimeListJXCS
|
||||||
// StartOrEndOpStore(true, 0, 0, false, true)
|
if !globals.IsMainProductEnv() {
|
||||||
// }, startOpStoreTimeListJXCS)
|
startTimeList = startOpStoreTimeListJXGY
|
||||||
// ScheduleTimerFunc(func() {
|
stopTimeList = endOpStoreTimeListJXGY
|
||||||
// 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)
|
|
||||||
// }
|
|
||||||
var (
|
|
||||||
time1, time2 time.Time
|
|
||||||
)
|
|
||||||
now := time.Now()
|
|
||||||
if globals.IsMainProductEnv() {
|
|
||||||
time1 = jxutils.GetNextTimeFromList(now, startOpStoreTimeListJXCS)
|
|
||||||
time2 = jxutils.GetNextTimeFromList(now, endOpStoreTimeListJXCS)
|
|
||||||
} else {
|
|
||||||
time1 = jxutils.GetNextTimeFromList(now, startOpStoreTimeListJXGY)
|
|
||||||
time2 = jxutils.GetNextTimeFromList(now, endOpStoreTimeListJXGY)
|
|
||||||
}
|
}
|
||||||
if time1.Sub(now) < 2*time.Hour {
|
ScheduleTimerFunc(func() {
|
||||||
utils.AfterFuncWithRecover(time1.Sub(now), func() {
|
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
||||||
StartOrEndOpStore(true, 0, 0, false, true)
|
StartOrEndOpStore(true, 0, 0, false, true)
|
||||||
})
|
}
|
||||||
utils.AfterFuncWithRecover(time2.Sub(now), func() {
|
}, startTimeList)
|
||||||
|
ScheduleTimerFunc(func() {
|
||||||
|
if !IsImportantTaskRunning(TaskNameSyncStoreSku) {
|
||||||
StartOrEndOpStore(false, 0, 0, false, true)
|
StartOrEndOpStore(false, 0, 0, false, true)
|
||||||
})
|
}
|
||||||
}
|
}, stopTimeList)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,3 +51,10 @@ func GetTasks(taskID string, fromStatus, toStatus int, lastHours int, createdBy
|
|||||||
func ManageTask(task ITask) ITask {
|
func ManageTask(task ITask) ITask {
|
||||||
return defTaskMan.ManageTask(task)
|
return defTaskMan.ManageTask(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsTaskRunning(taskID string) bool {
|
||||||
|
if taskList := GetTasks(taskID, TaskStatusBegin, TaskStatusWorking, 36, ""); len(taskList) > 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,9 +30,3 @@ func (*PageShop) TableUnique() [][]string {
|
|||||||
[]string{"VendorStoreID", "VendorID"},
|
[]string{"VendorStoreID", "VendorID"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*PageShop) TableIndex() [][]string {
|
|
||||||
return [][]string{
|
|
||||||
[]string{"Tel1"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user