新增药品订单退款

This commit is contained in:
wucongxing8150 2024-06-03 17:11:48 +08:00
parent 0dac42527f
commit ad242af2c4
2 changed files with 66 additions and 54 deletions

View File

@ -23,6 +23,7 @@ type OrderProduct struct {
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态0:否 1:是)" json:"is_delete"`
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:订单取消原因1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)" json:"cancel_reason"`
AmountTotal float64 `gorm:"column:amount_total;type:decimal(10,2);default:0.00;comment:订单金额" json:"amount_total"`
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);default:0.00;comment:优惠卷总金额" json:"coupon_amount_total"`
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
LogisticsFee float64 `gorm:"column:logistics_fee;type:decimal(10,2);default:0.00;comment:运费金额" json:"logistics_fee"`
LogisticsNo string `gorm:"column:logistics_no;type:varchar(100);comment:物流编号" json:"logistics_no"`

View File

@ -161,13 +161,7 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
var successTime time.Time
var refundId string
// // 通知处方平台订单取消
// _, err = prescription.NoticePreOrderCancel(orderProduct.OrderProductNo)
// if err != nil {
// tx.Rollback()
// return false, err
// }
if orderProduct.PaymentAmountTotal > 0 {
// 微信退款
refundRequest := weChat.RefundRequest{
TransactionId: orderProduct.EscrowTradeNo,
@ -221,6 +215,23 @@ func (r *OrderProductService) CancelOrderProduct(req requests.CancelOrderProduct
// 退款编号
refundId = *refund.RefundId
} else {
// 支付金额为0模拟退款
refundId = "模拟退款:" + strconv.FormatInt(global.Snowflake.Generate().Int64(), 10)
refundStatus = 3
successTime = time.Now()
// 模拟退款时手动退还优惠卷
if orderProduct.CouponAmountTotal > 0 {
orderService := OrderService{}
res, err := orderService.ReturnOrderCoupon(orderProduct.OrderProductNo, tx)
if err != nil || !res {
// 退还优惠卷失败
tx.Rollback()
return false, err
}
}
}
// 修改问诊订单退款状态
orderProductData["refund_status"] = refundStatus