修复统计订单
This commit is contained in:
parent
360639dc20
commit
591be029bd
@ -1,5 +1,6 @@
|
||||
package com.xhpc.order.controller;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
@ -87,7 +88,7 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
* 终端统计
|
||||
*/
|
||||
@GetMapping("/test3")
|
||||
//@Scheduled(cron = "0 0/8 * * * ?")
|
||||
@Scheduled(cron = "0 0/8 * * * ?")
|
||||
public void test3(){
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
@ -98,7 +99,7 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
* 场站统计
|
||||
*/
|
||||
@GetMapping("/test2")
|
||||
//@Scheduled(cron = "0 0/7 * * * ?")
|
||||
@Scheduled(cron = "0 0/7 * * * ?")
|
||||
public void test2(){
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
@ -110,7 +111,7 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
* 日期统计
|
||||
*/
|
||||
@GetMapping("/test1")
|
||||
//@Scheduled(cron = "0 0/6 * * * ?")
|
||||
@Scheduled(cron = "0 0/6 * * * ?")
|
||||
public void test1(){
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>");
|
||||
@ -178,21 +179,200 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
|
||||
}else{
|
||||
//跨天
|
||||
Date updateTime2= DateUtil.endOfDay(startTime);
|
||||
BigDecimal time5 = new BigDecimal((updateTime2.getTime()-startTime.getTime())).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN);
|
||||
addStation(xhpc, time5,type,DateUtil.formatTime(startTime),"23:59:59",divide);
|
||||
|
||||
DateTime tomorrow = DateUtil.offsetDay(startTime,1);
|
||||
Date startTime3 =DateUtil.beginOfDay(tomorrow);
|
||||
BigDecimal tim = new BigDecimal(DateUtil.between(DateUtil.beginOfDay(tomorrow), DateUtil.endOfDay(endTime), DateUnit.MINUTE)/ 60).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
//明天
|
||||
addStation(xhpc, tim,type, DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime),divide);
|
||||
|
||||
Map<String, BigDecimal> map =addStatisticsStation(new HashMap<String,BigDecimal>(),xhpc, DateUtil.formatTime(startTime), "23:59:59",divide,1,1);
|
||||
|
||||
addStatisticsStation(map,xhpc, DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime),divide,2,1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String,BigDecimal> addStatisticsStation(Map<String,BigDecimal> map1, XhpcChargeHistoryOrder xhpc, String startTime, String endTime, BigDecimal divide,int number,int type) {
|
||||
|
||||
//总金额
|
||||
BigDecimal totalPrice =new BigDecimal(0);
|
||||
//总电费
|
||||
BigDecimal powerPriceTotal =new BigDecimal(0);
|
||||
//总服务费
|
||||
BigDecimal servicePriceTotal =new BigDecimal(0);
|
||||
//实收电费
|
||||
BigDecimal actPowerPrice =new BigDecimal(0);
|
||||
//实收服务费
|
||||
BigDecimal actServicePrice =new BigDecimal(0);
|
||||
//总充电电量
|
||||
BigDecimal chargingDegree =new BigDecimal(0);
|
||||
//电站活动抵扣--抵扣的总金额
|
||||
BigDecimal promotionDiscount =new BigDecimal(0);
|
||||
//实际价格-用户支付的钱
|
||||
BigDecimal actPrice =new BigDecimal(0);
|
||||
if(number ==2){
|
||||
totalPrice =map1.get("totalPrice");
|
||||
powerPriceTotal =map1.get("powerPriceTotal");
|
||||
servicePriceTotal =map1.get("servicePriceTotal");
|
||||
actPowerPrice =map1.get("actPowerPrice");
|
||||
actServicePrice =map1.get("actServicePrice");
|
||||
chargingDegree =map1.get("chargingDegree");
|
||||
promotionDiscount =map1.get("promotionDiscount");
|
||||
actPrice =map1.get("actPrice");
|
||||
}else{
|
||||
totalPrice = xhpc.getTotalPrice();
|
||||
powerPriceTotal =xhpc.getPowerPriceTotal();
|
||||
servicePriceTotal =xhpc.getServicePriceTotal();
|
||||
actPowerPrice =xhpc.getActPowerPrice();
|
||||
actServicePrice =xhpc.getActServicePrice();
|
||||
chargingDegree =xhpc.getChargingDegree();
|
||||
promotionDiscount = xhpc.getPromotionDiscount();
|
||||
actPrice = xhpc.getActPrice();
|
||||
}
|
||||
|
||||
//叠加总电费
|
||||
BigDecimal powerPriceTotal1 =new BigDecimal(0);
|
||||
//叠加总服务费
|
||||
BigDecimal servicePriceTotal1 =new BigDecimal(0);
|
||||
|
||||
|
||||
//时长
|
||||
BigDecimal timeInterval = new BigDecimal(0);
|
||||
//时长
|
||||
BigDecimal chargingDegree2 = new BigDecimal(0);
|
||||
|
||||
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId());
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
Map<String, Object> map = reatTimeList.get(i);
|
||||
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
|
||||
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
|
||||
timeInterval =timeInterval.add(new BigDecimal((DateUtil.parse(map.get("endTime").toString()).getTime()-DateUtil.parse(map.get("startTime").toString()).getTime())).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN));
|
||||
powerPriceTotal1 = powerPriceTotal1.add(powerFee.multiply(divide).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
servicePriceTotal1 = servicePriceTotal1.add(serviceFee.multiply(divide).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
chargingDegree2 =chargingDegree2.add(timeInterval.multiply(divide).setScale(2,BigDecimal.ROUND_DOWN));
|
||||
}
|
||||
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(chargingDegree2);
|
||||
xhpcSt.setChargingTime(timeInterval.divide(new BigDecimal(60),2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(powerPriceTotal1);
|
||||
xhpcSt.setServicePrice(servicePriceTotal1);
|
||||
xhpcSt.setActPowerPrice(powerPriceTotal1);
|
||||
xhpcSt.setActServicePrice(servicePriceTotal1);
|
||||
xhpcSt.setTotalPrice(powerPriceTotal1.add(servicePriceTotal1));
|
||||
BigDecimal actPrice2 =powerPriceTotal1.add(servicePriceTotal1);
|
||||
BigDecimal promotion =new BigDecimal(2);
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
if(number==1){
|
||||
BigDecimal internetCommission = xhpcSt.getInternetCommission();
|
||||
if(internetCommission.compareTo(new BigDecimal(0))!=0){
|
||||
actPrice2 = actPrice2.subtract(internetCommission);
|
||||
}else{
|
||||
actPrice2 =actPrice2.subtract(xhpcSt.getInternetSvcCommission());
|
||||
}
|
||||
actPrice2 = actPrice2.subtract(xhpcSt.getPromotionDiscount());
|
||||
xhpcSt.setActPrice(actPrice2);
|
||||
//总金额
|
||||
BigDecimal totalPrice1 = xhpcSt.getTotalPrice();
|
||||
if(totalPrice.compareTo(totalPrice1)==1){
|
||||
totalPrice=totalPrice.subtract(totalPrice1);
|
||||
}else{
|
||||
xhpcSt.setTotalPrice(totalPrice);
|
||||
}
|
||||
//总电费
|
||||
BigDecimal powerPrice1 = xhpcSt.getPowerPrice();
|
||||
if(powerPriceTotal.compareTo(powerPrice1)==1){
|
||||
powerPriceTotal=powerPriceTotal.subtract(powerPrice1);
|
||||
}else{
|
||||
xhpcSt.setPowerPrice(powerPriceTotal);
|
||||
}
|
||||
//总服务费
|
||||
BigDecimal servicePrice1 = xhpcSt.getServicePrice();
|
||||
if(servicePriceTotal.compareTo(servicePrice1)==1){
|
||||
servicePriceTotal=servicePriceTotal.subtract(servicePrice1);
|
||||
}else{
|
||||
xhpcSt.setServicePrice(servicePriceTotal);
|
||||
}
|
||||
//实收电费
|
||||
BigDecimal actPowerPrice1 = xhpcSt.getActPowerPrice();
|
||||
if(actPowerPrice.compareTo(actPowerPrice1)==1){
|
||||
actPowerPrice=actPowerPrice.subtract(actPowerPrice1);
|
||||
}else{
|
||||
xhpcSt.setActPowerPrice(actPowerPrice);
|
||||
}
|
||||
//实收服务费
|
||||
BigDecimal actServicePrice1 = xhpcSt.getActServicePrice();
|
||||
if(actServicePrice.compareTo(actServicePrice1)==1){
|
||||
actServicePrice=actServicePrice.subtract(actServicePrice1);
|
||||
}else{
|
||||
xhpcSt.setActServicePrice(actServicePrice);
|
||||
}
|
||||
//总充电电量
|
||||
BigDecimal chargingDegree1 = xhpcSt.getChargingDegree();
|
||||
if(chargingDegree.compareTo(chargingDegree1)==1){
|
||||
chargingDegree=chargingDegree.subtract(chargingDegree1);
|
||||
}else{
|
||||
xhpcSt.setChargingDegree(chargingDegree);
|
||||
}
|
||||
|
||||
//实际价格-用户支付的钱
|
||||
BigDecimal actPrice1 = xhpcSt.getActPrice();
|
||||
if(actPrice.compareTo(actPrice1)==1){
|
||||
actPrice=actPrice.subtract(actPrice1);
|
||||
}else{
|
||||
xhpcSt.setActPrice(actPrice);
|
||||
}
|
||||
}else{
|
||||
xhpcSt.setPowerPrice(powerPriceTotal);
|
||||
xhpcSt.setServicePrice(servicePriceTotal);
|
||||
xhpcSt.setTotalPrice(totalPrice);
|
||||
xhpcSt.setPromotionDiscount(promotionDiscount);
|
||||
xhpcSt.setActPrice(actPrice);
|
||||
xhpcSt.setActPowerPrice(actPowerPrice);
|
||||
xhpcSt.setActServicePrice(actServicePrice);
|
||||
xhpcSt.setChargingDegree(chargingDegree);
|
||||
}
|
||||
|
||||
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);
|
||||
if(number==1){
|
||||
xhpcSt.setCreateTime(xhpc.getCreateTime());
|
||||
}else{
|
||||
xhpcSt.setCreateTime(DateUtil.offset(xhpc.getCreateTime(), DateField.DAY_OF_MONTH, 1));
|
||||
}
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
|
||||
|
||||
Map<String,BigDecimal> map2 =new HashMap<>();
|
||||
map2.put("totalPrice",totalPrice);
|
||||
map2.put("powerPriceTotal",powerPriceTotal);
|
||||
map2.put("servicePriceTotal",servicePriceTotal);
|
||||
map2.put("actPowerPrice",actPowerPrice);
|
||||
map2.put("actServicePrice",actServicePrice);
|
||||
map2.put("chargingDegree",chargingDegree);
|
||||
map2.put("promotionDiscount",promotionDiscount);
|
||||
map2.put("actPrice",actPrice);
|
||||
return map2;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 小时统计
|
||||
*/
|
||||
@ -272,6 +452,7 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString()));
|
||||
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setCreateTime(xhpc.getCreateTime());
|
||||
xhpcStatisticsService.addStatisticsTime(xhpcSt);
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
|
||||
@ -322,7 +503,6 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
//总共时段 endHour+1-startHour
|
||||
String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd");
|
||||
|
||||
|
||||
//总金额
|
||||
BigDecimal totalPrice =new BigDecimal(0);
|
||||
//总电费
|
||||
@ -383,16 +563,18 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
Map<String, Object> map =getReatTimeList(srt,endt,rateModelId);
|
||||
powerFee =new BigDecimal(map.get("powerFee").toString());
|
||||
serviceFee =new BigDecimal(map.get("serviceFee").toString());
|
||||
timeInterval =new BigDecimal((DateUtil.parse(endt).getTime()-DateUtil.parse(srt).getTime())).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN);
|
||||
} else {
|
||||
srt = end + ":00:00";
|
||||
endt = DateUtil.formatTime(endTime);
|
||||
Map<String, Object> map =getReatTimeList(srt,endt,rateModelId);
|
||||
powerFee =new BigDecimal(map.get("powerFee").toString());
|
||||
serviceFee =new BigDecimal(map.get("serviceFee").toString());
|
||||
timeInterval =new BigDecimal((DateUtil.parse(endt).getTime()-DateUtil.parse(srt).getTime())).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN);
|
||||
}
|
||||
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
|
||||
xhpcSt.setStatus(i+1);
|
||||
xhpcSt.setChargingTime(timeInterval);
|
||||
xhpcSt.setChargingTime(timeInterval.divide(new BigDecimal(60),2,BigDecimal.ROUND_DOWN));
|
||||
//电量
|
||||
BigDecimal decimal1 = timeInterval.multiply(decimal).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
xhpcSt.setChargingDegree(decimal1);
|
||||
@ -522,7 +704,11 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
|
||||
xhpcSt.setDelFlag(0);
|
||||
xhpcSt.setCreateTime(Calendar.getInstance().getTime());
|
||||
if(type!=3){
|
||||
xhpcSt.setCreateTime(xhpc.getCreateTime());
|
||||
}else{
|
||||
xhpcSt.setCreateTime(DateUtil.offset(xhpc.getCreateTime(), DateField.DAY_OF_MONTH, 1));
|
||||
}
|
||||
xhpcSt.setTerminalId(xhpc.getTerminalId());
|
||||
xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+srt);
|
||||
@ -583,13 +769,6 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
chargeOrderService.updateStatus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void add(int number,int type){
|
||||
//获取500条待统计历史订单
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(number,type);
|
||||
@ -624,246 +803,24 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setType(type);
|
||||
xhpcSt.setCreateTime(xhpc.getCreateTime());
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
|
||||
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
if("00:00:00".equals(endTime1)){
|
||||
endTime1="23:59:59";
|
||||
}
|
||||
//总度数
|
||||
BigDecimal chargingDegree2 = new BigDecimal((DateUtil.parse(endTime1).getTime() - DateUtil.parse(startTime1).getTime())/60000).multiply(divide).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
chargingDegree1 =chargingDegree1.add(chargingDegree2);
|
||||
powerPrice1 =powerPrice1.add(powerPrice.multiply(chargingDegree2).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
servicePrice1 =servicePrice1.add(servicePrice.multiply(chargingDegree2).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
}
|
||||
}
|
||||
|
||||
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, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActPrice(xhpcSt.getTotalPrice().subtract(xhpcSt.getPromotionDiscount()));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion,2, BigDecimal.ROUND_DOWN));
|
||||
|
||||
//抽成费用
|
||||
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);
|
||||
xhpcSt.setCreateTime(xhpc.getCreateTime());
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
|
||||
}
|
||||
|
||||
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);
|
||||
for (int i = startHour; i < endHour + 1; i++) {
|
||||
String end = String.format("%02d", i);
|
||||
//获取费率
|
||||
if (i == startHour) {
|
||||
//开始时间、结束时间
|
||||
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, DateUtil.formatTime(startTime), end + ":59:59",yyyyMMdd,multiply);
|
||||
} else if (i != endHour) {
|
||||
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, end + ":00:00", end + ":59:59",yyyyMMdd,multiply);
|
||||
} else {
|
||||
addStatis(xhpc, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, i, number, end + ":00:00", DateUtil.formatTime(endTime),yyyyMMdd,multiply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addInterval(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour,String yyyyMMdd,BigDecimal multiply) {
|
||||
Date data = Calendar.getInstance().getTime();
|
||||
if(endHour==startHour){
|
||||
//没有跨时段
|
||||
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
|
||||
xhpcSt.setStatus(endHour+1);
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()/3600).setScale(2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setChargingNumber(1);
|
||||
BigDecimal number = new BigDecimal(2);
|
||||
xhpcSt.setPowerPrice(xhpc.getActPowerPrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setServicePrice(xhpc.getActServicePrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setTotalPrice(xhpc.getTotalPrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActPrice(xhpc.getActPrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(number,2,BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperatorId(operatorId);
|
||||
xhpcSt.setChargingStationId(chargingStationId);
|
||||
xhpcSt.setCreateTime(data);
|
||||
xhpcSt.setTerminalId(terminalId);
|
||||
xhpcSt.setHistoryOrderId(historyOrderId);
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId);
|
||||
Map<String, Object> map = reatTimeList.get(0);
|
||||
xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString()));
|
||||
xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString()));
|
||||
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
|
||||
xhpcStatisticsService.addStatisticsTime(xhpcSt);
|
||||
//修改状态
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
|
||||
}else{
|
||||
//跨时段
|
||||
//总共时段 endHour+1-startHour
|
||||
addStatisTime(xhpc, startTime, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply);
|
||||
}
|
||||
}
|
||||
|
||||
private void addStatis(XhpcChargeHistoryOrder xhpc, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int status, BigDecimal number, String start, String end,String yyyyMMdd,BigDecimal multiply) {
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(start, end, rateModelId);
|
||||
if (reatTimeList != null && reatTimeList.size() > 0) {
|
||||
if (reatTimeList.size() == 1) {
|
||||
addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, status, number, reatTimeList, -1, 1,start,end,yyyyMMdd,multiply);
|
||||
} else {
|
||||
for (int j = 0; j < reatTimeList.size(); j++) {
|
||||
addSte(xhpc, operatorId, chargingStationId, terminalId, historyOrderId, status, number, reatTimeList, j, 2,start,end,yyyyMMdd,multiply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addSte(XhpcChargeHistoryOrder xhpc, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int status, BigDecimal number, List<Map<String, Object>> reatTimeList, int j, int type, String start, String end,String yyyyMMdd,BigDecimal multiply) {
|
||||
Date data = Calendar.getInstance().getTime();
|
||||
Map<String, Object> map =new HashMap<>();
|
||||
if(j==-1){
|
||||
map = reatTimeList.get(0);
|
||||
}else{
|
||||
map = reatTimeList.get(j);
|
||||
}
|
||||
BigDecimal size = new BigDecimal(reatTimeList.size());
|
||||
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
|
||||
long time3 =0L;
|
||||
long time4 =0L;
|
||||
if(j==-1){
|
||||
time3 = DateUtil.parse(end).getTime();
|
||||
time4 = DateUtil.parse(start).getTime();
|
||||
xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+start);
|
||||
xhpcSt.setEndTimeEvcs(yyyyMMdd+" "+end);
|
||||
}else if(j==0){
|
||||
time3 = DateUtil.parse(map.get("endTime").toString()).getTime();
|
||||
time4 = DateUtil.parse(start).getTime();
|
||||
xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+start);
|
||||
xhpcSt.setEndTimeEvcs(yyyyMMdd+" "+map.get("endTime").toString());
|
||||
}else if(j!=reatTimeList.size()){
|
||||
time3 = DateUtil.parse(map.get("endTime").toString()).getTime();
|
||||
time4 = DateUtil.parse(map.get("startTime").toString()).getTime();
|
||||
xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+map.get("startTime").toString());
|
||||
xhpcSt.setEndTimeEvcs(yyyyMMdd+" "+map.get("endTime").toString());
|
||||
}else{
|
||||
time3 = DateUtil.parse(end).getTime();
|
||||
time4 = DateUtil.parse(map.get("startTime").toString()).getTime();
|
||||
xhpcSt.setStartTimeEvcs(yyyyMMdd+" "+map.get("startTime").toString());
|
||||
xhpcSt.setEndTimeEvcs(yyyyMMdd+" "+end);
|
||||
}
|
||||
BigDecimal time5 = new BigDecimal((time3-time4)).divide(new BigDecimal(60000),2, BigDecimal.ROUND_DOWN);
|
||||
//每分钟多少度电
|
||||
BigDecimal decimal = multiply.multiply(time5).setScale(2,BigDecimal.ROUND_DOWN);
|
||||
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
|
||||
BigDecimal serviceFee =new BigDecimal(map.get("serviceFee").toString());
|
||||
xhpcSt.setElecPriceEvcs(powerFee);
|
||||
xhpcSt.setServicePriceEvcs(serviceFee);
|
||||
xhpcSt.setStatus(status+1);
|
||||
xhpcSt.setChargingDegree(decimal);
|
||||
xhpcSt.setChargingTime(time5);
|
||||
xhpcSt.setChargingNumber(1);
|
||||
BigDecimal powerFee1 = powerFee.multiply(decimal).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
BigDecimal serviceFee1 = serviceFee.multiply(decimal).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
xhpcSt.setPowerPrice(powerFee1);
|
||||
xhpcSt.setServicePrice(serviceFee1);
|
||||
xhpcSt.setTotalPrice(powerFee1.add(serviceFee1));
|
||||
if(type==1){
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActPrice(powerFee1.add(serviceFee1).subtract(xhpcSt.getPromotionDiscount()));
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(number,2, BigDecimal.ROUND_DOWN));
|
||||
}else{
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActPrice(powerFee1.add(serviceFee1).subtract(xhpcSt.getPromotionDiscount()));
|
||||
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setActServicePrice(xhpc.getActServicePrice().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(number,2, BigDecimal.ROUND_DOWN).divide(size,2, BigDecimal.ROUND_DOWN));
|
||||
}
|
||||
xhpcSt.setOperatorId(operatorId);
|
||||
xhpcSt.setChargingStationId(chargingStationId);
|
||||
xhpcSt.setCreateTime(data);
|
||||
xhpcSt.setTerminalId(terminalId);
|
||||
xhpcSt.setHistoryOrderId(historyOrderId);
|
||||
if(xhpc.getSource()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
|
||||
xhpcStatisticsService.addStatisticsTime(xhpcSt);
|
||||
//修改状态
|
||||
//修改历史订单表状态
|
||||
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String dateStr = "2017-03-01 20:33:23";
|
||||
Date date = DateUtil.parse(dateStr);
|
||||
|
||||
|
||||
String dateStr1 = "2017-03-01 22:33:23";
|
||||
Date date1 = DateUtil.parse(dateStr1);
|
||||
|
||||
System.out.println(date1.getTime()-date.getTime());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,6 +91,18 @@ public class XhpcAppUserController extends BaseController {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/userSum")
|
||||
public AjaxResult userSum(String phone) {
|
||||
return AjaxResult.success(iXhpcAppUserUserService.userSum(phone));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 以下为小程序接口
|
||||
*/
|
||||
|
||||
@ -54,6 +54,9 @@ public interface XhpcAppUserMapper {
|
||||
*/
|
||||
public List<Map<String, Object>> selectAppUserList(@Param("phone") String phone);
|
||||
|
||||
|
||||
public Map<String, Object> userSum(@Param("phone") String phone);
|
||||
|
||||
/**
|
||||
* 手机号查询C端用户信息
|
||||
*
|
||||
|
||||
@ -39,6 +39,8 @@ public interface IXhpcAppUserUserService {
|
||||
*/
|
||||
public List<Map<String, Object>> selectAppUserList(String phone);
|
||||
|
||||
|
||||
public Map<String, Object> userSum(String phone);
|
||||
/**
|
||||
* 禁用/启用C端用户
|
||||
*
|
||||
|
||||
@ -82,6 +82,12 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
|
||||
return xhpcAppUserMapper.selectAppUserList(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> userSum(String phone) {
|
||||
|
||||
return xhpcAppUserMapper.userSum(phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用/启用C端用户
|
||||
*
|
||||
|
||||
@ -197,6 +197,22 @@
|
||||
ORDER BY xau.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="userSum" resultType="map">
|
||||
select
|
||||
count(xau.app_user_id) userSum,
|
||||
(select count(app_user_id) from xhpc_app_user where datediff(now(),create_time)>30) userVitality
|
||||
from xhpc_app_user xau
|
||||
LEFT JOIN (select count(1) count ,user_id from xhpc_charge_order where del_flag = 0 ) a on a.user_id =
|
||||
xau.app_user_id
|
||||
WHERE xau.del_flag = 0
|
||||
<if test="phone != null and phone != ''">
|
||||
and xau.phone like concat(concat('%', #{phone}), '%')
|
||||
</if>
|
||||
ORDER BY xau.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="getAppUserByPhone" parameterType="java.lang.String" resultMap="XhpcAppUserResult">
|
||||
select *
|
||||
from xhpc_app_user
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user