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 65c47b4a..70eb9d1e 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 @@ -261,17 +261,17 @@ public class XhpcPileOrderController extends BaseController { } if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){ BigDecimal multiply = new BigDecimal(cacheOrderData.getT2PowerQuantity()).divide(bigDecimal).multiply(t2powerFee); - totalPower =totalPower+cacheOrderData.getT1PowerQuantity(); + totalPower =totalPower+cacheOrderData.getT2PowerQuantity(); powerPrice=powerPrice.add(multiply); } if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){ BigDecimal multiply = new BigDecimal(cacheOrderData.getT3PowerQuantity()).divide(bigDecimal).multiply(t3powerFee); - totalPower =totalPower+cacheOrderData.getT1PowerQuantity(); + totalPower =totalPower+cacheOrderData.getT3PowerQuantity(); powerPrice=powerPrice.add(multiply); } if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){ BigDecimal multiply = new BigDecimal(cacheOrderData.getT4PowerQuantity()).divide(bigDecimal).multiply(t4powerFee); - totalPower =totalPower+cacheOrderData.getT1PowerQuantity(); + totalPower =totalPower+cacheOrderData.getT4PowerQuantity(); powerPrice=powerPrice.add(multiply); } //总服务费 @@ -334,7 +334,7 @@ public class XhpcPileOrderController extends BaseController { xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice); - xhpcHistoryOrder.setTotalPower(totalPower.doubleValue()/1000); + xhpcHistoryOrder.setTotalPower(totalPower.doubleValue()/10000); xhpcHistoryOrder.setMeterValueStartEvcs(cacheOrderData.getElectricMeterStart().doubleValue()); xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue()); Map userMessage = xhpcChargeOrderService.getUserMessage(userId); @@ -347,7 +347,7 @@ public class XhpcPileOrderController extends BaseController { R.ok(); } //结算 - xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal()); + xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder); Map map = new HashMap<>(); map.put("code", 500); map.put("userId", userId); 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 5b813b21..c47a9576 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 @@ -15,6 +15,7 @@ import com.xhpc.order.service.IXhpcHistoryOrderService; import com.xhpc.order.service.IXhpcStatisticsService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -75,73 +76,30 @@ public class XhpcHistoryOrderController extends BaseController { * 终端统计 */ @GetMapping("/test3") + @Scheduled(cron = "0 0 12 * * ?") public void test3(){ - add(500,3); + add(100,3); } /** * 场站统计 */ @GetMapping("/test2") + @Scheduled(cron = "0 0 11 * * ?") public void test2(){ - add(500,2); + add(100,2); } - - public void add(int number,int type){ - //获取500条待统计历史订单 - List list = xhpcHistoryOrderService.getStatistisList(number,type); - //场站、运营商、流量方 - if(list !=null && list.size()>0){ - for (XhpcChargeHistoryOrder xhpc:list) { - XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); - xhpcSt.setChargingDegree(xhpc.getChargingDegree()); - BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP); - xhpcSt.setChargingTime(decimal); - xhpcSt.setChargingNumber(1); - xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal()); - xhpcSt.setServicePrice(xhpc.getServicePriceTotal()); - xhpcSt.setTotalPrice(xhpc.getTotalPrice()); - xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount()); - xhpcSt.setActPrice(xhpc.getActPrice()); - xhpcSt.setInternetCommission(xhpc.getInternetCommission()); - xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission()); - xhpcSt.setPlatformCommission(xhpc.getPlatformCommission()); - xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion()); - xhpcSt.setOperationCommission(xhpc.getOperationCommission()); - xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission()); - xhpcSt.setActPowerPrice(xhpc.getActPowerPrice()); - xhpcSt.setActServicePrice(xhpc.getActServicePrice()); - if(xhpc.getSource()==1){ - xhpcSt.setInternetUserId(xhpc.getUserId()); - } - xhpcSt.setOperatorId(xhpc.getOperatorId()); - xhpcSt.setChargingStationId(xhpc.getChargingStationId()); - xhpcSt.setCreateTime(Calendar.getInstance().getTime()); - xhpcSt.setTerminalId(xhpc.getTerminalId()); - xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); - xhpcSt.setChargingPileId(xhpc.getChargingPileId()); - xhpcSt.setType(type); - xhpcStatisticsService.addStatisticsStation(xhpcSt); - - - //修改历史订单表状态 - XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder(); - xhpcHistoryOrder.setHistoryOrderId(xhpc.getHistoryOrderId()); - xhpcHistoryOrder.setState(type+1); - xhpcHistoryOrderService.update(xhpcHistoryOrder); - } - } - } /** * 日期统计 */ @GetMapping("/test1") + @Scheduled(cron = "0 0 00 * * ?") public void test1(){ //获取500条待统计历史订单 //跨时段,跨费率,计费模型 //日期统计 int type =1; - List list = xhpcHistoryOrderService.getStatistisList(500,type); + List list = xhpcHistoryOrderService.getStatistisList(100,type); //是否跨天 if(list !=null && list.size()>0){ for (XhpcChargeHistoryOrder xhpc:list) { @@ -209,75 +167,16 @@ public class XhpcHistoryOrderController extends BaseController { } } - - - private void addStation(XhpcChargeHistoryOrder xhpc,BigDecimal chargingTime,int type,String startTime,String endTime,BigDecimal divide) { - - BigDecimal chargingDegree1 =new BigDecimal(0); - BigDecimal powerPrice1 =new BigDecimal(0); - BigDecimal servicePrice1 =new BigDecimal(0); - List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId()); - if(reatTimeList !=null && reatTimeList.size()>0){ - for (int i = 0; i objectMap = reatTimeList.get(i); - BigDecimal powerPrice =new BigDecimal(objectMap.get("powerFee").toString()); - BigDecimal servicePrice =new BigDecimal(objectMap.get("serviceFee").toString()); - String startTime1 = objectMap.get("startTime").toString(); - String endTime1 = objectMap.get("endTime").toString(); - //总度数 - BigDecimal chargingDegree2 = new BigDecimal((DateUtil.parse(endTime1).getTime() - DateUtil.parse(startTime1).getTime())/60000).multiply(divide).setScale(2, RoundingMode.HALF_UP); - chargingDegree1 =chargingDegree1.add(chargingDegree2); - powerPrice1 =powerPrice1.add(powerPrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP)); - servicePrice1 =servicePrice1.add(servicePrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP)); - } - } - - XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); - xhpcSt.setChargingDegree(chargingDegree1); - xhpcSt.setChargingTime(chargingTime); - xhpcSt.setChargingNumber(1); - xhpcSt.setPowerPrice(powerPrice1); - xhpcSt.setServicePrice(servicePrice1); - xhpcSt.setTotalPrice(powerPrice1.add(servicePrice1)); - BigDecimal promotion =new BigDecimal(2); - xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setActPrice(xhpcSt.getTotalPrice().subtract(xhpcSt.getPromotionDiscount())); - xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion,2, RoundingMode.HALF_UP)); - xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion,2, RoundingMode.HALF_UP)); - - //抽成费用 - BigDecimal money = xhpcSt.getPlatformCommission().add(xhpcSt.getPlatformSvcCommisssion()) - .add(xhpcSt.getInternetCommission()).add(xhpcSt.getInternetSvcCommission()) - .add(xhpcSt.getOperationCommission()).add(xhpcSt.getOperationSvcCommission()); - xhpcSt.setActPowerPrice(powerPrice1.subtract(money)); - xhpcSt.setActServicePrice(servicePrice1.subtract(money)); - if(xhpc.getSource()==1){ - xhpcSt.setInternetUserId(xhpc.getUserId()); - } - xhpcSt.setOperatorId(xhpc.getOperatorId()); - xhpcSt.setChargingStationId(xhpc.getChargingStationId()); - xhpcSt.setCreateTime(Calendar.getInstance().getTime()); - xhpcSt.setTerminalId(xhpc.getTerminalId()); - xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); - xhpcSt.setChargingPileId(xhpc.getChargingPileId()); - xhpcSt.setType(type); - xhpcStatisticsService.addStatisticsStation(xhpcSt); - } - - /** * 小时统计 */ @GetMapping("/test") + @Scheduled(cron = "0 0 * * * ?") public void test(){ //获取500条待统计历史订单 //跨时段,跨费率,计费模型 //小时统计 - List list = xhpcHistoryOrderService.getStatistisList(500,0); + List list = xhpcHistoryOrderService.getStatistisList(50,0); if(list !=null && list.size()>0){ for (XhpcChargeHistoryOrder xhpc:list) { //开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间 @@ -369,6 +268,109 @@ public class XhpcHistoryOrderController extends BaseController { } } + public void add(int number,int type){ + //获取500条待统计历史订单 + List list = xhpcHistoryOrderService.getStatistisList(number,type); + //场站、运营商、流量方 + if(list !=null && list.size()>0){ + for (XhpcChargeHistoryOrder xhpc:list) { + XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); + xhpcSt.setChargingDegree(xhpc.getChargingDegree()); + BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP); + xhpcSt.setChargingTime(decimal); + xhpcSt.setChargingNumber(1); + xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal()); + xhpcSt.setServicePrice(xhpc.getServicePriceTotal()); + xhpcSt.setTotalPrice(xhpc.getTotalPrice()); + xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount()); + xhpcSt.setActPrice(xhpc.getActPrice()); + xhpcSt.setInternetCommission(xhpc.getInternetCommission()); + xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission()); + xhpcSt.setPlatformCommission(xhpc.getPlatformCommission()); + xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion()); + xhpcSt.setOperationCommission(xhpc.getOperationCommission()); + xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission()); + xhpcSt.setActPowerPrice(xhpc.getActPowerPrice()); + xhpcSt.setActServicePrice(xhpc.getActServicePrice()); + if(xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + xhpcSt.setOperatorId(xhpc.getOperatorId()); + xhpcSt.setChargingStationId(xhpc.getChargingStationId()); + xhpcSt.setCreateTime(Calendar.getInstance().getTime()); + xhpcSt.setTerminalId(xhpc.getTerminalId()); + xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); + xhpcSt.setChargingPileId(xhpc.getChargingPileId()); + xhpcSt.setType(type); + xhpcStatisticsService.addStatisticsStation(xhpcSt); + + + //修改历史订单表状态 + XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder(); + xhpcHistoryOrder.setHistoryOrderId(xhpc.getHistoryOrderId()); + xhpcHistoryOrder.setState(type+1); + xhpcHistoryOrderService.update(xhpcHistoryOrder); + } + } + } + + private void addStation(XhpcChargeHistoryOrder xhpc,BigDecimal chargingTime,int type,String startTime,String endTime,BigDecimal divide) { + + BigDecimal chargingDegree1 =new BigDecimal(0); + BigDecimal powerPrice1 =new BigDecimal(0); + BigDecimal servicePrice1 =new BigDecimal(0); + List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId()); + if(reatTimeList !=null && reatTimeList.size()>0){ + for (int i = 0; i objectMap = reatTimeList.get(i); + BigDecimal powerPrice =new BigDecimal(objectMap.get("powerFee").toString()); + BigDecimal servicePrice =new BigDecimal(objectMap.get("serviceFee").toString()); + String startTime1 = objectMap.get("startTime").toString(); + String endTime1 = objectMap.get("endTime").toString(); + //总度数 + BigDecimal chargingDegree2 = new BigDecimal((DateUtil.parse(endTime1).getTime() - DateUtil.parse(startTime1).getTime())/60000).multiply(divide).setScale(2, RoundingMode.HALF_UP); + chargingDegree1 =chargingDegree1.add(chargingDegree2); + powerPrice1 =powerPrice1.add(powerPrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP)); + servicePrice1 =servicePrice1.add(servicePrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP)); + } + } + + XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); + xhpcSt.setChargingDegree(chargingDegree1); + xhpcSt.setChargingTime(chargingTime); + xhpcSt.setChargingNumber(1); + xhpcSt.setPowerPrice(powerPrice1); + xhpcSt.setServicePrice(servicePrice1); + xhpcSt.setTotalPrice(powerPrice1.add(servicePrice1)); + BigDecimal promotion =new BigDecimal(2); + xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setActPrice(xhpcSt.getTotalPrice().subtract(xhpcSt.getPromotionDiscount())); + xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion,2, RoundingMode.HALF_UP)); + xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion,2, RoundingMode.HALF_UP)); + + //抽成费用 + BigDecimal money = xhpcSt.getPlatformCommission().add(xhpcSt.getPlatformSvcCommisssion()) + .add(xhpcSt.getInternetCommission()).add(xhpcSt.getInternetSvcCommission()) + .add(xhpcSt.getOperationCommission()).add(xhpcSt.getOperationSvcCommission()); + xhpcSt.setActPowerPrice(powerPrice1.subtract(money)); + xhpcSt.setActServicePrice(servicePrice1.subtract(money)); + if(xhpc.getSource()==1){ + xhpcSt.setInternetUserId(xhpc.getUserId()); + } + xhpcSt.setOperatorId(xhpc.getOperatorId()); + xhpcSt.setChargingStationId(xhpc.getChargingStationId()); + xhpcSt.setCreateTime(Calendar.getInstance().getTime()); + xhpcSt.setTerminalId(xhpc.getTerminalId()); + xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId()); + xhpcSt.setChargingPileId(xhpc.getChargingPileId()); + xhpcSt.setType(type); + xhpcStatisticsService.addStatisticsStation(xhpcSt); + } + private void addStatisTime(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour,String yyyyMMdd,BigDecimal multiply) { BigDecimal number = new BigDecimal(endHour + 1 - startHour); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcOrderRedisRecord.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcOrderRedisRecord.java index 7038824f..81f6cdae 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcOrderRedisRecord.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcOrderRedisRecord.java @@ -15,6 +15,10 @@ public class XhpcOrderRedisRecord extends BaseEntity { * 充电订单id */ private Long chargeOrderId; + /** + * 充电订单号 + */ + private String serialNumber; /** * 历史订单id */ @@ -220,4 +224,14 @@ public class XhpcOrderRedisRecord extends BaseEntity { this.orderData = orderData; } + public String getSerialNumber() { + + return serialNumber; + } + + public void setSerialNumber(String serialNumber) { + + this.serialNumber = serialNumber; + } + } 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 685fca44..8130bcfa 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 @@ -116,7 +116,7 @@ public interface IXhpcRealTimeOrderService { * @param type 0 不发短信 1发短信 * @param vinNormal VUN 码 */ - void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map userMessage,Integer type,String vinNormal); + void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map userMessage,Integer type,String vinNormal,XhpcHistoryOrder xhpcHistoryOrder); /** * 添加redis到数据库 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 a10edfbf..9c3bab11 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 @@ -22,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * @author yuyang @@ -45,6 +47,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { @Autowired private SmsService smsService; + private ExecutorService executorService = Executors.newFixedThreadPool(20); + + private static final Logger logger = LoggerFactory.getLogger(XhpcRealTimeOrderServiceImpl.class); @Override @@ -180,7 +185,8 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { return AjaxResult.error("用户id:" + userId + "为空"); } //生成一条历史订单 - addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null); + XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder(); + addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder); return AjaxResult.success(); } @@ -198,8 +204,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { * @param type 0 不发短信 1发短信 */ @Override - public void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map userMessage,Integer type,String vinNormal) { - XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder(); + public void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map userMessage,Integer type,String vinNormal,XhpcHistoryOrder xhpcHistoryOrder) { xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setVinNormal(vinNormal); @@ -363,7 +368,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { xhpcChargeOrder.setErroRemark("扣钱失败"); }else{ xhpcHistoryOrderService.insert(xhpcHistoryOrder); - addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); + //添加流水 xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); try{ @@ -383,6 +388,13 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { }catch (Exception e){ logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); } + // 另起线程处理业务上传redis数据 + executorService.execute(new Runnable() { + @Override + public void run() { + addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); + } + }); } xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); } @@ -461,6 +473,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { //添加redis到数据库 XhpcOrderRedisRecord xhpcOrderRedisRecord =new XhpcOrderRedisRecord(); xhpcOrderRedisRecord.setChargeOrderId(chargeOrderId); + xhpcOrderRedisRecord.setSerialNumber(xhpcHistoryOrder.getSerialNumber()); xhpcOrderRedisRecord.setHistoryOrderOd(xhpcHistoryOrder.getHistoryOrderId()); if(cacheMap.get("endSoc") !=null){ xhpcOrderRedisRecord.setEndSoc(cacheMap.get("endSoc").toString()); @@ -498,9 +511,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { } xhpcOrderRedisRecord.setCreateTime(date); xhpcChargeOrderService.addXhpcOrderRedisRecord(xhpcOrderRedisRecord); - //删除redis - //redisService.deleteObject("order:"+orderNo); + redisService.deleteObject("order:"+orderNo); + redisService.deleteObject("order:"+orderNo+".lord"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>"); 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 9ec23042..ddc45905 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -403,7 +403,10 @@ remark, - order_data + order_data, + + + serial_number @@ -459,7 +462,10 @@ #{remark}, - #{orderData} + #{orderData}, + + + #{serialNumber} 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 4504531a..32c31b12 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -200,144 +200,144 @@ user_name_evcs, - phone, + phone - #{chargingStationId,jdbcType=BIGINT}, + #{chargingStationId}, - #{chargeOrderId,jdbcType=BIGINT}, + #{chargeOrderId}, - #{userId,jdbcType=BIGINT}, + #{userId}, - #{terminalId,jdbcType=BIGINT}, + #{terminalId}, - #{serialNumber,jdbcType=VARCHAR}, + #{serialNumber}, - #{internetSerialNumber,jdbcType=VARCHAR}, + #{internetSerialNumber}, - #{powerPriceTotal,jdbcType=DECIMAL}, + #{powerPriceTotal}, - #{servicePriceTotal,jdbcType=DECIMAL}, + #{servicePriceTotal}, - #{totalPrice,jdbcType=DECIMAL}, + #{totalPrice}, - #{promotionDiscount,jdbcType=DECIMAL}, + #{promotionDiscount}, - #{actPrice,jdbcType=DECIMAL}, + #{actPrice}, - #{actPowerPrice,jdbcType=DECIMAL}, + #{actPowerPrice}, - #{actServicePrice,jdbcType=DECIMAL}, + #{actServicePrice}, - #{internetCommission,jdbcType=DECIMAL}, + #{internetCommission}, - #{internetSvcCommission,jdbcType=DECIMAL}, + #{internetSvcCommission}, - #{platformCommission,jdbcType=DECIMAL}, + #{platformCommission}, - #{platformSvcCommisssion,jdbcType=DECIMAL}, + #{platformSvcCommisssion}, - #{operationCommission,jdbcType=DECIMAL}, + #{operationCommission}, - #{operationSvcCommission,jdbcType=DECIMAL}, + #{operationSvcCommission}, - #{startSoc,jdbcType=VARCHAR}, + #{startSoc}, - #{endSoc,jdbcType=VARCHAR}, + #{endSoc}, - #{reconciliationStatus,jdbcType=INTEGER}, + #{reconciliationStatus}, - #{sortingStatus,jdbcType=INTEGER}, + #{sortingStatus}, - #{type,jdbcType=TINYINT}, + #{type}, - #{status,jdbcType=INTEGER}, + #{status}, - #{delFlag,jdbcType=INTEGER}, + #{delFlag}, - #{createTime,jdbcType=TIMESTAMP}, + #{createTime}, - #{createBy,jdbcType=VARCHAR}, + #{createBy}, - #{updateTime,jdbcType=TIMESTAMP}, + #{updateTime}, - #{updateBy,jdbcType=VARCHAR}, + #{updateBy}, - #{remark,jdbcType=VARCHAR}, + #{remark}, - #{state,jdbcType=INTEGER}, + #{state}, - #{vinNormal,jdbcType=VARCHAR}, + #{vinNormal}, - #{searchValue,jdbcType=VARCHAR}, + #{searchValue}, - #{operatorIdEvcs,jdbcType=VARCHAR}, + #{operatorIdEvcs}, - #{chargeModelEvcs,jdbcType=INTEGER}, + #{chargeModelEvcs}, - #{connectorPowerEvcs,jdbcType=DOUBLE}, + #{connectorPowerEvcs}, - #{meterValueEndEvcs,jdbcType=DOUBLE}, + #{meterValueEndEvcs}, - #{meterValueStartEvcs,jdbcType=DOUBLE}, + #{meterValueStartEvcs}, - #{operatorId3rdptyEvcs,jdbcType=VARCHAR}, + #{operatorId3rdptyEvcs}, - #{startTime,jdbcType=TIMESTAMP}, + #{startTime}, - #{stopReasonEvcs,jdbcType=INTEGER}, + #{stopReasonEvcs}, - #{totalPower,jdbcType=DOUBLE}, + #{totalPower}, - #{userNameEvcs,jdbcType=VARCHAR}, + #{userNameEvcs}, - #{phone,jdbcType=VARCHAR}, + #{phone}