修改小时统计金额异常问题

This commit is contained in:
yuyang 2021-11-10 16:27:58 +08:00
parent b1c6171bea
commit 0f11b04fe1
7 changed files with 82 additions and 67 deletions

View File

@ -1114,7 +1114,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
@Override @Override
public Integer getTerminalStatus(String serialNumber) { public Integer getTerminalStatus(String serialNumber) {
Integer status =0; Integer status =5;
//终端状态用 redis数据 //终端状态用 redis数据
if(!"".equals(serialNumber) && serialNumber!=null){ if(!"".equals(serialNumber) && serialNumber!=null){
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber); Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber);
@ -1133,11 +1133,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
//充电桩 //充电桩
status = 3; status = 3;
} }
} else {
status = 5;
} }
} else {
status = 5;
} }
return status; return status;
} }

View File

@ -169,10 +169,12 @@ public class XhpcPileOrderController extends BaseController {
}else{ }else{
//修改订单判断订单 //修改订单判断订单
} }
map.put("code", code); if(xhpcChargeOrder.getSource()==0){
JSONObject json = new JSONObject(map); map.put("code", code);
//消息对了内容 JSONObject json = new JSONObject(map);
webSocketService.getMessage(userId+"",json.toString()); //消息对了内容
webSocketService.getMessage(userId+"",json.toString());
}
return R.ok(); return R.ok();
} }
@ -190,25 +192,27 @@ public class XhpcPileOrderController extends BaseController {
CacheRealtimeData cacheRealtimeData = redisService.getCacheObject("order:" + orderNo + ".lord"); CacheRealtimeData cacheRealtimeData = redisService.getCacheObject("order:" + orderNo + ".lord");
XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo); XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo);
Long userId = xhpcChargeOrder.getUserId(); if(xhpcChargeOrder.getSource()==0){
try { Long userId = xhpcChargeOrder.getUserId();
Date date = new Date(); try {
xhpcChargeOrder.setEndTime(date); Date date = new Date();
xhpcChargeOrder.setUpdateTime(date); xhpcChargeOrder.setEndTime(date);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); xhpcChargeOrder.setUpdateTime(date);
Map<String, Object> map = xhpcRealTimeOrderService.addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, 1); xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
JSONObject json = new JSONObject(map); Map<String, Object> map = xhpcRealTimeOrderService.addOrderTime(cacheRealtimeData, xhpcChargeOrder, orderNo, 1);
//消息对了内容 JSONObject json = new JSONObject(map);
webSocketService.getMessage(userId+"",json.toString()); //消息对了内容
logger.info("桩实时数据发送WebSocket成功>>>>>orderNo" + orderNo); webSocketService.getMessage(userId+"",json.toString());
} catch (Exception e) { logger.info("桩实时数据发送WebSocket成功>>>>>orderNo" + orderNo);
Map<String, Object> map = new HashMap<>(); } catch (Exception e) {
map.put("code", 500); Map<String, Object> map = new HashMap<>();
map.put("userId", xhpcChargeOrder.getUserId()); map.put("code", 500);
JSONObject json = new JSONObject(map); map.put("userId", xhpcChargeOrder.getUserId());
//消息对了内容 JSONObject json = new JSONObject(map);
webSocketService.getMessage(userId+"",json.toString()); //消息对了内容
return R.fail(500,"无实时数据"); webSocketService.getMessage(userId+"",json.toString());
return R.fail(500,"无实时数据");
}
} }
return R.ok(); return R.ok();
} }
@ -345,15 +349,19 @@ public class XhpcPileOrderController extends BaseController {
xhpcHistoryOrder.setTotalPower(totalPower.doubleValue()/10000); 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 =new HashMap<>();
if (userMessage == null || userMessage.get("balance") == null) { if(xhpcChargeOrder.getSource()==1 && xhpcChargeOrder.getInternetSerialNumber() !=null){
//订单异常 userMessage = xhpcChargeOrderService.getUserMessage(userId);
xhpcChargeOrder.setStatus(2); if (userMessage == null || userMessage.get("balance") == null) {
//异常原因 //订单异常
xhpcChargeOrder.setErroRemark("桩异常:" + stopReason + ">>>>用户id:" + userId + "为空"); xhpcChargeOrder.setStatus(2);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); //异常原因
R.ok(); xhpcChargeOrder.setErroRemark("桩异常:" + stopReason + ">>>>用户id:" + userId + "为空");
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
R.ok();
}
} }
//结算 //结算
xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder); xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();

