充电结算自动退款

This commit is contained in:
yuyang 2022-02-17 18:36:29 +08:00
parent 430cc48f8d
commit 1f41d92b8c
6 changed files with 208 additions and 48 deletions

View File

@ -91,5 +91,14 @@ public class UserTypeUtil {
public static final String SYS_USER_TYPE_TWO = "02";
public static final String SYS_USER_TYPE_THREE = "03";
/**
* 启动方式 微信支付宝刷卡
*/
public static final String CHARGING_MODE_WX = "微信";
public static final String CHARGING_MODE_ZFB = "支付宝";
public static final String CHARGING_MODE_CARD = "刷卡";
public static final Long SYS_USER_TYPE_ADMIN = 1L;
}

View File

@ -28,7 +28,6 @@ import com.xhpc.order.service.IXhpcChargeOrderService;
import com.xhpc.order.service.IXhpcHistoryOrderService;
import com.xhpc.order.service.IXhpcRealTimeOrderService;
import com.xhpc.system.api.model.LoginUser;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -248,7 +247,40 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
@Override
public void export(HttpServletResponse response, String phone, String transactionNumber, Integer status, String chargingStationName, Long operatorId, Integer source, String beginStartTime, String beginEndTime, Long userId, Integer type,String affiliationOrganization,String evcsOrderNo,String plateNum,Integer internetId,String internetSerialNumber,String terminalName,String vinCode,String overStartTime,String overEndTime,Long personnelId,Integer confirmResult) throws IOException {
List<Map<String, Object>> list = getListPage(phone, transactionNumber, status, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
Integer number = 0;
//电话和用户类型都不为null number =3
//电话不为null用户类型为null number =1
//电话为null用户类型不为null number=2
//电话为null用户类型为null number=0
if (!"".equals(phone) && phone != null && !"".equals(source) && source != null) {
number = 3;
} else if (!"".equals(phone) && phone != null && source==null) {
number = 1;
} else if(phone == null && source !=null) {
number = 2;
}
//获取登陆用户
Long logUserId = SecurityUtils.getUserId();
//桩的统计该时段金额
List<Map<String, Object>> list = new ArrayList<>();
if (userId != 1) {
Map<String, Object> landUser = xhpcHistoryOrderMapper.getLandUser(logUserId);
if (landUser != null) {
if (landUser.get("userType") != null) {
if ("01".equals(landUser.get("userType").toString())) {
Long logOperatorId = Long.valueOf(landUser.get("operatorId").toString());
//运营商看自己的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 1, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logOperatorId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
} else {
//查询赋值的场站
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 2, chargingStationName, operatorId, source, beginStartTime, beginEndTime, logUserId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
}
}
}
} else {
list = xhpcHistoryOrderMapper.getListPage(phone, transactionNumber, 0, chargingStationName, operatorId, source, beginStartTime, beginEndTime, userId, type, number,affiliationOrganization,evcsOrderNo,plateNum,internetId,internetSerialNumber,terminalName,vinCode,overStartTime,overEndTime,personnelId,confirmResult);
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("historyOrderId", "历史订单ID");

View File

@ -616,10 +616,10 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,xhpcChargeOrder.getSource());
map.put("userId",userId);
map.put("amount",subtract);
if(userMessage.get("weixinOpenId") !=null && !"".equals(userMessage.get("weixinOpenId").toString())){
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode())){
openid=userMessage.get("weixinOpenId").toString();
refundType="1";
}else{
}else if(UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode())){
openid=userMessage.get("alipayOpenId").toString();
refundType="2";
}
@ -641,18 +641,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
//充电结算后自动申请退款
if(userMessage !=null && "1".equals(userMessage.get("isRefund").toString()) && map !=null){
logger.info("<<<<<<<<<<<<<<<<进入自动退款111>>>>>>>>>>>>>>>>>");
if(UserTypeUtil.CHARGING_MODE_WX.equals(xhpcChargeOrder.getChargingMode()) ||UserTypeUtil.CHARGING_MODE_ZFB.equals(xhpcChargeOrder.getChargingMode()) ){
if(UserTypeUtil.USER_TYPE.equals(source) || UserTypeUtil.COMMUNIT_TYPE.equals(source)){
logger.info("<<<<<<<<<<<<<<<<进入自动退款222>>>>>>>>>>>>>>>>>");
logger.info("<<<<<<<<<<<<<<<<balance2>>>>>>>>>>>>>>>>>"+balance2);
logger.info("<<<<<<<<<<<<<<<<openids>>>>>>>>>>>>>>>>>"+openids);
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getSource()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getSource());
logger.info("<<<<<<<<<<<<<<<<refundTypes>>>>>>>>>>>>>>>>>"+refundTypes);
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getUserId()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getUserId().toString());
logger.info("<<<<<<<<<<<<<<<<xhpcChargeOrder.getTenantId()>>>>>>>>>>>>>>>>>"+xhpcChargeOrder.getTenantId());
R r = refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getCode());
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getData());
logger.info("<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>"+r.getMsg());
refundOrderService.sendNotice(balance2,openids,xhpcChargeOrder.getSource(),refundTypes,xhpcChargeOrder.getUserId().toString(),xhpcChargeOrder.getTenantId(),"充电结算自动申请退款");
}
}
}
}catch (Exception e){
@ -660,27 +653,34 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
logger.info("<<<<<<<<<<<<<<<<自动退款失败>>>>>>>>>>>>>>>>>");
}
try{
Map<String, Object> xhpcChargingPile = xhpcChargeOrderService.getXhpcChargingPile(xhpcChargeOrder.getTerminalId());
if(!UserTypeUtil.INSERT_BALANCE.equals(source)){
Map<String, Object> userMassage = xhpcChargeOrderService.getUserMessage(userId);
if(xhpcChargingPile !=null){
logger.info("<<<<<<<<<<<<<<<<进入发送短信>>>>>>>>>>>>>>>>>");
//发送短信
if(userMassage !=null && userMassage.get("phone") !=null){
if("1".equals(xhpcChargingPile.get("type").toString())){
logger.info("<<<<<<<<<<<<<<<<进行入短信发送>>>>>>>>>>>>>>>>>");
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
R<Map<String, Object>> user = userTypeService.getUser(null, userId, source, null, xhpcChargeOrder.getTenantId());
if(user !=null && user.getData() !=null){
logger.info("<<<<<<<<<<<<<<<<进行入短信发送1111>>>>>>>>>>>>>>>>>");
Map<String, Object> userMessage = (Map<String, Object>)user.getData();
if (userMessage != null && userMessage.get("phone") != null) {
logger.info("<<<<<<<<<<<<<<<<进行入短信发送222>>>>>>>>>>>>>>>>>");
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("elec", xhpcChargeOrder.getEndSoc());
paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMassage.get("phone").toString());
paramMap.put("phone", userMessage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap);
}else {
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("sumMoney", balance.toString());
paramMap.put("phone", userMassage.get("phone").toString());
paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。");
smsService.sendNotice(paramMap);
}
// if("1".equals(xhpcChargingPile.get("type").toString())){
// HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("elec", xhpcChargeOrder.getEndSoc());
// paramMap.put("sumMoney", balance.toString());
// paramMap.put("phone", userMessage.get("phone").toString());
// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,电量为:" + xhpcChargeOrder.getEndSoc() + "%,总费用为:" + balance + "元,充电费用明细,请查询小华充电小程序,谢谢。");
// smsService.sendNotice(paramMap);
// }else {
// HashMap<String, String> paramMap = new HashMap<>();
// paramMap.put("sumMoney", balance.toString());
// paramMap.put("phone", userMessage.get("phone").toString());
// paramMap.put("content", "【小华停止充电】尊敬的用户,你的爱车已停止充电,总费用为:" + balance.toString() + "元,充电费用明细,请查询小华充电小程序,谢谢。");
// smsService.sendNotice(paramMap);
// }
}
}
}

View File

@ -575,8 +575,34 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
@Override
public void dateIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException {
List<Map<String, Object>> list = getDateIntervalPage(request,chargingStationIds, internetUserId, operatorId, startTime, endTime, userId, type);
List<Map<String, Object>> list =new ArrayList<>();
if (getJudge(internetUserId, operatorId, type)){
}else{
List<String> chargingStationId =new ArrayList<>();
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
chargingStationId= Arrays.asList(chargingStationIds.split(","));
}
//获取登陆用户
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
//获取登陆用户
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
list = xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 1,logOperatorId,tenantId);
}else{
//查询赋值的场站
list = xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 2,sysUserId,tenantId);
}
}else{
list =xhpcStatisticsServiceMapper.getDateIntervalPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 0,sysUserId,tenantId);
}
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("createTime", "日期");
@ -617,7 +643,36 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
@Override
public void stationIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationIds,String operatorIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException {
List<Map<String, Object>> list = getStationIntervalPage(request,chargingStationIds, operatorIds, internetUserId, operatorId, startTime, endTime, userId, type);
List<Map<String, Object>> list =new ArrayList<>();
if (getJudge(internetUserId, operatorId, type)){
}else{
List<String> chargingStationId =new ArrayList<>();
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
chargingStationId= Arrays.asList(chargingStationIds.split(","));
}
List<String> operatorUserId =new ArrayList<>();
if(!"".equals(operatorIds) && operatorIds !=null){
operatorUserId= Arrays.asList(operatorIds.split(","));
}
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
list = xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,1,logOperatorId,tenantId);
}else{
//查询赋值的场站
list = xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,2,sysUserId,tenantId);
}
}else{
list =xhpcStatisticsServiceMapper.getStationIntervalPage(chargingStationId,operatorUserId,internetUserId,operatorId,startTime,endTime,0,sysUserId,tenantId);
}
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
@ -661,8 +716,32 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
@Override
public void operatorIntervalExport(HttpServletRequest request,HttpServletResponse response, String operatorIds,Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException {
List<Map<String, Object>> list = getOperatorIntervalPage(request,operatorIds, operatorId, startTime, endTime, userId, type);
List<Map<String, Object>> list =new ArrayList<>();
if(getJudge(null,operatorId,type)){
}else{
List<String> operatorUserId =new ArrayList<>();
if(!"".equals(operatorIds) && operatorIds !=null){
operatorUserId= Arrays.asList(operatorIds.split(","));
}
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
list = xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 1,logOperatorId,tenantId);
}else{
//查询赋值的场站
list = xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 2,sysUserId,tenantId);
}
}else{
list =xhpcStatisticsServiceMapper.getOperatorIntervalPage(operatorUserId, operatorId, startTime, endTime, 0,sysUserId,tenantId);
}
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("operatorName", "运营商名称");
@ -750,8 +829,23 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
@Override
public void terminalIntervalExport(HttpServletRequest request,HttpServletResponse response, String chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException {
List<Map<String, Object>> list = getTerminalIntervalPage(request,chargingStationId, terminalId, operatorId, startTime, endTime, userId, type);
LoginUser loginUser = tokenService.getLoginUser(request);
List<Map<String, Object>> list =new ArrayList<>();
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
list = xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, 1,logOperatorId,tenantId);
}else{
//查询赋值的场站
list = xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, 2,sysUserId,tenantId);
}
}else{
list =xhpcStatisticsServiceMapper.getTerminalIntervalPage(chargingStationId, terminalId, operatorId, startTime, endTime, 0,sysUserId,tenantId);
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("chargingStationName", "电站名称");
@ -794,8 +888,33 @@ public class XhpcStatisticsServiceImpl extends BaseService implements IXhpcStati
@Override
public void getMechanismExport(HttpServletRequest request, HttpServletResponse response, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, Integer source) throws IOException {
List<Map<String, Object>> list = getMechanismPage(request,chargingStationIds, internetUserId, operatorId, startTime, endTime, userId, type,source);
List<Map<String, Object>> list =new ArrayList<>();
if (getJudge(internetUserId, operatorId, type)){
}else{
List<String> chargingStationId =new ArrayList<>();
if(!"".equals(chargingStationIds) && chargingStationIds !=null){
chargingStationId= Arrays.asList(chargingStationIds.split(","));
}
//获取登陆用户
LoginUser loginUser = tokenService.getLoginUser(request);
SysUser sysUser = loginUser.getSysUser();
String tenantId = loginUser.getTenantId();
Long sysUserId = sysUser.getUserId();
//获取登陆用户
if(!UserTypeUtil.SYS_USER_TYPE_ADMIN.equals(sysUser.getUserId())){
if(UserTypeUtil.SYS_USER_TYPE_ONE.equals(sysUser.getUserType())){
Long logOperatorId = sysUser.getOperatorId();
//运营商看自己的场站
list = xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 1,logOperatorId,tenantId,source);
}else{
//查询赋值的场站
list = xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 2,sysUserId,tenantId,source);
}
}else{
list =xhpcStatisticsServiceMapper.getMechanismPage(chargingStationId, internetUserId, operatorId, startTime, endTime, 0,sysUserId,tenantId,source);
}
}
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("internetUserName", "流量方名称");

