From 35d63981ed5d46a7896c5273aca8b65681f5dcd5 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 19 Feb 2024 17:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E6=AF=94=E9=80=80?= =?UTF-8?q?=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/requests/orderInquiry.go | 3 ++- api/service/OrderInquiry.go | 8 +++++++- api/service/orderProduct.go | 1 + extend/weChat/weChatPay.go | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/requests/orderInquiry.go b/api/requests/orderInquiry.go index 8fc50dc..8419ded 100644 --- a/api/requests/orderInquiry.go +++ b/api/requests/orderInquiry.go @@ -36,7 +36,8 @@ type GetOrderInquiryPage struct { // CancelOrderInquiry 取消问诊订单 type CancelOrderInquiry struct { - CancelRemarks string `json:"cancel_remarks" form:"cancel_remarks" validate:"required" label:"取消订单备注"` + RefundAmount float64 `json:"refund_amount" form:"refund_amount" validate:"required" label:"退款金额"` + CancelRemarks string `json:"cancel_remarks" form:"cancel_remarks" validate:"required" label:"取消订单备注"` } // GetOrderInquiryRecordPage 获取问诊记录列表-分页 diff --git a/api/service/OrderInquiry.go b/api/service/OrderInquiry.go index d6a8a25..5adf853 100644 --- a/api/service/OrderInquiry.go +++ b/api/service/OrderInquiry.go @@ -70,6 +70,11 @@ func (r *OrderInquiryService) CancelOrderInquiry(req requests.CancelOrderInquiry return false, errors.New("订单未支付,无需取消") } + // 检测退款金额 + if req.RefundAmount > orderInquiry.PaymentAmountTotal { + return false, errors.New("退款金额不可超过实付金额") + } + // 订单完成时间预留5分钟进行操作 if !orderInquiry.CompleteTime.IsEmpty() { // 计算三天后的时间 @@ -113,6 +118,7 @@ func (r *OrderInquiryService) CancelOrderInquiry(req requests.CancelOrderInquiry OutTradeNo: orderInquiry.InquiryNo, OutRefundNo: inquiryRefundNo, Reason: "客服取消", + RefundAmount: int64(req.RefundAmount * 100), PaymentAmountTotal: int64(orderInquiry.PaymentAmountTotal * 100), NotifyUrl: config.C.Wechat.RefundNotifyDomain + config.C.Wechat.PatientInquiryRefundNotifyUrl, } @@ -196,7 +202,7 @@ func (r *OrderInquiryService) CancelOrderInquiry(req requests.CancelOrderInquiry InquiryRefundNo: inquiryRefundNo, RefundId: refundId, InquiryRefundStatus: inquiryRefundStatus, - RefundTotal: orderInquiry.PaymentAmountTotal, + RefundTotal: req.RefundAmount, RefundReason: req.CancelRemarks, SuccessTime: model.LocalTime(successTime), } diff --git a/api/service/orderProduct.go b/api/service/orderProduct.go index 0105c4a..bc4c160 100644 --- a/api/service/orderProduct.go +++ b/api/service/orderProduct.go @@ -167,6 +167,7 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct OutTradeNo: orderProduct.OrderProductNo, OutRefundNo: refundNo, Reason: "客服取消", + RefundAmount: int64(orderProduct.PaymentAmountTotal * 100), PaymentAmountTotal: int64(orderProduct.PaymentAmountTotal * 100), NotifyUrl: config.C.Wechat.RefundNotifyDomain + config.C.Wechat.PatientProductRefundNotifyUrl, } diff --git a/extend/weChat/weChatPay.go b/extend/weChat/weChatPay.go index 0821c9b..85aa982 100644 --- a/extend/weChat/weChatPay.go +++ b/extend/weChat/weChatPay.go @@ -16,7 +16,8 @@ type RefundRequest struct { OutTradeNo string `json:"out_trade_no" comment:"商户订单号"` OutRefundNo string `json:"out_refund_no" comment:"退款订单号"` Reason string `json:"reason" comment:"退款原因"` - PaymentAmountTotal int64 `json:"payment_amount_total" comment:"退款金额"` + RefundAmount int64 `json:"refund_amount" comment:"退款金额"` + PaymentAmountTotal int64 `json:"payment_amount_total" comment:"支付金额"` NotifyUrl string `json:"notify_url" comment:"回调地址"` } @@ -72,7 +73,7 @@ func (r RefundRequest) Refund(orderType int) (*refunddomestic.Refund, error) { NotifyUrl: core.String(r.NotifyUrl), Amount: &refunddomestic.AmountReq{ Currency: core.String("CNY"), - Refund: core.Int64(r.PaymentAmountTotal), + Refund: core.Int64(r.RefundAmount), Total: core.Int64(r.PaymentAmountTotal), }, }