From ee36497251fd6903a2906ebef10a7b4745174a27 Mon Sep 17 00:00:00 2001 From: yuyang <2265829957@qq.com> Date: Thu, 23 Sep 2021 12:06:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E5=B8=82=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/order/domain/XhpcHistoryOrder.java | 15 +++++++++++ .../order/api/XhpcChargeOrderController.java | 2 +- .../order/api/XhpcPileOrderController.java | 27 +++++++++++++++++-- .../XhpcHistoryOrderController.java | 20 +++++++------- .../service/IXhpcChargeOrderService.java | 2 +- .../impl/XhpcRealTimeOrderServiceImpl.java | 26 ++++++++++++++---- .../mapper/XhpcChargeOrderMapper.xml | 3 ++- .../mapper/XhpcHistoryOrderMapper.xml | 1 + .../resources/mapper/XhpcStatisticsMapper.xml | 3 --- .../controller/AlipayPaymentController.java | 2 +- .../socket/OrderNotificationWebSocket.java | 2 +- 11 files changed, 78 insertions(+), 25 deletions(-) diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java index aa49f3fe..390c6c1b 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java @@ -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; + } + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java index 16e80cf5..622b8bb3 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java @@ -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{ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java index d0bcd78b..c024de0f 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcPileOrderController.java @@ -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 userMessage = xhpcChargeOrderService.getUserMessage(userId); if (userMessage == null || userMessage.get("balance") == null) { //订单异常 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index b9c99e43..0df55c2f 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -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> 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> reatTimeList, int j, int type) { + private void addSte(XhpcChargeHistoryOrder xhpc, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int status, BigDecimal number, List> reatTimeList, int j, int type) { Date data = Calendar.getInstance().getTime(); Map 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); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 2f8c9ad2..c82baf37 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -139,7 +139,7 @@ public interface IXhpcChargeOrderService { /** * 获取电桩信息 - * @param chargingPileId + * @param terminalId * @return */ Map getXhpcChargingPile(Long terminalId); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index c3d59fc9..a10edfbf 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -269,11 +269,14 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { xhpcHistoryOrder.setInternetCommission(internetCommission); xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission); }else{ - //流量方,未实现 + //流量方,未实现,新增接口 } //获取运营商 Map 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 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 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("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index 2a34d655..9ec23042 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -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 diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 665cf7c9..763f39b2 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -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 diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index a7d9f05e..30f89179 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -492,9 +492,6 @@ #{terminalId}, - - #{chargingTimeNumber}, - #{historyOrderId} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java index 0c19ab57..aceff8c7 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/AlipayPaymentController.java @@ -31,7 +31,7 @@ public class AlipayPaymentController { @GetMapping("/payment") - @ApiOperation(value = "微信支付") + @ApiOperation(value = "支付宝支付") private String newPay() throws Exception { String orderNumber = "alipay" + DateUtils.timePath(); diff --git a/xhpc-modules/xhpc-wxma/src/main/java/com/xhpc/wxma/socket/OrderNotificationWebSocket.java b/xhpc-modules/xhpc-wxma/src/main/java/com/xhpc/wxma/socket/OrderNotificationWebSocket.java index 2354ca78..4de3ea1c 100644 --- a/xhpc-modules/xhpc-wxma/src/main/java/com/xhpc/wxma/socket/OrderNotificationWebSocket.java +++ b/xhpc-modules/xhpc-wxma/src/main/java/com/xhpc/wxma/socket/OrderNotificationWebSocket.java @@ -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());