diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 3e8f3fd2d..73722a7b3 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -247,25 +247,23 @@ func GetComplaintReasons() (complaintReasonList []*dadaapi.ComplaintReason) { return complaintReasonList } -func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorID, waybillVendorID, complaintID int) (err error) { - db := dao.GetDB() - p := partner.GetDeliveryPlatformFromVendorID(waybillVendorID).Handler - wayBillList, err := dao.GetWayBillByOrderID(db, 0, vendorID, waybillVendorID, vendorOrderID) +func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorWaybillId string, complaintID int) (err error) { + wayBillList, err := dao.GetComplaintList(dao.GetDB(), vendorOrderID, vendorWaybillId) + if err != nil { + return err + } + if len(wayBillList) != model.YES { + return fmt.Errorf("订单所属运单不存在,或运单为分配骑手,无法投诉") + } + p := partner.GetDeliveryPlatformFromVendorID(wayBillList[0].WaybillVendorID).Handler if err == nil && len(wayBillList) > 0 { err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID]) - } else { - return fmt.Errorf("未查询到到相关订单!订单号:[%v] ,厂商:[%v],运送厂商:[%v]", vendorOrderID, vendorID, waybillVendorID) } + return err } // GetComplaintList 获取投诉列表 func GetComplaintList(orderId string) ([]*model.Waybill, error) { - return dao.GetComplaintList(dao.GetDB(), orderId) -} - -func ComplaintRiderPlatform(ctx *jxcontext.Context, vendorOrderID string, vendorID, waybillVendorID, complaintID int) (err error) { - return fmt.Errorf("只支持三方配送投诉!") - //handler := partner.GetPurchaseOrderHandlerFromVendorID(vendorID) - //return handler.ComplaintRider(vendorOrderID, complaintID, "") + return dao.GetComplaintList(dao.GetDB(), orderId, "") } diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 01cc526c3..e75d1c176 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1291,10 +1291,20 @@ func GetWayBillByOrderID(db *DaoDB, orderStatus, vendorID, waybillVendorID int, return wayBillList, err } -func GetComplaintList(db *DaoDB, orderId string) ([]*model.Waybill, error) { - sql := ` SELECT * FROM waybill WHERE vendor_order_id = ? AND courier_name <> '' AND courier_mobile <> '' ` +func GetComplaintList(db *DaoDB, orderId string, vendorWaybillId string) ([]*model.Waybill, error) { + sql := ` SELECT * FROM waybill WHERE vendor_order_id = ? ` + var param []interface{} + param = append(param, orderId) + if vendorWaybillId != "" { + sql += ` AND vendor_waybill_id = ? ` + param = append(param, vendorWaybillId) + } + + sql += ` AND waybill_vendor_id IN (?,?,?) AND courier_name <> '' AND courier_mobile <> '' ORDER BY waybill_created_at ` + param = append(param, model.VendorIDFengNiao, model.VendorIDDada, model.VendorIDMTPS) + var data []*model.Waybill - if err := GetRows(db, &data, sql, []interface{}{orderId}); err != nil { + if err := GetRows(db, &data, sql, param...); err != nil { return nil, err } return data, nil diff --git a/controllers/jx_order.go b/controllers/jx_order.go index d95407a0e..b01792fac 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -987,19 +987,14 @@ func (c *OrderController) GetComplaintReasons() { // @Description 投诉骑手 // @Param token header string true "认证token" // @Param vendorOrderID formData string true "订单ID" -// @Param vendorID formData int true "订单所属厂商ID" -// @Param waybillVendorID formData int true "运单所属厂商ID" +// @Param waybillVendorID formData string true "运单所属厂商ID" // @Param complaintID formData int true "投诉原因ID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult // @router /ComplaintRider [post] func (c *OrderController) ComplaintRider() { c.callComplaintRider(func(params *tOrderComplaintRiderParams) (retVal interface{}, errCode string, err error) { - if params.WaybillVendorID > 100 { - err = orderman.ComplaintRider(params.Ctx, params.VendorOrderID, params.VendorID, params.WaybillVendorID, params.ComplaintID) - } else { - err = orderman.ComplaintRiderPlatform(params.Ctx, params.VendorOrderID, params.VendorID, params.WaybillVendorID, params.ComplaintID) - } + err = orderman.ComplaintRider(params.Ctx, params.VendorOrderID, params.WaybillVendorID, params.ComplaintID) return retVal, "", err }) }