This commit is contained in:
邹宗楠
2023-06-07 11:20:46 +08:00
parent f0422dae20
commit 2b4b23b2f5
9 changed files with 44 additions and 21 deletions

View File

@@ -80,13 +80,14 @@ func (c *DeliveryHandler) OnWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
}
func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
order, goodsOrder := c.callbackMsg2Waybill(msg)
store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode)
switch msg.OrderStatus {
case dadaapi.OrderStatusWaitingForAccept:
dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID)
if err == nil {
order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup)
}
order.Status = model.WaybillStatusNew
case dadaapi.OrderStatusAccepted:
@@ -94,7 +95,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
order.Remark = order.CourierName + "" + order.CourierMobile
if dadaOrder, err := api.DadaAPI.QueryOrderInfo(msg.OrderID); err == nil {
order.ActualFee = jxutils.StandardPrice2Int(dadaOrder.ActualFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee)
order.DesiredFee = jxutils.StandardPrice2Int(dadaOrder.DeliveryFee) + int64(store.FreightMarkup)
}
case dadaapi.OrderStatusReturningInOrder:
order.Status = model.WaybillStatusCourierArrived
@@ -161,7 +162,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *dadaapi.CallbackMsg) (retVal *dadaap
return err
}
func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill) {
func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal *model.Waybill, goods *model.GoodsOrder) {
retVal = &model.Waybill{
VendorWaybillID: msg.ClientID,
WaybillVendorID: model.VendorIDDada,
@@ -179,12 +180,11 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *dadaapi.CallbackMsg) (retVal
retVal.StatusTime = utils.Timestamp2Time(updateTime)
retVal.VendorOrderID, retVal.OrderVendorID = jxutils.SplitUniversalOrderID(msg.OrderID)
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.OrderID}
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
retVal.OrderVendorID = good.VendorID
return retVal
dao.GetRow(dao.GetDB(), &goods, sql, sqlParams)
retVal.OrderVendorID = goods.VendorID
return retVal, goods
}
func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.ShopInfo) {

View File

@@ -248,14 +248,17 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
}
order.VendorOrderID, order.OrderVendorID = jxutils.SplitUniversalOrderID(cc.PartnerOrderCode)
order.OrderVendorID = good.VendorID
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
orderStatus := utils.Str2Int64(order.VendorStatus)
switch orderStatus {
case fnpsapi.OrderStatusAcceptCreate, fnpsapi.OrderStatusAccept: // 0 创建订单
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.Status = model.WaybillStatusNew //5 带调度
order.DesiredFee += int64(store.FreightMarkup) // 运营加价
order.Status = model.WaybillStatusNew //5 带调度
case fnpsapi.OrderStatusAssigned: //20分配骑手
//order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.DesiredFee, order.ActualFee = GetDesiredFee(order.VendorOrderID)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusCourierAssigned //12
order.Remark = order.CourierName + "" + order.CourierMobile
case fnpsapi.OrderStatusArrived: // 80 到店

View File

@@ -85,7 +85,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg
}
func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) {
order := c.callbackMsg2Waybill(msg)
order, goodsOrder := c.callbackMsg2Waybill(msg)
// 多次取消,只处理第一次
if msg.Status == mtpsapi.OrderStatusCanceled {
orderStatus, _ := orderman.FixedOrderManager.GetWayBillStatusList(msg.OrderID, msg.MtPeisongID, model.VendorIDMTPS)
@@ -96,6 +96,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
}
store, _ := dao.GetStoreDetail(dao.GetDB(), goodsOrder.JxStoreID, goodsOrder.VendorID, goodsOrder.VendorOrgCode)
switch msg.Status {
case mtpsapi.OrderStatusWaitingForSchedule:
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
@@ -104,6 +105,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusNew
case mtpsapi.OrderStatusAccepted: // 已接单
data, err := api.MtpsAPI.QueryOrderStatus(msg.DeliveryID, msg.MtPeisongID)
@@ -112,6 +114,7 @@ func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *m
}
order.DesiredFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["delivery_fee"]) * 100)
order.ActualFee = utils.Float64TwoInt64(utils.MustInterface2Float64(data["pay_amount"]) * 100)
order.DesiredFee += int64(store.FreightMarkup)
order.Status = model.WaybillStatusCourierAssigned
order.Remark = order.CourierName + "" + order.CourierMobile
case mtpsapi.OrderStatusPickedUp: // 已取货
@@ -230,7 +233,7 @@ func signParams(params url.Values) string {
return fmt.Sprintf("%x", sha1.Sum([]byte(finalStr)))
}
func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill) {
func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (retVal *model.Waybill, good2 *model.GoodsOrder) {
retVal = &model.Waybill{
VendorWaybillID: msg.MtPeisongID,
VendorWaybillID2: utils.Int64ToStr(msg.DeliveryID),
@@ -250,7 +253,7 @@ func (c *DeliveryHandler) callbackMsg2Waybill(msg *mtpsapi.CallbackOrderMsg) (re
} else {
retVal.OrderVendorID = good.VendorID
}
return retVal
return retVal, good
}
// 老方法是自己计算

View File

@@ -140,9 +140,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
return nil, err
}
//+0.2
// 系统加价
desiredFee := utils.Float64TwoInt(sfTotalPrice) + utils.WayBillDeliveryMarkUp
// 运营加价
desiredFee += store.FreightMarkup
bill = &model.Waybill{
VendorOrderID: order.VendorOrderID,
OrderVendorID: order.VendorID,
@@ -220,8 +221,6 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
}
deliveryFeeInfo = &partner.WaybillFeeInfo{}
price, err := api.SfPsAPI.PreCreateOrder(param)
//+0.2
//deliveryFee := utils.Float64TwoInt(price) + utils.WayBillDeliveryMarkUp
deliveryFeeInfo.DeliveryFee = utils.Float64TwoInt64(price)
globals.SugarLogger.Debugf("GetWaybillFee deliveryFeeInfo.DeliveryFee=%d", deliveryFeeInfo.DeliveryFee)
return deliveryFeeInfo, err
@@ -330,8 +329,7 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
order.CourierMobile = sfOrder.RiderPhone
}
//+0.2
sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice) + utils.WayBillDeliveryMarkUp
sfTotalPrice := utils.Float64TwoInt(sfOrder.TotalPrice)
sfActualPrice := utils.Float64TwoInt64(sfOrder.RealPayMoney)
globals.SugarLogger.Debugf("SFPS OnWaybillMsg,sfTotalPrice=%d,sfActualPrice=%d", sfTotalPrice, sfActualPrice)
@@ -341,6 +339,9 @@ func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackRespons
dao.GetRow(dao.GetDB(), &good, sql, sqlParams)
order.OrderVendorID = good.VendorID
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
sfTotalPrice += store.FreightMarkup
orderStatus := utils.Str2Int64(order.VendorStatus)
switch orderStatus {
case sfps2.OrderStatusNewOrder: //1订单创建

View File

@@ -329,6 +329,10 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
} else {
reallyPrice = int64(utils.Str2Float64(uuPrice.OrderPrice) * 100)
}
store, _ := dao.GetStoreDetail(dao.GetDB(), good.JxStoreID, good.VendorID, good.VendorOrgCode)
reallyPrice += int64(store.FreightMarkup)
actualFee := int64((utils.Str2Float64(uuPrice.OrderPrice)-utils.Str2Float64(uuPrice.PriceOff))*100) - int64(utils.WayBillDeliveryMarkUp)
switch req.State {
case uuptapi.StateConfirmSuccess: