This commit is contained in:
richboo111
2023-05-29 10:24:43 +08:00
parent 14c8c32e47
commit d0ff027799
6 changed files with 61 additions and 16 deletions

View File

@@ -132,18 +132,22 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
}
param.OrderDetail.ProductDetail = productDetail
sfOrderID, sfBillID, sfTotalPrice, err := api.SfPsAPI.CreateOrder(param)
sfOrderID, sfBillID, sfTotalPrice, sfReallyPrice, err := api.SfPsAPI.CreateOrder(param)
if err != nil {
return nil, err
}
//+0.2
desiredFee := utils.Float64TwoInt(sfTotalPrice) + utils.WayBillDeliveryMarkUp
bill = &model.Waybill{
VendorOrderID: order.VendorOrderID,
OrderVendorID: order.VendorID,
VendorWaybillID: sfOrderID,
VendorWaybillID2: sfBillID,
WaybillVendorID: model.VendorIDFengNiao,
DesiredFee: int64(sfTotalPrice),
DesiredFee: int64(desiredFee),
ActualFee: utils.Float64TwoInt64(sfReallyPrice),
}
delivery.OnWaybillCreated(bill)
return bill, err
@@ -190,7 +194,10 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
}
deliveryFeeInfo = &partner.WaybillFeeInfo{}
price, err := api.SfPsAPI.PreCreateOrder(param)
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(price)
//+0.2
deliveryFee := utils.Float64TwoInt(price) + utils.WayBillDeliveryMarkUp
deliveryFeeInfo.DeliveryFee = int64(deliveryFee)
return deliveryFeeInfo, err
}
@@ -208,7 +215,7 @@ func (d DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId s
if deductionFee == 0 || err != nil {
return 0, err
}
money = jxutils.StandardPrice2Int(deductionFee)
money = utils.Float64TwoInt64(deductionFee)
return money, nil
}
@@ -283,6 +290,10 @@ func OnWaybillMsg(msg *sfps2.RiderStatus) (resp *sfps2.CallbackResponse) {
if err != nil {
return sfps2.Err2CallbackResponse(err)
}
//+0.2
sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) + utils.WayBillDeliveryMarkUp
sfActualPrice := utils.Float64TwoInt64(sfOrder.RealPayMoney)
var good *model.GoodsOrder
sql := `SELECT * FROM goods_order WHERE vendor_order_id = ? ORDER BY order_created_at DESC LIMIT 1 OFFSET 0`
sqlParams := []interface{}{msg.ShopOrderID}
@@ -292,20 +303,21 @@ func OnWaybillMsg(msg *sfps2.RiderStatus) (resp *sfps2.CallbackResponse) {
orderStatus := utils.Str2Int64(order.VendorStatus)
switch orderStatus {
case sfps2.OrderStatusNewOrder: //1订单创建
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
order.DesiredFee = int64(sfTotalPrice)
order.ActualFee = sfActualPrice
order.Status = model.WaybillStatusNew //5 带调度
case sfps2.OrderStatusTakeOrder: //10配送员接单
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
order.DesiredFee = int64(sfTotalPrice)
order.Status = model.WaybillStatusCourierAssigned //12
order.Remark = order.CourierName + "" + order.CourierMobile
case sfps2.OrderStatusArrivedStore:
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
order.DesiredFee = int64(sfTotalPrice)
order.Status = model.WaybillStatusCourierArrived
case sfps2.OrderStatusRiderArriving:
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
order.DesiredFee = int64(sfTotalPrice)
order.Status = model.WaybillStatusDelivering
case sfps2.OrderStatusFinished:
order.DesiredFee = jxutils.StandardPrice2Int(sfOrder.TotalPrice)
order.DesiredFee = int64(sfTotalPrice)
order.Status = model.WaybillStatusDelivered
case sfps2.OrderStatusOrderCancel:
order.Status = model.WaybillStatusCanceled