- move some funcs from controller to jxutils.
This commit is contained in:
@@ -108,31 +108,31 @@ func (c *WaybillController) calculateDeliveryFee(bill *model.Waybill) (retVal in
|
||||
|
||||
lng := utils.Str2Float64(lists[0][1].(string))
|
||||
lat := utils.Str2Float64(lists[0][2].(string))
|
||||
lng2, lat2, _ := controller.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
lng2, lat2, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
|
||||
distance := jxutils.EarthDistance(lat, lng, lat2, lng2) * 1.4
|
||||
if distance < 3 {
|
||||
} else if distance < 5 {
|
||||
delieveryFee += controller.StandardPrice2Int(math.Ceil(distance - 3))
|
||||
delieveryFee += jxutils.StandardPrice2Int(math.Ceil(distance - 3))
|
||||
} else {
|
||||
delieveryFee += controller.StandardPrice2Int(2 + 2*math.Ceil(distance-5))
|
||||
delieveryFee += jxutils.StandardPrice2Int(2 + 2*math.Ceil(distance-5))
|
||||
}
|
||||
|
||||
if order.Weight < 5*1000 {
|
||||
} else if order.Weight < 10*1000 {
|
||||
delieveryFee += controller.StandardPrice2Int(0.5 * float64(order.Weight/1000-5))
|
||||
delieveryFee += jxutils.StandardPrice2Int(0.5 * float64(order.Weight/1000-5))
|
||||
} else if order.Weight < 20*1000 {
|
||||
delieveryFee += controller.StandardPrice2Int(2.5 + 1*float64(order.Weight/1000-10))
|
||||
delieveryFee += jxutils.StandardPrice2Int(2.5 + 1*float64(order.Weight/1000-10))
|
||||
} else {
|
||||
delieveryFee += controller.StandardPrice2Int(2.5 + 10 + 2*float64(order.Weight/1000-20))
|
||||
delieveryFee += jxutils.StandardPrice2Int(2.5 + 10 + 2*float64(order.Weight/1000-20))
|
||||
}
|
||||
|
||||
hour, min, sec := bill.WaybillCreatedAt.Clock()
|
||||
totalSeconds := hour*3600 + min*60 + sec
|
||||
if totalSeconds >= 11*3600+30*60 && totalSeconds <= 13*3600 { // 11:30 -- 13:00
|
||||
delieveryFee += controller.StandardPrice2Int(3)
|
||||
delieveryFee += jxutils.StandardPrice2Int(3)
|
||||
} else if totalSeconds >= 21*3600 || totalSeconds <= 6*3600 { // 21:00 -- 06:00
|
||||
delieveryFee += controller.StandardPrice2Int(3)
|
||||
delieveryFee += jxutils.StandardPrice2Int(3)
|
||||
}
|
||||
return delieveryFee
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
|
||||
|
||||
db := orm.NewOrm()
|
||||
// 忽略坐标转换错误,即使是转换出错,也只能当成转换成功来处理,底层会有错误日志输出
|
||||
lngFloat, latFloat, _ := controller.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
lngFloat, latFloat, _ := jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams := &mtpsapi.CreateOrderByShopParam{
|
||||
OrderID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
|
||||
DeliveryServiceCode: mtpsapi.DeliveryServiceCodeRapid,
|
||||
@@ -152,9 +152,9 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
|
||||
ReceiverAddress: order.ConsigneeAddress,
|
||||
ReceiverPhone: order.ConsigneeMobile,
|
||||
CoordinateType: model.CoordinateTypeMars,
|
||||
ReceiverLng: controller.StandardCoordinate2Int(lngFloat),
|
||||
ReceiverLat: controller.StandardCoordinate2Int(latFloat),
|
||||
GoodsValue: controller.IntPrice2Standard(order.SalePrice), // todo 超价处理
|
||||
ReceiverLng: jxutils.StandardCoordinate2Int(lngFloat),
|
||||
ReceiverLat: jxutils.StandardCoordinate2Int(latFloat),
|
||||
GoodsValue: jxutils.IntPrice2Standard(order.SalePrice), // todo 超价处理
|
||||
GoodsWeight: float64(order.Weight) / 1000,
|
||||
ExpectedDeliveryTime: order.ExpectedDeliveredTime.Unix(),
|
||||
OrderType: mtpsapi.OrderTypeASAP,
|
||||
@@ -168,7 +168,7 @@ func (c *WaybillController) CreateWaybill(order *model.GoodsOrder) (err error) {
|
||||
goodItem := &mtpsapi.GoodsItem{
|
||||
GoodCount: sku.Count,
|
||||
GoodName: sku.SkuName,
|
||||
GoodPrice: controller.IntPrice2Standard(sku.SalePrice),
|
||||
GoodPrice: jxutils.IntPrice2Standard(sku.SalePrice),
|
||||
GoodUnit: "", //这个应该不是必须的,商品名里已经有UNIT的字样了
|
||||
}
|
||||
goods.Goods = append(goods.Goods, goodItem)
|
||||
|
||||
Reference in New Issue
Block a user