View File

@ -87,16 +87,22 @@ public class XhpcHistoryOrderController extends BaseController {
* 终端统计 * 终端统计
*/ */
@GetMapping("/test3") @GetMapping("/test3")
@Scheduled(cron = "0 0 12 * * ?") @Scheduled(cron = "0 0 * * * ?")
public void test3(){ public void test3(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>终端统计定时任务>>>>>>>>>>>>>>>>>>>>>");
add(1000,3); add(1000,3);
} }
/** /**
* 场站统计 * 场站统计
*/ */
@GetMapping("/test2") @GetMapping("/test2")
@Scheduled(cron = "0 0 11 * * ?") @Scheduled(cron = "0 0/30 * * * ?")
public void test2(){ public void test2(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>场站统计定时任务>>>>>>>>>>>>>>>>>>>>>");
add(1000,2); add(1000,2);
} }
@ -104,8 +110,11 @@ public class XhpcHistoryOrderController extends BaseController {
* 日期统计 * 日期统计
*/ */
@GetMapping("/test1") @GetMapping("/test1")
@Scheduled(cron = "0 0 00 * * ?") @Scheduled(cron = "0 0/20 * * * ?")
public void test1(){ public void test1(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>日期统计定时任务>>>>>>>>>>>>>>>>>>>>>");
//获取500条待统计历史订单 //获取500条待统计历史订单
//跨时段跨费率计费模型 //跨时段跨费率计费模型
//日期统计 //日期统计
@ -188,7 +197,7 @@ public class XhpcHistoryOrderController extends BaseController {
* 小时统计 * 小时统计
*/ */
@GetMapping("/test") @GetMapping("/test")
@Scheduled(cron = "0 */1 * * * ?") @Scheduled(cron = "0 0/5 * * * ?")
public void test(){ public void test(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>"); logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>");

View File

@ -117,7 +117,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
@Override @Override
public void addXhpcChargeOrder(String orderNo,Integer type) { public void addXhpcChargeOrder(String orderNo,Integer type) {
//(调用时间-启动时间3分钟 自动结算) //(调用时间-启动时间3分钟 自动结算)
logger.info("订单异常回调接口>>>>>orderNo" + orderNo); logger.info("订单异常回调接口>>>>>orderNo" + orderNo+" type:"+type);
//获取实时订单 //获取实时订单
CacheRealtimeData cacheRealtimeData = redisService.getCacheObject("order:" + orderNo + ".lord"); CacheRealtimeData cacheRealtimeData = redisService.getCacheObject("order:" + orderNo + ".lord");
if(cacheRealtimeData !=null){ if(cacheRealtimeData !=null){

View File

@ -210,7 +210,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setVinNormal(vinNormal); xhpcHistoryOrder.setVinNormal(vinNormal);
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(100));
//电站活动抵扣--抵扣的总金额 //电站活动抵扣--抵扣的总金额
BigDecimal promotionDiscount = new BigDecimal(0); BigDecimal promotionDiscount = new BigDecimal(0);
//实际价格-用户支付的钱 //实际价格-用户支付的钱
@ -252,6 +252,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
} }
} }
if ( source== 0) { if ( source== 0) {
BigDecimal balance = new BigDecimal(userMessage.get("balance").toString()).divide(new BigDecimal(100));
String state = ""; String state = "";
BigDecimal discount = new BigDecimal(0); BigDecimal discount = new BigDecimal(0);
//用户第几次充电 //用户第几次充电
@ -385,19 +386,18 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
xhpcHistoryOrder.setPhone(userMessage.get("phone").toString()); xhpcHistoryOrder.setPhone(userMessage.get("phone").toString());
xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower())); xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower()));
//扣除用户实际消费金额添加消费记录 if(source==0){
Map<String, Object> user = xhpcChargeOrderService.getUserMessage(userId); //扣除用户实际消费金额添加消费记录
//剩余的钱 Map<String, Object> user = xhpcChargeOrderService.getUserMessage(userId);
BigDecimal balance1 =(BigDecimal) user.get("balance"); //剩余的钱
BigDecimal subtract = balance1.subtract(actPrice); BigDecimal balance1 =(BigDecimal) user.get("balance");
int i = xhpcChargeOrderService.updateUserBalance(userId, subtract); BigDecimal subtract = balance1.subtract(actPrice);
if(i==0){ int i = xhpcChargeOrderService.updateUserBalance(userId, subtract);
//扣钱失败 if(i==0){
xhpcChargeOrder.setStatus(2); //扣钱失败
xhpcChargeOrder.setErroRemark("扣钱失败"); xhpcChargeOrder.setStatus(2);
}else{ xhpcChargeOrder.setErroRemark("扣钱失败");
xhpcHistoryOrderService.insert(xhpcHistoryOrder); }
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date);
try{ try{
@ -425,13 +425,15 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>");
} }
// 另起线程处理业务上传redis数据 // 另起线程处理业务上传redis数据
// executorService.execute(new Runnable() { executorService.execute(new Runnable() {
// @Override @Override
// public void run() { public void run() {
// addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
// } }
// }); });
} }
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder); xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
} }

