|
|
@@ -22,6 +22,7 @@ import com.zsElectric.boot.charging.vo.ChargeResponseVO;
|
|
|
import com.zsElectric.boot.charging.vo.QueryStationStatusVO;
|
|
|
import com.zsElectric.boot.common.constant.ConnectivityConstants;
|
|
|
import com.zsElectric.boot.common.constant.SystemConstants;
|
|
|
+import com.zsElectric.boot.common.util.DateUtils;
|
|
|
import com.zsElectric.boot.common.util.electric.ChargingUtil;
|
|
|
import com.zsElectric.boot.common.util.electric.RequestParmsEntity;
|
|
|
import com.zsElectric.boot.common.util.electric.ResponseParmsEntity;
|
|
|
@@ -36,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
|
@@ -183,18 +185,12 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
- public ResponseParmsEntity chargeOrderResponse(RequestParmsEntity requestDTO) {
|
|
|
+ public ResponseParmsEntity chargeOrderResponse(RequestParmsEntity requestDTO) throws Exception {
|
|
|
log.info("接收推送充电订单信息请求参数:{}", requestDTO);
|
|
|
return processChargeRequest(requestDTO, jsonNode -> {
|
|
|
- // 充电订单信息业务处理
|
|
|
- //订单结算:平台实际收取金额 = 互联互通金额 + 中数电动金额(平台总服务费)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //账户余额扣减
|
|
|
-// chargeOrderInfoService.orderSettlement();
|
|
|
log.debug("充电订单信息 - StartChargeSeq: {}", getTextValue(jsonNode, "StartChargeSeq"));
|
|
|
});
|
|
|
}
|
|
|
@@ -214,6 +210,62 @@ public class ChargingReceptionServiceImpl implements ChargingReceptionService {
|
|
|
try {
|
|
|
JsonNode jsonNode = verifyAndDecrypt(requestDTO);
|
|
|
|
|
|
+ //查询订单
|
|
|
+ String startChargeSeq = getTextValue(jsonNode, "StartChargeSeq");
|
|
|
+ String stopReason = getTextValue(jsonNode, "StopReason");
|
|
|
+ String endTime = getTextValue(jsonNode, "EndTime");
|
|
|
+ String totalPower = getTextValue(jsonNode, "TotalPower");
|
|
|
+ String totalElecMoney = getTextValue(jsonNode, "TotalElecMoney");
|
|
|
+ String totalMoney = getTextValue(jsonNode, "TotalMoney");
|
|
|
+ String totalSeviceMoney = getTextValue(jsonNode, "TotalSeviceMoney");
|
|
|
+ String connectorID = getTextValue(jsonNode, "ConnectorID");
|
|
|
+
|
|
|
+ ChargeOrderInfo chargeOrderInfo = chargeOrderInfoService.getOne(new LambdaQueryWrapper<ChargeOrderInfo>()
|
|
|
+ .eq(ChargeOrderInfo::getStartChargeSeq, startChargeSeq).last("LIMIT 1"));
|
|
|
+
|
|
|
+ chargeOrderInfo.setStopReason(stopReason);
|
|
|
+ chargeOrderInfo.setEndTime(endTime);
|
|
|
+ chargeOrderInfo.setTotalCharge(new BigDecimal(totalPower));
|
|
|
+
|
|
|
+ chargeOrderInfo.setThirdPartyTotalCost(new BigDecimal(totalMoney));
|
|
|
+ chargeOrderInfo.setThirdPartyServerfee(new BigDecimal(totalSeviceMoney));
|
|
|
+ chargeOrderInfo.setThirdPartyElecfee(new BigDecimal(totalElecMoney));
|
|
|
+
|
|
|
+ ThirdPartyConnectorInfo thirdPartyConnectorInfo = connectorInfoMapper.selectOne(Wrappers.<ThirdPartyConnectorInfo>lambdaQuery()
|
|
|
+ .eq(ThirdPartyConnectorInfo::getConnectorId, connectorID).last("LIMIT 1"));
|
|
|
+ String stationId = thirdPartyConnectorInfo.getStationId();
|
|
|
+
|
|
|
+ //平台服务费
|
|
|
+ BigDecimal serviceFee = BigDecimal.ZERO;
|
|
|
+ JsonNode chargeDetails = jsonNode.get("ChargeDetails");
|
|
|
+ for (JsonNode node : chargeDetails) {
|
|
|
+ //提取字段值
|
|
|
+ String itemFlag = node.get("ItemFlag").asText();
|
|
|
+ double detailPower = node.get("DetailPower").asDouble();
|
|
|
+ PolicyFee policyFee = policyFeeMapper.selectOne(Wrappers.<PolicyFee>lambdaQuery()
|
|
|
+ .eq(PolicyFee::getStationInfoId, stationId)
|
|
|
+ .eq(PolicyFee::getPeriodFlag, Integer.parseInt(itemFlag))
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ BigDecimal opFee = policyFee.getOpFee();
|
|
|
+ serviceFee = serviceFee.add(opFee.multiply(new BigDecimal(detailPower))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+ chargeOrderInfo.setRealServiceCost(serviceFee);
|
|
|
+ //订单结算:平台实际收取金额 = 互联互通金额 + 中数电动金额(平台总服务费)
|
|
|
+ chargeOrderInfo.setRealCost(chargeOrderInfo.getRealServiceCost().add(chargeOrderInfo.getThirdPartyTotalCost()));
|
|
|
+
|
|
|
+ //订单状态->已完成
|
|
|
+ chargeOrderInfo.setStatus(SystemConstants.STATUS_THREE);
|
|
|
+
|
|
|
+ //计算充电时间
|
|
|
+ chargeOrderInfo.setChargeTime(DateUtils.getDuration(chargeOrderInfo.getStartTime(), chargeOrderInfo.getEndTime()));
|
|
|
+
|
|
|
+ //修改订单
|
|
|
+ chargeOrderInfoService.updateById(chargeOrderInfo);
|
|
|
+
|
|
|
+ //账户余额扣减(积分增加)
|
|
|
+ chargeOrderInfoService.orderSettlement(chargeOrderInfo.getId());
|
|
|
+
|
|
|
// 执行业务处理
|
|
|
businessHandler.accept(jsonNode);
|
|
|
|