From 307ac5ff5f5f917f2eec2629449729e577b42dee Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 03 六月 2025 09:29:05 +0800 Subject: [PATCH] 政务云 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TCouponServiceImpl.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TCouponServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TCouponServiceImpl.java index eb7892a..c08b27b 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TCouponServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TCouponServiceImpl.java @@ -1,10 +1,18 @@ package com.ruoyi.other.service.impl; +import com.ruoyi.account.api.feignClient.AppCouponClient; +import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.other.api.domain.TCoupon; +import com.ruoyi.other.api.domain.TGoods; import com.ruoyi.other.mapper.TCouponMapper; +import com.ruoyi.other.query.CouponQuery; import com.ruoyi.other.service.TCouponService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; /** * <p> @@ -17,4 +25,34 @@ @Service public class TCouponServiceImpl extends ServiceImpl<TCouponMapper, TCoupon> implements TCouponService { + @Autowired + private AppCouponClient appCouponClient; + @Override + public PageInfo<TCoupon> pageList(CouponQuery dto) { + PageInfo<TCoupon> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); + List<TCoupon> list = this.baseMapper.pageList(pageInfo,dto); + StringBuilder couponIds = new StringBuilder(); + for (TCoupon tCoupon : list) { + couponIds.append(tCoupon.getId()).append(","); + // 如果优惠券库存为0 那么将优惠券状态改为下架 不启用 + if (tCoupon.getInventoryQuantity()==0){ + tCoupon.setStatus(2); + this.baseMapper.updateById(tCoupon); + + } + + } + if (!list.isEmpty()){ + if (StringUtils.hasLength(couponIds)){ + // 去除最后一个字符 + couponIds.deleteCharAt(couponIds.length()-1); + } + List<Integer> data = appCouponClient.getCountByCouponIds(couponIds.toString()).getData(); + for (int i = 0; i < list.size(); i++) { + list.get(i).setCount(data.get(i)); + } + } + pageInfo.setRecords(list); + return pageInfo; + } } -- Gitblit v1.7.1