Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop

This commit is contained in:
richboo111
2023-05-25 09:52:48 +08:00
10 changed files with 106 additions and 40 deletions

View File

@@ -358,7 +358,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
}
// 重新发送订单
result, err = api.DadaAPI.ReaddOrder(billParams)
globals.SugarLogger.Debugf("重新发送订单多次发单======== := %s", utils.Format4Output(result, false))
if err != nil {
return nil, err
}
@@ -368,7 +367,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
if result, err = api.DadaAPI.QueryDeliverFee(billParams); err != nil {
return nil, err
}
globals.SugarLogger.Debugf("查询达达订单费用(第一次发单)======== := %s", utils.Format4Output(result, false))
// 阀值警报
if err = delivery.CallCreateWaybillPolicy(jxutils.StandardPrice2Int(result.Fee), maxDeliveryFee, order, model.VendorIDDada); err != nil {
return nil, err
@@ -377,7 +375,6 @@ func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee
if err = api.DadaAPI.AddOrderAfterQuery(result.DeliveryNo); err != nil {
return nil, err
}
globals.SugarLogger.Debugf("重新发送订单======== := %s", utils.Format4Output(result, false))
}
if result == nil {
return nil, errors.New("达达配送,平台调用错误,无订单数据返回")

View File

@@ -210,6 +210,17 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
if err := utils.Map2StructByJson(msg.Param, cc, true); err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
// 多次取消,只处理第一次
if cc.OrderStatus == fnpsapi.OrderStatusAcceptCacle {
bill, err := partner.CurOrderManager.LoadWaybill(utils.Int64ToStr(cc.OrderId), model.VendorIDFengNiao)
if err != nil {
return fnpsapi.Err2CallbackResponse(err, "")
}
if bill.Status == model.OrderStatusCanceled {
return fnpsapi.Err2CallbackResponse(nil, "")
}
}
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{}{cc.PartnerOrderCode}
@@ -256,6 +267,7 @@ func OnWaybillMsg(msg *fnpsapi.OrderStatusNottify, resultParam *fnpsapi.ShortSta
order.Status = model.WaybillStatusDelivered
case fnpsapi.OrderStatusAcceptCacle: // 4取消订单
order.Status = model.WaybillStatusCanceled
order.VendorStatus = utils.Int2Str(fnpsapi.OrderStatusAcceptCacle)
case fnpsapi.OrderStatusException: // 5 异常
order.Status = model.WaybillStatusDeliverFailed // 22
default:

View File

@@ -122,6 +122,8 @@ func GetOrderRiderInfoToPlatform(orderId string, wayBillStatus int) {
globals.SugarLogger.Debug("Get Order waybill rider info err MT:%v", err)
}
}
} else {
continue
}
}
@@ -295,6 +297,8 @@ func makeRiderInfo(fakeWayBill *model.Waybill, riderInfo *mtpsapi.RiderInfo) {
riderInfo.CourierName = ""
riderInfo.CourierPhone = ""
riderInfo.OpCode = tiktok_api.TiktokLogisticsStatusCALLRIDER
riderInfo.Latitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat))
riderInfo.Longitude = utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng))
// 下一状态以及推送时间
fakeWayBill.Status = model.WaybillStatusCourierAssigned
@@ -504,3 +508,41 @@ func LoadingStoreOrderSettleAmount(startTime, endTime int64, jxStoreId []int) er
}
return nil
}
func GetVendorRiderInfo(wayBillVendorId, vendorId int, vendorOrderId, vendorWaybillId string) (riderInfo *mtpsapi.RiderInfo, err error) {
riderInfo = &mtpsapi.RiderInfo{}
if handlerInfo := partner.GetDeliveryPlatformFromVendorID(wayBillVendorId); handlerInfo != nil {
if wayBillVendorId == model.VendorIDDada || wayBillVendorId == model.VendorIDFengNiao || wayBillVendorId == model.VendorIDUUPT {
riderInfo, err = handlerInfo.Handler.GetRiderInfo(vendorOrderId, 0, vendorWaybillId)
if err != nil {
return nil, err
}
} else if wayBillVendorId == model.VendorIDMTPS {
riderInfo, err = handlerInfo.Handler.GetRiderInfo(vendorOrderId, time.Now().Unix()+1000000, vendorWaybillId)
if err != nil {
return nil, err
}
}
}
if riderInfo.Longitude == "" || riderInfo.Latitude == "" {
order, err := partner.CurOrderManager.LoadOrder(vendorOrderId, vendorId)
if err != nil {
return nil, err
}
if order.Status >= model.OrderStatusEndBegin {
riderInfo.Longitude = utils.Float64ToStr(utils.Int2Float64(order.ConsigneeLng) / 1000000)
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(order.ConsigneeLat) / 1000000)
} else {
store, err := dao.GetStoreDetail(dao.GetDB(), order.JxStoreID, order.VendorID, order.VendorOrgCode)
if err != nil {
return nil, err
}
riderInfo.Longitude = utils.Float64ToStr(utils.Int2Float64(store.Lng) / 1000000)
riderInfo.Latitude = utils.Float64ToStr(utils.Int2Float64(store.Lat) / 1000000)
}
}
return
}

View File

@@ -1,7 +1,19 @@
package delivery
import "testing"
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"testing"
)
func TestRider(t *testing.T) {
GetOrderRiderInfoToPlatform("144228632526740576", 0)
}
func TestCcc(t *testing.T) {
aa := utils.Float64ToStr(jxutils.IntCoordinate2Standard(103989607))
bb := utils.Float64ToStr(jxutils.IntCoordinate2Standard(30560797))
fmt.Println(aa)
fmt.Println(bb)
}