From 187155d0e0ae19d4846372e196afb9f4a4e2652e Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 09 十月 2025 11:23:45 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java |   89 ++++++++++++++++++++++++--------------------
 1 files changed, 49 insertions(+), 40 deletions(-)

diff --git a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
index c26fdc1..d574202 100644
--- a/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
+++ b/ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/SiteController.java
@@ -26,6 +26,7 @@
 import com.ruoyi.chargingPile.service.*;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.DateUtils;
+import com.ruoyi.common.core.utils.ServletUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.PageInfo;
@@ -149,30 +150,33 @@
 					&& DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
 				siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
 				// 获取当前登录用户id
-				Long userId = tokenService.getLoginUserApplet().getUserId();
-				// 根据id查询用户信息
-				TAppUser appUser = appUserClient.getUserById(userId).getData();
-				if(Objects.nonNull(byId1.getDiscount())){
-					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
-				}else {
-					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
-				}
-				TVip vip = null;
-				if(Objects.nonNull(appUser)){
-//					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();
-					if(Objects.nonNull(data1)){
-						String vipJson = data1.getVipJson();
-						vip = JSON.parseObject(vipJson, TVip.class);
+				String token = SecurityUtils.getToken(ServletUtils.getRequest());
+				if(StringUtils.isNotEmpty(token)){
+					Long userId = tokenService.getLoginUserApplet().getUserId();
+					// 根据id查询用户信息
+					TAppUser appUser = appUserClient.getUserById(userId).getData();
+					if(Objects.nonNull(byId1.getDiscount())){
+						siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
+					}else {
+						siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
 					}
-				}
+					TVip vip = null;
+					if(Objects.nonNull(appUser)){
+//					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();
+						if(Objects.nonNull(data1)){
+							String vipJson = data1.getVipJson();
+							vip = JSON.parseObject(vipJson, TVip.class);
+						}
+					}
 
-				if(Objects.nonNull(vip) && vip.getType() == 2){
-					siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
+					if(Objects.nonNull(vip) && vip.getType() == 2){
+						siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
+					}
 				}
 			}
 		}
@@ -207,29 +211,34 @@
 					&& DateUtils.string2LocalTime(tAccountingStrategyDetail.getEndTime() + ("23:59:59".equals(tAccountingStrategyDetail.getEndTime())?"":":00")).compareTo(LocalTime.now()) > 0){
 				siteInfoVO.setElectrovalence(tAccountingStrategyDetail.getElectrovalence().add(tAccountingStrategyDetail.getServiceCharge()).setScale(4, BigDecimal.ROUND_HALF_UP));
 				// 获取当前登录用户id
-				Long userId = tokenService.getLoginUserApplet().getUserId();
-				// 根据id查询用户信息
-				TAppUser appUser = appUserClient.getUserById(userId).getData();
+				String token = SecurityUtils.getToken(ServletUtils.getRequest());
+				if(StringUtils.isNotEmpty(token)){
+					Long userId = tokenService.getLoginUserApplet().getUserId();
+					// 根据id查询用户信息
+					TAppUser appUser = appUserClient.getUserById(userId).getData();
+					if(Objects.nonNull(appUser)){
+//					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();
+						if(Objects.nonNull(data1)){
+							String vipJson = data1.getVipJson();
+							TVip vip = JSON.parseObject(vipJson, TVip.class);
+							if(Objects.nonNull(vip) && vip.getType() == 2){
+								siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
+							}
+						}
+					}
+				}
+
 				if(Objects.nonNull(byId1.getDiscount())){
 					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().multiply(byId1.getDiscount()).add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
 				}else {
 					siteInfoVO.setVipElectrovalence((tAccountingStrategyDetail.getServiceCharge().add(tAccountingStrategyDetail.getElectrovalence())).setScale(4, BigDecimal.ROUND_HALF_UP));
 				}
-				if(Objects.nonNull(appUser)){
-//					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();
-					if(Objects.nonNull(data1)){
-						String vipJson = data1.getVipJson();
-						TVip vip = JSON.parseObject(vipJson, TVip.class);
-						if(Objects.nonNull(vip) && vip.getType() == 2){
-							siteInfoVO.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(tAccountingStrategyDetail.getServiceCharge()).add(tAccountingStrategyDetail.getElectrovalence()));
-						}
-					}
-				}
+
 			}
 		}
 		List<TVip> vips = vipClient.getVipList().getData();

--
Gitblit v1.7.1