Parcourir la source

1、优化货币支付相关

rayson il y a 6 mois
Parent
commit
6d587d13ba
14 fichiers modifiés avec 93 ajouts et 48 suppressions
  1. 25 0
      citu-module-pay/citu-module-pay-api/src/main/java/com/citu/module/pay/enums/ErrorCodeConstants.java
  2. 3 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/admin/currency/vo/recharge/PayCurrencyRechargeRespVO.java
  3. 4 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/admin/currency/vo/rechargepackage/CurrencyRechargePackageBaseVO.java
  4. 5 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyPackageRespVO.java
  5. 5 8
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyRechargeCreateReqVO.java
  6. 3 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyRechargeRespVO.java
  7. 3 3
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/convert/currency/PayCurrencyRechargeConvert.java
  8. 4 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyRechargeDO.java
  9. 4 0
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyRechargePackageDO.java
  10. 0 1
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyTransactionDO.java
  11. 5 5
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyRechargePackageServiceImpl.java
  12. 23 22
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyRechargeServiceImpl.java
  13. 7 7
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyServiceImpl.java
  14. 2 2
      citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyTransactionServiceImpl.java

+ 25 - 0
citu-module-pay/citu-module-pay-api/src/main/java/com/citu/module/pay/enums/ErrorCodeConstants.java

@@ -73,6 +73,29 @@ public interface ErrorCodeConstants {
     ErrorCode PAY_TRANSFER_STATUS_IS_NOT_WAITING = new ErrorCode(1_007_009_005, "转账单不处于待转账");
     ErrorCode PAY_TRANSFER_STATUS_IS_NOT_PENDING = new ErrorCode(1_007_009_006, "转账单不处于待转账或转账中");
 
+    // ========== 货币模块 1-007-010-000 ==========
+    ErrorCode CURRENCY_NOT_FOUND = new ErrorCode(1_007_007_000, "M豆账户不存在");
+    ErrorCode CURRENCY_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_007_001, "M豆账户余额不足");
+    ErrorCode CURRENCY_TRANSACTION_NOT_FOUND = new ErrorCode(1_007_007_002, "未找到对应的M豆账户交易");
+    ErrorCode CURRENCY_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在M豆账户退款");
+    ErrorCode CURRENCY_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "M豆账户冻结余额不足");
+
+    // ========== 货币充值模块 1-007-011-000 ==========
+    ErrorCode CURRENCY_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "M豆账户充值记录不存在");
+    ErrorCode CURRENCY_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "M豆账户充值更新支付状态失败,钱包充值记录不是【未支付】状态");
+    ErrorCode CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1_007_008_002, "M豆账户充值更新支付状态失败,支付单编号不匹配");
+    ErrorCode CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1_007_008_003, "M豆账户充值更新支付状态失败,支付单状态不是【支付成功】状态");
+    ErrorCode CURRENCY_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1_007_008_004, "M豆账户充值更新支付状态失败,支付单金额不匹配");
+    ErrorCode CURRENCY_RECHARGE_REFUND_FAIL_NOT_PAID = new ErrorCode(1_007_008_005, "M豆账户发起退款失败,M豆账户充值订单未支付");
+    ErrorCode CURRENCY_RECHARGE_REFUND_FAIL_REFUNDED = new ErrorCode(1_007_008_006, "M豆账户发起退款失败,M豆账户充值订单已退款");
+    ErrorCode CURRENCY_RECHARGE_REFUND_BALANCE_NOT_ENOUGH = new ErrorCode(1_007_008_007, "M豆账户发起退款失败,M豆账户余额不足");
+    ErrorCode CURRENCY_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR = new ErrorCode(1_007_008_008, "M豆账户退款更新失败,M豆账户退款单编号不匹配");
+    ErrorCode CURRENCY_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND = new ErrorCode(1_007_008_009, "M豆账户退款更新失败,退款订单不存在");
+    ErrorCode CURRENCY_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH = new ErrorCode(1_007_008_010, "M豆账户退款更新失败,退款单金额不匹配");
+    ErrorCode CURRENCY_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "M豆账户充值套餐不存在");
+    ErrorCode CURRENCY_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "M豆账户充值套餐已禁用");
+    ErrorCode CURRENCY_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "M豆账户充值套餐名称已存在");
+
     // ========== 示例订单 1-007-900-000 ==========
     ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1_007_900_000, "示例订单不存在");
     ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_900_001, "示例订单更新支付状态失败,订单不是【未支付】状态");
