diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index b0376d35d..b35f40236 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -485,14 +485,18 @@ func ResetCreateWaybillFee(db *dao.DaoDB, order *model.GoodsOrder) (err error) { } } - if !isRefund { - return err + if !isRefund { // 骑手已经到店了,无法退款 + globals.SugarLogger.Debug("Refund Money Fail:", "骑手已到店,无法退款") + return errors.New("骑手已到店,无法退款") } // 获取品牌的支付记录 - orderBill, _ := dao.GetBrandBill(db, store.BrandID, order.VendorOrderID, model.BrandBillTypeExpend, model.BrandBillFeeTypeDelivery, order.VendorWaybillID) - if len(orderBill) != model.YES { - return errors.New("订单支出数据异常,应该为一条数据") + orderBill, _ := dao.GetBrandBill(db, store.BrandID, order.VendorOrderID, 0, model.BrandBillFeeTypeDelivery, order.VendorWaybillID) + for _, v := range orderBill { + if v.BillType == model.BrandBillTypeIncome { // 已经退款了 + globals.SugarLogger.Debug("Refund Money Fail:", "同一订单无法重复退款") + return errors.New("无法重复退款") + } } // 将支出记录修改为退款记录,支付类型为收入,且类型为三方配送时:退费 diff --git a/business/jxcallback/scheduler/basesch/basesch.go b/business/jxcallback/scheduler/basesch/basesch.go index 93b01a334..560c4263b 100644 --- a/business/jxcallback/scheduler/basesch/basesch.go +++ b/business/jxcallback/scheduler/basesch/basesch.go @@ -240,11 +240,11 @@ func (c *BaseScheduler) CancelWaybill(bill *model.Waybill, cancelReasonID int, c if handlerInfo := partner.GetDeliveryPlatformFromVendorID(bill.WaybillVendorID); handlerInfo != nil { if err = utils.CallFuncLogErrorWithInfo(func() error { if err := handlerInfo.Handler.CancelWaybill(bill, cancelReasonID, cancelReason); err != nil { - globals.SugarLogger.Debug("=================正儿八经去平台取消订单") - order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID) - orderman.ResetCreateWaybillFee(nil, order) + return err } - return err + globals.SugarLogger.Debug("=================正儿八经去平台取消订单") + order, _ := partner.CurOrderManager.LoadOrder(bill.VendorOrderID, bill.OrderVendorID) + return orderman.ResetCreateWaybillFee(nil, order) }, "CancelWaybill bill:%v", bill); err == nil { bill.Status = model.WaybillStatusCanceled bill.DeliveryFlag |= model.WaybillDeliveryFlagMaskActiveCancel