| | |
| | | // 判断已经购买的了多少 |
| | | List<TSysGoodsExchange> list = sysGoodsExchangeMapper.selectList(new LambdaQueryWrapper<TSysGoodsExchange>().eq(TSysGoodsExchange::getGoodsId, dto.getGoodsId())); |
| | | int sum = list.stream().mapToInt(TSysGoodsExchange::getGoodsCount).sum(); |
| | | if(sum+dto.getCount()>tSysGoods.getGoodsTotal()){ |
| | | if(tSysGoods.getGoodsTotal()!=null && sum+dto.getCount()>tSysGoods.getGoodsTotal()){ |
| | | throw new RuntimeException("商品库存不足"); |
| | | } |
| | | if(sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){ |
| | | if(tSysGoods.getConvertibleQuantity()!=null && sum+dto.getCount()>tSysGoods.getConvertibleQuantity()){ |
| | | throw new RuntimeException("可兑换数量不足"); |
| | | } |
| | | List<TCrmClinicPoints> points = crmClinicPointsMapper.selectList(new LambdaQueryWrapper<TCrmClinicPoints>().eq(TCrmClinicPoints::getClinicId, crmClinic.getId()).ge(TCrmClinicPoints::getExpireTime, new Date()).last(" and points > use_points ORDER BY create_time ASC")); |