diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java index 578683bf..73a1f975 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingStationServiceImpl.java @@ -702,8 +702,7 @@ public class XhpcChargingStationServiceImpl extends BaseService implements IXhpc if (map !=null &&map.get("imgId") != null && map.get("imgId").toString() != "") { String[] split = map.get("imgId").toString().split(","); imgList = Arrays.asList(split); - List> imgLists = xhpcChargingStationMapper.getImageList(imgList); - map.put("imgIdList", imgLists); + map.put("imgIdList", imgList); } else { map.put("imgIdList", new ArrayList<>()); } 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 9097e60a..ce6e1d44 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 @@ -378,22 +378,22 @@ 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); + BigDecimal multiply = new BigDecimal(cacheOrderData.getT1PowerQuantity()).divide(bigDecimal).multiply(t1powerFee).setScale(2, BigDecimal.ROUND_HALF_UP); totalPower =totalPower+cacheOrderData.getT1PowerQuantity(); powerPrice=powerPrice.add(multiply); } 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).setScale(2, BigDecimal.ROUND_HALF_UP); totalPower =totalPower+cacheOrderData.getT2PowerQuantity(); powerPrice=powerPrice.add(multiply); } 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).setScale(2, BigDecimal.ROUND_HALF_UP); totalPower =totalPower+cacheOrderData.getT3PowerQuantity(); powerPrice=powerPrice.add(multiply); } 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).setScale(2, BigDecimal.ROUND_HALF_UP); totalPower =totalPower+cacheOrderData.getT4PowerQuantity(); powerPrice=powerPrice.add(multiply); } @@ -433,7 +433,7 @@ public class XhpcPileOrderController extends BaseController { xhpcChargeOrder.setChargingTime(new BigDecimal(mins).setScale(0) + "分"); } xhpcChargeOrder.setChargingTimeNumber(tiem); - BigDecimal divide = new BigDecimal(cacheOrderData.getTotalPowerQuantity()).divide(bigDecimal); + BigDecimal divide = new BigDecimal(cacheOrderData.getTotalPowerQuantity()).divide(bigDecimal,2, BigDecimal.ROUND_HALF_UP); xhpcChargeOrder.setChargingDegree(divide); xhpcChargeOrder.setAmountCharged(money); String stopReason = cacheOrderData.getStopReason(); @@ -474,7 +474,6 @@ public class XhpcPileOrderController extends BaseController { return R.fail(500,"添加订单回调失败"); } }else{ - if(pushOrder !=null){ if(pushOrder.get("internetSerialNumber") !=null){ xhpcHistoryOrder.setInternetSerialNumber(pushOrder.get("internetSerialNumber").toString()); 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 39702a06..cbd616f2 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 @@ -878,52 +878,44 @@ public class XhpcHistoryOrderController extends BaseController { //@Scheduled(cron = "0 0/5 * * * ?") public void test4(){ //获取异常的订单 24小时之外的异常订单 - List xhpcChargeOrderList= chargeOrderService.getXhpcChargeOrderStatus(2, 0); + List> xhpcChargeOrderList= chargeOrderService.getXhpcChargeOrderStatus(2); if(xhpcChargeOrderList !=null && xhpcChargeOrderList.size()>0){ for (int i = 0; i userMessage = (Map)user.getData(); - if (userMessage != null && userMessage.get("balance") != null) { - xhpcHistoryOrderService.addXhpcChargeOrder(userMessage,xhpcChargeOrder.getSerialNumber(),2); - } + Map 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); } - }else{ - xhpcHistoryOrderService.addXhpcChargeOrder(null,xhpcChargeOrder.getSerialNumber(),2); } } } } - - @GetMapping("/getManualAudit") - public void getManualAudit(Long chargeOrderId){ + @GetMapping("/test44") + public void test44(){ //获取异常的订单 24小时之外的异常订单 - XhpcChargeOrder xhpcChargeOrder = chargeOrderService.getChargingOrderId(chargeOrderId); - if(xhpcChargeOrder !=null){ - Integer source = xhpcChargeOrder.getSource(); - String tenantId = xhpcChargeOrder.getTenantId(); - xhpcChargeOrder.getChargeOrderId(); - if(!UserTypeUtil.INTERNET_TYPE.equals(source)){ - R user = userTypeService.getUser(null, xhpcChargeOrder.getUserId(), source, null, tenantId); - if(user !=null && user.getData() !=null){ - Map userMessage = (Map)user.getData(); - if (userMessage != null && userMessage.get("balance") != null) { - xhpcHistoryOrderService.addXhpcChargeOrder(userMessage,xhpcChargeOrder.getSerialNumber(),2); + List> xhpcChargeOrderList= chargeOrderService.getXhpcChargeOrderStatus(2); + + if(xhpcChargeOrderList !=null && xhpcChargeOrderList.size()>0){ + for (int i = 0; i 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); } } - }else{ - xhpcHistoryOrderService.addXhpcChargeOrder(null,xhpcChargeOrder.getSerialNumber(),2); } } } - - /** * 标记异常大于创建4小时,标记为异常 * @param diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java index 7d864d68..1d8fed32 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcRealTimeOrderController.java @@ -93,7 +93,7 @@ public class XhpcRealTimeOrderController extends BaseController { */ @GetMapping("/getExamineMessage") public AjaxResult getExamineMessage(Long realTimeOrderId,Long chargeOrderId){ - return xhpcRealTimeOrderService.getExamineMessage(realTimeOrderId,chargeOrderId); + return AjaxResult.success(xhpcRealTimeOrderService.getExamineMessage(realTimeOrderId,chargeOrderId)); } /** diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index c79fbff3..93eb28f7 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -175,7 +175,7 @@ public interface XhpcChargeOrderMapper { * @param source 0C端用户 1流量用户 * @return */ - List getXhpcChargeOrderStatus(@Param("status") Integer status, @Param("source") Integer source); + List> getXhpcChargeOrderStatus(@Param("status") Integer status); /** * insert a row by 3rd. 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 0dbdedf4..ff910b34 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 @@ -146,13 +146,11 @@ public interface IXhpcChargeOrderService { */ Map getXhpcChargingPile(Long terminalId); + /** - * 获取一次订单 - * @param status -1准备充电 0开始充电 1自动结算,2异常,3平台结算 - * @param source 0C端用户 1流量用户 - * @return + * 24小时异常结算 */ - List getXhpcChargeOrderStatus(Integer status,Integer source); + List> getXhpcChargeOrderStatus(Integer status); R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index 8d6168a9..917a0705 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -101,11 +101,9 @@ public interface IXhpcHistoryOrderService { /** - * 结算订单 - * @param orderNo 订单号 - * @param type 状态 1.异常 2.解决异常订单 + * 异常订单24小时自动结算 */ - void addXhpcChargeOrder(Map userMessage,String orderNo,Integer type); + void addXhpcChargeOrder(Long realTimeOrderId,Long chargeOrderId); /** diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java index 2a71cae3..0639a628 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcRealTimeOrderService.java @@ -93,7 +93,7 @@ public interface IXhpcRealTimeOrderService { * @param realTimeOrderId * @return */ - AjaxResult getExamineMessage(Long realTimeOrderId,Long chargeOrderId); + Map getExamineMessage(Long realTimeOrderId,Long chargeOrderId); /** * 审核 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index d6d413d0..efdec9d5 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -448,8 +448,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar } @Override - public List getXhpcChargeOrderStatus(Integer status, Integer source) { - return xhpcChargeOrderMapper.getXhpcChargeOrderStatus(status, source); + public List> getXhpcChargeOrderStatus(Integer status) { + return xhpcChargeOrderMapper.getXhpcChargeOrderStatus(status); } @Override diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index e55e3548..d9e779bf 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -404,379 +404,15 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis } @Override - public void addXhpcChargeOrder(Map userMessage,String orderNo, Integer type) { + public void addXhpcChargeOrder(Long realTimeOrderId,Long chargeOrderId) { //(调用时间-启动时间《3分钟 自动结算) - logger.info("订单异常回调接口>>>>>orderNo:" + orderNo + " type:" + type); - //获取实时订单 - CacheRealtimeData cacheRealtimeData = redisService.getCacheObject("order:" + orderNo + ".lord"); - if (cacheRealtimeData != null) { - XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo); - Long userId = xhpcChargeOrder.getUserId(); - try { - //开始时间 - Date startTime2 = xhpcChargeOrder.getStartTime(); - //当checking为true时,自动结算 - Integer chargingTime = cacheRealtimeData.getChargingTime(); - boolean checking = false; - if (type == 1) { - if (chargingTime < 3) { - checking = true; - } - } else { - checking = true; - } - - //毫秒 - DateTime date = DateUtil.offsetMinute(xhpcChargeOrder.getStartTime(), chargingTime); - xhpcChargeOrder.setEndTime(date); - xhpcChargeOrder.setUpdateTime(date); - if (checking) { - xhpcChargeOrder.setStatus(3); - } else { - xhpcChargeOrder.setStatus(2); - } - xhpcChargeOrder.setEndSoc(cacheRealtimeData.getSoc() + ""); - //充电时长 - long time = (long) (cacheRealtimeData.getChargingTime() / 1000); - if (time > 3600) { - long hours = time / 3600; - double mins = (double) ((time - (hours * 3600)) / 60); - xhpcChargeOrder.setChargingTime(hours + "时" + new BigDecimal(mins).setScale(0) + "分"); - } else { - double mins = (double) (time / 60); - xhpcChargeOrder.setChargingTime(new BigDecimal(mins).setScale(0) + "分"); - } - BigDecimal decimal = new BigDecimal(10000); - xhpcChargeOrder.setChargingDegree(new BigDecimal(cacheRealtimeData.getChargingDegree()).divide(decimal, 2, BigDecimal.ROUND_HALF_UP)); - xhpcChargeOrder.setAmountCharged(new BigDecimal(cacheRealtimeData.getAmountCharged()).divide(decimal, 2, BigDecimal.ROUND_HALF_UP)); - xhpcChargeOrder.setChargingTimeNumber(Long.valueOf(cacheRealtimeData.getChargingTime())); - - if (checking) { - BigDecimal money = xhpcChargeOrder.getAmountCharged(); - //结算 - //总电费 - BigDecimal powerPrice = new BigDecimal(0); - //算时间是否跨天 - Long rateModelId = xhpcChargeOrder.getRateModelId(); - - Date updateTime2 = xhpcChargeOrder.getEndTime(); - long betweenDay = DateUtil.between(startTime2, updateTime2, DateUnit.DAY); - - if (betweenDay == 0) { - powerPrice = getBigDecimal(rateModelId, startTime2, updateTime2, xhpcChargeOrder.getChargingDegree()); - } else { - //跨天 - Date updateTime = DateUtil.endOfDay(startTime2); - powerPrice = getBigDecimal(rateModelId, startTime2, updateTime, xhpcChargeOrder.getChargingDegree()); - //明天 - DateTime tomorrow = DateUtil.offsetDay(startTime2, 1); - Date startTime3 = DateUtil.beginOfDay(tomorrow); - powerPrice = powerPrice.add(getBigDecimal(rateModelId, startTime3, updateTime2, xhpcChargeOrder.getChargingDegree())); - } - - //总服务费 - BigDecimal servicePrice = money.subtract(powerPrice); - //剩余的电费 - BigDecimal surplusPowerPrice = powerPrice; - //剩余的服务费 - BigDecimal surplusServicePrice = servicePrice; - Integer source = xhpcChargeOrder.getSource(); - String tenantId = xhpcChargeOrder.getTenantId(); - XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder(); - xhpcChargeOrder.setType("平台停止"); - xhpcHistoryOrder.setStopReasonEvcs("平台停止"); - xhpcHistoryOrder.setPowerPriceTotal(powerPrice); - xhpcHistoryOrder.setServicePriceTotal(servicePrice); - xhpcHistoryOrder.setTotalPower(cacheRealtimeData.getAmountCharged().doubleValue() / 10000); - //电表总起值 - //xhpcHistoryOrder.setMeterValueStartEvcs(cacheOrderData.getElectricMeterStart().doubleValue()); - //电表总止值 - //xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue()); - //vin - //xhpcHistoryOrder.setVinNormal(vinNormal); - BigDecimal balance = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(100)); - //电站活动抵扣--抵扣的总金额 - BigDecimal promotionDiscount = new BigDecimal(0); - - //实际价格-用户支付的钱 - BigDecimal actPrice = money; - //流量方总金额抽成 - BigDecimal internetCommission = new BigDecimal(0); - //流量方服务费抽成 - BigDecimal internetSvcCommission = new BigDecimal(0); - //流量方电量抽成 - BigDecimal internetDegreeCommission =new BigDecimal(0); - //平台总金额抽成 - BigDecimal platformCommission = new BigDecimal(0); - //平台服务费抽成 - BigDecimal platformSvcCommission = new BigDecimal(0); - //运维总抽成 - BigDecimal operationCommission = new BigDecimal(0); - //运维服务费抽成 - BigDecimal operationSvcCommission = new BigDecimal(0); - - //判断是C端用户还是流量端用户 - //先计算第三方优惠力度 - - String internetSerialNumber = xhpcChargeOrder.getInternetSerialNumber(); - if(source==1 && internetSerialNumber!=null){ - String substring = internetSerialNumber.substring(0, 9); - xhpcHistoryOrder.setInternetSerialNumber(xhpcChargeOrder.getInternetSerialNumber()); - Map 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_HALF_UP); - BigDecimal decimal2 = surplusServicePrice.multiply(commissionRate).setScale(2, BigDecimal.ROUND_HALF_UP); - 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_HALF_UP); - internetSvcCommission = decimal2; - surplusServicePrice = surplusServicePrice.subtract(decimal2); - }else{ - //电量抽成 - BigDecimal chargingDegree = xhpcChargeOrder.getChargingDegree(); - internetDegreeCommission = chargingDegree.multiply(new BigDecimal(operatorIdEvcs.get("commissionRate").toString())).setScale(2, BigDecimal.ROUND_HALF_UP); - //减服务费 - surplusServicePrice = surplusServicePrice.subtract(internetDegreeCommission); - } - } - } - } - } - } - if ( !UserTypeUtil.INTERNET_TYPE.equals(source)) { - //用户第几次充电 - int count = xhpcChargeOrderService.getCount(userId,null,source,xhpcChargeOrder.getTenantId()); - if (count == 0) { - //活动折扣 - Map promotion = xhpcChargeOrderService.getPromotion(); - if (promotion != null && promotion.get("state") != null && promotion.get("discount") != null) { - //state 1.总金额 2.电费 3.服务费 discount 折扣率 - String state = promotion.get("state").toString(); - BigDecimal discount =new BigDecimal(promotion.get("discount").toString()).divide(new BigDecimal(100)); - - if(discount.compareTo(new BigDecimal(0))==1){ - if("1".equals(state) || "2".equals(state) || "3".equals(state)){ - //折扣的钱 - promotionDiscount=money.multiply(discount).setScale(2,BigDecimal.ROUND_HALF_UP); - //剩余的总金额 - actPrice = money.subtract(promotionDiscount); - - BigDecimal decimal1 = surplusPowerPrice.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); - BigDecimal decimal2 = surplusServicePrice.multiply(discount).setScale(2, BigDecimal.ROUND_HALF_UP); - if("1".equals(state)){ - //总金额 - actPrice =actPrice.subtract(decimal1.add(decimal2)); - //折扣的钱 - promotionDiscount = decimal1.add(decimal2); - surplusPowerPrice = surplusPowerPrice.subtract(decimal1); - surplusServicePrice= surplusServicePrice.subtract(decimal2); - }else if("2".equals(state)){ - //电费 - surplusPowerPrice=surplusPowerPrice.subtract(decimal1); - }else{ - //服务费 - surplusServicePrice =surplusServicePrice.subtract(decimal2); - } - } - } - } - } - } - //获取运营商 - Map operatorMessage = xhpcChargeOrderService.getOperatorMessage(xhpcChargeOrder.getChargingStationId()); - if(operatorMessage !=null){ - if(operatorMessage.get("operatorIdEvcs")!=null){ - - if(operatorMessage.get("operatorIdEvcs") !=null && !"".equals(operatorMessage.get("operatorIdEvcs").toString())){ - String stw = operatorMessage.get("operatorIdEvcs").toString(); - if(stw.length()>9){ - xhpcHistoryOrder.setOperatorIdEvcs(stw.substring(8, stw.length() - 1)); - } - } - } - if(operatorMessage.get("maintenanceCommissionRate") !=null && operatorMessage.get("commissionType") !=null && operatorMessage.get("platformCommissionRate") !=null){ - Integer commissionType = (Integer) operatorMessage.get("commissionType"); - //运维提成 - BigDecimal maintenanceCommissionRate = new BigDecimal(operatorMessage.get("maintenanceCommissionRate").toString()).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP); - //平台提成 - BigDecimal platformCommissionRate = new BigDecimal(operatorMessage.get("platformCommissionRate").toString()).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP); - //提成类型(0总金额提成 1服务费提成) - if(commissionType==0){ - //平台总抽成 - BigDecimal multiply1 = surplusPowerPrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal multiply2 = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - //运维总抽成 - BigDecimal multiply3 = surplusPowerPrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal multiply4 = surplusServicePrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - - //平台总金额抽成 - platformCommission = multiply1.add(multiply2); - //剩下的钱电费和服务 - surplusPowerPrice = surplusPowerPrice.subtract(multiply1); - surplusServicePrice = surplusServicePrice.subtract(multiply2); - - //运维总金额抽成 - operationCommission = multiply3.add(multiply4); - //剩下的钱电费和服务 - surplusPowerPrice = surplusPowerPrice.subtract(multiply3); - surplusServicePrice = surplusServicePrice.subtract(multiply4); - - }else if(commissionType==1){ - BigDecimal multiply1 = surplusServicePrice.multiply(platformCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - BigDecimal multiply2 = surplusServicePrice.multiply(maintenanceCommissionRate).setScale(2,BigDecimal.ROUND_HALF_UP); - //平台服务费抽成金额 - platformSvcCommission=multiply1; - //剩下的服务费钱 - surplusServicePrice = surplusServicePrice.subtract(multiply1); - - //运维服务费抽成金额 - operationCommission = multiply2; - //剩下的钱 - surplusServicePrice = surplusServicePrice.subtract(multiply2); - } - if("微信".equals(xhpcChargeOrder.getChargingMode())){ - xhpcHistoryOrder.setChargingMode("微信"); - } - if("支付宝".equals(xhpcChargeOrder.getChargingMode())){ - xhpcHistoryOrder.setChargingMode("支付宝"); - } - }else{ - //订单异常 - xhpcChargeOrder.setStatus(2); - //异常原因 - xhpcChargeOrder.setErroRemark("运营商数据为空"); - } - } - - Long chargeOrderId = xhpcChargeOrder.getChargeOrderId(); - xhpcHistoryOrder.setChargeOrderId(chargeOrderId); - xhpcHistoryOrder.setChargingStationId(xhpcChargeOrder.getChargingStationId()); - xhpcHistoryOrder.setUserId(userId); - xhpcHistoryOrder.setTerminalId(xhpcChargeOrder.getTerminalId()); - xhpcHistoryOrder.setStartTime(xhpcChargeOrder.getStartTime()); - xhpcHistoryOrder.setChargeModelEvcs(xhpcChargeOrder.getChargeModelEvcs()); - xhpcHistoryOrder.setSerialNumber(xhpcChargeOrder.getSerialNumber()); - xhpcHistoryOrder.setRateModelId(xhpcChargeOrder.getRateModelId()); - xhpcHistoryOrder.setStartSoc(xhpcChargeOrder.getStartSoc()); - xhpcHistoryOrder.setReconciliationStatus(0); - xhpcHistoryOrder.setSortingStatus(0); - xhpcHistoryOrder.setType(1); - //订单总价---运维服务费抽成 - xhpcHistoryOrder.setTotalPrice(money.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setPromotionDiscount(promotionDiscount.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setActPrice(actPrice.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setActPowerPrice(surplusPowerPrice.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setActServicePrice(surplusServicePrice.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setInternetCommission(internetCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setInternetSvcCommission(internetSvcCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setInternetDegreeCommission(internetDegreeCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setPlatformCommission(platformCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setPlatformSvcCommisssion(platformSvcCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setOperationCommission(operationCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setOperationSvcCommission(operationSvcCommission.setScale(2, BigDecimal.ROUND_HALF_UP)); - xhpcHistoryOrder.setStartSoc(xhpcChargeOrder.getStartSoc()); - xhpcHistoryOrder.setEndSoc(xhpcChargeOrder.getEndSoc()); - xhpcHistoryOrder.setReconciliationStatus(0); - xhpcHistoryOrder.setCreateTime(new Date()); - xhpcHistoryOrder.setChargeModelEvcs(3); - xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString()); - xhpcHistoryOrder.setPhone(userMessage.get("phone").toString()); - if(xhpcChargeOrder.getPower()!=null){ - xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower())); - } - Map map =new HashMap<>(); - if(!UserTypeUtil.INTERNET_TYPE.equals(source)){ - xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString()); - xhpcHistoryOrder.setPhone(userMessage.get("phone").toString()); - //增加流水订单号 - if(operatorMessage!=null && operatorMessage.get("operatorId")!=null){ - String evcs = EvcsUtil.transferInternetOrderNo(xhpcChargeOrder.getSerialNumber(), operatorMessage.get("operatorId").toString()); - xhpcHistoryOrder.setEvcsOrderNo(evcs); - } - - //扣除用户实际消费金额,添加消费记录-余的钱 - BigDecimal balance1 =new BigDecimal(userMessage.get("balance").toString()); - BigDecimal subtract = balance1.subtract(actPrice); - int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,source,xhpcChargeOrder.getTenantId()); - if(i==0){ - //扣钱失败 - xhpcChargeOrder.setStatus(2); - xhpcChargeOrder.setErroRemark("扣钱失败"); - }else{ - //添加流水 - xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,source); - map.put("userId",userId); - map.put("amount",subtract); - map.put("source",xhpcChargeOrder.getSource()); - map.put("tenantId",xhpcChargeOrder.getTenantId()); - if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){ - map.put("openid",userMessage.get("weixinOpenId").toString()); - map.put("type",1); - }else{ - map.put("openid",userMessage.get("alipayOpenId").toString()); - map.put("type",2); - } - map.put("remark","充电结算自动申请退款"); - } - try{ - Map xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId()); - if(xhpcChargingPile !=null){ - //发送短信 - if(userMessage.get("phone") !=null){ - if("1".equals(xhpcChargingPile.get("type").toString())){ - HashMap paramMap = new HashMap<>(); - paramMap.put("elec", xhpcChargeOrder.getEndSoc()); - paramMap.put("sumMoney", actPrice.toString()); - paramMap.put("phone", userMessage.get("phone").toString()); - paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。"); - smsService.sendNotice(paramMap); - }else { - HashMap paramMap = new HashMap<>(); - paramMap.put("sumMoney", actPrice.toString()); - paramMap.put("phone", userMessage.get("phone").toString()); - paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。"); - smsService.sendNotice(paramMap); - } - } - } - }catch (Exception e){ - logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); - } - } - insert(xhpcHistoryOrder); - // 另起线程处理业务上传redis数据 - executorService.execute(new Runnable() { - @Override - public void run() { - //充电结算后自动申请退款 - if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){ - refundOrderService.sendNotice(map.get("subtract").toString(),map.get("openid").toString(),source,map.get("type").toString(),map.get("userId").toString(),xhpcChargeOrder.getTenantId(),map.get("remark").toString()); - } - xhpcRealTimeOrderService.addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(), 1); - } - }); - } - xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); - } catch (Exception e) { - logger.info("异常订单回调失败"); - e.printStackTrace(); - } + logger.info("订单异常回调接口>>>>>realTimeOrderId:" + realTimeOrderId + " chargeOrderId:" + chargeOrderId); + Map map = xhpcRealTimeOrderService.getExamineMessage(realTimeOrderId,chargeOrderId); + if(map !=null){ + BigDecimal powerPriceTotal = new BigDecimal(map.get("powerPriceTotal").toString()); + BigDecimal servicePriceTotal = new BigDecimal(map.get("servicePriceTotal").toString()); + xhpcRealTimeOrderService.getExamine(chargeOrderId,powerPriceTotal,servicePriceTotal); } - - } @Override 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 870aa1c0..93381225 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 @@ -170,16 +170,14 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe @Transactional @Override - public AjaxResult getExamineMessage(Long realTimeOrderId,Long chargeOrderId) { + public Map getExamineMessage(Long realTimeOrderId,Long chargeOrderId) { if(realTimeOrderId==null){ Map message = xhpcRealTimeOrderMapper.getMessageChargeOrderId(chargeOrderId); message.put("powerPriceTotal",0); message.put("servicePriceTotal",0); - return AjaxResult.success(message); + return message; } - - //基本信息 Map message = xhpcRealTimeOrderMapper.getMessage(realTimeOrderId); try{ @@ -200,7 +198,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe endData =list.get(list.size()-1); for (int i = 0; i 0 && startData.getChargingTime()>0){ + if(startData.getAmountCharged()>0 && startData.getChargingTime()>0){ break; } } @@ -261,7 +259,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe if(startRealTimeOrder.getRealTimeOrderId().equals(startRealTimeOrder.getRealTimeOrderId())){ message.put("powerPriceTotal",0); message.put("servicePriceTotal",0); - return AjaxResult.success(message); + return message; } chargeOrder.setStartTime(startTime); @@ -275,7 +273,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe chargeOrder.setChargingTimeNumber(0L); } chargeOrder.setChargingDegree(chargingDegree); - chargeOrder.setType("平台停止"); + chargeOrder.setType("平台停止充电"); chargeOrder.setAmountCharged(endRealTimeOrder.getAmountCharged()); } @@ -323,7 +321,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe message.put("powerPriceTotal",0); message.put("servicePriceTotal",0); } - return AjaxResult.success(message); + return message; } @@ -349,7 +347,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe xhpcChargeOrder.setStatus(3); xhpcChargeOrder.setAmountCharged(money); xhpcChargeOrder.setStopReasonEvcs(45); - + xhpcChargeOrder.setType("平台停止充电"); Long userId = xhpcChargeOrder.getUserId(); Integer source = xhpcChargeOrder.getSource(); String tenantId = xhpcChargeOrder.getTenantId(); 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 2309337a..17ed3b59 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -577,13 +577,15 @@ where charging_pile_id = (select charging_pile_id from xhpc_terminal where terminal_id = #{terminalId} and del_flag =0) and del_flag =0 - + select + xco.charge_order_id as chargeOrderId, + max(xrt.real_time_order_id) as realTimeOrderId + from xhpc_charge_order as xco + left join xhpc_real_time_order as xrt on xrt.charging_order_id = xco.charge_order_id + where xco.del_flag = 0 + and xco.status = #{status} + and datediff(now(), xco.create_time) > 1