From 58af4e12a1750fa87aaa492be2001ee9ea9f96ed Mon Sep 17 00:00:00 2001 From: wangguorui <2069821375@qq.com> Date: Wed, 18 Mar 2026 13:10:05 +0800 Subject: [PATCH] =?UTF-8?q?20260318=20=E6=B7=BB=E5=8A=A0=E5=88=B0=E8=B4=A6?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E4=B8=8E=E9=92=B1=E5=8C=85=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cash/CashCollectionServiceImpl.java | 55 +++++++++++++++++++--- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java b/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java index b7f90d5..e0be2aa 100644 --- a/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java @@ -62,7 +62,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { throw new IllegalArgumentException("精网号不能为空"); } if (cashCollection.getJwcode() < 10000000 || cashCollection.getJwcode() > 99999999) { - throw new IllegalArgumentException("精网号必须为8位"); + throw new IllegalArgumentException("精网号必须为 8 位"); } if (cashCollection.getName() == null || cashCollection.getName().isEmpty()){ throw new IllegalArgumentException("客户姓名不能为空"); @@ -78,7 +78,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { throw new IllegalArgumentException("金币数量不能为空"); } if (cashCollection.getWalletId() == null || cashCollection.getWalletId() < 1 || cashCollection.getWalletId() > 10) { - throw new IllegalArgumentException("钱包ID为1~10"); + throw new IllegalArgumentException("钱包 ID 为 1~10"); } } if (!cashCollection.getGoodsName().equals("金币充值")) { @@ -104,6 +104,10 @@ public class CashCollectionServiceImpl implements CashCollectionService { if (cashCollection.getPayTime() == null) { throw new IllegalArgumentException("付款时间不能为空"); } + + // 校验钱包 ID 和到账地区的对应关系 + validateWalletAndMarket(cashCollection.getWalletId(), cashCollection.getReceivedMarket()); + //生成订单号后半部分 String orderNumber = UUID.randomUUID().toString().replaceAll("-", ""); CashRecord cashRecord = new CashRecord(); @@ -130,7 +134,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { cashRecord.setSubmitterMarket(cashCollection.getSubmitterMarket()); cashRecord.setOrderType(1); //订单类型:1-收款 cashRecord.setMarket(cashCollection.getMarket()); - //地区,根据jwcode插入 + //地区,根据 jwcode 插入 //cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode())); //插入新收款订单 cashCollectionMapper.add(cashRecord); @@ -248,7 +252,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { throw new IllegalArgumentException("精网号不能为空"); } if (cashRecord.getJwcode() < 10000000 || cashRecord.getJwcode() > 99999999) { - throw new IllegalArgumentException("精网号必须为8位"); + throw new IllegalArgumentException("精网号必须为 8 位"); } if (cashRecord.getName() == null) { throw new IllegalArgumentException("客户姓名不能为空"); @@ -266,7 +270,7 @@ public class CashCollectionServiceImpl implements CashCollectionService { throw new IllegalArgumentException("永久金币数量不能为空"); } if (cashRecord.getWalletId() == null) { - throw new IllegalArgumentException("钱包ID不能为空"); + throw new IllegalArgumentException("钱包 ID 不能为空"); } } if (!cashRecord.getGoodsName().equals("金币充值")) { @@ -293,11 +297,14 @@ public class CashCollectionServiceImpl implements CashCollectionService { throw new IllegalArgumentException("付款时间不能为空"); } + // 校验钱包 ID 和到账地区的对应关系 + validateWalletAndMarket(cashRecord.getWalletId(), cashRecord.getReceivedMarket()); + CashRecord status = cashCollectionMapper.selectByOrderCode(cashRecord.getOrderCode()); if (!status.getStatus().equals(5)) { throw new IllegalArgumentException("只允许编辑已撤回订单"); } - //地区,根据jwcode插入(弃用,插入前调用接口获取地区和姓名,之后前端传入) + //地区,根据 jwcode 插入(弃用,插入前调用接口获取地区和姓名,之后前端传入) //cashRecord.setMarket(cashCollectionMapper.getMarketByJwcode(cashRecord.getJwcode())); int rows = cashCollectionMapper.updateByOrderCode(cashRecord); if (rows > 0) { @@ -665,4 +672,40 @@ public class CashCollectionServiceImpl implements CashCollectionService { return resultPageInfo; } + /** + * 校验钱包 ID 和到账地区的对应关系 + * @param walletId 钱包 ID + * @param receivedMarket 到账地区 ID + */ + private void validateWalletAndMarket(Integer walletId, String receivedMarket) { + if (walletId == null) { + return; // 非金币充值不需要校验 + } + + Map walletMarketMap = new HashMap<>(); + walletMarketMap.put(2, "13"); // 香港 + walletMarketMap.put(3, "4"); // 新加坡 HC + walletMarketMap.put(4, "5"); // 马来西亚 + walletMarketMap.put(5, "4"); // 新加坡 CM + walletMarketMap.put(6, "24016"); // 加拿大 + walletMarketMap.put(7, "24018"); // 泰国 HS + walletMarketMap.put(8, "24018"); // 泰国 HA + walletMarketMap.put(9, "24022"); // 越南 HCM + walletMarketMap.put(10, "24033");// 北京 + + // 钱包 ID=1 为历史钱包,无限制,不需要校验 + if (walletId == 1) { + return; + } + + String expectedMarket = walletMarketMap.get(walletId); + if (expectedMarket == null) { + throw new IllegalArgumentException("无效的钱包 ID: " + walletId); + } + + if (!expectedMarket.equals(receivedMarket)) { + String marketName = marketMapper.getMarketNameById(expectedMarket); + throw new IllegalArgumentException("钱包 ID=" + walletId + " 对应的到账地区应为:" + marketName + "(" + expectedMarket + ")"); + } + } }