|
|
|
@ -484,8 +484,10 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进行反向订单的平台对账
|
|
|
|
|
*
|
|
|
|
|
* @param orderDO 订单信息
|
|
|
|
|
* @param notifyChargeOrderInfoBO 互联互通账单数据
|
|
|
|
|
* @return
|
|
|
|
@ -502,11 +504,18 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前配置的互联互通的容许单价误差金额、总金额误差金额
|
|
|
|
|
// select * from t_dict where code = #{code} and parent_id != 0
|
|
|
|
|
/**
|
|
|
|
|
29 28 reverseOrderCheck -1 账单单价与站点计费不一致 1 键值 ≥0表示开启,并按该值(元)判断冗余值,-1表示关闭 0 0
|
|
|
|
|
30 28 reverseOrderCheck 1 账单总金额与站点计费*充电量不一致 2 键值 断冗余值,-≥0表示开启,并按该值(元)判1表示关闭 0 0
|
|
|
|
|
*/
|
|
|
|
|
List<DictDO> dictDOList = commonMapper.getDictByCode("reverseOrderCheck");
|
|
|
|
|
BigDecimal unitPrice = BigDecimal.valueOf(-1);
|
|
|
|
|
BigDecimal totalPrice = BigDecimal.valueOf(-1);
|
|
|
|
|
if (dictDOList.size() >= 2) {
|
|
|
|
|
//单价差额上限
|
|
|
|
|
unitPrice = new BigDecimal(Optional.ofNullable(dictDOList.get(0).getDictKey()).orElse("0.0"));
|
|
|
|
|
//总价差额上限
|
|
|
|
|
totalPrice = new BigDecimal(Optional.ofNullable(dictDOList.get(1).getDictKey()).orElse("0.0"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -516,11 +525,27 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询该充电桩的计费规则
|
|
|
|
|
List<PriceRule> lpr = commonMapper.selectPriceRule(orderDO.getEquipmentId());
|
|
|
|
|
/**
|
|
|
|
|
select
|
|
|
|
|
ter.charge_settle_type chargeSettleType, //电费结算类型 1 全时段电费 2 分时段电费
|
|
|
|
|
tept.end_time endTime,
|
|
|
|
|
tept.elecfee elecfee, //电费
|
|
|
|
|
tept.servicefee servicefee, //服务费
|
|
|
|
|
tept.cost,
|
|
|
|
|
tept.start_time startTime,
|
|
|
|
|
tept.time_flag as timeFlag
|
|
|
|
|
from
|
|
|
|
|
t_equipment_pricing_rule ter left join t_equipment_pricing_rule_time tept on ter.id = tept.equipment_pricing_rule_id
|
|
|
|
|
where
|
|
|
|
|
ter.equipment_id=#{equipmentId} //哪个设备,也就是哪个电桩
|
|
|
|
|
order by tept.end_time asc
|
|
|
|
|
*/
|
|
|
|
|
List<PriceRule> lpr = commonMapper.selectPriceRule(orderDO.getEquipmentId());//以电桩ID为条件进行查询,获取此电桩的在不同时段的电费和服务费
|
|
|
|
|
//若是计费规则为空,则置为挂起状态,然后
|
|
|
|
|
// 电桩没有计费规则是个什么情况?
|
|
|
|
|
if (null == lpr || lpr.size() == 0) {
|
|
|
|
|
orderDO.setState((byte) 5);
|
|
|
|
|
orderDO.setExceptionFlag((byte) 4);
|
|
|
|
|
orderDO.setState((byte) 5);//订单状态 0 创建中 1准备充电中 2 充电中 3完成 4 取消 5挂起 6需要手动补单 7结算中
|
|
|
|
|
orderDO.setExceptionFlag((byte) 4); //订单异常标志 0正常 1电量负数 2 vin相同,在一个有交集的时间段内出现的订单异常 3电量异常修正后订单
|
|
|
|
|
orderDO.setExceptionMsg("账单单价与站点计费不一致");
|
|
|
|
|
orderDO.setCancelMsg("账单单价与站点计费不一致");
|
|
|
|
|
orderDO.setCancelTime(new Date());
|
|
|
|
@ -534,11 +559,14 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
BigDecimal unitDiffPrice = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal totalDiffPrice = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal totalDetailMoney = BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
//遍历每个互联互通账单数据
|
|
|
|
|
for (ChargeDetailDTO detailDTO : notifyChargeOrderInfoBO.getChargeDetails()) {
|
|
|
|
|
long chargeStartTime = getCurrentMinute(detailDTO.getDetailStartTime());
|
|
|
|
|
|
|
|
|
|
//查询当前的detail的开始时间的所属计费时段
|
|
|
|
|
for(PriceRule priceRule : lpr) {
|
|
|
|
|
for (PriceRule priceRule : lpr) {//遍历每个时段
|
|
|
|
|
//如果当前的detail的开始时间在当前计费时段内
|
|
|
|
|
if (priceRule.getStartTime().longValue() <= chargeStartTime && priceRule.getEndTime().longValue() > chargeStartTime) {
|
|
|
|
|
//进行单价差额的计算
|
|
|
|
|
unitDiffPrice = unitDiffPrice.add(BigDecimal.valueOf(priceRule.getElecfee()).subtract(BigDecimal.valueOf(detailDTO.getElecPrice())).abs()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
@ -559,7 +587,7 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
|
|
|
|
|
//判断单价的差额绝对值是否在允许范围内
|
|
|
|
|
if (unitDiffPrice.compareTo(unitPrice) > 0 && unitPrice.compareTo(BigDecimal.valueOf(-1)) != 0) {
|
|
|
|
|
orderDO.setState((byte) 5);
|
|
|
|
|
orderDO.setState((byte) 5); //订单状态 0 创建中 1准备充电中 2 充电中 3完成 4 取消 5挂起 6需要手动补单 7结算中
|
|
|
|
|
orderDO.setExceptionFlag((byte) 4);
|
|
|
|
|
orderDO.setExceptionMsg("账单单价与站点计费不一致");
|
|
|
|
|
orderDO.setCancelMsg("账单单价与站点计费不一致");
|
|
|
|
@ -583,13 +611,12 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
OrderTrackInfoUtil.addOrderTrackInfoCommon(new OrderTrackInfoDetail(orderDO.getOrderNo(), notifyChargeOrderInfoBO.toString(), "反向互联互通订单结算", false, "账单总金额与站点计费*充电量不一致", ""));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前时间的分钟数
|
|
|
|
|
*
|
|
|
|
|
* @param detailStartTime 当面的充电开始时间
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -837,6 +864,7 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 反向订单对账
|
|
|
|
|
*
|
|
|
|
|
* @param orderNoList 订单编号
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -862,6 +890,8 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取最后一次推送过来的账单数据
|
|
|
|
|
//【HuangHai】
|
|
|
|
|
// 互联互通的数据,其它平台的数据,是保存在MongoDb的 notificationChargeOrderInfoReqMongoDO 集合中
|
|
|
|
|
NotificationChargeOrderInfoReqMongoDO orderInfoReqMongoDO = notificationChargeOrderInfoReqDao.findOne(orderNo);
|
|
|
|
|
if (orderInfoReqMongoDO == null) {
|
|
|
|
|
log.warn("订单{}存储mongo上的账单数据为空,对账失败", orderNo);
|
|
|
|
@ -1287,6 +1317,7 @@ public class EvcsNotifyServiceImpl implements EvcsNotifyService {
|
|
|
|
|
// resp.setData(notifyChargeOrderInfoVO);
|
|
|
|
|
// return resp;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 启动失败解冻用户
|
|
|
|
|
*/
|
|
|
|
|