From e6a0c4d283a3211481ab759d7bc72f455578e693 Mon Sep 17 00:00:00 2001 From: lijianlin Date: Fri, 24 Oct 2025 10:30:35 +0800 Subject: [PATCH] =?UTF-8?q?10-24=20=E6=94=B6=E6=AC=BE=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E4=B8=8E=E9=87=91=E5=B8=81=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceImpl/cash/CashCollectionServiceImpl.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 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 0bfd909..5ab58b9 100644 --- a/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java +++ b/src/main/java/com/example/demo/serviceImpl/cash/CashCollectionServiceImpl.java @@ -57,8 +57,13 @@ public class CashCollectionServiceImpl implements CashCollectionService { if(cashCollection.getGoodsName()== null){ throw new IllegalArgumentException("商品名不能为空"); } - if(cashCollection.getGoodNum()== null && cashCollection.getPermanentGold()== null && cashCollection.getFreeGold()== null){ - throw new IllegalArgumentException("商品数量或金币数量不能为空"); + if (cashCollection.getGoodsName().equals("金币充值")){ + if( cashCollection.getPermanentGold()== 0 && cashCollection.getFreeGold()== 0){ + throw new IllegalArgumentException("金币数量不能为空");} + } + if (!cashCollection.getGoodsName().equals("金币充值")){ + if( cashCollection.getGoodNum()== 0 ){ + throw new IllegalArgumentException("产品数量不能为空");} } if(cashCollection.getPaymentCurrency()== null){ throw new IllegalArgumentException("支付币种不能为空"); @@ -145,8 +150,13 @@ public class CashCollectionServiceImpl implements CashCollectionService { if(cashRecord.getGoodsName()== null){ throw new IllegalArgumentException("商品名不能为空"); } - if(cashRecord.getGoodNum()== null){ - throw new IllegalArgumentException("商品数量不能为空"); + if (cashRecord.getGoodsName().equals("金币充值")){ + if( cashRecord.getPermanentGold()== 0 && cashRecord.getFreeGold()== 0){ + throw new IllegalArgumentException("金币数量不能为空");} + } + if (!cashRecord.getGoodsName().equals("金币充值")){ + if( cashRecord.getGoodNum()== 0 ){ + throw new IllegalArgumentException("产品数量不能为空");} } if(cashRecord.getPaymentCurrency()== null){ throw new IllegalArgumentException("支付币种不能为空");