- fixed mtps fee cal bug.

This commit is contained in:
gazebo
2018-07-19 21:10:26 +08:00
parent 61157174e6
commit 680c0a0696
6 changed files with 16 additions and 11 deletions

View File

@@ -51,9 +51,9 @@ func (c *WaybillController) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal
order := c.callbackMsg2Waybill(msg)
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule:
order.DesiredFee = c.calculateDeliveryFee(order)
order.Status = model.WaybillStatusNew
case mtpsapi.OrderStatusAccepted:
order.DesiredFee = c.calculateDeliveryFee(order)
order.Status = model.WaybillStatusAccepted
case mtpsapi.OrderStatusPickedUp:
order.Status = model.WaybillStatusDelivering
@@ -126,6 +126,14 @@ func (c *WaybillController) calculateDeliveryFee(bill *model.Waybill) (retVal in
} else {
delieveryFee += controller.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)
} else if totalSeconds >= 21*3600 || totalSeconds <= 6*3600 { // 21:00 -- 06:00
delieveryFee += controller.StandardPrice2Int(3)
}
return delieveryFee
}