This commit is contained in:
richboo111
2023-02-02 17:20:16 +08:00
parent a7b9bdee61
commit f51dbcd50a
2 changed files with 32 additions and 21 deletions

View File

@@ -137,6 +137,11 @@ func (d DeliveryHandler) IsErrStoreExist(err error) bool {
} }
func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) { func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
//获取门店老板详情
storeOwner, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
if err != nil {
return nil, err
}
//获取金额令牌,实际需要支付金额 //获取金额令牌,实际需要支付金额
price, err := getOrderPrice(order) price, err := getOrderPrice(order)
if err != nil { if err != nil {
@@ -148,8 +153,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
"balance_paymoney": price.NeedPayMoney, "balance_paymoney": price.NeedPayMoney,
"receiver": order.ConsigneeName, "receiver": order.ConsigneeName,
"receiver_phone": order.ConsigneeMobile, "receiver_phone": order.ConsigneeMobile,
"note": utils.FilterMb4("客户电话:" + order.ConsigneeMobile + "," + order.BuyerComment + "配送遇到问题可联系18048531223取消配送单禁止未配送直接完成定单"),
"callback_url": uuptapi.WaybillCallbackURL, "callback_url": uuptapi.WaybillCallbackURL,
"push_type": uuptapi.PushTypeOpen, "push_type": uuptapi.PushTypeOpen,
"pubusermobile": storeOwner.Tel1, //老板电话
"special_type": uuptapi.SpecialTypeNo, "special_type": uuptapi.SpecialTypeNo,
"callme_withtake": uuptapi.CallMeWithTakeYes, "callme_withtake": uuptapi.CallMeWithTakeYes,
} }
@@ -249,15 +256,16 @@ func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceRe
}) })
coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu) coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu)
param := map[string]interface{}{ param := map[string]interface{}{
"origin_id": order.VendorOrderID, "origin_id": order.VendorOrderID,
"from_address": store.Address, "from_address": store.Address,
"to_address": order.ConsigneeAddress, "from_usernote": "京西菜市(" + store.Store.Name + ")",
"city_name": store.CityName, "to_address": order.ConsigneeAddress,
"send_type": uuptapi.SendTypeHelpMeDeliver, "city_name": store.CityName,
"from_lat": coords[0].Lat, "send_type": uuptapi.SendTypeHelpMeDeliver,
"from_lng": coords[0].Lng, "from_lat": coords[0].Lat,
"to_lat": coords[1].Lat, "from_lng": coords[0].Lng,
"to_lng": coords[1].Lng, "to_lat": coords[1].Lat,
"to_lng": coords[1].Lng,
} }
if orderPrice, err = api.UuAPI.GetOrderPrice(param); err != nil { if orderPrice, err = api.UuAPI.GetOrderPrice(param); err != nil {
return nil, err return nil, err
@@ -265,16 +273,7 @@ func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceRe
return orderPrice, nil return orderPrice, nil
} }
} }
func getReallyStoreID(storeID, jxStoreID int) int {
if storeID == 0 && jxStoreID == 0 {
return 0
}
if storeID == 0 {
return jxStoreID
} else {
return storeID
}
}
func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResponse) { func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResponse) {
param := &model.Waybill{ param := &model.Waybill{
VendorOrderID: req.OriginID, VendorOrderID: req.OriginID,
@@ -318,3 +317,15 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
} }
return uuptapi.Err2CallbackResponse(nil) return uuptapi.Err2CallbackResponse(nil)
} }
//辅助函数
func getReallyStoreID(storeID, jxStoreID int) int {
if storeID == 0 && jxStoreID == 0 {
return 0
}
if storeID == 0 {
return jxStoreID
} else {
return storeID
}
}

View File

@@ -23,8 +23,8 @@ var (
tiktok_api.ShipmentStatusRejected: model.WaybillStatusRejected, tiktok_api.ShipmentStatusRejected: model.WaybillStatusRejected,
tiktok_api.ShipmentStatusReturning: model.WaybillStatusReturning, tiktok_api.ShipmentStatusReturning: model.WaybillStatusReturning,
tiktok_api.ShipmentStatusReturned: model.WaybillStatusReturned, tiktok_api.ShipmentStatusReturned: model.WaybillStatusReturned,
tiktok_api.ShipmentStatusDelivered: model.WaybillStatusCanceled, tiktok_api.ShipmentStatusDelivered: model.WaybillStatusDelivered,
tiktok_api.ShipmentStatusCanceled: model.WaybillStatusDelivered, tiktok_api.ShipmentStatusCanceled: model.WaybillStatusCanceled,
} }
) )