From 6e63e6f7e8d2922650ca05a9c9fc455b26ecbcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 10 Mar 2020 18:11:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E8=AE=A2=E5=8D=95=E9=85=8D?= =?UTF-8?q?=E9=80=81=E8=B4=B9=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jx/localjx/order.go | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index ce883db75..149845802 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -421,16 +421,6 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64 outJxOrder = &outJxOrder2 outJxOrder.StoreName = storeDetail.Name - //表示此订单为物料配送订单 - if fromStoreID != 0 { - storeDetail2, err2 := dao.GetStoreDetail(db, fromStoreID, model.VendorIDJX) - if err = err2; err != nil { - return nil, nil, fmt.Errorf("fromStoreID有误,[%v]", fromStoreID) - } - deliveryAddress.ConsigneeName = storeDetail2.Name - outJxOrder.FromStoreID = fromStoreID - } - skus := formalizeSkus(jxOrder.Skus) // 允许空商品列表(一般用于测试配送地址,门店信息是否合适) if len(skus) > 0 { @@ -501,23 +491,40 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64 } } } - sort.Sort(JxSkuInfoList(outJxOrder.Skus)) - outJxOrder.FreightPrice, _, err = delivery.CalculateDeliveryFee(dao.GetDB(), jxOrder.StoreID, "", - jxutils.StandardCoordinate2Int(deliveryAddress.Lng), jxutils.StandardCoordinate2Int(deliveryAddress.Lat), - model.CoordinateTypeMars, outJxOrder.Weight, checkTime) + if fromStoreID == 0 { + sort.Sort(JxSkuInfoList(outJxOrder.Skus)) + outJxOrder.FreightPrice, _, err = delivery.CalculateDeliveryFee(dao.GetDB(), jxOrder.StoreID, "", + jxutils.StandardCoordinate2Int(deliveryAddress.Lng), jxutils.StandardCoordinate2Int(deliveryAddress.Lat), + model.CoordinateTypeMars, outJxOrder.Weight, checkTime) + } // if jxOrder.StoreID == specialStoreID { // outJxOrder.FreightPrice = 0 // } } else { outJxOrder.FreightPrice = 0 } - if outJxOrder.FreightPrice > specialFreightPrice { - outJxOrder.FreightPrice = specialFreightPrice - } - if outJxOrder.OrderPrice >= int64(storeDetail.DeliveryFeeDeductionSill) { - outJxOrder.FreightPrice -= int64(storeDetail.DeliveryFeeDeductionFee) - if outJxOrder.FreightPrice < 0 { - outJxOrder.FreightPrice = 0 + //表示此订单为物料配送订单 + if fromStoreID != 0 { + storeDetail2, err2 := dao.GetStoreDetail(db, fromStoreID, model.VendorIDJX) + if err = err2; err != nil { + return nil, nil, fmt.Errorf("fromStoreID有误,[%v]", fromStoreID) + } + deliveryAddress.ConsigneeName = storeDetail2.Name + outJxOrder.FromStoreID = fromStoreID + if outJxOrder.Weight <= 2000 { + outJxOrder.FreightPrice = 500 + } else { + outJxOrder.FreightPrice = utils.Float64TwoInt64(500 + math.Ceil((utils.Int2Float64(outJxOrder.Weight)-2000)/1000)*200) + } + } else { + if outJxOrder.FreightPrice > specialFreightPrice { + outJxOrder.FreightPrice = specialFreightPrice + } + if outJxOrder.OrderPrice >= int64(storeDetail.DeliveryFeeDeductionSill) { + outJxOrder.FreightPrice -= int64(storeDetail.DeliveryFeeDeductionFee) + if outJxOrder.FreightPrice < 0 { + outJxOrder.FreightPrice = 0 + } } } if err == nil {