- fixed mtps fee cal bug.
This commit is contained in:
@@ -29,11 +29,11 @@ func (c *WaybillController) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dada
|
||||
order := c.callbackMsg2Waybill(msg)
|
||||
switch msg.OrderStatus {
|
||||
case dadaapi.OrderStatusWaitingForAccept:
|
||||
order.Status = model.WaybillStatusNew
|
||||
case dadaapi.OrderStatusAccepted:
|
||||
if result, err := api.DadaAPI.QueryOrderInfo(msg.OrderID); err == nil {
|
||||
order.DesiredFee = controller.StandardPrice2Int(utils.Interface2FloatWithDefault(result["deliveryFee"], 0.0))
|
||||
}
|
||||
order.Status = model.WaybillStatusNew
|
||||
case dadaapi.OrderStatusAccepted:
|
||||
order.Status = model.WaybillStatusAccepted
|
||||
case dadaapi.OrderStatusDelivering:
|
||||
order.Status = model.WaybillStatusDelivering
|
||||
|
||||
@@ -24,12 +24,12 @@ func (c *WaybillController) OnWaybillStatusMsg(msg *elmapi.CallbackWaybillStatus
|
||||
func (c *WaybillController) onWaybillStatusMsg(msg *elmapi.CallbackWaybillStatusMsg) (retVal *elmapi.CallbackResponse) {
|
||||
order := c.callbackMsg2Waybill(msg)
|
||||
if msg.MsgType == elmapi.MsgTypeWaybillWait4DeliveryVendor {
|
||||
order.Status = model.WaybillStatusNew
|
||||
} else if msg.MsgType == elmapi.MsgTypeWaybillPickingUp {
|
||||
if result, err := api.ElmAPI.GetOrder(msg.OrderID); err == nil {
|
||||
order.DesiredFee = controller.StandardPrice2Int(utils.Interface2FloatWithDefault(result["deliverFee"], 0.0) +
|
||||
utils.Interface2FloatWithDefault(result["vipDeliveryFeeDiscount"], 0.0))
|
||||
}
|
||||
order.Status = model.WaybillStatusNew
|
||||
} else if msg.MsgType == elmapi.MsgTypeWaybillPickingUp {
|
||||
order.Status = model.WaybillStatusAccepted
|
||||
} else if msg.MsgType == elmapi.MsgTypeWaybillCourierArrived {
|
||||
order.Status = model.WaybillStatusCourierArrived
|
||||
|
||||
@@ -23,13 +23,13 @@ func (c *WaybillController) onWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (
|
||||
order := c.callbackMsg2Waybill(msg)
|
||||
switch msg.DeliveryStatus {
|
||||
case jdapi.DeliveryStatusWait4Grap:
|
||||
order.Status = model.WaybillStatusNew
|
||||
case jdapi.DeliveryStatusAccepted:
|
||||
if result, err := api.JdAPI.QuerySingleOrder(msg.OrderID); err == nil {
|
||||
order.DesiredFee = utils.Interface2Int64WithDefault(result["orderFreightMoney"], 0) +
|
||||
utils.Interface2Int64WithDefault(result["merchantPaymentDistanceFreightMoney"], 0) +
|
||||
utils.Interface2Int64WithDefault(result["tips"], 0)
|
||||
}
|
||||
order.Status = model.WaybillStatusNew
|
||||
case jdapi.DeliveryStatusAccepted:
|
||||
order.Status = model.WaybillStatusAccepted
|
||||
case jdapi.DeliveryStatusCourierCanceled:
|
||||
order.Status = model.WaybillStatusCanceled
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ func (w *WaybillController) onWaybillAccepted(bill *model.Waybill) (err error) {
|
||||
params := orm.Params{
|
||||
"courier_name": bill.CourierName,
|
||||
"courier_mobile": bill.CourierMobile,
|
||||
"desired_fee": bill.DesiredFee,
|
||||
}
|
||||
utils.CallFuncLogError(func() error {
|
||||
_, err = db.QueryTable("waybill").Filter("vendor_waybill_id", bill.VendorWaybillID).Filter("waybill_vendor_id", bill.WaybillVendorID).Update(params)
|
||||
|
||||
4
main.go
4
main.go
@@ -1,10 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "git.rosy.net.cn/jx-callback/business/controller/dada"
|
||||
_ "git.rosy.net.cn/jx-callback/business/controller/elm"
|
||||
_ "git.rosy.net.cn/jx-callback/business/controller/jd"
|
||||
_ "git.rosy.net.cn/jx-callback/business/controller/mtps"
|
||||
"git.rosy.net.cn/jx-callback/legacy/jd/controller"
|
||||
"git.rosy.net.cn/jx-callback/legacy/tasks"
|
||||
_ "git.rosy.net.cn/jx-callback/routers"
|
||||
|
||||
Reference in New Issue
Block a user