init
This commit is contained in:
33
api/.gitignore
vendored
Normal file
33
api/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
65
api/pom.xml
Normal file
65
api/pom.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-vue-plus</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.8.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>api</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- Mysql驱动包 -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ct</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
BIN
api/src/main/.DS_Store
vendored
Normal file
BIN
api/src/main/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
api/src/main/java/.DS_Store
vendored
Normal file
BIN
api/src/main/java/.DS_Store
vendored
Normal file
Binary file not shown.
17
api/src/main/java/com/ruoyi/CTAPIApplication.java
Normal file
17
api/src/main/java/com/ruoyi/CTAPIApplication.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ruoyi;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"com.ruoyi.api", "com.ruoyi.ct"})
|
||||
public class CTAPIApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(CTAPIApplication.class);
|
||||
application.setApplicationStartup(new BufferingApplicationStartup(2048));
|
||||
application.run(args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ API启动成功 ლ(´ڡ`ლ)゙");
|
||||
}
|
||||
|
||||
}
|
||||
BIN
api/src/main/java/com/ruoyi/api/.DS_Store
vendored
Normal file
BIN
api/src/main/java/com/ruoyi/api/.DS_Store
vendored
Normal file
Binary file not shown.
45
api/src/main/java/com/ruoyi/api/EncryptDemo.java
Normal file
45
api/src/main/java/com/ruoyi/api/EncryptDemo.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.api;
|
||||
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
public class EncryptDemo {
|
||||
public static void main(String[] args) {
|
||||
// SM2的公钥
|
||||
// String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEZRdaHuSCG8U87+Cmh9LKbgC+DRBEwWpAyN31aCzoE1flWonnZezX2GqbvDdz7a0AxE6+FGEH1lxPYW39XhYupw==";
|
||||
String publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEPWIPW8Q8OvHvDfDe3cA4ipkUvR+sDLpqA5uCDqp4BQy3iYCUO62HdNsBnB8/IplMZy8LiJeiRkt0zn740FqGtw==";
|
||||
// SM2的私钥
|
||||
String privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQggIODudYqK6cb2KKXtVAcoMRSoWotOAuZRKqbgixUmdmgCgYIKoEcz1UBgi2hRANCAARR6gv7bA9ZXo7nr5dnk7K2q8JrnaoyDZ3mr2GPvPVlff9BH/jc6E9j1Ua6GJLpHsjdR+DgdoHrZNF4BqgaabQL";
|
||||
// String privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQghUZb+m/+ficnlbtoVJhkbUsw9FKQ5yF1wYcOP+tRQK+gCgYIKoEcz1UBgi2hRANCAASsJ3XVa/Udszyl0/tudSM7tUJsK190+2UQmEEZ6qLbRguzN+vaI3dsc04KllUojTRgXvE3vfaNAHOwQ6H5cjH+";
|
||||
// 初始化SM2
|
||||
SM2 sm2 = SmUtil.sm2(privateKey, publicKey);
|
||||
// 使用SM2加密字符串
|
||||
String encryptStr = sm2.encryptBase64("何琳琳", KeyType.PublicKey);
|
||||
// String encryptStr3 = sm2.encryptBase64("13371893748", KeyType.PublicKey);
|
||||
// System.out.println(sm2.encryptBase64("e34c1951-c492-4ed5-8e02-1e44eee3df7b", KeyType.PublicKey));
|
||||
// System.out.println(encryptStr);
|
||||
String b = "{\n" +
|
||||
" \"saleId\": \"108103\",\n" +
|
||||
" \"name\": \"毕彦兵\",\n" +
|
||||
" \"idCard\": \"230104198809293718\",\n" +
|
||||
" \"contactMobile\": \"18980692055\",\n" +
|
||||
" \"province\": \"黑龙江省\",\n" +
|
||||
" \"city\": \"哈尔滨市\",\n" +
|
||||
" \"county\": \"松北区\",\n" +
|
||||
" \"installedAddress\": \"世茂大道\",\n" +
|
||||
" \"number\": \"17301750842\"\n" +
|
||||
"}";
|
||||
|
||||
System.out.println(sm2.encryptBase64(b, KeyType.PublicKey));
|
||||
// System.out.println(encryptStr3);
|
||||
// 使用SM2解密字符串
|
||||
// String data = sm2.decryptStr("BI7jtmBaoB+O0E/5qbBZd35h5M/BGhLcCB0kOM5ONebPJNC7+mS404aeYpqQEmW5caqLYX9y6eV87tOKwWC3bs+ns83SHA8k1yMMTZrHKooPAH28ylgrgv/jZZbw7Xtsfxm3+XjWUQDmacHrYujwlhCiAHRxAEIot/3fvSkVB49gHjaDj7ER0NQCKUwVt5xLXgJlCHyYsWmY+ZWj6LmzBzIdND1IFQIEx3iKDuXAgZ05ojQb+y27YlI1TLKn36eTOlhifdnOG89UN1UWkMZuZ8m5qnaMyR7bT+7LazIyBvgAGMkgGpCNwVBXT4t5y+/nRvHwYkURGGO7DLgybL5/KtZ74yemZ52tqgU8pm4HWNWncdZ7veeu55gwUe8ttt3C8UtTwtSYlrRpfoWTSwE8rBtvl//MZWkNXqePCnO1QIQYhKiX5GopqjlxFLlr0CirW0/fhA==", KeyType.PrivateKey);
|
||||
// String data = sm2.decryptStr("BLmSzK7I1FAzi+bePR5HhCL0WruEYftUA4bw1cU0TBM0xfX4MX6ImLJzVBJP5jATbOsDC136xuDBf8uFZxmXf2gnIEOX+qBfZD7LcPgdcv06TpnCVtEQEcGULMe/iB3SEHj2xAx3R3bbkgXKGrJ2paj2D4S0uwbs0mLYpIQLFXsXogNupeUHEIq8aLNyUEDRH9HMFG+sJMJpGW80CaywaCCoevpwjc2pAdMdejT5+4/mQjXhKE5kBMyuRA0ugHR6ZfMd9P+pEk6UFDzlWw8kJ11xWgPZcNKWNA3JJBt035jdyMLNfIrPSeHjVXoQZR/l0CXcu+CsFuYvRH3zVaZBqFy+mmeB8omsdnGiuVYcJQfhAnrdU2p4bZEYAwN7KdaZCOPwE/xHoEyAsxKn/WExsYNfyaCs7wzrVaRJmOGBxL4AxzH9W4M6K6SILdPWeaz/DnPZG+pkSIck9jUwcYQnXR9y2EO95l1kwnbYrhFvL5EdLvHZgnrpWP2P7NCqixCKWYP/2rOoXpfhC0e+6w26lKAOUNbqlMWmvEcNBSUqLLzlmogmhB+Dk3SaJX6cwsFzJR9qW/4jE52V+E2pcD4ZIiqNu6UkFWZvMwQqxUvn/evyoKpPQZNr16HKTmyqG/BODPSDPOACmLDD/B8cLidb9MQaYbfS9eEXkTR7GMWji4YGBU8sMBP7WA==", KeyType.PrivateKey);
|
||||
// System.out.println(data);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.api.config;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||
public R<Void> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
|
||||
HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
|
||||
return R.fail(405, e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public R<Void> handleRuntimeException(RuntimeException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R<Void> handleException(Exception e, HttpServletRequest request) {
|
||||
if (e instanceof NoHandlerFoundException) {
|
||||
return R.fail(404, e.getMessage());
|
||||
}
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ruoyi.api.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.ruoyi.ct.mapper")
|
||||
public class MybatisPlusConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); //配置插件类
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //具体到配置哪一个插件
|
||||
return interceptor;
|
||||
}
|
||||
}
|
||||
|
||||
454
api/src/main/java/com/ruoyi/api/controller/APIController.java
Normal file
454
api/src/main/java/com/ruoyi/api/controller/APIController.java
Normal file
@@ -0,0 +1,454 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.CTResponse;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.ct.domain.AgentOrder;
|
||||
import com.ruoyi.ct.domain.bo.AgentAccountGoodBo;
|
||||
import com.ruoyi.ct.domain.bo.AgentOrderBo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountGoodVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentOrderVo;
|
||||
import com.ruoyi.ct.domain.vo.GoodVo;
|
||||
import com.ruoyi.ct.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("api/v1.0.0")
|
||||
public class APIController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CTService ctService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountService agentAccountService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountGoodService agentAccountGoodService;
|
||||
|
||||
@Resource
|
||||
private IAgentService agentService;
|
||||
|
||||
@Resource
|
||||
private IAgentOrderService agentOrderService;
|
||||
|
||||
@Resource
|
||||
private IGoodService goodService;
|
||||
|
||||
/**
|
||||
* 获取账号下的商品列表
|
||||
* @param request
|
||||
* @param page 页码,默认:1
|
||||
* @param pageSize 每页条数:默认20,最大不超过50
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getGoodsList")
|
||||
public R<JSONObject> getGoodsList(HttpServletRequest request, Integer page, Integer pageSize) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
AgentAccountGoodBo agentAccountGoodBo = new AgentAccountGoodBo();
|
||||
agentAccountGoodBo.setAgentAccountId(agentAccountVo.getId());
|
||||
Page<AgentAccountGoodVo> result = agentAccountGoodService.queryPage(agentAccountGoodBo, page, pageSize);
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", result.getTotal());
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
|
||||
List<JSONObject> dataList = new ArrayList<>();
|
||||
for(AgentAccountGoodVo vo: result.getRecords()) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("saleId", vo.getSaleId());
|
||||
data.set("title", vo.getTitle());
|
||||
data.set("content", vo.getContent());
|
||||
dataList.add(data);
|
||||
}
|
||||
resultData.set("objects", dataList);
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "", resultData.toString());
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getNumberList")
|
||||
public R<List<JSONObject>> getNumberList(HttpServletRequest request, Integer page, Integer pageSize, String saleId) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("参数错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:saleId为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
AgentAccountGoodVo agentAccountGoodVo = agentAccountGoodService.getByGoodAndAccount(saleId, agentAccountVo.getId());
|
||||
if (ObjectUtils.isNull(agentAccountGoodVo)) {
|
||||
log.error("参数错误");
|
||||
log.error("agentAccountVo: "+agentAccountVo);
|
||||
log.error("saleId: "+saleId);
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:没找到代理商账号代理的商品", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
List<JSONObject> data = ctService.selectNumber(agentAccountVo.getPersonnelId(), agentAccountGoodVo.getSaleId(), String.valueOf(page), String.valueOf(pageSize));
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "", data.toString());
|
||||
return R.ok(data);
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "电信请求异常", "[]");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.ok(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("confirmOrder")
|
||||
public R<String> confirmOrder(HttpServletRequest request, @RequestBody String body) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
try {
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
body = sm2.decryptStr(body, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("数据解密错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "数据解密错误", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "数据解密错误");
|
||||
}
|
||||
|
||||
JSONObject requestBody = JSONUtil.parseObj(body);
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderBo agentOrderBo = requestBody.toBean(AgentOrderBo.class);
|
||||
// 填充固定数据
|
||||
agentOrderBo.setAgentName(agentAccountVo.getAgentName());
|
||||
agentOrderBo.setAgentId(agentAccountVo.getAgentId());
|
||||
agentOrderBo.setStoreId("13");
|
||||
agentOrderBo.setSerialNumber(UUID.randomUUID().toString().replace("-", ""));
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
agentOrderBo.setCreateTime(new Date());
|
||||
AgentAccountGoodVo agentAccountGoodVo;
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
{
|
||||
// 校验数据
|
||||
// 校验gid
|
||||
String saleId = requestBody.getStr("saleId");
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("saleId为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
try {
|
||||
agentAccountGoodVo = agentAccountGoodService.getByGoodAndAccount(saleId, agentAccountVo.getId());
|
||||
agentOrderBo.setAgentAccountId(agentAccountGoodVo.getId());
|
||||
agentOrderBo.setSaleId(agentAccountGoodVo.getSaleId());
|
||||
GoodVo goodVo = goodService.queryById(agentAccountGoodVo.getGoodId());
|
||||
agentOrderBo.setTitle(goodVo.getName());
|
||||
agentOrderBo.setContent(goodVo.getContent());
|
||||
|
||||
if (ObjectUtils.isNull(agentAccountGoodVo)) {
|
||||
log.error("saleId无效");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId无效", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("saleId格式错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId格式错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
// 校验用户信息,姓名、身份证、手机号
|
||||
if (ObjectUtils.isNull(agentOrderBo.getName())) {
|
||||
log.error("姓名为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "姓名为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getIdCard())) {
|
||||
log.error("身份证号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "身份证号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
// String regex = "^\\d{17}[Xx]|\\d{15}$";
|
||||
// Pattern pattern = Pattern.compile(regex);
|
||||
// Matcher matcher = pattern.matcher(agentOrderBo.getIdCard());
|
||||
// if (!matcher.matches()) {
|
||||
// log.error("身份证号格式错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "身份证号格式错误", null);
|
||||
// return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
// }
|
||||
if (ObjectUtils.isNull(agentOrderBo.getContactMobile())) {
|
||||
log.error("手机号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "手机号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
// regex = "^1[3-9]\\d{9}$";
|
||||
// pattern = Pattern.compile(regex);
|
||||
// matcher = pattern.matcher(agentOrderBo.getContactMobile());
|
||||
// if (!matcher.matches()) {
|
||||
// log.error("手机号格式错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "手机号格式错误", null);
|
||||
// return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
// }
|
||||
|
||||
// 校验地址信息
|
||||
if (ObjectUtils.isNull(agentOrderBo.getProvince())) {
|
||||
log.error("省为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "省为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCity())) {
|
||||
log.error("市为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "市为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCounty())) {
|
||||
log.error("区为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "区为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstalledAddress())) {
|
||||
log.error("地址为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "地址为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstallAddress())) {
|
||||
agentOrderBo.setInstallAddress(agentOrderBo.getInstalledAddress());
|
||||
}
|
||||
// todo 根据代理商提供的验证url验证用户
|
||||
JSONObject paramMap = new JSONObject();
|
||||
paramMap.set("name", agentOrderBo.getName());
|
||||
paramMap.set("idCard", agentOrderBo.getIdCard());
|
||||
paramMap.set("contactMobile", agentOrderBo.getContactMobile());
|
||||
if (ObjectUtils.isNotNull(agentAccountVo.getVerifyUrl())) {
|
||||
try {
|
||||
String verifyResult = HttpUtil.post(agentAccountVo.getVerifyUrl(), sm2.encryptBase64(paramMap.toString(), KeyType.PublicKey));
|
||||
JSONObject verifyData = JSONUtil.parseObj(verifyResult);
|
||||
if (verifyData.getInt("code") != 200) {
|
||||
log.error("验证不通过");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "验证不通过", null);
|
||||
return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("验证请求错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "验证请求错误", null);
|
||||
return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
// agentOrderService.insertByBo(agentOrderBo);
|
||||
try {
|
||||
CTResponse<String> response = ctService.saveOrder(agentOrderBo.getName(), agentOrderBo.getIdCard(), agentOrderBo.getContactMobile(),
|
||||
agentOrderBo.getInstalledAddress(), agentOrderBo.getSaleId(), agentOrderBo.getStoreId(),
|
||||
agentOrderBo.getPersonnelId(), agentOrderBo.getProvince(), agentOrderBo.getCity(),
|
||||
agentOrderBo.getCounty(), agentOrderBo.getSerialNumber(), agentOrderBo.getNumber(),
|
||||
agentOrderBo.getLogiRemark(), agentOrderBo.getPageUrl(), agentOrderBo.getRemark(),
|
||||
agentOrderBo.getInstallAddress(), "", "");
|
||||
if (response.isSuccess()) {
|
||||
agentOrderBo.setOrderNum(response.getData());
|
||||
agentOrderBo.setOrderStatus("S1000");
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderService.insertByBo(agentOrderBo);
|
||||
return R.ok("操作成功", agentOrderBo.getSerialNumber());
|
||||
} else {
|
||||
// 订单验证失败
|
||||
log.error("电信订单验证失败");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信订单验证失败", response.getMessage());
|
||||
return R.fail(ERROR_CODE_PARAMS, response.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信请求异常", "");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.fail(ERROR_CODE_NETWORK, "电信网络异常");
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("getOrderList")
|
||||
public R<JSONObject> getOrderList(HttpServletRequest request,
|
||||
Integer page, Integer pageSize,
|
||||
String saleId,
|
||||
String name, String contactMobile, String number) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
|
||||
AgentAccountGoodBo agentAccountGoodBo = new AgentAccountGoodBo();
|
||||
agentAccountGoodBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
|
||||
// if (ObjectUtils.isNull(saleId) && ObjectUtils.isNull(name) && ObjectUtils.isNull(contactMobile) && ObjectUtils.isNull(number)) {
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("无saleId");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "无参数", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<AgentOrder> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(AgentOrder::getPersonnelId, agentAccountVo.getPersonnelId());
|
||||
lqw.eq(ObjectUtils.isNotNull(saleId), AgentOrder::getSaleId, saleId);
|
||||
if (ObjectUtils.isNotNull(name)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(name), AgentOrder::getName, sm2.decryptStr(name, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密姓名错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密姓名错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(contactMobile)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(contactMobile), AgentOrder::getContactMobile, sm2.decryptStr(contactMobile, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密联系电话错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密联系电话错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(number)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(number), AgentOrder::getNumber, sm2.decryptStr(number, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密手机号错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密手机号错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
|
||||
lqw.gt(AgentOrder::getStatus, "-1");
|
||||
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(page);
|
||||
pageQuery.setPageSize(pageSize);
|
||||
TableDataInfo<AgentOrderVo> tableDataInfo = agentOrderService.queryList(lqw, pageQuery);
|
||||
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", tableDataInfo.getTotal());
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
List<JSONObject> objects = new ArrayList<>();
|
||||
|
||||
for (AgentOrderVo vo: tableDataInfo.getRows()) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", vo.getSerialNumber());
|
||||
data.set("name", vo.getName());
|
||||
data.set("contactMobile", vo.getContactMobile());
|
||||
data.set("idCard", vo.getIdCard());
|
||||
data.set("number", vo.getNumber());
|
||||
data.set("status", vo.getStatus());
|
||||
data.set("orderStatus", vo.getOrderStatus());
|
||||
data.set("createTime", vo.getCreateTime());
|
||||
data.set("updateTime", vo.getUpdateTime());
|
||||
data.set("isRecharge", vo.getIsRecharge());
|
||||
data.set("chargeTitle", vo.getChargeTitle());
|
||||
data.set("expressVendor", vo.getExpressVendor());
|
||||
data.set("expressNum", vo.getExpressNum());
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", vo.getSaleId());
|
||||
goods.set("title", vo.getTitle());
|
||||
goods.set("content", vo.getContent());
|
||||
data.set("bookingGoods", goods);
|
||||
|
||||
objects.add(data);
|
||||
}
|
||||
|
||||
resultData.set("objects", sm2.encryptBase64(objects.toString(), KeyType.PublicKey));
|
||||
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getOrderDetail")
|
||||
public R<String> getOrderDetail(HttpServletRequest request, String serialNumber) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(serialNumber)) {
|
||||
log.error("参数错误:serialNumber为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:serialNumber为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
AgentOrderBo bo = new AgentOrderBo();
|
||||
bo.setSerialNumber(serialNumber);
|
||||
bo.setAgentId(agentAccountVo.getAgentId());
|
||||
bo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
List<AgentOrderVo> voList = agentOrderService.queryList(bo);
|
||||
if (voList.size() > 0) {
|
||||
AgentOrderVo vo = voList.get(0);
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", vo.getSerialNumber());
|
||||
data.set("name", vo.getName());
|
||||
data.set("contactMobile", vo.getContactMobile());
|
||||
data.set("idCard", vo.getIdCard());
|
||||
data.set("number", vo.getNumber());
|
||||
data.set("status", vo.getStatus());
|
||||
data.set("orderStatus", vo.getStatus());
|
||||
data.set("isRecharge", vo.getIsRecharge());
|
||||
data.set("chargeTitle", vo.getChargeTitle());
|
||||
data.set("expressVendor", vo.getExpressVendor());
|
||||
data.set("expressNum", vo.getExpressNum());
|
||||
data.set("routeArr", JSONUtil.parseArray(vo.getRouteArr()));
|
||||
data.set("expressRoutes", JSONUtil.parseArray(vo.getExpressRoutes()));
|
||||
data.set("createTime", vo.getCreateTime());
|
||||
data.set("updateTime", vo.getUpdateTime());
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", vo.getSaleId());
|
||||
goods.set("title", vo.getTitle());
|
||||
goods.set("content", vo.getContent());
|
||||
data.set("bookingGoods", goods);
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
return R.ok(null, sm2.encryptBase64(data.toString(), KeyType.PublicKey));
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String body = "{\"name\":\"毕彦兵\",\"idCard\":\"230104198809293718\",\"contactNumber\":\"18980692055\",\"installedAddress\":\"世贸大道世贸都柏林49栋3单元2402\",\"gid\":1,\"province\":\"黑龙江\",\"city\":\"哈尔滨\",\"county\":\"松北区\",\"number\":\"19384158592\",\"logiRemark\":\"\",\"pageUrl\":\"\",\"remark\":\"\",}";
|
||||
}
|
||||
}
|
||||
547
api/src/main/java/com/ruoyi/api/controller/APIControllerV2.java
Normal file
547
api/src/main/java/com/ruoyi/api/controller/APIControllerV2.java
Normal file
@@ -0,0 +1,547 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.CTResponse;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.ct.domain.AgentOrder;
|
||||
import com.ruoyi.ct.domain.bo.AgentAccountGoodBo;
|
||||
import com.ruoyi.ct.domain.bo.AgentOrderBo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountGoodVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentOrderVo;
|
||||
import com.ruoyi.ct.domain.vo.GoodVo;
|
||||
import com.ruoyi.ct.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("api/v2.0.0")
|
||||
public class APIControllerV2 extends BaseController {
|
||||
|
||||
@Resource
|
||||
private CTService ctService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountService agentAccountService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountGoodService agentAccountGoodService;
|
||||
|
||||
@Resource
|
||||
private IAgentService agentService;
|
||||
|
||||
@Resource
|
||||
private IAgentOrderService agentOrderService;
|
||||
|
||||
@Resource
|
||||
private IGoodService goodService;
|
||||
|
||||
/**
|
||||
* 获取账号下的商品列表
|
||||
* @param request
|
||||
* @param page 页码,默认:1
|
||||
* @param pageSize 每页条数:默认20,最大不超过50
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getGoodsList")
|
||||
public R<JSONObject> getGoodsList(HttpServletRequest request, Integer page, Integer pageSize) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
AgentAccountGoodBo agentAccountGoodBo = new AgentAccountGoodBo();
|
||||
agentAccountGoodBo.setAgentAccountId(agentAccountVo.getId());
|
||||
Page<AgentAccountGoodVo> result = agentAccountGoodService.queryPage(agentAccountGoodBo, page, pageSize);
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", result.getTotal());
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
|
||||
List<JSONObject> dataList = new ArrayList<>();
|
||||
for(AgentAccountGoodVo vo: result.getRecords()) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("saleId", vo.getSaleId());
|
||||
data.set("title", vo.getTitle());
|
||||
data.set("content", vo.getContent());
|
||||
dataList.add(data);
|
||||
}
|
||||
resultData.set("objects", dataList);
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "", resultData.toString());
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getNumberList")
|
||||
public R<List<JSONObject>> getNumberList(HttpServletRequest request, Integer page, Integer pageSize, String saleId) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("参数错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:saleId为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
AgentAccountGoodVo agentAccountGoodVo = agentAccountGoodService.getByGoodAndAccount(saleId, agentAccountVo.getId());
|
||||
if (ObjectUtils.isNull(agentAccountGoodVo)) {
|
||||
log.error("参数错误");
|
||||
log.error("agentAccountVo: "+agentAccountVo);
|
||||
log.error("saleId: "+saleId);
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:没找到代理商账号代理的商品", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
List<JSONObject> data = ctService.selectNumber(agentAccountVo.getPersonnelId(), agentAccountGoodVo.getSaleId(), String.valueOf(page), String.valueOf(pageSize));
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "", data.toString());
|
||||
return R.ok(data);
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "电信请求异常", "[]");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.ok(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("confirmOrderBaseInfo")
|
||||
public R<String> confirmOrderBaseInfo(HttpServletRequest request, @RequestBody String body) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
try {
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
body = sm2.decryptStr(body, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("数据解密错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "数据解密错误", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "数据解密错误");
|
||||
}
|
||||
|
||||
JSONObject requestBody = JSONUtil.parseObj(body);
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderBo agentOrderBo = requestBody.toBean(AgentOrderBo.class);
|
||||
// 填充固定数据
|
||||
agentOrderBo.setAgentName(agentAccountVo.getAgentName());
|
||||
agentOrderBo.setAgentId(agentAccountVo.getAgentId());
|
||||
agentOrderBo.setStoreId("13");
|
||||
agentOrderBo.setSerialNumber(UUID.randomUUID().toString().replace("-", ""));
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
agentOrderBo.setCreateTime(new Date());
|
||||
AgentAccountGoodVo agentAccountGoodVo;
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
{
|
||||
// 校验数据
|
||||
// 校验gid
|
||||
String saleId = requestBody.getStr("saleId");
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("saleId为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
try {
|
||||
agentAccountGoodVo = agentAccountGoodService.getByGoodAndAccount(saleId, agentAccountVo.getId());
|
||||
agentOrderBo.setAgentAccountId(agentAccountGoodVo.getId());
|
||||
agentOrderBo.setSaleId(agentAccountGoodVo.getSaleId());
|
||||
GoodVo goodVo = goodService.queryById(agentAccountGoodVo.getGoodId());
|
||||
agentOrderBo.setTitle(goodVo.getName());
|
||||
agentOrderBo.setContent(goodVo.getContent());
|
||||
|
||||
if (ObjectUtils.isNull(agentAccountGoodVo)) {
|
||||
log.error("saleId无效");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId无效", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("saleId格式错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "saleId格式错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
// 校验用户信息,姓名、身份证、手机号
|
||||
if (ObjectUtils.isNull(agentOrderBo.getName())) {
|
||||
log.error("姓名为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "姓名为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getIdCard())) {
|
||||
log.error("身份证号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "身份证号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
// String regex = "^\\d{17}[Xx]|\\d{15}$";
|
||||
// Pattern pattern = Pattern.compile(regex);
|
||||
// Matcher matcher = pattern.matcher(agentOrderBo.getIdCard());
|
||||
// if (!matcher.matches()) {
|
||||
// log.error("身份证号格式错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "身份证号格式错误", null);
|
||||
// return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
// }
|
||||
if (ObjectUtils.isNull(agentOrderBo.getContactMobile())) {
|
||||
log.error("手机号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "手机号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
// regex = "^1[3-9]\\d{9}$";
|
||||
// pattern = Pattern.compile(regex);
|
||||
// matcher = pattern.matcher(agentOrderBo.getContactMobile());
|
||||
// if (!matcher.matches()) {
|
||||
// log.error("手机号格式错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "手机号格式错误", null);
|
||||
// return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
// }
|
||||
|
||||
// 校验地址信息
|
||||
if (ObjectUtils.isNull(agentOrderBo.getProvince())) {
|
||||
log.error("省为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "省为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCity())) {
|
||||
log.error("市为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "市为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCounty())) {
|
||||
log.error("区为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "区为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstalledAddress())) {
|
||||
log.error("地址为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "地址为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstallAddress())) {
|
||||
agentOrderBo.setInstallAddress(agentOrderBo.getInstalledAddress());
|
||||
}
|
||||
// todo 根据代理商提供的验证url验证用户
|
||||
JSONObject paramMap = new JSONObject();
|
||||
paramMap.set("name", agentOrderBo.getName());
|
||||
paramMap.set("idCard", agentOrderBo.getIdCard());
|
||||
paramMap.set("contactMobile", agentOrderBo.getContactMobile());
|
||||
// if (ObjectUtils.isNotNull(agentAccountVo.getVerifyUrl())) {
|
||||
// try {
|
||||
// String verifyResult = HttpUtil.post(agentAccountVo.getVerifyUrl(), sm2.encryptBase64(paramMap.toString(), KeyType.PublicKey));
|
||||
// JSONObject verifyData = JSONUtil.parseObj(verifyResult);
|
||||
// if (verifyData.getInt("code") != 200) {
|
||||
// log.error("验证不通过");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "验证不通过", null);
|
||||
// return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// log.error("验证请求错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "验证请求错误", null);
|
||||
// return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
agentOrderService.insertByBo(agentOrderBo);
|
||||
return R.ok("操作成功", agentOrderBo.getSerialNumber());
|
||||
}
|
||||
|
||||
@PostMapping("uploadImg")
|
||||
public R<String> uploadImg(HttpServletRequest request, @RequestBody String body) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
// try {
|
||||
// SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
// body = sm2.decryptStr(body, KeyType.PrivateKey);
|
||||
// } catch (Exception e) {
|
||||
// log.error("数据解密错误");
|
||||
// saveLog(request, agentAccountVo.getPersonnelId(), 0, "数据解密错误", null);
|
||||
// return R.fail(ERROR_CODE_ENCRYPT, "数据解密错误");
|
||||
// }
|
||||
|
||||
JSONObject requestBody = JSONUtil.parseObj(body);
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderVo agentOrderVo = agentOrderService.queryBySerialNumber(requestBody.getStr("serialNumber"));
|
||||
if (ObjectUtils.isNull(agentOrderVo)) {
|
||||
log.error("订单不存在");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "订单不存在", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "订单不存在");
|
||||
}
|
||||
try {
|
||||
CTResponse<String> response = ctService.uploadFile(agentOrderVo.getSerialNumber(), agentOrderVo.getName(),
|
||||
agentOrderVo.getIdCard(), requestBody.getStr("type"), agentOrderVo.getUploadMsgId(), requestBody.getStr("img"));
|
||||
if (response.isSuccess()) {
|
||||
AgentOrderBo agentOrderBo = new AgentOrderBo();
|
||||
agentOrderBo.setId(agentOrderVo.getId());
|
||||
agentOrderBo.setUploadMsgId(response.getData());
|
||||
if (requestBody.getStr("type").equals("idCardFront")) {
|
||||
agentOrderBo.setIdCardFront(1);
|
||||
}
|
||||
else if (requestBody.getStr("type").equals("idCardBack")) {
|
||||
agentOrderBo.setIdCardBack(1);
|
||||
}
|
||||
else if (requestBody.getStr("type").equals("frontFace")) {
|
||||
agentOrderBo.setFrontFace(1);
|
||||
}
|
||||
agentOrderService.updateByBo(agentOrderBo);
|
||||
return R.ok(agentOrderVo.getSerialNumber());
|
||||
} else {
|
||||
// 订单验证失败
|
||||
log.error("上传失败");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "上传失败", response.getMessage());
|
||||
return R.fail(ERROR_CODE_PARAMS, response.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信请求异常", "");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.fail(ERROR_CODE_NETWORK, "电信网络异常");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("confirmOrder")
|
||||
public R<String> confirmOrder(HttpServletRequest request, @RequestBody String body) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
try {
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
body = sm2.decryptStr(body, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("数据解密错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "数据解密错误", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "数据解密错误");
|
||||
}
|
||||
|
||||
JSONObject requestBody = JSONUtil.parseObj(body);
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderVo agentOrderVo = agentOrderService.queryBySerialNumber(requestBody.getStr("serialNumber"));
|
||||
if (ObjectUtils.isNull(agentOrderVo)) {
|
||||
log.error("订单不存在");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "订单不存在", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "订单不存在");
|
||||
}
|
||||
if (agentOrderVo.getIdCardFront() == 0 || agentOrderVo.getIdCardBack() == 0 || agentOrderVo.getFrontFace() == 0) {
|
||||
log.error("照片上传不完整");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "照片上传不完整", null);
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "照片上传不完整");
|
||||
}
|
||||
try {
|
||||
CTResponse<String> response = ctService.saveOrder(agentOrderVo.getName(), agentOrderVo.getIdCard(), agentOrderVo.getContactMobile(),
|
||||
agentOrderVo.getInstalledAddress(), agentOrderVo.getSaleId(), agentOrderVo.getStoreId(),
|
||||
agentOrderVo.getPersonnelId(), agentOrderVo.getProvince(), agentOrderVo.getCity(),
|
||||
agentOrderVo.getCounty(), agentOrderVo.getSerialNumber(), agentOrderVo.getNumber(),
|
||||
agentOrderVo.getLogiRemark(), agentOrderVo.getPageUrl(), agentOrderVo.getRemark(),
|
||||
agentOrderVo.getInstallAddress(), "", "idCardFront,idCardBack,frontFace");
|
||||
if (response.isSuccess()) {
|
||||
AgentOrderBo agentOrderBo = new AgentOrderBo();
|
||||
agentOrderBo.setId(agentOrderVo.getId());
|
||||
agentOrderBo.setOrderNum(response.getData());
|
||||
agentOrderBo.setOrderStatus("S1000");
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderService.updateByBo(agentOrderBo);
|
||||
return R.ok("操作成功", agentOrderBo.getSerialNumber());
|
||||
} else {
|
||||
// 订单验证失败
|
||||
log.error("电信订单验证失败");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信订单验证失败", response.getMessage());
|
||||
return R.fail(ERROR_CODE_PARAMS, response.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信请求异常", "");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.fail(ERROR_CODE_NETWORK, "电信网络异常");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("getOrderList")
|
||||
public R<JSONObject> getOrderList(HttpServletRequest request,
|
||||
Integer page, Integer pageSize,
|
||||
String saleId,
|
||||
String name, String contactMobile, String number) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
|
||||
AgentAccountGoodBo agentAccountGoodBo = new AgentAccountGoodBo();
|
||||
agentAccountGoodBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
|
||||
// if (ObjectUtils.isNull(saleId) && ObjectUtils.isNull(name) && ObjectUtils.isNull(contactMobile) && ObjectUtils.isNull(number)) {
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("无saleId");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "无参数", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<AgentOrder> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(AgentOrder::getPersonnelId, agentAccountVo.getPersonnelId());
|
||||
lqw.eq(ObjectUtils.isNotNull(saleId), AgentOrder::getSaleId, saleId);
|
||||
if (ObjectUtils.isNotNull(name)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(name), AgentOrder::getName, sm2.decryptStr(name, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密姓名错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密姓名错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(contactMobile)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(contactMobile), AgentOrder::getContactMobile, sm2.decryptStr(contactMobile, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密联系电话错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密联系电话错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(number)) {
|
||||
try {
|
||||
lqw.eq(ObjectUtils.isNotNull(number), AgentOrder::getNumber, sm2.decryptStr(number, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("解密手机号错误");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "解密手机号错误", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
|
||||
lqw.gt(AgentOrder::getStatus, "-1");
|
||||
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(page);
|
||||
pageQuery.setPageSize(pageSize);
|
||||
TableDataInfo<AgentOrderVo> tableDataInfo = agentOrderService.queryList(lqw, pageQuery);
|
||||
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", tableDataInfo.getTotal());
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
List<JSONObject> objects = new ArrayList<>();
|
||||
|
||||
for (AgentOrderVo vo: tableDataInfo.getRows()) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", vo.getSerialNumber());
|
||||
data.set("name", vo.getName());
|
||||
data.set("contactMobile", vo.getContactMobile());
|
||||
data.set("idCard", vo.getIdCard());
|
||||
data.set("number", vo.getNumber());
|
||||
data.set("status", vo.getStatus());
|
||||
data.set("orderStatus", vo.getOrderStatus());
|
||||
data.set("createTime", vo.getCreateTime());
|
||||
data.set("updateTime", vo.getUpdateTime());
|
||||
data.set("isRecharge", vo.getIsRecharge());
|
||||
data.set("chargeTitle", vo.getChargeTitle());
|
||||
data.set("expressVendor", vo.getExpressVendor());
|
||||
data.set("expressNum", vo.getExpressNum());
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", vo.getSaleId());
|
||||
goods.set("title", vo.getTitle());
|
||||
goods.set("content", vo.getContent());
|
||||
data.set("bookingGoods", goods);
|
||||
|
||||
objects.add(data);
|
||||
}
|
||||
|
||||
resultData.set("objects", sm2.encryptBase64(objects.toString(), KeyType.PublicKey));
|
||||
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getOrderDetail")
|
||||
public R<String> getOrderDetail(HttpServletRequest request, String serialNumber) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(serialNumber)) {
|
||||
log.error("参数错误:serialNumber为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "参数错误:serialNumber为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
AgentOrderBo bo = new AgentOrderBo();
|
||||
bo.setSerialNumber(serialNumber);
|
||||
bo.setAgentId(agentAccountVo.getAgentId());
|
||||
bo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
List<AgentOrderVo> voList = agentOrderService.queryList(bo);
|
||||
if (voList.size() > 0) {
|
||||
AgentOrderVo vo = voList.get(0);
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", vo.getSerialNumber());
|
||||
data.set("name", vo.getName());
|
||||
data.set("contactMobile", vo.getContactMobile());
|
||||
data.set("idCard", vo.getIdCard());
|
||||
data.set("number", vo.getNumber());
|
||||
data.set("status", vo.getStatus());
|
||||
data.set("orderStatus", vo.getStatus());
|
||||
data.set("isRecharge", vo.getIsRecharge());
|
||||
data.set("chargeTitle", vo.getChargeTitle());
|
||||
data.set("expressVendor", vo.getExpressVendor());
|
||||
data.set("expressNum", vo.getExpressNum());
|
||||
data.set("routeArr", JSONUtil.parseArray(vo.getRouteArr()));
|
||||
data.set("expressRoutes", JSONUtil.parseArray(vo.getExpressRoutes()));
|
||||
data.set("createTime", vo.getCreateTime());
|
||||
data.set("updateTime", vo.getUpdateTime());
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", vo.getSaleId());
|
||||
goods.set("title", vo.getTitle());
|
||||
goods.set("content", vo.getContent());
|
||||
data.set("bookingGoods", goods);
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
return R.ok(null, sm2.encryptBase64(data.toString(), KeyType.PublicKey));
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String body = "{\"name\":\"毕彦兵\",\"idCard\":\"230104198809293718\",\"contactNumber\":\"18980692055\",\"installedAddress\":\"世贸大道世贸都柏林49栋3单元2402\",\"gid\":1,\"province\":\"黑龙江\",\"city\":\"哈尔滨\",\"county\":\"松北区\",\"number\":\"19384158592\",\"logiRemark\":\"\",\"pageUrl\":\"\",\"remark\":\"\",}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.ruoyi.common.core.domain.CTResponse;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.ct.domain.AgentAccountGoodUser;
|
||||
import com.ruoyi.ct.domain.bo.AgentAccountGoodBo;
|
||||
import com.ruoyi.ct.domain.bo.AgentAccountGoodUserBo;
|
||||
import com.ruoyi.ct.domain.bo.AgentOrderBo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountGoodUserVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountGoodVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.domain.vo.GoodVo;
|
||||
import com.ruoyi.ct.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("free-api/v1.0.0")
|
||||
public class APIFreeController extends BaseController {
|
||||
@Resource
|
||||
private CTService ctService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountService agentAccountService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountGoodService agentAccountGoodService;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountGoodUserService agentAccountGoodUserService;
|
||||
|
||||
@Resource
|
||||
private IAgentService agentService;
|
||||
|
||||
@Resource
|
||||
private IAgentOrderService agentOrderService;
|
||||
|
||||
@Resource
|
||||
private IGoodService goodService;
|
||||
|
||||
private AgentAccountGoodVo checkCode(String code) {
|
||||
try {
|
||||
byte[] decodedBytes = Base64.getDecoder().decode(code); // 对Base64字符串进行解码得到byte数组
|
||||
code = new String(decodedBytes);
|
||||
String[] codes = code.split(",");
|
||||
String agentAccountGoodId = codes[0];
|
||||
String agentAccountId = codes[1];
|
||||
String goodId = codes[2];
|
||||
log.error("agentAccountGoodId: "+ agentAccountGoodId);
|
||||
log.error("agentAccountId: "+ agentAccountId);
|
||||
log.error("goodId: "+ goodId);
|
||||
|
||||
AgentAccountGoodVo agentAccountGoodVo = agentAccountGoodService.queryById(Long.valueOf(agentAccountGoodId));
|
||||
log.error("agentAccountGoodVo: "+agentAccountGoodVo);
|
||||
log.error("agentAccountId: "+ agentAccountId.equals(agentAccountGoodVo.getAgentAccountId().toString()));
|
||||
log.error("goodId: "+ goodId.equals(agentAccountGoodVo.getGoodId().toString()));
|
||||
if (ObjectUtils.isNotNull(agentAccountGoodVo)
|
||||
&& agentAccountId.equals(agentAccountGoodVo.getAgentAccountId().toString())
|
||||
&& goodId.equals(agentAccountGoodVo.getGoodId().toString())) {
|
||||
return agentAccountGoodVo;
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查有效性,用于H5
|
||||
* @param code base64加密后数据,agentAccountGoodId+agentAccountId+goodId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/check")
|
||||
public R<JSONObject> check(@RequestParam String code) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isNotNull(agentAccountGoodVo)) {
|
||||
JSONObject data = new JSONObject();
|
||||
GoodVo goodVo = goodService.queryById(agentAccountGoodVo.getGoodId());
|
||||
data.set("title", goodVo.getName());
|
||||
data.set("images", agentAccountGoodVo.getImages());
|
||||
data.set("remark", agentAccountGoodVo.getRemark());
|
||||
return R.ok(data);
|
||||
}
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情,用于上传用户信息页面
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
public R<JSONObject> detail(@RequestParam String code, @RequestParam String verifyCode) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isNotEmpty(agentAccountGoodVo) && agentAccountGoodVo.getTmpPassword().equals(verifyCode)) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("registerCount", agentAccountGoodVo.getRegisterCount());
|
||||
data.set("registeredCount", agentAccountGoodVo.getCompleteCount() + agentAccountGoodVo.getWaitCount());
|
||||
data.set("verifyCount", agentAccountGoodVo.getVerifyCount());
|
||||
data.set("verifiedCount", agentAccountGoodVo.getVerifiedCount());
|
||||
return R.ok(data);
|
||||
}
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 号码列表,用于H5
|
||||
* @param request
|
||||
* @param code
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getNumberList")
|
||||
public R<List<JSONObject>> getNumberList(HttpServletRequest request, @RequestParam String code, @RequestParam Integer page, @RequestParam Integer pageSize) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
|
||||
AgentAccountVo agentAccountVo = agentAccountService.queryById(agentAccountGoodVo.getAgentAccountId());
|
||||
try {
|
||||
List<JSONObject> data = ctService.selectNumber(agentAccountVo.getPersonnelId(), agentAccountGoodVo.getSaleId(), String.valueOf(page), String.valueOf(pageSize));
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "", data.toString());
|
||||
return R.ok(data);
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 1, "电信请求异常", "[]");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.ok(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交订单,用于H5
|
||||
* @param request
|
||||
* @param code
|
||||
* @param requestBody
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("confirmOrder")
|
||||
public R<String> confirmOrder(HttpServletRequest request, @RequestParam String code,
|
||||
@RequestBody JSONObject requestBody) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
AgentAccountVo agentAccountVo = agentAccountService.queryById(agentAccountGoodVo.getAgentAccountId());
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderBo agentOrderBo = requestBody.toBean(AgentOrderBo.class);
|
||||
// 填充固定数据
|
||||
agentOrderBo.setAgentName(agentAccountVo.getAgentName());
|
||||
agentOrderBo.setAgentId(agentAccountVo.getAgentId());
|
||||
agentOrderBo.setStoreId("13");
|
||||
agentOrderBo.setSerialNumber(UUID.randomUUID().toString().replace("-", ""));
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
agentOrderBo.setCreateTime(new Date());
|
||||
agentOrderBo.setOrderType(1);
|
||||
{
|
||||
agentOrderBo.setAgentAccountId(agentAccountGoodVo.getId());
|
||||
agentOrderBo.setSaleId(agentAccountGoodVo.getSaleId());
|
||||
GoodVo goodVo = goodService.queryById(agentAccountGoodVo.getGoodId());
|
||||
agentOrderBo.setTitle(goodVo.getName());
|
||||
agentOrderBo.setContent(goodVo.getContent());
|
||||
|
||||
// 校验用户信息,姓名、身份证、手机号
|
||||
if (ObjectUtils.isNull(agentOrderBo.getName())) {
|
||||
log.error("姓名为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "姓名为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getIdCard())) {
|
||||
log.error("身份证号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "身份证号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
if (ObjectUtils.isNull(agentOrderBo.getContactMobile())) {
|
||||
log.error("手机号为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "手机号为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
// 校验地址信息
|
||||
if (ObjectUtils.isNull(agentOrderBo.getProvince())) {
|
||||
log.error("省为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "省为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCity())) {
|
||||
log.error("市为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "市为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCounty())) {
|
||||
log.error("区为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "区为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstalledAddress())) {
|
||||
log.error("地址为空");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "地址为空", null);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstallAddress())) {
|
||||
agentOrderBo.setInstallAddress(agentOrderBo.getInstalledAddress());
|
||||
}
|
||||
|
||||
// 校验数量
|
||||
if (agentAccountGoodVo.getIsNeedVerify() == 1) {
|
||||
Integer registerCount = agentAccountGoodVo.getRegisterCount();
|
||||
Integer completeCount = agentAccountGoodVo.getCompleteCount();
|
||||
Integer waitCount = agentAccountGoodVo.getWaitCount();;
|
||||
Integer verifyCount = agentAccountGoodVo.getVerifyCount();
|
||||
Integer verifiedCount = agentAccountGoodVo.getVerifiedCount();
|
||||
|
||||
if (registerCount > 0 && completeCount+waitCount >= registerCount) {
|
||||
// 申请数量已到达上限
|
||||
return R.fail(ERROR_CODE_VERIFY, "该推广码下单数量已到达上限");
|
||||
}
|
||||
if (verifyCount > 0) {
|
||||
if (verifiedCount >= verifyCount) {
|
||||
// 使用录入人员信息的数量已到达上限
|
||||
return R.fail(ERROR_CODE_VERIFY, "该推广码下单数量已到达上限");
|
||||
}
|
||||
AgentAccountGoodUserBo agentAccountGoodUserBo = new AgentAccountGoodUserBo();
|
||||
agentAccountGoodUserBo.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
agentAccountGoodUserBo.setName(agentOrderBo.getName());
|
||||
agentAccountGoodUserBo.setMobile(agentOrderBo.getContactMobile());
|
||||
agentAccountGoodUserBo.setIdCardNo(agentOrderBo.getIdCard());
|
||||
int c = agentAccountGoodUserService.queryList(agentAccountGoodUserBo).size();
|
||||
if (c == 0) {
|
||||
// 人员不在名单范围内
|
||||
return R.fail(ERROR_CODE_VERIFY, "非授权用户");
|
||||
}
|
||||
AgentAccountGoodBo agentAccountGoodBo = new AgentAccountGoodBo();
|
||||
agentAccountGoodBo.setVerifiedCount(agentAccountGoodVo.getVerifiedCount() + 1);
|
||||
agentAccountGoodBo.setWaitCount(agentAccountGoodVo.getWaitCount() + 1);
|
||||
agentAccountGoodBo.setId(agentAccountGoodVo.getId());
|
||||
agentAccountGoodService.updateByBo(agentAccountGoodBo);
|
||||
}
|
||||
}
|
||||
// 保存数据
|
||||
try {
|
||||
CTResponse<String> response = ctService.saveOrder(agentOrderBo.getName(), agentOrderBo.getIdCard(), agentOrderBo.getContactMobile(),
|
||||
agentOrderBo.getInstalledAddress(), agentOrderBo.getSaleId(), agentOrderBo.getStoreId(),
|
||||
agentOrderBo.getPersonnelId(), agentOrderBo.getProvince(), agentOrderBo.getCity(),
|
||||
agentOrderBo.getCounty(), agentOrderBo.getSerialNumber(), agentOrderBo.getNumber(),
|
||||
agentOrderBo.getLogiRemark(), agentOrderBo.getPageUrl(), agentOrderBo.getRemark(),
|
||||
agentOrderBo.getInstallAddress(), "", "");
|
||||
if (response.isSuccess()) {
|
||||
agentOrderBo.setOrderNum(response.getData());
|
||||
agentOrderBo.setOrderStatus("S1000");
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderService.insertByBo(agentOrderBo);
|
||||
return R.ok("操作成功", agentOrderBo.getSerialNumber());
|
||||
} else {
|
||||
// 订单验证失败
|
||||
log.error("电信订单验证失败");
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信订单验证失败", response.getMessage());
|
||||
return R.fail(ERROR_CODE_PARAMS, response.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveLog(request, agentAccountVo.getPersonnelId(), 0, "电信请求异常", "");
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.fail(ERROR_CODE_NETWORK, "电信网络异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getUserList")
|
||||
public R<TableDataInfo<AgentAccountGoodUserVo>> getUserList(HttpServletRequest request,
|
||||
@RequestParam String code,
|
||||
@RequestParam String verifyCode,
|
||||
@RequestParam Integer page,
|
||||
@RequestParam Integer pageSize) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo) || !agentAccountGoodVo.getTmpPassword().equals(verifyCode)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
AgentAccountGoodUserBo bo = new AgentAccountGoodUserBo();
|
||||
bo.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageSize(pageSize);
|
||||
pageQuery.setPageNum(page);
|
||||
TableDataInfo<AgentAccountGoodUserVo> tableDataInfo = agentAccountGoodUserService.queryPageList(bo, pageQuery);
|
||||
return R.ok(tableDataInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/saveUser")
|
||||
public R<Void> saveUser(HttpServletRequest request, @RequestParam String code,
|
||||
@RequestParam String verifyCode, @RequestBody AgentAccountGoodUserBo agentAccountGoodUserBo) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo) || !agentAccountGoodVo.getTmpPassword().equals(verifyCode)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
AgentAccountGoodUserBo bo = new AgentAccountGoodUserBo();
|
||||
bo.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
int c = agentAccountGoodUserService.queryList(bo).size();
|
||||
if (c >= agentAccountGoodVo.getVerifyCount()) {
|
||||
return R.fail(ERROR_CODE_VERIFY, "授权人员名单已达上限");
|
||||
}
|
||||
agentAccountGoodUserBo.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
|
||||
c = agentAccountGoodUserService.queryList(agentAccountGoodUserBo).size();
|
||||
if (c > 0) {
|
||||
return R.fail(ERROR_CODE_VERIFY, "该用户已存在");
|
||||
}
|
||||
|
||||
agentAccountGoodUserBo.setCreateTime(new Date());
|
||||
agentAccountGoodUserService.insertByBo(agentAccountGoodUserBo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/updateUser")
|
||||
public R<Void> updateUser(HttpServletRequest request, @RequestParam String code,
|
||||
@RequestParam String verifyCode, @RequestBody AgentAccountGoodUserBo agentAccountGoodUserBo) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo) || !agentAccountGoodVo.getTmpPassword().equals(verifyCode)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
agentAccountGoodUserBo.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
agentAccountGoodUserService.updateByBo(agentAccountGoodUserBo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/removeUser")
|
||||
public R<Void> removeUser(HttpServletRequest request, @RequestParam String code,
|
||||
@RequestParam String verifyCode,
|
||||
@RequestParam Long id) {
|
||||
AgentAccountGoodVo agentAccountGoodVo = checkCode(code);
|
||||
if (ObjectUtils.isEmpty(agentAccountGoodVo) || !agentAccountGoodVo.getTmpPassword().equals(verifyCode)) {
|
||||
return R.fail(CODE_ERROR, "活动不存在");
|
||||
}
|
||||
AgentAccountGoodUser agentAccountGoodUser = new AgentAccountGoodUser();
|
||||
agentAccountGoodUser.setId(id);
|
||||
agentAccountGoodUser.setAgentAccountGoodId(agentAccountGoodVo.getId());
|
||||
agentAccountGoodUserService.deleteByBo(agentAccountGoodUser);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.ct.domain.AgentOrder;
|
||||
import com.ruoyi.ct.domain.bo.AgentOrderBo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountGoodVo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.service.CTService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.ruoyi.api.controller.BaseController.ERROR_CODE_VERIFY;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/test/v1.0.0")
|
||||
@Slf4j
|
||||
public class APITestController extends BaseTestController {
|
||||
@Resource
|
||||
private CTService ctService;
|
||||
|
||||
@GetMapping("getGoodsList")
|
||||
public R<JSONObject> getGoodsList(HttpServletRequest request, Integer page, Integer pageSize) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", 2);
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
resultData.set("objects", JSONUtil.parseArray("[{\"saleId\":\"108002\",\"title\":\"49套餐\",\"content\":\"大概的介绍\"},{\"saleId\":\"107657\",\"title\":\"59套餐\"}]"));
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getNumberList")
|
||||
public R<List<JSONObject>> getNumberList(HttpServletRequest request, Integer page, Integer pageSize, String saleId) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(saleId) || !SALE_ID.equals(saleId)) {
|
||||
log.error("参数错误");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
try {
|
||||
List<JSONObject> data = ctService.selectNumber(agentAccountVo.getPersonnelId(), SALE_ID,
|
||||
String.valueOf(page), String.valueOf(pageSize));
|
||||
return R.ok(data);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
return R.ok(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("confirmOrder")
|
||||
public R<String> confirmOrder(HttpServletRequest request, @RequestBody String body) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
try {
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
body = sm2.decryptStr(body, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("数据解密错误");
|
||||
return R.fail(ERROR_CODE_ENCRYPT, "数据解密错误");
|
||||
}
|
||||
|
||||
JSONObject requestBody = JSONUtil.parseObj(body);
|
||||
System.out.println("requestBody = " + requestBody);
|
||||
AgentOrderBo agentOrderBo = requestBody.toBean(AgentOrderBo.class);
|
||||
// 填充固定数据
|
||||
agentOrderBo.setAgentName(agentAccountVo.getAgentName());
|
||||
agentOrderBo.setAgentId(agentAccountVo.getAgentId());
|
||||
agentOrderBo.setStoreId("13");
|
||||
agentOrderBo.setSerialNumber(UUID.randomUUID().toString().replace("-", ""));
|
||||
agentOrderBo.setStatus("0");
|
||||
agentOrderBo.setPersonnelId(agentAccountVo.getPersonnelId());
|
||||
agentOrderBo.setCreateTime(new Date());
|
||||
AgentAccountGoodVo agentAccountGoodVo;
|
||||
{
|
||||
// 校验数据
|
||||
// 校验gid
|
||||
String saleId = requestBody.getStr("saleId");
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("saleId为空");
|
||||
System.out.println("saleId为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
try {
|
||||
|
||||
if (ObjectUtils.isNull(saleId) || !SALE_ID.equals(saleId)) {
|
||||
log.error("saleId无效");
|
||||
System.out.println("saleId无效");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("saleId格式错误");
|
||||
System.out.println("saleId格式错误");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
// 校验用户信息,姓名、身份证、手机号
|
||||
if (ObjectUtils.isNull(agentOrderBo.getName())) {
|
||||
log.error("姓名为空");
|
||||
System.out.println("姓名为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getIdCard())) {
|
||||
log.error("身份证号为空");
|
||||
System.out.println("身份证号为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getContactMobile())) {
|
||||
log.error("手机号为空");
|
||||
System.out.println("手机号为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
// 校验地址信息
|
||||
if (ObjectUtils.isNull(agentOrderBo.getProvince())) {
|
||||
log.error("省为空");
|
||||
System.out.println("省为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCity())) {
|
||||
log.error("市为空");
|
||||
System.out.println("市为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getCounty())) {
|
||||
log.error("区为空");
|
||||
System.out.println("区为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstalledAddress())) {
|
||||
log.error("地址为空");
|
||||
System.out.println("地址为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
if (ObjectUtils.isNull(agentOrderBo.getInstallAddress())) {
|
||||
agentOrderBo.setInstallAddress(agentOrderBo.getInstalledAddress());
|
||||
}
|
||||
// todo 根据代理商提供的验证url验证用户
|
||||
String url = requestBody.getStr("url");
|
||||
if (ObjectUtils.isNotNull("url")) {
|
||||
JSONObject paramMap = new JSONObject();
|
||||
paramMap.set("name", agentOrderBo.getName());
|
||||
paramMap.set("idCard", agentOrderBo.getIdCard());
|
||||
paramMap.set("contactMobile", agentOrderBo.getContactMobile());
|
||||
try {
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
String verifyResult = HttpUtil.post(url, sm2.encryptBase64(paramMap.toString(), KeyType.PublicKey));
|
||||
JSONObject verifyData = JSONUtil.parseObj(verifyResult);
|
||||
if (verifyData.getInt("code") != 200) {
|
||||
log.error("验证不通过");
|
||||
System.out.println("验证不通过");
|
||||
return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("验证请求错误");
|
||||
System.out.println("验证请求错误");
|
||||
return R.fail(ERROR_CODE_VERIFY, "验证错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok("操作成功", UUID.randomUUID().toString().replace("-", ""));
|
||||
}
|
||||
|
||||
@GetMapping("getOrderList")
|
||||
public R<JSONObject> getOrderList(HttpServletRequest request,
|
||||
Integer page, Integer pageSize,
|
||||
String saleId,
|
||||
String name, String contactMobile, String number) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
System.out.println("saleId = " + saleId);
|
||||
System.out.println("name = " + name);
|
||||
System.out.println("contactMobile = " + contactMobile);
|
||||
System.out.println("number = " + number);
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (page == null || page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
if (pageSize == null || pageSize < 1 || pageSize > 50) {
|
||||
pageSize = 20;
|
||||
}
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
|
||||
// if (ObjectUtils.isNull(saleId) && ObjectUtils.isNull(name) && ObjectUtils.isNull(contactMobile) && ObjectUtils.isNull(number)) {
|
||||
if (ObjectUtils.isNull(saleId)) {
|
||||
log.error("参数错误");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<AgentOrder> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(AgentOrder::getPersonnelId, agentAccountVo.getPersonnelId());
|
||||
lqw.eq(ObjectUtils.isNotNull(saleId), AgentOrder::getSaleId, saleId);
|
||||
if (ObjectUtils.isNotNull(name)) {
|
||||
try {
|
||||
System.out.println("name = " + sm2.decryptStr(name, KeyType.PrivateKey));
|
||||
lqw.eq(ObjectUtils.isNotNull(name), AgentOrder::getName, sm2.decryptStr(name, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("参数错误");
|
||||
System.out.println("name = " + name);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(contactMobile)) {
|
||||
try {
|
||||
System.out.println("contactMobile = " + sm2.decryptStr(contactMobile, KeyType.PrivateKey));
|
||||
lqw.eq(ObjectUtils.isNotNull(contactMobile), AgentOrder::getContactMobile, sm2.decryptStr(contactMobile, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
log.error("参数错误");
|
||||
System.out.println("contactMobile = " + contactMobile);
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
if (ObjectUtils.isNotNull(number)) {
|
||||
try {
|
||||
System.out.println("number = " + sm2.decryptStr(number, KeyType.PrivateKey));
|
||||
lqw.eq(ObjectUtils.isNotNull(number), AgentOrder::getNumber, sm2.decryptStr(number, KeyType.PrivateKey));
|
||||
} catch (Exception e) {
|
||||
System.out.println("number = " + number);
|
||||
log.error("参数错误");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JSONObject resultData = new JSONObject();
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.set("total", 1);
|
||||
meta.set("page", page);
|
||||
meta.set("pageSize", pageSize);
|
||||
resultData.set("meta", meta);
|
||||
List<JSONObject> objects = new ArrayList<>();
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", UUID.randomUUID().toString().replace("-", ""));
|
||||
data.set("name", "李白");
|
||||
data.set("contactMobile", "18900001234");
|
||||
data.set("idCard", "310101200001011234");
|
||||
data.set("number", "19112341234");
|
||||
data.set("status", 0);
|
||||
data.set("orderStatus", "S1005");
|
||||
data.set("createTime", "2023-12-31 00:00:00");
|
||||
data.set("updateTime", "2023-12-31 00:00:00");
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", SALE_ID);
|
||||
goods.set("title", "49套餐");
|
||||
goods.set("content", "49套餐");
|
||||
data.set("bookingGoods", goods);
|
||||
|
||||
objects.add(data);
|
||||
|
||||
resultData.set("objects", sm2.encryptBase64(objects.toString(), KeyType.PublicKey));
|
||||
return R.ok(resultData);
|
||||
}
|
||||
|
||||
@GetMapping("getOrderDetail")
|
||||
public R<String> getOrderList(HttpServletRequest request, String serialNumber) {
|
||||
if (!checkAccount(request)) {
|
||||
return R.fail(ERROR_CODE_LOGIN, request.getAttribute("msg").toString());
|
||||
}
|
||||
AgentAccountVo agentAccountVo = (AgentAccountVo) request.getAttribute("agentAccount");
|
||||
if (ObjectUtils.isNull(serialNumber)) {
|
||||
log.error("参数错误:serialNumber为空");
|
||||
return R.fail(ERROR_CODE_PARAMS, "参数错误");
|
||||
}
|
||||
JSONObject data = new JSONObject();
|
||||
data.set("serialNumber", UUID.randomUUID().toString().replace("-", ""));
|
||||
data.set("name", "李白");
|
||||
data.set("contactMobile", "18900001234");
|
||||
data.set("idCard", "310101200001011234");
|
||||
data.set("number", "19112341234");
|
||||
data.set("status", 1);
|
||||
data.set("orderStatus", "S1013");
|
||||
data.set("createTime", "2023-12-31 00:00:00");
|
||||
data.set("updateTime", "2023-12-31 00:00:00");
|
||||
JSONObject goods = new JSONObject();
|
||||
goods.set("saleId", SALE_ID);
|
||||
goods.set("title", "49套餐");
|
||||
goods.set("content", "49套餐");
|
||||
data.set("bookingGoods", goods);
|
||||
data.set("expressNum", "SF001");
|
||||
data.set("routeArr", JSONUtil.parseArray("[{\"fRouteTime\":\"2019-11-23 16:11:45\",\"fStatusName\":\"已提交\",\"fStatusId\":\"S1000\"},{\"fRouteTime\":\"2019-11-23 16:11:50\",\"fStatusName\":\"S1050\",\"fStatusId\":\"S1050\"},{\"fRouteTime\":\"2019-11-23 16:11:56\",\"fStatusName\":\"S105001\",\"fStatusId\":\"S105001\"},{\"fRouteTime\":\"2019-11-23 16:11:57\",\"fStatusName\":\"S100501\",\"fStatusId\":\"S100501\"},{\"fRouteTime\":\"2019-11-23 16:12:19\",\"fStatusName\":\"S100531\",\"fStatusId\":\"S100531\"},{\"fRouteTime\":\"2019-11-23 16:12:21\",\"fStatusName\":\"S100506\",\"fStatusId\":\"S100506\"},{\"fRouteTime\":\"2019-11-24 17:05:01\",\"fStatusName\":\"S100532\",\"fStatusId\":\"S100532\"},{\"fRouteTime\":\"2019-11-25 16:08:12\",\"fStatusName\":\"S1006\",\"fStatusId\":\"S1006\"},{\"fRouteTime\":\"2019-11-25 16:08:12\",\"fStatusName\":\"S101301\",\"fStatusId\":\"S101301\"}]"));
|
||||
data.set("expressRoutes", JSONUtil.parseArray("[{\"updateDate\":\"2019-11-25 16:06:49\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100030\",\"remark\":\"订单提交补录 ICCID/串码:89811111111111;成功;\",\"createStaff\":165124796390,\"logiOrderId\":12444255,\"logiOrderFlowId\":13119474,\"dversion\":0,\"createDate\":\"2019-11-25 16:06:41\"},{\"updateDate\":\"2019-11-25 08:30:17\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100030\",\"remark\":\"预约再送-快递员:张三,电话:13333333333,预约您 2019-11-25 09 时, 再次为您配送快件! \",\"logiOrderId\":12444255,\"logiOrderFlowId\":12973108,\"createDate\":\"2019-11-25 08:29:34\"},{\"updateDate\":\"2019-11-25 08:30:17\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100030\",\"remark\":\"已派送-正在派送途中,将由快递员:张三,电话:13333333333送达, 请您准备签收。 \",\"logiOrderId\":12444255,\"logiOrderFlowId\":12973111,\"createDate\":\"2019-11-25 08:27:24\"},{\"updateDate\":\"2019-11-24 17:04:59\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100029\",\"remark\":\"快件已入库-您的快件正在运送中,已转至商海德中心仓库。\",\"logiOrderId\":12444255,\"logiOrderFlowId\":12796420,\"createDate\":\"2019-11-24 16:49:39\"},{\"updateDate\":\"2019-11-24 17:04:59\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100002\",\"remark\":\"已收件-您的快件已收取成功,我们将尽快为你派送!\",\"logiOrderId\":12444255,\"logiOrderFlowId\":12796421,\"createDate\":\"2019-11-24 16:46:22\"},{\"updateDate\":\"2019-11-24 16:34:17\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100004\",\"remark\":\"打包录入 ICCID/串码:89811111111111;成功;\",\"createStaff\":164294780591,\"logiOrderId\":12444255,\"logiOrderFlowId\":12802391,\"dversion\":0,\"createDate\":\"2019-11-24 16:34:16\"},{\"updateDate\":\"2019-11-24 17:04:59\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100010\",\"remark\":\"待取件\",\"logiOrderId\":12444255,\"logiOrderFlowId\":12796422,\"createDate\":\"2019-11-24 16:10:12\"},{\"updateDate\":\"2019-11-24 16:10:11\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100014\",\"remark\":\"物流单分发成功\",\"logiOrderId\":12444255,\"logiOrderFlowId\":12767190,\"dversion\":0,\"createDate\":\"2019-11-24 16:10:11\"},{\"updateDate\":\"2019-11-24 16:05:54\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100021\",\"createStaff\":115060634224,\"logiOrderId\":12444255,\"logiOrderFlowId\":12793430,\"dversion\":0,\"createDate\":\"2019-11-24 16:05:54\"},{\"updateDate\":\"2019-11-24 13:46:54\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100015\",\"remark\":\"派送通知\",\"logiOrderId\":12444255,\"logiOrderFlowId\":12749286,\"dversion\":0,\"createDate\":\"2019-11-24 13:46:54\"},{\"updateDate\":\"2019-11-23 16:12:02\",\"sourceLogiOrderId\":12444255,\"statusCd\":\"100005\",\"createStaff\":236240021834,\"logiOrderId\":12444255,\"logiOrderFlowId\":12444272,\"dversion\":0,\"createDate\":\"2019-11-23 16:12:02\"}]"));
|
||||
SM2 sm2 = (SM2) request.getAttribute("sm2");
|
||||
return R.ok(null, sm2.encryptBase64(data.toString(), KeyType.PublicKey));
|
||||
}
|
||||
}
|
||||
165
api/src/main/java/com/ruoyi/api/controller/BaseController.java
Normal file
165
api/src/main/java/com/ruoyi/api/controller/BaseController.java
Normal file
@@ -0,0 +1,165 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.ct.domain.ApiLog;
|
||||
import com.ruoyi.ct.domain.bo.ApiLogBo;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.service.IAgentAccountService;
|
||||
import com.ruoyi.ct.service.IApiLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@Slf4j
|
||||
public class BaseController {
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public final static Integer SUCCESS_CODE = 200;
|
||||
/**
|
||||
* 地址错误
|
||||
*/
|
||||
public final static Integer NOT_FOUND_CODE = 404;
|
||||
/**
|
||||
* 服务器异常
|
||||
*/
|
||||
public final static Integer ERROR_SYSTEM_CODE = 500;
|
||||
/**
|
||||
* AppId 或 AppSecret错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_LOGIN = 1000;
|
||||
/**
|
||||
* 参数错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_PARAMS = 1001;
|
||||
/**
|
||||
* 解密错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_ENCRYPT = 1002;
|
||||
/**
|
||||
* 电信网络异常
|
||||
*/
|
||||
public final static Integer ERROR_CODE_NETWORK = 1003;
|
||||
/**
|
||||
* 验证错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_VERIFY = 1004;
|
||||
|
||||
/**
|
||||
* H5验证错误
|
||||
*/
|
||||
public final static Integer CODE_ERROR = 1005;
|
||||
|
||||
@Resource
|
||||
private IAgentAccountService iAgentAccountService;
|
||||
|
||||
@Resource
|
||||
private IApiLogService apiLogService;
|
||||
|
||||
public boolean checkAccount(HttpServletRequest httpRequest) {
|
||||
String appId = httpRequest.getHeader("x-ct-appid");
|
||||
String appPwd = httpRequest.getHeader("x-ct-pwd");
|
||||
System.out.println("appPwd = " + appPwd);
|
||||
System.out.println("appId = " + appId);
|
||||
if (ObjectUtils.isNull(appId) || ObjectUtils.isNull(appPwd)) {
|
||||
log.error("账号或密码为空");
|
||||
httpRequest.setAttribute("msg", "账号或密码为空");
|
||||
saveLog(httpRequest, null, 0, "账号或密码为空", null);
|
||||
return false;
|
||||
}
|
||||
AgentAccountVo agentAccountVo = iAgentAccountService.getByAppId(appId);
|
||||
|
||||
System.out.println("agentAccountVo = " + agentAccountVo);
|
||||
if (ObjectUtils.isNull(agentAccountVo)) {
|
||||
log.error("账号错误");
|
||||
httpRequest.setAttribute("msg", "账号错误");
|
||||
saveLog(httpRequest, agentAccountVo.getPersonnelId(), 0, "账号错误", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
String ip = StringUtils.blankToDefault(httpRequest.getHeader("x-real-ip"), httpRequest.getRemoteAddr());
|
||||
if (ObjectUtils.isNotNull(agentAccountVo.getIpList())) {
|
||||
boolean isWhite = agentAccountVo.getIpList().contains(ip);
|
||||
if (!isWhite) {
|
||||
log.error("IP 不在白名单");
|
||||
httpRequest.setAttribute("msg", "IP 不在白名单");
|
||||
saveLog(httpRequest, agentAccountVo.getPersonnelId(), 0, "IP 不在白名单", null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SM2 sm2 = SmUtil.sm2(agentAccountVo.getAgentPrivateKey(), agentAccountVo.getPlatformPublicKey());
|
||||
httpRequest.setAttribute("sm2", sm2);
|
||||
String pwd;
|
||||
try {
|
||||
pwd = sm2.decryptStr(appPwd, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("解密错误");
|
||||
httpRequest.setAttribute("msg", "解密错误");
|
||||
saveLog(httpRequest, agentAccountVo.getPersonnelId(), 0, "解密错误", null);
|
||||
return false;
|
||||
}
|
||||
if (pwd.equals(agentAccountVo.getAppSecret())) {
|
||||
httpRequest.setAttribute("agentAccount", agentAccountVo);
|
||||
return true;
|
||||
}
|
||||
log.error("密码错误");
|
||||
httpRequest.setAttribute("msg", "密码错误");
|
||||
saveLog(httpRequest, agentAccountVo.getPersonnelId(), 0, "密码错误", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void saveLog(HttpServletRequest httpRequest, String personnelId, int isSuccess, String msg, String res) {
|
||||
ApiLogBo apiLog = new ApiLogBo();
|
||||
apiLog.setIp(StringUtils.blankToDefault(httpRequest.getHeader("x-real-ip"), httpRequest.getRemoteAddr()));
|
||||
apiLog.setUrl(httpRequest.getRequestURL().toString());
|
||||
System.out.println("httpRequest.getMethod() = " + httpRequest.getMethod());
|
||||
if (httpRequest.getMethod().equals("POST")) {
|
||||
try {
|
||||
InputStream inputStream = httpRequest.getInputStream();
|
||||
// 将输入流转换为字符串
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
stringBuilder.append(line);
|
||||
}
|
||||
String requestBody = stringBuilder.toString();
|
||||
apiLog.setRequestBody(requestBody);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
apiLog.setRequestBody(httpRequest.getQueryString());
|
||||
}
|
||||
JSONObject header = new JSONObject();
|
||||
Enumeration<String> headerKeys = httpRequest.getHeaderNames();
|
||||
while (headerKeys.hasMoreElements()) {
|
||||
String key = headerKeys.nextElement();
|
||||
header.put(key, httpRequest.getHeader(key));
|
||||
}
|
||||
apiLog.setRequestHeader(header.toString());
|
||||
apiLog.setPersonnelId(personnelId);
|
||||
apiLog.setIsSuccess(Long.valueOf(isSuccess));
|
||||
apiLog.setErrorMsg(msg);
|
||||
apiLog.setResponse(res);
|
||||
Date now = new Date();
|
||||
apiLog.setCreateTime(now);
|
||||
apiLog.setCreateBy(String.valueOf(now.getTime()));
|
||||
apiLogService.insertByBo(apiLog);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import cn.hutool.crypto.SmUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.ruoyi.ct.domain.vo.AgentAccountVo;
|
||||
import com.ruoyi.ct.service.IAgentAccountService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@Slf4j
|
||||
public class BaseTestController {
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public final static Integer SUCCESS_CODE = 200;
|
||||
/**
|
||||
* 地址错误
|
||||
*/
|
||||
public final static Integer NOT_FOUND_CODE = 404;
|
||||
/**
|
||||
* 服务器异常
|
||||
*/
|
||||
public final static Integer ERROR_SYSTEM_CODE = 500;
|
||||
/**
|
||||
* AppId 或 AppSecret错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_LOGIN = 1000;
|
||||
/**
|
||||
* 参数错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_PARAMS = 1001;
|
||||
/**
|
||||
* 解密错误
|
||||
*/
|
||||
public final static Integer ERROR_CODE_ENCRYPT = 1002;
|
||||
/**
|
||||
* 电信网络异常
|
||||
*/
|
||||
public final static Integer ERROR_CODE_NETWORK = 1003;
|
||||
|
||||
public final static String APP_ID = "02a42036-fe1f-4ef1-945a-08660a946b38";
|
||||
public final static String APP_SECRET = "ff2b4dd8-5843-475d-ac4e-c41bb77537fc";
|
||||
public final static String PLATFORM_PUBLIC_KEY = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAETyWQQ6VYQkbeW5ELmFFr/U/DAJGocNEd3hunFm4EoRHZD1MZcyqlCR/p/6ICmwZWYTAK3dz96Nabxi6yGOSkCQ==";
|
||||
public final static String PLATFORM_PRIVATE_KEY = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQg006Jj+5NK9HrtnyXNpnb131jV/8CHeo5t2T74WliktCgCgYIKoEcz1UBgi2hRANCAARPJZBDpVhCRt5bkQuYUWv9T8MAkahw0R3eG6cWbgShEdkPUxlzKqUJH+n/ogKbBlZhMArd3P3o1pvGLrIY5KQJ";
|
||||
public final static String AGENT_PUBLIC_KEY = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEZRdaHuSCG8U87+Cmh9LKbgC+DRBEwWpAyN31aCzoE1flWonnZezX2GqbvDdz7a0AxE6+FGEH1lxPYW39XhYupw==";
|
||||
public final static String AGENT_PRIVATE_KEY = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgTjIdgyVigyoyE86vsR+XshZ3c+shTCFO2hgNQpF+HT6gCgYIKoEcz1UBgi2hRANCAARlF1oe5IIbxTzv4KaH0spuAL4NEETBakDI3fVoLOgTV+Vaiedl7NfYapu8N3PtrQDETr4UYQfWXE9hbf1eFi6n";
|
||||
public final static String PERSONNEL_ID = "207202";
|
||||
|
||||
public final static String SALE_ID = "108002";
|
||||
|
||||
@Resource
|
||||
private IAgentAccountService iAgentAccountService;
|
||||
|
||||
public boolean checkAccount(HttpServletRequest httpRequest) {
|
||||
String appId = httpRequest.getHeader("x-ct-appid");
|
||||
String appPwd = httpRequest.getHeader("x-ct-pwd");
|
||||
|
||||
if (ObjectUtils.isNull(appId) || ObjectUtils.isNull(appPwd)) {
|
||||
log.error("账号或密码为空");
|
||||
httpRequest.setAttribute("msg", "账号或密码为空");
|
||||
return false;
|
||||
}
|
||||
AgentAccountVo agentAccountVo = iAgentAccountService.getByAppId(appId);
|
||||
if (ObjectUtils.isNull(agentAccountVo)) {
|
||||
log.error("账号错误");
|
||||
httpRequest.setAttribute("msg", "账号错误");
|
||||
return false;
|
||||
}
|
||||
System.out.println("agentAccountVo = " + agentAccountVo);
|
||||
System.out.println("PLATFORM_PUBLIC_KEY:"+PLATFORM_PUBLIC_KEY);
|
||||
System.out.println("AGENT_PRIVATE_KEY:"+AGENT_PRIVATE_KEY);
|
||||
SM2 sm2 = SmUtil.sm2(AGENT_PRIVATE_KEY, PLATFORM_PUBLIC_KEY);
|
||||
httpRequest.setAttribute("sm2", sm2);
|
||||
String pwd;
|
||||
try {
|
||||
pwd = sm2.decryptStr(appPwd, KeyType.PrivateKey);
|
||||
} catch (Exception e) {
|
||||
log.error("解密错误");
|
||||
httpRequest.setAttribute("msg", "解密错误");
|
||||
return false;
|
||||
}
|
||||
if (pwd.equals(agentAccountVo.getAppSecret())) {
|
||||
httpRequest.setAttribute("agentAccount", agentAccountVo);
|
||||
return true;
|
||||
}
|
||||
log.error("密码错误");
|
||||
httpRequest.setAttribute("msg", "密码错误");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
30
api/src/main/java/com/ruoyi/api/filter/APIFilter.java
Normal file
30
api/src/main/java/com/ruoyi/api/filter/APIFilter.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.api.filter;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class APIFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
System.out.println("过滤所有Controller之前");
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
|
||||
System.out.println("RequestURL=" + httpRequest.getRequestURL());
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
System.out.println("过滤所有Controller之后");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
Filter.super.init(filterConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
Filter.super.destroy();
|
||||
}
|
||||
}
|
||||
155
api/src/main/resources/application-dev.yml
Normal file
155
api/src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,155 @@
|
||||
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: true
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://43.140.198.163:3380/ct?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: qaHljgd123.
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username:
|
||||
password:
|
||||
# oracle:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: oracle.jdbc.OracleDriver
|
||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
||||
# username: ROOT
|
||||
# password: root
|
||||
# hikari:
|
||||
# connectionTestQuery: SELECT 1 FROM DUAL
|
||||
# postgres:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
# username: root
|
||||
# password: root
|
||||
# sqlserver:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
||||
# username: SA
|
||||
# password: root
|
||||
hikari:
|
||||
# 最大连接池数量
|
||||
maxPoolSize: 20
|
||||
# 最小空闲线程数量
|
||||
minIdle: 10
|
||||
# 配置获取连接等待超时的时间
|
||||
connectionTimeout: 30000
|
||||
# 校验超时时间
|
||||
validationTimeout: 5000
|
||||
# 空闲连接存活最大时间,默认10分钟
|
||||
idleTimeout: 600000
|
||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||
maxLifetime: 1800000
|
||||
# 连接测试query(配置检测连接是否有效)
|
||||
connectionTestQuery: SELECT 1
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: 43.140.198.163
|
||||
# 端口,默认为6379
|
||||
port: 3612
|
||||
# 数据库索引
|
||||
database: 4
|
||||
# 密码(如没有密码请注释掉)
|
||||
password: qaRedisPass123.
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 8
|
||||
# 连接池大小
|
||||
connectionPoolSize: 32
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
--- # mail 邮件发送
|
||||
mail:
|
||||
enabled: false
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
# 是否需要用户名密码验证
|
||||
auth: true
|
||||
# 发送方,遵循RFC-822标准
|
||||
from: xxx@163.com
|
||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
||||
user: xxx@163.com
|
||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置密码,详情查看相关帮助)
|
||||
pass: xxxxxxxxxx
|
||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
||||
starttlsEnable: true
|
||||
# 使用SSL安全连接
|
||||
sslEnable: true
|
||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
||||
timeout: 0
|
||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
||||
connectionTimeout: 0
|
||||
|
||||
--- # sms 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
|
||||
# https://wind.kim/doc/start 文档地址 各个厂商可同时使用
|
||||
sms:
|
||||
# 阿里云 dysmsapi.aliyuncs.com
|
||||
alibaba:
|
||||
#请求地址 默认为 dysmsapi.aliyuncs.com 如无特殊改变可以不用设置
|
||||
requestUrl: dysmsapi.aliyuncs.com
|
||||
#阿里云的accessKey
|
||||
accessKeyId: xxxxxxx
|
||||
#阿里云的accessKeySecret
|
||||
accessKeySecret: xxxxxxx
|
||||
#短信签名
|
||||
signature: 测试
|
||||
tencent:
|
||||
#请求地址默认为 sms.tencentcloudapi.com 如无特殊改变可不用设置
|
||||
requestUrl: sms.tencentcloudapi.com
|
||||
#腾讯云的accessKey
|
||||
accessKeyId: xxxxxxx
|
||||
#腾讯云的accessKeySecret
|
||||
accessKeySecret: xxxxxxx
|
||||
#短信签名
|
||||
signature: 测试
|
||||
#短信sdkAppId
|
||||
sdkAppId: appid
|
||||
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
|
||||
territory: ap-guangzhou
|
||||
189
api/src/main/resources/application-prod.yml
Normal file
189
api/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,189 @@
|
||||
--- # 临时文件存储位置 避免临时文件被系统清理报错
|
||||
spring.servlet.multipart.location: /ruoyi/server/temp
|
||||
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
--- # xxl-job 配置
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: false
|
||||
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
|
||||
admin-addresses: http://localhost:9100/xxl-job-admin
|
||||
# 执行器通讯TOKEN:非空时启用
|
||||
access-token: xxl-job
|
||||
executor:
|
||||
# 执行器AppName:执行器心跳注册分组依据;为空则关闭自动注册
|
||||
appname: xxl-job-executor
|
||||
# 28080 端口 随着主应用端口飘逸 避免集群冲突
|
||||
port: 2${server.port}
|
||||
# 执行器注册:默认IP:PORT
|
||||
address:
|
||||
# 执行器IP:默认自动获取IP
|
||||
ip:
|
||||
# 执行器运行日志文件存储磁盘路径
|
||||
logpath: ./logs/xxl-job
|
||||
# 执行器日志文件保存天数:大于3生效
|
||||
logretentiondays: 30
|
||||
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
# 动态数据源文档 https://www.kancloud.cn/tracy5546/dynamic-datasource/content
|
||||
dynamic:
|
||||
# 性能分析插件(有性能损耗 不建议生产环境使用)
|
||||
p6spy: false
|
||||
# 设置默认的数据源或者数据源组,默认值即为 master
|
||||
primary: master
|
||||
# 严格模式 匹配不到数据源则报错
|
||||
strict: true
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://127.0.0.1/ct?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username: ct
|
||||
password: K4edKweSkFKMPk68
|
||||
# 从库数据源
|
||||
slave:
|
||||
lazy: true
|
||||
type: ${spring.datasource.type}
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
|
||||
username:
|
||||
password:
|
||||
# oracle:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: oracle.jdbc.OracleDriver
|
||||
# url: jdbc:oracle:thin:@//localhost:1521/XE
|
||||
# username: ROOT
|
||||
# password: root
|
||||
# hikari:
|
||||
# connectionTestQuery: SELECT 1 FROM DUAL
|
||||
# postgres:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
# username: root
|
||||
# password: root
|
||||
# sqlserver:
|
||||
# type: ${spring.datasource.type}
|
||||
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
|
||||
# username: SA
|
||||
# password: root
|
||||
hikari:
|
||||
# 最大连接池数量
|
||||
maxPoolSize: 20
|
||||
# 最小空闲线程数量
|
||||
minIdle: 10
|
||||
# 配置获取连接等待超时的时间
|
||||
connectionTimeout: 30000
|
||||
# 校验超时时间
|
||||
validationTimeout: 5000
|
||||
# 空闲连接存活最大时间,默认10分钟
|
||||
idleTimeout: 600000
|
||||
# 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
|
||||
maxLifetime: 1800000
|
||||
# 连接测试query(配置检测连接是否有效)
|
||||
connectionTestQuery: SELECT 1
|
||||
# 多久检查一次连接的活性
|
||||
keepaliveTime: 30000
|
||||
|
||||
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
|
||||
spring:
|
||||
redis:
|
||||
# 地址
|
||||
host: 127.0.0.1
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 1
|
||||
# 密码(如没有密码请注释掉)
|
||||
# password: qaRedisPass123.
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 16
|
||||
# Netty线程池数量
|
||||
nettyThreads: 32
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 32
|
||||
# 连接池大小
|
||||
connectionPoolSize: 64
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
--- # mail 邮件发送
|
||||
mail:
|
||||
enabled: false
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
# 是否需要用户名密码验证
|
||||
auth: true
|
||||
# 发送方,遵循RFC-822标准
|
||||
from: xxx@163.com
|
||||
# 用户名(注意:如果使用foxmail邮箱,此处user为qq号)
|
||||
user: xxx@163.com
|
||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置密码,详情查看相关帮助)
|
||||
pass: xxxxxxxxxx
|
||||
# 使用 STARTTLS安全连接,STARTTLS是对纯文本通信协议的扩展。
|
||||
starttlsEnable: true
|
||||
# 使用SSL安全连接
|
||||
sslEnable: true
|
||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
||||
timeout: 0
|
||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
||||
connectionTimeout: 0
|
||||
|
||||
--- # sms 短信 支持 阿里云 腾讯云 云片 等等各式各样的短信服务商
|
||||
# https://wind.kim/doc/start 文档地址 各个厂商可同时使用
|
||||
sms:
|
||||
# 阿里云 dysmsapi.aliyuncs.com
|
||||
alibaba:
|
||||
#请求地址 默认为 dysmsapi.aliyuncs.com 如无特殊改变可以不用设置
|
||||
requestUrl: dysmsapi.aliyuncs.com
|
||||
#阿里云的accessKey
|
||||
accessKeyId: xxxxxxx
|
||||
#阿里云的accessKeySecret
|
||||
accessKeySecret: xxxxxxx
|
||||
#短信签名
|
||||
signature: 测试
|
||||
tencent:
|
||||
#请求地址默认为 sms.tencentcloudapi.com 如无特殊改变可不用设置
|
||||
requestUrl: sms.tencentcloudapi.com
|
||||
#腾讯云的accessKey
|
||||
accessKeyId: xxxxxxx
|
||||
#腾讯云的accessKeySecret
|
||||
accessKeySecret: xxxxxxx
|
||||
#短信签名
|
||||
signature: 测试
|
||||
#短信sdkAppId
|
||||
sdkAppId: appid
|
||||
#地域信息默认为 ap-guangzhou 如无特殊改变可不用设置
|
||||
territory: ap-guangzhou
|
||||
276
api/src/main/resources/application.yml
Normal file
276
api/src/main/resources/application.yml
Normal file
@@ -0,0 +1,276 @@
|
||||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: CT-API
|
||||
# 版本
|
||||
version: ${ruoyi-vue-plus.version}
|
||||
# 版权年份
|
||||
copyrightYear: 2023
|
||||
# 缓存懒加载
|
||||
cacheLazy: false
|
||||
|
||||
captcha:
|
||||
# 页面 <参数设置> 可开启关闭 验证码校验
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
type: MATH
|
||||
# line 线段干扰 circle 圆圈干扰 shear 扭曲干扰
|
||||
category: CIRCLE
|
||||
# 数字验证码位数
|
||||
numberLength: 1
|
||||
# 字符验证码长度
|
||||
charLength: 4
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8181
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
# undertow 配置
|
||||
undertow:
|
||||
# HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的
|
||||
max-http-post-size: -1
|
||||
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
|
||||
# 每块buffer的空间大小,越小的空间被利用越充分
|
||||
buffer-size: 512
|
||||
# 是否分配的直接内存
|
||||
direct-buffers: true
|
||||
threads:
|
||||
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
|
||||
io: 8
|
||||
# 阻塞任务线程池, 当执行类似servlet请求阻塞操作, undertow会从这个线程池中取得线程,它的值设置取决于系统的负载
|
||||
worker: 256
|
||||
|
||||
# 日志配置
|
||||
logging:
|
||||
level:
|
||||
com.ruoyi: @logging.level@
|
||||
org.springframework: warn
|
||||
config: classpath:logback-plus.xml
|
||||
|
||||
# 用户配置
|
||||
user:
|
||||
password:
|
||||
# 密码最大错误次数
|
||||
maxRetryCount: 5
|
||||
# 密码锁定时间(默认10分钟)
|
||||
lockTime: 10
|
||||
|
||||
# Spring配置
|
||||
spring:
|
||||
application:
|
||||
name: ${ruoyi.name}
|
||||
# 资源信息
|
||||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: @profiles.active@
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
# 服务模块
|
||||
devtools:
|
||||
restart:
|
||||
# 热部署开关
|
||||
enabled: true
|
||||
mvc:
|
||||
throw-exception-if-no-handler-found: true
|
||||
format:
|
||||
date-time: yyyy-MM-dd HH:mm:ss
|
||||
jackson:
|
||||
# 日期格式化
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
serialization:
|
||||
# 格式化输出
|
||||
indent_output: false
|
||||
# 忽略无法转换的对象
|
||||
fail_on_empty_beans: false
|
||||
deserialization:
|
||||
# 允许对象忽略json中不存在的属性
|
||||
fail_on_unknown_properties: false
|
||||
|
||||
# Sa-Token配置
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: Authorization
|
||||
# token有效期 设为一天 (必定过期) 单位: 秒
|
||||
timeout: 86400
|
||||
# 多端不同 token 有效期 可查看 LoginHelper.loginByDevice 方法自定义
|
||||
# token最低活跃时间 (指定时间无操作就过期) 单位: 秒
|
||||
active-timeout: 18000
|
||||
# 允许动态设置 token 有效期
|
||||
dynamic-active-timeout: true
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: false
|
||||
# 是否尝试从header里读取token
|
||||
is-read-header: true
|
||||
# 是否尝试从cookie里读取token
|
||||
is-read-cookie: false
|
||||
# token前缀
|
||||
token-prefix: "Bearer"
|
||||
# jwt秘钥
|
||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
||||
|
||||
# security配置
|
||||
security:
|
||||
# 排除路径
|
||||
excludes:
|
||||
# 静态资源
|
||||
- /*.html
|
||||
- /**/*.html
|
||||
- /**/*.css
|
||||
- /**/*.js
|
||||
# 公共路径
|
||||
- /favicon.ico
|
||||
- /error
|
||||
# swagger 文档配置
|
||||
- /*/api-docs
|
||||
- /*/api-docs/**
|
||||
# actuator 监控配置
|
||||
- /actuator
|
||||
- /actuator/**
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
mybatis-plus:
|
||||
# 不支持多包, 如有需要可在注解配置 或 提升扫包等级
|
||||
# 例如 com.**.**.mapper
|
||||
mapperPackage: com.ruoyi.**.mapper
|
||||
# 对应的 XML 文件位置
|
||||
mapperLocations: classpath*:mapper/**/*Mapper.xml
|
||||
# 实体扫描,多个package用逗号或者分号分隔
|
||||
typeAliasesPackage: com.ruoyi.**.domain
|
||||
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
|
||||
checkConfigLocation: false
|
||||
configuration:
|
||||
# 自动驼峰命名规则(camel case)映射
|
||||
mapUnderscoreToCamelCase: true
|
||||
# MyBatis 自动映射策略
|
||||
# NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射
|
||||
autoMappingBehavior: PARTIAL
|
||||
# MyBatis 自动映射时未知列或未知属性处理策
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: NONE
|
||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
# 是否打印 Logo banner
|
||||
banner: true
|
||||
dbConfig:
|
||||
# 主键类型
|
||||
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
|
||||
idType: AUTO
|
||||
# 逻辑已删除值
|
||||
logicDeleteValue: 2
|
||||
# 逻辑未删除值
|
||||
logicNotDeleteValue: 0
|
||||
# 字段验证策略之 insert,在 insert 的时候的字段验证策略
|
||||
# IGNORED 忽略 NOT_NULL 非NULL NOT_EMPTY 非空 DEFAULT 默认 NEVER 不加入 SQL
|
||||
insertStrategy: NOT_NULL
|
||||
# 字段验证策略之 update,在 update 的时候的字段验证策略
|
||||
updateStrategy: NOT_NULL
|
||||
# 字段验证策略之 select,在 select 的时候的字段验证策略既 wrapper 根据内部 entity 生成的 where 条件
|
||||
where-strategy: NOT_NULL
|
||||
|
||||
# 数据加密
|
||||
mybatis-encryptor:
|
||||
# 是否开启加密
|
||||
enable: false
|
||||
# 默认加密算法
|
||||
algorithm: BASE64
|
||||
# 编码方式 BASE64/HEX。默认BASE64
|
||||
encode: BASE64
|
||||
# 安全秘钥 对称算法的秘钥 如:AES,SM4
|
||||
password:
|
||||
# 公私钥 非对称算法的公私钥 如:SM2,RSA
|
||||
publicKey:
|
||||
privateKey:
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
# 是否开启接口文档
|
||||
enabled: false
|
||||
# swagger-ui:
|
||||
# # 持久化认证数据
|
||||
# persistAuthorization: true
|
||||
info:
|
||||
# 标题
|
||||
title: '标题:${ruoyi.name}后台管理系统_接口文档'
|
||||
# 描述
|
||||
description: '描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...'
|
||||
# 版本
|
||||
version: '版本号: ${ruoyi-vue-plus.version}'
|
||||
# 作者信息
|
||||
contact:
|
||||
name: Lion Li
|
||||
email: crazylionli@163.com
|
||||
url: https://gitee.com/dromara/RuoYi-Vue-Plus
|
||||
components:
|
||||
# 鉴权方式配置
|
||||
security-schemes:
|
||||
apiKey:
|
||||
type: APIKEY
|
||||
in: HEADER
|
||||
name: ${sa-token.token-name}
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
packages-to-scan: com.ruoyi.demo
|
||||
- group: 2.系统模块
|
||||
packages-to-scan: com.ruoyi.web
|
||||
- group: 3.代码生成模块
|
||||
packages-to-scan: com.ruoyi.generator
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
# 过滤开关
|
||||
enabled: true
|
||||
# 排除链接(多个用逗号分隔)
|
||||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
|
||||
# 全局线程池相关配置
|
||||
thread-pool:
|
||||
# 是否开启线程池
|
||||
enabled: true
|
||||
# 队列最大长度
|
||||
queueCapacity: 128
|
||||
# 线程池维护线程所允许的空闲时间
|
||||
keepAliveSeconds: 300
|
||||
|
||||
--- # 分布式锁 lock4j 全局配置
|
||||
lock4j:
|
||||
# 获取分布式锁超时时间,默认为 3000 毫秒
|
||||
acquire-timeout: 3000
|
||||
# 分布式锁的超时时间,默认为 30 秒
|
||||
expire: 30000
|
||||
|
||||
--- # Actuator 监控端点的配置项
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
endpoint:
|
||||
health:
|
||||
show-details: ALWAYS
|
||||
logfile:
|
||||
external-file: ./logs/sys-console.log
|
||||
|
||||
api:
|
||||
app-id: 1a8b2a5c-d51b-4b14-871b-080b1395fac0
|
||||
host: http://101.95.48.44/
|
||||
public-key: KEY657a695e0cf254f3bf10fe0a
|
||||
local-ip: 120.26.168.65
|
||||
token-key: CT-API-TOKEN
|
||||
8
api/src/main/resources/banner.txt
Normal file
8
api/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Application Version: ${ruoyi-vue-plus.version}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
__________ _____.___.__ ____ ____ __________.__
|
||||
\______ \__ __ ____\__ | |__| \ \ / /_ __ ____ \______ \ | __ __ ______
|
||||
| _/ | \/ _ \/ | | | ______ \ Y / | \_/ __ \ ______ | ___/ | | | \/ ___/
|
||||
| | \ | ( <_> )____ | | /_____/ \ /| | /\ ___/ /_____/ | | | |_| | /\___ \
|
||||
|____|_ /____/ \____// ______|__| \___/ |____/ \___ > |____| |____/____//____ >
|
||||
\/ \/ \/ \/
|
||||
BIN
api/src/main/resources/ip2region.xdb
Normal file
BIN
api/src/main/resources/ip2region.xdb
Normal file
Binary file not shown.
129
api/src/main/resources/logback-plus.xml
Normal file
129
api/src/main/resources/logback-plus.xml
Normal file
@@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="log.path" value="./logs"/>
|
||||
<property name="console.log.pattern"
|
||||
value="%red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
||||
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${console.log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/api-console.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/api-console.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大 1天 -->
|
||||
<maxHistory>1</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/api-info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/api-info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/api-error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/api-error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- info异步输出 -->
|
||||
<appender name="async_info" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||
<queueSize>512</queueSize>
|
||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
||||
<appender-ref ref="file_info"/>
|
||||
</appender>
|
||||
|
||||
<!-- error异步输出 -->
|
||||
<appender name="async_error" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
|
||||
<queueSize>512</queueSize>
|
||||
<!-- 添加附加的appender,最多只能添加一个 -->
|
||||
<appender-ref ref="file_error"/>
|
||||
</appender>
|
||||
|
||||
<!-- 整合 skywalking 控制台输出 tid -->
|
||||
<!-- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">-->
|
||||
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||
<!-- </layout>-->
|
||||
<!-- <charset>utf-8</charset>-->
|
||||
<!-- </encoder>-->
|
||||
<!-- </appender>-->
|
||||
|
||||
<!-- 整合 skywalking 推送采集日志 -->
|
||||
<!-- <appender name="sky_log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">-->
|
||||
<!-- <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
|
||||
<!-- <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">-->
|
||||
<!-- <pattern>[%tid] ${console.log.pattern}</pattern>-->
|
||||
<!-- </layout>-->
|
||||
<!-- <charset>utf-8</charset>-->
|
||||
<!-- </encoder>-->
|
||||
<!-- </appender>-->
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
<appender-ref ref="async_info" />
|
||||
<appender-ref ref="async_error" />
|
||||
<appender-ref ref="file_console" />
|
||||
<!-- <appender-ref ref="sky_log"/>-->
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
28
api/src/main/resources/spy.properties
Normal file
28
api/src/main/resources/spy.properties
Normal file
@@ -0,0 +1,28 @@
|
||||
# p6spy 性能分析插件配置文件
|
||||
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||
# 自定义日志打印
|
||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||
#日志输出到控制台
|
||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
# 使用日志系统记录 sql
|
||||
#appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# 设置 p6spy driver 代理
|
||||
#deregisterdrivers=true
|
||||
# 取消JDBC URL前缀
|
||||
useprefix=true
|
||||
# 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset.
|
||||
excludecategories=info,debug,result,commit,resultset
|
||||
# 日期格式
|
||||
dateformat=yyyy-MM-dd HH:mm:ss
|
||||
# SQL语句打印时间格式
|
||||
databaseDialectTimestampFormat=yyyy-MM-dd HH:mm:ss
|
||||
# 实际驱动可多个
|
||||
#driverlist=org.h2.Driver
|
||||
# 是否开启慢SQL记录
|
||||
outagedetection=true
|
||||
# 慢SQL记录标准 2 秒
|
||||
outagedetectioninterval=2
|
||||
# 是否过滤 Log
|
||||
filter=true
|
||||
# 过滤 Log 时所排除的 sql 关键字,以逗号分隔
|
||||
exclude=SELECT 1
|
||||
Reference in New Issue
Block a user