luodangjia
2024-08-23 7085ba24d8decee4b13c86a55b93a3bcc4ea0d03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.ruoyi.other.service.impl;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.other.api.domain.TCoupon;
import com.ruoyi.other.api.domain.TVip;
import com.ruoyi.other.mapper.TCouponMapper;
import com.ruoyi.other.mapper.TVipMapper;
import com.ruoyi.other.service.TVipService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 无关风月
 * @since 2024-08-06
 */
@Service
public class TVipServiceImpl extends ServiceImpl<TVipMapper, TVip> implements TVipService {
 
    @Autowired
    private TCouponMapper tCouponMapper;
    @Override
    public PageInfo<TVip> pageList(Integer pageCurr,Integer pageSize) {
        PageInfo<TVip> pageInfo = new PageInfo<>(pageCurr,pageSize);
        List<TVip> list = this.baseMapper.pageList(pageInfo);
 
        for (TVip tVip : list) {
            String coupon = tVip.getCoupon();
            JSONArray jsonArray = JSONObject.parseArray(coupon);
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                Integer id = jsonObject.getInteger("id");
                Integer number = jsonObject.getInteger("number");
                TCoupon tCoupon = tCouponMapper.selectById(id);
                if (tCoupon!=null){
                    stringBuilder.append(tCoupon.getName()).append("*").append(number).append(";");
                }
            }
            tVip.setCouponName(stringBuilder.toString());
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}