From 816a947ffb332fbba1b984cd273c0f2c1060fd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 30 May 2023 15:20:59 +0800 Subject: [PATCH 1/7] 1 --- business/jxcallback/orderman/order.go | 10 ---------- business/jxcallback/orderman/orderman_ext.go | 4 ++-- business/jxcallback/scheduler/defsch/defsch_ext.go | 4 ++++ business/partner/delivery/dada/waybill.go | 2 ++ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 2c7caca12..96a4defa1 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -539,16 +539,6 @@ func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder, bill *model.W cancelWaybill[bill.VendorWaybillID] = bill // 已经全部运单取消,退款结算 if len(bills) == len(cancelWaybill) { - //for _, v := range bills { - // if v.VendorWaybillID == bill.VendorWaybillID { - // continue - // } - // // 已经取消订单的违约金计算 - // if err = countWaybillSettleInfo(db, order, v, store); err != nil { - // return err - // } - //} - // 最终的金额核算,多退少补 if err = orderFeeSettle(db, order, bill, bills, store); err != nil { return err diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index bdc7dd678..844895e77 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -382,8 +382,8 @@ func (c *OrderManager) GetOrders(ctx *jxcontext.Context, isIncludeFake bool, fro var damages = &struct { Damages int64 `json:"damages"` }{} - sqlDamages := ` SELECT SUM(w.desired_fee) damages FROM waybill w WHERE w.vendor_order_id = ? AND w.status = ? ` - paramDamages := []interface{}{order.VendorOrderID, model.OrderStatusCanceled} + sqlDamages := ` SELECT SUM(w.desired_fee) damages FROM waybill w WHERE w.vendor_order_id = ? AND w.status = ? AND w.vendor_waybill_id <> ? ` + paramDamages := []interface{}{order.VendorOrderID, model.OrderStatusCanceled, order.VendorWaybillID} if err := dao.GetRow(db, damages, sqlDamages, paramDamages); err == nil { order.LiquidatedDamages = damages.Damages } diff --git a/business/jxcallback/scheduler/defsch/defsch_ext.go b/business/jxcallback/scheduler/defsch/defsch_ext.go index a3b3017f6..009c8ac57 100644 --- a/business/jxcallback/scheduler/defsch/defsch_ext.go +++ b/business/jxcallback/scheduler/defsch/defsch_ext.go @@ -427,6 +427,10 @@ func (s *DefScheduler) CancelAll3rdWaybills(ctx *jxcontext.Context, vendorOrderI // 取消三方运单,取消各平台单号信息,间隔一段时间后定时任务重新调度 savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true) if savedOrderInfo != nil { + // 查询三方运单是否为取消状态 + //for _, v := range savedOrderInfo.waybills { + // mtps, err := api.MtpsAPI.QueryOrderStatus(0, v.VendorWaybillID) + //} err = s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive) } else { err = scheduler.ErrCanNotFindOrder diff --git a/business/partner/delivery/dada/waybill.go b/business/partner/delivery/dada/waybill.go index c1e785a8b..9feea5a0e 100644 --- a/business/partner/delivery/dada/waybill.go +++ b/business/partner/delivery/dada/waybill.go @@ -589,6 +589,8 @@ func (c *DeliveryHandler) GetDeliverLiquidatedDamages(orderId string, deliverId } } + // 直接返回的 原因是,一个订单在达达发布多次运单时,QueryOrderInfo获取到的运单始终是最后一个运单的配送价格!所以直接返回算了! + return localPrice, nil // 平台状态兑换金额 var vendorPrice int64 = 0 // 未接单不扣款 From 7d848cde3903e41ddfa8f28ab1200aed333b8956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 30 May 2023 16:00:48 +0800 Subject: [PATCH 2/7] 1 --- business/jxcallback/scheduler/basesch/basesch.go | 3 --- business/jxcallback/scheduler/defsch/defsch.go | 10 +++++----- business/jxcallback/scheduler/defsch/defsch_ext.go | 4 ---- business/partner/delivery/mtps/waybill.go | 1 + 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index 0c601adef..81de0173c 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -275,7 +275,6 @@ func (c *BaseScheduler) CreateWaybill(platformVendorID int, order *model.GoodsOr func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) { // 部分快递平台在取消成功后有时会不发运单取消消息过来(比如达达,904200512000442),为避免二次取消报错,添加状态判断 - //if c.IsReallyCallPlatformAPI && bill.Status != model.WaybillStatusCanceled { //此行测试用 if c.IsReallyCallPlatformAPI && bill.OrderVendorID != bill.WaybillVendorID && bill.Status != model.WaybillStatusCanceled { if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil { if err = utils.CallFuncLogErrorWithInfo(func() error { @@ -283,8 +282,6 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c return err } return nil - //order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID) - //return orderman.ResetCreateWaybillFee(nil, order, bill) }, "CancelWaybill bill:%v", bill); err == nil { bill.Status = model.WaybillStatusCanceled bill.DeliveryFlag |= model.WaybillDeliveryFlagMaskActiveCancel diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 9f9428bf1..5d73f342b 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -740,6 +740,8 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo } } + globals.SugarLogger.Debugf("bill===============%s", utils.Format4Output(bill, false)) + globals.SugarLogger.Debugf("order===============%s", utils.Format4Output(bill, false)) if err := orderman.ResetCreateWaybillFee(nil, order, bill); err != nil { globals.SugarLogger.Errorf("ResetCreateWaybillFee err : %v", err) } @@ -776,6 +778,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo order.Status = model.OrderStatusFinished order.OrderFinishedAt = time.Now() partner.CurOrderManager.UpdateOrderFields(order, []string{"status", "OrderFinishedAt"}) + if err := orderman.FinisOrderWaybillFee(nil, order, bill); err != nil { globals.SugarLogger.Debugf("FinisOrderWaybillFee count err : %v", err) } @@ -999,9 +1002,7 @@ func (s *DefScheduler) solutionJdsOrder(bill *model.Waybill) (err error) { func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2Keep *model.Waybill, cancelReasonID int, cancelReason string) (err error) { for _, v := range savedOrderInfo.waybills { - if v.Status < model.WaybillStatusEndBegin && - !model.IsWaybillPlatformOwn(v) && - (bill2Keep == nil || !(v.WaybillVendorID == bill2Keep.WaybillVendorID && v.VendorWaybillID == bill2Keep.VendorWaybillID)) { + if v.Status < model.WaybillStatusEndBegin && !model.IsWaybillPlatformOwn(v) && (bill2Keep == nil || !(v.WaybillVendorID == bill2Keep.WaybillVendorID && v.VendorWaybillID == bill2Keep.VendorWaybillID)) { err2 := s.CancelWaybill(v, cancelReasonID, cancelReason) if err2 == nil { // 在这里就从map里删除,而不是等收到运单结束事件才删除,可避免不必要的重复取消(第二次取消还会失败) @@ -1011,8 +1012,7 @@ func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2 if err == nil { err = err2 } - partner.CurOrderManager.OnOrderMsg(savedOrderInfo.order, ""+ - "", err2.Error()) + partner.CurOrderManager.OnOrderMsg(savedOrderInfo.order, "", err2.Error()) } } diff --git a/business/jxcallback/scheduler/defsch/defsch_ext.go b/business/jxcallback/scheduler/defsch/defsch_ext.go index 009c8ac57..a3b3017f6 100644 --- a/business/jxcallback/scheduler/defsch/defsch_ext.go +++ b/business/jxcallback/scheduler/defsch/defsch_ext.go @@ -427,10 +427,6 @@ func (s *DefScheduler) CancelAll3rdWaybills(ctx *jxcontext.Context, vendorOrderI // 取消三方运单,取消各平台单号信息,间隔一段时间后定时任务重新调度 savedOrderInfo := s.loadSavedOrderByID(vendorOrderID, vendorID, true) if savedOrderInfo != nil { - // 查询三方运单是否为取消状态 - //for _, v := range savedOrderInfo.waybills { - // mtps, err := api.MtpsAPI.QueryOrderStatus(0, v.VendorWaybillID) - //} err = s.cancelOtherWaybills(savedOrderInfo, nil, partner.CancelWaybillReasonOther, partner.CancelWaybillReasonStrActive) } else { err = scheduler.ErrCanNotFindOrder diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index 5601bafd8..65652cdbf 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -85,6 +85,7 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg } func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) { + globals.SugarLogger.Debugf("=======msg %s", utils.Format4Output(msg, false)) order := c.callbackMsg2Waybill(msg) // 多次取消,只处理第一次 if msg.Status == mtpsapi.OrderStatusCanceled { From 833dcddced880738a93e7206b32475f39168390e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 30 May 2023 16:20:39 +0800 Subject: [PATCH 3/7] 1 --- business/jxcallback/scheduler/defsch/defsch.go | 2 -- business/partner/delivery/mtps/waybill.go | 12 +++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/business/jxcallback/scheduler/defsch/defsch.go b/business/jxcallback/scheduler/defsch/defsch.go index 5d73f342b..540c53817 100644 --- a/business/jxcallback/scheduler/defsch/defsch.go +++ b/business/jxcallback/scheduler/defsch/defsch.go @@ -740,8 +740,6 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo } } - globals.SugarLogger.Debugf("bill===============%s", utils.Format4Output(bill, false)) - globals.SugarLogger.Debugf("order===============%s", utils.Format4Output(bill, false)) if err := orderman.ResetCreateWaybillFee(nil, order, bill); err != nil { globals.SugarLogger.Errorf("ResetCreateWaybillFee err : %v", err) } diff --git a/business/partner/delivery/mtps/waybill.go b/business/partner/delivery/mtps/waybill.go index 65652cdbf..cf1b24812 100644 --- a/business/partner/delivery/mtps/waybill.go +++ b/business/partner/delivery/mtps/waybill.go @@ -85,16 +85,14 @@ func (c *DeliveryHandler) OnWaybillExcept(msg *mtpsapi.CallbackOrderExceptionMsg } func (c *DeliveryHandler) onWaybillMsg(msg *mtpsapi.CallbackOrderMsg) (retVal *mtpsapi.CallbackResponse) { - globals.SugarLogger.Debugf("=======msg %s", utils.Format4Output(msg, false)) order := c.callbackMsg2Waybill(msg) // 多次取消,只处理第一次 if msg.Status == mtpsapi.OrderStatusCanceled { - bill, err := partner.CurOrderManager.LoadWaybill(msg.MtPeisongID, model.VendorIDMTPS) - if err != nil { - return mtpsapi.Err2CallbackResponse(err, fmt.Sprintf("%s", "获取订单状态错误")) - } - if bill.Status == model.OrderStatusCanceled { - return mtpsapi.SuccessResponse + orderStatus, _ := orderman.FixedOrderManager.GetWayBillStatusList(msg.OrderID, msg.MtPeisongID, model.VendorIDMTPS) + for _, v := range orderStatus { + if v.VendorStatus == "99" { + return mtpsapi.SuccessResponse + } } } From 982c7568b3cbea963910da38c3c2009b02f5ffc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 31 May 2023 13:57:37 +0800 Subject: [PATCH 4/7] 1 --- business/jxcallback/orderman/order.go | 2 +- .../scheduler/basesch/basesch_ext.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 96a4defa1..5dd7a7646 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -620,7 +620,7 @@ func orderFeeSettle(db *dao.DaoDB, order *model.GoodsOrder, bill *model.Waybill, for _, v := range bills { allFee += int(v.DesiredFee) - allFee += int(v.TipFee) + //allFee += int(v.TipFee) } // 运单支出费用统计,应该等于 支出费用- 退还费用 globals.SugarLogger.Errorf("计算错误:订单支出费用应该=退还费用+运单支出费用,支出费用:%d,已经退还费用:%d,运单计算费用:%d", billExpend, billIncome, allFee) diff --git a/business/jxcallback/scheduler/basesch/basesch_ext.go b/business/jxcallback/scheduler/basesch/basesch_ext.go index 24c6775bc..6e3880caf 100644 --- a/business/jxcallback/scheduler/basesch/basesch_ext.go +++ b/business/jxcallback/scheduler/basesch/basesch_ext.go @@ -370,6 +370,9 @@ func (c *BaseScheduler) CheckStoreBalanceWithTip(ctx *jxcontext.Context, order * if roundTipFee != tipFee { return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("小费必须是1元的整数倍") } + if order.WaybillTipMoney >= tipFee { + return model.ErrCodeOnePayTipFeeMore, fmt.Errorf("本次小费金额不能小于已经支付的小费") + } if order.CreateDeliveryType == model.YES { //加小费只判断余额 storeAcct, err := cms.GetStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order)) @@ -415,20 +418,21 @@ func isWaybillCanAddTip(waybill *model.Waybill) (isCan bool) { func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order *model.GoodsOrder, tipFee int64) (err error) { db := dao.GetDB() + thisTimeTipFee := tipFee - order.WaybillTipMoney storeDetail, _ := dao.GetStoreDetail(db, jxutils.GetSaleStoreIDFromOrder(order), order.VendorID, "") flag := false // 如果平台支持设置配送小费,必须要成功设置 if handler := partner.GetWaybillTipUpdater(order.VendorID); handler != nil { - if err = handler.UpdateWaybillTip(ctx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, "", "", utils.Int2Str(storeDetail.CityCode), tipFee); err != nil { + if err = handler.UpdateWaybillTip(ctx, order.VendorOrgCode, order.VendorStoreID, order.VendorOrderID, "", "", utils.Int2Str(storeDetail.CityCode), thisTimeTipFee); err != nil { return err } else { //加小费成功扣钱 if order.CreateDeliveryType == model.YES { - if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0); err == nil { + if err = partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(thisTimeTipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0); err == nil { flag = true } } else if order.CreateDeliveryType == model.NO { - if err = partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, ""); err == nil { + if err = partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(thisTimeTipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, ""); err == nil { flag = true } } @@ -452,8 +456,10 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { waybill := batchItemList[0].(*model.Waybill) handler := partner.GetWaybillTipUpdater(waybill.WaybillVendorID) - if err == nil { + if waybill.WaybillVendorID == model.VendorIDDada { err = handler.UpdateWaybillTip(ctx, waybill.VendorOrgCode, storeDetail.VendorStoreID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), tipFee) + } else { + err = handler.UpdateWaybillTip(ctx, waybill.VendorOrgCode, storeDetail.VendorStoreID, waybill.VendorOrderID, waybill.VendorWaybillID, waybill.VendorWaybillID2, utils.Int2Str(storeDetail.CityCode), thisTimeTipFee) } return nil, err }, waybills2) @@ -464,9 +470,9 @@ func (c *BaseScheduler) SetOrderWaybillTipByOrder(ctx *jxcontext.Context, order if !flag { //加小费成功扣钱 if order.CreateDeliveryType == model.YES { - partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(tipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0) + partner.CurStoreAcctManager.InsertStoreAcctExpendAndUpdateStoreAcctBalance(ctx, jxutils.GetSaleStoreIDFromOrder(order), int(thisTimeTipFee), partner.StoreAcctTypeExpendCreateWaybillTip, order.VendorOrderID, "", 0) } else if order.CreateDeliveryType == model.NO { - partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(tipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, "") + partner.CurStoreAcctManager.InsertBrandBill(ctx, storeDetail.BrandID, int(thisTimeTipFee), model.BrandBillTypeExpend, model.BrandBillFeeTypeTipFee, order.VendorOrderID, "") } } } From 6add9ca9eeb2c4cab5972a8e603f2133f229ec90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 31 May 2023 15:39:12 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B0=8F=E8=B4=B9=E5=92=8C=E9=AA=91?= =?UTF-8?q?=E6=89=8B=E6=8A=95=E8=AF=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/delivery/sfps/waybill.go | 8 ++++++++ business/partner/delivery/uupt/waybill.go | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 4310940d1..37608da0d 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -275,6 +275,14 @@ func (d DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeison return result, nil } +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + return api.SfPsAPI.QueryTipFee(vendorWaybillID) +} + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + return api.SfPsAPI.AddTipFee(vendorWaybillID, tipFee) +} + // OnWaybillMsg 配送状态更改回调 func OnWaybillMsg(urlIndex string, msg interface{}) (resp *sfps2.CallbackResponse) { order := GetWaybillByStatus(urlIndex, msg) diff --git a/business/partner/delivery/uupt/waybill.go b/business/partner/delivery/uupt/waybill.go index 910925a20..81f5b8c18 100644 --- a/business/partner/delivery/uupt/waybill.go +++ b/business/partner/delivery/uupt/waybill.go @@ -198,6 +198,20 @@ func (d DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo return deliveryFeeInfo, err } +func (c *DeliveryHandler) GetWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2 string) (tipFee int64, err error) { + // uu跑腿没有获取小费的接口,直接返回系统支付的金额 + //order, err := api.UuAPI.GetOrderDetail(vendorOrderID) + //if err == nil { + // tipFee = jxutils.StandardPrice2Int(order.Tips) + //} + //return tipFee, err + return 0, nil +} + +func (c *DeliveryHandler) UpdateWaybillTip(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID, vendorOrderID, vendorWaybillID, vendorWaybillID2, cityCode string, tipFee int64) (err error) { + return api.UuAPI.AddTip(vendorOrderID, vendorWaybillID, int(tipFee)) +} + func (d DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) { return fmt.Errorf("UU跑腿暂不支持此操作") } From f38c6bcc4b01ef838bd94872e688315a319c3815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 1 Jun 2023 10:55:02 +0800 Subject: [PATCH 6/7] 1 --- business/jxcallback/orderman/waybill.go | 5 +++++ business/model/dao/dao_order.go | 9 +++++++++ controllers/jx_order.go | 14 ++++++++++++++ routers/commentsRouter_controllers.go | 9 +++++++++ 4 files changed, 37 insertions(+) diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 1381c18dc..3e8f3fd2d 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -259,6 +259,11 @@ func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorID, wayb 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) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index ac116e38b..01cc526c3 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -1291,6 +1291,15 @@ 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 <> '' ` + var data []*model.Waybill + if err := GetRows(db, &data, sql, []interface{}{orderId}); err != nil { + return nil, err + } + return data, nil +} + func GetOrdersSupplement(db *DaoDB, storIDs, vendorIDs, statuss []int, vendorOrderID string, fromTime, toTime time.Time, stype, IsReverse, offset, pageSize int) (orderSupplementFee []*model.OrderSupplementFee, totalCount int, err error) { sql := ` SELECT SQL_CALC_FOUND_ROWS * diff --git a/controllers/jx_order.go b/controllers/jx_order.go index 350f9dc36..d95407a0e 100644 --- a/controllers/jx_order.go +++ b/controllers/jx_order.go @@ -1004,6 +1004,20 @@ func (c *OrderController) ComplaintRider() { }) } +// @Title 获取可投诉骑手列表 +// @Description 获取可投诉骑手列表 +// @Param token header string true "认证token" +// @Param vendorOrderID formData string true "订单ID" +// @Success 200 {object} controllers.CallResult +// @Failure 200 {object} controllers.CallResult +// @router /ComplaintRiderList [get] +func (c *OrderController) ComplaintRiderList() { + c.callComplaintRiderList(func(params *tOrderComplaintRiderListParams) (retVal interface{}, errCode string, err error) { + retVal, err = orderman.GetComplaintList(params.VendorOrderID) + return retVal, "", err + }) +} + // @Title 查询门店订单扣款记录 // @Description 查询门店订单扣款记录 // @Param token header string true "认证token" diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 6a13fdda2..2be37534e 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -1223,6 +1223,15 @@ func init() { 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: "ComplaintRiderList", + Router: `/ComplaintRiderList`, + AllowHTTPMethods: []string{"get"}, + 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: "ConfirmReceiveGoods", From 2433cbd9f3ced6d656d265f82eae431eaa500925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 1 Jun 2023 12:47:35 +0800 Subject: [PATCH 7/7] 1 --- business/jxcallback/orderman/waybill.go | 24 +++++++++++------------- business/model/dao/dao_order.go | 16 +++++++++++++--- controllers/jx_order.go | 9 ++------- 3 files changed, 26 insertions(+), 23 deletions(-) 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 }) }