From 858d8b41a967c6267760aca0ae4bbfccc3b81654 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期六, 02 十一月 2024 20:32:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java |   85 ++++++++++++++++++++++++------------------
 1 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
index 3a4d301..72a8e3e 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/SiteServiceImpl.java
@@ -9,10 +9,7 @@
 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;
-import com.ruoyi.chargingPile.api.model.TChargingPile;
-import com.ruoyi.chargingPile.api.model.TParkingLot;
+import com.ruoyi.chargingPile.api.model.*;
 import com.ruoyi.chargingPile.api.query.GetSiteList;
 import com.ruoyi.chargingPile.api.query.SiteDetailQuery;
 import com.ruoyi.chargingPile.api.query.SiteQuery;
@@ -87,6 +84,9 @@
 	private IntegrationClient integrationClient;
 	@Resource
 	private AppUserVipDetailClient vipDetailClient;
+	
+	@Resource
+	private TAccountingStrategyDetailService accountingStrategyDetailService;
 	
 	
 	/**
@@ -293,29 +293,32 @@
 	public PageInfo<SiteVO> pageList(SiteQuery query,Integer isLogin) {
 		TAppUser appUser = null;
 		// 获取当前登录用户id
-		Long userId = tokenService.getLoginUserApplet().getUserId();
+		TAppUserVipDetail data1 = null;
 		if(isLogin == 1){
+			Long userId = tokenService.getLoginUserApplet().getUserId();
 			// 根据id查询用户信息
 			appUser = appUserClient.getUserById(userId).getData();
+			GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail();
+			getAppUserVipDetail.setAppUserId(userId);
+			getAppUserVipDetail.setVipId(appUser.getVipId());
+			R<TAppUserVipDetail> appUserVipDetail = vipDetailClient.getAppUserVipDetail(getAppUserVipDetail);
+			data1 = appUserVipDetail.getData();
 		}
 		PageInfo<SiteVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
 		List<SiteVO> list = this.baseMapper.pageList(query,pageInfo);
 		if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
 			// 查询会员信息
 //			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 -> {
-					if(Objects.nonNull(vip.getDiscount())){
-						item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
-					}
-				});
+			if(Objects.nonNull(data1)){
+				String vipJson = data1.getVipJson();
+				TVip vip = JSON.parseObject(vipJson, TVip.class);
+				if(Objects.nonNull(vip) && vip.getType() == 2){
+					list.forEach(item -> {
+						if(Objects.nonNull(vip.getDiscount())){
+							item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal()));
+						}
+					});
+				}
 			}
 		}
 		pageInfo.setRecords(list);
@@ -386,31 +389,36 @@
 	}
 
 	@Override
-	public List<SiteVO> getMapSiteList(SiteQuery query) {
+	public List<SiteVO> getMapSiteList(SiteQuery query,Integer isLogin) {
 
 		if(StringUtils.isEmpty(query.getLon()) || StringUtils.isEmpty(query.getLat())){
 			return new ArrayList<>();
 		}
-
+		TAppUser appUser = null;
 		// 获取当前登录用户id
-		Long userId = tokenService.getLoginUserApplet().getUserId();
-		// 根据id查询用户信息
-		TAppUser appUser = appUserClient.getUserById(userId).getData();
-		List<SiteVO> list = this.baseMapper.getMapSiteList(query);
-		if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
-			// 查询会员信息
-//			TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+		TAppUserVipDetail data1 = null;
+		if(isLogin == 1){
+			Long userId = tokenService.getLoginUserApplet().getUserId();
+			// 根据id查询用户信息
+			appUser = appUserClient.getUserById(userId).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()));
-				});
+			data1 = appUserVipDetail.getData();
+		}
+		List<SiteVO> list = this.baseMapper.getMapSiteList(query);
+		if(Objects.nonNull(appUser) && Objects.nonNull(appUser.getVipId())){
+			// 查询会员信息
+//			TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
+			if(Objects.nonNull(data1)){
+				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()));
+					});
+				}
 			}
 		}
 		return list;
@@ -430,14 +438,17 @@
 		this.updateById(site);
 		List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getSiteId, id).eq(TChargingGun::getDelFlag, 0));
 		for (TChargingGun tChargingGun : list) {
-			tChargingGun.setAccountingStrategyId(accountingStrategyId);
+			TChargingGun tChargingGun1 = new TChargingGun();
+			tChargingGun1.setId(tChargingGun.getId());
+			tChargingGun1.setAccountingStrategyId(accountingStrategyId);
+			chargingGunService.updateById(tChargingGun1);
 		}
-		chargingGunService.updateBatchById(list);
 		
 		//下发硬件数据
+		List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailService.list(new LambdaQueryWrapper<TAccountingStrategyDetail>().eq(TAccountingStrategyDetail::getAccountingStrategyId, accountingStrategyId));
 		List<TChargingPile> list1 = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0).list();
 		for (TChargingPile tChargingPile : list1) {
-			integrationClient.setupBillingModel1(tChargingPile.getCode());
+			integrationClient.setupBillingModel1(tChargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails));
 		}
 	}
 }

--
Gitblit v1.7.1