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 0de02dd4..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,18 +261,18 @@ 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(); - powerPrice = powerPrice.add(multiply); + 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(); - powerPrice = powerPrice.add(multiply); + 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(); - powerPrice = powerPrice.add(multiply); + totalPower =totalPower+cacheOrderData.getT4PowerQuantity(); + powerPrice=powerPrice.add(multiply); } //总服务费 BigDecimal servicePrice = money.subtract(powerPrice); @@ -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,8 +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/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 a4fa66ed..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 @@ -5,6 +5,7 @@ import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.order.domain.*; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -115,9 +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 0c9f2dd8..b446dadc 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,8 +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(); } @@ -199,11 +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); @@ -211,9 +212,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { //电站活动抵扣--抵扣的总金额 BigDecimal promotionDiscount = new BigDecimal(0); //实际价格-用户支付的钱 - BigDecimal actPrice = money; + BigDecimal actPrice =money; //流量方总金额抽成 - BigDecimal internetCommission = new BigDecimal(0); + BigDecimal internetCommission =new BigDecimal(0); //流量方服务费抽成 BigDecimal internetSvcCommission =new BigDecimal(0); //平台总金额抽成 @@ -367,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{ @@ -387,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); } @@ -465,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()); @@ -502,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-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java index 0656c2ed..ec7896b5 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcRefundAuditController.java @@ -186,8 +186,8 @@ public class XhpcRefundAuditController extends BaseController { CloseableHttpClient httpClient = null; try { //证书的地址 - String certPath = ConfigListener.getConf().get("certPath"); - System.out.println("certPath:"+certPath); + //String certPath = ConfigListener.getConf().get("certPath"); + //System.out.println("certPath:"+certPath); httpClient = initCert(); } catch (Exception e) { e.printStackTrace(); @@ -248,7 +248,7 @@ public class XhpcRefundAuditController extends BaseController { String path = "apiclient_cert.p12"; //File file = new File(this.getClass().getResource("/").getPath() + path); //线上地址 - File file = new File("/www/wwwroot/xhpc.scxhua.com/xhpc-payment/" + path); + File file = new File("/www/wwwroot/scxhua.cn/xhpc-payment/" + path); // 证书密码,默认为商户ID String key = environment.getProperty("MCHID"); // 指定读取证书格式为PKCS12 diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 68c05251..bf35408f 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -225,7 +225,7 @@