| | |
| | | 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> |
| | |
| | | @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(","); |
| | | } |
| | | 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; |
| | | } |
| | | } |