@@ -90,4 +113,6 @@ public interface ErrorCodeConstants {
     ErrorCode DEMO_TRANSFER_NOT_FOUND = new ErrorCode(1_007_901_001, "示例转账单不存在");
     ErrorCode DEMO_TRANSFER_FAIL_TRANSFER_ID_ERROR = new ErrorCode(1_007_901_002, "转账失败,转账单编号不匹配");
     ErrorCode DEMO_TRANSFER_FAIL_PRICE_NOT_MATCH = new ErrorCode(1_007_901_003, "转账失败,转账单金额不匹配");
+
+
 }

+ 3 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/admin/currency/vo/recharge/PayCurrencyRechargeRespVO.java

@@ -18,6 +18,9 @@ public class PayCurrencyRechargeRespVO {
     @Schema(description = "实际支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
     private Long payPrice;
 
+    @Schema(description = "到账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
+    private Long receiptPrice;
+
     @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
     private Long bonusPrice;
 

+ 4 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/admin/currency/vo/rechargepackage/CurrencyRechargePackageBaseVO.java

@@ -20,6 +20,10 @@ public class CurrencyRechargePackageBaseVO {
     @NotNull(message = "支付金额不能为空")
     private Long payPrice;
 
+    @NotNull(message = "到账金额不能为空")
+    @Schema(description = "到账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
+    private Long receiptPrice;
+
     @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20887")
     @NotNull(message = "赠送金额不能为空")
     private Long bonusPrice;

+ 5 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyPackageRespVO.java

@@ -9,11 +9,16 @@ public class AppPayCurrencyPackageRespVO {
 
     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
     private Long id;
+
     @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐")
     private String name;
 
     @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
     private Long payPrice;
+
+    @Schema(description = "到账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
+    private Long receiptPrice;
+
     @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
     private Long bonusPrice;
 

+ 5 - 8
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyRechargeCreateReqVO.java

@@ -5,22 +5,19 @@ import lombok.Data;
 
 import javax.validation.constraints.AssertTrue;
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
 import java.util.Objects;
 
 @Schema(description = "用户 APP - 创建货币账户充值 Request VO")
 @Data
 public class AppPayCurrencyRechargeCreateReqVO {
 
-    @Schema(description = "支付金额",  example = "1000")
-    @Min(value = 1,  message = "支付金额必须大于零")
-    private Long payPrice;
+//    @Schema(description = "支付金额",  example = "1000")
+//    @Min(value = 1,  message = "支付金额必须大于零")
+//    private Long payPrice;
 
+    @NotNull(message = "未选择充值套餐")
     @Schema(description = "充值套餐编号", example = "1024")
     private Long packageId;
 
-    @AssertTrue(message = "充值金额和充钱套餐不能同时为空")
-    public boolean isValidPayPriceAndPackageId() {
-        return Objects.nonNull(payPrice) || Objects.nonNull(packageId);
-    }
-
 }

+ 3 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/controller/app/currency/vo/recharge/AppPayCurrencyRechargeRespVO.java

@@ -18,6 +18,9 @@ public class AppPayCurrencyRechargeRespVO {
     @Schema(description = "实际支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
     private Long payPrice;
 
+    @Schema(description = "到账金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
+    private Long receiptPrice;
+
     @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
     private Long bonusPrice;
 

+ 3 - 3
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/convert/currency/PayCurrencyRechargeConvert.java

@@ -25,8 +25,8 @@ public interface PayCurrencyRechargeConvert {
 
     PayCurrencyRechargeConvert INSTANCE = Mappers.getMapper(PayCurrencyRechargeConvert.class);
 
-    @Mapping(target = "totalPrice", expression = "java( payPrice + bonusPrice)")
-    PayCurrencyRechargeDO convert(Long currencyId, Long payPrice, Long bonusPrice, Long packageId);
+    @Mapping(target = "totalPrice", expression = "java(receiptPrice + bonusPrice)")
+    PayCurrencyRechargeDO convert(Long currencyId, Long payPrice, Long receiptPrice, Long bonusPrice, Long packageId);
 
     AppPayCurrencyRechargeCreateRespVO convert(PayCurrencyRechargeDO bean);
 
@@ -59,7 +59,7 @@ public interface PayCurrencyRechargeConvert {
     }
 
     default PageResult<AppPayCurrencyRechargeRespVO> convertPage3(PageResult<PayCurrencyRechargeDO> pageResult,
-                                                               List<PayOrderDO> payOrderList) {
+                                                                  List<PayOrderDO> payOrderList) {
         PageResult<AppPayCurrencyRechargeRespVO> voPageResult = BeanUtils.toBean(pageResult, AppPayCurrencyRechargeRespVO.class);
         Map<Long, PayOrderDO> payOrderMap = CollectionUtils.convertMap(payOrderList, PayOrderDO::getId);
         voPageResult.getList().forEach(recharge -> {

+ 4 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyRechargeDO.java

@@ -42,6 +42,10 @@ public class PayCurrencyRechargeDO extends BaseDO {
      * 实际支付金额
      */
     private Long payPrice;
+    /**
+     * 到账金额
+     */
+    private Long receiptPrice;
     /**
      * 赠送金额
      */

+ 4 - 0
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyRechargePackageDO.java

@@ -32,6 +32,10 @@ public class PayCurrencyRechargePackageDO extends BaseDO {
      * 支付金额
      */
     private Long payPrice;
+    /**
+     * 到账金额
+     */
+    private Long receiptPrice;
     /**
      * 赠送金额
      */

+ 0 - 1
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/dal/dataobject/currency/PayCurrencyTransactionDO.java

@@ -54,7 +54,6 @@ public class PayCurrencyTransactionDO extends BaseDO {
 
     /**
      * 交易金额,单位分
-     *
      * 正值表示余额增加,负值表示余额减少
      */
     private Long price;

+ 5 - 5
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyRechargePackageServiceImpl.java

@@ -37,10 +37,10 @@ public class PayCurrencyRechargePackageServiceImpl implements PayCurrencyRecharg
     public PayCurrencyRechargePackageDO validCurrencyRechargePackage(Long packageId) {
         PayCurrencyRechargePackageDO rechargePackageDO = currencyRechargePackageMapper.selectById(packageId);
         if (rechargePackageDO == null) {
-            throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_PACKAGE_NOT_FOUND);
         }
         if (CommonStatusEnum.DISABLE.getStatus().equals(rechargePackageDO.getStatus())) {
-            throw exception(WALLET_RECHARGE_PACKAGE_IS_DISABLE);
+            throw exception(CURRENCY_RECHARGE_PACKAGE_IS_DISABLE);
         }
         return rechargePackageDO;
     }
@@ -78,10 +78,10 @@ public class PayCurrencyRechargePackageServiceImpl implements PayCurrencyRecharg
             return ;
         }
         if (id == null) {
-            throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS);
+            throw exception(CURRENCY_RECHARGE_PACKAGE_NAME_EXISTS);
         }
         if (!id.equals(rechargePackage.getId())) {
-            throw exception(WALLET_RECHARGE_PACKAGE_NAME_EXISTS);
+            throw exception(CURRENCY_RECHARGE_PACKAGE_NAME_EXISTS);
         }
     }
 
@@ -95,7 +95,7 @@ public class PayCurrencyRechargePackageServiceImpl implements PayCurrencyRecharg
 
     private void validateCurrencyRechargePackageExists(Long id) {
         if (currencyRechargePackageMapper.selectById(id) == null) {
-            throw exception(WALLET_RECHARGE_PACKAGE_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_PACKAGE_NOT_FOUND);
         }
     }
 

+ 23 - 22
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyRechargeServiceImpl.java

@@ -81,7 +81,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
      **/
     public static Long convertPriceRatio(Long price) {
 //        return (price / 100) * RATIO_MULTIPLE;
-        return price ;
+        return price;
     }
 
     /**
@@ -100,20 +100,20 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
     public PayCurrencyRechargeDO createCurrencyRecharge(Long dataId, Long userId, Integer userType, String userIp,
                                                         AppPayCurrencyRechargeCreateReqVO reqVO) {
         // 1.1 计算充值金额
-        long payPrice;
+        long payPrice = 0;
         long bonusPrice = 0;
+        long receiptPrice = 0;
         if (Objects.nonNull(reqVO.getPackageId())) {
             PayCurrencyRechargePackageDO rechargePackage = payCurrencyRechargePackageService
                     .validCurrencyRechargePackage(reqVO.getPackageId());
             payPrice = rechargePackage.getPayPrice();
             bonusPrice = rechargePackage.getBonusPrice();
-        } else {
-            payPrice = reqVO.getPayPrice();
+            receiptPrice = rechargePackage.getReceiptPrice();
         }
         // 1.2 插入充值记录
         PayCurrencyDO currency = payCurrencyService.getOrCreateCurrency(dataId, userId, userType);
         PayCurrencyRechargeDO recharge = PayCurrencyRechargeConvert.INSTANCE
-                .convert(currency.getId(), payPrice, bonusPrice, reqVO.getPackageId());
+                .convert(currency.getId(), payPrice, receiptPrice, bonusPrice, reqVO.getPackageId());
         currencyRechargeMapper.insert(recharge);
 
         // 2.1 创建支付单
@@ -165,7 +165,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
         if (currencyRecharge == null) {
             log.error("[updateCurrencyRechargerPaid][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
-            throw exception(WALLET_RECHARGE_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_NOT_FOUND);
         }
         // 1.2 校验货币账户充值是否可以支付
         PayOrderDO payOrderDO = validateCurrencyRechargerCanPaid(currencyRecharge, payOrderId);
@@ -175,7 +175,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
                 new PayCurrencyRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now())
                         .setPayChannelCode(payOrderDO.getChannelCode()));
         if (updateCount == 0) {
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
         }
 
         // 3. 更新货币账户余额
@@ -200,7 +200,8 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
                 .addMessage("character_string1", String.valueOf(payOrderId)) // 支付单编号
                 .addMessage("amount2", fenToYuanStr(Math.toIntExact(currencyRecharge.getTotalPrice()))) // 充值金额
                 .addMessage("time3", LocalDateTimeUtil.formatNormal(currencyRecharge.getCreateTime())) // 充值时间
-                .addMessage("phrase4", "充值成功")).checkError();; // 充值状态
+                .addMessage("phrase4", "充值成功")).checkError();
+        ; // 充值状态
     }
 
     @Override
@@ -210,7 +211,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
         if (currencyRecharge == null) {
             log.error("[refundCurrencyRecharge][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
-            throw exception(WALLET_RECHARGE_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_NOT_FOUND);
         }
         // 1.2 校验货币账户充值是否可以发起退款
         PayCurrencyDO currency = validateCurrencyRechargeCanRefund(currencyRecharge);
@@ -240,7 +241,7 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         PayCurrencyRechargeDO currencyRecharge = currencyRechargeMapper.selectById(id);
         if (currencyRecharge == null) {
             log.error("[updateCurrencyRechargerPaid][货币账户充值记录不存在,货币账户充值记录 id({})]", id);
-            throw exception(WALLET_RECHARGE_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_NOT_FOUND);
         }
         // 1.2 校验货币账户充值是否可以更新已退款
         PayRefundDO payRefund = validateCurrencyRechargeCanRefunded(currencyRecharge, payRefundId);
@@ -273,26 +274,26 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         if (notEqual(currencyRecharge.getPayRefundId(), payRefundId)) {
             log.error("[validateCurrencyRechargeCanRefunded][货币账户充值({}) 退款单不匹配({}),请进行处理!货币账户充值的数据是:{}]",
                     currencyRecharge.getId(), payRefundId, toJsonString(currencyRecharge));
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
         }
 
         // 2.1 校验退款订单
         PayRefundDO payRefund = payRefundService.getRefund(payRefundId);
         if (payRefund == null) {
             log.error("[validateCurrencyRechargeCanRefunded][payRefund({})不存在]", payRefundId);
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_NOT_FOUND);
         }
         // 2.2 校验退款金额一致
         if (notEqual(Long.valueOf(payRefund.getRefundPrice()), currencyRecharge.getPayPrice())) {
             log.error("[validateCurrencyRechargeCanRefunded][货币账户({}) payRefund({}) 退款金额不匹配,请进行处理!货币账户数据是:{},payRefund 数据是:{}]",
                     currencyRecharge.getId(), payRefundId, toJsonString(currencyRecharge), toJsonString(payRefund));
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_PRICE_NOT_MATCH);
         }
         // 2.3 校验退款订单商户订单是否匹配
         if (notEqual(payRefund.getMerchantOrderId(), currencyRecharge.getId().toString())) {
             log.error("[validateCurrencyRechargeCanRefunded][货币账户({}) 退款单不匹配({}),请进行处理!payRefund 数据是:{}]",
                     currencyRecharge.getId(), payRefundId, toJsonString(payRefund));
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUND_ORDER_ID_ERROR);
         }
         return payRefund;
     }
@@ -300,17 +301,17 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
     private PayCurrencyDO validateCurrencyRechargeCanRefund(PayCurrencyRechargeDO currencyRecharge) {
         // 校验充值订单是否支付
         if (!currencyRecharge.getPayStatus()) {
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_NOT_PAID);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_NOT_PAID);
         }
         // 校验充值订单是否已退款
         if (currencyRecharge.getPayRefundId() != null) {
-            throw exception(WALLET_RECHARGE_REFUND_FAIL_REFUNDED);
+            throw exception(CURRENCY_RECHARGE_REFUND_FAIL_REFUNDED);
         }
         // 校验货币账户余额是否足够
         PayCurrencyDO currency = payCurrencyService.getCurrency(currencyRecharge.getCurrencyId());
         Assert.notNull(currency, "用户货币账户({}) 不存在", currency.getId());
         if (revertConvertPriceRatio(currency.getBalance()) < currencyRecharge.getTotalPrice()) {
-            throw exception(WALLET_RECHARGE_REFUND_BALANCE_NOT_ENOUGH);
+            throw exception(CURRENCY_RECHARGE_REFUND_BALANCE_NOT_ENOUGH);
         }
         // TODO @芋艿:需要考虑下,赠送的金额,会不会导致提现超过;
         return currency;
@@ -321,13 +322,13 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         if (currencyRecharge.getPayStatus()) {
             log.error("[validateCurrencyRechargerCanPaid][货币账户({}) 不处于未支付状态!  货币账户数据是:{}]",
                     currencyRecharge.getId(), toJsonString(currencyRecharge));
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID);
         }
         // 1.2 校验支付订单匹配
         if (notEqual(currencyRecharge.getPayOrderId(), payOrderId)) { // 支付单号
             log.error("[validateCurrencyRechargerCanPaid][货币账户({}) 支付单不匹配({}),请进行处理! 货币账户数据是:{}]",
                     currencyRecharge.getId(), payOrderId, toJsonString(currencyRecharge));
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
         }
 
         // 2.1 校验支付单是否存在
@@ -341,19 +342,19 @@ public class PayCurrencyRechargeServiceImpl implements PayCurrencyRechargeServic
         if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) {
             log.error("[validateCurrencyRechargerCanPaid][货币账户({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]",
                     currencyRecharge.getId(), payOrderId, toJsonString(payOrder));
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS);
         }
         // 2.3 校验支付金额一致
         if (notEqual(Long.valueOf(payOrder.getPrice()), currencyRecharge.getPayPrice())) {
             log.error("[validateDemoOrderCanPaid][货币账户({}) payOrder({}) 支付金额不匹配,请进行处理!货币账户 数据是:{},payOrder 数据是:{}]",
                     currencyRecharge.getId(), payOrderId, toJsonString(currencyRecharge), toJsonString(payOrder));
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH);
         }
         // 2.4 校验支付订单的商户订单匹配
         if (notEqual(payOrder.getMerchantOrderId(), currencyRecharge.getId().toString())) {
             log.error("[validateDemoOrderCanPaid][货币账户({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]",
                     currencyRecharge.getId(), payOrderId, toJsonString(payOrder));
-            throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
+            throw exception(CURRENCY_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR);
         }
         return payOrder;
     }

+ 7 - 7
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyServiceImpl.java

@@ -115,13 +115,13 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
         // 1. 校验货币账户支付交易存在
         PayCurrencyTransactionDO currencyTransaction = currencyTransactionService.getCurrencyTransactionByNo(currencyPayNo);
         if (currencyTransaction == null) {
-            throw exception(WALLET_TRANSACTION_NOT_FOUND);
+            throw exception(CURRENCY_TRANSACTION_NOT_FOUND);
         }
         // 2. 校验退款是否存在
         PayCurrencyTransactionDO refundTransaction = currencyTransactionService.getCurrencyTransaction(
                 String.valueOf(refundId), PAYMENT_REFUND);
         if (refundTransaction != null) {
-            throw exception(WALLET_REFUND_EXIST);
+            throw exception(CURRENCY_REFUND_EXIST);
         }
         return currencyTransaction.getCurrencyId();
     }
@@ -135,7 +135,7 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
         PayCurrencyDO payCurrency = getCurrency(currencyId);
         if (payCurrency == null) {
             log.error("[reduceCurrencyBalance],用户货币账户({})不存在.", currencyId);
-            throw exception(WALLET_NOT_FOUND);
+            throw exception(CURRENCY_NOT_FOUND);
         }
         // 2. 加锁,更新钱包余额(目的:避免钱包流水的并发更新时,余额变化不连贯)
         return lockRedisDAO.lock(currencyId, UPDATE_TIMEOUT_MILLIS, () -> {
@@ -156,7 +156,7 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
                 }
             }
             if (updateCounts == 0) {
-                throw exception(WALLET_BALANCE_NOT_ENOUGH);
+                throw exception(CURRENCY_BALANCE_NOT_ENOUGH);
             }
             // 2.2 生成货币账户流水
             // TODO 加上payCurrency.getFreezePrice()冻结金额是因为创建退款单的时候就已经冻结的;
@@ -176,7 +176,7 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
         PayCurrencyDO payCurrency = getCurrency(currencyId);
         if (payCurrency == null) {
             log.error("[addCurrencyBalance],用户货币账户({})不存在.", currencyId);
-            throw exception(WALLET_NOT_FOUND);
+            throw exception(CURRENCY_NOT_FOUND);
         }
         // 1.2 更新货币账户金额
         switch (bizType) {
@@ -205,7 +205,7 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
     public void freezePrice(Long id, Long price) {
         int updateCounts = currencyMapper.freezePrice(id, price);
         if (updateCounts == 0) {
-            throw exception(WALLET_BALANCE_NOT_ENOUGH);
+            throw exception(CURRENCY_BALANCE_NOT_ENOUGH);
         }
     }
 
@@ -213,7 +213,7 @@ public class PayCurrencyServiceImpl implements PayCurrencyService {
     public void unfreezePrice(Long id, Long price) {
         int updateCounts = currencyMapper.unFreezePrice(id, price);
         if (updateCounts == 0) {
-            throw exception(WALLET_FREEZE_PRICE_NOT_ENOUGH);
+            throw exception(CURRENCY_FREEZE_PRICE_NOT_ENOUGH);
         }
     }
 

+ 2 - 2
citu-module-pay/citu-module-pay-biz/src/main/java/com/citu/module/pay/service/currency/PayCurrencyTransactionServiceImpl.java

@@ -34,7 +34,7 @@ public class PayCurrencyTransactionServiceImpl implements PayCurrencyTransaction
     /**
      * 货币账户流水的 no 前缀
      */
-    private static final String WALLET_NO_PREFIX = "M";
+    private static final String CURRENCY_NO_PREFIX = "M";
 
     @Resource
     private PayCurrencyService payCurrencyService;
@@ -58,7 +58,7 @@ public class PayCurrencyTransactionServiceImpl implements PayCurrencyTransaction
     @Override
     public PayCurrencyTransactionDO createCurrencyTransaction(CurrencyTransactionCreateReqBO bo) {
         PayCurrencyTransactionDO transaction = PayCurrencyTransactionConvert.INSTANCE.convert(bo)
-                .setNo(noRedisDAO.generate(WALLET_NO_PREFIX));
+                .setNo(noRedisDAO.generate(CURRENCY_NO_PREFIX));
         payCurrencyTransactionMapper.insert(transaction);
         return transaction;
     }