1修改对账和清分接口

This commit is contained in:
fengjundan 2021-08-03 18:43:23 +08:00
parent a89775ced7
commit ee7d0aa643
6 changed files with 53 additions and 52 deletions

View File

@ -1,12 +1,5 @@
package com.xhpc.common.security.service;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.xhpc.common.core.constant.CacheConstants;
import com.xhpc.common.core.constant.Constants;
import com.xhpc.common.core.utils.IdUtils;
@ -16,6 +9,13 @@ import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.core.utils.ip.IpUtils;
import com.xhpc.common.redis.service.RedisService;
import com.xhpc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* token验证处理
@ -23,8 +23,7 @@ import com.xhpc.system.api.model.LoginUser;
* @author ruoyi
*/
@Component
public class TokenService
{
public class TokenService {
@Autowired
private RedisService redisService;
@ -37,8 +36,7 @@ public class TokenService
/**
* 创建令牌
*/
public Map<String, Object> createToken(LoginUser loginUser)
{
public Map<String, Object> createToken(LoginUser loginUser) {
// 生成token
String token = IdUtils.fastUUID();
loginUser.setToken(token);
@ -52,6 +50,9 @@ public class TokenService
map.put("access_token", token);
map.put("expires_in", EXPIRE_TIME);
redisService.setCacheObject(ACCESS_TOKEN + token, loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
Map<String, Object> map1 = new HashMap<>();
map1.put("privilege", loginUser.getSysUser().getDataPowerType());
redisService.setCacheMap(loginUser.getSysUser().getUserId() + ":privilege", map1);
return map;
}
@ -60,8 +61,7 @@ public class TokenService
*
* @return 用户信息
*/
public LoginUser getLoginUser()
{
public LoginUser getLoginUser() {
return getLoginUser(ServletUtils.getRequest());
}
@ -70,12 +70,10 @@ public class TokenService
*
* @return 用户信息
*/
public LoginUser getLoginUser(HttpServletRequest request)
{
public LoginUser getLoginUser(HttpServletRequest request) {
// 获取请求携带的令牌
String token = SecurityUtils.getToken(request);
if (StringUtils.isNotEmpty(token))
{
if (StringUtils.isNotEmpty(token)) {
String userKey = getTokenKey(token);
LoginUser user = redisService.getCacheObject(userKey);
return user;
@ -86,18 +84,14 @@ public class TokenService
/**
* 设置用户身份信息
*/
public void setLoginUser(LoginUser loginUser)
{
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken()))
{
public void setLoginUser(LoginUser loginUser) {
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
refreshToken(loginUser);
}
}
public void delLoginUser(String token)
{
if (StringUtils.isNotEmpty(token))
{
public void delLoginUser(String token) {
if (StringUtils.isNotEmpty(token)) {
String userKey = getTokenKey(token);
redisService.deleteObject(userKey);
}
@ -108,8 +102,7 @@ public class TokenService
*
* @param loginUser 登录信息
*/
public void refreshToken(LoginUser loginUser)
{
public void refreshToken(LoginUser loginUser) {
loginUser.setLoginTime(System.currentTimeMillis());
loginUser.setExpireTime(loginUser.getLoginTime() + EXPIRE_TIME * MILLIS_SECOND);
// 根据uuid将loginUser缓存
@ -117,8 +110,7 @@ public class TokenService
redisService.setCacheObject(userKey, loginUser, EXPIRE_TIME, TimeUnit.SECONDS);
}
private String getTokenKey(String token)
{
private String getTokenKey(String token) {
return ACCESS_TOKEN + token;
}
}

View File

@ -96,11 +96,13 @@ public class XhpcHistoryOrderReconciliationStatusServiceImpl implements IXhpcHis
Map<String, Object> map = redisService.getCacheMap(userId + ":privilege");
if (StringUtils.isNotNull(map)) {
String privilege = StringUtils.valueOf(map.get("privilege"));
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return AjaxResult.success(xhpcHistoryOrderReconciliationStatusMapper.internetUser(userId, operatorId, null));
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return AjaxResult.success(xhpcHistoryOrderReconciliationStatusMapper.internetUser(userId, null, "privilege"));
if (StringUtils.isNotEmpty(privilege)) {
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return AjaxResult.success(xhpcHistoryOrderReconciliationStatusMapper.internetUser(userId, operatorId, null));
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return AjaxResult.success(xhpcHistoryOrderReconciliationStatusMapper.internetUser(userId, null, "privilege"));
}
}
}
return AjaxResult.success(xhpcHistoryOrderReconciliationStatusMapper.internetUser(userId, null, null));
@ -123,11 +125,13 @@ public class XhpcHistoryOrderReconciliationStatusServiceImpl implements IXhpcHis
Map<String, Object> map = redisService.getCacheMap(userId + ":privilege");
if (StringUtils.isNotNull(map)) {
String privilege = StringUtils.valueOf(map.get("privilege"));
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return xhpcHistoryOrderReconciliationStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, operatorId, null);
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return xhpcHistoryOrderReconciliationStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, "privilege");
if (StringUtils.isNotEmpty(privilege)) {
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return xhpcHistoryOrderReconciliationStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, operatorId, null);
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return xhpcHistoryOrderReconciliationStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, "privilege");
}
}
}
return xhpcHistoryOrderReconciliationStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, null);

View File

@ -96,11 +96,13 @@ public class XhpcHistoryOrderSortingStatusServiceImpl implements IXhpcHistoryOrd
Map<String, Object> map = redisService.getCacheMap(userId + ":privilege");
if (StringUtils.isNotNull(map)) {
String privilege = StringUtils.valueOf(map.get("privilege"));
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return AjaxResult.success(xhpcHistoryOrderSortingStatusMapper.operatorUser(userId, operatorId, null));
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return AjaxResult.success(xhpcHistoryOrderSortingStatusMapper.operatorUser(userId, null, "privilege"));
if (StringUtils.isNotEmpty(privilege)) {
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return AjaxResult.success(xhpcHistoryOrderSortingStatusMapper.operatorUser(userId, operatorId, null));
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return AjaxResult.success(xhpcHistoryOrderSortingStatusMapper.operatorUser(userId, null, "privilege"));
}
}
}
return AjaxResult.success(xhpcHistoryOrderSortingStatusMapper.operatorUser(userId, null, null));
@ -124,11 +126,13 @@ public class XhpcHistoryOrderSortingStatusServiceImpl implements IXhpcHistoryOrd
Map<String, Object> map = redisService.getCacheMap(userId + ":privilege");
if (StringUtils.isNotNull(map)) {
String privilege = StringUtils.valueOf(map.get("privilege"));
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return xhpcHistoryOrderSortingStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, operatorId, null);
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return xhpcHistoryOrderSortingStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, "privilege");
if (StringUtils.isNotEmpty(privilege)) {
if (StatusConstants.OPERATION_POWER_TYPE == Integer.parseInt(privilege)) {
String operatorId = StringUtils.valueOf(map.get("operatorId"));
return xhpcHistoryOrderSortingStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, operatorId, null);
} else if (StatusConstants.SON_POWER_TYPE == Integer.parseInt(privilege)) {
return xhpcHistoryOrderSortingStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, "privilege");
}
}
}
return xhpcHistoryOrderSortingStatusMapper.page(userId, serialNumber, createTimeStart, createTimeEnd, chargingStationName, status, null, null);

