无关风月
2024-12-25 042fbcd557ef21ab256a542f1fef039269684340
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.jilongda.optometrist.service.impl;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jilongda.common.basic.PageInfo;
import com.jilongda.optometrist.mapper.SecSettingMapper;
import com.jilongda.optometrist.mapper.TLensGoodsMapper;
import com.jilongda.optometrist.model.SecSetting;
import com.jilongda.optometrist.model.TLensGoods;
import com.jilongda.optometrist.query.TLensGoodsQuery;
import com.jilongda.optometrist.service.TLensGoodsService;
import com.jilongda.optometrist.vo.TLensGoodsVO;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 无关风月
 * @since 2024-12-09
 */
@Service
public class TLensGoodsServiceImpl extends ServiceImpl<TLensGoodsMapper, TLensGoods> implements TLensGoodsService {
 
 
    @Resource
    private SecSettingMapper secSettingMapper;
    @Override
    public PageInfo<TLensGoodsVO> lensReceiptList(TLensGoodsQuery query) {
        PageInfo<TLensGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TLensGoodsVO> list = this.baseMapper.lensReceiptList(query, pageInfo);
        SecSetting secSetting = secSettingMapper.selectOne(null);
        for (TLensGoodsVO tFrameGoodsVO : list) {
            if (tFrameGoodsVO.getTotal() < secSetting.getLensThreshold()) {
                tFrameGoodsVO.setIsWarning(1);
            }
            switch (tFrameGoodsVO.getLensType()){
                case 1:
                    String sphere = tFrameGoodsVO.getSphere();
                    if (sphere.contains("cost")){
                        JSONArray objects = JSONObject.parseArray(sphere);
                        // 遍历这个数组
                        for (Object object : objects) {
                            JSONObject jsonObject = (JSONObject) object;
                            String cost = jsonObject.getString("refractiveIndex");
                            if (tFrameGoodsVO.getRefractiveIndex().equals(cost)){
                                tFrameGoodsVO.setSale(jsonObject.getString("sale"));
                                tFrameGoodsVO.setCost(jsonObject.getString("cost"));
                                break;
                            }
                        }
                    }
                    break;
                case 2:
                    String sphere1 = tFrameGoodsVO.getAsphericSurface();
                    if (sphere1.contains("cost")){
                        JSONArray objects = JSONObject.parseArray(sphere1);
                        // 遍历这个数组
                        for (Object object : objects) {
                            JSONObject jsonObject = (JSONObject) object;
                            String cost = jsonObject.getString("refractiveIndex");
                            if (tFrameGoodsVO.getRefractiveIndex().equals(cost)){
                                tFrameGoodsVO.setSale(jsonObject.getString("sale"));
                                tFrameGoodsVO.setCost(jsonObject.getString("cost"));
                                break;
                            }
                        }
                    }
                    break;
                case 3:
                    String sphere2 = tFrameGoodsVO.getDoubleNon();
                    if (sphere2.contains("cost")){
                        JSONArray objects = JSONObject.parseArray(sphere2);
                        // 遍历这个数组
                        for (Object object : objects) {
                            JSONObject jsonObject = (JSONObject) object;
                            String cost = jsonObject.getString("refractiveIndex");
                            if (tFrameGoodsVO.getRefractiveIndex().equals(cost)){
                                tFrameGoodsVO.setSale(jsonObject.getString("sale"));
                                tFrameGoodsVO.setCost(jsonObject.getString("cost"));
                                break;
                            }
                        }
                    }
                    break;
            }
 
 
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
}