Просмотр исходного кода

付款时,资金账户不允许为负数

fubin 1 год назад
Родитель
Сommit
390ef6a94c

+ 1 - 1
src/main/java/com/dk/mdm/service/mac/AccountService.java

@@ -257,7 +257,7 @@ public class AccountService extends BaseService<Account> {
         if (!moneyAccountForUpdate.getFlgNegative()) {
             // 如果余额小于0 ,则提示余额不足
             if (sumAmtInflow.compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.RESIDUE_NO_LESS.getMessage());
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
             }
         }
 

+ 10 - 2
src/main/java/com/dk/mdm/service/mac/PaymentService.java

@@ -207,6 +207,14 @@ public class PaymentService extends BaseService<RecPay> {
                 MoneyAccount moneyAccountUpdate = new MoneyAccount();
                 moneyAccountUpdate.setBalance(moneyAccountForUpdate.getBalance().add(recPayItem.getAmtPay().negate()))
                         .setMacId(moneyAccountForUpdate.getMacId());
+
+                // 如果账户不允许为负数
+                if (!moneyAccountForUpdate.getFlgNegative()) {
+                    // 如果余额小于0 ,则提示余额不足
+                    if (moneyAccountUpdate.getBalance().compareTo(BigDecimal.ZERO) == -1) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
+                    }
+                }
                 moneyAccountService.updateByUuid(moneyAccountUpdate);
             }
         }
@@ -271,7 +279,7 @@ public class PaymentService extends BaseService<RecPay> {
 //            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.RESIDUE_NO_LESS.getMessage());
             }
             accountService.updateByUuid(accountUpdate);
         }
@@ -348,7 +356,7 @@ public class PaymentService extends BaseService<RecPay> {
 //        }
         // 可用金额为负数,则不能保存
         if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
-            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.RESIDUE_NO_LESS.getMessage());
         }
         accountService.updateByUuid(accountUpdate);