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) {
//获取门店老板详情
storeOwner, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
if err != nil {
return nil, err
}
//获取金额令牌,实际需要支付金额
price, err := getOrderPrice(order)
if err != nil {
@@ -148,8 +153,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
"balance_paymoney": price.NeedPayMoney,
"receiver": order.ConsigneeName,
"receiver_phone": order.ConsigneeMobile,
"note": utils.FilterMb4("客户电话:" + order.ConsigneeMobile + "," + order.BuyerComment + "配送遇到问题可联系18048531223取消配送单禁止未配送直接完成定单"),
"callback_url": uuptapi.WaybillCallbackURL,
"push_type": uuptapi.PushTypeOpen,
"pubusermobile": storeOwner.Tel1, //老板电话
"special_type": uuptapi.SpecialTypeNo,
"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)
param := map[string]interface{}{
"origin_id": order.VendorOrderID,
"from_address": store.Address,
"to_address": order.ConsigneeAddress,
"city_name": store.CityName,
"send_type": uuptapi.SendTypeHelpMeDeliver,
"from_lat": coords[0].Lat,
"from_lng": coords[0].Lng,
"to_lat": coords[1].Lat,
"to_lng": coords[1].Lng,
"origin_id": order.VendorOrderID,
"from_address": store.Address,
"from_usernote": "京西菜市(" + store.Store.Name + ")",
"to_address": order.ConsigneeAddress,
"city_name": store.CityName,
"send_type": uuptapi.SendTypeHelpMeDeliver,
"from_lat": coords[0].Lat,
"from_lng": coords[0].Lng,
"to_lat": coords[1].Lat,
"to_lng": coords[1].Lng,
}
if orderPrice, err = api.UuAPI.GetOrderPrice(param); err != nil {
return nil, err
@@ -265,16 +273,7 @@ func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceRe
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) {
param := &model.Waybill{
VendorOrderID: req.OriginID,
@@ -318,3 +317,15 @@ func OnWaybillMsg(req *uuptapi.WaybillCallbackParam) (resp *uuptapi.CallbackResp
}
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.ShipmentStatusReturning: model.WaybillStatusReturning,
tiktok_api.ShipmentStatusReturned: model.WaybillStatusReturned,
tiktok_api.ShipmentStatusDelivered: model.WaybillStatusCanceled,
tiktok_api.ShipmentStatusCanceled: model.WaybillStatusDelivered,
tiktok_api.ShipmentStatusDelivered: model.WaybillStatusDelivered,
tiktok_api.ShipmentStatusCanceled: model.WaybillStatusCanceled,
}
)