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;
|
}
|
}
|