diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java index 1bd39940..581982be 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java @@ -1,6 +1,14 @@ package com.ruoyi.gateway.filter; -import javax.annotation.Resource; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.core.constant.Constants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.ServletUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -15,27 +23,19 @@ import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.ruoyi.common.core.constant.CacheConstants; -import com.ruoyi.common.core.constant.Constants; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.common.core.utils.ServletUtils; -import com.ruoyi.common.core.utils.StringUtils; -import com.ruoyi.common.redis.service.RedisService; -import com.ruoyi.gateway.config.properties.IgnoreWhiteProperties; import reactor.core.publisher.Mono; +import javax.annotation.Resource; + /** * 网关鉴权 - * + * * @author ruoyi */ @Component -public class AuthFilter implements GlobalFilter, Ordered -{ +public class AuthFilter implements GlobalFilter, Ordered { private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); - + private final static long EXPIRE_TIME = Constants.TOKEN_EXPIRE * 60; // 排除过滤的 uri 地址,nacos自行添加 @@ -44,37 +44,35 @@ public class AuthFilter implements GlobalFilter, Ordered @Resource(name = "stringRedisTemplate") private ValueOperations sops; - + @Autowired private RedisService redisService; @Override - public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) - { + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { String url = exchange.getRequest().getURI().getPath(); // 跳过不需要验证的路径 - if (StringUtils.matches(url, ignoreWhite.getWhites())) - { + if (StringUtils.matches(url, ignoreWhite.getWhites())) { return chain.filter(exchange); } String token = getToken(exchange.getRequest()); - if (StringUtils.isBlank(token)) - { + if (StringUtils.isBlank(token)) { return setUnauthorizedResponse(exchange, "令牌不能为空"); } String userStr = sops.get(getTokenKey(token)); - if (StringUtils.isNull(userStr)) - { - return setUnauthorizedResponse(exchange, "登录状态已过期"); + if (StringUtils.isNull(userStr)) { + userStr = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + if (StringUtils.isNull(userStr)) { + return setUnauthorizedResponse(exchange, "登录状态已过期"); + } } JSONObject obj = JSONObject.parseObject(userStr); String userid = obj.getString("userid"); String username = obj.getString("username"); - if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) - { + if (StringUtils.isBlank(userid) || StringUtils.isBlank(username)) { return setUnauthorizedResponse(exchange, "令牌验证失败"); } - + // 设置过期时间 redisService.expire(getTokenKey(token), EXPIRE_TIME); // 设置用户信息到请求 @@ -85,8 +83,7 @@ public class AuthFilter implements GlobalFilter, Ordered return chain.filter(mutableExchange); } - private Mono setUnauthorizedResponse(ServerWebExchange exchange, String msg) - { + private Mono setUnauthorizedResponse(ServerWebExchange exchange, String msg) { ServerHttpResponse response = exchange.getResponse(); response.getHeaders().setContentType(MediaType.APPLICATION_JSON); response.setStatusCode(HttpStatus.OK); @@ -99,27 +96,23 @@ public class AuthFilter implements GlobalFilter, Ordered })); } - private String getTokenKey(String token) - { + private String getTokenKey(String token) { return CacheConstants.LOGIN_TOKEN_KEY + token; } /** * 获取请求token */ - private String getToken(ServerHttpRequest request) - { + private String getToken(ServerHttpRequest request) { String token = request.getHeaders().getFirst(CacheConstants.HEADER); - if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) - { + if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX)) { token = token.replace(CacheConstants.TOKEN_PREFIX, ""); } return token; } @Override - public int getOrder() - { + public int getOrder() { return -200; } } \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/pom.xml b/ruoyi-modules/ruoyi-file/pom.xml index 2edec5ee..e0b69999 100644 --- a/ruoyi-modules/ruoyi-file/pom.xml +++ b/ruoyi-modules/ruoyi-file/pom.xml @@ -65,7 +65,34 @@ com.ruoyi ruoyi-common-swagger + + com.aliyun.oss + aliyun-sdk-oss + 3.10.2 + + + org.springframework.boot + spring-boot-starter-web + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common-datasource + + + + + com.ruoyi + ruoyi-common-datascope + diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYFileApplication.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYFileApplication.java index 990dc1a4..33ed802a 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYFileApplication.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/RuoYFileApplication.java @@ -1,9 +1,10 @@ package com.ruoyi.file; +import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * 文件服务 @@ -11,7 +12,9 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; * @author ruoyi */ @EnableCustomSwagger2 -@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) +@EnableFeignClients +@SpringBootApplication +@MapperScan("com.ruoyi.file.mapper") public class RuoYFileApplication { public static void main(String[] args) diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java index 318db416..8a8f1602 100644 --- a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/controller/SysFileController.java @@ -1,15 +1,34 @@ package com.ruoyi.file.controller; +import com.aliyun.oss.OSSClient; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.core.utils.file.FileUtils; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.file.domain.XhpcImg; +import com.ruoyi.file.service.ISysFileService; +import com.ruoyi.file.service.IXhpcImgService; +import com.ruoyi.system.api.domain.SysFile; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.common.core.utils.file.FileUtils; -import com.ruoyi.file.service.ISysFileService; -import com.ruoyi.system.api.domain.SysFile; +import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; + +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; /** * 文件请求处理 @@ -24,6 +43,14 @@ public class SysFileController @Autowired private ISysFileService sysFileService; + @Autowired + private Environment environment; + + @Autowired + private IXhpcImgService iXhpcImgService; + + + /** * 文件上传请求 */ @@ -45,4 +72,66 @@ public class SysFileController return R.fail(e.getMessage()); } } + + /* + * TODO 阿里云图片上传 + * @author fjd + * @date 2020-07-03 16:13 + */ + @PostMapping("photoupload") + @ApiOperation(value = "上传", notes = "上传") + public AjaxResult myphotoupload(HttpServletRequest request) { + String fileNames = ""; + try { + StandardMultipartHttpServletRequest req = (StandardMultipartHttpServletRequest) request; + Iterator iterator = req.getFileNames(); + while (iterator.hasNext()) { + MultipartFile file = req.getFile(iterator.next()); + fileNames = file.getOriginalFilename(); + fileNames = DateUtils.timePath() + fileNames; + InputStream input = file.getInputStream(); + // 创建OSSClient实例 + OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key")); + // 上传文件流 + ossClient.putObject(environment.getProperty("oss.bucket-name"), fileNames, input); + ossClient.shutdown(); + } + XhpcImg xhpcImg = new XhpcImg(); + xhpcImg.setUrl(fileNames); + iXhpcImgService.insert(xhpcImg); + Map map = new HashMap<>(16); + map.put("imgId", StringUtils.valueOf(xhpcImg.getImgId())); + map.put("url", "https://dx-gzxh.oss-cn-beijing.aliyuncs.com/" + fileNames); + return AjaxResult.success(map); + + } catch (IOException e) { + e.printStackTrace(); + } + return AjaxResult.error(); + } + + /* + * TODO 阿里云图片删除 + * @author fjd + * @date 2020-07-03 16:14 + */ + @GetMapping("alyRemove") + @ApiOperation(value = "删除", notes = "删除") + public Object deleteImage(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + if (StringUtils.isNull(ids)) { + return AjaxResult.error(1006, "图片id不能未空"); + } + String[] idList = ids.split(","); + for (String id : idList) { + XhpcImg xhpcImg = iXhpcImgService.info(Long.parseLong(id)); + if (null != xhpcImg) { + OSSClient ossClient = new OSSClient(environment.getProperty("oss.endpoint"), environment.getProperty("oss.access-key"), environment.getProperty("oss.secret-key")); + ossClient.deleteObject(environment.getProperty("oss.bucket-name"), xhpcImg.getUrl()); + ossClient.shutdown(); + xhpcImg.setDelFlag(1); + iXhpcImgService.update(xhpcImg); + } + } + return AjaxResult.success(); + } } \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/domain/XhpcImg.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/domain/XhpcImg.java new file mode 100644 index 00000000..8ed289b5 --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/domain/XhpcImg.java @@ -0,0 +1,64 @@ +package com.ruoyi.file.domain; + +import com.ruoyi.common.core.web.domain.BaseEntity; + + +/** + * @author + * @description 上传图片 xhpc_img + * @date 2021-07-22 + */ +public class XhpcImg extends BaseEntity { + + /** + * 上传id + */ + private Long imgId; + + /** + * 路径 + */ + private String url; + + /** + * 状态(0正常 1停用) + */ + private Integer status; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private Integer delFlag; + + public Long getImgId() { + return imgId; + } + + public void setImgId(Long imgId) { + this.imgId = imgId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getDelFlag() { + return delFlag; + } + + public void setDelFlag(Integer delFlag) { + this.delFlag = delFlag; + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/mapper/XhpcImgMapper.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/mapper/XhpcImgMapper.java new file mode 100644 index 00000000..e894a4c7 --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/mapper/XhpcImgMapper.java @@ -0,0 +1,36 @@ +package com.ruoyi.file.mapper; + +import com.ruoyi.file.domain.XhpcImg; +import org.apache.ibatis.annotations.Param; + +/** + * 上传图片信息 数据层 + * + * @author ruoyi + */ +public interface XhpcImgMapper { + + /** + * 新增 上传图片信息 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int insert(XhpcImg xhpcImg); + + /** + * 更新 上传图片信息 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int update(XhpcImg xhpcImg); + + /** + * 查询 + * + * @param imgId 上传图片id + * @return 结果 + */ + public XhpcImg info(@Param("imgId") Long imgId); +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/IXhpcImgService.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/IXhpcImgService.java new file mode 100644 index 00000000..ff6f3c1c --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/IXhpcImgService.java @@ -0,0 +1,38 @@ +package com.ruoyi.file.service; + + +import com.ruoyi.file.domain.XhpcImg; + +/** + * 上传图片 服务类 + * + * @author BladeX + * @since 2020-06-17 + */ +public interface IXhpcImgService { + + /** + * 新增 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int insert(XhpcImg xhpcImg); + + /** + * 更新 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int update(XhpcImg xhpcImg); + + /** + * 查询 + * + * @param imgId 上传图片id + * @return 结果 + */ + public XhpcImg info(Long imgId); + +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/XhpcImgServiceImpl.java b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/XhpcImgServiceImpl.java new file mode 100644 index 00000000..e90eefdd --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/XhpcImgServiceImpl.java @@ -0,0 +1,49 @@ +package com.ruoyi.file.service; + +import com.ruoyi.file.domain.XhpcImg; +import com.ruoyi.file.mapper.XhpcImgMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 上传图片 服务实现类 + * + * @author BladeX + * @since 2020-06-17 + */ +@Service +public class XhpcImgServiceImpl implements IXhpcImgService { + + @Autowired + private XhpcImgMapper xhpcImgMapper; + + /** + * 新增 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int insert(XhpcImg xhpcImg) { + return xhpcImgMapper.insert(xhpcImg); + } + + /** + * 更新 + * + * @param xhpcImg 上传图片信息 + * @return 结果 + */ + public int update(XhpcImg xhpcImg) { + return xhpcImgMapper.update(xhpcImg); + } + + /** + * 查询 + * + * @param imgId 上传图片id + * @return 结果 + */ + public XhpcImg info(Long imgId) { + return xhpcImgMapper.info(imgId); + } +} diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/mapper/XhpcImgMapper.xml b/ruoyi-modules/ruoyi-file/src/main/resources/mapper/XhpcImgMapper.xml new file mode 100644 index 00000000..0b9031ef --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/resources/mapper/XhpcImgMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + INSERT INTO xhpc_img + + + url, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark + + + + + #{url}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark} + + + + + + UPDATE xhpc_img + + url = #{url}, + status = #{status}, + del_flag = #{delFlag}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + remark = #{remark} + + WHERE img_id = #{imgId} + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java index 0045a824..b6dd8386 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/DaoAspect.java @@ -1,7 +1,9 @@ package com.xhpc.order.aspect; +import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.beanutils.BeanUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -12,6 +14,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.util.Date; /* @@ -42,23 +45,35 @@ public class DaoAspect { if (attributes == null) { return point.proceed(); } - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (userName != null) { - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + HttpServletRequest request = attributes.getRequest(); + try { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } } } } + } catch (Exception e) { } Object object = point.proceed(); return object; @@ -71,29 +86,41 @@ public class DaoAspect { if (attributes == null) { return point.proceed(); } - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - Date date = new Date(); - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { - BeanUtils.setProperty(arg, CREATE_USER, userName); - } - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } - if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { - BeanUtils.setProperty(arg, CREATE_TIME, date); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, date); + if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } } } + } catch (Exception e) { } Object object = point.proceed(); return object; diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/LogUserUtils.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/LogUserUtils.java new file mode 100644 index 00000000..042afc85 --- /dev/null +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/aspect/LogUserUtils.java @@ -0,0 +1,26 @@ +package com.xhpc.order.aspect; + +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.HttpServletRequest; + +public class LogUserUtils { + + @Autowired + private RedisService redisService; + + /** + * 获取登录信息 + * + * @param request 请求参数 + * @return LoginUser 登录用户信息 + */ + public LoginUser getLogUser(HttpServletRequest request) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + return redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } +} diff --git a/xhpc-modules/xhpc-order/src/main/resources/logback.xml b/xhpc-modules/xhpc-order/src/main/resources/logback.xml index 4e0f1747..83ed4f2d 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/logback.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/logback.xml @@ -67,7 +67,7 @@ - + diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml index 5e0c4385..c5b0fb6e 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderMapper.xml @@ -37,7 +37,7 @@ + keyProperty="historyOrderId"> INSERT INTO xhpc_history_order @@ -112,13 +112,13 @@ del_flag, - + create_time, create_by, - + update_time, @@ -201,13 +201,13 @@ #{delFlag}, - + #{createTime}, #{createBy}, - + #{updateTime}, @@ -232,43 +232,43 @@ internet_serial_number = #{internetSerialNumber}, - total_price = #{totalPrice}, - promotion_discount = + total_price = #{totalPrice}, + promotion_discount = #{promotionDiscount}, - act_price = #{actPrice}, - act_power_price = #{actPowerPrice}, - act_service_price = #{actServicePrice}, - internet_commission = + act_price = #{actPrice}, + act_power_price = #{actPowerPrice}, + act_service_price = #{actServicePrice}, + internet_commission = #{internetCommission}, - internet_svc_commission = + internet_svc_commission = #{internetSvcCommission}, - platform_commission = + platform_commission = #{platformCommission}, - platform_svc_commisssion = + platform_svc_commisssion = #{platformSvcCommisssion}, - operation_commission = + operation_commission = #{operationCommission}, - operation_svc_commission = + operation_svc_commission = #{operationSvcCommission}, start_soc = #{startSoc}, end_soc = #{endSoc}, - reconciliation_status = + reconciliation_status = #{reconciliationStatus}, - sorting_status = #{sortingStatus}, - type = #{type}, - status = #{status}, + sorting_status = #{sortingStatus}, + type = #{type}, + status = #{status}, del_flag = #{delFlag}, - create_time = #{createTime}, + create_time = #{createTime}, create_by = #{createBy}, - update_time = #{updateTime}, + update_time = #{updateTime}, update_by = #{updateBy}, remark = #{remark} diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml index 76afff39..1a39cdf1 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderReconciliationStatusMapper.xml @@ -18,7 +18,7 @@ + useGeneratedKeys="true" keyProperty="historyOrderReconciliationStatusId"> INSERT INTO xhpc_recharge_order diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderSortingStatusMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderSortingStatusMapper.xml index f159da78..56d53a41 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderSortingStatusMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcHistoryOrderSortingStatusMapper.xml @@ -17,7 +17,7 @@ + keyProperty="historyOrderSortingStatusId"> INSERT INTO xhpc_recharge_order @@ -29,13 +29,13 @@ del_flag, - + create_time, create_by, - + update_time, @@ -55,13 +55,13 @@ #{delFlag}, - + #{createTime}, #{createBy}, - + #{updateTime}, @@ -77,11 +77,11 @@ UPDATE xhpc_history_order_reconciliation_status history_order_id = #{historyOrderId}, - status = #{status}, + status = #{status}, del_flag = #{delFlag}, - create_time = #{createTime}, + create_time = #{createTime}, create_by = #{createBy}, - update_time = #{updateTime}, + update_time = #{updateTime}, update_by = #{updateBy}, remark = #{remark} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java index e2bf7c0b..3e3d6f8c 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/DaoAspect.java @@ -1,7 +1,9 @@ package com.xhpc.payment.aspect; +import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.beanutils.BeanUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -12,6 +14,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.util.Date; /* @@ -42,23 +45,35 @@ public class DaoAspect { if (attributes == null) { return point.proceed(); } - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (userName != null) { - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + HttpServletRequest request = attributes.getRequest(); + try { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } } } } + } catch (Exception e) { } Object object = point.proceed(); return object; @@ -71,29 +86,41 @@ public class DaoAspect { if (attributes == null) { return point.proceed(); } - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - Date date = new Date(); - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { - BeanUtils.setProperty(arg, CREATE_USER, userName); - } - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } - if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { - BeanUtils.setProperty(arg, CREATE_TIME, date); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, date); + if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } } } + } catch (Exception e) { } Object object = point.proceed(); return object; diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/LogUserUtils.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/LogUserUtils.java new file mode 100644 index 00000000..96f4621e --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/aspect/LogUserUtils.java @@ -0,0 +1,26 @@ +package com.xhpc.payment.aspect; + +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.HttpServletRequest; + +public class LogUserUtils { + + @Autowired + private RedisService redisService; + + /** + * 获取登录信息 + * + * @param request 请求参数 + * @return LoginUser 登录用户信息 + */ + public LoginUser getLogUser(HttpServletRequest request) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + return redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcUserAccountStatementController.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcUserAccountStatementController.java new file mode 100644 index 00000000..f3905cdc --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/controller/XhpcUserAccountStatementController.java @@ -0,0 +1,32 @@ +package com.xhpc.payment.controller; + +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.xhpc.payment.service.IXhpcUserAccountStatementService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/account/statement") +@Api(value = "用户流水接口", tags = "用户流水接口") +public class XhpcUserAccountStatementController extends BaseController { + + @Autowired + private IXhpcUserAccountStatementService iXhpcUserAccountStatementService; + + /** + * 用户流水页列表 + */ + @GetMapping("/list") + public TableDataInfo page(@RequestParam Long refundOrderId) { + List> list = iXhpcUserAccountStatementService.list(refundOrderId); + return getDataTable(list); + } +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java index 7398f0f0..ed1dc07c 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcRefundOrder.java @@ -12,10 +12,6 @@ import java.math.BigDecimal; */ public class XhpcRefundOrder extends BaseEntity { - /** - * 退款订单审核id - */ - private Long refundAuditId; /** * 退款订单id @@ -52,6 +48,11 @@ public class XhpcRefundOrder extends BaseEntity { */ private Integer type; + /** + * 审核状态(0审核中 1审核通过,2审核失败) + */ + private Integer examineStatus; + /** * 状态(0退款中 1退款成功,2退款失败,3退款异常) */ @@ -62,14 +63,6 @@ public class XhpcRefundOrder extends BaseEntity { */ private Integer delFlag; - public Long getRefundAuditId() { - return refundAuditId; - } - - public void setRefundAuditId(Long refundAuditId) { - this.refundAuditId = refundAuditId; - } - public Long getRefundOrderId() { return refundOrderId; } @@ -141,4 +134,12 @@ public class XhpcRefundOrder extends BaseEntity { public void setDelFlag(Integer delFlag) { this.delFlag = delFlag; } + + public Integer getExamineStatus() { + return examineStatus; + } + + public void setExamineStatus(Integer examineStatus) { + this.examineStatus = examineStatus; + } } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcUserAccountStatement.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcUserAccountStatement.java new file mode 100644 index 00000000..a73db272 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/domain/XhpcUserAccountStatement.java @@ -0,0 +1,119 @@ +package com.xhpc.payment.domain; + +import com.ruoyi.common.core.web.domain.BaseEntity; + +import java.math.BigDecimal; + + +/** + * @author + * @description 用户流水 xhpc_user_account_statement + * @date 2021-07-22 + */ +public class XhpcUserAccountStatement extends BaseEntity { + + + /** + * 用户流水id + */ + private Long userAccountStatementId; + + /** + * 用户id + */ + private Long userId; + + /** + * 流水金额 + */ + private BigDecimal amount; + + /** + * 充电订单id + */ + private Long chargeOrderId; + + /** + * 充值订单id + */ + private Long rechargeOrderId; + + /** + * 退款订单id + */ + private Long refundOrderId; + + /** + * 状态(0正常 1停用) + */ + private Integer status; + + /** + * 删除标志(0代表存在 2代表删除) + */ + private Integer delFlag; + + public Long getUserAccountStatementId() { + return userAccountStatementId; + } + + public void setUserAccountStatementId(Long userAccountStatementId) { + this.userAccountStatementId = userAccountStatementId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public Long getChargeOrderId() { + return chargeOrderId; + } + + public void setChargeOrderId(Long chargeOrderId) { + this.chargeOrderId = chargeOrderId; + } + + public Long getRechargeOrderId() { + return rechargeOrderId; + } + + public void setRechargeOrderId(Long rechargeOrderId) { + this.rechargeOrderId = rechargeOrderId; + } + + public Long getRefundOrderId() { + return refundOrderId; + } + + public void setRefundOrderId(Long refundOrderId) { + this.refundOrderId = refundOrderId; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getDelFlag() { + return delFlag; + } + + public void setDelFlag(Integer delFlag) { + this.delFlag = delFlag; + } +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java new file mode 100644 index 00000000..19d87f72 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/mapper/XhpcUserAccountStatementMapper.java @@ -0,0 +1,31 @@ +package com.xhpc.payment.mapper; + +import com.xhpc.payment.domain.XhpcUserAccountStatement; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 用户流水信息 数据层 + * + * @author ruoyi + */ +public interface XhpcUserAccountStatementMapper { + + /** + * 新增 用户流水信息 + * + * @param xhpcUserAccountStatement 用户流水信息 + * @return 结果 + */ + public int insert(XhpcUserAccountStatement xhpcUserAccountStatement); + + /** + * 用户流水列表 + * + * @param refundOrderId + * @return + */ + public List> list(@Param("refundOrderId") Long refundOrderId); +} diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcUserAccountStatementService.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcUserAccountStatementService.java new file mode 100644 index 00000000..4903db25 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/IXhpcUserAccountStatementService.java @@ -0,0 +1,30 @@ +package com.xhpc.payment.service; + +import com.xhpc.payment.domain.XhpcUserAccountStatement; + +import java.util.List; +import java.util.Map; + +/** + * 用户流水信息 服务层 + * + * @author ruoyi + */ +public interface IXhpcUserAccountStatementService { + + /** + * 新增 用户流水 + * + * @param xhpcUserAccountStatement 用户流水 + */ + public int insert(XhpcUserAccountStatement xhpcUserAccountStatement); + + /** + * 用户流水列表 + * + * @param refundOrderId + * @return + */ + public List> list(Long refundOrderId); + +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java index 8c4c87eb..44d508f7 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRechargeOrderServiceImpl.java @@ -1,7 +1,10 @@ package com.xhpc.payment.service.impl; +import com.ruoyi.common.core.utils.StringUtils; import com.xhpc.payment.domain.XhpcRechargeOrder; +import com.xhpc.payment.domain.XhpcUserAccountStatement; import com.xhpc.payment.mapper.XhpcRechargeOrderMapper; +import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRechargeOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,6 +24,9 @@ public class XhpcRechargeOrderServiceImpl implements IXhpcRechargeOrderService { @Autowired private XhpcRechargeOrderMapper xhpcRechargeOrderMapper; + @Autowired + private XhpcUserAccountStatementMapper xhpcUserAccountStatementMapper; + /** * 更新 充值订单 * @@ -94,6 +100,16 @@ public class XhpcRechargeOrderServiceImpl implements IXhpcRechargeOrderService { } else { xhpcRechargeOrder.setAlipayNumber(paymentNumber); } + if ("1".equals(xhpcRechargeOrder.getStatus())) { + Map map = xhpcRechargeOrderMapper.info(rechargeOrderId); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + String amount = "-" + StringUtils.valueOf(map.get("amount")); + String userId = StringUtils.valueOf(map.get("uUserId")); + xhpcUserAccountStatement.setAmount(BigDecimal.valueOf(Double.valueOf(amount))); + xhpcUserAccountStatement.setRechargeOrderId(rechargeOrderId); + xhpcUserAccountStatement.setUserId(Long.parseLong(userId)); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + } xhpcRechargeOrderMapper.update(xhpcRechargeOrder); } } \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java index fed3afae..aff5c844 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundAuditServiceImpl.java @@ -1,7 +1,9 @@ package com.xhpc.payment.service.impl; import com.xhpc.payment.domain.XhpcRefundAudit; +import com.xhpc.payment.domain.XhpcRefundOrder; import com.xhpc.payment.mapper.XhpcRefundAuditMapper; +import com.xhpc.payment.mapper.XhpcRefundOrderMapper; import com.xhpc.payment.service.IXhpcRefundAuditService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,6 +22,9 @@ public class XhpcRefundAuditServiceImpl implements IXhpcRefundAuditService { @Autowired private XhpcRefundAuditMapper xhpcRefundAuditMapper; + @Autowired + private XhpcRefundOrderMapper xhpcRefundOrderMapper; + /** * 新增 退款审核 * @@ -27,6 +32,10 @@ public class XhpcRefundAuditServiceImpl implements IXhpcRefundAuditService { */ @Override public int insert(XhpcRefundAudit xhpcRefundAudit) { + XhpcRefundOrder xhpcRefundOrder = new XhpcRefundOrder(); + xhpcRefundOrder.setRefundOrderId(xhpcRefundAudit.getRefundOrderId()); + xhpcRefundOrder.setStatus(xhpcRefundAudit.getStatus()); + xhpcRefundOrderMapper.update(xhpcRefundOrder); return xhpcRefundAuditMapper.insert(xhpcRefundAudit); } diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java index 0ddcdc93..1abc1f78 100644 --- a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcRefundOrderServiceImpl.java @@ -1,7 +1,10 @@ package com.xhpc.payment.service.impl; +import com.ruoyi.common.core.utils.StringUtils; import com.xhpc.payment.domain.XhpcRefundOrder; +import com.xhpc.payment.domain.XhpcUserAccountStatement; import com.xhpc.payment.mapper.XhpcRefundOrderMapper; +import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; import com.xhpc.payment.service.IXhpcRefundOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,6 +24,9 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { @Autowired private XhpcRefundOrderMapper xhpcRefundOrderMapper; + @Autowired + private XhpcUserAccountStatementMapper xhpcUserAccountStatementMapper; + /** * 更新 退款订单 * @@ -67,12 +73,12 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { */ @Override public XhpcRefundOrder addRefundOrder(String appUserId, BigDecimal amount, String type) { - XhpcRefundOrder XhpcRefundOrder = new XhpcRefundOrder(); - XhpcRefundOrder.setUserId(Long.parseLong(appUserId)); - XhpcRefundOrder.setAmount(amount); - XhpcRefundOrder.setType(Integer.parseInt(type)); - xhpcRefundOrderMapper.insert(XhpcRefundOrder); - return XhpcRefundOrder; + XhpcRefundOrder xhpcRefundOrder = new XhpcRefundOrder(); + xhpcRefundOrder.setUserId(Long.parseLong(appUserId)); + xhpcRefundOrder.setAmount(amount); + xhpcRefundOrder.setType(Integer.parseInt(type)); + xhpcRefundOrderMapper.insert(xhpcRefundOrder); + return xhpcRefundOrder; } /** @@ -85,14 +91,24 @@ public class XhpcRefundOrderServiceImpl implements IXhpcRefundOrderService { */ @Override public void updateRefundOrder(Long refundOrderId, String type, String status, String paymentNumber) { - XhpcRefundOrder XhpcRefundOrder = new XhpcRefundOrder(); - XhpcRefundOrder.setRefundOrderId(refundOrderId); - XhpcRefundOrder.setStatus(Integer.parseInt(status)); + XhpcRefundOrder xhpcRefundOrder = new XhpcRefundOrder(); + xhpcRefundOrder.setRefundOrderId(refundOrderId); + xhpcRefundOrder.setStatus(Integer.parseInt(status)); if ("1".equals(type)) { - XhpcRefundOrder.setPrepayId(paymentNumber); + xhpcRefundOrder.setPrepayId(paymentNumber); } else { - XhpcRefundOrder.setAlipayNumber(paymentNumber); + xhpcRefundOrder.setAlipayNumber(paymentNumber); } - xhpcRefundOrderMapper.update(XhpcRefundOrder); + if ("1".equals(xhpcRefundOrder.getStatus())) { + Map map = xhpcRefundOrderMapper.info(refundOrderId); + XhpcUserAccountStatement xhpcUserAccountStatement = new XhpcUserAccountStatement(); + String amount = "-" + StringUtils.valueOf(map.get("amount")); + String userId = StringUtils.valueOf(map.get("uUserId")); + xhpcUserAccountStatement.setAmount(BigDecimal.valueOf(Double.valueOf(amount))); + xhpcUserAccountStatement.setRefundOrderId(refundOrderId); + xhpcUserAccountStatement.setUserId(Long.parseLong(userId)); + xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + } + xhpcRefundOrderMapper.update(xhpcRefundOrder); } } \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcUserAccountStatementServiceImpl.java b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcUserAccountStatementServiceImpl.java new file mode 100644 index 00000000..1d1c8c62 --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/java/com/xhpc/payment/service/impl/XhpcUserAccountStatementServiceImpl.java @@ -0,0 +1,43 @@ +package com.xhpc.payment.service.impl; + +import com.xhpc.payment.domain.XhpcUserAccountStatement; +import com.xhpc.payment.mapper.XhpcUserAccountStatementMapper; +import com.xhpc.payment.service.IXhpcUserAccountStatementService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 用户流水信息 服务层 + * + * @author ruoyi + */ +@Service +public class XhpcUserAccountStatementServiceImpl implements IXhpcUserAccountStatementService { + + @Autowired + private XhpcUserAccountStatementMapper xhpcUserAccountStatementMapper; + + /** + * 新增 用户流水 + * + * @param xhpcUserAccountStatement 用户流水 + */ + @Override + public int insert(XhpcUserAccountStatement xhpcUserAccountStatement) { + return xhpcUserAccountStatementMapper.insert(xhpcUserAccountStatement); + } + + /** + * 用户流水列表 + * + * @param refundOrderId + * @return + */ + @Override + public List> list(Long refundOrderId) { + return xhpcUserAccountStatementMapper.list(refundOrderId); + } +} \ No newline at end of file diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml index 49d67a80..50a7b0a8 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRechargeOrderMapper.xml @@ -21,7 +21,7 @@ + keyProperty="rechargeOrderId"> INSERT INTO xhpc_recharge_order @@ -48,13 +48,13 @@ del_flag, - + create_time, create_by, - + update_time, @@ -89,13 +89,13 @@ #{delFlag}, - + #{createTime}, #{createBy}, - + #{updateTime}, @@ -116,13 +116,13 @@ prepay_id = #{prepayId}, alipay_number = #{alipayNumber}, - amount = #{amount}, - type = #{type}, - status = #{status}, + amount = #{amount}, + type = #{type}, + status = #{status}, del_flag = #{delFlag}, - create_time = #{createTime}, + create_time = #{createTime}, create_by = #{createBy}, - update_time = #{updateTime}, + update_time = #{updateTime}, update_by = #{updateBy}, remark = #{remark} diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundAuditMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundAuditMapper.xml index 838f46bb..af029244 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundAuditMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundAuditMapper.xml @@ -17,7 +17,7 @@ + keyProperty="refundAuditId"> INSERT INTO xhpc_recharge_order @@ -29,13 +29,13 @@ del_flag, - + create_time, create_by, - + update_time, @@ -55,13 +55,13 @@ #{delFlag}, - + #{createTime}, #{createBy}, - + #{updateTime}, diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml index 68204997..61269638 100644 --- a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcRefundOrderMapper.xml @@ -12,6 +12,7 @@ + @@ -22,7 +23,7 @@ + keyProperty="refundOrderId"> INSERT INTO xhpc_recharge_order @@ -43,19 +44,22 @@ type, + + examine_status, + status, del_flag, - + create_time, create_by, - + update_time, @@ -84,19 +88,22 @@ #{type}, + + #{examineStatus}, + #{status}, #{delFlag}, - + #{createTime}, #{createBy}, - + #{updateTime}, @@ -117,13 +124,14 @@ user_id = #{userId}, prepay_id = #{prepayId}, alipay_number = #{alipayNumber}, - amount = #{amount}, - type = #{type}, - status = #{status}, + amount = #{amount}, + type = #{type}, + examine_status = #{examineStatus}, + status = #{status}, del_flag = #{delFlag}, - create_time = #{createTime}, + create_time = #{createTime}, create_by = #{createBy}, - update_time = #{updateTime}, + update_time = #{updateTime}, update_by = #{updateBy}, remark = #{remark} @@ -133,7 +141,7 @@ select xro.refund_order_id refundOrderId ,xro.refund_order_number refundOrderNumber, xro.alipay_number alipayNumber ,xro.prepay_id prepayid,xro.user_id userId,xro.amount, - xro.type ,xro.`status`,xro.create_time createTime,xau.phone,xdb.dict_value statusName + xro.type,xro.examine_status examineStatus,xro.`status`,xro.create_time createTime, + xau.phone,xdb.dict_value statusName,xdbes.dict_value examineStatusName from xhpc_refund_order xro LEFT JOIN xhpc_app_user xau on xau.app_user_id = xro.user_id LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'refund_order_status' and xdb.dict_key = xro.`status` + LEFT JOIN xhpc_dict_biz xdbes on xdbes.`code` = 'refund_examine_status' and xdbes.dict_key = + xro.`examine_status` where xro.del_flag = 0 and xau.phone like concat(concat('%', #{phone}), '%') diff --git a/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml new file mode 100644 index 00000000..1fe618ed --- /dev/null +++ b/xhpc-modules/xhpc-payment/src/main/resources/mapper/XhpcUserAccountStatementMapper.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + INSERT INTO xhpc_user_account_statement + + + user_id, + + + amount, + + + charge_order_id, + + + recharge_order_id, + + + refund_order_id, + + + status, + + + del_flag, + + + create_time, + + + create_by, + + + update_time, + + + update_by, + + + remark + + + + + #{userId}, + + + #{amount}, + + + #{chargeOrderId}, + + + #{rechargeOrderId}, + + + #{refundOrderId}, + + + #{status}, + + + #{delFlag}, + + + #{createTime}, + + + #{createBy}, + + + #{updateTime}, + + + #{updateBy}, + + + #{remark} + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/DaoAspect.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/DaoAspect.java index 0ace821c..ff782b69 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/DaoAspect.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/DaoAspect.java @@ -3,6 +3,7 @@ package com.xhpc.user.aspect; import com.ruoyi.common.core.utils.SecurityUtils; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.beanutils.BeanUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -25,84 +26,108 @@ import java.util.Date; @Component @Configuration public class DaoAspect { - private static final String CREATE_USER = "createUser"; - private static final String CREATE_TIME = "createTime"; - private static final String UPDATE_USER = "updateUser"; - private static final String UPDATE_TIME = "updateTime"; + private static final String CREATE_USER = "createUser"; + private static final String CREATE_TIME = "createTime"; + private static final String UPDATE_USER = "updateUser"; + private static final String UPDATE_TIME = "updateTime"; - @Pointcut("execution(* com.xhpc..*.update*(..))") - public void daoUpdate() { - } + @Pointcut("execution(* com.xhpc..*.update*(..))") + public void daoUpdate() { + } - @Pointcut("execution(* com.xhpc..*.insert*(..))") - public void daoCreate() { - } + @Pointcut("execution(* com.xhpc..*.insert*(..))") + public void daoCreate() { + } - @Around("daoUpdate()") - public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - if (attributes == null) { - return point.proceed(); - } - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (userName != null){ - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); - } - } - } - } - Object object = point.proceed(); - return object; + @Around("daoUpdate()") + public Object doAroundUpdate(ProceedingJoinPoint point) throws Throwable { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + if (userName != null) { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, new Date()); + } + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; - } + } - @Around("daoCreate()") - public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable { - ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - if (attributes == null) { - return point.proceed(); - } - Object[] objects = point.getArgs(); - if (objects != null && objects.length > 0) { - for (Object arg : objects) { - //String userName = StringUtils.valueOf(SecurityUtils.getUsername()); - String userName = ""; - Date date = new Date(); - if (StringUtils.isNull(userName)) { - userName = "admin"; - } - if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { - BeanUtils.setProperty(arg, CREATE_USER, userName); - } - if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { - BeanUtils.setProperty(arg, UPDATE_USER, userName); - } + @Around("daoCreate()") + public Object doAroundCreate(ProceedingJoinPoint point) throws Throwable { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (attributes == null) { + return point.proceed(); + } + HttpServletRequest request = attributes.getRequest(); + try { + Object[] objects = point.getArgs(); + if (objects != null && objects.length > 0) { + for (Object arg : objects) { + LogUserUtils logUserUtils = new LogUserUtils(); + LoginUser loginUser = logUserUtils.getLogUser(request); + String userName = ""; + try { + userName = SecurityUtils.getUsername(); + } catch (Exception e) { + } + if (StringUtils.isNull(userName)) { + userName = loginUser.getUsername(); + } + if (StringUtils.isNull(userName)) { + userName = "admin"; + } + Date date = new Date(); + if (isProperty(arg, CREATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_USER))) { + BeanUtils.setProperty(arg, CREATE_USER, userName); + } + if (isProperty(arg, UPDATE_USER) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_USER))) { + BeanUtils.setProperty(arg, UPDATE_USER, userName); + } - if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { - BeanUtils.setProperty(arg, CREATE_TIME, date); - } - if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { - BeanUtils.setProperty(arg, UPDATE_TIME, date); - } - } - } - Object object = point.proceed(); - return object; - } + if (isProperty(arg, CREATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, CREATE_TIME))) { + BeanUtils.setProperty(arg, CREATE_TIME, date); + } + if (isProperty(arg, UPDATE_TIME) && StringUtils.isNull(BeanUtils.getProperty(arg, UPDATE_TIME))) { + BeanUtils.setProperty(arg, UPDATE_TIME, date); + } + } + } + } catch (Exception e) { + } + Object object = point.proceed(); + return object; + } - public static boolean isProperty(Object bean, String field){ - return StringUtils.isProperty(bean, field); - } + public static boolean isProperty(Object bean, String field) { + return StringUtils.isProperty(bean, field); + } } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java new file mode 100644 index 00000000..f38094b8 --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/aspect/LogUserUtils.java @@ -0,0 +1,33 @@ +package com.xhpc.user.aspect; + +import com.ruoyi.common.core.constant.CacheConstants; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.system.api.model.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +@Service +public class LogUserUtils { + + @Autowired + private RedisService redisService; + + /** + * 获取登录信息 + * + * @param request 请求参数 + * @return LoginUser 登录用户信息 + */ + public LoginUser getLogUser(HttpServletRequest request) { + String token = request.getHeader(CacheConstants.HEADER); + token = token.substring(7); + LoginUser loginUser = new LoginUser(); + try { + loginUser = redisService.getCacheObject(CacheConstants.LOGIN_TOKEN_KEY + token); + } catch (Exception e) { + } + return loginUser; + } +} diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java index 6b2a1c45..f7ea7598 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcAppUserController.java @@ -105,8 +105,8 @@ public class XhpcAppUserController extends BaseController { */ @ApiOperation("小程序用户详情") @GetMapping("/appInfo") - public AjaxResult appInfo(@RequestParam Long appUserId) { - return AjaxResult.success(iXhpcAppUserUserService.info(appUserId)); + public AjaxResult appInfo(HttpServletRequest request) { + return AjaxResult.success(iXhpcAppUserUserService.appInfo(request)); } /** diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java index 4e19c715..857a4a91 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcAppUser.java @@ -1,6 +1,7 @@ package com.xhpc.user.domain; import com.ruoyi.common.core.web.domain.BaseEntity; +import org.hibernate.validator.constraints.Length; import java.math.BigDecimal; @@ -21,16 +22,19 @@ public class XhpcAppUser extends BaseEntity { /** * 手机号码 */ + @Length(max = 11, message = "手机号码不能超过11位") private String phone; /** * weixin_open_id */ + @Length(max = 50, message = "openId不能超过50位") private String weixinOpenId; /** * alipay_open_id */ + @Length(max = 50, message = "openId不能超过50位") private String alipayOpenId; /** diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcInternetUser.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcInternetUser.java index 5f720a64..1de4ba81 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcInternetUser.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcInternetUser.java @@ -1,6 +1,7 @@ package com.xhpc.user.domain; import com.ruoyi.common.core.web.domain.BaseEntity; +import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -23,37 +24,43 @@ public class XhpcInternetUser extends BaseEntity { * 名称 */ @NotBlank(message = "名称不能为空") + @Length(max = 12, message = "名称不能超过12位") private String name; /** * 手机号码(帐号) */ @NotBlank(message = "手机号码不能为空") + @Length(max = 11, message = "手机号码不能超过11位") private String phone; /** * 联系人 */ @NotBlank(message = "联系人不能为空") + @Length(max = 12, message = "联系人不能超过12位") private String contactName; /** * 联系人电话 */ @NotBlank(message = "联系人电话不能为空") + @Length(max = 11, message = "联系人电话不能超过11位") private String contactPhone; /** * 开户行 */ @NotBlank(message = "开户行不能为空") + @Length(max = 20, message = "开户行电话不能超过20位") private String openBank; /** * 卡号 */ @NotNull(message = "卡号不能为空") - private Long cardNumber; + @Length(max = 20, message = "卡号不能超过20位") + private String cardNumber; /** * 合作开始时间 @@ -80,12 +87,14 @@ public class XhpcInternetUser extends BaseEntity { * 地址 */ @NotBlank(message = "地址不能为空") + @Length(max = 50, message = "地址不能超过50位") private String address; /** * 详细地址 */ @NotBlank(message = "详细地址不能为空") + @Length(max = 50, message = "详细地址不能超过50位") private String detailedAddress; /** @@ -170,11 +179,11 @@ public class XhpcInternetUser extends BaseEntity { this.openBank = openBank; } - public Long getCardNumber() { + public String getCardNumber() { return cardNumber; } - public void setCardNumber(Long cardNumber) { + public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcOperator.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcOperator.java index 83109f16..d361bbce 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcOperator.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/domain/XhpcOperator.java @@ -51,17 +51,28 @@ public class XhpcOperator extends BaseEntity { @NotNull(message = "运营商属性不能为空") private Integer attribute; + + /** + * 税号 + */ + @NotNull(message = "税号不能为空") + @Length(max = 50, message = "税号不能超过50位") + private String dutyParagraph; + + /** * 开户行 */ @NotBlank(message = "开户行不能为空") + @Length(max = 20, message = "开户行电话不能超过20位") private String openBank; /** * 卡号 */ @NotNull(message = "卡号不能为空") - private Long cardNumber; + @Length(max = 20, message = "卡号不能超过20位") + private String cardNumber; /** * 地址code @@ -73,8 +84,16 @@ public class XhpcOperator extends BaseEntity { * 地址 */ @NotBlank(message = "地址不能为空") + @Length(max = 50, message = "地址不能超过50位") private String address; + /** + * 详细地址 + */ + @NotBlank(message = "详细地址不能为空") + @Length(max = 50, message = "详细地址不能超过50位") + private String detailedAddress; + /** * 经度 */ @@ -91,6 +110,7 @@ public class XhpcOperator extends BaseEntity { * 邮箱 */ @NotBlank(message = "邮箱不能为空") + @Length(max = 50, message = "邮箱不能超过50位") private String email; /** @@ -127,6 +147,7 @@ public class XhpcOperator extends BaseEntity { * 设置充电终止的soc */ @NotBlank(message = "充电终止的soc不能为空") + @Length(max = 10, message = "充电终止的soc不能超过10位") private String soc; /** @@ -300,11 +321,27 @@ public class XhpcOperator extends BaseEntity { this.openBank = openBank; } - public Long getCardNumber() { + public String getCardNumber() { return cardNumber; } - public void setCardNumber(Long cardNumber) { + public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; } + + public String getDutyParagraph() { + return dutyParagraph; + } + + public void setDutyParagraph(String dutyParagraph) { + this.dutyParagraph = dutyParagraph; + } + + public String getDetailedAddress() { + return detailedAddress; + } + + public void setDetailedAddress(String detailedAddress) { + this.detailedAddress = detailedAddress; + } } \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java index 149fa0d0..18a54422 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcAppUserUserService.java @@ -80,6 +80,14 @@ public interface IXhpcAppUserUserService { */ public R voluntaryLogin(Map map); + /** + * 小程序用户详情 + * + * @param + * @return 结果 + */ + public Map appInfo(HttpServletRequest request); + /** * 注销账号 * diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index 7391c221..4266b1cc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -11,6 +11,7 @@ import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; +import com.xhpc.user.aspect.LogUserUtils; import com.xhpc.user.domain.XhpcAppUser; import com.xhpc.user.mapper.XhpcAppUserMapper; import com.xhpc.user.service.IXhpcAppUserUserService; @@ -38,6 +39,9 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { @Autowired private TokenService tokenService; + @Autowired + private LogUserUtils logUserUtils; + /** * 更新C端用户 * @@ -216,7 +220,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { // 删除用户缓存记录 tokenService.delLoginUser(loginUser.getToken()); XhpcAppUser user = xhpcAppUserMapper.getAppUserByPhone(username); - if (StringUtils.isNull(user)) { + if (!StringUtils.isNull(user)) { if ("1".equals(type)) { user.setWeixinLogin(0); } else { @@ -242,9 +246,31 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { if (StringUtils.isNull(user)) { throw new BaseException("用户不存在"); } + if ("2".equals(type)) { + if ("0".equals(StringUtils.valueOf(user.getWeixinLogin()))) { + return R.fail(400, "用户未登录"); + } + } else if ("1".equals(type)) { + if ("0".equals(StringUtils.valueOf(user.getWeixinLogin()))) { + return R.fail(400, "用户未登录"); + } + } return appLogin(user.getPhone(), type, openid); } + /** + * 小程序用户详情 + * + * @param + * @return 结果 + */ + @Override + public Map appInfo(HttpServletRequest request) { + LoginUser loginUser = logUserUtils.getLogUser(request); + String userId = StringUtils.valueOf(loginUser.getUserid()); + return xhpcAppUserMapper.info(Long.parseLong(userId)); + } + /** * 注销账号 * diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml new file mode 100644 index 00000000..1947073a --- /dev/null +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcAppUserMapper.xml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO xhpc_app_user + + + app_user_id, + + + phone, + + + weixin_open_id, + + + alipay_open_id, + + + weixin_login, + + + alipay_login, + + + avatar, + + + balance, + + + password, + + + status, + + + del_flag, + + + create_by, + + + create_time, + + + update_by, + + + update_time, + + + remark + + + + + #{appUserId}, + + + #{phone}, + + + #{weixinOpenId}, + + + #{alipayOpenId}, + + + #{weixinLogin}, + + + #{alipayLogin}, + + + #{avatar}, + + + #{balance}, + + + #{password}, + + + #{status}, + + + #{delFlag}, + + + #{createBy}, + + + #{createTime}, + + + #{updateBy}, + + + #{updateTime}, + + + #{remark} + + + + + + UPDATE xhpc_app_user + + phone = #{phone}, + weixin_open_id = #{weixinOpenId}, + alipay_open_id = #{alipayOpenId}, + weixin_login = #{weixinLogin}, + alipay_login = #{alipayLogin}, + avatar = #{avatar}, + balance = #{balance}, + password = #{password}, + status = #{status}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark} + + WHERE app_user_id = #{appUserId} + + + + update xhpc_app_user set del_flag = 2 where app_user_id = #{appUserId} + + + + + + + + + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInternetUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInternetUserMapper.xml index bb44f361..27aca059 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInternetUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcInternetUserMapper.xml @@ -33,7 +33,7 @@ + keyProperty="internetUserId"> INSERT INTO xhpc_internet_user @@ -199,11 +199,11 @@ area_code = #{areaCode}, address = #{address}, detailed_address = #{detailedAddress}, - commission_type = #{commissionType}, + commission_type = #{commissionType}, commission_rate = #{commissionRate}, longitude = #{longitude}, latitude = #{latitude}, - status = #{status}, + status = #{status}, del_flag = #{delFlag}, create_by = #{createBy}, create_time = #{createTime}, diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorInternetBlacklistMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorInternetBlacklistMapper.xml index d7c6243e..33f8f27c 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorInternetBlacklistMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorInternetBlacklistMapper.xml @@ -18,7 +18,7 @@ + keyProperty="xhpcOperatorInternetBlacklistId"> insert into xhpc_operator_internet_blacklist diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml index ab03dea8..9b72d9c6 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcOperatorMapper.xml @@ -11,10 +11,12 @@ + + @@ -36,6 +38,7 @@ xo.operator_id operatorId, xo.name, xo.contact_name contactName, xo.contact_phone contactPhone, xo.phone, xo.attribute,xo.open_bank openBank,xo.card_number cardNumber, xo.area_code areaCode, xo.address, + xo.detailed_address detailedAddress, xo.duty_paragraph dutyParagraph, xo.longitude, xo.latitude, xo.email, xo.commission_type commissionType, xo.platform_commission_rate platformCommissionRate, xo.maintenance_commission_rate maintenanceCommissionRate, @@ -45,7 +48,7 @@ + keyProperty="operatorId"> insert into xhpc_operator @@ -63,6 +66,12 @@ attribute, + + duty_paragraph, + + + detailed_address, + open_bank, @@ -140,6 +149,12 @@ #{attribute}, + + #{dutyParagraph}, + + + #{detailedAddress}, + #{openBank}, @@ -213,13 +228,13 @@ phone = #{phone}, attribute = #{attribute}, open_bank = #{openBank}, - card_number = #{cardNumber}, + card_number = #{cardNumber}, area_code = #{areaCode}, address = #{address}, longitude = #{longitude}, latitude = #{latitude}, email = #{email}, - commission_type = #{commissionType}, + commission_type = #{commissionType}, platform_commission_rate = #{platformCommissionRate}, @@ -231,7 +246,7 @@ withdrawal_time = #{withdrawalTime}, soc = #{soc}, - status = #{status}, + status = #{status}, del_flag = #{delFlag}, create_time = #{createTime}, create_by = #{createBy}, @@ -266,8 +281,8 @@ select xo.operator_id operatorId, xo.name, xo.contact_name contactName, - xo.contact_phone contactPhone, xo.phone, xo.attribute, + xo.contact_phone contactPhone, xo.phone, xo.attribute, xo.duty_paragraph dutyParagraph, xdb.dict_value attributenName from xhpc_operator `xo` LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcStationInternetBlacklistMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcStationInternetBlacklistMapper.xml index 580027fe..79beac8f 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcStationInternetBlacklistMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcStationInternetBlacklistMapper.xml @@ -18,7 +18,7 @@ + keyProperty="xhpcStationInternetBlackId"> insert into xhpc_station_internet_blacklist @@ -30,13 +30,13 @@ status, - + create_time, create_by, - + update_time, @@ -56,13 +56,13 @@ #{status}, - + #{createTime}, #{createBy}, - + #{updateTime}, diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml index 7f09142f..e5a68a4a 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcUserMapper.xml @@ -43,7 +43,7 @@ avatar = #{avatar}, password = #{password}, data_power_type = #{dataPowerType}, - status = #{status}, + status = #{status}, del_flag = #{delFlag}, login_ip = #{loginIp}, login_date = #{loginDate}, @@ -133,8 +133,14 @@ WHERE su.del_flag = 0 and user_id = #{userId} - + select user_id userId, dept_id deptid,user_name userName, + nick_name nickName, user_type userType, email, + phonenumber,operator_id operatorId, internet_user_id internetUserId, + sex,avatar,password,data_power_type dataPowerType, status, + del_flag delFlag, login_ip loginIp, login_date loginDate, + create_by createBy, create_time createTime, update_by updateBy, + update_time updateTime, remark from sys_user where user_name = #{userName}