优化数据大屏接口,优化订单结算
This commit is contained in:
parent
f2cbe98fb4
commit
fbbbf3fd2b
@ -19,19 +19,19 @@ spring:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 172.31.183.135:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 127.0.0.1:8848
|
||||
server-addr: 172.31.183.135:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
com.xhpc.activity.mapper: debug
|
||||
#logging:
|
||||
# level:
|
||||
# root: info
|
||||
# com.xhpc.activity.mapper: debug
|
||||
|
||||
|
||||
wx:
|
||||
|
||||
@ -18,7 +18,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author WH
|
||||
@ -709,12 +708,7 @@ public class XhpcDataBigScreenServiceImpl implements XhpcDataBigScreenService {
|
||||
realtimeOrders.setTotalItems((long) realtimeOrderList.size());
|
||||
for (Map<String, Object> realtimeOrderMap : realtimeOrderList) {
|
||||
RealtimeOrders.RealtimeOrder realtimeOrder = new RealtimeOrders.RealtimeOrder();
|
||||
Integer userType = (Integer) realtimeOrderMap.get("source");
|
||||
if (userType == 1) {
|
||||
realtimeOrder.setUserType((String) realtimeOrderMap.get("chargingMode"));
|
||||
} else {
|
||||
realtimeOrder.setUserType((String) realtimeOrderMap.get("sourceMap"));
|
||||
}
|
||||
realtimeOrder.setUserType((String) realtimeOrderMap.get("chargingMode"));
|
||||
realtimeOrder.setStartChargingTime((String) realtimeOrderMap.get("startTime"));
|
||||
realtimeOrder.setChargingTime((String) realtimeOrderMap.get("chargingTime"));
|
||||
realtimeOrder.setChargedElectric((Double) realtimeOrderMap.get("chargingDegree"));
|
||||
|
||||
@ -80,10 +80,18 @@
|
||||
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
|
||||
and find_in_set(tenant_id, #{tenantIdsStr})
|
||||
</if>
|
||||
<if test="areaCode != null and areaCode != '' ">
|
||||
<if test="number ==0">
|
||||
<if test="areaCode== null">
|
||||
<if test="number ==1">
|
||||
AND area_code in (select code from xhpc_area where pcode in(select code from xhpc_area where pcode =xa.code))
|
||||
</if>
|
||||
<if test="number ==2">
|
||||
AND area_code in (select code from xhpc_area where pcode =xa.code)
|
||||
</if>
|
||||
<if test="number ==3">
|
||||
AND area_code =xa.code
|
||||
</if>
|
||||
</if>
|
||||
<if test="areaCode != null">
|
||||
<if test="number ==1">
|
||||
AND area_code in (select code from xhpc_area where pcode in(select code from xhpc_area where pcode =xa.code))
|
||||
</if>
|
||||
@ -97,30 +105,29 @@
|
||||
FROM
|
||||
xhpc_area as xa
|
||||
WHERE 1=1
|
||||
<if test="areaCode != null and areaCode != '' ">
|
||||
<if test="areaCode != null">
|
||||
and xa.level =#{number}
|
||||
<if test="number==0">
|
||||
and (SELECT count(charging_station_id) FROM xhpc_charging_station
|
||||
WHERE del_flag = 0
|
||||
AND area_code in (select code from xhpc_area where pcode in(select code from xhpc_area where pcode =xa.code)))>0
|
||||
</if>
|
||||
<if test="number ==1">
|
||||
and (SELECT count(charging_station_id) FROM xhpc_charging_station
|
||||
WHERE del_flag = 0
|
||||
AND area_code in (select code from xhpc_area where pcode in(select code from xhpc_area where pcode =xa.code)))>0
|
||||
</if>
|
||||
<if test="number ==2">
|
||||
<if test="number ==2">
|
||||
and (SELECT count(charging_station_id) FROM xhpc_charging_station
|
||||
WHERE del_flag = 0
|
||||
AND area_code in (select code from xhpc_area where pcode =xa.code))>0
|
||||
AND (xa.code in (select code from xhpc_area where pcode in(select code from xhpc_area where pcode =#{areaCode}))
|
||||
or xa.code in (select code from xhpc_area where pcode =#{areaCode})
|
||||
)
|
||||
</if>
|
||||
<if test="number ==3">
|
||||
and (SELECT count(charging_station_id) FROM xhpc_charging_station
|
||||
WHERE del_flag = 0
|
||||
AND area_code =xa.code )>0
|
||||
and xa.code in (select code from xhpc_area where pcode =#{areaCode})
|
||||
</if>
|
||||
</if>
|
||||
<if test="areaCode==null or areaCode == '' ">
|
||||
<if test="areaCode==null">
|
||||
and xa.level =1
|
||||
and (SELECT count(charging_station_id) FROM xhpc_charging_station
|
||||
WHERE del_flag = 0
|
||||
|
||||
@ -129,7 +129,7 @@
|
||||
FROM
|
||||
xhpc_history_order
|
||||
WHERE
|
||||
del_flag = 0
|
||||
del_flag = 0 and charging_mode is not null
|
||||
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
|
||||
and find_in_set(tenant_id, #{tenantIdsStr})
|
||||
</if>
|
||||
@ -174,7 +174,7 @@
|
||||
FROM
|
||||
mysql.help_topic t
|
||||
WHERE
|
||||
t.help_topic_id <![CDATA[<=]]> 15
|
||||
t.help_topic_id <![CDATA[<=]]> 31
|
||||
) a
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
@ -193,7 +193,7 @@
|
||||
#{chargingStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
AND end_time <![CDATA[>=]]> DATE_ADD( now(), INTERVAL - 15 DAY )
|
||||
AND end_time <![CDATA[>=]]> DATE_ADD( now(), INTERVAL - 31 DAY )
|
||||
GROUP BY
|
||||
DATE_FORMAT( end_time, "%Y-%m-%d" )) b ON a.`current_time` = b.end_time
|
||||
ORDER BY
|
||||
|
||||
@ -35,59 +35,46 @@
|
||||
</select>
|
||||
<select id="selectByTenantIdsAndCharingStationIds" resultType="Map">
|
||||
select
|
||||
r.charging_order_id chargingOrderId,
|
||||
ROUND(r.charging_degree,2) as chargingDegree,
|
||||
r.amount_charged amountCharged,
|
||||
r.electric_current electricCurrent,
|
||||
r.voltage,
|
||||
r.soc,
|
||||
r.source,
|
||||
DATE_FORMAT(o.start_time,"%H:%m") as startTime,
|
||||
CASE r.source
|
||||
WHEN 0 THEN
|
||||
ROUND(ro.charging_degree,2) as chargingDegree,
|
||||
DATE_FORMAT(co.start_time,"%H:%i") as startTime,
|
||||
ro.amount_charged amountCharged,
|
||||
ro.electric_current electricCurrent,
|
||||
ro.real_time_order_id as realTimeOrderId,
|
||||
ro.voltage as voltage,
|
||||
ro.soc as soc,
|
||||
ro.charging_time chargingTime,
|
||||
CASE
|
||||
WHEN co.charging_mode = "新电途" THEN
|
||||
"新电途用户"
|
||||
WHEN co.charging_mode = "快电" THEN
|
||||
"快电用户"
|
||||
WHEN co.charging_mode = "恒大" THEN
|
||||
"恒大用户"
|
||||
WHEN co.charging_mode = "小桔" THEN
|
||||
"小桔用户"
|
||||
ELSE
|
||||
"C端用户"
|
||||
WHEN 2 THEN
|
||||
"社区用户"
|
||||
WHEN 3 THEN
|
||||
"B端用户"
|
||||
END sourceMap,
|
||||
r.charging_time chargingTime,
|
||||
CONCAT(o.charging_mode,"用户") as chargingMode
|
||||
from
|
||||
(SELECT
|
||||
charging_order_id,
|
||||
charging_degree,
|
||||
amount_charged,
|
||||
electric_current,
|
||||
voltage,
|
||||
soc,
|
||||
source,
|
||||
tenant_id,
|
||||
charging_time
|
||||
FROM
|
||||
xhpc_real_time_order
|
||||
WHERE
|
||||
real_time_order_id IN
|
||||
(SELECT
|
||||
max(real_time_order_id)
|
||||
FROM
|
||||
xhpc_real_time_order
|
||||
WHERE
|
||||
charging_order_id IN
|
||||
(SELECT charge_order_id FROM xhpc_charge_order WHERE STATUS = 0 and del_flag = 0
|
||||
END chargingMode
|
||||
from xhpc_charge_order co
|
||||
left join xhpc_internet_user as inu on inu.internet_user_id = co.user_id and co.source =1
|
||||
left join xhpc_app_user as apu on apu.app_user_id = co.user_id and co.source =0
|
||||
left join xhpc_community_personnel as cop on cop.community_personnel_id = co.user_id and co.source =2
|
||||
left join xhpc_customers_personnel as cup on cup.customers_personnel_id = co.user_id and co.source =3
|
||||
LEFT JOIN (
|
||||
SELECT charging_order_id,real_time_order_id,soc,charging_degree,charging_time,amount_charged,electric_current,voltage FROM xhpc_real_time_order
|
||||
WHERE real_time_order_id IN ( SELECT max( real_time_order_id ) FROM xhpc_real_time_order GROUP BY charging_order_id )
|
||||
) ro ON ro.charging_order_id = co.charge_order_id
|
||||
where co.status=0 and co.del_flag=0
|
||||
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
|
||||
and find_in_set(tenant_id, #{tenantIdsStr})
|
||||
and find_in_set(co.tenant_id, #{tenantIdsStr})
|
||||
</if>
|
||||
<if test="xhpcChargingStationList!=null and xhpcChargingStationList.size()!=0">
|
||||
and charging_station_id in
|
||||
and co.charging_station_id in
|
||||
<foreach collection="xhpcChargingStationList" open="(" close=")" separator="," item="chargingStationId">
|
||||
#{chargingStationId}
|
||||
</foreach>
|
||||
</if>
|
||||
)
|
||||
GROUP BY charging_order_id))
|
||||
AS r LEFT JOIN xhpc_charge_order as o on r.charging_order_id = o.charge_order_id
|
||||
ORDER BY o.start_time ASC
|
||||
order by co.create_time desc
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete
|
||||
|
||||
@ -902,26 +902,6 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
}
|
||||
}
|
||||
}
|
||||
@GetMapping("/test44")
|
||||
public void test44(){
|
||||
//获取异常的订单 24小时之外的异常订单
|
||||
List<Map<String,Object>> xhpcChargeOrderList= chargeOrderService.getXhpcChargeOrderStatus(2);
|
||||
|
||||
if(xhpcChargeOrderList !=null && xhpcChargeOrderList.size()>0){
|
||||
for (int i = 0; i <xhpcChargeOrderList.size() ; i++) {
|
||||
Map<String,Object> map = xhpcChargeOrderList.get(i);
|
||||
if(map !=null){
|
||||
Long chargeOrderId = Long.valueOf(map.get("chargeOrderId").toString());
|
||||
if(map.get("realTimeOrderId")!=null){
|
||||
Long realTimeOrderId = Long.valueOf(map.get("realTimeOrderId").toString());
|
||||
xhpcHistoryOrderService.addXhpcChargeOrder(realTimeOrderId,chargeOrderId);
|
||||
}else{
|
||||
xhpcHistoryOrderService.addXhpcChargeOrder(null,chargeOrderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记异常大于创建4小时,标记为异常
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.xhpc.order.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author yuyang
|
||||
* @date 2022/5/13 14:31
|
||||
*/
|
||||
@Data
|
||||
public class RateTime implements Serializable {
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 服务费
|
||||
*/
|
||||
private BigDecimal servicePrice;
|
||||
|
||||
/**
|
||||
* 服务费
|
||||
*/
|
||||
private BigDecimal powerPrice;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.xhpc.order.domain.XhpcChargeOrderCurrent;
|
||||
import com.xhpc.order.domain.XhpcChargeOrderSoc;
|
||||
import com.xhpc.order.domain.XhpcChargeOrderVoltage;
|
||||
import com.xhpc.order.domain.XhpcRealTimeOrder;
|
||||
import com.xhpc.order.dto.RateTime;
|
||||
import com.xhpc.order.dto.XhpcActivityDiscountDto;
|
||||
import com.xhpc.order.dto.XhpcActivityFormulaDomainDto;
|
||||
import com.xhpc.order.dto.XhpcActivityInternetDomainDto;
|
||||
@ -163,9 +164,15 @@ public interface XhpcRealTimeOrderMapper {
|
||||
List<XhpcActivityDiscountDto> getActivityDiscountTime(@Param("internetUserId")Long internetUserId, @Param("startTime")String startTime, @Param("userType")Integer userType, @Param("chargingStationId")Long chargingStationId, @Param("tenantId")String tenantId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询该时段的计费公式
|
||||
*/
|
||||
List<XhpcActivityFormulaDomainDto> getActivityFormulaById(@Param("activityId") Integer activityId);
|
||||
|
||||
|
||||
//获取场站的费率时段
|
||||
List<RateTime> getRateTimeList(@Param("chargingStationId")Long chargingStationId, @Param("rateModelId")Long rateModelId,@Param("rateValue") String rateValue);
|
||||
|
||||
|
||||
XhpcActivityFormulaDomainDto getActivityFormulaTimeById(@Param("activityId") Integer activityId,@Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
}
|
||||
|
||||
@ -465,8 +465,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
|
||||
map1.put("chargingDegree", chargeOrder.getChargingDegree());
|
||||
map1.put("actPrice", totalPrice);
|
||||
list.add(map1);
|
||||
map.put("powerPriceTotal", 0);
|
||||
map.put("servicePriceTotal", 0);
|
||||
// map.put("powerPriceTotal", 0);
|
||||
// map.put("servicePriceTotal", 0);
|
||||
map.put("list", list);//数据列表
|
||||
return map;
|
||||
}
|
||||
@ -483,8 +483,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
|
||||
map1.put("actPrice", totalPrice);
|
||||
list.add(map1);
|
||||
map.put("list", list);//数据列表
|
||||
map.put("powerPriceTotal", 0);
|
||||
map.put("servicePriceTotal", 0);
|
||||
// map.put("powerPriceTotal", 0);
|
||||
// map.put("servicePriceTotal", 0);
|
||||
return map;
|
||||
}
|
||||
//每分钟多少度
|
||||
@ -537,8 +537,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("powerPriceTotal", powerPriceTotal);
|
||||
map.put("servicePriceTotal", servicePriceTotal);
|
||||
// map.put("powerPriceTotal", powerPriceTotal);
|
||||
// map.put("servicePriceTotal", servicePriceTotal);
|
||||
map.put("list", list);//数据列表
|
||||
//map.put("chargingTimeTotal",chargeOrder.getChargingTime());//总时长
|
||||
//map.put("powerPriceTotal",powerPriceTotal);//总电费单价(元/度)
|
||||
|
||||
@ -18,6 +18,7 @@ import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.common.util.EvcsUtil;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.order.domain.*;
|
||||
import com.xhpc.order.dto.RateTime;
|
||||
import com.xhpc.order.dto.XhpcActivityDiscountDto;
|
||||
import com.xhpc.order.dto.XhpcActivityFormulaDomainDto;
|
||||
import com.xhpc.order.dto.XhpcActivityInternetDomainDto;
|
||||
@ -355,6 +356,20 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
Integer source = xhpcChargeOrder.getSource();
|
||||
String tenantId = xhpcChargeOrder.getTenantId();
|
||||
Map<String, Object> userMessage =new HashMap<>();
|
||||
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
|
||||
|
||||
if(xhpcChargeOrder.getStartTime() ==null || xhpcChargeOrder.getEndTime()==null){
|
||||
//获取实时数据
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:"+xhpcChargeOrder.getSerialNumber());
|
||||
if(cacheMap !=null && cacheMap.get("realtimeDataList") !=null){
|
||||
List<CacheRealtimeData> list = (List<CacheRealtimeData>) cacheMap.get("realtimeDataList");
|
||||
if(list !=null && list.size()>0){
|
||||
xhpcChargeOrder.setEndTime(DateUtil.parse(list.get(list.size()-1).getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcChargeOrder.setStartTime(DateUtil.parse(list.get(0).getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
|
||||
R user = userTypeService.getUser(null, userId, source, null, tenantId);
|
||||
boolean judge = false;
|
||||
@ -374,9 +389,15 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
|
||||
return AjaxResult.error("用户id:" + userId + "为空");
|
||||
}
|
||||
}else{
|
||||
xhpcHistoryOrder.setInternetSerialNumber(xhpcChargeOrder.getInternetSerialNumber());
|
||||
Map<String, Object> pushOrder = redisService.getCacheMap("pushOrder:"+xhpcChargeOrder.getSerialNumber());
|
||||
if(pushOrder.get("operatorId3rdpty") !=null){
|
||||
xhpcHistoryOrder.setOperatorId3rdptyEvcs((String) pushOrder.get("operatorId3rdpty"));
|
||||
}
|
||||
}
|
||||
//生成一条历史订单
|
||||
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
|
||||
|
||||
xhpcHistoryOrder.setStartTime(xhpcChargeOrder.getStartTime());
|
||||
if(xhpcChargeOrder.getEndTime()==null ){
|
||||
xhpcHistoryOrder.setEndTime(xhpcChargeOrder.getStartTime());
|
||||
@ -461,6 +482,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
Date endTime = xhpcChargeOrder.getEndTime();
|
||||
Integer source = xhpcChargeOrder.getSource();
|
||||
String internetSerialNumber = xhpcChargeOrder.getInternetSerialNumber();
|
||||
Long chargingStationId = xhpcChargeOrder.getChargingStationId();
|
||||
String tenantId = xhpcChargeOrder.getTenantId();
|
||||
//判断是否有活动
|
||||
logger.info("<<<<<<<<<<<<<<<判断是否有活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
|
||||
boolean judge =false;
|
||||
@ -468,100 +491,123 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
xhpcHistoryOrder.setChargingMode(xhpcChargeOrder.getUserId()+"");
|
||||
xhpcHistoryOrder.setInternetSerialNumber(xhpcChargeOrder.getInternetSerialNumber());
|
||||
Double totalPower = xhpcHistoryOrder.getTotalPower();
|
||||
//yyyy-mm-dd(当前时间)
|
||||
String parse2 = DateUtil.formatDate(startTime);
|
||||
long time1 = startTime.getTime();
|
||||
long time2 = endTime.getTime();
|
||||
|
||||
if( time1 != time2 && time2>time1){
|
||||
List<XhpcActivityInternetDomainDto> activityStationTime = xhpcRealTimeOrderMapper.getActivityStationTime(internetUserId, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime), xhpcChargeOrder.getChargingStationId(), xhpcChargeOrder.getTenantId());
|
||||
//1时间没有跨天
|
||||
DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
|
||||
Map<String, Object> judgeActivity= getRateOrActivityFormul(xhpcChargeOrder.getSerialNumber(), internetUserId, startTime, endTime, chargingStationId, tenantId, xhpcChargeOrder.getRateModelId());
|
||||
|
||||
if(activityStationTime !=null && activityStationTime.size()==1){
|
||||
logger.info("<<<<<<<<<<<<<<<有流量方活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
|
||||
judge =true;
|
||||
Map<String, Double> params1 =new HashMap<>();
|
||||
if("1".equals(judgeActivity.get("status").toString())){
|
||||
params1.put("T",money.doubleValue());
|
||||
params1.put("P",powerPrice.doubleValue());
|
||||
params1.put("S",servicePrice.doubleValue());
|
||||
params1.put("E",totalPower);
|
||||
String computeFormula = judgeActivity.get("computeFormula").toString();
|
||||
int computeType = (int)judgeActivity.get("computeType");
|
||||
BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params1)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总服务费
|
||||
activityServicePriceTotal = servicePrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总电费
|
||||
activityPowerPriceTotal = powerPrice.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总金额
|
||||
activityTotalPriceTotal = money;
|
||||
if(computeType==1){
|
||||
BigDecimal decimal1 = eval.multiply(new BigDecimal(0.5)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
internetCommission = internetCommission.add(eval);
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal.subtract(decimal1));
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(decimal1));
|
||||
}else if(computeType==2){
|
||||
internetSvcCommission = internetSvcCommission.add(eval);
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
|
||||
}else{
|
||||
//电量抽成
|
||||
internetDegreeCommission = internetDegreeCommission.add(eval);
|
||||
//减服务费
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
|
||||
}
|
||||
promotionDiscount = money.subtract(activityTotalPriceTotal);
|
||||
xhpcHistoryOrder.setActivityId(judgeActivity.get("activityId").toString());
|
||||
}else if("2".equals(judgeActivity.get("status").toString())){
|
||||
|
||||
String start = DateUtil.formatTime(startTime);
|
||||
String end = DateUtil.formatTime(endTime);
|
||||
String activityId ="";
|
||||
BigDecimal chargingDegree = new BigDecimal(0);
|
||||
Map<String, Double> params =new HashMap<>();
|
||||
List<XhpcActivityFormulaDomainDto> activityFormulaTime1 =new ArrayList<>();
|
||||
List<XhpcActivityFormulaDomainDto> activityFormulaTime2 =new ArrayList<>();
|
||||
XhpcActivityInternetDomainDto activityInternet1 =new XhpcActivityInternetDomainDto();
|
||||
Long rateModelId = xhpcChargeOrder.getRateModelId();
|
||||
if(betweenDay>0){
|
||||
activityInternet1 = activityStationTime.get(0);
|
||||
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, "24:00:00");
|
||||
activityFormulaTime2 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), "00:00:00", end);
|
||||
activityId =activityInternet1.getActivityId()+"";
|
||||
}else{
|
||||
activityInternet1 = activityStationTime.get(0);
|
||||
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, end);
|
||||
activityId =activityInternet1.getActivityId()+"";
|
||||
}
|
||||
for (int j = 0; j < activityFormulaTime1.size(); j++) {
|
||||
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime1.get(j);
|
||||
//计费类型
|
||||
int computeType = activityInternet1.getComputeType();
|
||||
BigDecimal activityServicePriceFormula = activityFormula.getServicePrice();
|
||||
BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice();
|
||||
//计算公式
|
||||
String computeFormula = activityFormula.getComputeFormula();
|
||||
BigDecimal degree =new BigDecimal(0);
|
||||
if (activityFormulaTime2.size()==0 && activityFormulaTime1.size()-1==j) {
|
||||
degree = new BigDecimal(totalPower).subtract(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
String computeFormula = judgeActivity.get("computeFormula").toString();
|
||||
BigDecimal powerPrice1 = new BigDecimal(judgeActivity.get("powerPrice").toString());
|
||||
BigDecimal servicePrice1 = new BigDecimal(judgeActivity.get("servicePrice").toString());
|
||||
//活动总服务费
|
||||
activityServicePriceTotal = servicePrice1.multiply(new BigDecimal(totalPower)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总电费
|
||||
activityPowerPriceTotal = powerPrice1.multiply(new BigDecimal(totalPower)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总金额
|
||||
activityTotalPriceTotal = activityServicePriceTotal.add(activityPowerPriceTotal);
|
||||
params1.put("T",activityTotalPriceTotal.doubleValue());
|
||||
params1.put("P",activityPowerPriceTotal.doubleValue());
|
||||
params1.put("S",activityServicePriceTotal.doubleValue());
|
||||
params1.put("E",totalPower);
|
||||
|
||||
int computeType = (int)judgeActivity.get("computeType");
|
||||
BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params1)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
if(computeType==1){
|
||||
BigDecimal decimal1 = eval.multiply(new BigDecimal(0.5)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
internetCommission = internetCommission.add(eval);
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal.subtract(decimal1));
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(decimal1));
|
||||
}else if(computeType==2){
|
||||
internetSvcCommission = internetSvcCommission.add(eval);
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
|
||||
}else{
|
||||
//电量抽成
|
||||
internetDegreeCommission = internetDegreeCommission.add(eval);
|
||||
//减服务费
|
||||
activityServicePrice =activityServicePrice.add(activityServicePriceTotal.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPriceTotal);
|
||||
}
|
||||
promotionDiscount = money.subtract(activityTotalPriceTotal);
|
||||
xhpcHistoryOrder.setActivityId(judgeActivity.get("activityId").toString());
|
||||
}else{
|
||||
boolean activityInternet =false;
|
||||
//yyyy-mm-dd(当前时间)
|
||||
String parse2 = DateUtil.formatDate(startTime);
|
||||
long time1 = startTime.getTime();
|
||||
long time2 = endTime.getTime();
|
||||
|
||||
if( time1 != time2 && time2>time1){
|
||||
List<XhpcActivityInternetDomainDto> activityStationTime = xhpcRealTimeOrderMapper.getActivityStationTime(internetUserId, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime), chargingStationId, tenantId);
|
||||
//1时间没有跨天
|
||||
DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
|
||||
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
|
||||
if(activityStationTime !=null && activityStationTime.size()==1){
|
||||
logger.info("<<<<<<<<<<<<<<<有流量方活动>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSerialNumber());
|
||||
judge =true;
|
||||
|
||||
String start = DateUtil.formatTime(startTime);
|
||||
String end = DateUtil.formatTime(endTime);
|
||||
String activityId ="";
|
||||
BigDecimal chargingDegree = new BigDecimal(0);
|
||||
Map<String, Double> params =new HashMap<>();
|
||||
List<XhpcActivityFormulaDomainDto> activityFormulaTime1 =new ArrayList<>();
|
||||
List<XhpcActivityFormulaDomainDto> activityFormulaTime2 =new ArrayList<>();
|
||||
XhpcActivityInternetDomainDto activityInternet1 =new XhpcActivityInternetDomainDto();
|
||||
if(betweenDay>0){
|
||||
activityInternet1 = activityStationTime.get(0);
|
||||
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, "24:00:00");
|
||||
activityFormulaTime2 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), "00:00:00", end);
|
||||
activityId =activityInternet1.getActivityId()+"";
|
||||
}else{
|
||||
degree =getRealOrderTime(chargeOrderId, parse2+" "+activityFormula.getStartTime(), parse2+" "+activityFormula.getEndTime()).setScale(2,BigDecimal.ROUND_HALF_UP);;
|
||||
activityInternet1 = activityStationTime.get(0);
|
||||
activityFormulaTime1 = xhpcRealTimeOrderMapper.getActivityFormulaTime(activityInternet1.getActivityId(), start, end);
|
||||
activityId =activityInternet1.getActivityId()+"";
|
||||
}
|
||||
//挡前服务费
|
||||
BigDecimal activityServicePrice1 = activityServicePriceFormula.multiply(degree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总服务费
|
||||
activityServicePriceTotal = activityServicePriceTotal.add(activityServicePrice1).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//挡前电费
|
||||
BigDecimal activityPowerPrice1 = activityPowerPriceFormula.multiply(degree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总电费
|
||||
activityPowerPriceTotal = activityPowerPriceTotal.add(activityPowerPrice1).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总金额
|
||||
activityTotalPriceTotal = activityTotalPriceTotal.add(activityServicePrice1.add(activityPowerPrice1));
|
||||
params.put("T",activityPowerPrice1.add(activityServicePrice1).doubleValue());
|
||||
params.put("P",activityPowerPrice1.doubleValue());
|
||||
params.put("S",activityServicePrice1.doubleValue());
|
||||
params.put("E",degree.doubleValue());
|
||||
//支付给流量方的钱
|
||||
BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
if(computeType==1){
|
||||
BigDecimal decimal1 = eval.multiply(new BigDecimal(0.5)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
internetCommission = internetCommission.add(eval);
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1.subtract(decimal1));
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal1));
|
||||
}else if(computeType==2){
|
||||
internetSvcCommission = internetSvcCommission.add(eval);
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1);
|
||||
}else{
|
||||
//电量抽成
|
||||
internetDegreeCommission = internetDegreeCommission.add(eval);
|
||||
//减服务费
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1);
|
||||
}
|
||||
chargingDegree = chargingDegree.add(degree);
|
||||
}
|
||||
if(activityFormulaTime2.size()>0){
|
||||
for (int j = 0; j < activityFormulaTime2.size(); j++) {
|
||||
for (int j = 0; j < activityFormulaTime1.size(); j++) {
|
||||
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime1.get(j);
|
||||
//计费类型
|
||||
int computeType = activityInternet1.getComputeType();
|
||||
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime2.get(j);
|
||||
BigDecimal activityServicePriceFormula = activityFormula.getServicePrice();
|
||||
BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice();
|
||||
//计算公式
|
||||
String computeFormula = activityFormula.getComputeFormula();
|
||||
BigDecimal degree =new BigDecimal(0);
|
||||
if (activityFormulaTime2.size()-1==j) {
|
||||
if (activityFormulaTime2.size()==0 && activityFormulaTime1.size()-1==j) {
|
||||
degree = new BigDecimal(totalPower).subtract(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}else{
|
||||
degree =getRealOrderTime(chargeOrderId, parse2+" "+activityFormula.getStartTime(), parse2+" "+activityFormula.getEndTime()).setScale(2,BigDecimal.ROUND_HALF_UP);;
|
||||
@ -600,18 +646,110 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
}
|
||||
chargingDegree = chargingDegree.add(degree);
|
||||
}
|
||||
}
|
||||
promotionDiscount = money.subtract(activityTotalPriceTotal);
|
||||
xhpcHistoryOrder.setActivityId(activityId);
|
||||
}else{
|
||||
if(activityStationTime.size()>1){
|
||||
xhpcHistoryOrder.setActivityId("同一时间活动有2个");
|
||||
if(activityFormulaTime2.size()>0){
|
||||
for (int j = 0; j < activityFormulaTime2.size(); j++) {
|
||||
//计费类型
|
||||
int computeType = activityInternet1.getComputeType();
|
||||
XhpcActivityFormulaDomainDto activityFormula = activityFormulaTime2.get(j);
|
||||
BigDecimal activityServicePriceFormula = activityFormula.getServicePrice();
|
||||
BigDecimal activityPowerPriceFormula = activityFormula.getPowerPrice();
|
||||
//计算公式
|
||||
String computeFormula = activityFormula.getComputeFormula();
|
||||
BigDecimal degree =new BigDecimal(0);
|
||||
if (activityFormulaTime2.size()-1==j) {
|
||||
degree = new BigDecimal(totalPower).subtract(chargingDegree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}else{
|
||||
degree =getRealOrderTime(chargeOrderId, parse2+" "+activityFormula.getStartTime(), parse2+" "+activityFormula.getEndTime()).setScale(2,BigDecimal.ROUND_HALF_UP);;
|
||||
}
|
||||
//挡前服务费
|
||||
BigDecimal activityServicePrice1 = activityServicePriceFormula.multiply(degree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总服务费
|
||||
activityServicePriceTotal = activityServicePriceTotal.add(activityServicePrice1).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//挡前电费
|
||||
BigDecimal activityPowerPrice1 = activityPowerPriceFormula.multiply(degree).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总电费
|
||||
activityPowerPriceTotal = activityPowerPriceTotal.add(activityPowerPrice1).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
//活动总金额
|
||||
activityTotalPriceTotal = activityTotalPriceTotal.add(activityServicePrice1.add(activityPowerPrice1));
|
||||
params.put("T",activityPowerPrice1.add(activityServicePrice1).doubleValue());
|
||||
params.put("P",activityPowerPrice1.doubleValue());
|
||||
params.put("S",activityServicePrice1.doubleValue());
|
||||
params.put("E",degree.doubleValue());
|
||||
//支付给流量方的钱
|
||||
BigDecimal eval = new BigDecimal(Calc.eval(computeFormula, params)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
if(computeType==1){
|
||||
BigDecimal decimal1 = eval.multiply(new BigDecimal(0.5)).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
internetCommission = internetCommission.add(eval);
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1.subtract(decimal1));
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(decimal1));
|
||||
}else if(computeType==2){
|
||||
internetSvcCommission = internetSvcCommission.add(eval);
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1);
|
||||
}else{
|
||||
//电量抽成
|
||||
internetDegreeCommission = internetDegreeCommission.add(eval);
|
||||
//减服务费
|
||||
activityServicePrice =activityServicePrice.add(activityServicePrice1.subtract(eval));
|
||||
activityPowerPrice =activityPowerPrice.add(activityPowerPrice1);
|
||||
}
|
||||
chargingDegree = chargingDegree.add(degree);
|
||||
}
|
||||
}
|
||||
promotionDiscount = money.subtract(activityTotalPriceTotal);
|
||||
xhpcHistoryOrder.setActivityId(activityId);
|
||||
}else{
|
||||
xhpcHistoryOrder.setActivityId("无活动");
|
||||
//按照以前流量方折扣计算
|
||||
if(activityStationTime.size()>1){
|
||||
xhpcHistoryOrder.setActivityId("同一时间活动有2个");
|
||||
}else{
|
||||
xhpcHistoryOrder.setActivityId("无活动");
|
||||
}
|
||||
activityInternet =true;
|
||||
}
|
||||
}else{
|
||||
activityInternet =true;
|
||||
xhpcHistoryOrder.setActivityId("充电开始结束时间相等不做活动");
|
||||
}
|
||||
if(activityInternet){
|
||||
logger.info("无活动,流量方按照以前抽成");
|
||||
String substring = internetSerialNumber.substring(0, 9);
|
||||
xhpcHistoryOrder.setInternetSerialNumber(xhpcChargeOrder.getInternetSerialNumber());
|
||||
Map<String, Object> operatorIdEvcs = xhpcRealTimeOrderMapper.getOperatorIdEvcs(substring);
|
||||
if(operatorIdEvcs !=null){
|
||||
if(operatorIdEvcs.get("operatorIdEvcs")!=null && operatorIdEvcs.get("commissionType")!=null && operatorIdEvcs.get("commissionRate")!=null){
|
||||
BigDecimal commissionRate = new BigDecimal(operatorIdEvcs.get("commissionRate").toString()).divide(new BigDecimal(100));
|
||||
String commissionType = operatorIdEvcs.get("commissionType").toString();
|
||||
if(operatorIdEvcs.get("internetUserId") !=null){
|
||||
xhpcHistoryOrder.setChargingMode(operatorIdEvcs.get("internetUserId").toString());
|
||||
}
|
||||
//0总金额提成 1服务费提成
|
||||
if(new BigDecimal(0).compareTo(commissionRate)==-1){
|
||||
if("0".equals(commissionType) || "1".equals(commissionType)|| "2".equals(commissionType)){
|
||||
//流量方的钱
|
||||
if("0".equals(commissionType)){
|
||||
BigDecimal decimal1 = surplusPowerPrice.multiply(commissionRate).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
BigDecimal decimal2 = surplusServicePrice.multiply(commissionRate).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
internetCommission = decimal1.add(decimal2);
|
||||
surplusPowerPrice =surplusPowerPrice.subtract(decimal1);
|
||||
surplusServicePrice =surplusServicePrice.subtract(decimal2);
|
||||
}else if("1".equals(commissionType)){
|
||||
BigDecimal decimal2 = surplusServicePrice.multiply(commissionRate).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
internetSvcCommission = decimal2;
|
||||
surplusServicePrice = surplusServicePrice.subtract(decimal2);
|
||||
}else{
|
||||
//电量抽成
|
||||
BigDecimal chargingDegree = xhpcChargeOrder.getChargingDegree();
|
||||
internetDegreeCommission = chargingDegree.multiply(new BigDecimal(operatorIdEvcs.get("commissionRate").toString())).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
//减服务费
|
||||
surplusServicePrice = surplusServicePrice.subtract(internetDegreeCommission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
xhpcHistoryOrder.setActivityId("充电开始结束时间相等不做活动");
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
@ -1453,11 +1591,122 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
|
||||
|
||||
//判斷活动时间、电费、服务费、公式是否和场站一致
|
||||
private boolean getRateOrActivityFormul(){
|
||||
private Map<String,Object> getRateOrActivityFormul(String serialNumber,Long internetUserId,Date startTime,Date endTime,Long chargingStationId,String tenantId,Long rateModelId){
|
||||
Map<String,Object> map =new HashMap<>();
|
||||
List<XhpcActivityInternetDomainDto> activityStationTime = xhpcRealTimeOrderMapper.getActivityStationTime(internetUserId, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime), chargingStationId, tenantId);
|
||||
if(activityStationTime !=null && activityStationTime.size()==1) {
|
||||
//活动的时间、电费、服务费、公式
|
||||
Integer activityId = activityStationTime.get(0).getActivityId();
|
||||
int computeType = activityStationTime.get(0).getComputeType();
|
||||
List<XhpcActivityFormulaDomainDto> activityFormulaList = xhpcRealTimeOrderMapper.getActivityFormulaById(activityId);
|
||||
//场站的电费和服务费
|
||||
List<RateTime> rateTimeList = xhpcRealTimeOrderMapper.getRateTimeList(chargingStationId, rateModelId, null);
|
||||
String computeFormula = "";
|
||||
if (activityFormulaList != null && rateTimeList != null && activityFormulaList.size() > 0 && activityFormulaList.size() == rateTimeList.size()) {
|
||||
for (int i = 0; i < activityFormulaList.size(); i++) {
|
||||
XhpcActivityFormulaDomainDto activit = activityFormulaList.get(i);
|
||||
RateTime rateTime = rateTimeList.get(i);
|
||||
if (activit.getStartTime().equals(rateTime.getStartTime()) && activit.getEndTime().equals(rateTime.getEndTime()) &&
|
||||
activit.getServicePrice().compareTo(rateTime.getServicePrice()) == 0 && activit.getPowerPrice().compareTo(rateTime.getPowerPrice()) == 0) {
|
||||
if (i == 0) {
|
||||
computeFormula = activit.getComputeFormula();
|
||||
} else if (i != activityFormulaList.size() - 1) {
|
||||
if (!computeFormula.equals(activit.getComputeFormula())) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!computeFormula.equals(activit.getComputeFormula())) {
|
||||
break;
|
||||
} else {
|
||||
map.put("status","1");
|
||||
map.put("computeFormula",computeFormula);
|
||||
map.put("activityId",activityId);
|
||||
map.put("computeType",computeType);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//查看结算报文是否夸时段
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + serialNumber);
|
||||
if (cacheMap != null) {
|
||||
CacheOrderData cacheOrderData = (CacheOrderData) cacheMap.get("orderData");
|
||||
if (cacheOrderData != null) {
|
||||
int number = 0;
|
||||
if (!"0".equals(cacheOrderData.getT1PowerQuantity().toString())) {
|
||||
number++;
|
||||
rateTimeList = xhpcRealTimeOrderMapper.getRateTimeList(chargingStationId, rateModelId, "00");
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT2PowerQuantity().toString())) {
|
||||
number++;
|
||||
rateTimeList = xhpcRealTimeOrderMapper.getRateTimeList(chargingStationId, rateModelId, "01");
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT3PowerQuantity().toString())) {
|
||||
number++;
|
||||
rateTimeList = xhpcRealTimeOrderMapper.getRateTimeList(chargingStationId, rateModelId, "02");
|
||||
}
|
||||
if (!"0".equals(cacheOrderData.getT4PowerQuantity().toString())) {
|
||||
number++;
|
||||
rateTimeList = xhpcRealTimeOrderMapper.getRateTimeList(chargingStationId, rateModelId, "03");
|
||||
}
|
||||
BigDecimal powerPrice = new BigDecimal(0);
|
||||
BigDecimal servicePrice = new BigDecimal(0);
|
||||
if (number == 1) {
|
||||
for (int i = 0; i < rateTimeList.size(); i++) {
|
||||
RateTime rateTime = rateTimeList.get(i);
|
||||
XhpcActivityFormulaDomainDto activity = xhpcRealTimeOrderMapper.getActivityFormulaTimeById(activityStationTime.get(0).getActivityId(), rateTime.getStartTime(), rateTime.getEndTime());
|
||||
if (i == 0) {
|
||||
computeFormula = activity.getComputeFormula();
|
||||
powerPrice = activity.getPowerPrice();
|
||||
servicePrice = activity.getServicePrice();
|
||||
if(rateTimeList.size()==1){
|
||||
map.put("status","2");
|
||||
map.put("computeFormula",computeFormula);
|
||||
map.put("powerPrice",powerPrice);
|
||||
map.put("servicePrice",servicePrice);
|
||||
map.put("activityId",activityId);
|
||||
map.put("computeType",computeType);
|
||||
return map;
|
||||
}
|
||||
} else if (i != rateTimeList.size() - 1) {
|
||||
if (computeFormula.equals(activity.getComputeFormula())) {
|
||||
break;
|
||||
}
|
||||
if (powerPrice.compareTo(activity.getPowerPrice()) != 0) {
|
||||
break;
|
||||
}
|
||||
if (servicePrice.compareTo(activity.getServicePrice()) != 0) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (computeFormula.equals(activity.getComputeFormula())) {
|
||||
break;
|
||||
}
|
||||
if (powerPrice.compareTo(activity.getPowerPrice()) != 0) {
|
||||
break;
|
||||
}
|
||||
if (servicePrice.compareTo(activity.getServicePrice()) != 0) {
|
||||
break;
|
||||
}
|
||||
map.put("status","2");
|
||||
map.put("computeFormula",computeFormula);
|
||||
map.put("powerPrice",powerPrice);
|
||||
map.put("servicePrice",servicePrice);
|
||||
map.put("activityId",activityId);
|
||||
map.put("computeType",computeType);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
map.put("status","0");
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -827,4 +827,46 @@
|
||||
order by xad.start_time asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getActivityFormulaById" resultType="com.xhpc.order.dto.XhpcActivityFormulaDomainDto">
|
||||
select
|
||||
activity_formula_id as activityFormulaId,
|
||||
activity_id as activityId,
|
||||
start_time as startTime,
|
||||
end_time as endTime,
|
||||
service_price as servicePrice,
|
||||
power_price as powerPrice,
|
||||
compute_formula as computeFormula
|
||||
from xhpc_activity_formula
|
||||
where activity_id = #{activityId}
|
||||
</select>
|
||||
|
||||
<select id="getRateTimeList" resultType="com.xhpc.order.dto.RateTime">
|
||||
select
|
||||
start_time as startTime,
|
||||
replace(end_time, '00:00:00', '24:00:00') as endTime,
|
||||
power_fee as powerPrice,
|
||||
service_fee as servicePrice
|
||||
from xhpc_rate_time as xrt
|
||||
left join xhpc_rate as xr on xrt.rate_id = xr.rate_id
|
||||
where xrt.charging_station_id=#{chargingStationId} and xrt.rate_model_id=#{rateModelId} and xrt.del_flag=0
|
||||
<if test="rateValue !=null and rateValue !=''">
|
||||
and xrt.rate_value =#{rateValue}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getActivityFormulaTimeById" resultType="com.xhpc.order.dto.XhpcActivityFormulaDomainDto">
|
||||
select
|
||||
activity_formula_id as activityFormulaId,
|
||||
activity_id as activityId,
|
||||
start_time as startTime,
|
||||
end_time as endTime,
|
||||
service_price as servicePrice,
|
||||
power_price as powerPrice,
|
||||
compute_formula as computeFormula
|
||||
from xhpc_activity_formula
|
||||
where activity_id = #{activityId}
|
||||
and start_time >= #{startTime} AND end_time <= #{endTime}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user