订单回调,优化实时数据,修改申请退款

This commit is contained in:
yuyang 2021-10-12 11:17:19 +08:00
parent 80731e0ae8
commit 2b473127c5
6 changed files with 49 additions and 28 deletions

View File

@ -261,18 +261,18 @@ public class XhpcPileOrderController extends BaseController {
} }
if(!"0".equals(cacheOrderData.getT2PowerQuantity().toString())){ 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);
totalPower = totalPower + cacheOrderData.getT1PowerQuantity(); totalPower =totalPower+cacheOrderData.getT2PowerQuantity();
powerPrice = powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
if(!"0".equals(cacheOrderData.getT3PowerQuantity().toString())){ 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);
totalPower = totalPower + cacheOrderData.getT1PowerQuantity(); totalPower =totalPower+cacheOrderData.getT3PowerQuantity();
powerPrice = powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
if(!"0".equals(cacheOrderData.getT4PowerQuantity().toString())){ 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);
totalPower = totalPower + cacheOrderData.getT1PowerQuantity(); totalPower =totalPower+cacheOrderData.getT4PowerQuantity();
powerPrice = powerPrice.add(multiply); powerPrice=powerPrice.add(multiply);
} }
//总服务费 //总服务费
BigDecimal servicePrice = money.subtract(powerPrice); BigDecimal servicePrice = money.subtract(powerPrice);
@ -334,7 +334,7 @@ public class XhpcPileOrderController extends BaseController {
xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setTotalPower(totalPower.doubleValue() / 1000); xhpcHistoryOrder.setTotalPower(totalPower.doubleValue()/10000);
xhpcHistoryOrder.setMeterValueStartEvcs(cacheOrderData.getElectricMeterStart().doubleValue()); xhpcHistoryOrder.setMeterValueStartEvcs(cacheOrderData.getElectricMeterStart().doubleValue());
xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue()); xhpcHistoryOrder.setMeterValueEndEvcs(cacheOrderData.getElectricMeterEnd().doubleValue());
Map<String, Object> userMessage = xhpcChargeOrderService.getUserMessage(userId); Map<String, Object> userMessage = xhpcChargeOrderService.getUserMessage(userId);
@ -347,8 +347,7 @@ public class XhpcPileOrderController extends BaseController {
R.ok(); R.ok();
} }
//结算 //结算
xhpcRealTimeOrderService.addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder);
xhpcChargeOrder, userId, userMessage, 1, cacheOrderData.getVinNormal());
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("code", 500); map.put("code", 500);
map.put("userId", userId); map.put("userId", userId);

View File

@ -15,6 +15,10 @@ public class XhpcOrderRedisRecord extends BaseEntity {
* 充电订单id * 充电订单id
*/ */
private Long chargeOrderId; private Long chargeOrderId;
/**
* 充电订单号
*/
private String serialNumber;
/** /**
* 历史订单id * 历史订单id
*/ */
@ -220,4 +224,14 @@ public class XhpcOrderRedisRecord extends BaseEntity {
this.orderData = orderData; this.orderData = orderData;
} }
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
} }

View File

