liujie
2023-04-06 30cb1d32796a1b482d44bd424fdfe28c26b87be9
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.*;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.ITBoxSizeService;
import com.stylefeng.guns.modular.system.service.ITOrderService;
import com.stylefeng.guns.modular.system.service.ITUserService;
import com.stylefeng.guns.modular.system.utils.UserInfoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2023-01-09
 */
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ITUserService {
 
    @Resource
    private TGoodsMapper tGoodsMapper;
 
    @Resource
    private TCompanyMapper tCompanyMapper;
 
    @Resource
    private TPriceMapper priceMapper;
 
    @Resource
    private TQuoteMapper tQuoteMapper;
 
    @Autowired
    private ITBoxSizeService sizeService;
 
    @Autowired
    private ITOrderService orderService;
    @Resource
    private TUserAddressMapper userAddressMapper;
    @Override
    public List<TUserVo> getList(Page<TUserVo> tUserVoPage, String name, Integer id) {
        Integer companyId = UserInfoUtil.getId();
        List<TUserVo> list = this.baseMapper.getListCompany(tUserVoPage, name, id, companyId);
        for (TUserVo tUserVo : list) {
            List<TUserAddress> addresses = userAddressMapper.selectList(new EntityWrapper<TUserAddress>().eq("user_id", tUserVo.getId()).eq("is_default", 1));
            if(addresses.size()>0){
                tUserVo.setAddress(addresses.get(0).getAddress());
            }
        }
        return list;
    }
 
    @Override
    public TUserBasicInfo getBasicInfo(Integer tUserId) {
        return this.baseMapper.getBasicInfo(tUserId);
    }
 
    @Override
    public List<TUserChild> getChildUser(Page<TUserChild> tUserChildPage,Integer tUserId) {
        return this.baseMapper.getChildUser(tUserChildPage,tUserId);
    }
 
    @Override
    public List<TUserReviewVo> getCheckList(Page<TUserReviewVo> tUserVoPage, String name, Integer state) {
        return this.baseMapper.getCheckList(tUserVoPage,name,state);
    }
 
    @Override
    public List<TGroupVo> groupList(Page<TGroupVo> groupVoPage, String name) {
        return this.baseMapper.groupList(groupVoPage,name);
    }
 
    @Override
    public List<InvoicesInfo> getInvoices(Page<InvoicesInfo> invoicesInfoPage, int userId) {
        return this.baseMapper.getInvoices(invoicesInfoPage,userId);
    }
 
    @Override
    public InvoicesVo getInvoicesFromNumber(Long number) {
        // 1先获取订单详情  发货收货信息
        InvoicesVo info = this.baseMapper.getOrderInfo(number);
 
        // 根据订单id 获取货物信息
        Long id = info.getId();
        TOrder tOrder = orderService.selectById(id);
        List<TGoods> orders = tGoodsMapper.selectList(new EntityWrapper<TGoods>().eq("order_id", id));
        ArrayList<TGoodsVo> tGoodsVos = new ArrayList<>();
        TCompany tCompany = tCompanyMapper.selectById(info.getCompanyId());
        List<TBoxSize> tBoxSizes = sizeService.selectList(null);
        for (TGoods order : orders) {
            TGoodsVo tGoodsVo = new TGoodsVo();
            tGoodsVo.setName(tCompany.getName());
            tGoodsVo.setSize(order.getSize());
            tGoodsVo.setKg(order.getKg());
            String size = order.getSize();
            for (TBoxSize tBoxSize : tBoxSizes) {
                if(size.equals(tBoxSize.getBoxName())){
                    tGoodsVo.setLength(tBoxSize.getBoxLength());
                    tGoodsVo.setWidth(tBoxSize.getBoxWidth());
                    tGoodsVo.setHeight(tBoxSize.getBoxHigh());
                }
            }
            tGoodsVos.add(tGoodsVo);
        }
 
        // 根据订单id 获取价格
 
//        TQuote tQuote = tQuoteMapper.selectList(new EntityWrapper<TQuote>().eq("order_id", tOrder.geteZipZ()).eq("state", 1)).get(0);
 
 
        // 根据订单id 获取价格
        List<TPrice> prices = priceMapper.selectList(new EntityWrapper<TPrice>().eq("order_id", tOrder.getId()));
 
        ArrayList<TPriceVo> priceVos = new ArrayList<TPriceVo>();
 
        for (TPrice price : prices) {
            TPriceVo tPriceVo = new TPriceVo();
            tPriceVo.setId(price.getId());
            tPriceVo.setPrice(price.getPrice());
            tPriceVo.setType(price.getType());
            priceVos.add(tPriceVo);
        }
        info.setGoodsVos(tGoodsVos);
        info.setPriceVos(priceVos);
 
        return info;
    }
}