|
|
|
|
@@ -2,9 +2,11 @@ package uupt
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
|
|
|
|
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
|
|
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
|
|
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
|
|
|
|
@@ -151,7 +153,10 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
|
|
|
|
"special_type": uuptapi.SpecialTypeNo,
|
|
|
|
|
"callme_withtake": uuptapi.CallMeWithTakeYes,
|
|
|
|
|
}
|
|
|
|
|
if orderCode, originID, err := api.UuAPI.AddOrder(param); err != nil {
|
|
|
|
|
//test
|
|
|
|
|
apis := uuptapi.New("ccba8bd4a2d54a2fb6df97e87979f303", "2815a7a1f8e3405d81fd6263683ec4e7", "910a0dfd12bb4bc0acec147bcb1ae246")
|
|
|
|
|
if orderCode, originID, err := apis.AddOrder(param); err != nil {
|
|
|
|
|
//if orderCode, originID, err := api.UuAPI.AddOrder(param); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
bill = &model.Waybill{
|
|
|
|
|
@@ -160,7 +165,7 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
|
|
|
|
VendorWaybillID: orderCode,
|
|
|
|
|
VendorWaybillID2: originID,
|
|
|
|
|
WaybillVendorID: model.VendorIDUUPT,
|
|
|
|
|
DesiredFee: utils.Str2Int64(price.NeedPayMoney),
|
|
|
|
|
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.NeedPayMoney)),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delivery.OnWaybillCreated(bill)
|
|
|
|
|
@@ -168,7 +173,9 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
|
|
|
|
if err = api.UuAPI.CancelOrder(bill.VendorWaybillID, uuptapi.CancelReasonNormal); err != nil {
|
|
|
|
|
apis := uuptapi.New("ccba8bd4a2d54a2fb6df97e87979f303", "2815a7a1f8e3405d81fd6263683ec4e7", "910a0dfd12bb4bc0acec147bcb1ae246")
|
|
|
|
|
if err = apis.CancelOrder(bill.VendorWaybillID, uuptapi.CancelReasonNormal); err != nil {
|
|
|
|
|
//if err = api.UuAPI.CancelOrder(bill.VendorWaybillID, uuptapi.CancelReasonNormal); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
bill.Status = model.WaybillStatusCanceled
|
|
|
|
|
@@ -182,7 +189,7 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
|
|
|
|
deliveryFeeInfo.DeliveryFee = utils.Str2Int64(orderPrice.NeedPayMoney)
|
|
|
|
|
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney))
|
|
|
|
|
}
|
|
|
|
|
return deliveryFeeInfo, err
|
|
|
|
|
}
|
|
|
|
|
@@ -232,32 +239,50 @@ func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeison
|
|
|
|
|
|
|
|
|
|
//辅助函数
|
|
|
|
|
func getOrderPrice(order *model.GoodsOrder) (orderPrice *uuptapi.GetOrderPriceResp, err error) {
|
|
|
|
|
store, err := dao.GetStoreDetail(dao.GetDB(), order.StoreID, 0, "")
|
|
|
|
|
store, err := dao.GetStoreDetail(dao.GetDB(), getReallyStoreID(order.StoreID, order.JxStoreID), 0, "")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
address, _, err := dao.QueryUserDeliveryAddress(dao.GetDB(), order.AddressID, nil, 0, 0)
|
|
|
|
|
if err != nil || len(address) == 0 {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
//转换百度坐标系
|
|
|
|
|
var coords []*baidunavi.Coordinate
|
|
|
|
|
coords = append(coords, &baidunavi.Coordinate{
|
|
|
|
|
Lng: jxutils.IntCoordinate2Standard(store.Lng),
|
|
|
|
|
Lat: jxutils.IntCoordinate2Standard(store.Lat),
|
|
|
|
|
}, &baidunavi.Coordinate{
|
|
|
|
|
Lat: jxutils.IntCoordinate2Standard(order.ConsigneeLat),
|
|
|
|
|
Lng: jxutils.IntCoordinate2Standard(order.ConsigneeLng),
|
|
|
|
|
})
|
|
|
|
|
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": address[0].CityName,
|
|
|
|
|
"city_name": store.CityName,
|
|
|
|
|
"send_type": uuptapi.SendTypeHelpMeDeliver,
|
|
|
|
|
"to_lat": order.ConsigneeLat,
|
|
|
|
|
"to_lng": order.ConsigneeLng,
|
|
|
|
|
"from_lat": store.Lat,
|
|
|
|
|
"from_lng": store.Lng,
|
|
|
|
|
"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 {
|
|
|
|
|
//test
|
|
|
|
|
apis := uuptapi.New("ccba8bd4a2d54a2fb6df97e87979f303", "2815a7a1f8e3405d81fd6263683ec4e7", "910a0dfd12bb4bc0acec147bcb1ae246")
|
|
|
|
|
if orderPrice, err = apis.GetOrderPrice(param); err != nil {
|
|
|
|
|
//if orderPrice, err = api.UuAPI.GetOrderPrice(param); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
} else {
|
|
|
|
|
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,
|
|
|
|
|
|