- treat DeliveryStatusFailedGetGoods as WaybillStatusFailed for jd waybill
- adjust defsch.
This commit is contained in:
@@ -281,10 +281,20 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
s.CancelWaybill(bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else if order.WaybillVendorID != model.VendorIDUnknown {
|
||||
globals.SugarLogger.Debugf("OnWaybillStatusChanged multiple waybill created, bill:%v", bill)
|
||||
if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID {
|
||||
if order.VendorID == bill.WaybillVendorID { // 是购物平台运单
|
||||
if order.VendorID != order.WaybillVendorID { // 既有运单不是购物平台运单
|
||||
globals.SugarLogger.Infof("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
|
||||
oldBill := savedOrderInfo.waybills[order.WaybillVendorID]
|
||||
if oldBill != nil {
|
||||
s.CancelWaybill(oldBill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else {
|
||||
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v, oldBill is null, strange!!!", bill)
|
||||
}
|
||||
}
|
||||
bill.WaybillVendorID = model.VendorIDUnknown
|
||||
s.updateOrderByBill(order, bill, false)
|
||||
} else {
|
||||
s.CancelWaybill(bill, partner.CancelWaybillReasonNotAcceptIntime, partner.CancelWaybillReasonStrNotAcceptIntime)
|
||||
} else if bill.WaybillVendorID == order.VendorID && order.WaybillVendorID != order.VendorID {
|
||||
globals.SugarLogger.Warnf("OnWaybillStatusChanged bill:%v purchase platform bill came later than others, strange!!!", bill)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,6 +433,7 @@ func (s *DefScheduler) removeWaybillFromMap(savedOrderInfo *WatchOrderInfo, wayb
|
||||
func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInfo, excludeBill *model.Waybill) (err error) {
|
||||
order := savedOrderInfo.order
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders, orderID:%s, status:%d, excludeBill:%v", order.VendorOrderID, order.Status, excludeBill)
|
||||
if order.WaybillVendorID == model.VendorIDUnknown {
|
||||
if order.LockStatus == model.OrderStatusUnknown && order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin { // 订单在配送中被取消时就是配送中状态
|
||||
if (order.DeliveryFlag & model.OrderDeliveryFlagMaskScheduleDisabled) == 0 {
|
||||
if savedOrderInfo.retryCount <= maxWaybillRetryCount {
|
||||
@@ -474,6 +485,9 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders, orderID:%s, status:%d doesn't match model.OrderStatusFinishedPickup, bypass", order.VendorOrderID, order.Status)
|
||||
}
|
||||
} else {
|
||||
globals.SugarLogger.Debugf("createWaybillOn3rdProviders, orderID:%s, waybillVendorID:%d, vendorWaybilID:%s is not empty, bypass", order.VendorOrderID, order.WaybillVendorID, order.VendorWaybillID)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ func CallMsgHandlerAsync(handler func(), primaryID string) {
|
||||
}, primaryID)
|
||||
}
|
||||
|
||||
func SplitSkuName(fullName string) (name string, unit string) {
|
||||
func GetNameAndUnitFromSkuName(fullName string) (name string, unit string) {
|
||||
unit = "份"
|
||||
index := strings.Index(fullName, "/")
|
||||
if index >= 0 {
|
||||
|
||||
@@ -29,24 +29,24 @@ func TestMapValue2Scope(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitSkuName(t *testing.T) {
|
||||
name, unit := SplitSkuName("【满59免运】蒜苔肉丝约400g/个(蒜苔约250g 肉丝约150g/份)")
|
||||
func TestGetNameAndUnitFromSkuName(t *testing.T) {
|
||||
name, unit := GetNameAndUnitFromSkuName("【满59免运】蒜苔肉丝约400g/个(蒜苔约250g 肉丝约150g/份)")
|
||||
if name != "【满59免运】蒜苔肉丝约400g" || unit != "个" {
|
||||
t.Fatalf("SplitSkuName wrong, name:%s, unit:%s", name, unit)
|
||||
}
|
||||
name, unit = SplitSkuName("【满59免运】蒜苔肉丝约400g/g份(蒜苔约250g 肉丝约150g/份)")
|
||||
name, unit = GetNameAndUnitFromSkuName("【满59免运】蒜苔肉丝约400g/g份(蒜苔约250g 肉丝约150g/份)")
|
||||
if name != "【满59免运】蒜苔肉丝约400g" || unit != "g" {
|
||||
t.Fatalf("SplitSkuName wrong, name:%s, unit:%s", name, unit)
|
||||
}
|
||||
name, unit = SplitSkuName("【满59免运】蒜苔肉丝约400g/个")
|
||||
name, unit = GetNameAndUnitFromSkuName("【满59免运】蒜苔肉丝约400g/个")
|
||||
if name != "【满59免运】蒜苔肉丝约400g" || unit != "个" {
|
||||
t.Fatalf("SplitSkuName wrong, name:%s, unit:%s", name, unit)
|
||||
}
|
||||
name, unit = SplitSkuName("【满59免运】蒜苔肉丝约400g/")
|
||||
name, unit = GetNameAndUnitFromSkuName("【满59免运】蒜苔肉丝约400g/")
|
||||
if name != "【满59免运】蒜苔肉丝约400g" || unit != "份" {
|
||||
t.Fatalf("SplitSkuName wrong, name:%s, unit:%s", name, unit)
|
||||
}
|
||||
name, unit = SplitSkuName("【满59免运】蒜苔肉丝约400g")
|
||||
name, unit = GetNameAndUnitFromSkuName("【满59免运】蒜苔肉丝约400g")
|
||||
if name != "【满59免运】蒜苔肉丝约400g" || unit != "份" {
|
||||
t.Fatalf("SplitSkuName wrong, name:%s, unit:%s", name, unit)
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ func (c *DeliveryHandler) calculateOrderDeliveryFee(order *model.GoodsOrder, bil
|
||||
return 0, 0, ErrStoreNoPriceInfo
|
||||
}
|
||||
|
||||
lng := utils.Str2Float64(lists[0][1].(string))
|
||||
lat := utils.Str2Float64(lists[0][2].(string))
|
||||
lng := utils.Str2Float64(utils.Interface2String(lists[0][1]))
|
||||
lat := utils.Str2Float64(utils.Interface2String(lists[0][2]))
|
||||
if lng == 0 || lat == 0 {
|
||||
globals.SugarLogger.Warnf("calculateDeliveryFee can not calculate delivery fee for orderID:%s, because no coordinate info", order.VendorOrderID)
|
||||
return 0, 0, ErrStoreNoCoordinate
|
||||
@@ -207,7 +207,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, policy func(del
|
||||
GoodCount: sku.Count,
|
||||
GoodPrice: jxutils.IntPrice2Standard(sku.SalePrice),
|
||||
}
|
||||
goodItem.GoodName, goodItem.GoodUnit = jxutils.SplitSkuName(sku.SkuName)
|
||||
goodItem.GoodName, goodItem.GoodUnit = jxutils.GetNameAndUnitFromSkuName(sku.SkuName)
|
||||
// 好像SKU名不能重复,否则会报错,尝试处理一下
|
||||
if item, ok := goodItemMap[goodItem.GoodName]; !ok {
|
||||
goods.Goods = append(goods.Goods, goodItem)
|
||||
|
||||
@@ -38,7 +38,7 @@ func (c *PurchaseHandler) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (re
|
||||
order.Status = model.WaybillStatusDelivering
|
||||
case jdapi.DeliveryStatusFinished:
|
||||
order.Status = model.WaybillStatusDelivered
|
||||
case jdapi.DeliveryStatusFailedDelivery: //, jdapi.DeliveryStatusFailedGetGoods: todo 取货失败不当成投递失败
|
||||
case jdapi.DeliveryStatusFailedDelivery, jdapi.DeliveryStatusFailedGetGoods: // todo 取货失败需不需要当成运单失败?
|
||||
order.Status = model.WaybillStatusFailed
|
||||
default:
|
||||
order.Status = model.WaybillStatusUnknown
|
||||
|
||||
Reference in New Issue
Block a user