diff --git a/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java b/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java index 4a2cf9d..698ad2e 100644 --- a/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/cash/CashRefundServiceImpl.java @@ -198,57 +198,52 @@ public class CashRefundServiceImpl implements RefundService { if (cashRecordRefund.getMarket() == null || cashRecordRefund.getMarket().trim().isEmpty()) { throw new Exception("请选择所属地区"); } - String payType = cashRecordRefund.getPayType(); - Integer wallet = null; - if (payType == null || payType.trim().isEmpty()) { - throw new SystemException("未穿输支付方式"); - } - if (payType.equals("Stripe")||payType.equals("PaymentAsia")) - { - wallet = 2; - } - if (payType.equals("FirstData")||payType.equals("Grabpay")||payType.equals("Nets")||payType.equals("PayPal")||payType.equals("IOS")) - { - wallet = 5; - } - if (payType.equals("Stripe2")) - { - wallet = 3; - } - if (payType.equals("Ipay88")) - { - wallet = 4; - } - if (payType.equals("E-Transfer")) - { - wallet = 6; - } - if (payType.equals("paysolution")) - { - wallet = 8; - } - String payType1 = languageTranslationUtil.translate("银行转账", lang); - String payType2 = languageTranslationUtil.translate("现金", lang); - String payType3 = languageTranslationUtil.translate("支票", lang); - String payType4 = languageTranslationUtil.translate("刷卡", lang); - if (payType.equals(payType1)||payType.equals(payType2)||payType.equals(payType3)||payType.equals(payType4)){ - wallet=cashRecordRefund.getWalletId(); - } - UserRegionWallet userRegionWallet = walletMapper.selectWallet(cashRecordRefund.getJwcode(), wallet); - User user = userMapper.selectUserByJwcode(cashRecordRefund.getJwcode()); - if (user.getCurrentFreeJune().add(user.getCurrentFreeDecember()).compareTo(BigDecimal.valueOf(cashRecordRefund.getPartRefundFree()))<0){ - String errorMsg = languageTranslationUtil.translate("用户钱包余额不足", lang); - throw new BusinessException(errorMsg); - } - if (userRegionWallet == null) { - //初始化钱包 - walletMapper.insert(new UserRegionWallet(null, cashRecordRefund.getJwcode(), wallet, BigDecimal.ZERO, new Date(), new Date())); - log.warn("用户钱包不存在,已初始化钱包"); - } - if (userRegionWallet.getCurrentPermanentGold().compareTo(BigDecimal.valueOf(cashRecordRefund.getPartRefundGold())) < 0) { - throw new BusinessException("用户钱包金币不足"); + if(cashRecordRefund.getWalletId() != null) { + String payType = cashRecordRefund.getPayType(); + Integer wallet = null; + if (payType == null || payType.trim().isEmpty()) { + throw new SystemException("未穿输支付方式"); + } + if (payType.equals("Stripe") || payType.equals("PaymentAsia")) { + wallet = 2; + } + if (payType.equals("FirstData") || payType.equals("Grabpay") || payType.equals("Nets") || payType.equals("PayPal") || payType.equals("IOS")) { + wallet = 5; + } + if (payType.equals("Stripe2")) { + wallet = 3; + } + if (payType.equals("Ipay88")) { + wallet = 4; + } + if (payType.equals("E-Transfer")) { + wallet = 6; + } + if (payType.equals("paysolution")) { + wallet = 8; + } + String payType1 = languageTranslationUtil.translate("银行转账", lang); + String payType2 = languageTranslationUtil.translate("现金", lang); + String payType3 = languageTranslationUtil.translate("支票", lang); + String payType4 = languageTranslationUtil.translate("刷卡", lang); + if (payType.equals(payType1) || payType.equals(payType2) || payType.equals(payType3) || payType.equals(payType4)) { + wallet = cashRecordRefund.getWalletId(); + } + UserRegionWallet userRegionWallet = walletMapper.selectWallet(cashRecordRefund.getJwcode(), wallet); + User user = userMapper.selectUserByJwcode(cashRecordRefund.getJwcode()); + if (user.getCurrentFreeJune().add(user.getCurrentFreeDecember()).compareTo(BigDecimal.valueOf(cashRecordRefund.getPartRefundFree())) < 0) { + String errorMsg = languageTranslationUtil.translate("用户钱包余额不足", lang); + throw new BusinessException(errorMsg); + } + if (userRegionWallet == null) { + //初始化钱包 + walletMapper.insert(new UserRegionWallet(null, cashRecordRefund.getJwcode(), wallet, BigDecimal.ZERO, new Date(), new Date())); + log.warn("用户钱包不存在,已初始化钱包"); + } + if (userRegionWallet.getCurrentPermanentGold().compareTo(BigDecimal.valueOf(cashRecordRefund.getPartRefundGold())) < 0) { + throw new BusinessException("用户钱包金币不足"); + } } - CashRecordDone cashRecordDonetwo = new CashRecordDone(); cashRecordDonetwo.setAreaServise(cashRecordRefund.getAreaServise()); cashRefundMapper.addAudit(cashRecordDonetwo);