修改社区、B端用户充电逻辑

This commit is contained in:
yuyang 2022-01-27 17:20:30 +08:00
parent 575cab9590
commit 5e4c675bb4
10 changed files with 470 additions and 387 deletions

View File

@ -197,4 +197,9 @@ public class Constants
* 模板id为null * 模板id为null
*/ */
public static final String LNVALID_RATE_MODE = "lnvalid rateModelId"; public static final String LNVALID_RATE_MODE = "lnvalid rateModelId";
/**
* 数据问题报错
*/
public static final String DATA_EXCEPTION = "data exception";
} }

View File

@ -326,7 +326,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
OrderDatasDTO orderDatasDTO = new OrderDatasDTO(); OrderDatasDTO orderDatasDTO = new OrderDatasDTO();
orderDatasDTO.setOrderId((Long) data.get("historyOrderId")); orderDatasDTO.setOrderId((Long) data.get("historyOrderId"));
orderDatasDTO.setOrderNumber((String) data.get("serialNumber")); orderDatasDTO.setOrderNumber((String) data.get("serialNumber"));
orderDatasDTO.setOrderMoney((BigDecimal) data.get("actPrice")); orderDatasDTO.setOrderMoney(new BigDecimal(data.get("actPrice").toString()));
//因为数据库中存储的时间类型为datetime所以Mybatis会将其转换为LocalDateTime类型对象我们不能直接得到Date所以我们需要对其进行转换 //因为数据库中存储的时间类型为datetime所以Mybatis会将其转换为LocalDateTime类型对象我们不能直接得到Date所以我们需要对其进行转换
LocalDateTime createTime = (LocalDateTime) data.get("createTime"); LocalDateTime createTime = (LocalDateTime) data.get("createTime");
ZoneId zoneId = ZoneId.systemDefault(); ZoneId zoneId = ZoneId.systemDefault();

View File

@ -396,7 +396,8 @@ public class XhpcPileOrderController extends BaseController {
} }
xhpcHistoryOrder.setType(1); xhpcHistoryOrder.setType(1);
//结算 //结算
xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder); R r = xhpcRealTimeOrderService.addSettlement(powerPrice,servicePrice,money,surplusPowerPrice,surplusServicePrice,xhpcChargeOrder,userId,userMessage,1,cacheOrderData.getVinNormal(),xhpcHistoryOrder);
if(r.getCode()==200){
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);
@ -413,6 +414,9 @@ public class XhpcPileOrderController extends BaseController {
} }
webSocketService.getMessage(message,json.toString()); webSocketService.getMessage(message,json.toString());
} }
}else{
return R.fail();
}
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return R.fail(500,"添加订单回调失败"); return R.fail(500,"添加订单回调失败");

View File

@ -44,13 +44,29 @@ public interface XhpcChargeOrderMapper {
Map<String,Object> getUserMessage(@Param("userId")Long userId); Map<String,Object> getUserMessage(@Param("userId")Long userId);
/** /**
* 修改余额 * C端用户修改余额
* @param userId * @param userId
* @param balance * @param balance
* @return * @return
*/ */
int updateUserBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance); int updateUserBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/**
* 社区用户修改余额
* @param userId
* @param balance
* @return
*/
int updateCommunityBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/**
* B端用户修改余额
* @param userId
* @param balance
* @return
*/
int updateCustomersBalance(@Param("userId")Long userId, @Param("balance")BigDecimal balance);
/** /**
* 判断用户是否在充电中 * 判断用户是否在充电中
*/ */
@ -137,7 +153,7 @@ public interface XhpcChargeOrderMapper {
* @param date 时间 * @param date 时间
* @return * @return
*/ */
int insertUserAccountStatement(@Param("userId") Long userId,@Param("amount") BigDecimal amount,@Param("remainingSum") BigDecimal remainingSum,@Param("chargeOrderId") Long chargeOrderId,@Param("type") Integer type,@Param("date") Date date); int insertUserAccountStatement(@Param("userId") Long userId,@Param("amount") BigDecimal amount,@Param("remainingSum") BigDecimal remainingSum,@Param("chargeOrderId") Long chargeOrderId,@Param("type") Integer type,@Param("date") Date date,@Param("source")Integer source);
/** /**
* 获取费率 * 获取费率

View File

@ -129,7 +129,7 @@ public interface IXhpcChargeOrderService {
* @return * @return
*/ */
int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId, Integer type, int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId, Integer type,
Date date); Date date,Integer source);
XhpcChargeOrder getChargingOrderId(Long chargingOrderId); XhpcChargeOrder getChargingOrderId(Long chargingOrderId);

