适配市对接平台

This commit is contained in:
yuyang 2021-09-23 12:06:14 +08:00
parent 962b29cd9f
commit ee36497251
11 changed files with 78 additions and 25 deletions

View File

@ -226,6 +226,11 @@ public class XhpcHistoryOrder extends BaseEntity {
*/ */
private Double meterValueEndEvcs; private Double meterValueEndEvcs;
/**
* 充电用户手机号
*/
private String phone;
public Double getMeterValueEndEvcs() { public Double getMeterValueEndEvcs() {
return meterValueEndEvcs; return meterValueEndEvcs;
@ -629,4 +634,14 @@ public class XhpcHistoryOrder extends BaseEntity {
this.meterValueStartEvcs = meterValueStartEvcs; this.meterValueStartEvcs = meterValueStartEvcs;
} }
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
} }

View File

@ -150,7 +150,7 @@ public class XhpcChargeOrderController extends BaseController {
data.put("remainingTime","0"); data.put("remainingTime","0");
data.put("chargingTimeNumber",0); data.put("chargingTimeNumber",0);
data.put("serialNumber","0"); data.put("serialNumber","0");
data.put("type","1"); data.put("type","-1");
data.put("parkingInstructions","在非充电情况下占用车位按照0.30元/分钟收费"); data.put("parkingInstructions","在非充电情况下占用车位按照0.30元/分钟收费");
map.put("data", data); map.put("data", data);
}else{ }else{

View File

@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -252,20 +253,25 @@ public class XhpcPileOrderController extends BaseController {
} }
//总电费 //总电费
BigDecimal powerPrice =new BigDecimal(0); BigDecimal powerPrice =new BigDecimal(0);
Integer totalPower =0;
if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){ if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee); BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){ if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee); BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){ if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee); BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){ if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee); BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
//总服务费 //总服务费
@ -304,16 +310,33 @@ public class XhpcPileOrderController extends BaseController {
xhpcChargeOrder.setErroRemark(stopReason); xhpcChargeOrder.setErroRemark(stopReason);
xhpcChargeOrder.setUpdateTime(date); xhpcChargeOrder.setUpdateTime(date);
xhpcChargeOrder.setStatus(status); xhpcChargeOrder.setStatus(status);
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
//停止原因 //停止原因
try{ try{
xhpcChargeOrder.setType(Integer.parseInt(cacheOrderData.getStopReason())); if(!"".equals(stopReason) && stopReason!=null){
xhpcChargeOrder.setType(Integer.parseInt(stopReason));
if("40".equals(stopReason)){
xhpcHistoryOrder.setStopReasonEvcs(0);
}else if("42".equals(stopReason) || "43".equals(stopReason)||"44".equals(stopReason)){
xhpcHistoryOrder.setStopReasonEvcs(1);
}else if("41".equals(stopReason)){
xhpcHistoryOrder.setStopReasonEvcs(2);
}else if("48".equals(stopReason)){
xhpcHistoryOrder.setStopReasonEvcs(3);
}else{
xhpcHistoryOrder.setStopReasonEvcs(5);
}
}
}catch (Exception e){} }catch (Exception e){}
//历史订单 //历史订单
Long userId = xhpcChargeOrder.getUserId(); Long userId = xhpcChargeOrder.getUserId();
//生成一条历史订单 //生成一条历史订单
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setTotalPower(totalPower.doubleValue()/1000);
xhpcHistoryOrder.setMeterValueStartEvcs(cacheOrderData.getElectricMeterStart().doubleValue());
xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue());
Map<String, Object> userMessage = xhpcChargeOrderService.getUserMessage(userId); Map<String, Object> userMessage = xhpcChargeOrderService.getUserMessage(userId);
if (userMessage == null || userMessage.get("balance") == null) { if (userMessage == null || userMessage.get("balance") == null) {
//订单异常 //订单异常

View File

@ -361,15 +361,15 @@ public class XhpcHistoryOrderController extends BaseController {
private void addStatisTime(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour) { private void addStatisTime(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour) {
BigDecimal number = new BigDecimal(endHour + 1 - startHour); BigDecimal number = new BigDecimal(endHour + 1 - startHour);
for (int i = startHour; i <= endHour + 1; i++) { for (int i = startHour; i < endHour + 1; i++) {
//获取费率 //获取费率
if (i == startHour) { if (i == startHour) {
//开始时间结束时间 //开始时间结束时间
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, DateUtil.formatTime(startTime), i + ":59:59"); addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, DateUtil.formatTime(startTime), i + ":59:59");
} else if (i != endHour + 1) { } else if (i != endHour) {
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, i + ":00:00", i + ":59:59"); addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, i + ":00:00", i + ":59:59");
} else { } else {
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, i + ":00:00", DateUtil.formatTime(endTime)); addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, i + ":00:00", DateUtil.formatTime(endTime));
} }
} }
} }
@ -413,20 +413,20 @@ public class XhpcHistoryOrderController extends BaseController {
} }
} }
private void addStatis(XhpcChargeHistoryOrder xhpc, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int endHour, BigDecimal number, String start, String end) { private void addStatis(XhpcChargeHistoryOrder xhpc, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int status, BigDecimal number, String start, String end) {
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, end, rateModelId); List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, end, rateModelId);
if (reatTimeList != null && reatTimeList.size() > 0) { if (reatTimeList != null && reatTimeList.size() > 0) {
if (reatTimeList.size() == 1) { if (reatTimeList.size() == 1) {
addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, reatTimeList, 0, 1); addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, status, number, reatTimeList, 0, 1);
} else { } else {
for (int j = 0; j < reatTimeList.size(); j++) { for (int j = 0; j < reatTimeList.size(); j++) {
addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, reatTimeList, j, 2); addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, status, number, reatTimeList, j, 2);
} }
} }
} }
} }
private void addSte(XhpcChargeHistoryOrder xhpc, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int endHour, BigDecimal number, List<Map<String, Object>> reatTimeList, int j, int type) { private void addSte(XhpcChargeHistoryOrder xhpc, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int status, BigDecimal number, List<Map<String, Object>> reatTimeList, int j, int type) {
Date data = Calendar.getInstance().getTime(); Date data = Calendar.getInstance().getTime();
Map<String, Object> map = reatTimeList.get(j); Map<String, Object> map = reatTimeList.get(j);
BigDecimal size = new BigDecimal(reatTimeList.size()); BigDecimal size = new BigDecimal(reatTimeList.size());
@ -436,7 +436,7 @@ public class XhpcHistoryOrderController extends BaseController {
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString()); BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString()); BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval(); XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
xhpcSt.setStatus(endHour+1); xhpcSt.setStatus(status+1);
xhpcSt.setChargingDegree(xhpc.getChargingDegree()); xhpcSt.setChargingDegree(xhpc.getChargingDegree());
xhpcSt.setChargingTime(time5); xhpcSt.setChargingTime(time5);
xhpcSt.setChargingNumber(1); xhpcSt.setChargingNumber(1);

View File

@ -139,7 +139,7 @@ public interface IXhpcChargeOrderService {
/** /**
* 获取电桩信息 * 获取电桩信息
* @param chargingPileId * @param terminalId
* @return * @return
*/ */
Map<String,Object> getXhpcChargingPile(Long terminalId); Map<String,Object> getXhpcChargingPile(Long terminalId);

View File

@ -269,11 +269,14 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
xhpcHistoryOrder.setInternetCommission(internetCommission); xhpcHistoryOrder.setInternetCommission(internetCommission);
xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission); xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission);
}else{ }else{
//流量方未实现 //流量方未实现新增接口
} }
//获取运营商 //获取运营商
Map<String, Object> operatorMessage = xhpcChargeOrderService.getOperatorMessage(xhpcChargeOrder.getChargingStationId()); Map<String, Object> operatorMessage = xhpcChargeOrderService.getOperatorMessage(xhpcChargeOrder.getChargingStationId());
if(operatorMessage !=null){ if(operatorMessage !=null){
if(operatorMessage.get("operatorIdEvcs")!=null){
xhpcHistoryOrder.setOperatorIdEvcs(operatorMessage.get("operatorIdEvcs").toString());
}
if(operatorMessage.get("maintenanceCommissionRate") !=null && operatorMessage.get("commissionType") !=null && operatorMessage.get("platformCommissionRate") !=null){ if(operatorMessage.get("maintenanceCommissionRate") !=null && operatorMessage.get("commissionType") !=null && operatorMessage.get("platformCommissionRate") !=null){
Integer commissionType = (Integer) operatorMessage.get("commissionType"); Integer commissionType = (Integer) operatorMessage.get("commissionType");
//运维提成 //运维提成
@ -343,6 +346,11 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
xhpcHistoryOrder.setReconciliationStatus(0); xhpcHistoryOrder.setReconciliationStatus(0);
Date date = new Date(); Date date = new Date();
xhpcHistoryOrder.setCreateTime(date); xhpcHistoryOrder.setCreateTime(date);
xhpcHistoryOrder.setChargeModelEvcs(3);
xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString());
xhpcHistoryOrder.setPhone(userMessage.get("phone").toString());
xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower()));
//扣除用户实际消费金额添加消费记录 //扣除用户实际消费金额添加消费记录
Map<String, Object> user = xhpcChargeOrderService.getUserMessage(userId); Map<String, Object> user = xhpcChargeOrderService.getUserMessage(userId);
//剩余的钱 //剩余的钱
@ -359,10 +367,18 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date);
try{ try{
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
if(xhpcChargingPile !=null){
//发送短信 //发送短信
if(user.get("phone") !=null){ if(user.get("phone") !=null){
if("1".equals(xhpcChargingPile.get("type").toString())){
String content = "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。"; String content = "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。";
smsService.sendNotice(user.get("phone").toString(),content); smsService.sendNotice(user.get("phone").toString(),content);
}else{
String content = "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。";
smsService.sendNotice(user.get("phone").toString(),content);
}
}
} }
}catch (Exception e){ }catch (Exception e){
logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>");

View File

@ -83,7 +83,7 @@
rto.charging_order_id as chargingOrderId, rto.charging_order_id as chargingOrderId,
rto.voltage as voltage, rto.voltage as voltage,
rto.charging_time_number as chargingTimeNumber, rto.charging_time_number as chargingTimeNumber,
concat(rto.pile_number,"",rto.gun_number)as seriaNumber, concat(rto.pile_number,"",rto.gun_number)as serialNumber,
rto.electric_current as electricCurrent, rto.electric_current as electricCurrent,
(select power from xhpc_charging_pile where charging_pile_id= (select power from xhpc_charging_pile where charging_pile_id=
(select charging_pile_id from xhpc_charging_pile where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power, (select charging_pile_id from xhpc_charging_pile where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power,
@ -332,6 +332,7 @@
select select
operator_id as operatorId, operator_id as operatorId,
commission_type as commissionType, commission_type as commissionType,
operator_id_evcs as operatorIdEvcs,
soc as soc, soc as soc,
platform_commission_rate as platformCommissionRate, platform_commission_rate as platformCommissionRate,
maintenance_commission_rate as maintenanceCommissionRate maintenance_commission_rate as maintenanceCommissionRate

View File

@ -550,6 +550,7 @@
when co.type=47 then "手动停止充电.." when co.type=47 then "手动停止充电.."
when co.type=48 then "急停停止充电" when co.type=48 then "急停停止充电"
when co.type=49 then "手动停止充电..." when co.type=49 then "手动停止充电..."
else "手动停止充电!"
end typeName end typeName
FROM xhpc_history_order as ho FROM xhpc_history_order as ho
LEFT JOIN xhpc_charging_station as cs on cs.charging_station_id = ho.charging_station_id LEFT JOIN xhpc_charging_station as cs on cs.charging_station_id = ho.charging_station_id

View File

@ -492,9 +492,6 @@
<if test="null != terminalId "> <if test="null != terminalId ">
#{terminalId}, #{terminalId},
</if> </if>
<if test="null != chargingTimeNumber ">
#{chargingTimeNumber},
</if>
<if test="null != historyOrderId "> <if test="null != historyOrderId ">
#{historyOrderId} #{historyOrderId}
</if> </if>

View File

@ -31,7 +31,7 @@ public class AlipayPaymentController {
@GetMapping("/payment") @GetMapping("/payment")
@ApiOperation(value = "微信支付") @ApiOperation(value = "支付宝支付")
private String newPay() throws Exception { private String newPay() throws Exception {
String orderNumber = "alipay" + DateUtils.timePath(); String orderNumber = "alipay" + DateUtils.timePath();

View File

@ -114,7 +114,7 @@ public class OrderNotificationWebSocket {
data.put("remainingTime","0"); data.put("remainingTime","0");
data.put("serialNumber","0"); data.put("serialNumber","0");
data.put("parkingInstructions","在非充电情况下占用车位按照0.30元/分钟收费"); data.put("parkingInstructions","在非充电情况下占用车位按照0.30元/分钟收费");
data.put("type", "1"); data.put("type", "-1");
map.put("data", data); map.put("data", data);
JSONObject json = new JSONObject(map); JSONObject json = new JSONObject(map);
sendMessage(this.userId,json.toString()); sendMessage(this.userId,json.toString());