From 2b69998ee58787dfc4bec343066659d7a83cdc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 4 Nov 2022 18:18:55 +0800 Subject: [PATCH] 1 --- .../jxcallback/scheduler/defsch/defsch_ext.go | 14 +++++--------- business/jxstore/misc/misc.go | 2 +- business/model/const.go | 2 +- business/partner/delivery/dada/waybill.go | 2 -- business/partner/delivery/rider.go | 16 +++++++++------- business/partner/purchase/tiktok_store/order.go | 16 +++++++++++++++- 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/business/jxcallback/scheduler/defsch/defsch_ext.go b/business/jxcallback/scheduler/defsch/defsch_ext.go index dabc1ed6e..8466725c4 100644 --- a/business/jxcallback/scheduler/defsch/defsch_ext.go +++ b/business/jxcallback/scheduler/defsch/defsch_ext.go @@ -82,7 +82,7 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven if order.VendorID == model.VendorIDDD && courierName != "" && courierMobile != "" { timeNow := time.Now() rand.Seed(timeNow.UnixNano()) - randNumber := rand.Int63n(481) + randNumber := rand.Int63n(640) if randNumber < 60 { randNumber += 60 } @@ -104,14 +104,10 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven DeliveryFlag: 0, WaybillCreatedAt: timeNow, WaybillFinishedAt: utils.DefaultTimeValue, - StatusTime: timeNow, - ModelTimeInfo: model.ModelTimeInfo{ - CreatedAt: timeNow, - UpdatedAt: timeNow.Add(randTime), // 下一次更新时间 - }, - OriginalData: "", - Remark: "自定义物流单", - VendorOrgCode: order.VendorOrgCode, + StatusTime: timeNow.Add(randTime), // 下一状态时间 + OriginalData: "", + Remark: "自定义物流单", + VendorOrgCode: order.VendorOrgCode, } err = dao.CreateEntity(dao.GetDB(), bill) } diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 67fdb883f..4af874a1b 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -189,7 +189,7 @@ func Init() { // 每分钟轮询一次,推送抖店骑手信息 ScheduleTimerFuncByInterval(func() { delivery.UpdateFakeWayBillToTiktok() - }, 10*time.Second, 30*time.Second) + }, 10*time.Second, 5*time.Second) // 定时任务更新负责人信息 ScheduleTimerFunc("RefreshStoreOperator", func() { diff --git a/business/model/const.go b/business/model/const.go index e0463bae1..be7314774 100644 --- a/business/model/const.go +++ b/business/model/const.go @@ -330,7 +330,7 @@ const ( WaybillStatusAcceptCanceled = 8 // 取消运单 WaybillStatusAccepted = 10 // 分配骑手,正在接单 WaybillStatusCourierAssigned = 12 // 已分配骑手 - WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态 + WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态 (到店) WaybillStatusApplyFailedGetGoods = 17 // 取货失败待审核 WaybillStatusAgreeFailedGetGoods = 18 // 取货失败 diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index ff5d6beb3..2207c53b5 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -67,7 +67,6 @@ func (c *DeliveryHandler) OnWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap } func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaapi.CallbackResponse) { - globals.SugarLogger.Debugf("onWaybillMsg=================:%s", utils.Format4Output(msg, false)) order := c.callbackMsg2Waybill(msg) switch msg.OrderStatus { case dadaapi.OrderStatusWaitingForAccept: @@ -76,7 +75,6 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee) order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) } - globals.SugarLogger.Debugf("onWaybillMsg====dadaOrder=============:%s", utils.Format4Output(dadaOrder, false)) order.Status = model.WaybillStatusNew case dadaapi.OrderStatusAccepted: order.Status = model.WaybillStatusCourierAssigned diff --git a/business/partner/delivery/rider.go b/business/partner/delivery/rider.go index facaca66f..797358d12 100644 --- a/business/partner/delivery/rider.go +++ b/business/partner/delivery/rider.go @@ -80,6 +80,7 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) { } } } + if riderInfo == nil || wayBillStatus == model.OrderStatusNew || wayBillStatus == model.OrderStatusCanceled || (riderInfo.CourierName == "" && v.WaybillVendorID == -1 && v.DeliveryType == "store") { // 真商家自送 riderInfo.OrderId = v.VendorOrderID riderInfo.CourierName = "石锋" @@ -99,7 +100,6 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) { } riderInfo.ThirdCarrierOrderId = v.VendorWaybillID - globals.SugarLogger.Debugf("=============================caoniam= %s", utils.Format4Output(riderInfo, false)) switch riderInfo.LogisticsStatus { case 5: // 呼叫骑手 riderInfo.LogisticsStatus = 0 @@ -193,6 +193,11 @@ func UpdateOrder2Complete() { // UpdateFakeWayBillToTiktok 轮询更新假订单到抖音 func UpdateFakeWayBillToTiktok() { + scheduleTimer, _ := rand.Int(rand.Reader, big.NewInt(1000)) + randTimeSchedule := scheduleTimer.Int64() + if randTimeSchedule > 200 { + return + } fakeWayBill, err := dao.GetWayBillFakeOrder() if err != nil { @@ -205,8 +210,7 @@ func UpdateFakeWayBillToTiktok() { for i := 0; i < len(fakeWayBill); i++ { // 判断当前订单是否可以推送,UpdatedAt > 当前时间 就跳过 - globals.SugarLogger.Debugf("updateTiem ==== %s,i=[%d],timeNow[%s]", fakeWayBill[i].ModelTimeInfo.UpdatedAt, i, time.Now()) - if fakeWayBill[i].ModelTimeInfo.UpdatedAt.After(time.Now()) { + if fakeWayBill[i].StatusTime.After(time.Now()) { continue } @@ -276,11 +280,9 @@ func UpdateFakeWayBillToTiktok() { if randTime < 66 { randTime += 60 } - fakeWayBill[i].ModelTimeInfo.UpdatedAt = time.Now().Add(time.Duration(randTime) * time.Second) - globals.SugarLogger.Debugf("randNumber :=------------%d", randNumber) - globals.SugarLogger.Debugf("randTime :=------------%d", randTime) + fakeWayBill[i].StatusTime = time.Now().Add(time.Duration(randTime) * time.Second).Local() // 更新假运单 - if _, err := dao.UpdateEntity(dao.GetDB(), fakeWayBill[i], "Status", "VendorStatus", "UpdatedAt"); err != nil { + if _, err := dao.UpdateEntity(dao.GetDB(), fakeWayBill[i], "Status", "VendorStatus", "StatusTime"); err != nil { globals.SugarLogger.Errorf("Update Fake Way Bill Err:%s--%s--%v", riderInfo.OrderId, riderInfo.ThirdCarrierOrderId, err) } // 更新运单为完成状态 diff --git a/business/partner/purchase/tiktok_store/order.go b/business/partner/purchase/tiktok_store/order.go index 88508932b..517ee734c 100644 --- a/business/partner/purchase/tiktok_store/order.go +++ b/business/partner/purchase/tiktok_store/order.go @@ -3,6 +3,7 @@ package tiktok_store import ( "errors" "fmt" + "git.rosy.net.cn/baseapi/platformapi/mtpsapi" order_logisticsAdd_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_logisticsAdd/request" order_orderDetail_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response" tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api" @@ -626,7 +627,20 @@ func (c *PurchaseHandler) SelfDeliverDelivering(order *model.GoodsOrder, userNam return err } - return err + riderInfo := &mtpsapi.RiderInfo{ + OrderId: order.VendorOrderID, + ThirdCarrierOrderId: order.VendorOrderID, + CourierName: "", + CourierPhone: "", + LogisticsProviderCode: "10002", + LogisticsStatus: 0, + LogisticsContext: "呼叫骑手,新建运单", + Latitude: "", + Longitude: "", + OpCode: tiktokShop.TiktokLogisticsStatusCALLRIDER, + } + + return c.GetOrderRider("", "", utils.Struct2MapByJson(riderInfo)) } // SelfDeliverDelivered 自配搜完成(暂无)