View File

@ -1,5 +1,6 @@
package com.xhpc.order.service; package com.xhpc.order.service;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.data.redis.CacheRealtimeData; import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.order.domain.*; import com.xhpc.order.domain.*;
@ -115,7 +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, R addSettlement(BigDecimal powerPrice, BigDecimal servicePrice, BigDecimal money, BigDecimal surplusPowerPrice,
BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId, BigDecimal surplusServicePrice, XhpcChargeOrder xhpcChargeOrder, Long userId,
Map<String, Object> userMessage, Integer type, String vinNormal, XhpcHistoryOrder xhpcHistoryOrder); Map<String, Object> userMessage, Integer type, String vinNormal, XhpcHistoryOrder xhpcHistoryOrder);

View File

@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -230,8 +231,8 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
//用户平台最小的 //用户平台最小的
int number =0; int number =0;
if(!"".equals(userMessage.get("soc")) && userMessage.get("soc") !=null && !"".equals(userMessage.get("soc"))){ if(!"".equals(userMessage.get("socUser")) && userMessage.get("socUser") !=null && !"".equals(userMessage.get("socUser"))){
number =Integer.parseInt(userMessage.get("soc").toString()); number =Integer.parseInt(userMessage.get("socUser").toString());
} }
//平台 //平台
String soc = redisService.getCacheObject("global:SOC"); String soc = redisService.getCacheObject("global:SOC");
@ -381,8 +382,15 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
@Override @Override
public int updateUserBalance(Long userId, BigDecimal balance,Integer source,String tenantId) { public int updateUserBalance(Long userId, BigDecimal balance,Integer source,String tenantId) {
//修改用户余额
if(UserTypeUtil.USER_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateUserBalance(userId, balance); return xhpcChargeOrderMapper.updateUserBalance(userId, balance);
}else if (UserTypeUtil.COMMUNIT_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateCommunityBalance(userId, balance);
}else if(UserTypeUtil.CUSTOMERS_TYPE.equals(source)){
return xhpcChargeOrderMapper.updateCustomersBalance(userId, balance);
}
return 0;
} }
@Override @Override
@ -399,9 +407,9 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
@Override @Override
public int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId, public int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId,
Integer type, Date date) { Integer type, Date date,Integer source) {
return xhpcChargeOrderMapper.insertUserAccountStatement(userId, amount, remainingSum, chargeOrderId, type, date); return xhpcChargeOrderMapper.insertUserAccountStatement(userId, amount, remainingSum, chargeOrderId, type, date,source);
} }
@Override @Override
@ -629,7 +637,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
@Override @Override
public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId) { public R cardStartup(Long userId, String serialNumber, Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId) {
try{
R user = userTypeService.getUser(null, userId, userType, null,tenantId); R user = userTypeService.getUser(null, userId, userType, null,tenantId);
if(user ==null || user.getData() ==null){ if(user ==null || user.getData() ==null){
return R.fail(Constants.LNVALID_USER); return R.fail(Constants.LNVALID_USER);
@ -737,8 +745,40 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
Map<String,Object> map =new HashMap<>(); Map<String,Object> map =new HashMap<>();
map.put("balance",userMessage.get("balance")); map.put("balance",userMessage.get("balance"));
map.put("serialNumber",orderNo); map.put("serialNumber",orderNo);
//用户平台最小的
int number =0;
if(!"".equals(userMessage.get("socUser")) && userMessage.get("socUser") !=null && !"".equals(userMessage.get("socUser"))){
number =Integer.parseInt(userMessage.get("socUser").toString());
}
//平台
String soc = redisService.getCacheObject("global:SOC");
if(!"".equals(soc) && soc!=null){
if(number!=0){
if(Integer.parseInt(soc)-number<0){
number=Integer.parseInt(soc);
}
}else{
number=Integer.parseInt(soc);
}
}
Map<String, Object> operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId());
if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){
if(number!=0){
if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){
number=Integer.parseInt(operatorMessage.get("soc").toString());
}
}else{
number=Integer.parseInt(operatorMessage.get("soc").toString());
}
}
map.put("soc",number);
return R.ok(map); return R.ok(map);
}catch (Exception e){
//数据回滚
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return R.fail(Constants.DATA_EXCEPTION);
} }
public static boolean isValidDate(String str) { public static boolean isValidDate(String str) {

View File

@ -650,7 +650,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
} }
//扣除用户实际消费金额添加消费记录-余的钱 //扣除用户实际消费金额添加消费记录-余的钱
BigDecimal balance1 =(BigDecimal) userMessage.get("balance"); BigDecimal balance1 =new BigDecimal(userMessage.get("balance").toString());
BigDecimal subtract = balance1.subtract(actPrice); BigDecimal subtract = balance1.subtract(actPrice);
int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,source,xhpcChargeOrder.getTenantId()); int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,source,xhpcChargeOrder.getTenantId());
if(i==0){ if(i==0){
@ -659,7 +659,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
xhpcChargeOrder.setErroRemark("扣钱失败"); xhpcChargeOrder.setErroRemark("扣钱失败");
}else{ }else{
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,source);
map.put("userId",userId); map.put("userId",userId);
map.put("amount",subtract); map.put("amount",subtract);
if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){ if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){
@ -749,8 +749,8 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
Date updateTime = DateUtil.endOfDay(startTime2); Date updateTime = DateUtil.endOfDay(startTime2);
Map<String, Object> map1 = getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list); Map<String, Object> map1 = getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list);
//获取 //获取
BigDecimal powerPriceTotal1 = (BigDecimal) map1.get("powerPriceTotal"); BigDecimal powerPriceTotal1 = new BigDecimal(map1.get("powerPriceTotal").toString());
BigDecimal servicePriceTotal1 = (BigDecimal) map1.get("servicePriceTotal"); BigDecimal servicePriceTotal1 = new BigDecimal(map1.get("servicePriceTotal").toString());
//明天 //明天
DateTime tomorrow = DateUtil.offsetDay(startTime2, 1); DateTime tomorrow = DateUtil.offsetDay(startTime2, 1);
Date startTime3 = DateUtil.beginOfDay(tomorrow); Date startTime3 = DateUtil.beginOfDay(tomorrow);

