This commit is contained in:
邹宗楠
2022-11-04 18:18:55 +08:00
parent 7d6bd131a7
commit 2b69998ee5
6 changed files with 31 additions and 21 deletions

View File

@@ -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)
}

View File

@@ -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() {

View File

@@ -330,7 +330,7 @@ const (
WaybillStatusAcceptCanceled = 8 // 取消运单
WaybillStatusAccepted = 10 // 分配骑手,正在接单
WaybillStatusCourierAssigned = 12 // 已分配骑手
WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态
WaybillStatusCourierArrived = 15 // 此状态是可选的,明确写出来是因为还是较重要的状态,但业务逻辑不应依赖此状态 (到店)
WaybillStatusApplyFailedGetGoods = 17 // 取货失败待审核
WaybillStatusAgreeFailedGetGoods = 18 // 取货失败

View File

@@ -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

View File

@@ -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)
}
// 更新运单为完成状态

View File

@@ -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 自配搜完成(暂无)