@ -5,6 +5,7 @@ import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.order.domain.*; import com.xhpc.order.domain.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -115,9 +116,7 @@ public interface IXhpcRealTimeOrderService {
* @param type 0 不发短信 1发短信 * @param type 0 不发短信 1发短信
* @param vinNormal VUN * @param vinNormal VUN
*/ */
void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map<String, Object> userMessage,Integer type,String vinNormal,XhpcHistoryOrder xhpcHistoryOrder);
BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId,
Map<String, Object> userMessage, Integer type, String vinNormal);
/** /**
* 添加redis到数据库 * 添加redis到数据库

View File

@ -22,6 +22,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* @author yuyang * @author yuyang
@ -45,6 +47,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
@Autowired @Autowired
private SmsService smsService; private SmsService smsService;
private ExecutorService executorService = Executors.newFixedThreadPool(20);
private static final Logger logger = LoggerFactory.getLogger(XhpcRealTimeOrderServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(XhpcRealTimeOrderServiceImpl.class);
@Override @Override
@ -180,8 +185,8 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
return AjaxResult.error("用户id:" + userId + "为空"); return AjaxResult.error("用户id:" + userId + "为空");
} }
//生成一条历史订单 //生成一条历史订单
addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
userMessage, 0, null); addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -199,11 +204,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
* @param type 0 不发短信 1发短信 * @param type 0 不发短信 1发短信
*/ */
@Override @Override
public void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, public void addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map<String, Object> userMessage,Integer type,String vinNormal,XhpcHistoryOrder xhpcHistoryOrder) {
BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, Map<String,
Object> userMessage, Integer type, String vinNormal) {
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setVinNormal(vinNormal); xhpcHistoryOrder.setVinNormal(vinNormal);
@ -211,9 +212,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
//电站活动抵扣--抵扣的总金额 //电站活动抵扣--抵扣的总金额
BigDecimal promotionDiscount = new BigDecimal(0); 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); BigDecimal internetSvcCommission =new BigDecimal(0);
//平台总金额抽成 //平台总金额抽成
@ -367,7 +368,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
xhpcChargeOrder.setErroRemark("扣钱失败"); xhpcChargeOrder.setErroRemark("扣钱失败");
}else{ }else{
xhpcHistoryOrderService.insert(xhpcHistoryOrder); xhpcHistoryOrderService.insert(xhpcHistoryOrder);
addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(), 1);
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date);
try{ try{
@ -387,6 +388,13 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
}catch (Exception e){ }catch (Exception e){
logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>");
} }
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
public void run() {
addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
}
});
} }
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
} }
@ -465,6 +473,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
//添加redis到数据库 //添加redis到数据库
XhpcOrderRedisRecord xhpcOrderRedisRecord =new XhpcOrderRedisRecord(); XhpcOrderRedisRecord xhpcOrderRedisRecord =new XhpcOrderRedisRecord();
xhpcOrderRedisRecord.setChargeOrderId(chargeOrderId); xhpcOrderRedisRecord.setChargeOrderId(chargeOrderId);
xhpcOrderRedisRecord.setSerialNumber(xhpcHistoryOrder.getSerialNumber());
xhpcOrderRedisRecord.setHistoryOrderOd(xhpcHistoryOrder.getHistoryOrderId()); xhpcOrderRedisRecord.setHistoryOrderOd(xhpcHistoryOrder.getHistoryOrderId());
if(cacheMap.get("endSoc") !=null){ if(cacheMap.get("endSoc") !=null){
xhpcOrderRedisRecord.setEndSoc(cacheMap.get("endSoc").toString()); xhpcOrderRedisRecord.setEndSoc(cacheMap.get("endSoc").toString());
@ -502,9 +511,9 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
} }
xhpcOrderRedisRecord.setCreateTime(date); xhpcOrderRedisRecord.setCreateTime(date);
xhpcChargeOrderService.addXhpcOrderRedisRecord(xhpcOrderRedisRecord); xhpcChargeOrderService.addXhpcOrderRedisRecord(xhpcOrderRedisRecord);
//删除redis //删除redis
//redisService.deleteObject("order:"+orderNo); redisService.deleteObject("order:"+orderNo);
redisService.deleteObject("order:"+orderNo+".lord");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");

View File

@ -186,8 +186,8 @@ public class XhpcRefundAuditController extends BaseController {
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
try { try {
//证书的地址 //证书的地址
String certPath = ConfigListener.getConf().get("certPath"); //String certPath = ConfigListener.getConf().get("certPath");
System.out.println("certPath:"+certPath); //System.out.println("certPath:"+certPath);
httpClient = initCert(); httpClient = initCert();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -248,7 +248,7 @@ public class XhpcRefundAuditController extends BaseController {
String path = "apiclient_cert.p12"; String path = "apiclient_cert.p12";
//File file = new File(this.getClass().getResource("/").getPath() + path); //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 // 证书密码默认为商户ID
String key = environment.getProperty("MCHID"); String key = environment.getProperty("MCHID");
// 指定读取证书格式为PKCS12 // 指定读取证书格式为PKCS12

View File

@ -225,7 +225,7 @@
<select id="countXhpcRealTimeOrder" resultType="int"> <select id="countXhpcRealTimeOrder" resultType="int">
select charge_order_id as chargeOrderId from xhpc_charge_order where user_id =#{userId} and status=0 and del_flag =0 limit 1 select count(charge_order_id) from xhpc_charge_order where user_id =#{userId} and status=0 and del_flag =0 limit 1
</select> </select>
<select id="countXhpcChargeOrder" resultType="int"> <select id="countXhpcChargeOrder" resultType="int">