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) {