refactor: 移除wepay依赖,简化订单退款逻辑
This commit is contained in:
@@ -77,12 +77,12 @@ func (m *orders) List(
|
||||
}
|
||||
|
||||
// Refund 订单退款(余额支付走本地退款;微信支付走微信退款并标记为退款处理中)。
|
||||
func (m *orders) Refund(ctx context.Context, id int64) error {
|
||||
func (m *orders) Refund(ctx context.Context, order *models.Order) error {
|
||||
// 余额支付:这里强调“状态一致性”,必须在一个事务中完成:余额退回 + 撤销购买权益 + 更新订单状态。
|
||||
return models.Q.Transaction(func(tx *models.Query) error {
|
||||
order, err := tx.Order.WithContext(ctx).GetByID(id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get order in tx")
|
||||
// 已移除微信退款(wepay)能力:仅支持余额支付订单退款。
|
||||
if order.PaymentMethod != "balance" {
|
||||
return errors.New("暂不支持该支付方式退款")
|
||||
}
|
||||
|
||||
// 退回余额(使用原子自增,避免并发覆盖)。
|
||||
|
||||
Reference in New Issue
Block a user