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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** *

* 服务实现类 *

* * @author stylefeng * @since 2023-01-09 */ @Service public class TUserServiceImpl extends ServiceImpl 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 getList(Page tUserVoPage, String name, Integer id,int companyId) { List list = this.baseMapper.getListCompany(tUserVoPage, name, id, companyId); for (TUserVo tUserVo : list) { List addresses = userAddressMapper.selectList(new EntityWrapper().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 getChildUser(Page tUserChildPage,Integer tUserId) { return this.baseMapper.getChildUser(tUserChildPage,tUserId); } @Override public List getCheckList(Page tUserVoPage, String name, Integer state) { return this.baseMapper.getCheckList(tUserVoPage,name,state); } @Override public List groupList(Page groupVoPage, String name) { return this.baseMapper.groupList(groupVoPage,name); } @Override public List getInvoices(Page 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 orders = tGoodsMapper.selectList(new EntityWrapper().eq("order_id", id)); ArrayList tGoodsVos = new ArrayList<>(); TCompany tCompany = tCompanyMapper.selectById(info.getCompanyId()); List 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())){ } } tGoodsVos.add(tGoodsVo); } // 根据订单id 获取价格 // TQuote tQuote = tQuoteMapper.selectList(new EntityWrapper().eq("order_id", tOrder.geteZipZ()).eq("state", 1)).get(0); // 根据订单id 获取价格 List prices = priceMapper.selectList(new EntityWrapper().eq("order_id", tOrder.getId())); ArrayList priceVos = new ArrayList(); 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; } }