From c52e8deade839c062437447b0c8f671766ba5d2d Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 5 Sep 2018 22:48:15 +0800 Subject: [PATCH 1/2] - fix calculateOrderDeliveryFee bug for weight. --- business/jxcallback/orderman/order_legacy.go | 2 +- business/partner/delivery/dada/waybill.go | 2 +- business/partner/delivery/mtps/waybill.go | 8 ++++---- business/partner/purchase/jd/order.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/business/jxcallback/orderman/order_legacy.go b/business/jxcallback/orderman/order_legacy.go index b77f707c5..84555f237 100644 --- a/business/jxcallback/orderman/order_legacy.go +++ b/business/jxcallback/orderman/order_legacy.go @@ -170,7 +170,7 @@ func (c *OrderManager) legacyWriteJxOrder(order *model.GoodsOrder, db orm.Ormer, OrderTotalMoney: int(order.SalePrice), OrderDiscountMoney: int(order.SalePrice - order.ActualPayPrice), OrderBuyerPayableMoney: int(order.ActualPayPrice), - // DeliveryPackageWeight: float64(order.Weight) / 1000, + // DeliveryPackageWeight: float64(jxutils.IntWeight2Float(order.Weight)), } if order.VendorID == model.VendorIDELM { jxorder.OrderStatus = JX_ORDER_STATUS_WAIT_FOR_DELIVERY diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index 0c42a25e6..5b5f0913c 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -112,7 +112,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, policy func(del // "origin_mark": model.VendorNames[order.VendorID], "origin_mark_no": fmt.Sprintf("%d", order.OrderSeq), "cargo_type": 13, - "cargo_weight": float64(order.Weight) / 1000.0, + "cargo_weight": jxutils.IntWeight2Float(order.Weight), "cargo_num": order.GoodsCount, } diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index bd9495861..b8b4ceddc 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -144,11 +144,11 @@ func (c *DeliveryHandler) calculateOrderDeliveryFee(order *model.GoodsOrder, bil if order.Weight < 5*1000 { } else if order.Weight < 10*1000 { - addFee += jxutils.StandardPrice2Int(0.5 * float64(order.Weight/1000-5)) + addFee += jxutils.StandardPrice2Int(0.5 * float64(jxutils.IntWeight2Float(order.Weight)-5)) } else if order.Weight < 20*1000 { - addFee += jxutils.StandardPrice2Int(2.5 + 1*float64(order.Weight/1000-10)) + addFee += jxutils.StandardPrice2Int(2.5 + 1*float64(jxutils.IntWeight2Float(order.Weight)-10)) } else { - addFee += jxutils.StandardPrice2Int(2.5 + 10 + 2*float64(order.Weight/1000-20)) + addFee += jxutils.StandardPrice2Int(2.5 + 10 + 2*float64(jxutils.IntWeight2Float(order.Weight)-20)) } hour, min, sec := billTime.Clock() @@ -191,7 +191,7 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, policy func(del ReceiverLng: jxutils.StandardCoordinate2Int(lngFloat), ReceiverLat: jxutils.StandardCoordinate2Int(latFloat), GoodsValue: jxutils.IntPrice2Standard(order.ActualPayPrice), // todo 超价处理 - GoodsWeight: float64(order.Weight) / 1000, + GoodsWeight: float64(jxutils.IntWeight2Float(order.Weight)), // ExpectedDeliveryTime: order.ExpectedDeliveredTime.Unix(), OrderType: mtpsapi.OrderTypeASAP, } diff --git a/business/partner/purchase/jd/order.go b/business/partner/purchase/jd/order.go index ee4c40c87..bcc690d14 100644 --- a/business/partner/purchase/jd/order.go +++ b/business/partner/purchase/jd/order.go @@ -114,7 +114,7 @@ func (c *PurchaseHandler) GetOrder(orderID string) (order *model.GoodsOrder, err SkuID: int(utils.Str2Int64WithDefault(utils.Interface2String(product["skuIdIsv"]), 0)), VendorSkuID: utils.Int64ToStr(utils.MustInterface2Int64(product["skuId"])), SkuName: product["skuName"].(string), - Weight: int(utils.MustInterface2Float64(product["skuWeight"]) * 1000), + Weight: jxutils.FloatWeight2Int(float32(utils.MustInterface2Float64(product["skuWeight"]))), SalePrice: utils.MustInterface2Int64(product["skuJdPrice"]), PromotionType: int(utils.MustInterface2Int64(product["promotionType"])), } From f44f9476294ba8cacee8c6b933ff9e3f735c6fba Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 5 Sep 2018 23:19:22 +0800 Subject: [PATCH 2/2] - change mtps extra fee time from 11:30-13:00 to 11:00-14:00 --- business/partner/delivery/mtps/waybill.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index b8b4ceddc..551bdf32a 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -153,11 +153,12 @@ func (c *DeliveryHandler) calculateOrderDeliveryFee(order *model.GoodsOrder, bil hour, min, sec := billTime.Clock() totalSeconds := hour*3600 + min*60 + sec - if totalSeconds >= 11*3600+30*60 && totalSeconds <= 13*3600 { // 11:30 -- 13:00 - addFee += jxutils.StandardPrice2Int(3) - } else if totalSeconds >= 21*3600 || totalSeconds <= 6*3600 { // 21:00 -- 06:00 + if totalSeconds >= 11*3600 && totalSeconds <= 14*3600 { // 11:00 -- 14:00 addFee += jxutils.StandardPrice2Int(3) } + // else if totalSeconds >= 21*3600 || totalSeconds <= 6*3600 { // 21:00 -- 06:00 + // addFee += jxutils.StandardPrice2Int(3) + // } return deliveryFee + addFee, addFee, nil }