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("支付币种不能为空");