|
|
|
@ -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<Integer, String> 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 + ")"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |