|
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zsElectric.boot.business.mapper.BannerInfoMapper;
|
|
|
+import com.zsElectric.boot.business.mapper.PolicyFeeMapper;
|
|
|
import com.zsElectric.boot.business.mapper.ThirdPartyStationInfoMapper;
|
|
|
import com.zsElectric.boot.business.mapper.UserFirmMapper;
|
|
|
import com.zsElectric.boot.charging.entity.ThirdPartyConnectorInfo;
|
|
|
@@ -16,6 +17,7 @@ import com.zsElectric.boot.business.mapper.ThirdPartyEquipmentInfoMapper;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyEquipmentPricePolicyMapper;
|
|
|
import com.zsElectric.boot.charging.mapper.ThirdPartyPolicyInfoMapper;
|
|
|
import com.zsElectric.boot.business.model.entity.BannerInfo;
|
|
|
+import com.zsElectric.boot.business.model.entity.PolicyFee;
|
|
|
import com.zsElectric.boot.business.model.entity.UserFirm;
|
|
|
import com.zsElectric.boot.business.model.query.StationInfoQuery;
|
|
|
import com.zsElectric.boot.business.model.vo.AppletConnectorListVO;
|
|
|
@@ -35,6 +37,7 @@ import java.math.BigDecimal;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -52,6 +55,7 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
private final ThirdPartyEquipmentInfoMapper thirdPartyEquipmentInfoMapper;
|
|
|
private final ThirdPartyEquipmentPricePolicyMapper thirdPartyEquipmentPricePolicyMapper;
|
|
|
private final ThirdPartyPolicyInfoMapper thirdPartyPolicyInfoMapper;
|
|
|
+ private final PolicyFeeMapper policyFeeMapper;
|
|
|
|
|
|
/**
|
|
|
* 时间格式化器 HHmmss
|
|
|
@@ -378,6 +382,22 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
result.setStationName(stationInfo.getStationName());
|
|
|
result.setTips(stationInfo.getStationTips());
|
|
|
|
|
|
+ // 获取当前登录用户ID
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+
|
|
|
+ // 查询用户是否为企业用户,获取企业ID
|
|
|
+ Long firmId = null;
|
|
|
+ if (userId != null) {
|
|
|
+ UserFirm userFirm = userFirmMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<UserFirm>()
|
|
|
+ .eq(UserFirm::getUserId, userId)
|
|
|
+ .last("LIMIT 1")
|
|
|
+ );
|
|
|
+ if (userFirm != null) {
|
|
|
+ firmId = userFirm.getFirmId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 获取当前时间(HHmmss格式)
|
|
|
String currentTime = LocalTime.now().format(TIME_FORMATTER);
|
|
|
|
|
|
@@ -415,7 +435,48 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
.orderByAsc(ThirdPartyPolicyInfo::getStartTime)
|
|
|
);
|
|
|
|
|
|
- // 4. 构建价格列表
|
|
|
+ // 4. 如果是企业用户,查询企业价格
|
|
|
+ Map<String, BigDecimal> enterprisePriceMap = new HashMap<>();
|
|
|
+ boolean hasEnterprisePrice = false;
|
|
|
+ if (firmId != null) {
|
|
|
+ List<PolicyFee> policyFeeList = policyFeeMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<PolicyFee>()
|
|
|
+ .eq(PolicyFee::getStationInfoId, stationId)
|
|
|
+ .eq(PolicyFee::getSalesType, 1) // 1-企业
|
|
|
+ .eq(PolicyFee::getFirmId, firmId)
|
|
|
+ .eq(PolicyFee::getIsDeleted, 0)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 如果查询到企业价格记录,设置标志为true
|
|
|
+ if (!policyFeeList.isEmpty()) {
|
|
|
+ hasEnterprisePrice = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建企业价格映射 (startTime -> enterprisePrice)
|
|
|
+ for (PolicyFee policyFee : policyFeeList) {
|
|
|
+ // 查找对应的时段价格信息
|
|
|
+ ThirdPartyPolicyInfo matchedPolicyInfo = policyInfoList.stream()
|
|
|
+ .filter(info -> info.getStartTime().equals(policyFee.getStartTime()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+
|
|
|
+ if (matchedPolicyInfo != null) {
|
|
|
+ // 企业价格 = 电费 + 服务费 + 运营费 + 综合销售费
|
|
|
+ BigDecimal elecPrice = matchedPolicyInfo.getElecPrice() != null ? matchedPolicyInfo.getElecPrice() : BigDecimal.ZERO;
|
|
|
+ BigDecimal servicePrice = matchedPolicyInfo.getServicePrice() != null ? matchedPolicyInfo.getServicePrice() : BigDecimal.ZERO;
|
|
|
+ BigDecimal opFee = policyFee.getOpFee() != null ? policyFee.getOpFee() : BigDecimal.ZERO;
|
|
|
+ BigDecimal compSalesFee = policyFee.getCompSalesFee() != null ? policyFee.getCompSalesFee() : BigDecimal.ZERO;
|
|
|
+
|
|
|
+ BigDecimal enterprisePrice = elecPrice.add(servicePrice).add(opFee).add(compSalesFee);
|
|
|
+ enterprisePriceMap.put(policyFee.getStartTime(), enterprisePrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置是否有企业价格
|
|
|
+ result.setHasEnterprisePrice(hasEnterprisePrice);
|
|
|
+
|
|
|
+ // 5. 构建价格列表
|
|
|
List<AppletStationPriceListVO.PriceItemVO> priceList = new ArrayList<>();
|
|
|
for (int i = 0; i < policyInfoList.size(); i++) {
|
|
|
ThirdPartyPolicyInfo policyInfo = policyInfoList.get(i);
|
|
|
@@ -439,6 +500,10 @@ public class AppletHomeServiceImpl implements AppletHomeService {
|
|
|
BigDecimal servicePrice = policyInfo.getServicePrice() != null ? policyInfo.getServicePrice() : BigDecimal.ZERO;
|
|
|
priceItem.setTotalPrice(elecPrice.add(servicePrice));
|
|
|
|
|
|
+ // 设置企业价格(如果有)
|
|
|
+ BigDecimal enterprisePrice = enterprisePriceMap.get(policyInfo.getStartTime());
|
|
|
+ priceItem.setEnterprisePrice(enterprisePrice);
|
|
|
+
|
|
|
// 判断是否为当前时段
|
|
|
priceItem.setCurrentPeriod(isCurrentPeriod(policyInfo.getStartTime(),
|
|
|
(i + 1 < policyInfoList.size()) ? policyInfoList.get(i + 1).getStartTime() : null,
|