View File

@ -114,7 +114,7 @@
</if>
GROUP BY xho.user_id) b on a.user_id = su.user_id
LEFT JOIN xhpc_internet_user xiu on xiu.internet_user_id = su.internet_user_id
where a.user_id = #{userId} limit 1
where su.user_id = #{userId} limit 1
</select>
<select id="page" parameterType="java.lang.Long" resultType="java.util.Map">

View File

@ -244,7 +244,7 @@
xiu.internet_user_id internetUserId, xiu.`name`, xiu.phone, xiu.contact_name contactName,
xiu.contact_phone contactPhone,xiu.create_time createTime,
xiu.commission_type commissionType, xiu.commission_rate commissionRate,
xiu.latitude, xiu.`status`,
xiu.latitude, xiu.`status`,su.user_id userId,
CASE WHEN xiu.`status` = 0 THEN '正常' else '禁用' end statusName,
CASE WHEN xiu.commission_type = 0 THEN '总金额提成' else '服务费提成' end commissionTypeName
from xhpc_internet_user xiu

View File

@ -283,9 +283,10 @@
<select id="selectOperatorList" parameterType="java.lang.Long" resultType="java.util.Map">
select xo.operator_id operatorId, xo.name, xo.contact_name contactName, xo.duty_paragraph dutyParagraph,
xo.contact_phone contactPhone, xo.phone, xo.attribute,`xo`.create_time createTime,`xo`.status,
CASE WHEN xo.`status` = 0 THEN '正常' else '禁用' end statusName,
CASE WHEN xo.`status` = 0 THEN '正常' else '禁用' end statusName,su.user_id userId,
xdb.dict_value attributenName
from xhpc_operator `xo`
LEFT JOIN sys_user su on su.internet_user_id = `xo`.operator_id
LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute
where xo.del_flag = 0
<if test="name != null and name != ''">