订单回调,优化实时数据
This commit is contained in:
parent
3ddc900bc9
commit
f46f060f0a
@ -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<String, Object> 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<String, Object> map = new HashMap<>();
|
||||
map.put("code", 500);
|
||||
map.put("userId", userId);
|
||||
|
||||
@ -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<XhpcChargeHistoryOrder> 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<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(500,type);
|
||||
List<XhpcChargeHistoryOrder> 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<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId());
|
||||
if(reatTimeList !=null && reatTimeList.size()>0){
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
Map<String, Object> 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<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(500,0);
|
||||
List<XhpcChargeHistoryOrder> 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<XhpcChargeHistoryOrder> 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<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId());
|
||||
if(reatTimeList !=null && reatTimeList.size()>0){
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
Map<String, Object> 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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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<String, Object> userMessage,Integer type,String vinNormal);
|
||||
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);
|
||||
|
||||
/**
|
||||
* 添加redis到数据库
|
||||
|
||||
@ -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<String, Object> 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<String, Object> 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("<<<<<<<<<<<<<<<<订单结束回调成功>>>>>>>>>>>>>>>>>");
|
||||
|
||||
@ -403,7 +403,10 @@
|
||||
remark,
|
||||
</if>
|
||||
<if test="null != orderData ">
|
||||
order_data
|
||||
order_data,
|
||||
</if>
|
||||
<if test="null != serialNumber ">
|
||||
serial_number
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@ -459,7 +462,10 @@
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="null != orderData ">
|
||||
#{orderData}
|
||||
#{orderData},
|
||||
</if>
|
||||
<if test="null != serialNumber ">
|
||||
#{serialNumber}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@ -200,144 +200,144 @@
|
||||
user_name_evcs,
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
phone,
|
||||
phone
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="chargingStationId != null">
|
||||
#{chargingStationId,jdbcType=BIGINT},
|
||||
#{chargingStationId},
|
||||
</if>
|
||||
<if test="chargeOrderId != null">
|
||||
#{chargeOrderId,jdbcType=BIGINT},
|
||||
#{chargeOrderId},
|
||||
</if>
|
||||
<if test="userId != null">
|
||||
#{userId,jdbcType=BIGINT},
|
||||
#{userId},
|
||||
</if>
|
||||
<if test="terminalId != null">
|
||||
#{terminalId,jdbcType=BIGINT},
|
||||
#{terminalId},
|
||||
</if>
|
||||
<if test="serialNumber != null">
|
||||
#{serialNumber,jdbcType=VARCHAR},
|
||||
#{serialNumber},
|
||||
</if>
|
||||
<if test="internetSerialNumber != null">
|
||||
#{internetSerialNumber,jdbcType=VARCHAR},
|
||||
#{internetSerialNumber},
|
||||
</if>
|
||||
<if test="powerPriceTotal != null">
|
||||
#{powerPriceTotal,jdbcType=DECIMAL},
|
||||
#{powerPriceTotal},
|
||||
</if>
|
||||
<if test="servicePriceTotal != null">
|
||||
#{servicePriceTotal,jdbcType=DECIMAL},
|
||||
#{servicePriceTotal},
|
||||
</if>
|
||||
<if test="totalPrice != null">
|
||||
#{totalPrice,jdbcType=DECIMAL},
|
||||
#{totalPrice},
|
||||
</if>
|
||||
<if test="promotionDiscount != null">
|
||||
#{promotionDiscount,jdbcType=DECIMAL},
|
||||
#{promotionDiscount},
|
||||
</if>
|
||||
<if test="actPrice != null">
|
||||
#{actPrice,jdbcType=DECIMAL},
|
||||
#{actPrice},
|
||||
</if>
|
||||
<if test="actPowerPrice != null">
|
||||
#{actPowerPrice,jdbcType=DECIMAL},
|
||||
#{actPowerPrice},
|
||||
</if>
|
||||
<if test="actServicePrice != null">
|
||||
#{actServicePrice,jdbcType=DECIMAL},
|
||||
#{actServicePrice},
|
||||
</if>
|
||||
<if test="internetCommission != null">
|
||||
#{internetCommission,jdbcType=DECIMAL},
|
||||
#{internetCommission},
|
||||
</if>
|
||||
<if test="internetSvcCommission != null">
|
||||
#{internetSvcCommission,jdbcType=DECIMAL},
|
||||
#{internetSvcCommission},
|
||||
</if>
|
||||
<if test="platformCommission != null">
|
||||
#{platformCommission,jdbcType=DECIMAL},
|
||||
#{platformCommission},
|
||||
</if>
|
||||
<if test="platformSvcCommisssion != null">
|
||||
#{platformSvcCommisssion,jdbcType=DECIMAL},
|
||||
#{platformSvcCommisssion},
|
||||
</if>
|
||||
<if test="operationCommission != null">
|
||||
#{operationCommission,jdbcType=DECIMAL},
|
||||
#{operationCommission},
|
||||
</if>
|
||||
<if test="operationSvcCommission != null">
|
||||
#{operationSvcCommission,jdbcType=DECIMAL},
|
||||
#{operationSvcCommission},
|
||||
</if>
|
||||
<if test="startSoc != null">
|
||||
#{startSoc,jdbcType=VARCHAR},
|
||||
#{startSoc},
|
||||
</if>
|
||||
<if test="endSoc != null">
|
||||
#{endSoc,jdbcType=VARCHAR},
|
||||
#{endSoc},
|
||||
</if>
|
||||
<if test="reconciliationStatus != null">
|
||||
#{reconciliationStatus,jdbcType=INTEGER},
|
||||
#{reconciliationStatus},
|
||||
</if>
|
||||
<if test="sortingStatus != null">
|
||||
#{sortingStatus,jdbcType=INTEGER},
|
||||
#{sortingStatus},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=TINYINT},
|
||||
#{type},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=INTEGER},
|
||||
#{status},
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
#{delFlag,jdbcType=INTEGER},
|
||||
#{delFlag},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">
|
||||
#{createBy,jdbcType=VARCHAR},
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=TIMESTAMP},
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">
|
||||
#{updateBy,jdbcType=VARCHAR},
|
||||
#{updateBy},
|
||||
</if>
|
||||
<if test="remark != null">
|
||||
#{remark,jdbcType=VARCHAR},
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="state != null">
|
||||
#{state,jdbcType=INTEGER},
|
||||
#{state},
|
||||
</if>
|
||||
<if test="vinNormal != null">
|
||||
#{vinNormal,jdbcType=VARCHAR},
|
||||
#{vinNormal},
|
||||
</if>
|
||||
<if test="searchValue != null">
|
||||
#{searchValue,jdbcType=VARCHAR},
|
||||
#{searchValue},
|
||||
</if>
|
||||
<if test="operatorIdEvcs != null">
|
||||
#{operatorIdEvcs,jdbcType=VARCHAR},
|
||||
#{operatorIdEvcs},
|
||||
</if>
|
||||
<if test="chargeModelEvcs != null">
|
||||
#{chargeModelEvcs,jdbcType=INTEGER},
|
||||
#{chargeModelEvcs},
|
||||
</if>
|
||||
<if test="connectorPowerEvcs != null">
|
||||
#{connectorPowerEvcs,jdbcType=DOUBLE},
|
||||
#{connectorPowerEvcs},
|
||||
</if>
|
||||
<if test="meterValueEndEvcs != null">
|
||||
#{meterValueEndEvcs,jdbcType=DOUBLE},
|
||||
#{meterValueEndEvcs},
|
||||
</if>
|
||||
<if test="meterValueStartEvcs != null">
|
||||
#{meterValueStartEvcs,jdbcType=DOUBLE},
|
||||
#{meterValueStartEvcs},
|
||||
</if>
|
||||
<if test="operatorId3rdptyEvcs != null">
|
||||
#{operatorId3rdptyEvcs,jdbcType=VARCHAR},
|
||||
#{operatorId3rdptyEvcs},
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
#{startTime,jdbcType=TIMESTAMP},
|
||||
#{startTime},
|
||||
</if>
|
||||
<if test="stopReasonEvcs != null">
|
||||
#{stopReasonEvcs,jdbcType=INTEGER},
|
||||
#{stopReasonEvcs},
|
||||
</if>
|
||||
<if test="totalPower != null">
|
||||
#{totalPower,jdbcType=DOUBLE},
|
||||
#{totalPower},
|
||||
</if>
|
||||
<if test="userNameEvcs != null">
|
||||
#{userNameEvcs,jdbcType=VARCHAR},
|
||||
#{userNameEvcs},
|
||||
</if>
|
||||
<if test="phone != null">
|
||||
#{phone,jdbcType=VARCHAR},
|
||||
#{phone}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user