|
@@ -2,28 +2,18 @@ package com.zsElectric.boot.business.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.zsElectric.boot.business.mapper.PolicyFeeMapper;
|
|
import com.zsElectric.boot.business.mapper.PolicyFeeMapper;
|
|
|
-import com.zsElectric.boot.business.mapper.ThirdPartyEquipmentInfoMapper;
|
|
|
|
|
import com.zsElectric.boot.business.mapper.ThirdPartyStationInfoMapper;
|
|
import com.zsElectric.boot.business.mapper.ThirdPartyStationInfoMapper;
|
|
|
import com.zsElectric.boot.business.model.dto.AddPolicyFeeDTO;
|
|
import com.zsElectric.boot.business.model.dto.AddPolicyFeeDTO;
|
|
|
import com.zsElectric.boot.business.model.entity.PolicyFee;
|
|
import com.zsElectric.boot.business.model.entity.PolicyFee;
|
|
|
import com.zsElectric.boot.business.model.vo.TimePeriodPriceVO;
|
|
import com.zsElectric.boot.business.model.vo.TimePeriodPriceVO;
|
|
|
import com.zsElectric.boot.business.service.PolicyFeeService;
|
|
import com.zsElectric.boot.business.service.PolicyFeeService;
|
|
|
-import com.zsElectric.boot.charging.entity.*;
|
|
|
|
|
-import com.zsElectric.boot.charging.mapper.ThirdPartyConnectorInfoMapper;
|
|
|
|
|
-import com.zsElectric.boot.charging.mapper.ThirdPartyEquipmentPricePolicyMapper;
|
|
|
|
|
-import com.zsElectric.boot.charging.mapper.ThirdPartyPolicyInfoMapper;
|
|
|
|
|
-import com.zsElectric.boot.system.model.entity.DictItem;
|
|
|
|
|
-import com.zsElectric.boot.system.service.DictItemService;
|
|
|
|
|
|
|
+import com.zsElectric.boot.charging.entity.ThirdPartyStationInfo;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 策略费用服务实现
|
|
* 策略费用服务实现
|
|
@@ -36,106 +26,12 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class PolicyFeeServiceImpl implements PolicyFeeService {
|
|
public class PolicyFeeServiceImpl implements PolicyFeeService {
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 时段标志映射:1-尖, 2-峰, 3-平, 4-谷(固定常量,避免重复创建)
|
|
|
|
|
- */
|
|
|
|
|
- private static final Map<Integer, String> PERIOD_FLAG_LABEL_MAP = Map.of(
|
|
|
|
|
- 1, "尖",
|
|
|
|
|
- 2, "峰",
|
|
|
|
|
- 3, "平",
|
|
|
|
|
- 4, "谷"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
private final PolicyFeeMapper policyFeeMapper;
|
|
private final PolicyFeeMapper policyFeeMapper;
|
|
|
-
|
|
|
|
|
- private final ThirdPartyPolicyInfoMapper thirdPartyPolicyInfoMapper;
|
|
|
|
|
-
|
|
|
|
|
- private final ThirdPartyEquipmentPricePolicyMapper thirdPartyEquipmentPricePolicyMapper;
|
|
|
|
|
-
|
|
|
|
|
- private final DictItemService dictItemService;
|
|
|
|
|
-
|
|
|
|
|
private final ThirdPartyStationInfoMapper stationInfoMapper;
|
|
private final ThirdPartyStationInfoMapper stationInfoMapper;
|
|
|
|
|
|
|
|
- private final ThirdPartyConnectorInfoMapper thirdPartyConnectorInfoMapper;
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, Long firmId, Long thirdPartyId) {
|
|
public List<TimePeriodPriceVO> getPolicyFee(long stationId, int salesType, Long firmId, Long thirdPartyId) {
|
|
|
- List<TimePeriodPriceVO> timePeriodPriceVOS = new ArrayList<>();
|
|
|
|
|
-
|
|
|
|
|
- // 查询价格策略
|
|
|
|
|
- ThirdPartyEquipmentPricePolicy pricePolicy = thirdPartyEquipmentPricePolicyMapper.selectOne(Wrappers.<ThirdPartyEquipmentPricePolicy>lambdaQuery()
|
|
|
|
|
- .eq(ThirdPartyEquipmentPricePolicy::getConnectorId, thirdPartyConnectorInfoMapper.selectOne(Wrappers.<ThirdPartyConnectorInfo>lambdaQuery()
|
|
|
|
|
- .eq(ThirdPartyConnectorInfo::getStationId,stationInfoMapper.selectById(stationId).getStationId()).last("limit 1")).getConnectorId())
|
|
|
|
|
- .eq(ThirdPartyEquipmentPricePolicy::getIsDeleted, 0)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- if (pricePolicy == null) {
|
|
|
|
|
- return timePeriodPriceVOS;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 互联互通成本价
|
|
|
|
|
- List<ThirdPartyPolicyInfo> thirdPartyPolicyInfos = thirdPartyPolicyInfoMapper.selectList(Wrappers.<ThirdPartyPolicyInfo>lambdaQuery()
|
|
|
|
|
- .eq(ThirdPartyPolicyInfo::getPricePolicyId, pricePolicy.getId())
|
|
|
|
|
- .eq(ThirdPartyPolicyInfo::getIsDeleted, 0));
|
|
|
|
|
-
|
|
|
|
|
- // 运营费(按时段配置)
|
|
|
|
|
- Map<String, PolicyFee> policyFeeMap = policyFeeMapper.selectList(Wrappers.<PolicyFee>lambdaQuery()
|
|
|
|
|
- .eq(PolicyFee::getStationInfoId, stationId)
|
|
|
|
|
- .eq(PolicyFee::getIsDeleted, 0)
|
|
|
|
|
- .eq(PolicyFee::getSalesType, salesType)
|
|
|
|
|
- .eq(salesType == 1, PolicyFee::getFirmId, firmId)
|
|
|
|
|
- .eq(salesType == 2, PolicyFee::getThirdPartyId, thirdPartyId))
|
|
|
|
|
- .stream()
|
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
|
- PolicyFee::getStartTime,
|
|
|
|
|
- policyFee -> policyFee,
|
|
|
|
|
- (v1, v2) -> v1
|
|
|
|
|
- ));
|
|
|
|
|
-
|
|
|
|
|
- // 查询时段标志字典,获取增值服务费价格(label对应中文,value对应价格)
|
|
|
|
|
- Map<String, BigDecimal> labelPriceMap = dictItemService.list(
|
|
|
|
|
- Wrappers.<DictItem>lambdaQuery()
|
|
|
|
|
- .eq(DictItem::getDictCode, "time_period_flag")
|
|
|
|
|
- .eq(DictItem::getStatus, 1)
|
|
|
|
|
- ).stream()
|
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
|
- DictItem::getLabel,
|
|
|
|
|
- item -> new BigDecimal(item.getValue()),
|
|
|
|
|
- (v1, v2) -> v1
|
|
|
|
|
- ));
|
|
|
|
|
-
|
|
|
|
|
- // 计算综合价格
|
|
|
|
|
- for (ThirdPartyPolicyInfo policyInfo : thirdPartyPolicyInfos) {
|
|
|
|
|
- // 获取增值服务费
|
|
|
|
|
- BigDecimal valueAddedFees = labelPriceMap.getOrDefault(
|
|
|
|
|
- PERIOD_FLAG_LABEL_MAP.get(policyInfo.getPeriodFlag()),
|
|
|
|
|
- BigDecimal.ZERO
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // 根据时段获取对应的运营费配置
|
|
|
|
|
- PolicyFee policyFee = policyFeeMap.get(policyInfo.getStartTime());
|
|
|
|
|
-
|
|
|
|
|
- TimePeriodPriceVO timePeriodPriceVO = new TimePeriodPriceVO();
|
|
|
|
|
- timePeriodPriceVO.setTimePeriod(policyInfo.getStartTime())
|
|
|
|
|
- .setPeriodFlag(policyInfo.getPeriodFlag())
|
|
|
|
|
- .setElectricityPrice(policyInfo.getElecPrice())
|
|
|
|
|
- .setSettlementServiceFee(policyInfo.getServicePrice())
|
|
|
|
|
- .setSettlementTotalPrice(policyInfo.getElecPrice().add(policyInfo.getServicePrice()))
|
|
|
|
|
- .setOperationServiceFee(BigDecimal.ZERO)
|
|
|
|
|
- .setSaleTotalPrice(BigDecimal.ZERO)
|
|
|
|
|
- .setValueAddedFees(valueAddedFees);
|
|
|
|
|
-
|
|
|
|
|
- // 只有配置了该时段的运营费才计算销售价并返回
|
|
|
|
|
- if (policyFee != null) {
|
|
|
|
|
- timePeriodPriceVO.setOperationServiceFee(policyFee.getOpFee())
|
|
|
|
|
- .setSaleTotalPrice(policyInfo.getElecPrice()
|
|
|
|
|
- .add(policyInfo.getServicePrice())
|
|
|
|
|
- .add(policyFee.getOpFee())
|
|
|
|
|
- .add(valueAddedFees));
|
|
|
|
|
- }
|
|
|
|
|
- timePeriodPriceVOS.add(timePeriodPriceVO);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return timePeriodPriceVOS;
|
|
|
|
|
|
|
+ return policyFeeMapper.selectTimePeriodPriceList(stationId, salesType, firmId, thirdPartyId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -161,8 +57,12 @@ public class PolicyFeeServiceImpl implements PolicyFeeService {
|
|
|
policyFee.setStartTime(addPolicyFeeDTO.getTimePeriod());
|
|
policyFee.setStartTime(addPolicyFeeDTO.getTimePeriod());
|
|
|
policyFee.setOpFee(addPolicyFeeDTO.getOperationServiceFee());
|
|
policyFee.setOpFee(addPolicyFeeDTO.getOperationServiceFee());
|
|
|
policyFee.setSalesType(addPolicyFeeDTO.getSalesType());
|
|
policyFee.setSalesType(addPolicyFeeDTO.getSalesType());
|
|
|
- policyFee.setFirmId(addPolicyFeeDTO.getFirmId());
|
|
|
|
|
- policyFee.setThirdPartyId(addPolicyFeeDTO.getThirdPartyId());
|
|
|
|
|
|
|
+ // 根据销售类型设置对应的ID
|
|
|
|
|
+ if (addPolicyFeeDTO.getSalesType() == 1) {
|
|
|
|
|
+ policyFee.setFirmId(addPolicyFeeDTO.getFirmId());
|
|
|
|
|
+ } else if (addPolicyFeeDTO.getSalesType() == 2) {
|
|
|
|
|
+ policyFee.setThirdPartyId(addPolicyFeeDTO.getThirdPartyId());
|
|
|
|
|
+ }
|
|
|
boolean inserted = policyFeeMapper.insert(policyFee) > 0;
|
|
boolean inserted = policyFeeMapper.insert(policyFee) > 0;
|
|
|
|
|
|
|
|
// 新增成功后,更新站点的配置状态为已配置
|
|
// 新增成功后,更新站点的配置状态为已配置
|