gongzuming
2024-09-19 1bcd5a3c6447a0a00dc450b8b7780dadbb8e0e56
优化
已修改2个文件
11 ■■■■ 文件已修改
src/main/java/com/mzl/flower/service/impl/coupon/CouponTemplateServiceImpl2.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/point/PointGoodsService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/impl/coupon/CouponTemplateServiceImpl2.java
@@ -421,7 +421,9 @@
            if(couponTemplateDO==null){
                throw new ValidationException("优惠券不存在");
            }
            if(couponTemplateDO.getCouponAmount()<=0 ){
               throw new ValidationException("优惠券已兑换完");
            }
            CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>()
                    .eq(CustomerPoint::getUserId, SecurityUtils.getUserId()));
            if(cp == null || (cp.getTotalPoint()-cp.getUsedPoint()-cp.getExpiredPoint()- cp.getExpiredPoint()) < couponTemplateDO.getPoint() * dto.getNum()){
@@ -439,6 +441,10 @@
            recordDTO.setCustomerId(customer.getId());
            couponRecordService.createCouponRecord(recordDTO);
            //更新优惠券数量
            couponTemplateDO.setCouponAmount(couponTemplateDO.getCouponAmount()-dto.getNum());
            couponTemplateService.updateById(couponTemplateDO);
            //更新积分汇总
            cp.setUsedPoint(cp.getUsedPoint()+couponTemplateDO.getPoint());
            customerPointMapper.updateById(cp);
@@ -455,6 +461,7 @@
            detail.create(SecurityUtils.getUserId());
            customerPointDetailMapper.insert(detail);
        }catch (Exception e){
            log.error("兑换失败",e);
            throw new ValidationException("兑换失败");
        }finally {
            lockService.releaseObjectLock(key,"");
src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -143,7 +143,7 @@
            if(!Constants.POINT_GOODS_STATUS.A.name().equals(p.getStatus())){
                throw new ValidationException("商品未上架");
            }
            if(p.getStock()< dto.getNum()){
            if(p.getStock() <=0 || p.getStock()< dto.getNum()){
                throw new ValidationException("商品库存不足");
            }
            CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>()