View File

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.RefundOrderService; import com.xhpc.common.api.RefundOrderService;
import com.xhpc.common.api.SmsService; import com.xhpc.common.api.SmsService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.SecurityUtils; import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService; import com.xhpc.common.core.web.service.BaseService;
@ -23,6 +24,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@ -355,7 +357,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
* @param type 0 不发短信 1发短信 * @param type 0 不发短信 1发短信
*/ */
@Override @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) { public R 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) {
try{
xhpcHistoryOrder.setPowerPriceTotal(powerPrice); xhpcHistoryOrder.setPowerPriceTotal(powerPrice);
xhpcHistoryOrder.setServicePriceTotal(servicePrice); xhpcHistoryOrder.setServicePriceTotal(servicePrice);
xhpcHistoryOrder.setVinNormal(vinNormal); xhpcHistoryOrder.setVinNormal(vinNormal);
@ -568,9 +572,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
String evcs = EvcsUtil.transferInternetOrderNo(xhpcChargeOrder.getSerialNumber(), operatorMessage.get("operatorId").toString()); String evcs = EvcsUtil.transferInternetOrderNo(xhpcChargeOrder.getSerialNumber(), operatorMessage.get("operatorId").toString());
xhpcHistoryOrder.setEvcsOrderNo(evcs); xhpcHistoryOrder.setEvcsOrderNo(evcs);
} }
//扣除用户实际消费金额添加消费记录 剩余的钱 //扣除用户实际消费金额添加消费记录 剩余的钱
BigDecimal balance1 =(BigDecimal) userMessage.get("balance"); BigDecimal balance1 =new BigDecimal(userMessage.get("balance").toString());
BigDecimal subtract = balance1.subtract(actPrice); BigDecimal subtract = balance1.subtract(actPrice);
int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId()); int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId());
if(i==0){ if(i==0){
@ -579,7 +582,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcChargeOrder.setErroRemark("扣钱失败"); xhpcChargeOrder.setErroRemark("扣钱失败");
}else{ }else{
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,xhpcChargeOrder.getSource());
map.put("userId",userId); map.put("userId",userId);
map.put("amount",subtract); map.put("amount",subtract);
if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){ if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){
@ -591,51 +594,59 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
} }
map.put("remark","充电结算自动申请退款"); map.put("remark","充电结算自动申请退款");
} }
}
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
logger.info("<<<<<<<<<<<<<<<<订单结束异步之前>>>>>>>>>>>>>>>>>"+xhpcHistoryOrder.getSerialNumber());
final BigDecimal balance = actPrice;
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
public void run() {
try{ try{
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId()); Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>");
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>");
refundOrderService.sendNotice(map);
}
}
if(!UserTypeUtil.INSERT_BALANCE.equals(source)){
Map<String, Object> userMassage = xhpcChargeOrderService.getUserMessage(userId);
if(xhpcChargingPile !=null){ if(xhpcChargingPile !=null){
//发送短信 //发送短信
if(userMessage.get("phone") !=null){ if(userMassage !=null && userMassage.get("phone") !=null){
if("1".equals(xhpcChargingPile.get("type").toString())){ if("1".equals(xhpcChargingPile.get("type").toString())){
HashMap<String, String> paramMap = new HashMap<>(); HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("elec", xhpcChargeOrder.getEndSoc()); paramMap.put("elec", xhpcChargeOrder.getEndSoc());
paramMap.put("sumMoney", actPrice.toString()); paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMessage.get("phone").toString()); paramMap.put("phone", userMassage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。"); paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap); smsService.sendNotice(paramMap);
}else { }else {
HashMap<String, String> paramMap = new HashMap<>(); HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("sumMoney", actPrice.toString()); paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMessage.get("phone").toString()); paramMap.put("phone", userMassage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + actPrice + "元,充电费用明细,请查询小华充电小程序,谢谢。"); paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap); smsService.sendNotice(paramMap);
} }
} }
} }
}
}catch (Exception e){ }catch (Exception e){
logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>");
} }
}
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
public void run() {
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
refundOrderService.sendNotice(map);
}
addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1); addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
} }
}); });
// redisService.deleteObject("pushOrder:"+xhpcChargeOrder.getSerialNumber()); }catch (Exception e){
logger.info("<<<<<<<<<<<<<<<<运行异常,结算失败,数据回滚>>>>>>>>>>>>>>>>>");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return R.fail();
}
return R.ok();
} }
@Override @Override

