Merge branch 'test' into dev
# Conflicts: # src/main/java/com/sqx/modules/pay/controller/app/WuyouController.java
This commit is contained in:
86
pom.xml
86
pom.xml
@@ -35,12 +35,14 @@
|
|||||||
<qiniu.version>7.2.23</qiniu.version>
|
<qiniu.version>7.2.23</qiniu.version>
|
||||||
<aliyun.oss.version>3.4.0</aliyun.oss.version>
|
<aliyun.oss.version>3.4.0</aliyun.oss.version>
|
||||||
<qcloud.cos.version>4.4</qcloud.cos.version>
|
<qcloud.cos.version>4.4</qcloud.cos.version>
|
||||||
<swagger.version>2.7.0</swagger.version>
|
<!-- <swagger.version>2.7.0</swagger.version>-->
|
||||||
|
<swagger.version>2.9.2</swagger.version>
|
||||||
<joda.time.version>2.9.9</joda.time.version>
|
<joda.time.version>2.9.9</joda.time.version>
|
||||||
<gson.version>2.8.5</gson.version>
|
<gson.version>2.8.5</gson.version>
|
||||||
<fastjson.version>1.2.83</fastjson.version>
|
<fastjson.version>1.2.83</fastjson.version>
|
||||||
<hutool.version>4.6.10</hutool.version>
|
<hutool.version>4.6.10</hutool.version>
|
||||||
<lombok.version>1.18.4</lombok.version>
|
<lombok.version>1.18.4</lombok.version>
|
||||||
|
<shardingsphere.version>4.1.1</shardingsphere.version>
|
||||||
|
|
||||||
<!--wagon plugin 配置-->
|
<!--wagon plugin 配置-->
|
||||||
<!--<service-path>/work/sz</service-path>
|
<!--<service-path>/work/sz</service-path>
|
||||||
@@ -67,6 +69,12 @@
|
|||||||
<groupId>com.amazonaws</groupId>
|
<groupId>com.amazonaws</groupId>
|
||||||
<artifactId>aws-java-sdk</artifactId>
|
<artifactId>aws-java-sdk</artifactId>
|
||||||
<version>1.11.274</version>
|
<version>1.11.274</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>aws-java-sdk-simpleworkflow</artifactId>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.afterturn</groupId>
|
<groupId>cn.afterturn</groupId>
|
||||||
@@ -97,13 +105,6 @@
|
|||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--云购os支付-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yungouos.pay</groupId>
|
|
||||||
<artifactId>yungouos-pay-sdk</artifactId>
|
|
||||||
<version>2.0.10</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate.validator</groupId>
|
<groupId>org.hibernate.validator</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
@@ -129,11 +130,11 @@
|
|||||||
<version>5.5.0</version>
|
<version>5.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
|
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.alibaba</groupId>
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
<artifactId>druid</artifactId>
|
<!-- <artifactId>druid</artifactId>-->
|
||||||
<version>1.1.10</version>
|
<!-- <version>1.1.10</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<!-- 苹果工具类 -->
|
<!-- 苹果工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.auth0</groupId>
|
<groupId>com.auth0</groupId>
|
||||||
@@ -183,6 +184,12 @@
|
|||||||
<groupId>com.aliyun.oss</groupId>
|
<groupId>com.aliyun.oss</groupId>
|
||||||
<artifactId>aliyun-sdk-oss</artifactId>
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
<version>3.4.0</version>
|
<version>3.4.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
@@ -247,16 +254,40 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--动态数据库切换-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
|
||||||
|
<!-- <version>4.1.3</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>${mysql.version}</version>
|
<version>${mysql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--oracle驱动-->
|
<!--oracle驱动-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.oracle</groupId>-->
|
||||||
|
<!-- <artifactId>ojdbc6</artifactId>-->
|
||||||
|
<!-- <version>${oracle.version}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- 用于定义sharding-jdbc 分片规则 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.oracle</groupId>
|
<groupId>org.apache.shardingsphere</groupId>
|
||||||
<artifactId>ojdbc6</artifactId>
|
<artifactId>sharding-core-api</artifactId>
|
||||||
<version>${oracle.version}</version>
|
<version>${shardingsphere.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.shardingsphere</groupId>
|
||||||
|
<artifactId>sharding-jdbc-core</artifactId>
|
||||||
|
<version>${shardingsphere.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--mssql驱动-->
|
<!--mssql驱动-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -265,10 +296,10 @@
|
|||||||
<version>${mssql.version}</version>
|
<version>${mssql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--postgresql驱动-->
|
<!--postgresql驱动-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>org.postgresql</groupId>
|
<!-- <groupId>org.postgresql</groupId>-->
|
||||||
<artifactId>postgresql</artifactId>
|
<!-- <artifactId>postgresql</artifactId>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
@@ -327,14 +358,25 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
<version>${swagger.version}</version>
|
<version>${swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.5.22</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-models</artifactId>
|
||||||
|
<version>1.5.22</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.qiniu</groupId>
|
<groupId>com.qiniu</groupId>
|
||||||
<artifactId>qiniu-java-sdk</artifactId>
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.sqx;
|
package com.sqx;
|
||||||
|
|
||||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
@@ -18,25 +17,7 @@ import java.util.Map;
|
|||||||
public class SqxApplication {
|
public class SqxApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ConfigurableApplicationContext context = SpringApplication.run(SqxApplication.class, args);
|
SpringApplication.run(SqxApplication.class, args);
|
||||||
context.getEnvironment().getPropertySources().forEach(source -> {
|
|
||||||
if (source.getName().contains("application-dev.yml") || source.getName().contains("application-prod.yml")) {
|
|
||||||
if (source.getSource() instanceof Map) {
|
|
||||||
((Map<String, Object>) source.getSource()).forEach((key, value) -> {
|
|
||||||
System.out.println(key + ": " + value);
|
|
||||||
if ("pay.orderNotifyUrl".equals(key)) {
|
|
||||||
WuyouPay.setNotifyUrl(value.toString());
|
|
||||||
}
|
|
||||||
if ("pay.extractNotifyUrl".equals(key)) {
|
|
||||||
WuyouPay.setExtractNotifyUrl(value.toString());
|
|
||||||
}
|
|
||||||
if ("pay.h5BaseUrl".equals(key)) {
|
|
||||||
WuyouPay.setH5BaseUrl(value.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 短剧系统启动成功 ლ(´ڡ`ლ)゙ \n"+
|
System.out.println("(♥◠‿◠)ノ゙ 短剧系统启动成功 ლ(´ڡ`ლ)゙ \n"+
|
||||||
" _ \n" +
|
" _ \n" +
|
||||||
" | | \n" +
|
" | | \n" +
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sqx.common.aspect;
|
package com.sqx.common.aspect;
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.sqx.common.utils.HttpContextUtils;
|
import com.sqx.common.utils.HttpContextUtils;
|
||||||
import com.sqx.common.utils.IPUtils;
|
import com.sqx.common.utils.IPUtils;
|
||||||
@@ -21,9 +22,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppApiMethodAspect {
|
public class AppApiMethodAspect {
|
||||||
|
|
||||||
@Pointcut("execution(public * (com.sqx.modules.*.controller.*).*(..)) " +
|
@Pointcut("!execution(public * (com.sqx.modules.sys.controller.SysLoginController).*(..)) " +
|
||||||
"&& " +
|
"&& (execution(public * (com.sqx.modules.*.controller.*).*(..)) " +
|
||||||
"!execution(public * (com.sqx.modules.sys.controller.SysLoginController).*(..))")
|
"|| execution(public * (com.sqx.modules.app.*.controller.*).*(..)))")
|
||||||
public void pkg() {
|
public void pkg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,22 +45,31 @@ public class AppApiMethodAspect {
|
|||||||
|
|
||||||
// 执行被拦截的方法
|
// 执行被拦截的方法
|
||||||
Object result = pjp.proceed();
|
Object result = pjp.proceed();
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
//请求的参数
|
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||||
String resultJson = new Gson().toJson(result);
|
String method = request.getMethod();
|
||||||
try{
|
String requestUrl = request.getRequestURL().toString();
|
||||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
String requestIp = IPUtils.getIpAddr(request);
|
||||||
long end = System.currentTimeMillis();
|
long useTime = end - start;
|
||||||
if(StringUtils.isNotBlank(resultJson) && !"null".equals(resultJson)){
|
ThreadUtil.execAsync(() -> {
|
||||||
log.info("\n>>>>>> {} {}\n>>>>>> IP: {} \n>>>>>> execute time:{}ms \n>>>>>> Request: {}\n>>>>>> Response: {}",
|
//请求的参数
|
||||||
request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request),end-start,
|
String resultJson = new Gson().toJson(result);
|
||||||
params,
|
try {
|
||||||
resultJson
|
if (StringUtils.isNotBlank(resultJson) && !"null".equals(resultJson)) {
|
||||||
);
|
log.info("\n>>>>>> {} {}" +
|
||||||
|
"\n>>>>>> IP: {} " +
|
||||||
|
"\n>>>>>> execute time:{}ms " +
|
||||||
|
"\n>>>>>> Request: {}" +
|
||||||
|
"\n>>>>>> Response: {}",
|
||||||
|
method, requestUrl, requestIp, useTime,
|
||||||
|
params,
|
||||||
|
resultJson
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Request 为空" + e.getMessage());
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
});
|
||||||
log.error("Request 为空"+e.getMessage());
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.sqx.common.utils;
|
package com.sqx.common.utils;
|
||||||
|
|
||||||
import com.alibaba.druid.util.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public class RedisKeys {
|
|||||||
|
|
||||||
public static final String FREE_WATCH_KEY = "free:watch:";
|
public static final String FREE_WATCH_KEY = "free:watch:";
|
||||||
public static final String LOCK_KEY = "SYS:LOCK:";
|
public static final String LOCK_KEY = "SYS:LOCK:";
|
||||||
|
public static final String RATE_LIMIT = "RATE:z";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static String getSysConfigKey(String key){
|
public static String getSysConfigKey(String key){
|
||||||
@@ -41,4 +43,12 @@ public class RedisKeys {
|
|||||||
}
|
}
|
||||||
return key.toString();
|
return key.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUserIpRateKey(long userId, String ip) {
|
||||||
|
return RATE_LIMIT + "user:" + userId + ":ip:" + ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUserUrlRateKey(long userId, String url) {
|
||||||
|
return RATE_LIMIT + "user:" + userId + ":url:" + url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sqx.config;
|
package com.sqx.config;
|
||||||
|
|
||||||
|
import com.sqx.common.utils.RedisUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@@ -70,4 +71,10 @@ public class RedisConfig {
|
|||||||
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
|
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
|
||||||
return redisTemplate.opsForZSet();
|
return redisTemplate.opsForZSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisUtils redisUtils() {
|
||||||
|
// 根据实际情况初始化RedisUtils实例,可能需要传入相关配置参数,如Redis连接信息等
|
||||||
|
return new RedisUtils();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
150
src/main/java/com/sqx/config/ShardingConfig.java
Normal file
150
src/main/java/com/sqx/config/ShardingConfig.java
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
package com.sqx.config;
|
||||||
|
|
||||||
|
import com.sqx.sharding.MasterSlaveRules;
|
||||||
|
import com.sqx.sharding.ShardingDataBase;
|
||||||
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration;
|
||||||
|
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
|
||||||
|
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
|
||||||
|
import org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sharding-jdbc 配置文件
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Data
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "spring.shardingsphere")
|
||||||
|
public class ShardingConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取数据源信息
|
||||||
|
*/
|
||||||
|
private Map<String, ShardingDataBase> datasource;
|
||||||
|
/**
|
||||||
|
* 读写分离的配置
|
||||||
|
*/
|
||||||
|
private Map<String, MasterSlaveRules> masterSlaveRules;
|
||||||
|
/**
|
||||||
|
* 显示sharding-jdbc的sql
|
||||||
|
*/
|
||||||
|
private String showSql;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中心库的节点
|
||||||
|
*/
|
||||||
|
private String centerTablesDataNode;
|
||||||
|
|
||||||
|
@Value("${center-tables}")
|
||||||
|
private String tableNamesAsString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中心表,不进行分库操作
|
||||||
|
*/
|
||||||
|
// @Value("${center-tables}")
|
||||||
|
private Set<String> centerTables;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
// 使用换行符进行分割,然后去除空白字符,收集到Set集合中
|
||||||
|
centerTables = Arrays.stream(tableNamesAsString.split(","))
|
||||||
|
.map(String::trim)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置sharding-jdbc数据源
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public DataSource dataSource() throws SQLException {
|
||||||
|
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
|
||||||
|
|
||||||
|
// 配置数据库主从
|
||||||
|
shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigs());
|
||||||
|
|
||||||
|
// 配置表的切分策略
|
||||||
|
shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs());
|
||||||
|
|
||||||
|
// 配置是否显示sql
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.put("sql.show", showSql);
|
||||||
|
|
||||||
|
// 配置数据源
|
||||||
|
Map<String, DataSource> dataSourceMap = getShardingDataBase();
|
||||||
|
return ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingRuleConfig, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置
|
||||||
|
*/
|
||||||
|
private Set<TableRuleConfiguration> addTableRuleConfigs() {
|
||||||
|
Set<TableRuleConfiguration> sets = new HashSet<>();
|
||||||
|
for (String centerTable : centerTables) {
|
||||||
|
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(centerTable,
|
||||||
|
String.format(centerTablesDataNode, centerTable));
|
||||||
|
sets.add(tableRuleConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 定义区域表的分库规则
|
||||||
|
// InlineShardingStrategyConfiguration databaseShardingStrategyConfig = new InlineShardingStrategyConfiguration(
|
||||||
|
// regionTablesShardingDatabaseColumn, regionTablesShardingDatabaseAlgorithm);
|
||||||
|
// for (String regionTable : regionTables) {
|
||||||
|
// TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
|
||||||
|
// tableRuleConfig.setDatabaseShardingStrategyConfig(databaseShardingStrategyConfig);
|
||||||
|
// sets.add(tableRuleConfig);
|
||||||
|
// }
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置数据源
|
||||||
|
*/
|
||||||
|
private Map<String, DataSource> getShardingDataBase() {
|
||||||
|
String testQuery = "SELECT 1";
|
||||||
|
Map<String, DataSource> map = new HashMap<>();
|
||||||
|
datasource.forEach((datasourceName, shardingDataBase) -> {
|
||||||
|
HikariConfig config = new HikariConfig();
|
||||||
|
config.setDriverClassName(shardingDataBase.getDriverClassName());
|
||||||
|
config.setJdbcUrl(shardingDataBase.getJdbcUrl());
|
||||||
|
config.setUsername(shardingDataBase.getUsername());
|
||||||
|
config.setPassword(shardingDataBase.getPassword());
|
||||||
|
config.setPoolName(datasourceName);
|
||||||
|
config.setMinimumIdle(shardingDataBase.getMinimumIdle());
|
||||||
|
config.setMaximumPoolSize(shardingDataBase.getMaximumPoolSize());
|
||||||
|
config.setIdleTimeout(shardingDataBase.getIdleTimeout());
|
||||||
|
config.setMaxLifetime(shardingDataBase.getMaxLifetime());
|
||||||
|
config.setConnectionTimeout(shardingDataBase.getConnectionTimeout());
|
||||||
|
config.setConnectionTestQuery(testQuery);
|
||||||
|
map.put(datasourceName, new HikariDataSource(config));
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置读写分离
|
||||||
|
*/
|
||||||
|
private Set<MasterSlaveRuleConfiguration> masterSlaveRuleConfigs() {
|
||||||
|
Set<MasterSlaveRuleConfiguration> sets = new HashSet<>();
|
||||||
|
masterSlaveRules.forEach((databaseName, masterSlaveRules) -> {
|
||||||
|
MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration(databaseName,
|
||||||
|
masterSlaveRules.getMasterDataSourceName(), masterSlaveRules.getSlaveDataSourceNames());
|
||||||
|
sets.add(masterSlaveRuleConfig);
|
||||||
|
});
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,58 +1,85 @@
|
|||||||
package com.sqx.config;
|
//package com.sqx.config;
|
||||||
|
//
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
//import org.springframework.context.annotation.Profile;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
//import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.service.ApiInfo;
|
//import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.service.ApiKey;
|
//import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
//import springfox.documentation.service.ApiInfo;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
//import springfox.documentation.service.ApiKey;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
//import springfox.documentation.spi.DocumentationType;
|
||||||
|
//import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import java.util.List;
|
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
//
|
||||||
import static com.google.common.collect.Lists.newArrayList;
|
//import java.util.List;
|
||||||
|
//
|
||||||
@Configuration
|
//import static com.google.common.collect.Lists.newArrayList;
|
||||||
@EnableSwagger2
|
//
|
||||||
public class SwaggerConfig implements WebMvcConfigurer {
|
////@Configuration
|
||||||
|
////@EnableSwagger2
|
||||||
@Value("${swagger.enabled}")
|
////public class SwaggerConfig implements WebMvcConfigurer {
|
||||||
private boolean enabled;
|
////
|
||||||
|
//// @Value("${swagger.enabled}")
|
||||||
@Bean
|
//// private boolean enabled;
|
||||||
public Docket createRestApi() {
|
////
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
//// @Bean
|
||||||
.enable(enabled)
|
//// public Docket createRestApi() {
|
||||||
.apiInfo(apiInfo())
|
//// return new Docket(DocumentationType.SWAGGER_2)
|
||||||
.select()
|
//// .enable(enabled)
|
||||||
//加了ApiOperation注解的类,才生成接口文档
|
//// .apiInfo(apiInfo())
|
||||||
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
//// .select()
|
||||||
//包下的类,才生成接口文档
|
//// //加了ApiOperation注解的类,才生成接口文档
|
||||||
//.apis(RequestHandlerSelectors.basePackage("com.sqx.controller"))
|
//// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
.paths(PathSelectors.any())
|
//// //包下的类,才生成接口文档
|
||||||
.build()
|
//// //.apis(RequestHandlerSelectors.basePackage("com.sqx.controller"))
|
||||||
.securitySchemes(security());
|
//// .paths(PathSelectors.any())
|
||||||
}
|
//// .build()
|
||||||
|
//// .securitySchemes(security());
|
||||||
private ApiInfo apiInfo() {
|
//// }
|
||||||
return new ApiInfoBuilder()
|
////
|
||||||
.title("")
|
//// private ApiInfo apiInfo() {
|
||||||
.description("sqx-fast文档")
|
//// return new ApiInfoBuilder()
|
||||||
.termsOfServiceUrl("")
|
//// .title("")
|
||||||
.version("3.0.0")
|
//// .description("sqx-fast文档")
|
||||||
.build();
|
//// .termsOfServiceUrl("")
|
||||||
}
|
//// .version("3.0.0")
|
||||||
|
//// .build();
|
||||||
private List<ApiKey> security() {
|
//// }
|
||||||
return newArrayList(
|
////
|
||||||
new ApiKey("token", "token", "header")
|
//// private List<ApiKey> security() {
|
||||||
);
|
//// return newArrayList(
|
||||||
}
|
//// new ApiKey("token", "token", "header")
|
||||||
|
//// );
|
||||||
}
|
//// }
|
||||||
|
////
|
||||||
|
////}
|
||||||
|
//
|
||||||
|
//@Configuration
|
||||||
|
//@EnableSwagger2
|
||||||
|
//@Profile({"local", "dev"})
|
||||||
|
//public class SwaggerConfig {
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
|
// public Docket api() {
|
||||||
|
// return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
// .apiInfo(apiInfo())
|
||||||
|
// .select()
|
||||||
|
// .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
|
||||||
|
// .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
|
// .paths(PathSelectors.any())
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private ApiInfo apiInfo() {
|
||||||
|
// return new ApiInfoBuilder()
|
||||||
|
// .title("悠车位后台API接口文档")
|
||||||
|
// .description("悠车位服务端后台API接口文档")
|
||||||
|
// .version("1.0")
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.sqx.datasource.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源注解
|
|
||||||
*/
|
|
||||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Documented
|
|
||||||
@Inherited
|
|
||||||
public @interface DataSource {
|
|
||||||
String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.sqx.datasource.aspect;
|
|
||||||
|
|
||||||
|
|
||||||
import com.sqx.datasource.annotation.DataSource;
|
|
||||||
import com.sqx.datasource.config.DynamicContextHolder;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源,切面处理类
|
|
||||||
*/
|
|
||||||
@Aspect
|
|
||||||
@Component
|
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
||||||
public class DataSourceAspect {
|
|
||||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
@Pointcut("@annotation(com.sqx.datasource.annotation.DataSource) " +
|
|
||||||
"|| @within(com.sqx.datasource.annotation.DataSource)")
|
|
||||||
public void dataSourcePointCut() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Around("dataSourcePointCut()")
|
|
||||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
|
||||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
|
||||||
Class targetClass = point.getTarget().getClass();
|
|
||||||
Method method = signature.getMethod();
|
|
||||||
|
|
||||||
DataSource targetDataSource = (DataSource)targetClass.getAnnotation(DataSource.class);
|
|
||||||
DataSource methodDataSource = method.getAnnotation(DataSource.class);
|
|
||||||
if(targetDataSource != null || methodDataSource != null){
|
|
||||||
String value;
|
|
||||||
if(methodDataSource != null){
|
|
||||||
value = methodDataSource.value();
|
|
||||||
}else {
|
|
||||||
value = targetDataSource.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicContextHolder.push(value);
|
|
||||||
logger.debug("set datasource is {}", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return point.proceed();
|
|
||||||
} finally {
|
|
||||||
DynamicContextHolder.poll();
|
|
||||||
logger.debug("clean datasource");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.sqx.datasource.config;
|
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Deque;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源上下文
|
|
||||||
*/
|
|
||||||
public class DynamicContextHolder {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static final ThreadLocal<Deque<String>> CONTEXT_HOLDER = new ThreadLocal() {
|
|
||||||
@Override
|
|
||||||
protected Object initialValue() {
|
|
||||||
return new ArrayDeque();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得当前线程数据源
|
|
||||||
*
|
|
||||||
* @return 数据源名称
|
|
||||||
*/
|
|
||||||
public static String peek() {
|
|
||||||
return CONTEXT_HOLDER.get().peek();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置当前线程数据源
|
|
||||||
*
|
|
||||||
* @param dataSource 数据源名称
|
|
||||||
*/
|
|
||||||
public static void push(String dataSource) {
|
|
||||||
CONTEXT_HOLDER.get().push(dataSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空当前线程数据源
|
|
||||||
*/
|
|
||||||
public static void poll() {
|
|
||||||
Deque<String> deque = CONTEXT_HOLDER.get();
|
|
||||||
deque.poll();
|
|
||||||
if (deque.isEmpty()) {
|
|
||||||
CONTEXT_HOLDER.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.sqx.datasource.config;
|
|
||||||
|
|
||||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源
|
|
||||||
*/
|
|
||||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Object determineCurrentLookupKey() {
|
|
||||||
return DynamicContextHolder.peek();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.sqx.datasource.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.sqx.datasource.properties.DataSourceProperties;
|
|
||||||
import com.sqx.datasource.properties.DynamicDataSourceProperties;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置多数据源
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
|
|
||||||
public class DynamicDataSourceConfig {
|
|
||||||
@Autowired
|
|
||||||
private DynamicDataSourceProperties properties;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
|
||||||
public DataSourceProperties dataSourceProperties() {
|
|
||||||
return new DataSourceProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) {
|
|
||||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
|
||||||
dynamicDataSource.setTargetDataSources(getDynamicDataSource());
|
|
||||||
|
|
||||||
//默认数据源
|
|
||||||
DruidDataSource defaultDataSource = DynamicDataSourceFactory.buildDruidDataSource(dataSourceProperties);
|
|
||||||
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource);
|
|
||||||
|
|
||||||
return dynamicDataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Object, Object> getDynamicDataSource(){
|
|
||||||
Map<String, DataSourceProperties> dataSourcePropertiesMap = properties.getDatasource();
|
|
||||||
Map<Object, Object> targetDataSources = new HashMap<>(dataSourcePropertiesMap.size());
|
|
||||||
dataSourcePropertiesMap.forEach((k, v) -> {
|
|
||||||
DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v);
|
|
||||||
targetDataSources.put(k, druidDataSource);
|
|
||||||
});
|
|
||||||
|
|
||||||
return targetDataSources;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.sqx.datasource.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.sqx.datasource.properties.DataSourceProperties;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DruidDataSource
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DynamicDataSourceFactory {
|
|
||||||
|
|
||||||
public static DruidDataSource buildDruidDataSource(DataSourceProperties properties) {
|
|
||||||
DruidDataSource druidDataSource = new DruidDataSource();
|
|
||||||
druidDataSource.setDriverClassName(properties.getDriverClassName());
|
|
||||||
druidDataSource.setUrl(properties.getUrl());
|
|
||||||
druidDataSource.setUsername(properties.getUsername());
|
|
||||||
druidDataSource.setPassword(properties.getPassword());
|
|
||||||
|
|
||||||
druidDataSource.setInitialSize(properties.getInitialSize());
|
|
||||||
druidDataSource.setMaxActive(properties.getMaxActive());
|
|
||||||
druidDataSource.setMinIdle(properties.getMinIdle());
|
|
||||||
druidDataSource.setMaxWait(properties.getMaxWait());
|
|
||||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
|
|
||||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
|
|
||||||
druidDataSource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis());
|
|
||||||
druidDataSource.setValidationQuery(properties.getValidationQuery());
|
|
||||||
druidDataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
|
|
||||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
|
|
||||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn());
|
|
||||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
|
|
||||||
druidDataSource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements());
|
|
||||||
druidDataSource.setSharePreparedStatements(properties.isSharePreparedStatements());
|
|
||||||
|
|
||||||
try {
|
|
||||||
druidDataSource.setFilters(properties.getFilters());
|
|
||||||
druidDataSource.init();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return druidDataSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
package com.sqx.datasource.properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源属性
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class DataSourceProperties {
|
|
||||||
private String driverClassName;
|
|
||||||
private String url;
|
|
||||||
private String username;
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Druid默认参数
|
|
||||||
*/
|
|
||||||
private int initialSize = 2;
|
|
||||||
private int maxActive = 10;
|
|
||||||
private int minIdle = -1;
|
|
||||||
private long maxWait = 60 * 1000L;
|
|
||||||
private long timeBetweenEvictionRunsMillis = 60 * 1000L;
|
|
||||||
private long minEvictableIdleTimeMillis = 1000L * 60L * 30L;
|
|
||||||
private long maxEvictableIdleTimeMillis = 1000L * 60L * 60L * 7;
|
|
||||||
private String validationQuery = "select 1";
|
|
||||||
private int validationQueryTimeout = -1;
|
|
||||||
private boolean testOnBorrow = false;
|
|
||||||
private boolean testOnReturn = false;
|
|
||||||
private boolean testWhileIdle = true;
|
|
||||||
private boolean poolPreparedStatements = false;
|
|
||||||
private int maxOpenPreparedStatements = -1;
|
|
||||||
private boolean sharePreparedStatements = false;
|
|
||||||
private String filters = "stat,wall";
|
|
||||||
|
|
||||||
public String getDriverClassName() {
|
|
||||||
return driverClassName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDriverClassName(String driverClassName) {
|
|
||||||
this.driverClassName = driverClassName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInitialSize() {
|
|
||||||
return initialSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInitialSize(int initialSize) {
|
|
||||||
this.initialSize = initialSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxActive() {
|
|
||||||
return maxActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxActive(int maxActive) {
|
|
||||||
this.maxActive = maxActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinIdle() {
|
|
||||||
return minIdle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinIdle(int minIdle) {
|
|
||||||
this.minIdle = minIdle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMaxWait() {
|
|
||||||
return maxWait;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxWait(long maxWait) {
|
|
||||||
this.maxWait = maxWait;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTimeBetweenEvictionRunsMillis() {
|
|
||||||
return timeBetweenEvictionRunsMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
|
|
||||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMinEvictableIdleTimeMillis() {
|
|
||||||
return minEvictableIdleTimeMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
|
|
||||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getMaxEvictableIdleTimeMillis() {
|
|
||||||
return maxEvictableIdleTimeMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
|
|
||||||
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValidationQuery() {
|
|
||||||
return validationQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidationQuery(String validationQuery) {
|
|
||||||
this.validationQuery = validationQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValidationQueryTimeout() {
|
|
||||||
return validationQueryTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValidationQueryTimeout(int validationQueryTimeout) {
|
|
||||||
this.validationQueryTimeout = validationQueryTimeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestOnBorrow() {
|
|
||||||
return testOnBorrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestOnBorrow(boolean testOnBorrow) {
|
|
||||||
this.testOnBorrow = testOnBorrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestOnReturn() {
|
|
||||||
return testOnReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestOnReturn(boolean testOnReturn) {
|
|
||||||
this.testOnReturn = testOnReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestWhileIdle() {
|
|
||||||
return testWhileIdle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestWhileIdle(boolean testWhileIdle) {
|
|
||||||
this.testWhileIdle = testWhileIdle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPoolPreparedStatements() {
|
|
||||||
return poolPreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
|
|
||||||
this.poolPreparedStatements = poolPreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxOpenPreparedStatements() {
|
|
||||||
return maxOpenPreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
|
|
||||||
this.maxOpenPreparedStatements = maxOpenPreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSharePreparedStatements() {
|
|
||||||
return sharePreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSharePreparedStatements(boolean sharePreparedStatements) {
|
|
||||||
this.sharePreparedStatements = sharePreparedStatements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFilters() {
|
|
||||||
return filters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFilters(String filters) {
|
|
||||||
this.filters = filters;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.sqx.datasource.properties;
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多数据源属性
|
|
||||||
*/
|
|
||||||
@ConfigurationProperties(prefix = "dynamic")
|
|
||||||
public class DynamicDataSourceProperties {
|
|
||||||
private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
public Map<String, DataSourceProperties> getDatasource() {
|
|
||||||
return datasource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDatasource(Map<String, DataSourceProperties> datasource) {
|
|
||||||
this.datasource = datasource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,7 @@ import com.sqx.modules.pay.service.PayDetailsService;
|
|||||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||||
import com.sqx.modules.sys.service.SysUserService;
|
import com.sqx.modules.sys.service.SysUserService;
|
||||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||||
|
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
@@ -270,7 +271,7 @@ public class UserController {
|
|||||||
@ApiOperation("短剧分析")
|
@ApiOperation("短剧分析")
|
||||||
public Result courseMessage(Long page, Long limit, String date, int type, Long sysUserId) {
|
public Result courseMessage(Long page, Long limit, String date, int type, Long sysUserId) {
|
||||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||||
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, date, sysUserId);
|
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, TimeCompleteUtils.completeStartTime(date), sysUserId);
|
||||||
return Result.success().put("data", new PageUtils(mapIPage));
|
return Result.success().put("data", new PageUtils(mapIPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,6 +281,7 @@ public class UserController {
|
|||||||
@GetMapping("/userMessage")
|
@GetMapping("/userMessage")
|
||||||
@ApiOperation("用户分析")
|
@ApiOperation("用户分析")
|
||||||
public Result userMessage(String date, int type, Long sysUserId) {
|
public Result userMessage(String date, int type, Long sysUserId) {
|
||||||
|
date = TimeCompleteUtils.completeStartTime(date);
|
||||||
String qdCode = null;
|
String qdCode = null;
|
||||||
if (sysUserId != null) {
|
if (sysUserId != null) {
|
||||||
qdCode = sysUserService.getById(sysUserId).getQdCode();
|
qdCode = sysUserService.getById(sysUserId).getQdCode();
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ public class AppController {
|
|||||||
userEntity.setUserId(userId);
|
userEntity.setUserId(userId);
|
||||||
old.setZhiFuBao(userEntity.getZhiFuBao());
|
old.setZhiFuBao(userEntity.getZhiFuBao());
|
||||||
old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
|
old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
|
||||||
|
boolean bool = userService.updateById(userEntity);
|
||||||
// 去除首绑支付宝奖励
|
// 去除首绑支付宝奖励
|
||||||
// boolean bool = userService.updateById(userEntity);
|
|
||||||
// if (bool && isFirstBind) {
|
// if (bool && isFirstBind) {
|
||||||
// userService.firstBindAwardsMoney(old);
|
// userService.firstBindAwardsMoney(old);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public interface UserDao extends BaseMapper<UserEntity> {
|
|||||||
|
|
||||||
Double queryPayMoney(@Param("type") int type, @Param("date") String date,String qdCode);
|
Double queryPayMoney(@Param("type") int type, @Param("date") String date,String qdCode);
|
||||||
|
|
||||||
IPage<Map<String, Object>> queryCourseOrder(Page iPage,@Param("type") int type, @Param("date") String date,Long sysUserId);
|
IPage<Map<String, Object>> queryCourseOrder(Page iPage,@Param("type") int type, @Param("start") String start, @Param("end") String end,Long sysUserId);
|
||||||
|
|
||||||
int userMessage( String date, int type,String qdCode,Integer vipType);
|
int userMessage( String date, int type,String qdCode,Integer vipType);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.sqx.modules.app.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName invite_achievement
|
||||||
|
*/
|
||||||
|
@TableName(value ="invite_achievement")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString
|
||||||
|
public class InviteAchievement implements Serializable {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上级邀请用户id
|
||||||
|
*/
|
||||||
|
private Long sourceUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 达标次数
|
||||||
|
*/
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否首次达标
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
package com.sqx.modules.app.interceptor;
|
package com.sqx.modules.app.interceptor;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.sqx.common.exception.CzgException;
|
||||||
import com.sqx.common.exception.SqxException;
|
import com.sqx.common.exception.SqxException;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
|
import com.sqx.common.utils.IPUtils;
|
||||||
|
import com.sqx.modules.app.annotation.Login;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.app.service.UserService;
|
import com.sqx.modules.app.service.UserService;
|
||||||
import com.sqx.modules.app.utils.JwtUtils;
|
import com.sqx.modules.app.utils.JwtUtils;
|
||||||
|
import com.sqx.modules.redisService.RedisService;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import com.sqx.modules.app.annotation.Login;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -24,13 +31,20 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(AuthorizationInterceptor.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private JwtUtils jwtUtils;
|
private JwtUtils jwtUtils;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
private final RedisService redisService;
|
||||||
|
|
||||||
public static final String USER_KEY = "userId";
|
public static final String USER_KEY = "userId";
|
||||||
|
|
||||||
|
public AuthorizationInterceptor(RedisService redisService) {
|
||||||
|
this.redisService = redisService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
Login annotation;
|
Login annotation;
|
||||||
@@ -44,13 +58,13 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取用户凭证
|
// 获取用户凭证
|
||||||
String token = request.getHeader(jwtUtils.getHeader());
|
String token = request.getHeader(jwtUtils.getHeader());
|
||||||
if (StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(token)) {
|
||||||
token = request.getParameter(jwtUtils.getHeader());
|
token = request.getParameter(jwtUtils.getHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
//凭证为空
|
// 凭证为空
|
||||||
if (StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(token)) {
|
||||||
throw new SqxException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value());
|
throw new SqxException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value());
|
||||||
}
|
}
|
||||||
@@ -60,18 +74,43 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
|
|||||||
throw new SqxException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value());
|
throw new SqxException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置userId到request里,后续根据userId,获取用户信息
|
|
||||||
long userId = Long.parseLong(claims.getSubject());
|
long userId = Long.parseLong(claims.getSubject());
|
||||||
UserEntity user = userService.selectUserById(userId);
|
|
||||||
if (user.getStatus().equals(0)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
request.setAttribute(USER_KEY, userId);
|
request.setAttribute(USER_KEY, userId);
|
||||||
//记录用户最后一次调用接口的时间
|
|
||||||
UserEntity userEntity = new UserEntity();
|
String ip = IPUtils.getIpAddr(request); // 获取用户的 IP 地址
|
||||||
userEntity.setUserId(userId);
|
// 检查用户是否超过限流
|
||||||
userEntity.setOnLineTime(DateUtils.format(new Date()));
|
if (redisService.checkIpJumpLimit(userId, ip)) {
|
||||||
userService.updateById(userEntity);
|
log.warn("用户地址跳动频繁,封禁: {}", userId);
|
||||||
|
if (!redisService.isSetUserState(userId)) {
|
||||||
|
ThreadUtil.execAsync(() -> {
|
||||||
|
userService.update(null, new LambdaUpdateWrapper<UserEntity>()
|
||||||
|
.eq(UserEntity::getUserId, userId)
|
||||||
|
.set(UserEntity::getStatus, 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw new CzgException("ip跳动过于频繁,请联系管理员解封");
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadUtil.execAsync(() -> {
|
||||||
|
redisService.recordUrlVisitCountWithIp(userId, request.getRequestURI(), ip);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置 userId 到 request 里,后续根据 userId 获取用户信息
|
||||||
|
UserEntity user = userService.selectUserById(userId);
|
||||||
|
if (user != null && user.getStatus().equals(0)) {
|
||||||
|
throw new CzgException("异常行为用户: {}" + user.getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redisService.isRecordUserOnLineTime(userId)) {
|
||||||
|
ThreadUtil.execAsync(() -> {
|
||||||
|
// 记录用户最后一次调用接口的时间
|
||||||
|
UserEntity userEntity = new UserEntity();
|
||||||
|
userEntity.setUserId(userId);
|
||||||
|
userEntity.setOnLineTime(DateUtils.format(new Date()));
|
||||||
|
userService.updateById(userEntity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.sqx.modules.app.mapper;
|
||||||
|
|
||||||
|
import com.sqx.modules.app.entity.InviteAchievement;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Insert;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【invite_achievement】的数据库操作Mapper
|
||||||
|
* @createDate 2024-12-30 13:26:18
|
||||||
|
* @Entity com.sqx.modules.app.entity.InviteAchievement
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface InviteAchievementMapper extends BaseMapper<InviteAchievement> {
|
||||||
|
|
||||||
|
@Update("update invite_achievement set count = count + #{i}, update_time=now() where id = #{id}")
|
||||||
|
int incrCount(Integer id, int i);
|
||||||
|
|
||||||
|
@Insert("INSERT INTO invite_achievement (user_id, source_user_id, count, state, create_time)\n" +
|
||||||
|
"SELECT #{userId}, #{sourceUserId}, #{count}, #{state}, #{createTime} " +
|
||||||
|
"WHERE NOT EXISTS ( " +
|
||||||
|
" SELECT 1 FROM invite_achievement WHERE user_id = #{userId} " +
|
||||||
|
");")
|
||||||
|
boolean insertNotExists(InviteAchievement inviteAchievement);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.sqx.modules.app.service;
|
||||||
|
|
||||||
|
import com.sqx.modules.app.entity.InviteAchievement;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【invite_achievement】的数据库操作Service
|
||||||
|
* @createDate 2024-12-30 13:26:18
|
||||||
|
*/
|
||||||
|
public interface InviteAchievementService extends IService<InviteAchievement> {
|
||||||
|
|
||||||
|
int countByUserId(Long userId);
|
||||||
|
|
||||||
|
InviteAchievement getByUserId(Long userId);
|
||||||
|
|
||||||
|
int incrCount(Integer id, int i);
|
||||||
|
|
||||||
|
boolean insertNotExists(InviteAchievement inviteAchievement);
|
||||||
|
|
||||||
|
int countBySourceUserId(Long userId);
|
||||||
|
|
||||||
|
int countNum(Long userId, Integer signCount);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.sqx.modules.app.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.modules.app.entity.InviteAchievement;
|
||||||
|
import com.sqx.modules.app.service.InviteAchievementService;
|
||||||
|
import com.sqx.modules.app.mapper.InviteAchievementMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【invite_achievement】的数据库操作Service实现
|
||||||
|
* @createDate 2024-12-30 13:26:18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InviteAchievementServiceImpl extends ServiceImpl<InviteAchievementMapper, InviteAchievement>
|
||||||
|
implements InviteAchievementService{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countByUserId(Long userId) {
|
||||||
|
return count(new LambdaQueryWrapper<InviteAchievement>()
|
||||||
|
.eq(InviteAchievement::getUserId, userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InviteAchievement getByUserId(Long userId) {
|
||||||
|
return getOne(new LambdaQueryWrapper<InviteAchievement>()
|
||||||
|
.eq(InviteAchievement::getUserId, userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int incrCount(Integer id, int i) {
|
||||||
|
return baseMapper.incrCount(id,i);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertNotExists(InviteAchievement inviteAchievement) {
|
||||||
|
return baseMapper.insertNotExists(inviteAchievement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countBySourceUserId(Long userId) {
|
||||||
|
return count(new LambdaQueryWrapper<InviteAchievement>()
|
||||||
|
.eq(InviteAchievement::getSourceUserId, userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int countNum(Long userId, Integer signCount) {
|
||||||
|
return count(new LambdaQueryWrapper<InviteAchievement>()
|
||||||
|
.eq(InviteAchievement::getSourceUserId, userId)
|
||||||
|
.ge(InviteAchievement::getCount, signCount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.sqx.modules.app.service.impl;
|
package com.sqx.modules.app.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -55,6 +56,7 @@ import com.sqx.modules.sys.service.SysUserService;
|
|||||||
import com.sqx.modules.utils.HttpClientUtil;
|
import com.sqx.modules.utils.HttpClientUtil;
|
||||||
import com.sqx.modules.utils.InvitationCodeUtil;
|
import com.sqx.modules.utils.InvitationCodeUtil;
|
||||||
import com.sqx.modules.utils.MD5Util;
|
import com.sqx.modules.utils.MD5Util;
|
||||||
|
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||||
import com.tencentcloudapi.common.Credential;
|
import com.tencentcloudapi.common.Credential;
|
||||||
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
@@ -1335,7 +1337,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||||||
String invitationCode, String startTime, String endTime, String qdCode, String sysUserName, Integer vipType) {
|
String invitationCode, String startTime, String endTime, String qdCode, String sysUserName, Integer vipType) {
|
||||||
Page<UserEntity> pages = new Page<>(page, limit);
|
Page<UserEntity> pages = new Page<>(page, limit);
|
||||||
return new PageUtils(baseMapper.selectUserPage(pages, search, sex, platform, sysPhone, status, member,
|
return new PageUtils(baseMapper.selectUserPage(pages, search, sex, platform, sysPhone, status, member,
|
||||||
inviterCode, userName, invitationCode, startTime, endTime, qdCode, sysUserName, vipType));
|
inviterCode, userName, invitationCode, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), qdCode, sysUserName, vipType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1367,7 +1369,18 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date, Long sysUserId) {
|
public IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date, Long sysUserId) {
|
||||||
return baseMapper.queryCourseOrder(iPage, type, date, sysUserId);
|
DateTime parse = DateUtil.parse(date, "yyyy-MM-dd");
|
||||||
|
|
||||||
|
String startTime = DateUtil.format(parse, "yyyy-MM-dd 00:00:00");
|
||||||
|
String endTime = DateUtil.format(parse, "yyyy-MM-dd 23:59:59");
|
||||||
|
if (type == 2) {
|
||||||
|
startTime = DateUtil.format(DateUtil.beginOfMonth(parse), "yyyy-MM-dd 00:00:00");
|
||||||
|
endTime = DateUtil.format(DateUtil.endOfMonth(parse), "yyyy-MM-dd 23:59:59");
|
||||||
|
} else if (type == 3) {
|
||||||
|
startTime = DateUtil.format(DateUtil.beginOfYear(parse), "yyyy-MM-dd 00:00:00");
|
||||||
|
endTime = DateUtil.format(DateUtil.endOfYear(parse), "yyyy-MM-dd 23:59:59");
|
||||||
|
}
|
||||||
|
return baseMapper.queryCourseOrder(iPage, type, startTime, endTime, sysUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1498,7 +1511,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
ThreadUtil.execAsync(()->{
|
ThreadUtil.execAsync(()->{
|
||||||
discSpinningService.withdrawAsync(entity, money.doubleValue(), "[提现]");
|
discSpinningService.withdrawAsync(entity, money.doubleValue(), "[提现]");
|
||||||
},true);
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("首绑支付宝发放奖励异常,用户信息:{}", JSONUtil.toJsonStr(entity));
|
log.error("首绑支付宝发放奖励异常,用户信息:{}", JSONUtil.toJsonStr(entity));
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ public class AppCommonController {
|
|||||||
" 20后台管理平台域名配置\n" +
|
" 20后台管理平台域名配置\n" +
|
||||||
" 22拼多多优惠券地址")
|
" 22拼多多优惠券地址")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Login
|
|
||||||
public Result getCommonList(@PathVariable Integer type) {
|
public Result getCommonList(@PathVariable Integer type) {
|
||||||
return commonService.findByType(type);
|
return commonService.findByType(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ public class CourseController extends AbstractController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/selectCourseUserbyid")
|
// @GetMapping("/selectCourseUserbyid")
|
||||||
@ApiOperation("我的短剧")
|
// @ApiOperation("我的短剧")
|
||||||
public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
// public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
||||||
return courseUserService.selectCourseUser(page, limit, userId);
|
// return courseUserService.selectCourseUser(page, limit, userId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@GetMapping("/updateCourse")
|
@GetMapping("/updateCourse")
|
||||||
@ApiOperation("修改状态")
|
@ApiOperation("修改状态")
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class AppCourseController extends AbstractController {
|
|||||||
if (result.get("code").equals(0)) {
|
if (result.get("code").equals(0)) {
|
||||||
redisUtils.set(redisKey, result.get("data"), 3);
|
redisUtils.set(redisKey, result.get("data"), 3);
|
||||||
}
|
}
|
||||||
return courseDetailsService.selectCourseDetailsById(id, token, courseDetailsId);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ public class AppCourseUserController extends AbstractController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseUserService courseUserService;
|
private CourseUserService courseUserService;
|
||||||
|
|
||||||
@Login
|
// @Login
|
||||||
@GetMapping("/selectCourseUser")
|
// @GetMapping("/selectCourseUser")
|
||||||
@ApiOperation("App我的短剧")
|
// @ApiOperation("App我的短剧")
|
||||||
public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
// public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
||||||
return courseUserService.selectCourseUser(page, limit, userId);
|
// return courseUserService.selectCourseUser(page, limit, userId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@GetMapping("/updateTime")
|
@GetMapping("/updateTime")
|
||||||
@@ -33,12 +33,12 @@ public class AppCourseUserController extends AbstractController {
|
|||||||
courseUserService.updateTime(courseId);
|
courseUserService.updateTime(courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
// @Login
|
||||||
@GetMapping("/selectLatelyCourse")
|
// @GetMapping("/selectLatelyCourse")
|
||||||
@ApiOperation("最近学习")
|
// @ApiOperation("最近学习")
|
||||||
public Result selectLatelyCourse(Integer page, Integer limit, Long userId) {
|
// public Result selectLatelyCourse(Integer page, Integer limit, Long userId) {
|
||||||
return courseUserService.selectLatelyCourse(page, limit, userId);
|
// return courseUserService.selectLatelyCourse(page, limit, userId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface CourseUserDao extends BaseMapper<CourseUser> {
|
public interface CourseUserDao extends BaseMapper<CourseUser> {
|
||||||
|
|
||||||
IPage<Course> selectLatelyCourse(Page<Course> pages, @Param("userId") Long userId);
|
// IPage<Course> selectLatelyCourse(Page<Course> pages, @Param("userId") Long userId);
|
||||||
|
|
||||||
IPage<Course> selectCourseByCourseUser(Page<Course> pages, @Param("userId") Long userId);
|
//子查询不能用
|
||||||
|
// IPage<Course> selectCourseByCourseUser(Page<Course> pages, @Param("userId") Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户是否订购
|
* 查询用户是否订购
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ import java.io.Serializable;
|
|||||||
* @date 2021-03-27
|
* @date 2021-03-27
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
@TableName("course_collect")
|
@TableName("course_collect")
|
||||||
public class CourseCollect implements Serializable {
|
public class CourseCollect implements Serializable {
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,4 @@ public class CourseDetails implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String wxUrl;
|
private String wxUrl;
|
||||||
|
|
||||||
public CourseDetails() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ public interface CourseUserService extends IService<CourseUser> {
|
|||||||
|
|
||||||
void updateTime(Long courseId);
|
void updateTime(Long courseId);
|
||||||
|
|
||||||
Result selectCourseUser(Integer page, Integer limit, Long userId);
|
// Result selectCourseUser(Integer page, Integer limit, Long userId);
|
||||||
|
|
||||||
Result selectLatelyCourse(Integer page, Integer limit, Long userId);
|
// Result selectLatelyCourse(Integer page, Integer limit, Long userId);
|
||||||
|
|
||||||
Result insertCourseUser(CourseUser courseUser);
|
Result insertCourseUser(CourseUser courseUser);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,29 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||||||
public Result insertCourseCollect(CourseCollect courseCollect) {
|
public Result insertCourseCollect(CourseCollect courseCollect) {
|
||||||
reentrantReadWriteLock.writeLock().lock();
|
reentrantReadWriteLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
|
if (courseCollect.getClassify() == 3) {
|
||||||
|
QueryWrapper<CourseCollect> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("user_id", courseCollect.getUserId()).eq("classify", 3).eq("course_id", courseCollect.getCourseId());
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
CourseCollect collect = baseMapper.selectOne(queryWrapper);
|
||||||
|
if (collect != null) {
|
||||||
|
collect.setUpdateTime(DateUtils.format(new Date()));
|
||||||
|
collect.setCourseCollectId(courseCollect.getCourseCollectId());
|
||||||
|
baseMapper.updateById(collect);
|
||||||
|
return Result.success("操作成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
collect = new CourseCollect()
|
||||||
|
.setUserId(courseCollect.getUserId())
|
||||||
|
.setCourseId(courseCollect.getCourseId())
|
||||||
|
.setCourseDetailsId(courseCollect.getCourseDetailsId())
|
||||||
|
.setClassify(3)
|
||||||
|
.setCreateTime(DateUtils.format(new Date()))
|
||||||
|
.setUpdateTime(DateUtils.format(new Date()));
|
||||||
|
baseMapper.insert(collect);
|
||||||
|
return Result.success("操作成功!");
|
||||||
|
}
|
||||||
CourseCollect courseCollect1 = selectCourseCollectUserIdAnd(courseCollect.getUserId(), courseCollect.getCourseId(),courseCollect.getClassify(),courseCollect.getCourseDetailsId());
|
CourseCollect courseCollect1 = selectCourseCollectUserIdAnd(courseCollect.getUserId(), courseCollect.getCourseId(),courseCollect.getClassify(),courseCollect.getCourseDetailsId());
|
||||||
if (courseCollect.getType() == 1) {
|
if (courseCollect.getType() == 1) {
|
||||||
if(courseCollect1==null){
|
if(courseCollect1==null){
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
package com.sqx.modules.course.service.impl;
|
package com.sqx.modules.course.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.sqx.common.exception.SqxException;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
@@ -27,7 +30,6 @@ import com.sqx.modules.course.entity.CourseUser;
|
|||||||
import com.sqx.modules.course.service.CourseDetailsService;
|
import com.sqx.modules.course.service.CourseDetailsService;
|
||||||
import com.sqx.modules.course.vo.CourseDetailsIn;
|
import com.sqx.modules.course.vo.CourseDetailsIn;
|
||||||
import com.sqx.modules.orders.dao.OrdersDao;
|
import com.sqx.modules.orders.dao.OrdersDao;
|
||||||
import com.sqx.modules.orders.entity.Orders;
|
|
||||||
import com.sqx.modules.orders.service.OrdersService;
|
import com.sqx.modules.orders.service.OrdersService;
|
||||||
import com.sqx.modules.redisService.impl.RedisServiceImpl;
|
import com.sqx.modules.redisService.impl.RedisServiceImpl;
|
||||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||||
@@ -68,6 +70,8 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
private CommonInfoDao commonInfoDao;
|
private CommonInfoDao commonInfoDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisServiceImpl redisServiceImpl;
|
private RedisServiceImpl redisServiceImpl;
|
||||||
|
@Autowired
|
||||||
|
private CourseDetailsDao courseDetailsDao;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,6 +98,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户是否达到免费播放购买次数
|
* 校验用户是否达到免费播放购买次数
|
||||||
|
*
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @return true 可观看
|
* @return true 可观看
|
||||||
*/
|
*/
|
||||||
@@ -117,7 +122,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
// 触发计时
|
// 触发计时
|
||||||
redisServiceImpl.getFreeWatchTimeIsExpire(userId);
|
redisServiceImpl.getFreeWatchTimeIsExpire(userId);
|
||||||
isExpire = false;
|
isExpire = false;
|
||||||
}else {
|
} else {
|
||||||
isExpire = true;
|
isExpire = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +157,8 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
if (freeWatch || courseUser != null || (userEntity != null && userEntity.getMember() != null && userEntity.getMember() == 2)) {
|
if (freeWatch || courseUser != null || (userEntity != null && userEntity.getMember() != null && userEntity.getMember() == 2)) {
|
||||||
bean.setListsDetail(baseMapper.findByCourseId(id, userId));
|
bean.setListsDetail(baseMapper.findByCourseId(id, userId));
|
||||||
} else {
|
} else {
|
||||||
bean.setListsDetail(baseMapper.findByCourseIdNotUrl(id, userId));
|
List<CourseDetails> list = baseMapper.findByCourseIdNotUrl(id, userId);
|
||||||
|
bean.setListsDetail(list);
|
||||||
//查询用户是否单独购买了集
|
//查询用户是否单独购买了集
|
||||||
List<CourseUser> courseUsers = courseUserDao.selectCourseUserList(id, userId);
|
List<CourseUser> courseUsers = courseUserDao.selectCourseUserList(id, userId);
|
||||||
if (courseUsers.size() > 0) {
|
if (courseUsers.size() > 0) {
|
||||||
@@ -199,6 +205,30 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CourseCollect courseCollect = courseCollectDao.selectOne(Wrappers.<CourseCollect>lambdaQuery()
|
||||||
|
.select(CourseCollect::getCourseDetailsId)
|
||||||
|
.eq(CourseCollect::getCourseId, id)
|
||||||
|
.eq(CourseCollect::getClassify, 3)
|
||||||
|
.eq(CourseCollect::getUserId, userId)
|
||||||
|
.orderByDesc(CourseCollect::getUpdateTime).last("limit 1")
|
||||||
|
);
|
||||||
|
if (courseCollect != null && courseCollect.getCourseDetailsId() != null) {
|
||||||
|
CourseDetails courseDetails = courseDetailsDao.selectById(courseCollect.getCourseDetailsId());
|
||||||
|
if (courseDetails != null) {
|
||||||
|
bean.setCourseDetailsId(courseDetails.getCourseDetailsId());
|
||||||
|
bean.setCourseDetailsName(courseDetails.getCourseDetailsName());
|
||||||
|
bean.setCourseDetailsCount(courseDetails.getCourseDetailsCount());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//默认取第一集
|
||||||
|
CourseDetails courseDetails = courseDetailsDao.selectOne(Wrappers.<CourseDetails>lambdaQuery().eq(CourseDetails::getCourseId, id)
|
||||||
|
.orderByAsc(CourseDetails::getSort).last(" limit 1"));
|
||||||
|
if (courseDetails != null) {
|
||||||
|
bean.setCourseDetailsId(courseDetails.getCourseDetailsId());
|
||||||
|
bean.setCourseDetailsName(courseDetails.getCourseDetailsName());
|
||||||
|
bean.setCourseDetailsCount(courseDetails.getCourseDetailsCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
return Result.success().put("data", bean);
|
return Result.success().put("data", bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +241,9 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||||||
userId = Long.parseLong(claims.getSubject());
|
userId = Long.parseLong(claims.getSubject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!Validator.isNumber(randomNum)){
|
||||||
|
throw new SqxException("随机码必须是数字");
|
||||||
|
};
|
||||||
IPage<CourseDetails> courseDetailsIPage = baseMapper.selectCourseDetailsList(new Page<>(page, limit), randomNum, wxShow, dyShow);
|
IPage<CourseDetails> courseDetailsIPage = baseMapper.selectCourseDetailsList(new Page<>(page, limit), randomNum, wxShow, dyShow);
|
||||||
|
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
|
|
||||||
private void setCache(String key, String value) {
|
private void setCache(String key, String value) {
|
||||||
key = getIndexKey(key);
|
key = getIndexKey(key);
|
||||||
redisUtils.set(key, value, 600);
|
redisUtils.set(key, value, 60 * 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCache(String key) {
|
private String getCache(String key) {
|
||||||
@@ -174,26 +174,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||||
for (Map<String, Object> map : records) {
|
for (Map<String, Object> map : records) {
|
||||||
Object courseDetailsId = map.get("courseDetailsId");
|
map.put("courseDetailsId", null);
|
||||||
Object courseId = map.get("courseId");
|
map.put("courseDetailsName", "");
|
||||||
if (courseDetailsId != null) {
|
map.put("dyEpisodeId", "");
|
||||||
CourseDetails courseDetails = courseDetailsDao.selectById(Long.parseLong(String.valueOf(courseDetailsId)));
|
map.put("wxCourseDetailsId", "");
|
||||||
if (courseDetails != null) {
|
|
||||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
|
||||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
|
||||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//默认取第一集
|
|
||||||
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("course_id", courseId)
|
|
||||||
.orderByAsc("sort").last(" limit 1"));
|
|
||||||
if (courseDetails != null) {
|
|
||||||
map.put("courseDetailsId", courseDetails.getCourseDetailsId());
|
|
||||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
|
||||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
|
||||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||||
return Result.success().put("data", new PageUtils(mapIPage));
|
return Result.success().put("data", new PageUtils(mapIPage));
|
||||||
@@ -202,16 +186,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||||
for (Map<String, Object> map : records) {
|
for (Map<String, Object> map : records) {
|
||||||
Object courseId = map.get("courseId");
|
map.put("courseDetailsId", null);
|
||||||
//默认取第一集
|
map.put("courseDetailsName", "");
|
||||||
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("course_id", courseId)
|
map.put("dyEpisodeId", "");
|
||||||
.orderByAsc("sort").last(" limit 1"));
|
map.put("wxCourseDetailsId", "");
|
||||||
if (courseDetails != null) {
|
|
||||||
map.put("courseDetailsId", courseDetails.getCourseDetailsId());
|
|
||||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
|
||||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
|
||||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||||
return Result.success().put("data", new PageUtils(mapIPage));
|
return Result.success().put("data", new PageUtils(mapIPage));
|
||||||
|
|||||||
@@ -42,40 +42,40 @@ public class CourseUserServiceImpl extends ServiceImpl<CourseUserDao, CourseUser
|
|||||||
baseMapper.update(bean, updateWrapper);
|
baseMapper.update(bean, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
// public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
||||||
Page<Course> courseUserPage = new Page<>(page, limit);
|
// Page<Course> courseUserPage = new Page<>(page, limit);
|
||||||
IPage<Course> iPage = baseMapper.selectCourseByCourseUser(courseUserPage, userId);
|
// IPage<Course> iPage = baseMapper.selectCourseByCourseUser(courseUserPage, userId);
|
||||||
|
//
|
||||||
|
// List<Course> courses = iPage.getRecords();
|
||||||
|
// if (courses != null && courses.size() > 0) {
|
||||||
|
// for (Course course : courses) {
|
||||||
|
// Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
||||||
|
// if(orders!=null){
|
||||||
|
// course.setOrders(orders);
|
||||||
|
// }
|
||||||
|
// course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return Result.success().put("data", new PageUtils(iPage));
|
||||||
|
// }
|
||||||
|
|
||||||
List<Course> courses = iPage.getRecords();
|
// @Override
|
||||||
if (courses != null && courses.size() > 0) {
|
// public Result selectLatelyCourse(Integer page, Integer limit, Long userId) {
|
||||||
for (Course course : courses) {
|
// Page<Course> pages = new Page<>(page, limit);
|
||||||
Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
// IPage<Course> iPage = baseMapper.selectLatelyCourse(pages, userId);
|
||||||
if(orders!=null){
|
// List<Course> courses = iPage.getRecords();
|
||||||
course.setOrders(orders);
|
// if (courses != null && courses.size() > 0) {
|
||||||
}
|
// for (Course course : courses) {
|
||||||
course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
// Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
||||||
}
|
// if(orders!=null){
|
||||||
}
|
// course.setOrders(orders);
|
||||||
return Result.success().put("data", new PageUtils(iPage));
|
// }
|
||||||
}
|
// course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||||
|
// }
|
||||||
@Override
|
// }
|
||||||
public Result selectLatelyCourse(Integer page, Integer limit, Long userId) {
|
// return Result.success().put("data", new PageUtils(iPage));
|
||||||
Page<Course> pages = new Page<>(page, limit);
|
// }
|
||||||
IPage<Course> iPage = baseMapper.selectLatelyCourse(pages, userId);
|
|
||||||
List<Course> courses = iPage.getRecords();
|
|
||||||
if (courses != null && courses.size() > 0) {
|
|
||||||
for (Course course : courses) {
|
|
||||||
Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
|
||||||
if(orders!=null){
|
|
||||||
course.setOrders(orders);
|
|
||||||
}
|
|
||||||
course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.success().put("data", new PageUtils(iPage));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -53,9 +53,8 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final CashOutService cashOutService;
|
private final CashOutService cashOutService;
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
|
private final WuyouPay wuyouPay;
|
||||||
@Autowired
|
private final PlatformTransactionManager transactionManager;
|
||||||
private PlatformTransactionManager transactionManager;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -63,7 +62,9 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
UserMoneyDetailsService userMoneyDetailsService, CashOutService cashOutService,
|
UserMoneyDetailsService userMoneyDetailsService, CashOutService cashOutService,
|
||||||
DiscSpinningRecordService recordService,
|
DiscSpinningRecordService recordService,
|
||||||
UserMoneyService userMoneyService, UserService userService,
|
UserMoneyService userMoneyService, UserService userService,
|
||||||
RedisUtils redisUtils
|
RedisUtils redisUtils,
|
||||||
|
WuyouPay wuyouPay,
|
||||||
|
PlatformTransactionManager transactionManager
|
||||||
) {
|
) {
|
||||||
this.commonRepository = commonRepository;
|
this.commonRepository = commonRepository;
|
||||||
this.recordService = recordService;
|
this.recordService = recordService;
|
||||||
@@ -72,6 +73,8 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.cashOutService = cashOutService;
|
this.cashOutService = cashOutService;
|
||||||
this.redisUtils = redisUtils;
|
this.redisUtils = redisUtils;
|
||||||
|
this.wuyouPay = wuyouPay;
|
||||||
|
this.transactionManager = transactionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -128,11 +131,11 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
//最高提现金额
|
//最高提现金额
|
||||||
CommonInfo one2 = commonRepository.findOne(910);
|
CommonInfo one2 = commonRepository.findOne(910);
|
||||||
if (one2 == null || money <= Double.parseDouble(one2.getValue())) {
|
if (one2 == null || money <= Double.parseDouble(one2.getValue())) {
|
||||||
if (WuyouPay.checkCanCash(userInfo.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, BigDecimal.valueOf(money))) {
|
if (wuyouPay.checkCanCash(userInfo.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, BigDecimal.valueOf(money))) {
|
||||||
cashOut.setStatus(4);
|
cashOut.setStatus(4);
|
||||||
String outOrderNo = AliPayOrderUtil.createOrderId();
|
String outOrderNo = AliPayOrderUtil.createOrderId();
|
||||||
cashOut.setOrderNumber(outOrderNo);
|
cashOut.setOrderNumber(outOrderNo);
|
||||||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(
|
||||||
userInfo.getUserId(), null, null, title, 4, 2, 1,
|
userInfo.getUserId(), null, null, title, 4, 2, 1,
|
||||||
@@ -254,6 +257,7 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void receive1(DiscSpinningRecord receive) {
|
public void receive1(DiscSpinningRecord receive) {
|
||||||
if (recordService.countDraw(receive.getUserId()) > 10) {
|
if (recordService.countDraw(receive.getUserId()) > 10) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class InviteServiceImpl extends ServiceImpl<InviteDao, Invite> implements
|
|||||||
|
|
||||||
// 金币
|
// 金币
|
||||||
int money = Integer.parseInt(commonInfoService.findOne(911).getValue());
|
int money = Integer.parseInt(commonInfoService.findOne(911).getValue());
|
||||||
if (money > 0) {
|
if (money > 0 && userEntity.getUserId() != 1) {
|
||||||
userMoneyService.updateMoney(1, userEntity.getUserId(), money);
|
userMoneyService.updateMoney(1, userEntity.getUserId(), money);
|
||||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||||
userMoneyDetails.setUserId(userEntity.getUserId());
|
userMoneyDetails.setUserId(userEntity.getUserId());
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.sqx.modules.job.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务配置
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class ScheduleConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
|
|
||||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
|
||||||
factory.setDataSource(dataSource);
|
|
||||||
|
|
||||||
//quartz参数
|
|
||||||
Properties prop = new Properties();
|
|
||||||
prop.put("org.quartz.scheduler.instanceName", "sqxScheduler");
|
|
||||||
prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
|
||||||
//线程池配置
|
|
||||||
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
|
||||||
prop.put("org.quartz.threadPool.threadCount", "20");
|
|
||||||
prop.put("org.quartz.threadPool.threadPriority", "5");
|
|
||||||
//JobStore配置
|
|
||||||
prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
|
|
||||||
//集群配置
|
|
||||||
prop.put("org.quartz.jobStore.isClustered", "true");
|
|
||||||
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
|
||||||
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
|
||||||
|
|
||||||
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
|
||||||
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
|
||||||
prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
|
||||||
|
|
||||||
//PostgreSQL数据库,需要打开此注释
|
|
||||||
//prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
|
|
||||||
|
|
||||||
factory.setQuartzProperties(prop);
|
|
||||||
|
|
||||||
factory.setSchedulerName("sqxScheduler");
|
|
||||||
//延时启动
|
|
||||||
factory.setStartupDelay(30);
|
|
||||||
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
|
||||||
//可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
|
|
||||||
factory.setOverwriteExistingJobs(true);
|
|
||||||
//设置自动启动,默认为true
|
|
||||||
factory.setAutoStartup(true);
|
|
||||||
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,11 +4,16 @@ import com.sqx.common.annotation.SysLog;
|
|||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
import com.sqx.common.validator.ValidatorUtils;
|
import com.sqx.common.validator.ValidatorUtils;
|
||||||
|
import com.sqx.modules.job.dto.RunJobDTO;
|
||||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||||
import com.sqx.modules.job.service.ScheduleJobService;
|
import com.sqx.modules.job.service.ScheduleJobService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +26,14 @@ public class ScheduleJobController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ScheduleJobService scheduleJobService;
|
private ScheduleJobService scheduleJobService;
|
||||||
|
|
||||||
/**
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public ScheduleJobController(ApplicationContext applicationContext) {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* 定时任务列表
|
* 定时任务列表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
@@ -81,34 +93,42 @@ public class ScheduleJobController {
|
|||||||
/**
|
/**
|
||||||
* 立即执行任务
|
* 立即执行任务
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SysLog("立即执行任务")
|
@SysLog("立即执行任务")
|
||||||
@RequestMapping("/run")
|
@RequestMapping("/run")
|
||||||
public Result run(@RequestBody Long[] jobIds){
|
public Result run(@RequestBody Long[] jobIds) throws Exception {
|
||||||
scheduleJobService.run(jobIds);
|
|
||||||
|
|
||||||
return Result.success();
|
return Result.success().put("data", scheduleJobService.run(jobIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// @SysLog("立即执行任务")
|
||||||
* 暂停定时任务
|
// @RequestMapping("/run")
|
||||||
*/
|
// public Result run(@RequestBody Long[] jobIds){
|
||||||
@SysLog("暂停定时任务")
|
// scheduleJobService.run(jobIds);
|
||||||
@RequestMapping("/pause")
|
//
|
||||||
public Result pause(@RequestBody Long[] jobIds){
|
// return Result.success();
|
||||||
scheduleJobService.pause(jobIds);
|
// }
|
||||||
|
|
||||||
return Result.success();
|
// /**
|
||||||
}
|
// * 暂停定时任务
|
||||||
|
// */
|
||||||
/**
|
// @SysLog("暂停定时任务")
|
||||||
* 恢复定时任务
|
// @RequestMapping("/pause")
|
||||||
*/
|
// public Result pause(@RequestBody Long[] jobIds){
|
||||||
@SysLog("恢复定时任务")
|
// scheduleJobService.pause(jobIds);
|
||||||
@RequestMapping("/resume")
|
//
|
||||||
public Result resume(@RequestBody Long[] jobIds){
|
// return Result.success();
|
||||||
scheduleJobService.resume(jobIds);
|
// }
|
||||||
|
//
|
||||||
return Result.success();
|
// /**
|
||||||
}
|
// * 恢复定时任务
|
||||||
|
// */
|
||||||
|
// @SysLog("恢复定时任务")
|
||||||
|
// @RequestMapping("/resume")
|
||||||
|
// public Result resume(@RequestBody Long[] jobIds){
|
||||||
|
// scheduleJobService.resume(jobIds);
|
||||||
|
//
|
||||||
|
// return Result.success();
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/main/java/com/sqx/modules/job/dto/RunJobDTO.java
Normal file
14
src/main/java/com/sqx/modules/job/dto/RunJobDTO.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package com.sqx.modules.job.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RunJobDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer jobId;
|
||||||
|
private List<?> args;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.sqx.modules.job.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
|
import com.sqx.modules.job.dto.RunJobDTO;
|
||||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -34,18 +35,20 @@ public interface ScheduleJobService extends IService<ScheduleJobEntity> {
|
|||||||
*/
|
*/
|
||||||
int updateBatch(Long[] jobIds, int status);
|
int updateBatch(Long[] jobIds, int status);
|
||||||
|
|
||||||
/**
|
Object run(Long[] jobIds) throws Exception;
|
||||||
* 立即执行
|
|
||||||
*/
|
|
||||||
void run(Long[] jobIds);
|
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 暂停运行
|
// * 立即执行
|
||||||
*/
|
// */
|
||||||
void pause(Long[] jobIds);
|
// void run(Long[] jobIds);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 恢复运行
|
// * 暂停运行
|
||||||
*/
|
// */
|
||||||
void resume(Long[] jobIds);
|
// void pause(Long[] jobIds);
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 恢复运行
|
||||||
|
// */
|
||||||
|
// void resume(Long[] jobIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sqx.modules.job.service.impl;
|
package com.sqx.modules.job.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -7,40 +8,30 @@ import com.sqx.common.utils.Constant;
|
|||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.Query;
|
import com.sqx.common.utils.Query;
|
||||||
import com.sqx.modules.job.dao.ScheduleJobDao;
|
import com.sqx.modules.job.dao.ScheduleJobDao;
|
||||||
|
import com.sqx.modules.job.dto.RunJobDTO;
|
||||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
||||||
import com.sqx.modules.job.service.ScheduleJobService;
|
import com.sqx.modules.job.service.ScheduleJobService;
|
||||||
import com.sqx.modules.job.utils.ScheduleUtils;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.quartz.CronTrigger;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.quartz.Scheduler;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service("scheduleJobService")
|
@Service("scheduleJobService")
|
||||||
public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService {
|
public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService {
|
||||||
@Autowired
|
|
||||||
private Scheduler scheduler;
|
|
||||||
|
|
||||||
/**
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public ScheduleJobServiceImpl(ApplicationContext applicationContext) {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* 项目启动时,初始化定时器
|
* 项目启动时,初始化定时器
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
|
||||||
public void init(){
|
|
||||||
List<ScheduleJobEntity> scheduleJobList = this.list();
|
|
||||||
for(ScheduleJobEntity scheduleJob : scheduleJobList){
|
|
||||||
CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, scheduleJob.getJobId());
|
|
||||||
//如果不存在,则创建
|
|
||||||
if(cronTrigger == null) {
|
|
||||||
ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
|
|
||||||
}else {
|
|
||||||
ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
@@ -61,14 +52,11 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
|||||||
scheduleJob.setCreateTime(new Date());
|
scheduleJob.setCreateTime(new Date());
|
||||||
scheduleJob.setStatus(Constant.ScheduleStatus.NORMAL.getValue());
|
scheduleJob.setStatus(Constant.ScheduleStatus.NORMAL.getValue());
|
||||||
this.save(scheduleJob);
|
this.save(scheduleJob);
|
||||||
|
|
||||||
ScheduleUtils.createScheduleJob(scheduler, scheduleJob);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(ScheduleJobEntity scheduleJob) {
|
public void update(ScheduleJobEntity scheduleJob) {
|
||||||
ScheduleUtils.updateScheduleJob(scheduler, scheduleJob);
|
|
||||||
|
|
||||||
this.updateById(scheduleJob);
|
this.updateById(scheduleJob);
|
||||||
}
|
}
|
||||||
@@ -76,10 +64,6 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteBatch(Long[] jobIds) {
|
public void deleteBatch(Long[] jobIds) {
|
||||||
for(Long jobId : jobIds){
|
|
||||||
ScheduleUtils.deleteScheduleJob(scheduler, jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
//删除数据
|
//删除数据
|
||||||
this.removeByIds(Arrays.asList(jobIds));
|
this.removeByIds(Arrays.asList(jobIds));
|
||||||
}
|
}
|
||||||
@@ -92,32 +76,72 @@ public class ScheduleJobServiceImpl extends ServiceImpl<ScheduleJobDao, Schedule
|
|||||||
return baseMapper.updateBatch(map);
|
return baseMapper.updateBatch(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void run(Long[] jobIds) {
|
|
||||||
for(Long jobId : jobIds){
|
|
||||||
ScheduleUtils.run(scheduler, this.getById(jobId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
public Object run(Long[] jobIds) throws Exception {
|
||||||
public void pause(Long[] jobIds) {
|
ArrayList<Object> result = new ArrayList<>();
|
||||||
for(Long jobId : jobIds){
|
for(Long jobId : jobIds){
|
||||||
ScheduleUtils.pauseJob(scheduler, jobId);
|
ScheduleJobEntity jobEntity = baseMapper.selectById(jobId);
|
||||||
}
|
if (jobEntity == null) {
|
||||||
|
throw new RuntimeException("任务不存在");
|
||||||
|
}
|
||||||
|
|
||||||
updateBatch(jobIds, Constant.ScheduleStatus.PAUSE.getValue());
|
// 从Spring容器获取类的实例
|
||||||
}
|
Object classInstance = applicationContext.getBean(StrUtil.lowerFirst(jobEntity.getBeanName()));
|
||||||
|
if (!"com.sqx.modules.job.task".equals(classInstance.getClass().getPackage().getName())) {
|
||||||
|
throw new RuntimeException("非法调用");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
// if (jobDTO.getArgs() != null && !jobDTO.getArgs().isEmpty()) {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
// Class<?>[] argTypes = new Class<?>[jobDTO.getArgs().size()];
|
||||||
public void resume(Long[] jobIds) {
|
// for (int i = 0; i < jobDTO.getArgs().size(); i++) {
|
||||||
for(Long jobId : jobIds){
|
// argTypes[i] = jobDTO.getArgs().get(i).getClass();
|
||||||
ScheduleUtils.resumeJob(scheduler, jobId);
|
// }
|
||||||
}
|
// // 获取指定的Method对象
|
||||||
|
// Method method = classInstance.getClass().getDeclaredMethod(jobDTO.getMethodName(), argTypes);
|
||||||
|
//
|
||||||
|
// // 调用方法并返回结果
|
||||||
|
// return method.invoke(classInstance, jobDTO.getArgs().toArray());
|
||||||
|
// }
|
||||||
|
// 获取指定的Method对象
|
||||||
|
Method method = classInstance.getClass().getDeclaredMethod("run", String.class);
|
||||||
|
|
||||||
updateBatch(jobIds, Constant.ScheduleStatus.NORMAL.getValue());
|
// 调用方法并返回结果
|
||||||
}
|
Object invoke = method.invoke(classInstance, jobEntity.getParams());
|
||||||
|
if (invoke != null) {
|
||||||
|
result.add(invoke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
|
// public void run(Long[] jobIds) {
|
||||||
|
// for(Long jobId : jobIds){
|
||||||
|
// ScheduleUtils.run(scheduler, this.getById(jobId));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
|
// public void pause(Long[] jobIds) {
|
||||||
|
// for(Long jobId : jobIds){
|
||||||
|
// ScheduleUtils.pauseJob(scheduler, jobId);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// updateBatch(jobIds, Constant.ScheduleStatus.PAUSE.getValue());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// @Transactional(rollbackFor = Exception.class)
|
||||||
|
// public void resume(Long[] jobIds) {
|
||||||
|
// for(Long jobId : jobIds){
|
||||||
|
// ScheduleUtils.resumeJob(scheduler, jobId);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// updateBatch(jobIds, Constant.ScheduleStatus.NORMAL.getValue());
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import javax.annotation.Resource;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component("CashOutTask")
|
@Component
|
||||||
public class CashOutTask implements ITask {
|
public class CashOutTask{
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CashOutDao cashOutDao;
|
private CashOutDao cashOutDao;
|
||||||
@@ -27,20 +27,21 @@ public class CashOutTask implements ITask {
|
|||||||
private UserMoneyService userMoneyService;
|
private UserMoneyService userMoneyService;
|
||||||
@Resource
|
@Resource
|
||||||
private UserMoneyDetailsService userMoneyDetailsService;
|
private UserMoneyDetailsService userMoneyDetailsService;
|
||||||
|
@Resource
|
||||||
|
private WuyouPay wuyouPay;
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params) {
|
public void run(String params) {
|
||||||
logger.info("提现开始");
|
logger.info("提现开始");
|
||||||
List<CashOut> cashOuts = cashOutDao.selectYesterday();
|
List<CashOut> cashOuts = cashOutDao.selectYesterday();
|
||||||
for (CashOut cashOut : cashOuts) {
|
for (CashOut cashOut : cashOuts) {
|
||||||
if (WuyouPay.checkCanCash(cashOut.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, new BigDecimal(cashOut.getMoney()))) {
|
if (wuyouPay.checkCanCash(cashOut.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, new BigDecimal(cashOut.getMoney()))) {
|
||||||
cashOut.setState(4);
|
cashOut.setState(4);
|
||||||
String outOrderNo = AliPayOrderUtil.createOrderId();
|
String outOrderNo = AliPayOrderUtil.createOrderId();
|
||||||
cashOut.setOrderNumber(outOrderNo);
|
cashOut.setOrderNumber(outOrderNo);
|
||||||
|
|
||||||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||||
if (baseResp.getStatus() != null && baseResp.getStatus().equals(2)) {
|
if (baseResp.getStatus() != null && baseResp.getStatus().equals(2)) {
|
||||||
cashOut.setState(1);
|
cashOut.setState(1);
|
||||||
} else {
|
} else {
|
||||||
@@ -66,4 +67,9 @@ public class CashOutTask implements ITask {
|
|||||||
}
|
}
|
||||||
logger.info("提现结束");
|
logger.info("提现结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void test(String name, String age) {
|
||||||
|
logger.info("name: {}, age: {}", name, age);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.sqx.modules.utils.AliPayOrderUtil;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -23,8 +24,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component("CashOutTask2")
|
@Component
|
||||||
public class CashOutTask2 implements ITask {
|
public class CashOutTask2{
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CashOutDao cashOutDao;
|
private CashOutDao cashOutDao;
|
||||||
@@ -32,10 +33,11 @@ public class CashOutTask2 implements ITask {
|
|||||||
private UserMoneyService userMoneyService;
|
private UserMoneyService userMoneyService;
|
||||||
@Resource
|
@Resource
|
||||||
private UserMoneyDetailsService userMoneyDetailsService;
|
private UserMoneyDetailsService userMoneyDetailsService;
|
||||||
|
@Resource
|
||||||
|
private WuyouPay wuyouPay;
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params) {
|
public void run(String params) {
|
||||||
logger.info("提现开始");
|
logger.info("提现开始");
|
||||||
if (StringUtils.isBlank(params) || isValidDate(params)) {
|
if (StringUtils.isBlank(params) || isValidDate(params)) {
|
||||||
@@ -47,11 +49,11 @@ public class CashOutTask2 implements ITask {
|
|||||||
.lt("create_at", params + " 23:59:59"));
|
.lt("create_at", params + " 23:59:59"));
|
||||||
System.out.println(cashOuts.size());
|
System.out.println(cashOuts.size());
|
||||||
for (CashOut cashOut : cashOuts) {
|
for (CashOut cashOut : cashOuts) {
|
||||||
if (WuyouPay.checkCanCash(cashOut.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, new BigDecimal(cashOut.getMoney()))) {
|
if (wuyouPay.checkCanCash(cashOut.getUserId(), WithdrawTypeEnum.RED_ENVELOPE, new BigDecimal(cashOut.getMoney()))) {
|
||||||
cashOut.setState(4);
|
cashOut.setState(4);
|
||||||
String outOrderNo = AliPayOrderUtil.createOrderId();
|
String outOrderNo = AliPayOrderUtil.createOrderId();
|
||||||
cashOut.setOrderNumber(outOrderNo);
|
cashOut.setOrderNumber(outOrderNo);
|
||||||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||||
if (baseResp.getStatus() != null && baseResp.getStatus().equals(2)) {
|
if (baseResp.getStatus() != null && baseResp.getStatus().equals(2)) {
|
||||||
cashOut.setState(1);
|
cashOut.setState(1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.sqx.modules.job.task;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务接口,所有定时任务都要实现该接口
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface ITask {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行定时任务接口
|
|
||||||
*
|
|
||||||
* @param params 参数,多参数使用JSON数据
|
|
||||||
*/
|
|
||||||
void run(String params);
|
|
||||||
}
|
|
||||||
@@ -9,14 +9,17 @@ import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component("SpinningTask3")
|
@Component
|
||||||
public class SpinningTask3 implements ITask {
|
@EnableScheduling
|
||||||
|
public class SpinningTask3 {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DiscSpinningService spinningController;
|
private DiscSpinningService spinningController;
|
||||||
@@ -25,8 +28,12 @@ public class SpinningTask3 implements ITask {
|
|||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
@Scheduled(cron = "0 0/2 * * * ? ")
|
||||||
public void run(String params) {
|
public void record() {
|
||||||
|
record("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void record(String params) {
|
||||||
logger.info("大转盘到账补偿机制");
|
logger.info("大转盘到账补偿机制");
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
Date now = DateUtil.date();
|
Date now = DateUtil.date();
|
||||||
@@ -48,6 +55,7 @@ public class SpinningTask3 implements ITask {
|
|||||||
recordQueryWrapper.lt("create_time", fiveMinutesAgoStr);
|
recordQueryWrapper.lt("create_time", fiveMinutesAgoStr);
|
||||||
//小于
|
//小于
|
||||||
recordQueryWrapper.gt("create_time", tenMinutesAgoStr);
|
recordQueryWrapper.gt("create_time", tenMinutesAgoStr);
|
||||||
|
logger.info("大转盘到账补偿时间范围:{}-----{}", tenMinutesAgoStr, fiveMinutesAgoStr);
|
||||||
List<DiscSpinningRecord> list = recordService.list(recordQueryWrapper);
|
List<DiscSpinningRecord> list = recordService.list(recordQueryWrapper);
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
for (DiscSpinningRecord record : list) {
|
for (DiscSpinningRecord record : list) {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
* @author GYJoker
|
* @author GYJoker
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component("SupplyAgainSignRewardTask")
|
@Component
|
||||||
public class SupplyAgainSignRewardTask implements ITask {
|
public class SupplyAgainSignRewardTask{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@@ -35,7 +35,6 @@ public class SupplyAgainSignRewardTask implements ITask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserMoneyService userMoneyService;
|
private UserMoneyService userMoneyService;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params) {
|
public void run(String params) {
|
||||||
if (StringUtils.isBlank(params)) {
|
if (StringUtils.isBlank(params)) {
|
||||||
log.error("参数为空");
|
log.error("参数为空");
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.sqx.modules.job.task;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
|
||||||
import com.sqx.modules.pay.dao.CashOutDao;
|
import com.sqx.modules.pay.dao.CashOutDao;
|
||||||
import com.sqx.modules.pay.entity.CashOut;
|
import com.sqx.modules.pay.entity.CashOut;
|
||||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||||
@@ -15,24 +13,21 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component("TempCashOutTask")
|
@Component
|
||||||
public class TempCashOutTask implements ITask {
|
public class TempCashOutTask{
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CashOutDao cashOutDao;
|
private CashOutDao cashOutDao;
|
||||||
@Resource
|
@Resource
|
||||||
private UserMoneyService userMoneyService;
|
private WuyouPay wuyouPay;
|
||||||
@Resource
|
|
||||||
private UserMoneyDetailsService userMoneyDetailsService;
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params) {
|
public void run(String params) {
|
||||||
logger.info("提现开始");
|
logger.info("提现开始");
|
||||||
List<CashOut> cashOuts = cashOutDao.selectTemp();
|
List<CashOut> cashOuts = cashOutDao.selectTemp();
|
||||||
for (CashOut cashOut : cashOuts) {
|
for (CashOut cashOut : cashOuts) {
|
||||||
BaseResp baseResp = WuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getMoney());
|
BaseResp baseResp = wuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getMoney());
|
||||||
logger.info("baseResp:{} ", JSONUtil.toJsonStr(baseResp));
|
logger.info("baseResp:{} ", JSONUtil.toJsonStr(baseResp));
|
||||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){
|
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){
|
||||||
logger.info("success:{} ", cashOut.getOrderNumber());
|
logger.info("success:{} ", cashOut.getOrderNumber());
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("TempOrdersTask")
|
@Component
|
||||||
public class TempOrdersTask implements ITask {
|
public class TempOrdersTask {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OrdersDao ordersDao;
|
private OrdersDao ordersDao;
|
||||||
@@ -65,11 +65,12 @@ public class TempOrdersTask implements ITask {
|
|||||||
private InviteDao inviteDao;
|
private InviteDao inviteDao;
|
||||||
@Resource
|
@Resource
|
||||||
private CompletAwardService completAwardService;
|
private CompletAwardService completAwardService;
|
||||||
|
@Resource
|
||||||
|
private WuyouPay wuyouPay;
|
||||||
|
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params) {
|
public void run(String params) {
|
||||||
logger.info("订单表数据处理开始");
|
logger.info("订单表数据处理开始");
|
||||||
List<Orders> orders = ordersDao.selectList(Wrappers.<Orders>lambdaQuery()
|
List<Orders> orders = ordersDao.selectList(Wrappers.<Orders>lambdaQuery()
|
||||||
@@ -92,7 +93,7 @@ public class TempOrdersTask implements ITask {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BaseResp baseResp = WuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/131.0.0.0");
|
BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/131.0.0.0");
|
||||||
logger.info("baseResp:{} ", JSONUtil.toJsonStr(baseResp));
|
logger.info("baseResp:{} ", JSONUtil.toJsonStr(baseResp));
|
||||||
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
||||||
continue;
|
continue;
|
||||||
@@ -104,13 +105,13 @@ public class TempOrdersTask implements ITask {
|
|||||||
logger.info("payDetails:{} ", JSONUtil.toJsonStr(payDetails));
|
logger.info("payDetails:{} ", JSONUtil.toJsonStr(payDetails));
|
||||||
logger.info("order:{} ", JSONUtil.toJsonStr(order));
|
logger.info("order:{} ", JSONUtil.toJsonStr(order));
|
||||||
updateOrderStatus(payDetails, order);
|
updateOrderStatus(payDetails, order);
|
||||||
}else {
|
} else {
|
||||||
order.setStatus(3);
|
order.setStatus(3);
|
||||||
payDetails.setState(2);
|
payDetails.setState(2);
|
||||||
ordersDao.updateById(order);
|
ordersDao.updateById(order);
|
||||||
payDetailsDao.updateById(payDetails);
|
payDetailsDao.updateById(payDetails);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("订单数据处理异常:", e);
|
logger.error("订单数据处理异常:", e);
|
||||||
}
|
}
|
||||||
@@ -119,17 +120,13 @@ public class TempOrdersTask implements ITask {
|
|||||||
logger.info("订单表数据处理完毕");
|
logger.info("订单表数据处理完毕");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
WuyouPay.queryOrder("1000001323859732", "0.5", "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/131.0.0.0");
|
|
||||||
}
|
|
||||||
|
|
||||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
private void updateOrderStatus(PayDetails payDetails, Orders order) {
|
private void updateOrderStatus(PayDetails payDetails, Orders order) {
|
||||||
|
|
||||||
|
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(), 1, format, payDetails.getTradeNo());
|
payDetailsDao.updateState(payDetails.getId(), 1, format, payDetails.getTradeNo(), payDetails.getThirdOrderNo());
|
||||||
|
|
||||||
order.setPayWay(9);
|
order.setPayWay(9);
|
||||||
order.setStatus(1);
|
order.setStatus(1);
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.sqx.modules.job.task;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 测试定时任务(演示Demo,可删除)
|
|
||||||
*
|
|
||||||
* testTask为spring bean的名称
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Component("testTask")
|
|
||||||
public class TestTask implements ITask {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String params){
|
|
||||||
|
|
||||||
logger.debug("TestTask定时任务正在执行,参数为:{}", params);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package com.sqx.modules.job.utils;
|
|
||||||
|
|
||||||
import com.sqx.common.utils.SpringContextUtils;
|
|
||||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
|
||||||
import com.sqx.modules.job.entity.ScheduleJobLogEntity;
|
|
||||||
import com.sqx.modules.job.service.ScheduleJobLogService;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import org.quartz.JobExecutionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ScheduleJob extends QuartzJobBean {
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
|
||||||
ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap()
|
|
||||||
.get(ScheduleJobEntity.JOB_PARAM_KEY);
|
|
||||||
|
|
||||||
//获取spring bean
|
|
||||||
ScheduleJobLogService scheduleJobLogService = (ScheduleJobLogService) SpringContextUtils.getBean("scheduleJobLogService");
|
|
||||||
|
|
||||||
//数据库保存执行记录
|
|
||||||
ScheduleJobLogEntity log = new ScheduleJobLogEntity();
|
|
||||||
log.setJobId(scheduleJob.getJobId());
|
|
||||||
log.setBeanName(scheduleJob.getBeanName());
|
|
||||||
log.setParams(scheduleJob.getParams());
|
|
||||||
log.setCreateTime(new Date());
|
|
||||||
|
|
||||||
//任务开始时间
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
try {
|
|
||||||
//执行任务
|
|
||||||
logger.debug("任务准备执行,任务ID:" + scheduleJob.getJobId());
|
|
||||||
|
|
||||||
Object target = SpringContextUtils.getBean(scheduleJob.getBeanName());
|
|
||||||
Method method = target.getClass().getDeclaredMethod("run", String.class);
|
|
||||||
method.invoke(target, scheduleJob.getParams());
|
|
||||||
|
|
||||||
//任务执行总时长
|
|
||||||
long times = System.currentTimeMillis() - startTime;
|
|
||||||
log.setTimes((int)times);
|
|
||||||
//任务状态 0:成功 1:失败
|
|
||||||
log.setStatus(0);
|
|
||||||
|
|
||||||
logger.debug("任务执行完毕,任务ID:" + scheduleJob.getJobId() + " 总共耗时:" + times + "毫秒");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("任务执行失败,任务ID:" + scheduleJob.getJobId(), e);
|
|
||||||
|
|
||||||
//任务执行总时长
|
|
||||||
long times = System.currentTimeMillis() - startTime;
|
|
||||||
log.setTimes((int)times);
|
|
||||||
|
|
||||||
//任务状态 0:成功 1:失败
|
|
||||||
log.setStatus(1);
|
|
||||||
log.setError(StringUtils.substring(e.toString(), 0, 2000));
|
|
||||||
}finally {
|
|
||||||
scheduleJobLogService.save(log);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
package com.sqx.modules.job.utils;
|
|
||||||
|
|
||||||
import com.sqx.common.exception.SqxException;
|
|
||||||
import com.sqx.common.utils.Constant;
|
|
||||||
import com.sqx.modules.job.entity.ScheduleJobEntity;
|
|
||||||
import org.quartz.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务工具类
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ScheduleUtils {
|
|
||||||
private final static String JOB_NAME = "TASK_";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取触发器key
|
|
||||||
*/
|
|
||||||
public static TriggerKey getTriggerKey(Long jobId) {
|
|
||||||
return TriggerKey.triggerKey(JOB_NAME + jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取jobKey
|
|
||||||
*/
|
|
||||||
public static JobKey getJobKey(Long jobId) {
|
|
||||||
return JobKey.jobKey(JOB_NAME + jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取表达式触发器
|
|
||||||
*/
|
|
||||||
public static CronTrigger getCronTrigger(Scheduler scheduler, Long jobId) {
|
|
||||||
try {
|
|
||||||
return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId));
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("获取定时任务CronTrigger出现异常", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建定时任务
|
|
||||||
*/
|
|
||||||
public static void createScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
|
||||||
try {
|
|
||||||
//构建job信息
|
|
||||||
JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(scheduleJob.getJobId())).build();
|
|
||||||
|
|
||||||
//表达式调度构建器
|
|
||||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
|
|
||||||
.withMisfireHandlingInstructionDoNothing();
|
|
||||||
|
|
||||||
//按新的cronExpression表达式构建一个新的trigger
|
|
||||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(scheduleJob.getJobId())).withSchedule(scheduleBuilder).build();
|
|
||||||
|
|
||||||
//放入参数,运行时的方法可以获取
|
|
||||||
jobDetail.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
|
||||||
|
|
||||||
scheduler.scheduleJob(jobDetail, trigger);
|
|
||||||
|
|
||||||
//暂停任务
|
|
||||||
if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){
|
|
||||||
pauseJob(scheduler, scheduleJob.getJobId());
|
|
||||||
}
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("创建定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新定时任务
|
|
||||||
*/
|
|
||||||
public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
|
||||||
try {
|
|
||||||
TriggerKey triggerKey = getTriggerKey(scheduleJob.getJobId());
|
|
||||||
|
|
||||||
//表达式调度构建器
|
|
||||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
|
|
||||||
.withMisfireHandlingInstructionDoNothing();
|
|
||||||
|
|
||||||
CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getJobId());
|
|
||||||
|
|
||||||
//按新的cronExpression表达式重新构建trigger
|
|
||||||
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
|
||||||
|
|
||||||
//参数
|
|
||||||
trigger.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
|
||||||
|
|
||||||
scheduler.rescheduleJob(triggerKey, trigger);
|
|
||||||
|
|
||||||
//暂停任务
|
|
||||||
if(scheduleJob.getStatus() == Constant.ScheduleStatus.PAUSE.getValue()){
|
|
||||||
pauseJob(scheduler, scheduleJob.getJobId());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("更新定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 立即执行任务
|
|
||||||
*/
|
|
||||||
public static void run(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
|
|
||||||
try {
|
|
||||||
//参数
|
|
||||||
JobDataMap dataMap = new JobDataMap();
|
|
||||||
dataMap.put(ScheduleJobEntity.JOB_PARAM_KEY, scheduleJob);
|
|
||||||
|
|
||||||
scheduler.triggerJob(getJobKey(scheduleJob.getJobId()), dataMap);
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("立即执行定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停任务
|
|
||||||
*/
|
|
||||||
public static void pauseJob(Scheduler scheduler, Long jobId) {
|
|
||||||
try {
|
|
||||||
scheduler.pauseJob(getJobKey(jobId));
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("暂停定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复任务
|
|
||||||
*/
|
|
||||||
public static void resumeJob(Scheduler scheduler, Long jobId) {
|
|
||||||
try {
|
|
||||||
scheduler.resumeJob(getJobKey(jobId));
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("暂停定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除定时任务
|
|
||||||
*/
|
|
||||||
public static void deleteScheduleJob(Scheduler scheduler, Long jobId) {
|
|
||||||
try {
|
|
||||||
scheduler.deleteJob(getJobKey(jobId));
|
|
||||||
} catch (SchedulerException e) {
|
|
||||||
throw new SqxException("删除定时任务失败", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,6 +70,14 @@ public class AppMessageController {
|
|||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Login
|
||||||
|
@PostMapping("/sendMessage")
|
||||||
|
@ApiOperation("添加投诉")
|
||||||
|
public Result sendMessage(@RequestBody MessageInfo messageInfo){
|
||||||
|
messageService.saveBody(messageInfo);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class OrdersController extends AbstractController {
|
|||||||
Double tuiMemberOrdersMoney = ordersService.selectOrdersMoney(2, 2, flag, time, null, sysUserId);
|
Double tuiMemberOrdersMoney = ordersService.selectOrdersMoney(2, 2, flag, time, null, sysUserId);
|
||||||
//提现
|
//提现
|
||||||
Integer cashCount = cashOutDao.selectCount(new QueryWrapper<CashOut>()
|
Integer cashCount = cashOutDao.selectCount(new QueryWrapper<CashOut>()
|
||||||
.eq("sys_user_id", sysUserId)
|
// .eq("sys_user_id", sysUserId)
|
||||||
.eq("state", 1)
|
.eq("state", 1)
|
||||||
.gt("create_at", DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss")));
|
.gt("create_at", DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss")));
|
||||||
Double cashSum = cashOutDao.selectSysUserCashOutSum(sysUserId, DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss"));
|
Double cashSum = cashOutDao.selectSysUserCashOutSum(sysUserId, DateUtil.format(DateUtil.parse(time, "yyyy-MM-dd"), "yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.sqx.modules.pay.controller.app.AliPayController;
|
|||||||
import com.sqx.modules.pay.service.DyService;
|
import com.sqx.modules.pay.service.DyService;
|
||||||
import com.sqx.modules.pay.service.WxService;
|
import com.sqx.modules.pay.service.WxService;
|
||||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||||
|
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -657,8 +658,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
Integer flag, String time, String userName, Integer ordersType, String startTime, String endTime,
|
Integer flag, String time, String userName, Integer ordersType, String startTime, String endTime,
|
||||||
Long sysUserId, String qdCode, String sysUserName) {
|
Long sysUserId, String qdCode, String sysUserName) {
|
||||||
Page<Orders> pages = new Page<>(page, limit);
|
Page<Orders> pages = new Page<>(page, limit);
|
||||||
|
|
||||||
return Result.success().put("data", new PageUtils(baseMapper.selectOrdersByOrdersNo(pages, ordersNo, status, userId, courseId,
|
return Result.success().put("data", new PageUtils(baseMapper.selectOrdersByOrdersNo(pages, ordersNo, status, userId, courseId,
|
||||||
flag, time, userName, ordersType, startTime, endTime, sysUserId, qdCode, sysUserName)));
|
flag, time, userName, ordersType, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), sysUserId, qdCode, sysUserName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.sqx.modules.pay.controller;
|
package com.sqx.modules.pay.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.AlipayClient;
|
import com.alipay.api.AlipayClient;
|
||||||
@@ -211,9 +213,21 @@ public class CashController {
|
|||||||
@ApiOperation("财务提现统计")
|
@ApiOperation("财务提现统计")
|
||||||
@GetMapping("/statisticsCashMoney")
|
@GetMapping("/statisticsCashMoney")
|
||||||
public Result statisticsMoney(String time, Integer flag) {
|
public Result statisticsMoney(String time, Integer flag) {
|
||||||
Double sumMoney = cashOutService.sumMoney(time, flag);
|
DateTime parse = DateUtil.parse(time, "yyyy-MM-dd");
|
||||||
Integer countMoney = cashOutService.countMoney(time, flag);
|
|
||||||
Integer stayMoney = cashOutService.stayMoney(time, flag);
|
String startTime = DateUtil.format(parse, "yyyy-MM-dd 00:00:00");
|
||||||
|
String endTime = DateUtil.format(parse, "yyyy-MM-dd 23:59:59");
|
||||||
|
if (flag == 2) {
|
||||||
|
startTime = DateUtil.format(DateUtil.beginOfMonth(parse), "yyyy-MM-dd 00:00:00");
|
||||||
|
endTime = DateUtil.format(DateUtil.endOfMonth(parse), "yyyy-MM-dd 23:59:59");
|
||||||
|
} else if (flag == 3) {
|
||||||
|
startTime = DateUtil.format(DateUtil.beginOfYear(parse), "yyyy-MM-dd 00:00:00");
|
||||||
|
endTime = DateUtil.format(DateUtil.endOfYear(parse), "yyyy-MM-dd 23:59:59");
|
||||||
|
}
|
||||||
|
|
||||||
|
Double sumMoney = cashOutService.sumMoney(startTime, endTime, flag);
|
||||||
|
Integer countMoney = cashOutService.countMoney(startTime, endTime, flag);
|
||||||
|
Integer stayMoney = cashOutService.stayMoney(startTime, endTime, flag);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
map.put("sumMoney", sumMoney == null ? 0.00 : sumMoney);
|
map.put("sumMoney", sumMoney == null ? 0.00 : sumMoney);
|
||||||
map.put("countMoney", countMoney == null ? 0 : countMoney);
|
map.put("countMoney", countMoney == null ? 0 : countMoney);
|
||||||
|
|||||||
@@ -32,9 +32,6 @@ import com.sqx.modules.pay.dao.PayDetailsDao;
|
|||||||
import com.sqx.modules.pay.entity.PayClassify;
|
import com.sqx.modules.pay.entity.PayClassify;
|
||||||
import com.sqx.modules.pay.entity.PayDetails;
|
import com.sqx.modules.pay.entity.PayDetails;
|
||||||
import com.sqx.modules.pay.service.PayClassifyService;
|
import com.sqx.modules.pay.service.PayClassifyService;
|
||||||
import com.yungouos.pay.alipay.AliPay;
|
|
||||||
import com.yungouos.pay.entity.AliPayH5Biz;
|
|
||||||
import com.yungouos.pay.util.PaySignUtil;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -109,16 +106,16 @@ public class AliPayController {
|
|||||||
log.info(flag + "回调验证信息");
|
log.info(flag + "回调验证信息");
|
||||||
if (flag) {
|
if (flag) {
|
||||||
String tradeStatus = params.get("trade_status");
|
String tradeStatus = params.get("trade_status");
|
||||||
if("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)){
|
if ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus)) {
|
||||||
//支付宝返回的订单编号
|
//支付宝返回的订单编号
|
||||||
String outTradeNo = params.get("out_trade_no");
|
String outTradeNo = params.get("out_trade_no");
|
||||||
//支付宝支付单号
|
//支付宝支付单号
|
||||||
String tradeNo = params.get("trade_no");
|
String tradeNo = params.get("trade_no");
|
||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(outTradeNo);
|
||||||
if(payDetails.getState()==0){
|
if (payDetails.getState() == 0) {
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,tradeNo);
|
payDetailsDao.updateState(payDetails.getId(), 1, format, tradeNo,"");
|
||||||
if(payDetails.getType()==1){
|
if (payDetails.getType() == 1) {
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayWay(4);
|
orders.setPayWay(4);
|
||||||
orders.setStatus(1);
|
orders.setStatus(1);
|
||||||
@@ -128,34 +125,34 @@ public class AliPayController {
|
|||||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||||
Map map = inviteService.updateInvite(byUser, format, user.getUserId(), orders.getPayMoney());
|
Map map = inviteService.updateInvite(byUser, format, user.getUserId(), orders.getPayMoney());
|
||||||
Object oneUserId = map.get("oneUserId");
|
Object oneUserId = map.get("oneUserId");
|
||||||
if(oneUserId!=null){
|
if (oneUserId != null) {
|
||||||
orders.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
orders.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
||||||
orders.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
orders.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
||||||
}
|
}
|
||||||
Object twoUserId = map.get("twoUserId");
|
Object twoUserId = map.get("twoUserId");
|
||||||
if(twoUserId!=null){
|
if (twoUserId != null) {
|
||||||
orders.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
orders.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
||||||
orders.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
orders.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
||||||
}
|
}
|
||||||
Object sysUserId = map.get("sysUserId");
|
Object sysUserId = map.get("sysUserId");
|
||||||
if(sysUserId!=null){
|
if (sysUserId != null) {
|
||||||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||||
}
|
}
|
||||||
ordersService.updateById(orders);
|
ordersService.updateById(orders);
|
||||||
ordersService.insertOrders(orders);
|
ordersService.insertOrders(orders);
|
||||||
}else{
|
} else {
|
||||||
String remark = payDetails.getRemark();
|
String remark = payDetails.getRemark();
|
||||||
PayClassify payClassify = payClassifyService.getById(Long.parseLong(remark));
|
PayClassify payClassify = payClassifyService.getById(Long.parseLong(remark));
|
||||||
BigDecimal add = payClassify.getMoney().add(payClassify.getGiveMoney());
|
BigDecimal add = payClassify.getMoney().add(payClassify.getGiveMoney());
|
||||||
userMoneyService.updateMoney(1,payDetails.getUserId(),add.doubleValue());
|
userMoneyService.updateMoney(1, payDetails.getUserId(), add.doubleValue());
|
||||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||||
// ✅
|
// ✅
|
||||||
userMoneyDetails.setClassify(2);
|
userMoneyDetails.setClassify(2);
|
||||||
userMoneyDetails.setMoney(add);
|
userMoneyDetails.setMoney(add);
|
||||||
userMoneyDetails.setUserId(payDetails.getUserId());
|
userMoneyDetails.setUserId(payDetails.getUserId());
|
||||||
userMoneyDetails.setContent("支付宝充值金币");
|
userMoneyDetails.setContent("支付宝充值金币");
|
||||||
userMoneyDetails.setTitle("支付宝充值金币:"+payClassify.getMoney()+",赠送:"+payClassify.getGiveMoney());
|
userMoneyDetails.setTitle("支付宝充值金币:" + payClassify.getMoney() + ",赠送:" + payClassify.getGiveMoney());
|
||||||
userMoneyDetails.setType(1);
|
userMoneyDetails.setType(1);
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
||||||
@@ -179,92 +176,15 @@ public class AliPayController {
|
|||||||
@ApiOperation("支付宝回调")
|
@ApiOperation("支付宝回调")
|
||||||
@RequestMapping("/notifyAppYunOS")
|
@RequestMapping("/notifyAppYunOS")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String notifyAppYunOS(HttpServletRequest request, HttpServletResponse response){
|
public String notifyAppYunOS(HttpServletRequest request, HttpServletResponse response) {
|
||||||
//获取支付宝POST过来反馈信息
|
return "SUCCESS";
|
||||||
Map<String,String> params = new HashMap<String,String>();
|
|
||||||
Map requestParams = request.getParameterMap();
|
|
||||||
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
|
|
||||||
String name = (String) iter.next();
|
|
||||||
String[] values = (String[]) requestParams.get(name);
|
|
||||||
String valueStr = "";
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
|
||||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
|
||||||
: valueStr + values[i] + ",";
|
|
||||||
}
|
|
||||||
//乱码解决,这段代码在出现乱码时使用。
|
|
||||||
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
|
||||||
params.put(name, valueStr);
|
|
||||||
}
|
|
||||||
String outTradeNo = params.get("outTradeNo");
|
|
||||||
String code = params.get("code");
|
|
||||||
String key = commonInfoService.findOne(169).getValue();
|
|
||||||
try {
|
|
||||||
boolean flag = PaySignUtil.checkNotifySign(request, key);
|
|
||||||
if(flag){
|
|
||||||
if("1".equals(code)){
|
|
||||||
PayDetails payDetails=payDetailsDao.selectByOrderId(outTradeNo);
|
|
||||||
if(payDetails.getState()==0) {
|
|
||||||
String format = sdf.format(new Date());
|
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,null);
|
|
||||||
if(payDetails.getType()==1){
|
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
|
||||||
orders.setPayWay(4);
|
|
||||||
orders.setStatus(1);
|
|
||||||
orders.setPayTime(DateUtils.format(new Date()));
|
|
||||||
ordersService.updateById(orders);
|
|
||||||
UserEntity user = userService.selectUserById(orders.getUserId());
|
|
||||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
|
||||||
Map map = inviteService.updateInvite(byUser, format, user.getUserId(), orders.getPayMoney());
|
|
||||||
Object oneUserId = map.get("oneUserId");
|
|
||||||
if(oneUserId!=null){
|
|
||||||
orders.setOneUserId(Long.parseLong(String.valueOf(oneUserId)));
|
|
||||||
orders.setOneMoney(new BigDecimal(String.valueOf(map.get("oneMoney"))));
|
|
||||||
}
|
|
||||||
Object twoUserId = map.get("twoUserId");
|
|
||||||
if(twoUserId!=null){
|
|
||||||
orders.setTwoUserId(Long.parseLong(String.valueOf(twoUserId)));
|
|
||||||
orders.setTwoMoney(new BigDecimal(String.valueOf(map.get("twoMoney"))));
|
|
||||||
}
|
|
||||||
Object sysUserId = map.get("sysUserId");
|
|
||||||
if(sysUserId!=null){
|
|
||||||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
|
||||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
|
||||||
}
|
|
||||||
ordersService.insertOrders(orders);
|
|
||||||
}else{
|
|
||||||
String remark = payDetails.getRemark();
|
|
||||||
PayClassify payClassify = payClassifyService.getById(Long.parseLong(remark));
|
|
||||||
BigDecimal add = payClassify.getMoney().add(payClassify.getGiveMoney());
|
|
||||||
userMoneyService.updateMoney(1,payDetails.getUserId(),add.doubleValue());
|
|
||||||
UserMoneyDetails userMoneyDetails=new UserMoneyDetails();
|
|
||||||
// ✅
|
|
||||||
userMoneyDetails.setClassify(2);
|
|
||||||
userMoneyDetails.setMoney(add);
|
|
||||||
userMoneyDetails.setUserId(payDetails.getUserId());
|
|
||||||
userMoneyDetails.setContent("支付宝充值金币");
|
|
||||||
userMoneyDetails.setTitle("支付宝充值金币:"+payClassify.getMoney()+",赠送:"+payClassify.getGiveMoney());
|
|
||||||
userMoneyDetails.setType(1);
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
|
|
||||||
userMoneyDetails.setMoneyType(2);
|
|
||||||
userMoneyDetailsService.save(userMoneyDetails);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "SUCCESS";
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
log.error("云购os支付报错!"+e.getMessage());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Login
|
@Login
|
||||||
@ApiOperation("支付宝支付订单")
|
@ApiOperation("支付宝支付订单")
|
||||||
@RequestMapping(value = "/payOrder", method = RequestMethod.POST)
|
@RequestMapping(value = "/payOrder", method = RequestMethod.POST)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result payOrder(Long orderId,Integer classify) {
|
public Result payOrder(Long orderId, Integer classify) {
|
||||||
//通知页面地址
|
//通知页面地址
|
||||||
CommonInfo one = commonInfoService.findOne(19);
|
CommonInfo one = commonInfoService.findOne(19);
|
||||||
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
||||||
@@ -274,17 +194,17 @@ public class AliPayController {
|
|||||||
log.info("回调地址:" + url);
|
log.info("回调地址:" + url);
|
||||||
Orders orders = ordersDao.selectById(orderId);
|
Orders orders = ordersDao.selectById(orderId);
|
||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(orders.getOrdersNo());
|
PayDetails payDetails = payDetailsDao.selectByOrderId(orders.getOrdersNo());
|
||||||
if(payDetails==null){
|
if (payDetails == null) {
|
||||||
payDetails=new PayDetails();
|
payDetails = new PayDetails();
|
||||||
payDetails.setState(0);
|
payDetails.setState(0);
|
||||||
payDetails.setCreateTime(sdf.format(new Date()));
|
payDetails.setCreateTime(sdf.format(new Date()));
|
||||||
payDetails.setOrderId(orders.getOrdersNo());
|
payDetails.setOrderId(orders.getOrdersNo());
|
||||||
payDetails.setUserId(orders.getUserId());
|
payDetails.setUserId(orders.getUserId());
|
||||||
payDetails.setMoney(orders.getPayMoney().doubleValue());
|
payDetails.setMoney(orders.getPayMoney().doubleValue());
|
||||||
payDetails.setType(1);
|
payDetails.setType(1);
|
||||||
if(classify==1){
|
if (classify == 1) {
|
||||||
payDetails.setClassify(4);
|
payDetails.setClassify(4);
|
||||||
}else{
|
} else {
|
||||||
payDetails.setClassify(5);
|
payDetails.setClassify(5);
|
||||||
}
|
}
|
||||||
payDetailsDao.insert(payDetails);
|
payDetailsDao.insert(payDetails);
|
||||||
@@ -300,7 +220,7 @@ public class AliPayController {
|
|||||||
@ApiOperation("支付宝支付订单")
|
@ApiOperation("支付宝支付订单")
|
||||||
@RequestMapping(value = "/payMoney", method = RequestMethod.POST)
|
@RequestMapping(value = "/payMoney", method = RequestMethod.POST)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result payMoney(Long payClassifyId, Integer classify,@RequestAttribute Long userId) {
|
public Result payMoney(Long payClassifyId, Integer classify, @RequestAttribute Long userId) {
|
||||||
//通知页面地址
|
//通知页面地址
|
||||||
CommonInfo one = commonInfoService.findOne(19);
|
CommonInfo one = commonInfoService.findOne(19);
|
||||||
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
String returnUrl = one.getValue() + "/#/pages/task/recharge";
|
||||||
@@ -310,15 +230,15 @@ public class AliPayController {
|
|||||||
log.info("回调地址:" + url);
|
log.info("回调地址:" + url);
|
||||||
String generalOrder = getGeneralOrder();
|
String generalOrder = getGeneralOrder();
|
||||||
PayClassify payClassify = payClassifyService.getById(payClassifyId);
|
PayClassify payClassify = payClassifyService.getById(payClassifyId);
|
||||||
PayDetails payDetails=new PayDetails();
|
PayDetails payDetails = new PayDetails();
|
||||||
payDetails.setState(0);
|
payDetails.setState(0);
|
||||||
payDetails.setCreateTime(sdf.format(new Date()));
|
payDetails.setCreateTime(sdf.format(new Date()));
|
||||||
payDetails.setOrderId(generalOrder);
|
payDetails.setOrderId(generalOrder);
|
||||||
payDetails.setUserId(userId);
|
payDetails.setUserId(userId);
|
||||||
payDetails.setMoney(payClassify.getPrice().doubleValue());
|
payDetails.setMoney(payClassify.getPrice().doubleValue());
|
||||||
if(classify==1){
|
if (classify == 1) {
|
||||||
payDetails.setClassify(4);
|
payDetails.setClassify(4);
|
||||||
}else{
|
} else {
|
||||||
payDetails.setClassify(5);
|
payDetails.setClassify(5);
|
||||||
}
|
}
|
||||||
payDetails.setType(2);
|
payDetails.setType(2);
|
||||||
@@ -368,7 +288,6 @@ public class AliPayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Result payApp(String name, String generalOrder, Double money) {
|
public Result payApp(String name, String generalOrder, Double money) {
|
||||||
CommonInfo one = commonInfoService.findOne(19);
|
CommonInfo one = commonInfoService.findOne(19);
|
||||||
String url = one.getValue() + "/sqx_fast/app/aliPay/notifyApp";
|
String url = one.getValue() + "/sqx_fast/app/aliPay/notifyApp";
|
||||||
@@ -405,7 +324,7 @@ public class AliPayController {
|
|||||||
model.setSubject(name);
|
model.setSubject(name);
|
||||||
model.setOutTradeNo(generalOrder);
|
model.setOutTradeNo(generalOrder);
|
||||||
model.setTimeoutExpress("30m");
|
model.setTimeoutExpress("30m");
|
||||||
model.setTotalAmount(money +"");
|
model.setTotalAmount(money + "");
|
||||||
model.setProductCode("QUICK_MSECURITY_PAY");
|
model.setProductCode("QUICK_MSECURITY_PAY");
|
||||||
request.setBizModel(model);
|
request.setBizModel(model);
|
||||||
request.setNotifyUrl(url);
|
request.setNotifyUrl(url);
|
||||||
@@ -417,7 +336,7 @@ public class AliPayController {
|
|||||||
return Result.error("获取订单失败!");
|
return Result.error("获取订单失败!");
|
||||||
}
|
}
|
||||||
return Result.success().put("data", result);
|
return Result.success().put("data", result);
|
||||||
} else if("2".equals(payWay.getValue())){
|
} else if ("2".equals(payWay.getValue())) {
|
||||||
//实例化客户端
|
//实例化客户端
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
||||||
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
|
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
|
||||||
@@ -439,13 +358,6 @@ public class AliPayController {
|
|||||||
return Result.error("获取订单失败!");
|
return Result.error("获取订单失败!");
|
||||||
}
|
}
|
||||||
return Result.success().put("data", result);
|
return Result.success().put("data", result);
|
||||||
}else{
|
|
||||||
url=one.getValue()+"/sqx_fast/app/aliPay/notifyAppYunOS";
|
|
||||||
log.info("回调地址:"+url);
|
|
||||||
String mchId = commonInfoService.findOne(168).getValue();
|
|
||||||
String key = commonInfoService.findOne(169).getValue();
|
|
||||||
result = AliPay.appPay(generalOrder, String.valueOf(money), mchId, name ,null, url, null, null, null, null,key);
|
|
||||||
return Result.success().put("data", result);
|
|
||||||
}
|
}
|
||||||
} catch (AlipayApiException e) {
|
} catch (AlipayApiException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -491,7 +403,7 @@ public class AliPayController {
|
|||||||
alipayRequest.setReturnUrl(returnUrl); //线上通知页面地址
|
alipayRequest.setReturnUrl(returnUrl); //线上通知页面地址
|
||||||
String result = alipayClient.pageExecute(alipayRequest).getBody();
|
String result = alipayClient.pageExecute(alipayRequest).getBody();
|
||||||
return Result.success().put("data", result);
|
return Result.success().put("data", result);
|
||||||
} else if ("2".equals(payWay.getValue())){
|
} else if ("2".equals(payWay.getValue())) {
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", commonInfoService.findOne(63).getValue(), commonInfoService.findOne(65).getValue(), "json", AliPayConstants.CHARSET, commonInfoService.findOne(64).getValue(), "RSA2");
|
||||||
AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
|
AlipayTradeWapPayRequest alipayRequest = new AlipayTradeWapPayRequest();
|
||||||
JSONObject order = new JSONObject();
|
JSONObject order = new JSONObject();
|
||||||
@@ -507,13 +419,6 @@ public class AliPayController {
|
|||||||
alipayRequest.setReturnUrl(returnUrl);
|
alipayRequest.setReturnUrl(returnUrl);
|
||||||
String form = alipayClient.pageExecute(alipayRequest).getBody();
|
String form = alipayClient.pageExecute(alipayRequest).getBody();
|
||||||
return Result.success().put("data", form);
|
return Result.success().put("data", form);
|
||||||
}else{
|
|
||||||
url=one.getValue()+"/sqx_fast/app/aliPay/notifyAppYunOS";
|
|
||||||
log.info("回调地址:"+url);
|
|
||||||
String mchId = commonInfoService.findOne(168).getValue();
|
|
||||||
String key = commonInfoService.findOne(169).getValue();
|
|
||||||
AliPayH5Biz aliPayH5Biz = AliPay.h5Pay(generalOrder, String.valueOf(money), mchId, name, null, url, returnUrl, null, null, null,null,key);
|
|
||||||
return Result.success().put("data", aliPayH5Biz.getForm());
|
|
||||||
}
|
}
|
||||||
} catch (AlipayApiException e) {
|
} catch (AlipayApiException e) {
|
||||||
log.error("CreatPayOrderForH5", e);
|
log.error("CreatPayOrderForH5", e);
|
||||||
@@ -522,5 +427,4 @@ public class AliPayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import com.sqx.common.utils.ApiAccessLimitUtil;
|
|||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.RedisKeys;
|
import com.sqx.common.utils.RedisKeys;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.modules.app.entity.InviteAchievement;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.entity.UserEntity;
|
||||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||||
|
import com.sqx.modules.app.service.InviteAchievementService;
|
||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
import com.sqx.modules.app.service.UserMoneyService;
|
||||||
import com.sqx.modules.app.service.UserService;
|
import com.sqx.modules.app.service.UserService;
|
||||||
@@ -71,13 +73,13 @@ public class WuyouController {
|
|||||||
private final CashOutDao cashOutDao;
|
private final CashOutDao cashOutDao;
|
||||||
private final CompletAwardService completAwardService;
|
private final CompletAwardService completAwardService;
|
||||||
private final SysUserService sysUserService;
|
private final SysUserService sysUserService;
|
||||||
private final ApplicationContext applicationContext;
|
private final WuyouPay wuyouPay;
|
||||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
private final InviteAchievementService inviteAchievementService;
|
||||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
|
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
|
||||||
UserMoneyService userMoneyService, UserMoneyDetailsService userMoneyDetailsService, CommonInfoService commonRepository,
|
UserMoneyService userMoneyService, UserMoneyDetailsService userMoneyDetailsService, CommonInfoService commonRepository,
|
||||||
InviteDao inviteDao, CompletAwardService completAwardService, SysUserService sysUserService, ApplicationContext applicationContext) {
|
InviteDao inviteDao, CompletAwardService completAwardService, SysUserService sysUserService, WuyouPay wuyouPay, InviteAchievementService inviteAchievementService) {
|
||||||
this.ordersService = ordersService;
|
this.ordersService = ordersService;
|
||||||
this.payDetailsDao = payDetailsDao;
|
this.payDetailsDao = payDetailsDao;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
@@ -89,59 +91,59 @@ public class WuyouController {
|
|||||||
this.inviteDao = inviteDao;
|
this.inviteDao = inviteDao;
|
||||||
this.completAwardService = completAwardService;
|
this.completAwardService = completAwardService;
|
||||||
this.sysUserService = sysUserService;
|
this.sysUserService = sysUserService;
|
||||||
this.applicationContext = applicationContext;
|
this.wuyouPay = wuyouPay;
|
||||||
|
this.inviteAchievementService = inviteAchievementService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Debounce(interval = 1000, value = "#orderId")
|
@Debounce(interval = 1000, value = "#orderId")
|
||||||
@ApiOperation("支付订单")
|
@ApiOperation("支付订单")
|
||||||
@GetMapping("/payOrder/{orderId}")
|
@GetMapping("/payOrder/{orderId}")
|
||||||
public Result payOrder(HttpServletRequest request, @PathVariable("orderId") Long orderId, @RequestParam(value = "payType", required = false) String payType) {
|
public Result payOrder(HttpServletRequest request, @PathVariable("orderId") Long orderId, @RequestParam(value = "payType", required = false) String payType) {
|
||||||
return Result.error("暂无可支付渠道");
|
Orders order = ordersService.getById(orderId);
|
||||||
// Orders order = ordersService.getById(orderId);
|
if (order == null) {
|
||||||
// if (order == null) {
|
return Result.error("订单不存在");
|
||||||
// return Result.error("订单不存在");
|
}
|
||||||
// }
|
|
||||||
//
|
if (order.getStatus() != 0) {
|
||||||
// if (order.getStatus() != 0) {
|
return Result.error("订单已支付");
|
||||||
// return Result.error("订单已支付");
|
}
|
||||||
// }
|
|
||||||
//
|
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
||||||
// PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
if (payDetails == null) {
|
||||||
// if (payDetails == null) {
|
payDetails = new PayDetails();
|
||||||
// payDetails = new PayDetails();
|
payDetails.setState(0);
|
||||||
// payDetails.setState(0);
|
payDetails.setCreateTime(sdf.format(new Date()));
|
||||||
// payDetails.setCreateTime(sdf.format(new Date()));
|
payDetails.setOrderId(order.getOrdersNo());
|
||||||
// payDetails.setOrderId(order.getOrdersNo());
|
payDetails.setUserId(order.getUserId());
|
||||||
// payDetails.setUserId(order.getUserId());
|
payDetails.setMoney(order.getPayMoney().doubleValue());
|
||||||
// payDetails.setMoney(order.getPayMoney().doubleValue());
|
payDetails.setType(1);
|
||||||
// payDetails.setType(1);
|
payDetails.setClassify(9);
|
||||||
// payDetails.setClassify(9);
|
payDetails.setTradeNo(AliPayOrderUtil.createOrderId());
|
||||||
// payDetails.setTradeNo(AliPayOrderUtil.createOrderId());
|
payDetailsDao.insert(payDetails);
|
||||||
// payDetailsDao.insert(payDetails);
|
} else {
|
||||||
// } else {
|
payDetails.setTradeNo(AliPayOrderUtil.createOrderId());
|
||||||
// payDetails.setTradeNo(AliPayOrderUtil.createOrderId());
|
payDetailsDao.updateById(payDetails);
|
||||||
// payDetailsDao.updateById(payDetails);
|
}
|
||||||
// }
|
|
||||||
//
|
if (order.getPayMoney().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
// if (order.getPayMoney().compareTo(BigDecimal.ZERO) == 0) {
|
updateOrderStatus(payDetails, order);
|
||||||
// updateOrderStatus(payDetails, order);
|
Map<String, Object> data = new HashMap<>();
|
||||||
// Map<String, Object> data = new HashMap<>();
|
data.put("tradeNo", payDetails.getTradeNo());
|
||||||
// data.put("tradeNo", payDetails.getTradeNo());
|
data.put("payStatus", 1);
|
||||||
// data.put("payStatus", 1);
|
return Result.success().put("data", data);
|
||||||
// return Result.success().put("data", data);
|
}
|
||||||
// }
|
|
||||||
//
|
BaseResp baseResp = wuyouPay.payOrder(payDetails.getTradeNo(), order.getPayMoney().toString(),
|
||||||
// BaseResp baseResp = WuyouPay.payOrder(payDetails.getTradeNo(), order.getPayMoney().toString(),
|
request.getHeader("User-Agent"), String.format("%d-%d", order.getCourseId(), order.getCourseDetailsId()),
|
||||||
// request.getHeader("User-Agent"), String.format("%d-%d", order.getCourseId(), order.getCourseDetailsId()),
|
payType);
|
||||||
// payType);
|
if (baseResp.getCode() == null) {
|
||||||
// if (baseResp.getCode() == null) {
|
return Result.error(baseResp.getErrorMsg());
|
||||||
// return Result.error(baseResp.getErrorMsg());
|
}
|
||||||
// }
|
if (baseResp.getCode() != 200) {
|
||||||
// if (baseResp.getCode() != 200) {
|
return Result.error(baseResp.getMsg());
|
||||||
// return Result.error(baseResp.getMsg());
|
}
|
||||||
// }
|
|
||||||
//
|
return Result.success().put("data", baseResp.getData());
|
||||||
// return Result.success().put("data", baseResp.getData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询订单支付结果")
|
@ApiOperation("查询订单支付结果")
|
||||||
@@ -161,7 +163,7 @@ public class WuyouController {
|
|||||||
return Result.success().put("data", 1);
|
return Result.success().put("data", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseResp baseResp = WuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||||
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
||||||
return Result.success().put("data", 0);
|
return Result.success().put("data", 0);
|
||||||
}
|
}
|
||||||
@@ -245,54 +247,65 @@ public class WuyouController {
|
|||||||
if (sourceUser == null || sourceUser.getUserId() == 1) {
|
if (sourceUser == null || sourceUser.getUserId() == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper<>();
|
// QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("classify", 6);
|
// queryWrapper.eq("classify", 6);
|
||||||
queryWrapper.eq("user_id", sourceUser.getUserId());
|
// queryWrapper.eq("user_id", sourceUser.getUserId());
|
||||||
queryWrapper.eq("by_user_id", user.getUserId());
|
// queryWrapper.eq("by_user_id", user.getUserId());
|
||||||
int count = userMoneyDetailsService.count(queryWrapper);
|
// int count = userMoneyDetailsService.count(queryWrapper);
|
||||||
if (count == 0) {
|
InviteAchievement inviteAchievement = inviteAchievementService.getByUserId(user.getUserId());
|
||||||
|
// 首次达标
|
||||||
|
int signCount = Integer.parseInt(commonRepository.findOne(913).getValue());
|
||||||
|
if (inviteAchievement.getState() == 0 && inviteAchievement.getCount() >= signCount) {
|
||||||
//满3笔
|
//满3笔
|
||||||
Integer sumOrderNum = ordersService.countOrderNum(user.getUserId(), null);
|
// Integer sumOrderNum = ordersService.countOrderNum(user.getUserId(), null);
|
||||||
if (sumOrderNum >= Integer.parseInt(commonRepository.findOne(913).getValue())) {
|
// if (sumOrderNum >= Integer.parseInt(commonRepository.findOne(913).getValue())) {
|
||||||
String amount = commonRepository.findOne(912).getValue();
|
String amount = commonRepository.findOne(912).getValue();
|
||||||
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
|
||||||
userMoneyDetails.setClassify(6);
|
userMoneyDetails.setClassify(6);
|
||||||
userMoneyDetails.setMoney(new BigDecimal(amount));
|
userMoneyDetails.setMoney(new BigDecimal(amount));
|
||||||
userMoneyDetails.setUserId(sourceUser.getUserId());
|
userMoneyDetails.setUserId(sourceUser.getUserId());
|
||||||
userMoneyDetails.setByUserId(user.getUserId());
|
userMoneyDetails.setByUserId(user.getUserId());
|
||||||
userMoneyDetails.setCreateTime(DateUtil.now());
|
userMoneyDetails.setCreateTime(DateUtil.now());
|
||||||
userMoneyDetails.setContent("分享达标奖励" + amount + "元");
|
userMoneyDetails.setContent("分享达标奖励" + amount + "元");
|
||||||
userMoneyDetails.setTitle("分享达标奖励");
|
userMoneyDetails.setTitle("分享达标奖励");
|
||||||
userMoneyDetails.setState(2);
|
userMoneyDetails.setState(2);
|
||||||
userMoneyDetails.setType(1);
|
userMoneyDetails.setType(1);
|
||||||
userMoneyDetails.setMoneyType(1);
|
userMoneyDetails.setMoneyType(1);
|
||||||
userMoneyDetailsService.save(userMoneyDetails);
|
userMoneyDetailsService.save(userMoneyDetails);
|
||||||
//存入余额 钱
|
//存入余额 钱
|
||||||
userMoneyService.updateAmount(1, sourceUser.getUserId(), Double.parseDouble(amount));
|
userMoneyService.updateAmount(1, sourceUser.getUserId(), Double.parseDouble(amount));
|
||||||
|
|
||||||
|
inviteAchievement.setState(1);
|
||||||
|
inviteAchievementService.updateById(inviteAchievement);
|
||||||
|
|
||||||
|
int count = inviteAchievementService.countBySourceUserId(sourceUser.getUserId());
|
||||||
|
// 首次达标奖励
|
||||||
|
if (count == 1) {
|
||||||
SysUserEntity sysUser = sysUserService.selectSysUserByQdCode(user.getQdCode());
|
SysUserEntity sysUser = sysUserService.selectSysUserByQdCode(user.getQdCode());
|
||||||
String qdAward = commonRepository.findOne(915).getValue();
|
String qdAward = commonRepository.findOne(915).getValue();
|
||||||
|
|
||||||
UserMoneyDetails userMoneyDetails4 = new UserMoneyDetails(
|
UserMoneyDetails userMoneyDetails4 = new UserMoneyDetails(
|
||||||
null, sysUser == null ? null : sysUser.getUserId(), null, "[分享达标额外奖励]", 6, 1, 2,
|
null, sysUser == null ? null : sysUser.getUserId(), null, "[分享达标额外奖励]", 6, 1, 2,
|
||||||
new BigDecimal(qdAward), "推广人员首次达标,额外奖励现金红包" + qdAward, 2);
|
new BigDecimal(qdAward), "推广人员首次达标,额外奖励现金红包" + qdAward, 2);
|
||||||
|
|
||||||
userMoneyService.updateSysAmount(1, sysUser == null ? null : sysUser.getUserId(), Double.parseDouble(qdAward));
|
userMoneyService.updateSysAmount(1, sysUser == null ? null : sysUser.getUserId(), Double.parseDouble(qdAward));
|
||||||
userMoneyDetailsService.save(userMoneyDetails4);
|
userMoneyDetailsService.save(userMoneyDetails4);
|
||||||
|
|
||||||
Invite invite = inviteService.selectInviteByUser(sourceUser.getUserId(), user.getUserId(), 1);
|
|
||||||
if (invite != null) {
|
|
||||||
invite.setMoney(Double.valueOf(amount));
|
|
||||||
invite.setState(1);
|
|
||||||
inviteDao.updateById(invite);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Invite invite = inviteService.selectInviteByUser(sourceUser.getUserId(), user.getUserId(), 1);
|
||||||
|
if (invite != null) {
|
||||||
|
invite.setMoney(Double.valueOf(amount));
|
||||||
|
invite.setState(1);
|
||||||
|
inviteDao.updateById(invite);
|
||||||
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<UserMoneyDetails> moneyDetailsQuery = new QueryWrapper<>();
|
QueryWrapper<UserMoneyDetails> moneyDetailsQuery = new QueryWrapper<>();
|
||||||
moneyDetailsQuery.eq("classify", 6);
|
moneyDetailsQuery.eq("classify", 6);
|
||||||
moneyDetailsQuery.eq("user_id", sourceUser.getUserId());
|
moneyDetailsQuery.eq("user_id", sourceUser.getUserId());
|
||||||
//达标人数
|
//达标人数
|
||||||
int completeCount = userMoneyDetailsService.count(moneyDetailsQuery);
|
// int completeCount = userMoneyDetailsService.count(moneyDetailsQuery);
|
||||||
|
int completeCount = inviteAchievementService.countNum(sourceUser.getUserId(), signCount);
|
||||||
completAwardService.list(new QueryWrapper<CompletAward>().eq("invite_count", completeCount)).forEach(completAward -> {
|
completAwardService.list(new QueryWrapper<CompletAward>().eq("invite_count", completeCount)).forEach(completAward -> {
|
||||||
switch (completAward.getType()) {
|
switch (completAward.getType()) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -322,7 +335,7 @@ public class WuyouController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(), 1, format, payDetails.getTradeNo());
|
payDetailsDao.updateState(payDetails.getId(), 1, format, payDetails.getTradeNo(),payDetails.getThirdOrderNo());
|
||||||
|
|
||||||
order.setPayWay(9);
|
order.setPayWay(9);
|
||||||
order.setStatus(1);
|
order.setStatus(1);
|
||||||
@@ -348,6 +361,22 @@ public class WuyouController {
|
|||||||
}
|
}
|
||||||
ordersService.updateById(order);
|
ordersService.updateById(order);
|
||||||
ordersService.insertOrders(order);
|
ordersService.insertOrders(order);
|
||||||
|
|
||||||
|
if (byUser != null) {
|
||||||
|
InviteAchievement inviteAchievement = inviteAchievementService.getByUserId(user.getUserId());
|
||||||
|
if (inviteAchievement == null) {
|
||||||
|
inviteAchievement = new InviteAchievement();
|
||||||
|
inviteAchievement.setState(0);
|
||||||
|
inviteAchievement.setCount(1);
|
||||||
|
inviteAchievement.setCreateTime(DateUtil.date());
|
||||||
|
inviteAchievement.setUserId(user.getUserId());
|
||||||
|
inviteAchievement.setSourceUserId(byUser.getUserId());
|
||||||
|
inviteAchievementService.save(inviteAchievement);
|
||||||
|
} else {
|
||||||
|
inviteAchievementService.incrCount(inviteAchievement.getId(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
activities(user, byUser);
|
activities(user, byUser);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public interface CashOutDao extends BaseMapper<CashOut> {
|
|||||||
|
|
||||||
Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time);
|
Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time);
|
||||||
|
|
||||||
Double sumMoney(@Param("time") String time, @Param("flag") Integer flag);
|
Double sumMoney(@Param("start") String start, @Param("end") String end, @Param("flag") Integer flag);
|
||||||
|
|
||||||
Integer countMoney(@Param("time") String time, @Param("flag") Integer flag);
|
Integer countMoney(@Param("start") String start, @Param("end") String end, @Param("flag") Integer flag);
|
||||||
|
|
||||||
Integer stayMoney(@Param("time") String time, @Param("flag") Integer flag);
|
Integer stayMoney(@Param("start") String start, @Param("end") String end, @Param("flag") Integer flag);
|
||||||
|
|
||||||
void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money);
|
void updateMayMoney(@Param("type") Integer type, @Param("userId") Long userId, @Param("money") Double money);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public interface PayDetailsDao extends BaseMapper<PayDetails> {
|
|||||||
|
|
||||||
PayDetails selectByTradeNo(@Param("tradeNo") String tradeNo);
|
PayDetails selectByTradeNo(@Param("tradeNo") String tradeNo);
|
||||||
|
|
||||||
int updateState(@Param("id") Long id, @Param("state") Integer state, @Param("time") String time, @Param("tradeNo") String tradeNo);
|
int updateState(@Param("id") Long id, @Param("state") Integer state, @Param("time") String time, @Param("tradeNo") String tradeNo,@Param("thirdOrderNo") String thirdOrderNo);
|
||||||
|
|
||||||
IPage<Map<String, Object>> selectPayDetails(@Param("page") Page<Map<String, Object>> page, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") Long userId, @Param("state") Integer state, @Param("userName") String userName, String orderId);
|
IPage<Map<String, Object>> selectPayDetails(@Param("page") Page<Map<String, Object>> page, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("userId") Long userId, @Param("state") Integer state, @Param("userName") String userName, String orderId);
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ public interface CashOutService {
|
|||||||
|
|
||||||
Double selectCashOutSum(Long userId, Date startTime, Date endTime);
|
Double selectCashOutSum(Long userId, Date startTime, Date endTime);
|
||||||
|
|
||||||
Double sumMoney(String time, Integer flag);
|
Double sumMoney(String time, String end, Integer flag);
|
||||||
|
|
||||||
Integer countMoney(String time, Integer flag);
|
Integer countMoney(String time, String end, Integer flag);
|
||||||
|
|
||||||
Integer stayMoney(String time, Integer flag);
|
Integer stayMoney(String time, String end, Integer flag);
|
||||||
|
|
||||||
void updateMayMoney(int i, Long userId, Double money);
|
void updateMayMoney(int i, Long userId, Double money);
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserDao userDao;
|
private UserDao userDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WuyouPay wuyouPay;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut) {
|
public PageUtils selectCashOutList(Integer page, Integer limit, CashOut cashOut) {
|
||||||
return new PageUtils(baseMapper.selectCashOutPage(new Page<>(page, limit), cashOut));
|
return new PageUtils(baseMapper.selectCashOutPage(new Page<>(page, limit), cashOut));
|
||||||
@@ -247,18 +250,18 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double sumMoney(String time, Integer flag) {
|
public Double sumMoney(String start, String end, Integer flag) {
|
||||||
return cashOutDao.sumMoney(time, flag);
|
return cashOutDao.sumMoney(start, end, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer countMoney(String time, Integer flag) {
|
public Integer countMoney(String start, String end, Integer flag) {
|
||||||
return cashOutDao.countMoney(time, flag);
|
return cashOutDao.countMoney(start, end, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer stayMoney(String time, Integer flag) {
|
public Integer stayMoney(String start, String end, Integer flag) {
|
||||||
return cashOutDao.stayMoney(time, flag);
|
return cashOutDao.stayMoney(start, end, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -503,9 +506,9 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
return Result.success("可提现余额不足!");
|
return Result.success("可提现余额不足!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
if (wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
||||||
cashOut.setStatus(4);
|
cashOut.setStatus(4);
|
||||||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||||
userMoneyDetails.setContent("成功提现:" + money);
|
userMoneyDetails.setContent("成功提现:" + money);
|
||||||
cashOut.setState(1);
|
cashOut.setState(1);
|
||||||
@@ -590,7 +593,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||||||
entity.setOrderNumber(outOrderNo);
|
entity.setOrderNumber(outOrderNo);
|
||||||
}
|
}
|
||||||
// 执行提现操作
|
// 执行提现操作
|
||||||
BaseResp baseResp = WuyouPay.extractOrder(entity.getOrderNumber(), entity.getMoney(), entity.getZhifubao(), entity.getZhifubaoName());
|
BaseResp baseResp = wuyouPay.extractOrder(entity.getOrderNumber(), entity.getMoney(), entity.getZhifubao(), entity.getZhifubaoName());
|
||||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||||
entity.setState(1);
|
entity.setState(1);
|
||||||
} else if (StringUtils.isNotBlank(baseResp.getErrorMsg())) {
|
} else if (StringUtils.isNotBlank(baseResp.getErrorMsg())) {
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ public class DyServiceImpl implements DyService {
|
|||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
||||||
if(payDetails.getState()==0){
|
if(payDetails.getState()==0){
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,"");
|
payDetailsDao.updateState(payDetails.getId(),1,format,"","");
|
||||||
if(payDetails.getType()==1){
|
if(payDetails.getType()==1){
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayWay(7);
|
orders.setPayWay(7);
|
||||||
@@ -493,7 +493,7 @@ public class DyServiceImpl implements DyService {
|
|||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
||||||
if(payDetails.getState()==0){
|
if(payDetails.getState()==0){
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,"");
|
payDetailsDao.updateState(payDetails.getId(),1,format,"","");
|
||||||
if(payDetails.getType()==1){
|
if(payDetails.getType()==1){
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayWay(7);
|
orders.setPayWay(7);
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ public class KsServiceImpl implements KsService {
|
|||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(orderNo);
|
||||||
if(payDetails.getState()==0){
|
if(payDetails.getState()==0){
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,"");
|
payDetailsDao.updateState(payDetails.getId(),1,format,"","");
|
||||||
if(payDetails.getType()==1){
|
if(payDetails.getType()==1){
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayWay(8);
|
orders.setPayWay(8);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.sqx.common.utils.PageUtils;
|
|||||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||||
import com.sqx.modules.pay.entity.PayDetails;
|
import com.sqx.modules.pay.entity.PayDetails;
|
||||||
import com.sqx.modules.pay.service.PayDetailsService;
|
import com.sqx.modules.pay.service.PayDetailsService;
|
||||||
|
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -30,15 +31,15 @@ public class PayDetailsServiceImpl extends ServiceImpl<PayDetailsDao, PayDetails
|
|||||||
if (state != null && state == -1) {
|
if (state != null && state == -1) {
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
return new PageUtils(payDetailsDao.selectPayDetails(pages, startTime, endTime, userId, state,userName,orderId));
|
return new PageUtils(payDetailsDao.selectPayDetails(pages, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), userId, state,userName,orderId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double selectSumPay(String createTime, String endTime, Long userId) {
|
public Double selectSumPay(String createTime, String endTime, Long userId) {
|
||||||
if (userId == null || userId == -1) {
|
if (userId == null || userId == -1) {
|
||||||
return payDetailsDao.selectSumPay(createTime, endTime, null);
|
return payDetailsDao.selectSumPay(TimeCompleteUtils.completeStartTime(createTime), TimeCompleteUtils.completeEndTime(endTime), null);
|
||||||
}
|
}
|
||||||
return payDetailsDao.selectSumPay(createTime, endTime, userId);
|
return payDetailsDao.selectSumPay(TimeCompleteUtils.completeStartTime(createTime), TimeCompleteUtils.completeEndTime(endTime), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ public class WxServiceImpl implements WxService {
|
|||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no);
|
||||||
if(payDetails.getState()==0){
|
if(payDetails.getState()==0){
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,"");
|
payDetailsDao.updateState(payDetails.getId(),1,format,"","");
|
||||||
if(payDetails.getType()==1){
|
if(payDetails.getType()==1){
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayTime(DateUtils.format(new Date()));
|
orders.setPayTime(DateUtils.format(new Date()));
|
||||||
@@ -357,7 +357,7 @@ public class WxServiceImpl implements WxService {
|
|||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no);
|
PayDetails payDetails = payDetailsDao.selectByOrderId(out_trade_no);
|
||||||
if(payDetails.getState()==0){
|
if(payDetails.getState()==0){
|
||||||
String format = sdf.format(new Date());
|
String format = sdf.format(new Date());
|
||||||
payDetailsDao.updateState(payDetails.getId(),1,format,"");
|
payDetailsDao.updateState(payDetails.getId(),1,format,"","");
|
||||||
if(payDetails.getType()==1){
|
if(payDetails.getType()==1){
|
||||||
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
Orders orders = ordersService.selectOrderByOrdersNo(payDetails.getOrderId());
|
||||||
orders.setPayTime(DateUtils.format(new Date()));
|
orders.setPayTime(DateUtils.format(new Date()));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.sqx.modules.pay.wuyou;
|
package com.sqx.modules.pay.wuyou;
|
||||||
|
|
||||||
import com.alibaba.druid.util.Utils;
|
import com.sqx.modules.utils.MD5Util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -23,7 +23,7 @@ public class Encrypt {
|
|||||||
sb.append("key=").append(APP_SECRET);
|
sb.append("key=").append(APP_SECRET);
|
||||||
String signStr = sb.toString();
|
String signStr = sb.toString();
|
||||||
System.out.println("signStr: " + signStr);
|
System.out.println("signStr: " + signStr);
|
||||||
return Utils.md5(signStr).toUpperCase();
|
return MD5Util.encodeByMD5(signStr).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import com.sqx.modules.pay.dao.CashOutDao;
|
|||||||
import com.sqx.modules.pay.entity.WithdrawTypeEnum;
|
import com.sqx.modules.pay.entity.WithdrawTypeEnum;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -19,48 +20,39 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* @author GYJ
|
* @author GYJ
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class WuyouPay {
|
public class WuyouPay {
|
||||||
|
|
||||||
static String NOTIFY_URL = "";
|
@Value("${pay.orderNotifyUrl}")
|
||||||
static String EXTRACT_NOTIFY_URL = "";
|
private String notifyUrl = "";
|
||||||
static String H5_BASE_URL = "";
|
@Value("${pay.extractNotifyUrl}")
|
||||||
|
private String extractNotifyUrl = "";
|
||||||
|
@Value("${pay.h5BaseUrl}")
|
||||||
|
private String h5BaseUrl = "";
|
||||||
|
|
||||||
private static CashOutDao cashOutDao;
|
private final CashOutDao cashOutDao;
|
||||||
private static CommonInfoService commonInfoService;
|
private final CommonInfoService commonInfoService;
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WuyouPay.class);
|
private static final Logger logger = LoggerFactory.getLogger(WuyouPay.class);
|
||||||
|
|
||||||
public WuyouPay(CashOutDao cashOutDao, CommonInfoService commonInfoService) {
|
public WuyouPay(CashOutDao cashOutDao, CommonInfoService commonInfoService) {
|
||||||
WuyouPay.cashOutDao = cashOutDao;
|
this.cashOutDao = cashOutDao;
|
||||||
WuyouPay.commonInfoService = commonInfoService;
|
this.commonInfoService = commonInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNotifyUrl(String notifyUrl) {
|
public BaseResp payOrder(String orderNo, String amount, String userAgent, String allId, String payType) {
|
||||||
NOTIFY_URL = notifyUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setExtractNotifyUrl(String extractNotifyUrl) {
|
|
||||||
EXTRACT_NOTIFY_URL = extractNotifyUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setH5BaseUrl(String h5BaseUrl) {
|
|
||||||
H5_BASE_URL = h5BaseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BaseResp payOrder(String orderNo, String amount, String userAgent, String allId, String payType) {
|
|
||||||
Map<String, Object> params = getBaseParams();
|
Map<String, Object> params = getBaseParams();
|
||||||
params.put("type", "6001");
|
params.put("type", "6001");
|
||||||
params.put("is_code", "1");
|
params.put("is_code", "1");
|
||||||
params.put("out_trade_no", orderNo);
|
params.put("out_trade_no", orderNo);
|
||||||
params.put("total", amount);
|
params.put("total", amount);
|
||||||
params.put("notify_url", NOTIFY_URL);
|
params.put("notify_url", notifyUrl);
|
||||||
|
|
||||||
String sign = Encrypt.getParamsSign(params);
|
String sign = Encrypt.getParamsSign(params);
|
||||||
params.put("sign", sign);
|
params.put("sign", sign);
|
||||||
if ("h5".equals(payType)) {
|
if ("h5".equals(payType)) {
|
||||||
params.put("return_url", H5_BASE_URL + allId);
|
params.put("return_url", h5BaseUrl + allId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dj-h5.hnsiyao.cn/me/detail/detail?allId=1230-98688
|
// https://dj-h5.hnsiyao.cn/me/detail/detail?allId=1230-98688
|
||||||
@@ -70,7 +62,7 @@ public class WuyouPay {
|
|||||||
return JSONObject.parseObject(body, BaseResp.class);
|
return JSONObject.parseObject(body, BaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseResp queryOrder(String orderNo, String amount, String userAgent) {
|
public BaseResp queryOrder(String orderNo, String amount, String userAgent) {
|
||||||
Map<String, Object> params = getBaseParams();
|
Map<String, Object> params = getBaseParams();
|
||||||
params.put("out_trade_no", orderNo);
|
params.put("out_trade_no", orderNo);
|
||||||
params.put("total", amount);
|
params.put("total", amount);
|
||||||
@@ -82,10 +74,10 @@ public class WuyouPay {
|
|||||||
return JSONObject.parseObject(body, BaseResp.class);
|
return JSONObject.parseObject(body, BaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkCanCash(long userId, WithdrawTypeEnum type, BigDecimal money) {
|
public boolean checkCanCash(long userId, WithdrawTypeEnum type, BigDecimal money) {
|
||||||
if (WithdrawTypeEnum.MANUAL.equals(type)) {
|
if (WithdrawTypeEnum.MANUAL.equals(type)) {
|
||||||
// 查询当日体现次数
|
// 查询当日体现次数
|
||||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1, DateUtil.today()+ " 00:00:00");
|
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1, DateUtil.today() + " 00:00:00");
|
||||||
CommonInfo cashLimit = commonInfoService.findOne(922);
|
CommonInfo cashLimit = commonInfoService.findOne(922);
|
||||||
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
||||||
logger.warn("提现必要参数未配置,请联系管理员");
|
logger.warn("提现必要参数未配置,请联系管理员");
|
||||||
@@ -102,7 +94,7 @@ public class WuyouPay {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkCanCashByLimit(BigDecimal money) {
|
public boolean checkCanCashByLimit(BigDecimal money) {
|
||||||
CommonInfo info = commonInfoService.findOne(923);
|
CommonInfo info = commonInfoService.findOne(923);
|
||||||
if (info == null || StrUtil.isBlank(info.getValue())) {
|
if (info == null || StrUtil.isBlank(info.getValue())) {
|
||||||
logger.warn("未配置提现限制,请联系管理员配置");
|
logger.warn("未配置提现限制,请联系管理员配置");
|
||||||
@@ -114,11 +106,11 @@ public class WuyouPay {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 提现
|
* 提现
|
||||||
* @param account 支付宝账号
|
*
|
||||||
* @param userName 支付宝名称
|
* @param account 支付宝账号
|
||||||
* @return
|
* @param userName 支付宝名称
|
||||||
*/
|
*/
|
||||||
public static BaseResp extractOrder(String outOrderNo, String amount, String account, String userName) {
|
public BaseResp extractOrder(String outOrderNo, String amount, String account, String userName) {
|
||||||
Map<String, Object> params = getBaseParams();
|
Map<String, Object> params = getBaseParams();
|
||||||
|
|
||||||
params.put("out_trade_no", outOrderNo);
|
params.put("out_trade_no", outOrderNo);
|
||||||
@@ -129,7 +121,7 @@ public class WuyouPay {
|
|||||||
params.put("bank_branch", "1");
|
params.put("bank_branch", "1");
|
||||||
params.put("province", "1");
|
params.put("province", "1");
|
||||||
params.put("city", "1");
|
params.put("city", "1");
|
||||||
params.put("notify_url", EXTRACT_NOTIFY_URL);
|
params.put("notify_url", extractNotifyUrl);
|
||||||
|
|
||||||
String sign = Encrypt.getParamsSign(params);
|
String sign = Encrypt.getParamsSign(params);
|
||||||
params.put("sign", sign);
|
params.put("sign", sign);
|
||||||
@@ -141,7 +133,7 @@ public class WuyouPay {
|
|||||||
return JSONObject.parseObject(body, BaseResp.class);
|
return JSONObject.parseObject(body, BaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseResp queryExtractOrder(String outOrderNo, String amount) {
|
public BaseResp queryExtractOrder(String outOrderNo, String amount) {
|
||||||
Map<String, Object> params = getBaseParams();
|
Map<String, Object> params = getBaseParams();
|
||||||
params.put("out_trade_no", outOrderNo);
|
params.put("out_trade_no", outOrderNo);
|
||||||
params.put("total", amount);
|
params.put("total", amount);
|
||||||
@@ -153,7 +145,7 @@ public class WuyouPay {
|
|||||||
return JSONObject.parseObject(body, BaseResp.class);
|
return JSONObject.parseObject(body, BaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, Object> getBaseParams() {
|
private Map<String, Object> getBaseParams() {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("mch_id", Constants.MERCHANT_ID);
|
params.put("mch_id", Constants.MERCHANT_ID);
|
||||||
params.put("timestamp", System.currentTimeMillis() / 1000);
|
params.put("timestamp", System.currentTimeMillis() / 1000);
|
||||||
@@ -161,7 +153,7 @@ public class WuyouPay {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String request(String url, Map<String, Object> params, String userAgent) {
|
private String request(String url, Map<String, Object> params, String userAgent) {
|
||||||
String body = HttpRequest.post(url)
|
String body = HttpRequest.post(url)
|
||||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||||
.header("User-Agent", userAgent)
|
.header("User-Agent", userAgent)
|
||||||
@@ -181,6 +173,6 @@ public class WuyouPay {
|
|||||||
// extractOrder("20221118123456793", "1", "1157756119@qq.com", "巩奕杰");
|
// extractOrder("20221118123456793", "1", "1157756119@qq.com", "巩奕杰");
|
||||||
// queryExtractOrder("20221118123456793", "1");
|
// queryExtractOrder("20221118123456793", "1");
|
||||||
|
|
||||||
System.out.println(DateUtil.today()+ " 00:00:00");
|
System.out.println(DateUtil.today() + " 00:00:00");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,11 @@ public interface RedisService {
|
|||||||
Boolean getFreeWatchTimeIsExpire(Long userId);
|
Boolean getFreeWatchTimeIsExpire(Long userId);
|
||||||
|
|
||||||
Long getFreeWatchRemainTime(Long userId, boolean isPermanently);
|
Long getFreeWatchRemainTime(Long userId, boolean isPermanently);
|
||||||
|
|
||||||
|
boolean checkIpJumpLimit(long userId, String ip);
|
||||||
|
void recordUrlVisitCountWithIp(long userId, String url, String ip);
|
||||||
|
|
||||||
|
boolean isRecordUserOnLineTime(long userId);
|
||||||
|
|
||||||
|
boolean isSetUserState(long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,23 +12,36 @@ import com.sqx.modules.discSpinning.entity.DiscSpinningAmount;
|
|||||||
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
import com.sqx.modules.discSpinning.service.DiscSpinningAmountService;
|
||||||
import com.sqx.modules.redisService.RedisService;
|
import com.sqx.modules.redisService.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RedisServiceImpl implements RedisService {
|
public class RedisServiceImpl implements RedisService {
|
||||||
|
@Value("${limit.urlRate}")
|
||||||
|
private Integer urlLimitRate;
|
||||||
|
@Value("${limit.ipJumpLimit}")
|
||||||
|
private Integer ipJumpLimit;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtils redisUtils;
|
private RedisUtils redisUtils;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DiscSpinningAmountService amountService;
|
private DiscSpinningAmountService amountService;
|
||||||
|
private final StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
public RedisServiceImpl(StringRedisTemplate redisTemplate) {
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDiscSpinningAmounts(String key) {
|
public void setDiscSpinningAmounts(String key) {
|
||||||
@@ -84,7 +97,7 @@ public class RedisServiceImpl implements RedisService {
|
|||||||
expireTime = jsonObject.getLong("expireTime");
|
expireTime = jsonObject.getLong("expireTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((StrUtil.isNotBlank(permanentlyFreeWatch) && redisUtils.isExpiredSet(freeWatchKey)) || (StrUtil.isNotBlank(permanentlyFreeWatch) && DateUtil.current() >= expireTime)) {
|
if ((StrUtil.isNotBlank(permanentlyFreeWatch) && redisUtils.isExpiredSet(freeWatchKey)) || (StrUtil.isNotBlank(permanentlyFreeWatch) && DateUtil.current(false) >= expireTime)) {
|
||||||
if (StrUtil.isBlank(permanentlyFreeWatch)) {
|
if (StrUtil.isBlank(permanentlyFreeWatch)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -108,7 +121,7 @@ public class RedisServiceImpl implements RedisService {
|
|||||||
redisUtils.set(watchKey, jsonObject.toJSONString(), expire);
|
redisUtils.set(watchKey, jsonObject.toJSONString(), expire);
|
||||||
return false;
|
return false;
|
||||||
}else {
|
}else {
|
||||||
return DateUtil.current() > expireTime;
|
return DateUtil.current(false) > expireTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,6 +149,146 @@ public class RedisServiceImpl implements RedisService {
|
|||||||
Integer expireTime = jsonObject.getInteger("expireTime");
|
Integer expireTime = jsonObject.getInteger("expireTime");
|
||||||
Long second = jsonObject.getLong("second");
|
Long second = jsonObject.getLong("second");
|
||||||
|
|
||||||
return expireTime == -1 ? second : expireTime > DateUtil.current() ? expireTime - DateUtil.current() : 0L;
|
return expireTime == -1 ? second : expireTime > DateUtil.current(false) ? expireTime - DateUtil.current(false) : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean checkIpJumpLimit(long userId, String ip) {
|
||||||
|
String userKey = "user:" + userId + ":last_ip"; // 存储用户上次的 IP 地址
|
||||||
|
String lastIp = redisTemplate.opsForValue().get(userKey);
|
||||||
|
|
||||||
|
// 获取用户跳动的历史 IP 地址集合
|
||||||
|
String jumpHistoryKey = "user:" + userId + ":ip_history"; // 记录用户跳动过的 IP 地址
|
||||||
|
Set<String> jumpHistory = redisTemplate.opsForSet().members(jumpHistoryKey);
|
||||||
|
|
||||||
|
// 记录 IP 跳动次数
|
||||||
|
String ipTimestampKey = "user:" + userId + ":ip_timestamp"; // 记录每个 IP 跳动的过期时间
|
||||||
|
String userJumpCountKey = "user:" + userId + ":jump_count"; // 用户跳动的总次数
|
||||||
|
|
||||||
|
// 新增用于记录所有 IP 请求时间和次数的 Hash
|
||||||
|
String ipRequestsKey = "user:" + userId + ":ip_requests"; // 用来记录 IP 的请求次数和时间
|
||||||
|
|
||||||
|
|
||||||
|
// 如果用户之前没有记录过 IP,说明是第一次请求,直接保存
|
||||||
|
if (lastIp == null) {
|
||||||
|
redisTemplate.opsForValue().set(userKey, ip);
|
||||||
|
|
||||||
|
// 将当前 IP 添加到跳动历史中,设置 60 秒过期时间
|
||||||
|
redisTemplate.opsForSet().add(jumpHistoryKey, ip);
|
||||||
|
redisTemplate.expire(jumpHistoryKey, 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
// 设置该 IP 的过期时间为 60 秒,表示跳动记录会在 60 秒后过期
|
||||||
|
redisTemplate.opsForValue().set(ipTimestampKey + ":" + ip, "1", 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
// 记录用户 IP 请求的次数和时间
|
||||||
|
String ipData = DateUtil.date() + "|1"; // 时间和请求次数
|
||||||
|
redisTemplate.opsForHash().put(ipRequestsKey, ip, ipData);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前 IP 和上次 IP 不一致,说明发生了 IP 跳动
|
||||||
|
if (!lastIp.equals(ip)) {
|
||||||
|
// 判断当前 IP 是否在历史跳动的 IP 中
|
||||||
|
if (jumpHistory != null && jumpHistory.contains(ip)) {
|
||||||
|
// 如果当前 IP 存在于历史跳动记录中,认为是多节点登录,增加跳动次数
|
||||||
|
String s = redisTemplate.opsForValue().get(userJumpCountKey);
|
||||||
|
Integer currentJumpCount = s == null ? null : Integer.parseInt(s);
|
||||||
|
if (currentJumpCount == null) {
|
||||||
|
currentJumpCount = 0;
|
||||||
|
}
|
||||||
|
currentJumpCount++;
|
||||||
|
|
||||||
|
// 更新跳动次数
|
||||||
|
redisTemplate.opsForValue().set(userJumpCountKey, String.valueOf(currentJumpCount));
|
||||||
|
|
||||||
|
// 如果跳动次数超过限制,触发封禁
|
||||||
|
if (currentJumpCount >= ipJumpLimit) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户是否跳动过多次
|
||||||
|
if (jumpHistory != null && jumpHistory.size() >= ipJumpLimit) {
|
||||||
|
// 如果历史 IP 地址数超过最大跳动次数,触发封禁
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将当前 IP 添加到跳动历史中,设置 60 秒过期时间
|
||||||
|
redisTemplate.opsForSet().add(jumpHistoryKey, ip);
|
||||||
|
redisTemplate.expire(jumpHistoryKey, 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
// 更新用户的上次 IP 地址
|
||||||
|
redisTemplate.opsForValue().set(userKey, ip);
|
||||||
|
|
||||||
|
// 增加该 IP 的跳动计数,并设置过期时间为 60 秒
|
||||||
|
redisTemplate.opsForValue().increment(ipTimestampKey + ":" + ip, 1);
|
||||||
|
redisTemplate.expire(ipTimestampKey + ":" + ip, 1, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
// 记录该 IP 请求的次数和时间
|
||||||
|
String ipData = DateUtil.date() + "|1"; // 时间和请求次数
|
||||||
|
redisTemplate.opsForHash().put(ipRequestsKey, ip, ipData);
|
||||||
|
} else {
|
||||||
|
// 如果 IP 没有变化,更新该 IP 的请求次数和时间
|
||||||
|
String currentCount = (String) redisTemplate.opsForHash().get(ipRequestsKey, ip);
|
||||||
|
String[] ipData = currentCount != null ? currentCount.split("\\|") : new String[]{"", "0"};
|
||||||
|
int newCount = Integer.parseInt(ipData[1]) + 1; // 增加请求次数
|
||||||
|
|
||||||
|
// 更新新的时间和请求次数
|
||||||
|
String updatedIpData = DateUtil.date() + "|" + newCount;
|
||||||
|
redisTemplate.opsForHash().put(ipRequestsKey, ip, updatedIpData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSetUserState(long userId) {
|
||||||
|
String userKey = "user:" + userId + ":state"; // 存储用户上次的 IP 地址
|
||||||
|
String key = redisUtils.get(userKey);
|
||||||
|
if (StrUtil.isBlank(key)) {
|
||||||
|
DateTime date = DateUtil.date();
|
||||||
|
Date tomorrow = DateUtil.beginOfDay(DateUtil.offsetDay(date, 1));
|
||||||
|
long expire = DateUtil.between(date, tomorrow, DateUnit.SECOND);
|
||||||
|
redisUtils.set(key, userId, expire);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录用户访问 URL 的次数和 IP 地址
|
||||||
|
public void recordUrlVisitCountWithIp(long userId, String url, String ip) {
|
||||||
|
String userUrlKey = "user:" + userId + ":url:" + url; // 存储用户访问特定 URL 的数据
|
||||||
|
|
||||||
|
// 获取用户访问该 URL 的访问记录
|
||||||
|
Map<Object, Object> urlAccessInfo = redisTemplate.opsForHash().entries(userUrlKey);
|
||||||
|
|
||||||
|
// 记录访问次数的键名和每个 IP 地址的计数
|
||||||
|
String ipKey = "ip:" + ip;
|
||||||
|
int currentIpVisitCount = urlAccessInfo.containsKey(ipKey) ? Integer.parseInt(urlAccessInfo.get(ipKey).toString()) : 0;
|
||||||
|
|
||||||
|
// 更新该 IP 的访问计数
|
||||||
|
redisTemplate.opsForHash().put(userUrlKey, ipKey, String.valueOf(currentIpVisitCount + 1));
|
||||||
|
|
||||||
|
// 更新总的访问次数(不区分 IP)
|
||||||
|
int totalVisitCount = urlAccessInfo.containsKey("total") ? Integer.parseInt(urlAccessInfo.get("total").toString()) : 0;
|
||||||
|
redisTemplate.opsForHash().put(userUrlKey, "total", String.valueOf(totalVisitCount + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRecordUserOnLineTime(long userId) {
|
||||||
|
// Redis 键值为 "user:{userId}:last_call_time",存储的是用户最后一次调用接口的时间戳
|
||||||
|
String lastCallTimeKey = "user:" + userId + ":last_call_time";
|
||||||
|
|
||||||
|
// 获取 Redis 中存储的上次更新时间
|
||||||
|
String lastCallTimeStr = redisTemplate.opsForValue().get(lastCallTimeKey);
|
||||||
|
// 如果 Redis 中没有记录过,表示这是用户第一次调用接口
|
||||||
|
if (lastCallTimeStr == null) {
|
||||||
|
// 更新 Redis 中记录的最后调用时间
|
||||||
|
redisTemplate.opsForValue().set(lastCallTimeKey, String.valueOf(DateUtil.date().getTime()), 10, TimeUnit.MINUTES);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* oauth2过滤器
|
* oauth2过滤器
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class OAuth2Filter extends AuthenticatingFilter {
|
public class OAuth2Filter extends AuthenticatingFilter {
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
|||||||
//获取请求token
|
//获取请求token
|
||||||
String token = getRequestToken((HttpServletRequest) request);
|
String token = getRequestToken((HttpServletRequest) request);
|
||||||
|
|
||||||
if(StringUtils.isBlank(token)){
|
if (StringUtils.isBlank(token)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
||||||
if(((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())){
|
if (((HttpServletRequest) request).getMethod().equals(RequestMethod.OPTIONS.name())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +51,7 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
|||||||
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
|
||||||
//获取请求token,如果token不存在,直接返回401
|
//获取请求token,如果token不存在,直接返回401
|
||||||
String token = getRequestToken((HttpServletRequest) request);
|
String token = getRequestToken((HttpServletRequest) request);
|
||||||
if(StringUtils.isBlank(token)){
|
if (StringUtils.isBlank(token)) {
|
||||||
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
HttpServletResponse httpResponse = (HttpServletResponse) response;
|
||||||
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
|
httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin());
|
httpResponse.setHeader("Access-Control-Allow-Origin", HttpContextUtils.getOrigin());
|
||||||
@@ -63,17 +62,8 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try{
|
return executeLogin(request, response);
|
||||||
return executeLogin(request, response);
|
|
||||||
}catch (AbstractMethodError e){
|
|
||||||
if (e.getMessage().contains("sessionCreated")) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return false;
|
|
||||||
}else {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,12 +89,12 @@ public class OAuth2Filter extends AuthenticatingFilter {
|
|||||||
/**
|
/**
|
||||||
* 获取请求的token
|
* 获取请求的token
|
||||||
*/
|
*/
|
||||||
private String getRequestToken(HttpServletRequest httpRequest){
|
private String getRequestToken(HttpServletRequest httpRequest) {
|
||||||
//从header中获取token
|
//从header中获取token
|
||||||
String token = httpRequest.getHeader("token");
|
String token = httpRequest.getHeader("token");
|
||||||
|
|
||||||
//如果header中不存在token,则从参数中获取token
|
//如果header中不存在token,则从参数中获取token
|
||||||
if(StringUtils.isBlank(token)){
|
if (StringUtils.isBlank(token)) {
|
||||||
token = httpRequest.getParameter("token");
|
token = httpRequest.getParameter("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
src/main/java/com/sqx/modules/utils/TimeCompleteUtils.java
Normal file
27
src/main/java/com/sqx/modules/utils/TimeCompleteUtils.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package com.sqx.modules.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author GYJoker
|
||||||
|
*/
|
||||||
|
public class TimeCompleteUtils {
|
||||||
|
|
||||||
|
public static String completeStartTime(String startTime) {
|
||||||
|
if (startTime == null || startTime.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (startTime.contains(" ")) {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
return startTime + " 00:00:00";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String completeEndTime(String endTime) {
|
||||||
|
if (endTime == null || endTime.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (endTime.contains(" ")) {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
return endTime + " 23:59:59";
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/main/java/com/sqx/sharding/MasterSlaveRules.java
Normal file
22
src/main/java/com/sqx/sharding/MasterSlaveRules.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package com.sqx.sharding;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读写分离配置
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MasterSlaveRules {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写库
|
||||||
|
*/
|
||||||
|
private String masterDataSourceName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读库
|
||||||
|
*/
|
||||||
|
private List<String> slaveDataSourceNames;
|
||||||
|
}
|
||||||
61
src/main/java/com/sqx/sharding/ShardingDataBase.java
Normal file
61
src/main/java/com/sqx/sharding/ShardingDataBase.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package com.sqx.sharding;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于注入sharding-jdbc的值
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ShardingDataBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接池
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驱动名称
|
||||||
|
*/
|
||||||
|
private String driverClassName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库地址
|
||||||
|
*/
|
||||||
|
private String jdbcUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库用户名
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库密码
|
||||||
|
*/
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||||
|
*/
|
||||||
|
private int minimumIdle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大连接数,小于等于0会被重置为默认值10;大于零小于1会被重置为minimum-idle的值
|
||||||
|
*/
|
||||||
|
private int maximumPoolSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 空闲连接超时时间,默认值600000(10分钟),大于等于max-lifetime且max-lifetime>0,会被重置为0;不等于0且小于10秒,会被重置为10秒。
|
||||||
|
*/
|
||||||
|
private int idleTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接最大存活时间.不等于0且小于30秒,会被重置为默认值30分钟.设置应该比mysql设置的超时时间短
|
||||||
|
*/
|
||||||
|
private int maxLifetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接超时时间:毫秒,小于250毫秒,否则被重置为默认值30秒
|
||||||
|
*/
|
||||||
|
private int connectionTimeout;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.sqx.sharding;
|
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
import com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory;
|
||||||
|
import io.micrometer.core.instrument.MeterRegistry;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShardingDataSource;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceUnwrapper;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wxkj0012
|
||||||
|
*/
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@AutoConfigureAfter({MetricsAutoConfiguration.class, DataSourceAutoConfiguration.class,
|
||||||
|
SimpleMetricsExportAutoConfiguration.class})
|
||||||
|
@ConditionalOnClass({DataSource.class, MeterRegistry.class})
|
||||||
|
@ConditionalOnBean({DataSource.class, MeterRegistry.class})
|
||||||
|
@Slf4j
|
||||||
|
public class ShardingDataSourcePoolMetricsAutoConfiguration {
|
||||||
|
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@ConditionalOnClass({ShardingDataSource.class, HikariDataSource.class})
|
||||||
|
static class ShardingDataSourceMetricsConfiguration {
|
||||||
|
|
||||||
|
private final MeterRegistry registry;
|
||||||
|
|
||||||
|
ShardingDataSourceMetricsConfiguration(MeterRegistry registry) {
|
||||||
|
this.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
void bindMetricsRegistryToHikariDataSources(Collection<DataSource> dataSources) {
|
||||||
|
for (DataSource dataSource : dataSources) {
|
||||||
|
ShardingDataSource shardingDataSource = DataSourceUnwrapper.unwrap(dataSource, ShardingDataSource.class);
|
||||||
|
Collection<DataSource> shardDataSources = shardingDataSource.getDataSourceMap().values();
|
||||||
|
for (DataSource ds : shardDataSources) {
|
||||||
|
HikariDataSource hikariDataSource = DataSourceUnwrapper.unwrap(ds, HikariDataSource.class);
|
||||||
|
if (hikariDataSource != null) {
|
||||||
|
bindMetricsRegistryToHikariDataSource(hikariDataSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindMetricsRegistryToHikariDataSource(HikariDataSource hikari) {
|
||||||
|
if (hikari.getMetricRegistry() == null && hikari.getMetricsTrackerFactory() == null) {
|
||||||
|
try {
|
||||||
|
hikari.setMetricsTrackerFactory(new MicrometerMetricsTrackerFactory(this.registry));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
log.warn("Failed to bind Hikari metrics: {}}", ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +1,55 @@
|
|||||||
|
# 数据源的一些配置
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||||
|
minimum-idle: 5
|
||||||
|
# 最大连接数,小于等于0会被重置为默认值10;大于零小于1会被重置为minimum-idle的值
|
||||||
|
maximum-pool-size: 15
|
||||||
|
# 空闲连接超时时间,默认值600000(10分钟),大于等于max-lifetime且max-lifetime>0,会被重置为0;不等于0且小于10秒,会被重置为10秒。
|
||||||
|
idle-timeout: 30000
|
||||||
|
# 连接最大存活时间.不等于0且小于30秒,会被重置为默认值30分钟.设置应该比mysql设置的超时时间短
|
||||||
|
max-lifetime: 30000
|
||||||
|
# 连接超时时间:毫秒,小于250毫秒,否则被重置为默认值30秒
|
||||||
|
connection-timeout: 30000
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
datasource:
|
# sharding-jdbc 配置
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
shardingsphere:
|
||||||
druid:
|
center-tables-data-node: duanju.%s
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
# 显示sharding-jdbc改写的sql语句
|
||||||
url: jdbc:mysql://rm-gc712o11yndj78x6a6o.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
show-sql: false
|
||||||
username: video_user
|
# 数据源名称
|
||||||
password: VideoUser@1
|
datasource:
|
||||||
initial-size: 10
|
# 数据源配置begin
|
||||||
max-active: 50
|
master-0:
|
||||||
min-idle: 10
|
driver-class-name: ${driver-class-name}
|
||||||
max-wait: 60000
|
jdbc-url: jdbc:mysql://rm-gc712o11yndj78x6a6o.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
pool-prepared-statements: true
|
username: video_user
|
||||||
max-pool-prepared-statement-per-connection-size: 20
|
password: VideoUser@1
|
||||||
time-between-eviction-runs-millis: 60000
|
minimum-idle: ${minimum-idle}
|
||||||
min-evictable-idle-time-millis: 300000
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
#Oracle需要打开注释
|
idle-timeout: ${idle-timeout}
|
||||||
#validation-query: SELECT 1 FROM DUAL
|
max-lifetime: ${max-lifetime}
|
||||||
test-while-idle: true
|
connection-timeout: ${connection-timeout}
|
||||||
test-on-borrow: false
|
slave-0:
|
||||||
test-on-return: false
|
driver-class-name: ${driver-class-name}
|
||||||
stat-view-servlet:
|
jdbc-url: jdbc:mysql://47.122.26.160:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
enabled: true
|
username: root
|
||||||
url-pattern: /druid/*
|
password: 0fd6497c308ccfa8
|
||||||
#login-username: admin
|
minimum-idle: ${minimum-idle}
|
||||||
#login-password: admin
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
filter:
|
idle-timeout: ${idle-timeout}
|
||||||
stat:
|
max-lifetime: ${max-lifetime}
|
||||||
log-slow-sql: true
|
connection-timeout: ${connection-timeout}
|
||||||
slow-sql-millis: 1000
|
# 数据源配置end
|
||||||
merge-sql: false
|
|
||||||
wall:
|
# 读写分离配置begin
|
||||||
config:
|
master-slave-rules:
|
||||||
multi-statement-allow: true
|
#数据源
|
||||||
|
duanju:
|
||||||
|
master-data-source-name: master-0
|
||||||
|
slave-data-source-names: slave-0
|
||||||
|
# - master-0
|
||||||
|
# - slave-0
|
||||||
|
|
||||||
swagger:
|
swagger:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
59
src/main/resources/application-local.yml
Normal file
59
src/main/resources/application-local.yml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# 数据源的一些配置
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||||
|
minimum-idle: 5
|
||||||
|
# 最大连接数,小于等于0会被重置为默认值10;大于零小于1会被重置为minimum-idle的值
|
||||||
|
maximum-pool-size: 15
|
||||||
|
# 空闲连接超时时间,默认值600000(10分钟),大于等于max-lifetime且max-lifetime>0,会被重置为0;不等于0且小于10秒,会被重置为10秒。
|
||||||
|
idle-timeout: 30000
|
||||||
|
# 连接最大存活时间.不等于0且小于30秒,会被重置为默认值30分钟.设置应该比mysql设置的超时时间短
|
||||||
|
max-lifetime: 30000
|
||||||
|
# 连接超时时间:毫秒,小于250毫秒,否则被重置为默认值30秒
|
||||||
|
connection-timeout: 30000
|
||||||
|
|
||||||
|
spring:
|
||||||
|
# sharding-jdbc 配置
|
||||||
|
shardingsphere:
|
||||||
|
center-tables-data-node: duanju.%s
|
||||||
|
# 显示sharding-jdbc改写的sql语句
|
||||||
|
show-sql: false
|
||||||
|
# 数据源名称
|
||||||
|
datasource:
|
||||||
|
# 数据源配置begin
|
||||||
|
master-0:
|
||||||
|
driver-class-name: ${driver-class-name}
|
||||||
|
jdbc-url: jdbc:mysql://rm-gc712o11yndj78x6a6o.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
username: video_user
|
||||||
|
password: VideoUser@1
|
||||||
|
minimum-idle: ${minimum-idle}
|
||||||
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
|
idle-timeout: ${idle-timeout}
|
||||||
|
max-lifetime: ${max-lifetime}
|
||||||
|
connection-timeout: ${connection-timeout}
|
||||||
|
slave-0:
|
||||||
|
driver-class-name: ${driver-class-name}
|
||||||
|
jdbc-url: jdbc:mysql://47.122.26.160:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
username: root
|
||||||
|
password: 0fd6497c308ccfa8
|
||||||
|
minimum-idle: ${minimum-idle}
|
||||||
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
|
idle-timeout: ${idle-timeout}
|
||||||
|
max-lifetime: ${max-lifetime}
|
||||||
|
connection-timeout: ${connection-timeout}
|
||||||
|
# 数据源配置end
|
||||||
|
|
||||||
|
# 读写分离配置begin
|
||||||
|
master-slave-rules:
|
||||||
|
#数据源
|
||||||
|
duanju:
|
||||||
|
master-data-source-name: master-0
|
||||||
|
slave-data-source-names: slave-0
|
||||||
|
# - master-0
|
||||||
|
# - slave-0
|
||||||
|
|
||||||
|
swagger:
|
||||||
|
enabled: true
|
||||||
|
pay:
|
||||||
|
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
|
||||||
|
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
|
||||||
|
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify
|
||||||
65
src/main/resources/application-pay.yml
Normal file
65
src/main/resources/application-pay.yml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# 数据源的一些配置
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||||
|
minimum-idle: 5
|
||||||
|
# 最大连接数,小于等于0会被重置为默认值10;大于零小于1会被重置为minimum-idle的值
|
||||||
|
maximum-pool-size: 15
|
||||||
|
# 空闲连接超时时间,默认值600000(10分钟),大于等于max-lifetime且max-lifetime>0,会被重置为0;不等于0且小于10秒,会被重置为10秒。
|
||||||
|
idle-timeout: 30000
|
||||||
|
# 连接最大存活时间.不等于0且小于30秒,会被重置为默认值30分钟.设置应该比mysql设置的超时时间短
|
||||||
|
max-lifetime: 30000
|
||||||
|
# 连接超时时间:毫秒,小于250毫秒,否则被重置为默认值30秒
|
||||||
|
connection-timeout: 30000
|
||||||
|
|
||||||
|
spring:
|
||||||
|
# sharding-jdbc 配置
|
||||||
|
shardingsphere:
|
||||||
|
center-tables-data-node: duanju.%s
|
||||||
|
# 显示sharding-jdbc改写的sql语句
|
||||||
|
show-sql: false
|
||||||
|
# 数据源名称
|
||||||
|
datasource:
|
||||||
|
# 数据源配置begin
|
||||||
|
master-0:
|
||||||
|
driver-class-name: ${driver-class-name}
|
||||||
|
jdbc-url: jdbc:mysql://rm-gc7xx913734hv5w5qxo.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
username: video_user
|
||||||
|
password: VideoUser@1
|
||||||
|
# jdbc-url: jdbc:mysql://rm-gc712o11yndj78x6a6o.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
# username: video_user
|
||||||
|
# password: VideoUser@1
|
||||||
|
minimum-idle: ${minimum-idle}
|
||||||
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
|
idle-timeout: ${idle-timeout}
|
||||||
|
max-lifetime: ${max-lifetime}
|
||||||
|
connection-timeout: ${connection-timeout}
|
||||||
|
slave-0:
|
||||||
|
driver-class-name: ${driver-class-name}
|
||||||
|
jdbc-url: jdbc:mysql://rm-gc7xx913734hv5w5qxo.mysql.cn-chengdu.rds.aliyuncs.com/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
username: video_user
|
||||||
|
password: VideoUser@1
|
||||||
|
# jdbc-url: jdbc:mysql://47.122.26.160:3306/duanju?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||||
|
# username: root
|
||||||
|
# password: 0fd6497c308ccfa8
|
||||||
|
minimum-idle: ${minimum-idle}
|
||||||
|
maximum-pool-size: ${maximum-pool-size}
|
||||||
|
idle-timeout: ${idle-timeout}
|
||||||
|
max-lifetime: ${max-lifetime}
|
||||||
|
connection-timeout: ${connection-timeout}
|
||||||
|
# 数据源配置end
|
||||||
|
|
||||||
|
# 读写分离配置begin
|
||||||
|
master-slave-rules:
|
||||||
|
#数据源
|
||||||
|
duanju:
|
||||||
|
master-data-source-name: master-0
|
||||||
|
slave-data-source-names: slave-0
|
||||||
|
# - master-0
|
||||||
|
# - slave-0
|
||||||
|
|
||||||
|
swagger:
|
||||||
|
enabled: true
|
||||||
|
pay:
|
||||||
|
h5BaseUrl: https://video-h5.hnsiyao.cn/me/detail/detail?allId=
|
||||||
|
orderNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/notify
|
||||||
|
extractNotifyUrl: https://video.hnsiyao.cn/czg/app/wuyou/extractNotify
|
||||||
1
src/main/resources/application.properties
Normal file
1
src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
center-tables=activity,app,banner,cash_out,comment_good,common_info,complet_award,coupon,coupon_user,course,course_classification,course_collect,course_comment,course_details,course_user,disc_spinning,disc_spinning_amount,disc_spinning_record,help_classify,help_word,invite,invite_award,invite_money,message_info,msg,orders,pay_classify,pay_details,qrtz_blob_triggers,qrtz_calendars,qrtz_cron_triggers,qrtz_fired_triggers,qrtz_job_details,qrtz_locks,qrtz_paused_trigger_grps,qrtz_scheduler_state,qrtz_simple_triggers,qrtz_simprop_triggers,qrtz_triggers,schedule_job,schedule_job_log,sdk_info,sdk_type,search,sys_captcha,sys_config,sys_dict,sys_log,sys_menu,sys_oss,sys_role,sys_role_menu,sys_user,sys_user_role,sys_user_token,task_center,task_center_record,task_center_reward,tb_user,uni_ad_callback_record,url_address,user_integral,user_integral_details,user_money,user_money_details,user_prize_exchange,user_sign_record,user_vip,vip_details,invite_achievement
|
||||||
@@ -45,10 +45,14 @@ spring:
|
|||||||
min-idle: 5 # 连接池中的最小空闲连接
|
min-idle: 5 # 连接池中的最小空闲连接
|
||||||
mvc:
|
mvc:
|
||||||
throw-exception-if-no-handler-found: true
|
throw-exception-if-no-handler-found: true
|
||||||
pathmatch:
|
# pathmatch:
|
||||||
matching-strategy: ant_path_matcher
|
# matching-strategy: ant_path_matcher
|
||||||
|
|
||||||
|
|
||||||
|
management:
|
||||||
|
health:
|
||||||
|
db:
|
||||||
|
enabled: false #关闭数据库健康检查isV
|
||||||
#mybatis
|
#mybatis
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath*:/mapper/**/*.xml
|
mapper-locations: classpath*:/mapper/**/*.xml
|
||||||
@@ -84,3 +88,8 @@ sqx:
|
|||||||
header: token
|
header: token
|
||||||
uni:
|
uni:
|
||||||
adSecret: 122e4ff1edc66dcf8761f7f7ffc81e0f8773cbfafb58aed29c72fbd092c77315
|
adSecret: 122e4ff1edc66dcf8761f7f7ffc81e0f8773cbfafb58aed29c72fbd092c77315
|
||||||
|
|
||||||
|
|
||||||
|
limit:
|
||||||
|
urlRate: 10 # 同一用户单url每秒限制次数
|
||||||
|
ipJumpLimit: 4 # 同一ip每分钟跳动次数
|
||||||
|
|||||||
19
src/main/resources/mapper/InviteAchievementMapper.xml
Normal file
19
src/main/resources/mapper/InviteAchievementMapper.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.sqx.modules.app.mapper.InviteAchievementMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.sqx.modules.app.entity.InviteAchievement">
|
||||||
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="userId" column="user_id" jdbcType="BIGINT"/>
|
||||||
|
<result property="byUserId" column="by_user_id" jdbcType="BIGINT"/>
|
||||||
|
<result property="amount" column="amount" jdbcType="DECIMAL"/>
|
||||||
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,user_id,by_user_id,
|
||||||
|
amount,create_time
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -52,13 +52,13 @@
|
|||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||||
and date_format(u.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}
|
and u.create_time BETWEEN #{startTime} and #{endTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="startTime!=null and startTime!='' and (endTime==null or endTime=='')">
|
<if test="startTime!=null and startTime!='' and (endTime==null or endTime=='')">
|
||||||
and date_format(u.create_time,'%Y-%m-%d') >= #{startTime}
|
and u.create_time >= #{startTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
|
<if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
|
||||||
and date_format(u.create_time,'%Y-%m-%d') <= #{endTime}
|
and u.create_time <= #{endTime}
|
||||||
</if>
|
</if>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
@@ -136,7 +136,6 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryCourseOrder" resultType="com.sqx.modules.app.response.CourseOrderResponse">
|
<select id="queryCourseOrder" resultType="com.sqx.modules.app.response.CourseOrderResponse">
|
||||||
select * from (
|
|
||||||
select c.course_id as courseId,sum(o.pay_money) as 'coursemoney' ,count(*) as 'coursenum',any_value(c.title) as 'coursename'
|
select c.course_id as courseId,sum(o.pay_money) as 'coursemoney' ,count(*) as 'coursenum',any_value(c.title) as 'coursename'
|
||||||
from orders o
|
from orders o
|
||||||
left join course c on o.course_id=c.course_id
|
left join course c on o.course_id=c.course_id
|
||||||
@@ -144,18 +143,9 @@
|
|||||||
<if test="sysUserId!=null">
|
<if test="sysUserId!=null">
|
||||||
and sys_user_id=#{sysUserId}
|
and sys_user_id=#{sysUserId}
|
||||||
</if>
|
</if>
|
||||||
<if test="type==1">
|
and o.create_time between #{start} and #{end}
|
||||||
and date_format(o.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
|
|
||||||
</if>
|
|
||||||
<if test="type==2">
|
|
||||||
and date_format(o.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
|
|
||||||
</if>
|
|
||||||
<if test="type==3">
|
|
||||||
and date_format(o.create_time,'%Y')=date_format(#{date},'%Y')
|
|
||||||
</if>
|
|
||||||
group by c.course_id
|
group by c.course_id
|
||||||
) a
|
order by coursenum desc
|
||||||
order by a.coursenum desc
|
|
||||||
</select>
|
</select>
|
||||||
<select id="userMessage" resultType="int">
|
<select id="userMessage" resultType="int">
|
||||||
select count(*) from tb_user t
|
select count(*) from tb_user t
|
||||||
|
|||||||
@@ -6,46 +6,91 @@
|
|||||||
|
|
||||||
<select id="selectCourseByCollect" resultType="com.sqx.modules.course.entity.Course">
|
<select id="selectCourseByCollect" resultType="com.sqx.modules.course.entity.Course">
|
||||||
SELECT
|
SELECT
|
||||||
MAX( u.update_time ) AS produceEndTime,
|
MAX(u.update_time) AS produceEndTime,
|
||||||
c.*,
|
c.*,
|
||||||
(
|
d.course_details_name AS courseDetailsName,
|
||||||
SELECT
|
d.course_details_id AS courseDetailsId,
|
||||||
d.course_details_name
|
cd.course_details_count AS courseDetailsCount
|
||||||
FROM
|
|
||||||
course_collect cc
|
|
||||||
LEFT JOIN course_details d ON cc.course_details_id = d.course_details_id
|
|
||||||
WHERE
|
|
||||||
d.course_id = u.course_id
|
|
||||||
AND cc.classify = 3 and cc.user_id=#{userId}
|
|
||||||
ORDER BY
|
|
||||||
cc.update_time DESC
|
|
||||||
LIMIT 1
|
|
||||||
) AS courseDetailsName,
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
d.course_details_id
|
|
||||||
FROM
|
|
||||||
course_collect cc
|
|
||||||
LEFT JOIN course_details d ON cc.course_details_id = d.course_details_id
|
|
||||||
WHERE
|
|
||||||
d.course_id = u.course_id
|
|
||||||
AND cc.classify = 3 and cc.user_id=#{userId}
|
|
||||||
ORDER BY
|
|
||||||
cc.update_time DESC
|
|
||||||
LIMIT 1
|
|
||||||
) AS courseDetailsId,
|
|
||||||
( SELECT count(*) FROM course_details d WHERE d.course_id = c.course_id ) AS courseDetailsCount
|
|
||||||
FROM
|
FROM
|
||||||
course_collect u
|
course_collect u
|
||||||
LEFT JOIN course c ON u.course_id = c.course_id
|
LEFT JOIN course c ON u.course_id = c.course_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
cc.course_id,
|
||||||
|
cc.user_id,
|
||||||
|
d.course_details_name,
|
||||||
|
d.course_details_id
|
||||||
|
FROM
|
||||||
|
course_collect cc
|
||||||
|
LEFT JOIN course_details d ON cc.course_details_id = d.course_details_id
|
||||||
WHERE
|
WHERE
|
||||||
u.user_id = #{userId}
|
cc.classify = 3
|
||||||
AND c.course_id IS NOT NULL
|
AND cc.user_id = #{userId}
|
||||||
AND u.classify = #{classify}
|
|
||||||
GROUP BY
|
|
||||||
u.course_id
|
|
||||||
ORDER BY
|
ORDER BY
|
||||||
produceEndTime DESC
|
cc.update_time DESC
|
||||||
|
) AS d ON u.course_id = d.course_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
d.course_id,
|
||||||
|
COUNT(*) AS course_details_count
|
||||||
|
FROM
|
||||||
|
course_details d
|
||||||
|
GROUP BY
|
||||||
|
d.course_id
|
||||||
|
) AS cd ON c.course_id = cd.course_id
|
||||||
|
WHERE
|
||||||
|
u.user_id = #{userId}
|
||||||
|
AND c.course_id IS NOT NULL
|
||||||
|
AND u.classify = #{classify}
|
||||||
|
GROUP BY
|
||||||
|
u.course_id
|
||||||
|
ORDER BY
|
||||||
|
produceEndTime DESC
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- SELECT
|
||||||
|
MAX( u.update_time ) AS produceEndTime,
|
||||||
|
c.*,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
d.course_details_name
|
||||||
|
FROM
|
||||||
|
course_collect cc
|
||||||
|
LEFT JOIN course_details d ON cc.course_details_id = d.course_details_id
|
||||||
|
WHERE
|
||||||
|
d.course_id = u.course_id
|
||||||
|
AND cc.classify = 3 and cc.user_id=#{userId}
|
||||||
|
ORDER BY
|
||||||
|
cc.update_time DESC
|
||||||
|
LIMIT 1
|
||||||
|
) AS courseDetailsName,
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
d.course_details_id
|
||||||
|
FROM
|
||||||
|
course_collect cc
|
||||||
|
LEFT JOIN course_details d ON cc.course_details_id = d.course_details_id
|
||||||
|
WHERE
|
||||||
|
d.course_id = u.course_id
|
||||||
|
AND cc.classify = 3 and cc.user_id=#{userId}
|
||||||
|
ORDER BY
|
||||||
|
cc.update_time DESC
|
||||||
|
LIMIT 1
|
||||||
|
) AS courseDetailsId,
|
||||||
|
( SELECT count(*) FROM course_details d WHERE d.course_id = c.course_id ) AS courseDetailsCount
|
||||||
|
FROM
|
||||||
|
course_collect u
|
||||||
|
LEFT JOIN course c ON u.course_id = c.course_id
|
||||||
|
WHERE
|
||||||
|
u.user_id = #{userId}
|
||||||
|
AND c.course_id IS NOT NULL
|
||||||
|
AND u.classify = #{classify}
|
||||||
|
GROUP BY
|
||||||
|
u.course_id
|
||||||
|
ORDER BY
|
||||||
|
produceEndTime DESC
|
||||||
|
-->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -31,43 +31,32 @@
|
|||||||
c.course_type as courseType,
|
c.course_type as courseType,
|
||||||
c.banner_id as bannerId,
|
c.banner_id as bannerId,
|
||||||
b.name as bannerName,
|
b.name as bannerName,
|
||||||
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
|
0 as viewCounts,
|
||||||
c.dy_img_id as dyImgId,
|
c.dy_img_id as dyImgId,
|
||||||
c.dy_course_id as dyCourseId,
|
c.dy_course_id as dyCourseId,
|
||||||
c.wx_course_id as wxCourseId,
|
c.wx_course_id as wxCourseId,
|
||||||
c.wx_show as wxShow,
|
c.wx_show as wxShow,
|
||||||
c.dy_show as dyShow,
|
c.dy_show as dyShow,
|
||||||
c.sort,
|
c.sort,
|
||||||
(select sum(good_num) from course_details d where d.course_id=c.course_id ) as goodNum,
|
round(10000*rand(),0) as goodNum,
|
||||||
(select count(*) from course_details d where d.course_id=c.course_id ) as courseDetailsCount,
|
ifnull(d.courseDetailsCount,0) as courseDetailsCount,
|
||||||
<if test="userId!=null">
|
null AS courseDetailsName,
|
||||||
(
|
null AS courseDetailsId,
|
||||||
SELECT
|
round(10000*rand(),0) as weekGoodNum,
|
||||||
cc.course_details_id
|
0 as isRecommend
|
||||||
FROM
|
|
||||||
course_collect cc
|
|
||||||
WHERE
|
|
||||||
cc.course_id = c.course_id
|
|
||||||
AND cc.classify = 3
|
|
||||||
and cc.user_id = #{userId}
|
|
||||||
ORDER BY
|
|
||||||
cc.update_time desc
|
|
||||||
LIMIT 1
|
|
||||||
) AS courseDetailsId,
|
|
||||||
</if>
|
|
||||||
<if test="userId==null">
|
|
||||||
null AS courseDetailsName,
|
|
||||||
null AS courseDetailsId,
|
|
||||||
</if>
|
|
||||||
|
|
||||||
(select count(*) from course_collect d where d.course_id=c.course_id
|
|
||||||
and date_format(create_time,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d') and
|
|
||||||
date_format(create_time,'%Y-%m-%d')<=date_format(#{endTime},'%Y-%m-%d') ) as weekGoodNum,
|
|
||||||
(select count(*) from course_details cd where c.course_id=cd.course_id and cd.good=1 ) as isRecommend
|
|
||||||
FROM
|
FROM
|
||||||
course AS c
|
course AS c
|
||||||
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
||||||
left join banner as b on b.id=c.banner_id
|
LEFT JOIN banner AS b ON b.id = c.banner_id
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
course_id,
|
||||||
|
COUNT(*) AS courseDetailsCount
|
||||||
|
FROM
|
||||||
|
course_details
|
||||||
|
GROUP BY
|
||||||
|
course_id
|
||||||
|
) AS d ON d.course_id = c.course_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND c.is_delete = 0
|
AND c.is_delete = 0
|
||||||
@@ -114,7 +103,7 @@
|
|||||||
and c.dy_status=4
|
and c.dy_status=4
|
||||||
</if>
|
</if>
|
||||||
<if test="sort==null">
|
<if test="sort==null">
|
||||||
order by c.sort asc
|
order by c.sort asc,c.create_time desc
|
||||||
</if>
|
</if>
|
||||||
<if test="sort!=null and sort==1">
|
<if test="sort!=null and sort==1">
|
||||||
order by goodNum desc
|
order by goodNum desc
|
||||||
@@ -150,7 +139,7 @@
|
|||||||
c.course_type as courseType,
|
c.course_type as courseType,
|
||||||
c.banner_id as bannerId,
|
c.banner_id as bannerId,
|
||||||
b.name as bannerName,
|
b.name as bannerName,
|
||||||
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
|
ifnull(d.viewCounts,0) as viewCounts,
|
||||||
c.dy_img_id as dyImgId,
|
c.dy_img_id as dyImgId,
|
||||||
c.dy_course_id as dyCourseId,
|
c.dy_course_id as dyCourseId,
|
||||||
c.dy_status as dyStatus,
|
c.dy_status as dyStatus,
|
||||||
@@ -173,26 +162,26 @@
|
|||||||
c.`cost_distribution_uri` as costDistributionUri,
|
c.`cost_distribution_uri` as costDistributionUri,
|
||||||
c.`assurance_uri` as assuranceUri,
|
c.`assurance_uri` as assuranceUri,
|
||||||
c.`playlet_production_cost` as playletProductionCost,
|
c.`playlet_production_cost` as playletProductionCost,
|
||||||
|
|
||||||
c.`qualification_type` as qualificationType,
|
c.`qualification_type` as qualificationType,
|
||||||
c.`registration_number` as registrationNumber,
|
c.`registration_number` as registrationNumber,
|
||||||
c.`qualification_certificate_material_id` as qualificationCertificateMaterialId,
|
c.`qualification_certificate_material_id` as qualificationCertificateMaterialId,
|
||||||
c.`cost_of_production` as costOfProduction,
|
c.`cost_of_production` as costOfProduction,
|
||||||
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
||||||
c.`wx_course_status` as wxCourseStatus,
|
c.`wx_course_status` as wxCourseStatus,
|
||||||
|
t.dyUrlStatus,
|
||||||
(select count(*) from course_details where dy_url_status in (1,3) or dy_url_status=null) as dyUrlStatus,
|
o.payMoney,
|
||||||
(select sum(o.pay_money) from orders o where o.course_id=c.course_id and o.status=1) as payMoney,
|
ifnull(d.goodNum,0) as goodNum,
|
||||||
(select sum(good_num) from course_details d where d.course_id=c.course_id ) as goodNum,
|
ifnull(d.courseDetailsCount) as courseDetailsCount,
|
||||||
(select count(*) from course_details d where d.course_id=c.course_id ) as courseDetailsCount,
|
0 as weekGoodNum,
|
||||||
(select count(*) from course_collect d where d.course_id=c.course_id
|
ifnull(tt.isRecommend,0) as isRecommend
|
||||||
and date_format(create_time,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d') and
|
|
||||||
date_format(create_time,'%Y-%m-%d')<=date_format(#{endTime},'%Y-%m-%d') ) as weekGoodNum,
|
|
||||||
(select count(*) from course_details cd where c.course_id=cd.course_id and cd.good=1 ) as isRecommend
|
|
||||||
FROM
|
FROM
|
||||||
course AS c
|
course AS c
|
||||||
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
||||||
left join banner as b on b.id=c.banner_id
|
left join banner as b on b.id=c.banner_id
|
||||||
|
left join (select 1 as id,count(*) as dyUrlStatus from course_details where dy_url_status in (1,3) or dy_url_status=null group by course_id) t on t.id = 1
|
||||||
|
left join (select course_id,sum(pay_money) as payMoney from orders where status=1 group by course_id) o on o.course_id = c.course_id
|
||||||
|
left join (select course_id,sum(view_count) as viewCounts,sum(good_num) as goodNum,count(*) as courseDetailsCount from course_details group by course_id) d on d.course_id = c.course_id
|
||||||
|
left join (select course_id,count(*) as isRecommend from course_details where good=1 group by course_id) tt on tt.course_id = c.course_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND c.is_delete = 0
|
AND c.is_delete = 0
|
||||||
@@ -217,7 +206,7 @@
|
|||||||
<if test='null!= bannerId and bannerId!=0'>
|
<if test='null!= bannerId and bannerId!=0'>
|
||||||
and c.banner_id = #{bannerId}
|
and c.banner_id = #{bannerId}
|
||||||
</if>
|
</if>
|
||||||
<if test="classifyId==0">
|
<if test="classifyId!=null and classifyId==0">
|
||||||
and c.is_recommend=1
|
and c.is_recommend=1
|
||||||
</if>
|
</if>
|
||||||
<if test="over!=null and over==1">
|
<if test="over!=null and over==1">
|
||||||
|
|||||||
@@ -4,9 +4,12 @@
|
|||||||
|
|
||||||
<!--查找指定短剧的目录 按照顺序数字升序-->
|
<!--查找指定短剧的目录 按照顺序数字升序-->
|
||||||
<select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
select c.*,
|
select
|
||||||
(select count(*) from course_collect cc where cc.user_id=#{userId} and cc.course_details_id=c.course_details_id and cc.classify=2) as isGood
|
c.*,
|
||||||
from course_details c where c.course_id=#{id} order by c.sort asc
|
ifnull(cc.isGood,0) as isGood
|
||||||
|
from course_details c
|
||||||
|
left join (select course_details_id,count(*) isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on c.course_details_id = c.course_details_id
|
||||||
|
where c.course_id=#{id} order by c.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCoursePageByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="selectCoursePageByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
@@ -21,12 +24,23 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findByCourseIdNotUrl" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="findByCourseIdNotUrl" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
select c.course_details_id as courseDetailsId,c.course_id as courseId,c.wx_course_details_id as wxCourseDetailsId,
|
select c.course_details_id as courseDetailsId,
|
||||||
c.course_details_name as courseDetailsName,c.create_time as createTime,
|
c.course_id as courseId,
|
||||||
c.dy_episode_id as dyEpisodeId,c.advertising, c.view_count as viewCount, c.play_complete_count as playCompleteCount,
|
c.wx_course_details_id as wxCourseDetailsId,
|
||||||
(select count(*) from course_collect cc where cc.user_id=#{userId} and cc.course_details_id=c.course_details_id and cc.classify=2) as isGood,
|
c.course_details_name as courseDetailsName,
|
||||||
c.title_img as titleImg,c.content,c.good_num as goodNum,c.price,if(is_price!=1,c.video_url,'') as videoUrl
|
c.create_time as createTime,
|
||||||
|
c.title_img as titleImg,
|
||||||
|
c.content,
|
||||||
|
c.good_num as goodNum,
|
||||||
|
c.price,
|
||||||
|
if(c.is_price!=1,c.video_url,'') as videoUrl,
|
||||||
|
c.dy_episode_id as dyEpisodeId,
|
||||||
|
c.advertising,
|
||||||
|
c.view_count as viewCount,
|
||||||
|
c.play_complete_count as playCompleteCount,
|
||||||
|
ifnull(cc.isGood,0) as isGood
|
||||||
from course_details c
|
from course_details c
|
||||||
|
left join (select course_details_id,count(*) as isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on cc.course_details_id = c.course_details_id
|
||||||
where c.course_id=#{id} order by c.sort asc
|
where c.course_id=#{id} order by c.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -57,7 +71,7 @@
|
|||||||
<if test='null != dyShow and dyShow==2'>
|
<if test='null != dyShow and dyShow==2'>
|
||||||
and (c.dy_show = #{dyShow} or c.dy_show is null)
|
and (c.dy_show = #{dyShow} or c.dy_show is null)
|
||||||
</if>
|
</if>
|
||||||
order by SUBSTR(uid, #{randomNum}, 6)
|
order by SUBSTR(uid, ${randomNum}, 6)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -2,31 +2,31 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.sqx.modules.course.dao.CourseUserDao">
|
<mapper namespace="com.sqx.modules.course.dao.CourseUserDao">
|
||||||
|
|
||||||
<select id="selectLatelyCourse" resultType="com.sqx.modules.course.entity.Course">
|
<!-- <select id="selectLatelyCourse" resultType="com.sqx.modules.course.entity.Course">-->
|
||||||
select c.*,(select count(*) from course_user cu where cu.course_id=u.course_id) as courseCount,
|
<!-- select c.*,(select count(*) from course_user cu where cu.course_id=u.course_id) as courseCount,-->
|
||||||
(select group_concat(avatar) from
|
<!-- (select group_concat(avatar) from-->
|
||||||
(SELECT tu.avatar,course_id FROM course_user o
|
<!-- (SELECT tu.avatar,course_id FROM course_user o-->
|
||||||
left join tb_user tu on tu.user_id=o.user_id
|
<!-- left join tb_user tu on tu.user_id=o.user_id-->
|
||||||
GROUP BY course_id,tu.avatar
|
<!-- GROUP BY course_id,tu.avatar-->
|
||||||
limit 3
|
<!-- limit 3-->
|
||||||
) a where a.course_id=u.course_id ) as avatar from course_user u
|
<!-- ) a where a.course_id=u.course_id ) as avatar from course_user u-->
|
||||||
left join course c on u.course_id=c.course_id
|
<!-- left join course c on u.course_id=c.course_id-->
|
||||||
where u.user_id=#{userId} and c.is_delete=0 order by update_time desc
|
<!-- where u.user_id=#{userId} and c.is_delete=0 order by update_time desc-->
|
||||||
</select>
|
<!-- </select>-->
|
||||||
|
|
||||||
<select id="selectCourseByCourseUser" resultType="com.sqx.modules.course.entity.Course">
|
<!-- <select id="selectCourseByCourseUser" resultType="com.sqx.modules.course.entity.Course">-->
|
||||||
select c.*,(select count(*) from course_user cu where cu.course_id=u.course_id) as courseCount,
|
<!-- select c.*,(select count(*) from course_user cu where cu.course_id=u.course_id) as courseCount,-->
|
||||||
(select group_concat(avatar) from
|
<!-- (select group_concat(avatar) from-->
|
||||||
(SELECT tu.avatar,course_id FROM course_user o
|
<!-- (SELECT tu.avatar,course_id FROM course_user o-->
|
||||||
left join tb_user tu on tu.user_id=o.user_id
|
<!-- left join tb_user tu on tu.user_id=o.user_id-->
|
||||||
GROUP BY course_id,tu.avatar
|
<!-- GROUP BY course_id,tu.avatar-->
|
||||||
limit 3
|
<!-- limit 3-->
|
||||||
) a where a.course_id=u.course_id ) as avatar
|
<!-- ) a where a.course_id=u.course_id ) as avatar-->
|
||||||
from course_user u
|
<!-- from course_user u-->
|
||||||
left join course c on u.course_id=c.course_id
|
<!-- left join course c on u.course_id=c.course_id-->
|
||||||
where u.user_id=#{userId} and c.is_delete=0
|
<!-- where u.user_id=#{userId} and c.is_delete=0-->
|
||||||
order by u.create_time desc
|
<!-- order by u.create_time desc-->
|
||||||
</select>
|
<!-- </select>-->
|
||||||
|
|
||||||
<select id="selectCourseUser" resultType="com.sqx.modules.course.entity.CourseUser">
|
<select id="selectCourseUser" resultType="com.sqx.modules.course.entity.CourseUser">
|
||||||
select * from course_user u where u.user_id=#{userId} and u.course_id=#{id} and u.classify=1
|
select * from course_user u where u.user_id=#{userId} and u.course_id=#{id} and u.classify=1
|
||||||
|
|||||||
@@ -127,13 +127,13 @@
|
|||||||
and o.sys_user_id=#{sysUserId}
|
and o.sys_user_id=#{sysUserId}
|
||||||
</if>
|
</if>
|
||||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!=''">
|
||||||
and date_format(o.create_time,'%Y-%m-%d') BETWEEN #{startTime} and #{endTime}
|
and o.create_time BETWEEN #{startTime} and #{endTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="startTime!=null and startTime!='' and (endTime==null or endTime=='')">
|
<if test="startTime!=null and startTime!='' and (endTime==null or endTime=='')">
|
||||||
and date_format(o.create_time,'%Y-%m-%d') >= #{startTime}
|
and o.create_time >= #{startTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
|
<if test="endTime!=null and endTime!='' and (startTime==null or startTime=='')">
|
||||||
and date_format(o.create_time,'%Y-%m-%d') <= #{endTime}
|
and o.create_time <= #{endTime}
|
||||||
</if>
|
</if>
|
||||||
order by o.create_time desc
|
order by o.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -30,43 +30,15 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="sumMoney" resultType="Double">
|
<select id="sumMoney" resultType="Double">
|
||||||
select sum(money) from cash_out where state =1
|
select sum(money) from cash_out where state = 1 and create_at between #{start} and #{end}
|
||||||
<if test="flag!=null and flag==1">
|
|
||||||
and date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==2">
|
|
||||||
and date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==3">
|
|
||||||
and date_format(create_at,'%Y')=date_format(#{time},'%Y')
|
|
||||||
</if>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="countMoney" resultType="Integer">
|
<select id="countMoney" resultType="Integer">
|
||||||
select count(*) from cash_out where
|
select count(*) from cash_out where create_at between #{start} and #{end}
|
||||||
<if test="flag!=null and flag==1">
|
|
||||||
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==2">
|
|
||||||
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==3">
|
|
||||||
date_format(create_at,'%Y')=date_format(#{time},'%Y')
|
|
||||||
</if>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="stayMoney" resultType="Integer">
|
<select id="stayMoney" resultType="Integer">
|
||||||
select count(*) from cash_out where
|
select count(*) from cash_out where create_at between #{start} and #{end} and state=0
|
||||||
<if test="flag!=null and flag==1">
|
|
||||||
date_format(create_at,'%Y-%m-%d')=date_format(#{time},'%Y-%m-%d')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==2">
|
|
||||||
date_format(create_at,'%Y-%m')=date_format(#{time},'%Y-%m')
|
|
||||||
</if>
|
|
||||||
<if test="flag!=null and flag==3">
|
|
||||||
date_format(create_at,'%Y')=date_format(#{time},'%Y')
|
|
||||||
</if>
|
|
||||||
and state=0
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMayMoney" resultType="Double">
|
<select id="selectMayMoney" resultType="Double">
|
||||||
|
|||||||
@@ -20,30 +20,13 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateState">
|
<update id="updateState">
|
||||||
update pay_details set `state`=#{state},pay_time=#{time},trade_no=#{tradeNo} where id=#{id}
|
update pay_details
|
||||||
</update>
|
set `state`=#{state},
|
||||||
|
pay_time=#{time},
|
||||||
<select id=" selectPayDetails" resultType="Map">
|
trade_no=#{tradeNo},
|
||||||
select s.id,s.classify,s.order_id as orderId,s.money,s.user_id as userId,
|
third_order_no=#{thirdOrderNo}
|
||||||
s.state,s.create_time as createTime,s.pay_time as payTime,u.user_name as userName,u.phone
|
where id = #{id}
|
||||||
from pay_details s
|
</update>
|
||||||
left join tb_user u on u.user_id=s.user_id
|
|
||||||
where 1=1
|
|
||||||
<if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
|
|
||||||
and str_to_date(s.create_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND str_to_date(#{endTime}, '%Y-%m-%d')
|
|
||||||
</if>
|
|
||||||
<if test="userId!=null">
|
|
||||||
and u.user_id=#{userId}
|
|
||||||
</if>
|
|
||||||
<if test="state!=null and state!=-1">
|
|
||||||
and s.state=#{state}
|
|
||||||
</if>
|
|
||||||
<if test="state==null or state==-1">
|
|
||||||
and s.state!=-1
|
|
||||||
</if>
|
|
||||||
group by s.id
|
|
||||||
order by s.create_time desc
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectPayDetails" resultType="Map">
|
<select id="selectPayDetails" resultType="Map">
|
||||||
select s.id,s.classify,s.order_id as orderId,s.money,s.user_id as userId,s.pay_diamond as payDiamond,s.diamond,
|
select s.id,s.classify,s.order_id as orderId,s.money,s.user_id as userId,s.pay_diamond as payDiamond,s.diamond,
|
||||||
@@ -52,8 +35,7 @@
|
|||||||
left join tb_user u on u.user_id=s.user_id
|
left join tb_user u on u.user_id=s.user_id
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
|
<if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
|
||||||
and str_to_date(s.create_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
|
and s.create_time between #{startTime} AND #{endTime}
|
||||||
str_to_date(#{endTime}, '%Y-%m-%d')
|
|
||||||
</if>
|
</if>
|
||||||
<if test="userName!=null and userName!=''">
|
<if test="userName!=null and userName!=''">
|
||||||
and u.user_name like concat("%",#{userName},"%")
|
and u.user_name like concat("%",#{userName},"%")
|
||||||
@@ -77,7 +59,7 @@
|
|||||||
|
|
||||||
<select id="selectSumPay" resultType="Double">
|
<select id="selectSumPay" resultType="Double">
|
||||||
select sum(money) from pay_details
|
select sum(money) from pay_details
|
||||||
where str_to_date(create_time, '%Y-%m-%d') BETWEEN str_to_date(#{createTime}, '%Y-%m-%d') AND str_to_date(#{endTime}, '%Y-%m-%d')
|
where create_time BETWEEN #{createTime} AND #{endTime}
|
||||||
<if test="userId!=null">
|
<if test="userId!=null">
|
||||||
and user_id=#{userId}
|
and user_id=#{userId}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user