修改九点半定时任务会修改已经下线且禁用的美团门店
This commit is contained in:
@@ -219,7 +219,7 @@ func (v *VendorSync) SyncReorderCategories(ctx *jxcontext.Context, db *dao.DaoDB
|
||||
func (v *VendorSync) SyncStore2Time(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs, storeIDs []int, mustDirty, isAsync bool) (hint string, err error) {
|
||||
userName := ctx.GetUserName()
|
||||
isManageIt := len(storeIDs) == 0 || len(storeIDs) > 5
|
||||
_, hint, err = v.LoopStoresMap2(ctx, nil, db, fmt.Sprintf("同步门店信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, mustDirty, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) {
|
||||
_, hint, err = v.LoopStoresMapNotDisable(ctx, nil, db, fmt.Sprintf("同步门店信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, mustDirty, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (resultList interface{}, err error) {
|
||||
loopMapInfo := batchItemList[0].(*LoopStoreMapInfo)
|
||||
var failedList []*partner.StoreSkuInfoWithErr
|
||||
handler := v.GetStoreHandler(loopMapInfo.VendorID)
|
||||
@@ -234,9 +234,7 @@ func (v *VendorSync) SyncStore2Time(ctx *jxcontext.Context, db *dao.DaoDB, vendo
|
||||
if len(loopMapInfo.StoreMapList) > 1 {
|
||||
db2 = dao.GetDB()
|
||||
}
|
||||
if storeMap.Status == model.StoreStatusDisabled { // 会出现已经禁用的门店还去调用下线操作,这儿给筛选一下
|
||||
resultList = append(resultList, 1)
|
||||
} else if model.IsSyncStatusNew(storeMap.SyncStatus) {
|
||||
if model.IsSyncStatusNew(storeMap.SyncStatus) {
|
||||
storeDetail, _ := dao.GetStoreDetail(db, storeMap.StoreID, storeMap.VendorID, storeMap.VendorOrgCode)
|
||||
if vendorStoreID, err = handler.CreateStore2(db2, storeMap.StoreID, userName, nil, storeDetail); err == nil {
|
||||
resultList = append(resultList, 1)
|
||||
@@ -811,6 +809,57 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, parentTask tasksch.I
|
||||
return task, hint, err
|
||||
}
|
||||
|
||||
// LoopStoresMapNotDisable 获取非禁用门店去同步上下线
|
||||
func (v *VendorSync) LoopStoresMapNotDisable(ctx *jxcontext.Context, parentTask tasksch.ITask, db *dao.DaoDB, taskName string, isAsync, isManageIt bool, vendorIDs []int, storeIDs []int, mustDirty bool, handler tasksch.WorkFunc, isContinueWhenError bool) (task tasksch.ITask, hint string, err error) {
|
||||
var storeMapList []*model.StoreMap
|
||||
if storeMapList, err = dao.GetStoresMapList2(db, vendorIDs, storeIDs, []int{model.StoreStatusOpened, model.StoreStatusClosed, model.StoreStatusHaveRest}, model.StoreStatusAll, model.StoreIsSyncYes, "", "", "", mustDirty); err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
if len(storeMapList) == 0 {
|
||||
return nil, "", nil
|
||||
}
|
||||
vendorStoreMap := make(map[int][]*model.StoreMap)
|
||||
for _, v := range storeMapList {
|
||||
vendorStoreMap[v.VendorID] = append(vendorStoreMap[v.VendorID], v)
|
||||
}
|
||||
loopInfoList := make([]*LoopStoreMapInfo, len(vendorStoreMap))
|
||||
index := 0
|
||||
for k, v := range vendorStoreMap {
|
||||
loopInfoList[index] = &LoopStoreMapInfo{
|
||||
VendorID: k,
|
||||
StoreMapList: v,
|
||||
}
|
||||
index++
|
||||
}
|
||||
|
||||
if len(loopInfoList) == 1 {
|
||||
taskName = fmt.Sprintf("%s,处理平台%s", taskName, model.VendorChineseNames[loopInfoList[0].VendorID])
|
||||
}
|
||||
|
||||
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
||||
if isAsync {
|
||||
buildSetFinishHook(task, ctx)
|
||||
}
|
||||
tasksch.HandleTask(task, parentTask, isManageIt).Run()
|
||||
if !isAsync {
|
||||
resultList, err2 := task.GetResult(0)
|
||||
if len(task.GetFailedList()) > 0 {
|
||||
err2 = buildErrMsg(task)
|
||||
err = err2
|
||||
}
|
||||
if err = err2; err == nil {
|
||||
if len(resultList) == 0 {
|
||||
hint = "1" // todo 暂时这样
|
||||
} else {
|
||||
hint = jxutils.TaskResult2Hint(resultList)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
}
|
||||
return task, hint, err
|
||||
}
|
||||
|
||||
func buildSetFinishHook(task tasksch.ITask, ctx *jxcontext.Context) {
|
||||
task.SetFinishHook(func(task tasksch.ITask) {
|
||||
var noticeMsg = "您此次的同步任务错误详情返回如下: \n"
|
||||
|
||||
@@ -221,7 +221,6 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
}
|
||||
fillOpTimeParams(storeParams, store.GetOpTimeList())
|
||||
errList := errlist.New()
|
||||
globals.SugarLogger.Debugf("=========================1")
|
||||
if globals.EnableJdStoreWrite {
|
||||
store1 := fmt.Sprintf("门店id:%d,门店名称:%s,第三方门店状态:%d,本地修改前门店状态%d,本地门店修改后状态:%d,第三方平台Id(ebai):%s", storeID, store.Name, 100, store.Status, 100, store.VendorOrgCode)
|
||||
event.AddOperateEvent(jxcontext.AdminCtx, jxcontext.AdminCtx.GetTrackInfo(), store1, "", "", 10, "UpdateStore")
|
||||
|
||||
Reference in New Issue
Block a user