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

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

View File

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

View File

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

View File

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

View File

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

View File

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