diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 085127f6f..0dd42ce12 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -773,7 +773,7 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa statusType = scheduler.TimerStatusTypeWaybill statusTime = bill.StatusTime } - globals.SugarLogger.Debugf("resetTimer, orderID:%s statusType:%d status:%v", order.VendorOrderID, statusType, status) + globals.SugarLogger.Debugf("resetTimer, orderID:%s statusType:%d status:%d", order.VendorOrderID, statusType, status) if isStatusNewer(savedOrderInfo.timerStatusType, savedOrderInfo.timerStatus, statusType, status) { // 新设置的TIMER不能覆盖状态在其后的TIMER,如果状态回绕,需要注意 config := s.mergeOrderStatusConfig(savedOrderInfo, statusTime, statusType, status) if config == nil || config.TimerType != partner.TimerTypeByPass { diff --git a/business/jxstore/act/act.go b/business/jxstore/act/act.go index 552b374da..10c630b74 100644 --- a/business/jxstore/act/act.go +++ b/business/jxstore/act/act.go @@ -120,7 +120,7 @@ func ActStoreSkuParam2Model(ctx *jxcontext.Context, db *dao.DaoDB, act *model.Ac if storeSkuInfo := storeSkuMap[jxutils.Combine2Int(v.StoreID, v.SkuID)]; storeSkuInfo != nil { validVendorMap[vendorID] = 1 validSkuMap[v.SkuID] = 1 - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSkuInfo.UnitPrice, int(storeDetail.PricePercentage)) + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSkuInfo.Price, int(storeDetail.PricePercentage)) actSkuMap := &model.ActStoreSkuMap{ ActID: act.ID, StoreID: storeID, diff --git a/business/jxstore/cms/store_sku.go b/business/jxstore/cms/store_sku.go index 993565b89..43645afa7 100644 --- a/business/jxstore/cms/store_sku.go +++ b/business/jxstore/cms/store_sku.go @@ -495,7 +495,9 @@ func updateActPrice4StoreSkuNameNew(db *dao.DaoDB, storeIDs, skuIDs []int, skuNa // globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err) // return err // } - + if len(skuIDs) == 0 { + return nil + } actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, nil, storeIDs, skuIDs, time.Now(), time.Now()) if err != nil { globals.SugarLogger.Errorf("updateActPrice4StoreSkuNameNew can not get sku promotion info for error:%v", err) @@ -2055,7 +2057,7 @@ func RefreshStoresSkuByVendor(ctx *jxcontext.Context, storeIDs []int, vendorID i } } for _, v := range storeSkuList { - pricePercentage := jxutils.GetPricePercentageByVendorPrice(storeMap[v.StoreID].PricePercentagePackObj, v.UnitPrice, int(storeMap[v.StoreID].PricePercentage)) + pricePercentage := jxutils.GetPricePercentageByVendorPrice(storeMap[v.StoreID].PricePercentagePackObj, v.Price, int(storeMap[v.StoreID].PricePercentage)) skuName := skuNameMap[skuMap[v.SkuID].NameID] v.Price = jxutils.CaculateSkuPriceFromVendor(v.Price, pricePercentage, 0) v.UnitPrice = jxutils.CaculateSkuPriceFromVendor(skuName.Price, pricePercentage, 0) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index ee11c0c48..d36879390 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -438,6 +438,7 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo } func isUseOldSyncLogic(storeMap *model.StoreMap) bool { + return false return globals.IsProductEnv() && storeMap.StoreID != 102652 // 绿城四季鲜店 } diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 5de655855..128715311 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -190,7 +190,7 @@ func storeSkuSyncInfo2Bare(inSku *dao.StoreSkuSyncInfo) (outSku *partner.StoreSk } func calVendorPrice4StoreSku(inSku *dao.StoreSkuSyncInfo, pricePercentagePack model.PricePercentagePack, pricePercentage int) (outSku *dao.StoreSkuSyncInfo) { - pricePercentage = jxutils.GetPricePercentage(pricePercentagePack, int(inSku.UnitPrice), pricePercentage) + pricePercentage = jxutils.GetPricePercentage(pricePercentagePack, int(inSku.Price), pricePercentage) inSku.VendorPrice = int64(jxutils.CaculateSkuVendorPrice(int(inSku.Price), pricePercentage, 0)) if inSku.VendorPrice <= 0 { inSku.VendorPrice = 1 // 最少1分钱 diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 63c4be009..b4b126001 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -97,9 +97,10 @@ func Init() { func doDailyWork() { globals.SugarLogger.Debug("doDailyWork") - // 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, true, true) netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, 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() } func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) { diff --git a/business/jxstore/misc/misc2.go b/business/jxstore/misc/misc2.go index 2b4a47a44..29d8ea465 100644 --- a/business/jxstore/misc/misc2.go +++ b/business/jxstore/misc/misc2.go @@ -6,6 +6,7 @@ import ( "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/utils" "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/tasksch" "git.rosy.net.cn/jx-callback/business/model" @@ -159,19 +160,38 @@ func StartOrEndOpStore(isStart bool, startTime, endTime int16, isAsync, isContin } func InitEx() { + // 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) + // } + var ( + time1, time2 time.Time + ) + now := time.Now() if globals.IsMainProductEnv() { - ScheduleTimerFunc(func() { - StartOrEndOpStore(true, 0, 0, false, true) - }, startOpStoreTimeListJXCS) - ScheduleTimerFunc(func() { - StartOrEndOpStore(false, 0, 0, false, true) - }, endOpStoreTimeListJXCS) + time1 = jxutils.GetNextTimeFromList(now, startOpStoreTimeListJXCS) + time2 = jxutils.GetNextTimeFromList(now, endOpStoreTimeListJXCS) } else { - ScheduleTimerFunc(func() { + time1 = jxutils.GetNextTimeFromList(now, startOpStoreTimeListJXGY) + time2 = jxutils.GetNextTimeFromList(now, endOpStoreTimeListJXGY) + } + if time1.Sub(now) < 2*time.Hour { + utils.AfterFuncWithRecover(time1.Sub(now), func() { StartOrEndOpStore(true, 0, 0, false, true) - }, startOpStoreTimeListJXGY) - ScheduleTimerFunc(func() { + }) + utils.AfterFuncWithRecover(time2.Sub(now), func() { StartOrEndOpStore(false, 0, 0, false, true) - }, endOpStoreTimeListJXGY) + }) } } diff --git a/business/jxutils/jxutils_cms.go b/business/jxutils/jxutils_cms.go index 9fcd7d2b3..2a78f02c9 100644 --- a/business/jxutils/jxutils_cms.go +++ b/business/jxutils/jxutils_cms.go @@ -260,12 +260,12 @@ func CaculateSkuPriceFromVendor(vendorPrice, percentage, catPercentage int) int return price } -func GetPricePercentage(l model.PricePercentagePack, unitPrice int, defPricePercentage int) (pricePercentage int) { +func GetPricePercentage(l model.PricePercentagePack, price int, defPricePercentage int) (pricePercentage int) { pricePercentage = defPricePercentage if len(l) > 0 { var lastItem *model.PricePercentageItem for _, v := range l { - if v.BeginPrice > unitPrice { + if v.BeginPrice > price { break } lastItem = v diff --git a/business/jxutils/tasksch/task.go b/business/jxutils/tasksch/task.go index 80070a1fc..d386e6caf 100644 --- a/business/jxutils/tasksch/task.go +++ b/business/jxutils/tasksch/task.go @@ -418,14 +418,14 @@ func (t *BaseTask) run(taskHandler func()) { if authInfo, err := t.ctx.GetV2AuthInfo(); err == nil { // 这里应该是不管登录类型,直接以可能的方式发消息 var content string taskDesc := fmt.Sprintf("你的异步任务[%s],ID[%s],开始于:%s,结束于:%s,", t.Name, t.ID, utils.Time2Str(t.CreatedAt), utils.Time2Str(t.TerminatedAt)) - if t.mainErr == nil { - content = fmt.Sprintf("%s执行%s", taskDesc, TaskStatusName[t.Status]) + content = fmt.Sprintf("%s执行%s", taskDesc, TaskStatusName[t.Status]) + if t.Error() == "" { noticeMsg := t.GetNoticeMsg() if noticeMsg != "" { content += ",通知消息:" + noticeMsg } } else { - content = t.Error() + content += ",\n" + t.Error() } msg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content) } diff --git a/business/model/dao/act.go b/business/model/dao/act.go index f66bfe739..a631b193a 100644 --- a/business/model/dao/act.go +++ b/business/model/dao/act.go @@ -308,7 +308,7 @@ func GetExistVendorActIDs(db *DaoDB, vendorID int) (vendorActIDs []string, err e SELECT DISTINCT t1.vendor_act_id FROM act_store_sku_map t1 - WHERE t1.deleted_at = ? AND t.vendor_id = ?` + WHERE t1.deleted_at = ? AND t1.vendor_id = ?` sqlParams := []interface{}{ utils.DefaultTimeValue, vendorID, diff --git a/business/partner/purchase/ebai/store_sku.go b/business/partner/purchase/ebai/store_sku.go index 046f18120..1001b300c 100644 --- a/business/partner/purchase/ebai/store_sku.go +++ b/business/partner/purchase/ebai/store_sku.go @@ -223,7 +223,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks task := tasksch.NewParallelTask("SyncStoreSkus饿百2", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeSku := batchItemList[0].(*tStoreSkuFullInfo) - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSku.UnitPrice, int(storeDetail.PricePercentage)) + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, storeSku.Price, int(storeDetail.PricePercentage)) // globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", storeSku.SkuID, storeSku.Price, pricePercentage) // globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false)) updateFields := []string{model.FieldEbaiSyncStatus} diff --git a/business/partner/purchase/jd/store_sku.go b/business/partner/purchase/jd/store_sku.go index 7f5a36e8f..e7ab65ccf 100644 --- a/business/partner/purchase/jd/store_sku.go +++ b/business/partner/purchase/jd/store_sku.go @@ -65,7 +65,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks } if storeSku.StoreSkuSyncStatus&(model.SyncFlagPriceMask|model.SyncFlagNewMask) != 0 { vendorSkuID4Price = storeSku.VendorSkuID - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(storeSku.UnitPrice), int(storeDetail.PricePercentage)) + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(storeSku.Price), int(storeDetail.PricePercentage)) skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{ OutSkuId: utils.Int2Str(storeSku.SkuID), Price: constrainPrice(jxutils.CaculateSkuVendorPrice(int(storeSku.Price), pricePercentage, storeSku.CatPricePercentage)), diff --git a/business/partner/purchase/mtwm/store_sku.go b/business/partner/purchase/mtwm/store_sku.go index f6c986adc..1288dbd57 100644 --- a/business/partner/purchase/mtwm/store_sku.go +++ b/business/partner/purchase/mtwm/store_sku.go @@ -308,7 +308,7 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks if skuItem.Img == "" { err = fmt.Errorf("SKUNAME%d:%s没有图片,同步失败", skuItem.NameID, skuItem.Name) } else { - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.UnitPrice), int(storeDetail.PricePercentage)) + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.Price), int(storeDetail.PricePercentage)) // globals.SugarLogger.Debugf("skuID:%d, price:%d, pricePercentage:%d", skuItem.SkuID, skuItem.Price, pricePercentage) // globals.SugarLogger.Debugf(utils.Format4Output(storeDetail.PricePercentagePackObj, false)) foodData["name"] = jxutils.ComposeSkuName(skuItem.Prefix, skuItem.Name, skuItem.Comment, skuItem.Unit, skuItem.SpecQuality, skuItem.SpecUnit, mtwmapi.MaxSkuNameCharCount) diff --git a/business/partner/purchase/weimob/wsc/store_sku.go b/business/partner/purchase/weimob/wsc/store_sku.go index 29636a286..9814c1038 100644 --- a/business/partner/purchase/weimob/wsc/store_sku.go +++ b/business/partner/purchase/weimob/wsc/store_sku.go @@ -184,7 +184,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks func(rootTask *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { v := batchItemList[0] skuItem := v.(*dao.StoreSkuSyncInfo) - pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.UnitPrice), int(storeDetail.PricePercentage)) + pricePercentage := jxutils.GetPricePercentage(storeDetail.PricePercentagePackObj, int(skuItem.Price), int(storeDetail.PricePercentage)) updateFields := []string{model.FieldWscSyncStatus} storeSkuBind := &model.StoreSkuBind{} storeSkuBind.ID = skuItem.BindID diff --git a/main.go b/main.go index b0e563a2a..c5c8d3e42 100644 --- a/main.go +++ b/main.go @@ -56,7 +56,6 @@ func Init() { if globals.IsProductEnv() { ebai.CurPurchaseHandler.StartRefreshComment() - misc.InitEx() } misc.Init() }