GetOrderWaybillInfo可选参数:isGetPos支持获取运单骑手实时信息
This commit is contained in:
@@ -161,7 +161,7 @@ func (c *OrderManager) GetOrderInfo(ctx *jxcontext.Context, vendorOrderID string
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isNotEnded bool) (bills []*model.Waybill, err error) {
|
||||
func (c *OrderManager) GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isNotEnded, isGetPos bool) (bills []*model.WaybillExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderWaybillInfo orderID:%s", vendorOrderID)
|
||||
db := dao.GetDB()
|
||||
sql := `
|
||||
@@ -178,7 +178,26 @@ func (c *OrderManager) GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID
|
||||
sqlParams = append(sqlParams, model.OrderStatusEndBegin)
|
||||
}
|
||||
err = dao.GetRows(db, &bills, sql, sqlParams...)
|
||||
globals.SugarLogger.Infof("GetOrderWaybillInfo orderID:%s failed with error:%v", vendorOrderID, err)
|
||||
if err == nil && isGetPos {
|
||||
var taskBills []*model.WaybillExt
|
||||
for _, v := range bills {
|
||||
if v.Status >= model.WaybillStatusAccepted && v.Status <= model.WaybillStatusDelivering {
|
||||
if handler := partner.GetRidderPositionGetter(v.WaybillVendorID); handler != nil {
|
||||
taskBills = append(taskBills, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(taskBills) > 0 {
|
||||
task := tasksch.NewParallelTask("GetOrderWaybillInfo", nil, ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
waybill := batchItemList[0].(*model.WaybillExt)
|
||||
waybill.Lng, waybill.Lat, err = partner.GetRidderPositionGetter(waybill.WaybillVendorID).GetRidderPosition(ctx, waybill.VendorOrderID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2)
|
||||
return nil, err
|
||||
}, taskBills)
|
||||
tasksch.HandleTask(task, nil, false).Run()
|
||||
task.GetResult(0)
|
||||
}
|
||||
}
|
||||
return bills, err
|
||||
}
|
||||
|
||||
|
||||
@@ -214,13 +214,13 @@ func (s *DefScheduler) QueryOrderWaybillFeeInfoEx(ctx *jxcontext.Context, vendor
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
waybillList, err := partner.CurOrderManager.GetOrderWaybillInfo(ctx, vendorOrderID, vendorID, true)
|
||||
waybillList, err := partner.CurOrderManager.GetOrderWaybillInfo(ctx, vendorOrderID, vendorID, true, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
waybillMap := make(map[int]*model.Waybill)
|
||||
for _, bill := range waybillList {
|
||||
waybillMap[bill.WaybillVendorID] = bill
|
||||
waybillMap[bill.WaybillVendorID] = &bill.Waybill
|
||||
}
|
||||
deliveryFeeMap = make(map[int]*partner.WaybillFeeInfo)
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ const (
|
||||
WaybillStatusDelivered = 105 // todo 这个应该改为110,与订单对应
|
||||
WaybillStatusCanceled = 115
|
||||
WaybillStatusFailed = 120 // 这个状态存在的意义是区分于WaybillStatusCanceled,比如达达平台在这种状态下再次创建运单的方式不一样
|
||||
WaybillStatusEndEnd = 120
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -366,3 +367,7 @@ func WaybillVendorID2Mask(vendorID int) (mask int8) {
|
||||
func IsAfsOrderFinalStatus(status int) bool {
|
||||
return status >= AfsOrderStatusFinished && status <= AfsOrderStatusFailed
|
||||
}
|
||||
|
||||
func IsWaybillFinalStatus(status int) bool {
|
||||
return status >= WaybillStatusEndBegin && status <= WaybillStatusEndEnd
|
||||
}
|
||||
|
||||
@@ -197,6 +197,12 @@ func (w *Waybill) TableIndex() [][]string {
|
||||
}
|
||||
}
|
||||
|
||||
type WaybillExt struct {
|
||||
Waybill
|
||||
Lng float64 `json:"lng"`
|
||||
Lat float64 `json:"lat"`
|
||||
}
|
||||
|
||||
// 包含订单与运单的状态及事件vendor status
|
||||
type OrderStatus struct {
|
||||
ID int64 `orm:"column(id)" json:"id"`
|
||||
|
||||
@@ -410,3 +410,12 @@ func (c *DeliveryHandler) AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, v
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error) {
|
||||
order, err := api.DadaAPI.QueryOrderInfo2(vendorOrderID)
|
||||
if err == nil {
|
||||
lng = utils.Str2Float64WithDefault(order.TransporterLng, 0)
|
||||
lat = utils.Str2Float64WithDefault(order.TransporterLat, 0)
|
||||
}
|
||||
return lng, lat, err
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||
@@ -18,15 +19,14 @@ func TestCreateWaybill(t *testing.T) {
|
||||
orderID := "817540316000041"
|
||||
if order, err := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDJD); err == nil {
|
||||
// globals.SugarLogger.Debug(order)
|
||||
c := new(DeliveryHandler)
|
||||
_, err = c.CreateWaybill(order, nil)
|
||||
_, err = CurDeliveryHandler.CreateWaybill(order, 0)
|
||||
if err == nil {
|
||||
time.Sleep(1 * time.Second)
|
||||
bill := &model.Waybill{
|
||||
VendorOrderID: orderID,
|
||||
WaybillVendorID: model.VendorIDDada,
|
||||
}
|
||||
err = c.CancelWaybill(bill, partner.CancelWaybillReasonOther, "")
|
||||
err = CurDeliveryHandler.CancelWaybill(bill, partner.CancelWaybillReasonOther, "")
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
@@ -37,3 +37,11 @@ func TestCreateWaybill(t *testing.T) {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetRidderPosition(t *testing.T) {
|
||||
lng, lat, err := CurDeliveryHandler.GetRidderPosition(jxcontext.AdminCtx, "", "80704840263399812", "", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("lng:%f, lat:%f", lng, lat)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||
"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"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -255,3 +256,12 @@ func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, reson
|
||||
err = api.MtpsAPI.EvaluateRider(utils.Str2Int64(bill.VendorWaybillID2), bill.VendorWaybillID, 1, resonContent)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *DeliveryHandler) GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error) {
|
||||
intLng, intLat, err := api.MtpsAPI.RiderLocation(utils.Str2Int64(vendorWaybillID2), vendorWaybillID)
|
||||
if err == nil {
|
||||
lng = jxutils.IntCoordinate2Standard(intLng)
|
||||
lat = jxutils.IntCoordinate2Standard(intLat)
|
||||
}
|
||||
return lng, lat, err
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ type IOrderManager interface {
|
||||
SaveOrderFinancialInfo(order *model.OrderFinancial, operation string) (err error)
|
||||
SaveAfsOrderFinancialInfo(afsOrder *model.AfsOrder) (err error)
|
||||
|
||||
GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isNotEnded bool) (bills []*model.Waybill, err error)
|
||||
GetOrderWaybillInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int, isNotEnded, isGetPos bool) (bills []*model.WaybillExt, err error)
|
||||
|
||||
// afs order
|
||||
OnAfsOrderAdjust(afsOrder *model.AfsOrder, orderStatus *model.OrderStatus) (err error)
|
||||
@@ -277,3 +277,13 @@ func IsMultiStore(vendorID int) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func GetRidderPositionGetter(vendorID int) (handler IRidderPositionGetter) {
|
||||
if handlerInfo := GetDeliveryPlatformFromVendorID(vendorID); handlerInfo != nil {
|
||||
if handler, _ = handlerInfo.Handler.(IRidderPositionGetter); handler != nil {
|
||||
return handler
|
||||
}
|
||||
}
|
||||
handler, _ = GetPurchasePlatformFromVendorID(vendorID).(IRidderPositionGetter)
|
||||
return handler
|
||||
}
|
||||
|
||||
@@ -61,3 +61,7 @@ type IAddWaybillTip interface {
|
||||
GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error)
|
||||
AddWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee2Add int64) (err error)
|
||||
}
|
||||
|
||||
type IRidderPositionGetter interface {
|
||||
GetRidderPosition(ctx *jxcontext.Context, vendorOrgCode, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (lng, lat float64, err error)
|
||||
}
|
||||
|
||||
@@ -220,12 +220,13 @@ func (c *OrderController) GetOrderInfo() {
|
||||
// @Param vendorOrderID query string true "订单ID"
|
||||
// @Param vendorID query int true "订单所属的厂商ID"
|
||||
// @Param isNotEnded query bool false "是否只是没有结束的运单"
|
||||
// @Param isGetPos query bool false "是否得到骑手位置"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /GetOrderWaybillInfo [get]
|
||||
func (c *OrderController) GetOrderWaybillInfo() {
|
||||
c.callGetOrderWaybillInfo(func(params *tOrderGetOrderWaybillInfoParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = orderman.FixedOrderManager.GetOrderWaybillInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.IsNotEnded)
|
||||
retVal, err = orderman.FixedOrderManager.GetOrderWaybillInfo(params.Ctx, params.VendorOrderID, params.VendorID, params.IsNotEnded, params.IsGetPos)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
@@ -900,7 +901,7 @@ func (c *OrderController) GetComplaintReasons() {
|
||||
// @router /ComplaintRider [post]
|
||||
func (c *OrderController) ComplaintRider() {
|
||||
c.callComplaintRider(func(params *tOrderComplaintRiderParams) (retVal interface{}, errCode string, err error) {
|
||||
err = orderman.ComplaintRider(params.Ctx, params.OrderID,params.VendorID, params.ComplaintID)
|
||||
err = orderman.ComplaintRider(params.Ctx, params.OrderID, params.VendorID, params.ComplaintID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user