View File

@ -141,10 +141,10 @@
sorting_status,
</if>
<if test="type != null">
`type`,
type,
</if>
<if test="status != null">
`status`,
status,
</if>
<if test="delFlag != null">
del_flag,
@ -165,7 +165,7 @@
remark,
</if>
<if test="state != null">
`state`,
state,
</if>
<if test="vinNormal != null">
vin_normal,
@ -675,7 +675,7 @@
when ho.charging_mode="4" then "小桔"
when ho.charging_mode="微信" then "微信"
when ho.charging_mode="支付宝" then "支付宝"
else "C端客户"
else "刷卡"
end chargingModeName
from xhpc_history_order as ho
left join xhpc_charging_station as ct on ct.charging_station_id = ho.charging_station_id

View File

@ -610,7 +610,7 @@ public class XhpcRefundAuditController extends BaseController {
/** 应用私钥, 如何获取请参考https://opensupport.alipay.com/support/helpcenter/207/201602471154?ant_source=antsupport **/
certAlipayRequest.setPrivateKey(xhpcSettingConfig.getZfbPrivateKey());
/** 应用公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setCertPath(xhpcSettingConfig.getZfbCallbackUrl());
certAlipayRequest.setCertPath(xhpcSettingConfig.getZfbAppCertPublicKey());
/** 支付宝公钥证书路径,下载后保存位置的绝对路径 **/
certAlipayRequest.setAlipayPublicCertPath(xhpcSettingConfig.getZfbAlipayCertPublicKeyRsa());
/** 支付宝根证书路径,下载后保存位置的绝对路径 **/