From ac70afa4e394626dc03d82def3df1db886bb7c2e Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期四, 12 九月 2024 14:43:59 +0800 Subject: [PATCH] 1.活动优惠券-管理端-类型是首页领取的活动优惠券,发布的时候将已经发布的设置为下架,只能留有一个已发布的优惠券 3.活动优惠券-小程序-新增首页弹窗优惠券-如果领取数量没有超过当前优惠券还可以再次领取,超过领取优惠券的话则不返回数据 --- src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java index 91da73f..28efa42 100644 --- a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java +++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java @@ -19,6 +19,7 @@ import com.mzl.flower.mapper.point.PointGoodsRecordMapper; import com.mzl.flower.service.BaseService; import com.mzl.flower.service.payment.RedisLockService; +import com.mzl.flower.utils.DateUtils; import com.mzl.flower.utils.UUIDGenerator; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; @Service @@ -114,6 +116,12 @@ continue; } + if(Constants.POINT_GOODS_STATUS.A.name().equals(status)){ + if(p.getStock() == null || p.getStock() <= 0){ + throw new ValidationException("商品" + p.getName() + "库存为0不能上架"); + } + } + p.setStatus(status); p.update(SecurityUtils.getUserId()); pointGoodsMapper.updateById(p); @@ -140,7 +148,7 @@ } CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>() .eq(CustomerPoint::getUserId, SecurityUtils.getUserId())); - if(cp == null || (cp.getTotalPoint()-cp.getUsedPoint()-cp.getExpiredPoint()) < p.getPoint() * dto.getNum()){ + if(cp == null || (cp.getTotalPoint()-cp.getUsedPoint()-cp.getExpiredPoint()-cp.getDeductionPoint()) < p.getPoint() * dto.getNum()){ throw new ValidationException("积分不足"); } //记录兑换记录 @@ -151,12 +159,16 @@ record.setNum(dto.getNum()); record.setPoint(p.getPoint()); record.setName(p.getName()); - record.setPictures(p.getPictures()); + record.setPictures(p.getCover()); record.setDescription(p.getDescription()); record.setTotalPoint(p.getPoint() * dto.getNum()); record.setCover(p.getCover()); record.setRedeemCode(UUIDGenerator.getUUID()); record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.A.name());//未使用 + LocalDate expireDate = LocalDate.now().plusYears(1); + String expireDateStr = DateUtils.toString(expireDate,"yyyy-MM-dd"); + record.setExpireTime(DateUtils.dateToLocalDateTime(expireDateStr,false)); + record.create(SecurityUtils.getUserId()); pointGoodsRecordMapper.insert(record); //更新积分汇总 -- Gitblit v1.9.3