Merge branch 'jdshop' of https://e.coding.net/rosydev/jx-callback into jdshop
This commit is contained in:
@@ -62,7 +62,7 @@ func (c *BaseScheduler) CreateWaybillOnProviders(ctx *jxcontext.Context, order *
|
||||
}
|
||||
err = nil
|
||||
} else if errList.GetErrListAsOne() == nil {
|
||||
err = fmt.Errorf("orderID:%s订单发三方配送亏损超过6元/当前订单配送方式不是门店自送/没有绑定有效的三方配送门店", order.VendorOrderID)
|
||||
err = fmt.Errorf("orderID:%s过订单发三方配送亏损超6元/当前订单配送方式不是门店自送/没有绑定有效的三方配送门店", order.VendorOrderID)
|
||||
} else {
|
||||
err = fmt.Errorf("orderID:%s所有运单失败:%s", order.VendorOrderID, errList.GetErrListAsOne().Error())
|
||||
}
|
||||
|
||||
@@ -559,11 +559,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
||||
}
|
||||
}
|
||||
}
|
||||
//if !model.IsWaybillPlatformOwn(bill) {
|
||||
// if storeDetail, err2 := dao.GetStoreDetail(dao.GetDB(), jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, ""); err2 == nil {
|
||||
// s.updateBrandAccount(storeDetail, bill)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
flag2Clear := model.WaybillVendorID2Mask(bill.WaybillVendorID)
|
||||
if order.DeliveryFlag&flag2Clear != 0 {
|
||||
@@ -896,7 +891,7 @@ func (s *DefScheduler) createWaybillOn3rdProviders(savedOrderInfo *WatchOrderInf
|
||||
// excludeVendorIDs = append(excludeVendorIDs, model.VendorIDMTPS)
|
||||
// }
|
||||
//TODO 2020-08-18 饿百美团订单暂时不自动发送三方
|
||||
if order.VendorID == model.VendorIDMTWM || order.VendorID == model.VendorIDEBAI || order.VendorID == model.VendorIDJD {
|
||||
if order.VendorID == model.VendorIDMTWM || order.VendorID == model.VendorIDEBAI || order.VendorID == model.VendorIDJD || order.VendorID == model.VendorIDDD {
|
||||
if order.DeliveryType != model.OrderDeliveryTypeStoreSelf {
|
||||
excludeVendorIDs = append(excludeVendorIDs, waybillVendorIDs...)
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ func (s *DefScheduler) SelfDeliveringAndUpdateStatus(ctx *jxcontext.Context, ven
|
||||
CourierMobile: courierMobile,
|
||||
Status: model.OrderStatusNew,
|
||||
VendorStatus: utils.Int2Str(model.OrderStatusNew),
|
||||
ActualFee: 500,
|
||||
DesiredFee: order.ActualPayPrice,
|
||||
ActualFee: 0,
|
||||
DesiredFee: 0,
|
||||
TipFee: 0,
|
||||
DuplicatedCount: 0,
|
||||
DeliveryFlag: 0,
|
||||
@@ -214,37 +214,14 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(newPrice)-lastFee, partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, "", expend.ID) //int(newPrice)-lastFee
|
||||
}
|
||||
}
|
||||
} /*else { // 品牌发单,品牌支出运费
|
||||
if storeAcct.AccountBalance > int(newPrice) {
|
||||
if int(newPrice) > lastFee {
|
||||
// 品牌支出费用
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(newPrice), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
} else { // 新订单的发单记录,门店发单扣门店,品牌发单扣品牌
|
||||
if len(courierVendorIDs) == 1 {
|
||||
courierVendorID := courierVendorIDs[0]
|
||||
if _, ok := deliveryFeeMap[courierVendorID]; ok {
|
||||
//if storeList.BrandID != scheduler.JXC4B_SHOP && storeList.BrandID != scheduler.JXC4B_RAND_JXGY { // 非京西品牌,先扣门店在扣品牌
|
||||
//if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
if order.CreateDeliveryType == model.YES {
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(deliveryFeeMap[courierVendorID].DeliveryFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, "", 0) //int(newPrice)-lastFee
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 238 err := %v", err)
|
||||
} /*else {
|
||||
partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(bill.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, bill.VendorOrderID, bill.VendorWaybillID)
|
||||
}*/
|
||||
//} /*else if result > int(model.Waybill{}.DesiredFee) {
|
||||
// 品牌支出费用
|
||||
// partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(model.Waybill{}.DesiredFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
//}*/
|
||||
//} else { // 京西品牌
|
||||
// if storeAcct.AccountBalance > int(model.Waybill{}.DesiredFee) {
|
||||
// // 门店支出费用
|
||||
// partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(model.Waybill{}.DesiredFee), partner.StoreAcctTypeExpendCreateWaybill2ndMore, order.VendorOrderID, expend.ID) //int(newPrice)-lastFee
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
} else if len(courierVendorIDs) == 0 {
|
||||
var maxFee int64
|
||||
@@ -254,7 +231,6 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
}
|
||||
}
|
||||
err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(maxFee), partner.StoreAcctTypeExpendCreateWaybillEx, order.VendorOrderID, "", 0) //int(maxFee)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 260 err := %v", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -273,7 +249,6 @@ func (s *DefScheduler) CreateWaybillOnProviders4SavedOrder(ctx *jxcontext.Contex
|
||||
}
|
||||
}
|
||||
err = partner.CurStoreAcctManager.InsertBrandBill(jxcontext.AdminCtx, storeList.BrandID, int(maxFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorOrderID, order.VendorWaybillID)
|
||||
globals.SugarLogger.Debugf("InsertStoreAcctExpendAndUpdateStoreAcctBalance 260 err := %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -324,6 +326,11 @@ func Waybill2Status(bill *Waybill) (retVal *OrderStatus) {
|
||||
StatusTime: bill.StatusTime,
|
||||
Remark: bill.Remark,
|
||||
}
|
||||
if retVal.Remark == "" {
|
||||
retVal.Remark = fmt.Sprintf("运费: %s", utils.Float64ToStr(float64(bill.DesiredFee)/float64(100)))
|
||||
} else {
|
||||
retVal.Remark += fmt.Sprintf(",运费: %s", utils.Float64ToStr(float64(bill.DesiredFee)/float64(100)))
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
|
||||
@@ -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("达达配送,平台调用错误,无订单数据返回")
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1370,3 +1370,20 @@ func (c *OrderController) UpdateMTOrderSettle() {
|
||||
return nil, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 获取三方配送的骑手坐标
|
||||
// @Description 获取三方配送的骑手坐标
|
||||
// @Param token header string true "认证token"
|
||||
// @Param orderId formData string true "订单id"
|
||||
// @Param deliveryId formData string true "运单id"
|
||||
// @Param waybillVendorId formData int true "运单平台id"
|
||||
// @Param orderVendorId formData int true "运单平台id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetRiderLng [post]
|
||||
func (c *OrderController) GetRiderLng() {
|
||||
c.callGetRiderLng(func(params *tOrderGetRiderLngParams) (interface{}, string, error) {
|
||||
rider, err := delivery.GetVendorRiderInfo(params.WaybillVendorId, params.OrderVendorId, params.OrderId, params.DeliveryId)
|
||||
return rider, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1574,6 +1574,15 @@ func init() {
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
// 获取三方运单骑手坐标
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
web.ControllerComments{
|
||||
Method: "GetRiderLng",
|
||||
Router: `/GetRiderLng`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||
web.ControllerComments{
|
||||
|
||||
Reference in New Issue
Block a user