View File

@ -127,6 +127,12 @@
<update id="updateUserBalance"> <update id="updateUserBalance">
update xhpc_app_user set balance=#{balance} where app_user_id=#{userId} update xhpc_app_user set balance=#{balance} where app_user_id=#{userId}
</update> </update>
<update id="updateCommunityBalance">
update xhpc_community_personnel set surplus_money=#{balance} where community_personnel_id=#{userId}
</update>
<update id="updateCustomersBalance">
update xhpc_customers_personnel set surplus_money=#{balance} where customers_personnel_id=#{userId}
</update>
<select id="countXhpcRealTimeOrder" resultType="String"> <select id="countXhpcRealTimeOrder" resultType="String">
select select
charge_order_id as chargeOrderId charge_order_id as chargeOrderId
@ -518,8 +524,8 @@
</insert> </insert>
<insert id="insertUserAccountStatement"> <insert id="insertUserAccountStatement">
INSERT INTO xhpc_user_account_statement(user_id, amount, remaining_sum, charge_order_id, type, create_time) INSERT INTO xhpc_user_account_statement(user_id, amount, remaining_sum, charge_order_id, type, create_time,source)
values (#{userId}, #{amount}, #{remainingSum}, #{chargeOrderId}, #{type}, #{date}) values (#{userId}, #{amount}, #{remainingSum}, #{chargeOrderId}, #{type}, #{date},#{source})
</insert> </insert>
<select id="getRateModelId" resultMap="XhpcRateMap"> <select id="getRateModelId" resultMap="XhpcRateMap">