适配市对接平台

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 String phone;
public Double getMeterValueEndEvcs() {
return meterValueEndEvcs;
@ -629,4 +634,14 @@ public class XhpcHistoryOrder extends BaseEntity {
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("chargingTimeNumber",0);
data.put("serialNumber","0");
data.put("type","1");
data.put("type","-1");
data.put("parkingInstructions","在非充电情况下占用车位按照0.30元/分钟收费");
map.put("data", data);
}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.RestController;
import javax.persistence.criteria.CriteriaBuilder;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
@ -252,20 +253,25 @@ public class XhpcPileOrderController extends BaseController {
}
//总电费
BigDecimal powerPrice =new BigDecimal(0);
Integer totalPower =0;
if(!"0".equals(cacheOrderData.getT1PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){
BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee);
totalPower =totalPower+cacheOrderData.getT1PowerQuantity();
powerPrice=powerPrice.add(multiply);
}
//总服务费
@ -304,16 +310,33 @@ public class XhpcPileOrderController extends BaseController {
xhpcChargeOrder.setErroRemark(stopReason);
xhpcChargeOrder.setUpdateTime(date);
xhpcChargeOrder.setStatus(status);
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
//停止原因
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){}
//历史订单
Long userId = xhpcChargeOrder.getUserId();
//生成一条历史订单
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
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);
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) {
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) {
//开始时间结束时间
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, DateUtil.formatTime(startTime), i + ":59:59");
} else if (i != endHour + 1) {
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, endHour, number, i + ":00:00", i + ":59:59");
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, DateUtil.formatTime(startTime), i + ":59:59");
} else if (i != endHour) {
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, i + ":00:00", i + ":59:59");
} 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);
if (reatTimeList != null && reatTimeList.size() > 0) {
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 {
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();
Map<String, Object> map = reatTimeList.get(j);
BigDecimal size = new BigDecimal(reatTimeList.size());
@ -436,7 +436,7 @@ public class XhpcHistoryOrderController extends BaseController {
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
xhpcSt.setStatus(endHour+1);
xhpcSt.setStatus(status+1);
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
xhpcSt.setChargingTime(time5);
xhpcSt.setChargingNumber(1);

View File

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

View File

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

View File

@ -83,7 +83,7 @@
rto.charging_order_id as chargingOrderId,
rto.voltage as voltage,
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,
(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,
@ -332,6 +332,7 @@
select
operator_id as operatorId,
commission_type as commissionType,
operator_id_evcs as operatorIdEvcs,
soc as soc,
platform_commission_rate as platformCommissionRate,
maintenance_commission_rate as maintenanceCommissionRate

View File

@ -550,6 +550,7 @@
when co.type=47 then "手动停止充电.."
when co.type=48 then "急停停止充电"
when co.type=49 then "手动停止充电..."
else "手动停止充电!"
end typeName
FROM xhpc_history_order as ho
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 ">
#{terminalId},
</if>
<if test="null != chargingTimeNumber ">
#{chargingTimeNumber},
</if>
<if test="null != historyOrderId ">
#{historyOrderId}
</if>

View File

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

View File

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