物料订单配送费计算
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user