View File

@ -610,7 +610,7 @@
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2 left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
where ho.status =0 and ho.del_flag=0 where ho.status =0 and ho.del_flag=0 and ho.total_price !=null
<if test="type !=null"> <if test="type !=null">
and ho.type=#{type} and ho.type=#{type}
</if> </if>
@ -670,8 +670,8 @@
from xhpc_rate_time as rt from xhpc_rate_time as rt
left join xhpc_rate ra on rt.rate_id =ra.rate_id left join xhpc_rate ra on rt.rate_id =ra.rate_id
where rt.rate_model_id=#{rateModelId} where rt.rate_model_id=#{rateModelId}
and ((rt.start_time &lt;= #{startTime} and replace(rt.end_time, '00:00:00', '23:59:59') &gt;= #{startTime}) and ((rt.start_time &lt; #{startTime} and replace(rt.end_time, '00:00:00', '23:59:59') &gt; #{startTime})
or (rt.start_time &lt;= #{endTime} and replace(rt.end_time, '00:00:00', '23:59:59') &gt;= #{endTime})) or (rt.start_time &lt; #{endTime} and replace(rt.end_time, '00:00:00', '23:59:59') &gt; #{endTime}))
</select> </select>
<select id="getById" resultType="map"> <select id="getById" resultType="map">
@ -772,7 +772,7 @@
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.state = #{state} and ho.total_price &gt;0 and ho.end_time &gt; ho.start_time where ho.state = #{state} and ho.total_price &gt;0 and ho.end_time &gt; ho.start_time and ho.vin_normal !="2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D" and ho.power_price_total !=0
limit 0,#{number} limit 0,#{number}
</select> </select>

View File

@ -16,10 +16,10 @@ spring:
nacos: nacos:
discovery: discovery:
# 服务注册地址 # 服务注册地址
server-addr: 172.31.183.135:8848 server-addr: 127.0.0.1:8848
config: config:
# 配置中心地址 # 配置中心地址
server-addr: 172.31.183.135:8848 server-addr: 127.0.0.1:8848
# 配置文件格式 # 配置文件格式
file-extension: yml file-extension: yml
# 共享配置 # 共享配置