|  |  |  | 
|---|
|  |  |  | package com.ruoyi.order.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.ruoyi.order.api.model.TOrderAppeal; | 
|---|
|  |  |  | import com.ruoyi.order.mapper.TOrderAppealMapper; | 
|---|
|  |  |  | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; | 
|---|
|  |  |  | import com.ruoyi.chargingPile.api.model.Site; | 
|---|
|  |  |  | import com.ruoyi.chargingPile.api.model.TChargingPile; | 
|---|
|  |  |  | import com.ruoyi.chargingPile.api.vo.SiteNameVO; | 
|---|
|  |  |  | import com.ruoyi.common.core.web.page.PageInfo; | 
|---|
|  |  |  | import com.ruoyi.order.api.model.*; | 
|---|
|  |  |  | import com.ruoyi.order.api.query.TOrderAppealQuery; | 
|---|
|  |  |  | import com.ruoyi.order.api.vo.TOrderAppealVO; | 
|---|
|  |  |  | import com.ruoyi.order.mapper.*; | 
|---|
|  |  |  | import com.ruoyi.order.service.TChargingOrderService; | 
|---|
|  |  |  | import com.ruoyi.order.service.TOrderAppealService; | 
|---|
|  |  |  | import com.ruoyi.other.api.domain.TGoods; | 
|---|
|  |  |  | import com.ruoyi.other.api.feignClient.GoodsClient; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class TOrderAppealServiceImpl extends ServiceImpl<TOrderAppealMapper, TOrderAppeal> implements TOrderAppealService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TChargingOrderMapper chargingOrderMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private TShoppingOrderMapper shoppingOrderMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private GoodsClient goodsClient; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ChargingGunClient chargingGunClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageInfo<TOrderAppealVO> pageList(TOrderAppealQuery query) { | 
|---|
|  |  |  | PageInfo<TOrderAppealVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); | 
|---|
|  |  |  | List<TOrderAppealVO> list = this.baseMapper.pageList(query,pageInfo); | 
|---|
|  |  |  | List<Long> orderIds = list.stream().map(TOrderAppealVO::getOrderId).collect(Collectors.toList()); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(orderIds)){ | 
|---|
|  |  |  | return new PageInfo<>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 查询当前页的订单 | 
|---|
|  |  |  | List<TChargingOrder> chargingOrders = chargingOrderMapper.selectList(Wrappers.lambdaQuery(TChargingOrder.class) | 
|---|
|  |  |  | .in(TChargingOrder::getId, orderIds)); | 
|---|
|  |  |  | List<TShoppingOrder> shoppingOrders = shoppingOrderMapper.selectList(Wrappers.lambdaQuery(TShoppingOrder.class) | 
|---|
|  |  |  | .in(TShoppingOrder::getId, orderIds)); | 
|---|
|  |  |  | list.forEach(item -> { | 
|---|
|  |  |  | if (item.getOrderType() == 1) { | 
|---|
|  |  |  | TChargingOrder tChargingOrder = chargingOrders.stream().filter(chargingOrder -> chargingOrder.getId().equals(item.getOrderId())).findFirst().orElse(null); | 
|---|
|  |  |  | if(Objects.nonNull(tChargingOrder)){ | 
|---|
|  |  |  | item.setChargingOrder(tChargingOrder); | 
|---|
|  |  |  | SiteNameVO siteNameVO = chargingGunClient.getAllInfoById(tChargingOrder.getChargingGunId()).getData(); | 
|---|
|  |  |  | if(Objects.nonNull(siteNameVO)){ | 
|---|
|  |  |  | item.setGunName(siteNameVO.getGunName()); | 
|---|
|  |  |  | item.setGunNumber(siteNameVO.getGunNumber()); | 
|---|
|  |  |  | item.setPileName(siteNameVO.getPileName()); | 
|---|
|  |  |  | item.setPileNumber(siteNameVO.getPileNumber()); | 
|---|
|  |  |  | item.setSiteName(siteNameVO.getSiteName()); | 
|---|
|  |  |  | item.setEndMode(tChargingOrder.getEndMode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (item.getOrderType() == 2) { | 
|---|
|  |  |  | TShoppingOrder tShoppingOrder = shoppingOrders.stream().filter(shoppingOrder -> shoppingOrder.getId().equals(item.getOrderId())).findFirst().orElse(null); | 
|---|
|  |  |  | setGoodsInfo(item,tShoppingOrder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | item.setOrderIdStr(item.getOrderId().toString()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | list.forEach(e->e.setUid(e.getId().toString())); | 
|---|
|  |  |  | pageInfo.setRecords(list); | 
|---|
|  |  |  | return pageInfo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public TOrderAppealVO getDetailById(String id) { | 
|---|
|  |  |  | TOrderAppeal orderAppeal = this.baseMapper.selectById(id); | 
|---|
|  |  |  | TOrderAppealVO orderAppealVO = new TOrderAppealVO(); | 
|---|
|  |  |  | BeanUtils.copyProperties(orderAppeal,orderAppealVO); | 
|---|
|  |  |  | // 查询申诉详情 | 
|---|
|  |  |  | if (orderAppeal.getOrderType() == 1) { | 
|---|
|  |  |  | TChargingOrder tChargingOrder = chargingOrderMapper.selectById(orderAppeal.getOrderId()); | 
|---|
|  |  |  | orderAppealVO.setChargingOrder(tChargingOrder); | 
|---|
|  |  |  | if(Objects.nonNull(tChargingOrder)){ | 
|---|
|  |  |  | orderAppealVO.setEndMode(tChargingOrder.getEndMode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (orderAppeal.getOrderType() == 2) { | 
|---|
|  |  |  | TShoppingOrder tShoppingOrder = shoppingOrderMapper.selectById(orderAppeal.getOrderId()); | 
|---|
|  |  |  | setGoodsInfo(orderAppealVO,tShoppingOrder); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderAppealVO.setOrderIdStr(orderAppealVO.getOrderId().toString()); | 
|---|
|  |  |  | return orderAppealVO; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void setGoodsInfo(TOrderAppealVO orderAppealVO,TShoppingOrder tShoppingOrder){ | 
|---|
|  |  |  | if(Objects.nonNull(tShoppingOrder)){ | 
|---|
|  |  |  | orderAppealVO.setShoppingOrder(tShoppingOrder); | 
|---|
|  |  |  | TGoods goods = goodsClient.getGoodsById(tShoppingOrder.getGoodsId()).getData(); | 
|---|
|  |  |  | if(Objects.nonNull(goods)){ | 
|---|
|  |  |  | orderAppealVO.setGoodsName(goods.getName()); | 
|---|
|  |  |  | orderAppealVO.setGoodsPicture(goods.getCoverPicture()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|