Commit 60f766f35cdf8b23f566fe4b8807e3769ac7e615
1 parent
92f6c8f4
钱包充值允许多次退款
Showing
2 changed files
with
16 additions
and
24 deletions
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
| ... | ... | @@ -44,23 +44,21 @@ public interface ErrorCodeConstants { |
| 44 | 44 | ErrorCode WALLET_NOT_FOUND = new ErrorCode(1007007000, "用户钱包不存在"); |
| 45 | 45 | ErrorCode WALLET_BALANCE_NOT_ENOUGH = new ErrorCode(1007007001, "钱包余额不足"); |
| 46 | 46 | ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1007007002, "未找到对应的钱包交易"); |
| 47 | - ErrorCode WALLET_REFUND_AMOUNT_ERROR = new ErrorCode(1007007003, "钱包退款金额不对"); | |
| 48 | - ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1007007004, "已经存在钱包退款"); | |
| 49 | - ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1007007005, "钱包冻结余额不足"); | |
| 47 | + ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1007007003, "已经存在钱包退款"); | |
| 48 | + ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1007007004, "钱包冻结余额不足"); | |
| 50 | 49 | |
| 51 | - // TODO @jason:把钱包充值,单独搞个错误码段哈; | |
| 52 | - | |
| 53 | - ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1007007005, "钱包充值记录不存在"); | |
| 54 | - ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007007006, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); | |
| 55 | - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1007007007, "钱包充值更新支付状态失败,支付单编号不匹配"); | |
| 56 | - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1007007008, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); | |
| 57 | - ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1007007009, "钱包充值更新支付状态失败,支付单金额不匹配"); | |
| 58 | - ErrorCode WALLET_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1007900010, "钱包发起退款失败,钱包充值订单未支付"); | |
| 59 | - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1007900011, "钱包发起退款失败,钱包充值订单已退款"); | |
| 60 | - ErrorCode WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1007900012, "钱包发起退款失败,钱包余额不足"); | |
| 61 | - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1007900013, "钱包退款更新失败,钱包退款单编号不匹配"); | |
| 62 | - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1007900014, "钱包退款更新失败,退款订单不存在"); | |
| 63 | - ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1007900015, "钱包退款更新失败,退款单金额不匹配"); | |
| 50 | + // ========== 钱包充值模块 1007008000 ========== | |
| 51 | + ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1007008000, "钱包充值记录不存在"); | |
| 52 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007008001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); | |
| 53 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1007008002, "钱包充值更新支付状态失败,支付单编号不匹配"); | |
| 54 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1007008003, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); | |
| 55 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1007008004, "钱包充值更新支付状态失败,支付单金额不匹配"); | |
| 56 | + ErrorCode WALLET_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1007008005, "钱包发起退款失败,钱包充值订单未支付"); | |
| 57 | + ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1007008006, "钱包发起退款失败,钱包充值订单已退款"); | |
| 58 | + ErrorCode WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1007008007, "钱包发起退款失败,钱包余额不足"); | |
| 59 | + ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1007008008, "钱包退款更新失败,钱包退款单编号不匹配"); | |
| 60 | + ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1007008009, "钱包退款更新失败,退款订单不存在"); | |
| 61 | + ErrorCode WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1007008010, "钱包退款更新失败,退款单金额不匹配"); | |
| 64 | 62 | // ========== 示例订单 1007900000 ========== |
| 65 | 63 | ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1007900000, "示例订单不存在"); |
| 66 | 64 | ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007900001, "示例订单更新支付状态失败,订单不是【未支付】状态"); | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| ... | ... | @@ -82,7 +82,7 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 82 | 82 | throw exception(REFUND_NOT_FOUND); |
| 83 | 83 | } |
| 84 | 84 | // 1.2 校验是否可以退款 |
| 85 | - Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo(), refundPrice); | |
| 85 | + Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo()); | |
| 86 | 86 | PayWalletDO wallet = walletMapper.selectById(walletId); |
| 87 | 87 | Assert.notNull(wallet, "钱包 {} 不存在", walletId); |
| 88 | 88 | |
| ... | ... | @@ -96,18 +96,12 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 96 | 96 | * @param refundId 支付退款单 id |
| 97 | 97 | * @param walletPayNo 钱包支付 no |
| 98 | 98 | */ |
| 99 | - private Long validateWalletCanRefund(Long refundId, String walletPayNo, Integer refundPrice) { | |
| 99 | + private Long validateWalletCanRefund(Long refundId, String walletPayNo) { | |
| 100 | 100 | // 1. 校验钱包支付交易存在 |
| 101 | 101 | PayWalletTransactionDO walletTransaction = walletTransactionService.getWalletTransactionByNo(walletPayNo); |
| 102 | 102 | if (walletTransaction == null) { |
| 103 | 103 | throw exception(WALLET_TRANSACTION_NOT_FOUND); |
| 104 | 104 | } |
| 105 | - // 原来的支付金额 | |
| 106 | - // TODO @jason:应该允许多次退款哈; | |
| 107 | - int amount = - walletTransaction.getPrice(); | |
| 108 | - if (refundPrice != amount) { | |
| 109 | - throw exception(WALLET_REFUND_AMOUNT_ERROR); | |
| 110 | - } | |
| 111 | 105 | PayWalletTransactionDO refundTransaction = walletTransactionService.getWalletTransaction( |
| 112 | 106 | String.valueOf(refundId), PAYMENT_REFUND); |
| 113 | 107 | if (refundTransaction != null) { | ... | ... |