xuhy
2024-10-31 3a874d41d591fa2d987f7109cf503af355ea7aad
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -1,9 +1,13 @@
package com.ruoyi.chargingPile.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.feignClient.AppUserVipDetailClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.model.TChargingGun;
@@ -18,6 +22,7 @@
import com.ruoyi.chargingPile.domain.SiteMenu;
import com.ruoyi.chargingPile.mapper.SiteMapper;
import com.ruoyi.chargingPile.service.*;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.ServletUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
@@ -80,7 +85,8 @@
   
   @Resource
   private IntegrationClient integrationClient;
   @Resource
   private AppUserVipDetailClient vipDetailClient;
   
   
   /**
@@ -280,9 +286,9 @@
   @Override
   public PageInfo<SiteVO> pageList(SiteQuery query,Integer isLogin) {
      TAppUser appUser = null;
      // 获取当前登录用户id
      Long userId = tokenService.getLoginUserApplet().getUserId();
      if(isLogin == 1){
         // 获取当前登录用户id
         Long userId = tokenService.getLoginUserApplet().getUserId();
         // 根据id查询用户信息
         appUser = appUserClient.getUserById(userId).getData();
      }
@@ -290,10 +296,19 @@
      List<SiteVO> list = this.baseMapper.pageList(query,pageInfo);
      if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
         // 查询会员信息
         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
         getAppUserVipDetail.setAppUserId(userId);
         getAppUserVipDetail.setVipId(appUser.getVipId());
         R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
         TAppUserVipDetail data1 = appUserVipDetail.getData();
         String vipJson = data1.getVipJson();
         TVip vip = JSON.parseObject(vipJson, TVip.class);
         if(Objects.nonNull(vip) && vip.getType() == 2){
            list.forEach(item -> {
               item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
               if(Objects.nonNull(vip.getDiscount())){
                  item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
               }
            });
         }
      }
@@ -328,9 +343,15 @@
      }
      // 查询所有的停车场的站点id
      List<TParkingLot> list = parkingLotService.list();
      List<Integer> siteIds = list.stream().map(TParkingLot::getSiteId).collect(Collectors.toList());
      List<Integer> siteIds = list.stream().map(TParkingLot::getSiteId).distinct().collect(Collectors.toList());
      if(!CollectionUtils.isEmpty(ids) && !CollectionUtils.isEmpty(siteIds)){
         ids.addAll(siteIds);
         Iterator<Integer> iterator = ids.iterator();
         while (iterator.hasNext()){
            Integer next = iterator.next();
            if(siteIds.contains(next)){
               iterator.remove();
            }
         }
      }
      return this.baseMapper.getSiteListParkLot(ids);
   }
@@ -372,7 +393,14 @@
      List<SiteVO> list = this.baseMapper.getMapSiteList(query);
      if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
         // 查询会员信息
         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
//         TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
         GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
         getAppUserVipDetail.setAppUserId(userId);
         getAppUserVipDetail.setVipId(appUser.getVipId());
         R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
         TAppUserVipDetail data1 = appUserVipDetail.getData();
         String vipJson = data1.getVipJson();
         TVip vip = JSON.parseObject(vipJson, TVip.class);
         if(Objects.nonNull(vip) && vip.getType() == 2){
            list.forEach(item -> {
               item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
@@ -394,7 +422,7 @@
      Site site = this.getById(id);
      site.setAccountingStrategyId(accountingStrategyId);
      this.updateById(site);
      List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, id).eq(TChargingGun::getDelFlag, 0));
      List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, id).eq(TChargingGun::getDelFlag, 0));
      for (TChargingGun tChargingGun : list) {
         tChargingGun.setAccountingStrategyId(accountingStrategyId);
      }