1
This commit is contained in:
@@ -58,7 +58,7 @@ func (w *OrderManager) LoadPendingWaybills() []*model.Waybill {
|
||||
return bills
|
||||
}
|
||||
|
||||
func (w *OrderManager) onWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
func (w *OrderManager) OnWaybillNew(bill2 *model.Waybill, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
isDuplicated, err = addOrderOrWaybillStatus(model.Waybill2Status(bill2), db)
|
||||
if err == nil && !isDuplicated {
|
||||
bill2.ID = 0
|
||||
@@ -111,7 +111,7 @@ func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) {
|
||||
}()
|
||||
duplicatedCount := 0
|
||||
if bill.Status == model.WaybillStatusNew {
|
||||
isDuplicated, err = w.onWaybillNew(bill, db)
|
||||
isDuplicated, err = w.OnWaybillNew(bill, db)
|
||||
if isDuplicated {
|
||||
duplicatedCount = 1
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (w *OrderManager) OnWaybillStatusChanged(bill *model.Waybill) (err error) {
|
||||
existingBill = bill
|
||||
billCopy := *bill
|
||||
billCopy.Status = model.WaybillStatusNew
|
||||
if isDuplicated, err = w.onWaybillNew(&billCopy, db); err != nil {
|
||||
if isDuplicated, err = w.OnWaybillNew(&billCopy, db); err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package defsch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"math"
|
||||
"time"
|
||||
@@ -23,14 +24,14 @@ func (s *DefScheduler) loadSavedOrderByID(vendorOrderID string, vendorID int, is
|
||||
}, isForceLoad)
|
||||
}
|
||||
|
||||
func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, vendorOrderID string, vendorID int, userName string) (err error) {
|
||||
func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, vendorOrderID string, vendorID int, userName, courierName, courierMobile string) (err error) {
|
||||
var order *model.GoodsOrder
|
||||
jxutils.CallMsgHandler(func() {
|
||||
err = func() (err error) {
|
||||
savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true)
|
||||
if savedOrderInfo != nil {
|
||||
order = savedOrderInfo.order
|
||||
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil {
|
||||
if err = s.isPossibleSwitch2SelfDelivery(order); err == nil { // 是否能转自送
|
||||
err = s.cancelOtherWaybillsCheckOrderDeliveryFlag(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive)
|
||||
if err == nil {
|
||||
if model.IsOrderDeliveryByStore(order) {
|
||||
@@ -76,6 +77,39 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
remark = err.Error()
|
||||
}
|
||||
partner.CurOrderManager.OnOrderMsg(order, vendorStatus, remark)
|
||||
// 上面是真的转自送,支持美团,饿百,京东,如果时抖店,抖店暂时全部是自送的!但是有骑手信息时,就是一个白嫖单子!
|
||||
if order.VendorID == model.VendorIDDD && courierName != "" && courierMobile != "" {
|
||||
timeNow := time.Now()
|
||||
var randData = []int64{1, 2, 3, 4, 5}
|
||||
randTime := time.Duration(randData[0]) * time.Minute
|
||||
bill := &model.Waybill{
|
||||
VendorWaybillID: order.VendorOrderID,
|
||||
VendorWaybillID2: "",
|
||||
WaybillVendorID: model.VendorJXFakeWL,
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
OrderVendorID: model.VendorIDDD,
|
||||
CourierName: courierName,
|
||||
CourierMobile: courierMobile,
|
||||
Status: model.OrderStatusNew,
|
||||
VendorStatus: utils.Int2Str(model.OrderStatusNew),
|
||||
ActualFee: 500,
|
||||
DesiredFee: order.ActualPayPrice,
|
||||
TipFee: 0,
|
||||
DuplicatedCount: 0,
|
||||
DeliveryFlag: 0,
|
||||
WaybillCreatedAt: timeNow,
|
||||
WaybillFinishedAt: utils.DefaultTimeValue,
|
||||
StatusTime: timeNow,
|
||||
ModelTimeInfo: model.ModelTimeInfo{
|
||||
CreatedAt: timeNow,
|
||||
UpdatedAt: timeNow.Add(randTime), // 下一次更新时间
|
||||
},
|
||||
OriginalData: "",
|
||||
Remark: "自定义物流单",
|
||||
VendorOrgCode: order.VendorOrgCode,
|
||||
}
|
||||
err = dao.CreateEntity(dao.GetDB(), bill)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user