Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -247,8 +247,8 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr
|
|||||||
|
|
||||||
func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||||
// 部分快递平台在取消成功后有时会不发运单取消消息过来(比如达达,904200512000442),为避免二次取消报错,添加状态判断
|
// 部分快递平台在取消成功后有时会不发运单取消消息过来(比如达达,904200512000442),为避免二次取消报错,添加状态判断
|
||||||
if c.IsReallyCallPlatformAPI && bill.Status != model.WaybillStatusCanceled { //此行测试用
|
//if c.IsReallyCallPlatformAPI && bill.Status != model.WaybillStatusCanceled { //此行测试用
|
||||||
//if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled {
|
if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled {
|
||||||
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil {
|
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil {
|
||||||
if err = utils.CallFuncLogErrorWithInfo(func() error {
|
if err = utils.CallFuncLogErrorWithInfo(func() error {
|
||||||
if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
|
if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil {
|
||||||
|
|||||||
@@ -1099,7 +1099,6 @@ func (s *DefScheduler) loadSavedOrderFromMap(status *model.OrderStatus, isForceL
|
|||||||
var realSavedInfo *WatchOrderInfo
|
var realSavedInfo *WatchOrderInfo
|
||||||
if savedInfo, ok := s.orderMap.Load(universalOrderID); ok {
|
if savedInfo, ok := s.orderMap.Load(universalOrderID); ok {
|
||||||
realSavedInfo = savedInfo.(*WatchOrderInfo)
|
realSavedInfo = savedInfo.(*WatchOrderInfo)
|
||||||
globals.SugarLogger.Debugf("loadSavedOrderFromMap savedInfo=%s", utils.Format4Output(savedInfo, false))
|
|
||||||
} else {
|
} else {
|
||||||
realSavedInfo = NewWatchOrderInfo(nil)
|
realSavedInfo = NewWatchOrderInfo(nil)
|
||||||
s.orderMap.StoreWithTimeout(universalOrderID, realSavedInfo, orderMapStoreMaxTime)
|
s.orderMap.StoreWithTimeout(universalOrderID, realSavedInfo, orderMapStoreMaxTime)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
|||||||
err = s.SelfDeliverDelivering(order, phone)
|
err = s.SelfDeliverDelivering(order, phone)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (order.Status < model.OrderStatusDelivering) || (order.VendorID == model.VendorIDDD && order.Status <= model.OrderStatusDelivering) {
|
if order.Status < model.OrderStatusDelivering || (order.VendorID == model.VendorIDDD && order.Status <= model.OrderStatusDelivering) {
|
||||||
err = s.Swtich2SelfDeliver(order, userName)
|
err = s.Swtich2SelfDeliver(order, userName)
|
||||||
} else if order.VendorID == order.WaybillVendorID { // 状态为配送中,且是购物平台运单,不能转自送了
|
} else if order.VendorID == order.WaybillVendorID { // 状态为配送中,且是购物平台运单,不能转自送了
|
||||||
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
err = scheduler.ErrOrderStatusIsNotSuitable4CurOperation
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package uupt
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
"git.rosy.net.cn/baseapi/platformapi/uuptapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"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/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"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,
|
"special_type": uuptapi.SpecialTypeNo,
|
||||||
"callme_withtake": uuptapi.CallMeWithTakeYes,
|
"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
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
bill = &model.Waybill{
|
bill = &model.Waybill{
|
||||||
@@ -160,7 +165,7 @@ func (d DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee i
|
|||||||
VendorWaybillID: orderCode,
|
VendorWaybillID: orderCode,
|
||||||
VendorWaybillID2: originID,
|
VendorWaybillID2: originID,
|
||||||
WaybillVendorID: model.VendorIDUUPT,
|
WaybillVendorID: model.VendorIDUUPT,
|
||||||
DesiredFee: utils.Str2Int64(price.NeedPayMoney),
|
DesiredFee: jxutils.StandardPrice2Int(utils.Str2Float64(price.NeedPayMoney)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delivery.OnWaybillCreated(bill)
|
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) {
|
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
|
return err
|
||||||
}
|
}
|
||||||
bill.Status = model.WaybillStatusCanceled
|
bill.Status = model.WaybillStatusCanceled
|
||||||
@@ -182,7 +189,7 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo
|
|||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
deliveryFeeInfo = &partner.WaybillFeeInfo{}
|
||||||
deliveryFeeInfo.DeliveryFee = utils.Str2Int64(orderPrice.NeedPayMoney)
|
deliveryFeeInfo.DeliveryFee = jxutils.StandardPrice2Int(utils.Str2Float64(orderPrice.NeedPayMoney))
|
||||||
}
|
}
|
||||||
return deliveryFeeInfo, err
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
address, _, err := dao.QueryUserDeliveryAddress(dao.GetDB(), order.AddressID, nil, 0, 0)
|
//转换百度坐标系
|
||||||
if err != nil || len(address) == 0 {
|
var coords []*baidunavi.Coordinate
|
||||||
return nil, err
|
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{}{
|
param := map[string]interface{}{
|
||||||
"origin_id": order.VendorOrderID,
|
"origin_id": order.VendorOrderID,
|
||||||
"from_address": store.Address,
|
"from_address": store.Address,
|
||||||
"to_address": order.ConsigneeAddress,
|
"to_address": order.ConsigneeAddress,
|
||||||
"city_name": address[0].CityName,
|
"city_name": store.CityName,
|
||||||
"send_type": uuptapi.SendTypeHelpMeDeliver,
|
"send_type": uuptapi.SendTypeHelpMeDeliver,
|
||||||
"to_lat": order.ConsigneeLat,
|
"from_lat": coords[0].Lat,
|
||||||
"to_lng": order.ConsigneeLng,
|
"from_lng": coords[0].Lng,
|
||||||
"from_lat": store.Lat,
|
"to_lat": coords[1].Lat,
|
||||||
"from_lng": store.Lng,
|
"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
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
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,
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
package tiktok_store
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package tiktok_store
|
|
||||||
|
|
||||||
type TransportCallbackResp struct {
|
|
||||||
Tag string `json:"tag"`
|
|
||||||
MsgID string `json:"msgID"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ShipmentInfo struct {
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user