Commit 4aa19ff8 authored by 心月梦天's avatar 心月梦天

抽奖项目的开发

parent e42602ad
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
2021-05-11 11:12:41.522 [tracerId:] [task-3] ERROR [draw, , ] com.miya.draw.manager.OtherManagerImpl:89 - phone=15314614603,prize=20,couponId=570代金券发券失败:重试失败
2021-05-11 11:12:44.197 [tracerId:] [task-2] ERROR [draw, , ] com.miya.draw.manager.OtherManagerImpl:89 - phone=15314614603,prize=21,couponId=570代金券发券失败:重试失败
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
2021-05-07 14:41:42.074 [tracerId:] [http-nio-6048-exec-4] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:38 - 程序发生错误:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 3
### The error may exist in com/miya/draw/mapper/SyncTradeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,trade_uuid,member_id,phone,trade_no,store_id,store_name,tran_time,create_time,update_time FROM sync_trade WHERE (phone = ? AND tran_time BETWEEN ? AND ? AND store_id IN ())
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 3
2021-05-07 15:01:15.565 [tracerId:] [http-nio-6048-exec-1] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:38 - 程序发生错误:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND code IN ())' at line 3
### The error may exist in com/miya/draw/mapper/SyncTradeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,trade_uuid,pos_no,phone,trade_no,store_id,store_name,tran_time,code,name,barcode,price,qty,std_amount,fav_amount,create_time,update_time FROM sync_trade WHERE (phone = ? AND tran_time BETWEEN ? AND ? AND store_id IN () AND code IN ())
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND code IN ())' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND code IN ())' at line 3
2021-05-07 16:08:30.112 [tracerId:] [http-nio-6048-exec-5] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:38 - 程序发生错误: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.Long'. Check configuration for 'myPrizeId'
2021-05-07 16:09:53.486 [tracerId:] [http-nio-6048-exec-1] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:28 - 程序发生错误: 收货信息已填写!
2021-05-07 16:58:42.226 [tracerId:] [http-nio-6048-exec-7] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:28 - 程序发生错误: 收货信息已填写!
2021-05-07 17:17:32.702 [tracerId:] [http-nio-6048-exec-3] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:28 - 自定义业务异常: 收货信息已填写!
2021-05-07 17:19:56.644 [tracerId:] [http-nio-6048-exec-1] ERROR [draw, , ] com.miya.draw.config.exception.MyControllerAdvice:28 - 自定义业务异常: 收货信息已填写!
2021-05-07 17:29:12.424 [tracerId:] [main] ERROR [draw, , ] o.s.b.diagnostics.LoggingFailureAnalysisReporter:40 -
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 6048 was already in use.
Action:
Identify and stop the process that's listening on port 6048 or configure this application to listen on another port.
This diff is collapsed.
This diff is collapsed.
2021-05-10 16:14:31.095 [tracerId:] [main] ERROR [draw, , ] com.miya.draw.xxljob.TradeSyncJob:108 - 批量更新重复键错误: com.miya.draw.mapper.SyncTradeMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Duplicate entry '321225' for key 'uniq_billno'
; Duplicate entry '321225' for key 'uniq_billno'; nested exception is java.sql.BatchUpdateException: Duplicate entry '321225' for key 'uniq_billno'
2021-05-10 16:18:20.861 [tracerId:] [main] ERROR [draw, , ] com.miya.draw.xxljob.TradeSyncJob:108 - 批量更新重复键错误: com.miya.draw.mapper.SyncTradeMapper.insert (batch index #1) failed. Cause: java.sql.BatchUpdateException: Duplicate entry '321225' for key 'uniq_billno'
; Duplicate entry '321225' for key 'uniq_billno'; nested exception is java.sql.BatchUpdateException: Duplicate entry '321225' for key 'uniq_billno'
2021-05-10 17:37:52.956 [tracerId:] [main] ERROR [draw, , ] com.miya.draw.xxljob.TradeSyncJob:125 - 回调更新十足数据库状态出错:com.miya.draw.mapper.TradeMapper.updateById (batch index #1) failed. Cause: java.sql.BatchUpdateException: Table 'draw.trade' doesn't exist
; bad SQL grammar []; nested exception is java.sql.BatchUpdateException: Table 'draw.trade' doesn't exist list=[{"tradeIdId":"36171361711141231","code":"334080","tradeNo":"141231","favAmount":0.0000,"posNo":"361711","storeId":"36171","type":"sale","uuid":"f4386992b4994da691c086e04e270e42","stdAmount":3.8000,"tranTime":"2021-05-07T10:03:09","phone":"15657519699","price":3.8000,"qty":1,"name":"伊利小白袋纯牛奶180ml","storeName":"绍兴剡溪路店","barcode":"6907992103952","billNo":321225,"memberId":"124be3bedb404782bdd8980c214cf174"}]
This diff is collapsed.
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.13.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.miya.draw</groupId>
<artifactId>draw</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>draw</name>
<description>Draw For Some Mch</description>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<hutools.version>5.4.7</hutools.version>
<mybatisplus.version>3.4.1</mybatisplus.version>
<spring.cloud.version>2.2.2.RELEASE</spring.cloud.version>
<freemarket.version>2.3.31</freemarket.version>
<knife4j.version>3.0.2</knife4j.version>
<mysql-connector.version>5.1.48</mysql-connector.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<junit.version>4.13.1</junit.version>
<mybatis-spring-boot-starter.version>2.1.3</mybatis-spring-boot-starter.version>
<dynamic-datasource.version>3.3.2</dynamic-datasource.version>
<p6spy.version>3.9.1</p6spy.version>
<api-boot.version>2.3.3.RELEASE</api-boot.version>
<redisson.version>3.15.4</redisson.version>
<ahas.version>1.9.0</ahas.version>
<xxljob.version>2.0.1</xxljob.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!--需要引入该jar才能使bootstrap配置文件生效-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
<version>${spring.cloud.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${mybatisplus.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarket.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutools.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency> <!--多数据源-->
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${dynamic-datasource.version}</version>
</dependency>
<dependency> <!--打印mysql日志-->
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>${p6spy.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency><!--打印请求日志-->
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-starter-logging</artifactId>
<version>${api-boot.version}</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<!-- ahas阿里云应用防护 start-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>spring-boot-starter-ahas-sentinel-client</artifactId>
<version>${ahas.version}</version>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>${xxljob.version}</version>
</dependency>
<dependency><!--参数转换-->
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.4.6</version>
</dependency>
</dependencies>
<build>
<finalName>draw</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
1620300068494|4|statement|connection 0|url jdbc:p6spy:mysql://127.0.0.1:3306/draw?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8|SELECT id,name,phone,create_time,update_time FROM account WHERE (phone = ?)|SELECT id,name,phone,create_time,update_time FROM account WHERE (phone = '15314614603')
1620300068600|90|statement|connection 0|url jdbc:p6spy:mysql://127.0.0.1:3306/draw?characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8|INSERT INTO account ( name, phone ) VALUES ( ?, ? )|INSERT INTO account ( name, phone ) VALUES ( '天选之子', '15314614603' )
package com.miya.draw;
import org.minbox.framework.logging.spring.context.annotation.client.EnableLoggingClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author jack
* <p>
* 启动类
*/
@EnableAsync
@SpringBootApplication(scanBasePackages = {"com.miya.draw"})
@MapperScan(basePackages = "com.miya.draw.mapper")
@EnableSwagger2
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableLoggingClient
public class DrawApplication {
public static void main(String[] args) {
SpringApplication.run(DrawApplication.class, args);
}
}
package com.miya.draw.config.ahas;
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException;
import com.alibaba.csp.sentinel.slots.system.SystemBlockException;
import com.miya.draw.config.constant.ConStants;
import com.miya.draw.config.exception.BusinessException;
import com.miya.draw.enums.ErrorEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @ClassName SentinelBlockHandler
* @Description 统一处理sentinel异常
* @Author wangjun
* @Date 2020/9/8 10:31
* @Version 1.0
**/
@Component
@Slf4j
public class SentinelBlockHandler implements UrlBlockHandler {
@Override
public void blocked(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s, BlockException e) throws IOException {
log.error("触发抽奖限流限制,exception={},message={}", e, s);
if (e instanceof FlowException) {
throw new BusinessException(ErrorEnum.SENTINEL_FLOW_EXCEPTION, ConStants.DRAW_SENTINEL);
} else if (e instanceof ParamFlowException) {
throw new BusinessException(ErrorEnum.SENTINEL_PARAM_FLOW_EXCEPTION, ConStants.DRAW_SENTINEL);
} else if (e instanceof SystemBlockException) {
throw new BusinessException(ErrorEnum.SENTINEL_SYSTEM_EXCEPTION, ConStants.DRAW_SENTINEL);
} else if (e instanceof DegradeException) {
throw new BusinessException(ErrorEnum.SENTINEL_DEGRADE_EXCEPTION, ConStants.DRAW_SENTINEL);
} else if (e instanceof AuthorityException) {
throw new BusinessException(ErrorEnum.SENTINEL_AUTHORITY_EXCEPTION, ConStants.DRAW_SENTINEL);
} else {
throw new BusinessException(ErrorEnum.SENTINEL_UNKNOWN_EXCEPTION, ConStants.DRAW_SENTINEL);
}
}
}
package com.miya.draw.config.ahas;
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* 初始化异常处理类
*
* @author wangjun
* @version 1.0
* @since 2020/9/8 10:36
**/
@Component
@Order(0)
@Slf4j
public class SentinelInitConfig implements CommandLineRunner {
@Override
public void run(final String... args) {
log.info("**************初始化Sentinel**************");
WebCallbackManager.setUrlBlockHandler(new SentinelBlockHandler());
}
}
/*
* Miya.com Inc.
* Copyright (c) 2004-${YEAR} All Rights Reserved.
*/
package com.miya.draw.config.business;
/**
* 封装读取业务配置
*
* @author jack
*/
public interface BusinessConfig {
/**
* 最大抽奖次数
*
* @return
*/
Integer getDrawMaxCount();
/**
* 多少元算一次
*
* @return
*/
Integer getDrawCountUnit();
/**
* 理论上最大可花费金额
*
* @return
*/
Long getDrawMaxMoney();
}
/*
* Miya.com Inc.
* Copyright (c) 2004-${YEAR} All Rights Reserved.
*/
package com.miya.draw.config.business;
import io.swagger.models.auth.In;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* 读取业务配置实现类
*
* @author jack
*/
@Data
@Component
public class BusinessConfigImpl implements BusinessConfig {
@Value("${draw.maxcount}")
private Integer drawMaxCount;
@Value("${draw.countunit}")
public Integer drawCountUnit;
@Value("${draw.maxmoney}")
public Long drawMaxMoney;
}
package com.miya.draw.config.business;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.ClassPathResource;
/**
* 加载业务配置
*
* @author jack
*/
@Configuration
public class LoadBusinessConfig {
/**
* 加载业务配置
*/
@Bean
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("bussiness-config.yml"));
propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
return propertySourcesPlaceholderConfigurer;
}
}
package com.miya.draw.config.constant;
/**
* 常量类
*
* @author jack
*/
public class ConStants {
/**
* 十足抽奖前缀
*/
public static final String SHIZU_DRAW_PREFIX = "shizu:draw:";
/**
* 活动门店
*/
public static final String SHIZU_ACTIVITY_STOREID = "activity:storeid";
/**
* 活动商品
*/
public static final String SHIZU_ACTIVITY_GOOD = "activity:good";
/**
* 活动商品
*/
public static final String SHIZU_ACTIVITY_PRIZE = "activity:prize";
/**
* 可抽奖次数
*/
public static final String CANDRAWCOUNT = "canDrawCount";
/**
* 今日购买商品总额
*/
public static final String PURCHASEDAMOUNT = "purchasedAmount";
/**
* 成功凑得
*/
public static final String SUCCESS_CODE = "200";
/**
* 抽奖限流
*/
public static final String DRAW_SENTINEL = "当前抽奖人数过多,请稍后再试";
}
package com.miya.draw.config.exception;
import com.miya.draw.enums.ErrorEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author jack
* @since 2020/2/29 18:48
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {
/**
* 异常码枚举信息
*/
private ErrorEnum errorEnum;
/**
* 自定义message
* @param errorEnum
* @param message
*/
public BusinessException(ErrorEnum errorEnum, String message) {
super(message);
this.errorEnum = errorEnum;
}
/**
* 使用ErrorEnum的message
* @param errorEnum 自定义枚举类型
*/
public BusinessException(ErrorEnum errorEnum) {
super(errorEnum.getMessage());
this.errorEnum = errorEnum;
}
/**
* 异常构造函数
*
* @param errorEnum 错误码
* @param message 异常信息
* @param e 异常堆栈
*/
public BusinessException(ErrorEnum errorEnum, String message, Throwable e) {
super(message, e);
this.errorEnum = errorEnum;
}
}
\ No newline at end of file
package com.miya.draw.config.exception;
import com.miya.draw.config.response.RestResult;
import com.miya.draw.config.response.RestResultUtil;
import com.miya.draw.enums.ErrorEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Controller层异常捕捉器
*
* @author jack
*/
@ControllerAdvice
@Slf4j
public class MyControllerAdvice {
/**
* 全局异常捕捉处理
*/
@ResponseBody
@ExceptionHandler(value = BusinessException.class)
public RestResult errorHandler(BusinessException ex) {
log.error("自定义业务异常: {}", ex.getMessage());
return RestResultUtil.createFailureResult(RestResult.create(), ex);
}
/**
* 全局异常捕捉处理
*/
@ResponseBody
@ExceptionHandler(value = Exception.class)
public RestResult errorHandler(Exception ex) {
log.error("程序异常: {}", ex.getMessage());
return RestResultUtil.createFailureResult(RestResult.create(), new BusinessException(ErrorEnum.SYSTEM_EXP));
}
/**
* 全局异常捕捉处理
*/
@ResponseBody
@ExceptionHandler(value = MethodArgumentNotValidException.class)
public RestResult validErrorHandler(Exception ex) {
log.error("参数效验异常: {}", ex.getMessage());
MethodArgumentNotValidException me = (MethodArgumentNotValidException) ex;
StringBuilder b = new StringBuilder();
for (ObjectError error : me.getBindingResult().getAllErrors()) {
b.append(error.getDefaultMessage()).append(",");
}
return RestResultUtil.createFailureResult(RestResult.create(), new BusinessException(ErrorEnum.PARAM_CHECK_EXP, b.toString()));
}
}
\ No newline at end of file
package com.miya.draw.config.mybatisplus;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.FileType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* @author jack
* @since 2021/4/18 17:39
*/
public class MybatisGenerator {
/**
* <p>
* 读取控制台内容
* </p>
*/
public static String scanner(String tip) {
Scanner scanner = new Scanner(System.in);
StringBuilder help = new StringBuilder();
help.append("请输入" + tip + ":");
System.out.println(help.toString());
if (scanner.hasNext()) {
String ipt = scanner.next();
if (StringUtils.isNotBlank(ipt)) {
return ipt;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "!");
}
public static void main(String[] args) {
//添加表名
List<String> tables = new ArrayList<>(10);
// tables.add("account");
// tables.add("account_prize");
// tables.add("activity_goods");
// tables.add("activity_store");
// tables.add("prize");
// tables.add("sync_record");
// tables.add("sync_trade");
// tables.add("sync_trade_good");
// tables.add("trade");
tables.add("winner");
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("jack");
gc.setOpen(false);
gc.setSwagger2(true);
//开启 BaseResultMap
gc.setBaseResultMap(true);
gc.setBaseColumnList(true);
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
// dsc.setUrl("jdbc:mysql://localhost:3306/draw?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8");
// dsc.setDriverName("com.mysql.jdbc.Driver");
// dsc.setUsername("root");
// dsc.setPassword("123456");
dsc.setUrl("jdbc:mysql://122.228.157.38:1111/szapplets?useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8");
dsc.setDriverName("com.mysql.jdbc.Driver");
dsc.setUsername("sz_root");
dsc.setPassword("Sz20010526");
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent("com.miya.draw");
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
}
};
// 如果模板引擎是 freemarker
String templatePath = "/templates/mapper.xml.ftl";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return projectPath + "/src/main/resources/com/miya/draw/mapper/" +
tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
// 这段代码是为了覆盖 如果是第一次生成请注掉
cfg.setFileCreate((configBuilder, fileType, filePath) -> {
if (filePath.contains("Controller") || filePath.contains("Service")
|| fileType.equals(FileType.MAPPER)) {
// 已经生成 mapper 文件判断存在,不想重新生成返回 false
return !new File(filePath).exists();
}
// 允许生成模板文件
return true;
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 配置模板
TemplateConfig templateConfig = new TemplateConfig();
templateConfig.setController("");
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setEntityLombokModel(true);
strategy.setInclude(tables.toArray(new String[]{}));
strategy.setControllerMappingHyphenStyle(true);
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
}
package com.miya.draw.config.redis;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* redis的配置使用
*
* @author jack
*/
@Configuration
public class RedisConfig {
@Autowired
private RedisConnectionFactory redisConnectionFactory;
@Bean(name = "redisTemplate")
public RedisTemplate<String, Object> initRedisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// 支持事物
redisTemplate.setEnableTransactionSupport(true);
// key的序列化方式采用StringRedisSerializer。相信很少用对象作为key的吧。
// 如果要走非主流路线,将对象作为key,且对象含有非String属性,需要将key的序列化方式
// 更改为下面的value序列化方式
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
redisTemplate.setKeySerializer(stringRedisSerializer);
redisTemplate.setHashKeySerializer(stringRedisSerializer);
// 如果不想使用fastJson。常用的还有jackson的序列化方式。springboot项目中,默认带了jackson。
Jackson2JsonRedisSerializer<Object> jacksonSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSerializer.setObjectMapper(objectMapper);
redisTemplate.setValueSerializer(jacksonSerializer);
redisTemplate.setHashValueSerializer(jacksonSerializer);
// 顾名思义,在属性设置之后运行.初始化配置的作用
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}
\ No newline at end of file
package com.miya.draw.config.redis;
import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@Data
@ConfigurationProperties(prefix = "spring.redis")
public class RedissonConfig {
private String host;
private String port;
private String password;
private int timeout;
@Bean
public RedissonClient redissonClient() {
Config config = new Config();
int database = 3;
config.useSingleServer().setAddress("redis://" + host + ":" + port).setPassword(password)
.setDatabase(database).setTimeout(timeout);
return Redisson.create(config);
}
}
\ No newline at end of file
package com.miya.draw.config.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 封装我们的返回数据信息
*
* @author 13:58 2019/2/22
**/
@Data
@ApiModel(value = "统一返回模型")
public class RestResult<T> {
@ApiModelProperty(value = "是否成功 true成功 false失败")
private boolean success;
@ApiModelProperty(value = "错误码")
private String errcode;
@ApiModelProperty(value = "错误信息")
private String errmsg;
@ApiModelProperty(value = "数据")
private T data;
public static RestResult create() {
return new RestResult();
}
}
\ No newline at end of file
/*
* Dian.so Inc.
* Copyright (c) 2004-2017 All Rights Reserved.
*/
package com.miya.draw.config.response;
import com.miya.draw.config.exception.BusinessException;
import com.miya.draw.enums.ErrorEnum;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* 结果处理类
*
* @author jack
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class RestResultUtil {
/**
* 生成失败结果
*
* @param exception
* @param <T>
* @return
*/
public static <T> RestResult<T> createFailureResult(RestResult result, BusinessException exception) {
result.setSuccess(false);
ErrorEnum errorEnum = exception.getErrorEnum();
result.setErrcode(errorEnum.getCode());
result.setErrmsg(exception.getMessage());
return result;
}
/**
* 生成成功结果
*
* @param <T>
* @return
*/
public static <T> RestResult<T> createSuccessResult() {
return createSuccessResult(RestResult.create(), null);
}
/**
* 生成成功结果
*
* @param data
* @param <T>
* @return
*/
public static <T> RestResult<T> createSuccessResult(T data) {
return createSuccessResult(RestResult.create(), data);
}
/**
* 生成成功结果
*
* @param data
* @param <T>
* @return
*/
public static <T> RestResult<T> createSuccessResult(RestResult<T> result, T data) {
result.setSuccess(true);
result.setData(data);
return result;
}
/**
* 是否为成功的结果
*
* @param result 结果
* @return true:成功的结果,false:失败的结果
*/
public static boolean isSuccess(RestResult result) {
return result != null && result.isSuccess();
}
}
/*
* Miya.com Inc.
* Copyright (c) 2004-2018 All Rights Reserved.
*/
package com.miya.draw.config.swagger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
/**
* @author ${zhangguodong}
* @version $Id: swagger2.java, v 0.1 2018年08月06日 11:19 ${zhangguodong} Exp $
*/
@Configuration
public class Swagger2Configuration {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(true)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.miya.draw.controller"))
.paths(PathSelectors.any())
.build()
// .pathMapping("/api")
;
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("抽奖项目文档")
//api描述
.description("")
//外链详细信息地址
.termsOfServiceUrl("")
.version("1.0.0")
.build();
}
}
package com.miya.draw.config.xxl;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author tianjunwei
* @date 2018/11/28 20:07
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "xxl.job")
public class XXlJobConfigProperty {
private Admin admin;
private Executor executor;
@Data
public static class Executor{
//应用名称
private String appname;
private String ip;
//服务端口
private Integer port;
}
@Data
public static class Admin{
//注册中心地址
private String addresses;
}
}
package com.miya.draw.config.xxl;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import javax.annotation.Resource;
import java.util.Arrays;
/**
* xxljob配置
*
* @author jack
*/
@Slf4j
@Configuration
public class XxlJobConfig {
/**
* 默认环境
*/
private static final String DEFAULT = "default";
@Resource
private XXlJobConfigProperty xxlJobConfigProperty;
@Resource
private Environment environment;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
if (environment.getActiveProfiles().length <= 0 ||
Arrays.stream(environment.getActiveProfiles()).allMatch(x -> x.equals(DEFAULT))) {
return null;
}
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(xxlJobConfigProperty.getAdmin().getAddresses());
xxlJobSpringExecutor.setAppName(xxlJobConfigProperty.getExecutor().getAppname());
xxlJobSpringExecutor.setIp(xxlJobConfigProperty.getExecutor().getIp());
xxlJobSpringExecutor.setPort(xxlJobConfigProperty.getExecutor().getPort());
return xxlJobSpringExecutor;
}
}
package com.miya.draw.controller;
import cn.hutool.core.bean.copier.BeanCopier;
import cn.hutool.core.bean.copier.CopyOptions;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.miya.draw.config.response.RestResult;
import com.miya.draw.config.response.RestResultUtil;
import com.miya.draw.manager.IDrawManager;
import com.miya.draw.model.DrawModel;
import com.miya.draw.request.*;
import com.miya.draw.response.DrawClickResponse;
import com.miya.draw.response.DrawUserInfoGainResponse;
import com.miya.draw.response.MinePrizeGainResponse;
import com.miya.draw.response.PrizeDrawListResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 抽奖Controller
*
* @author jack
*/
@Api(tags = "抽奖模块")
@RestController
@RequestMapping(value = "/draw/")
public class DrawController {
@Autowired
private IDrawManager drawManager;
@ApiOperationSupport(author = "jack")
@ApiOperation(value = "用户点击活动页面弹出的信息提示")
@PostMapping(value = "user/info/gain")
public RestResult<DrawUserInfoGainResponse> gainUserInfo(@RequestBody @Valid DrawUserInfoGainRequest request) {
DrawModel drawModel = drawManager.gainActivityUserInfo(request);
BeanCopier<DrawUserInfoGainResponse> copier = BeanCopier.create(drawModel, DrawUserInfoGainResponse.builder().build(), CopyOptions.create());
return RestResultUtil.createSuccessResult(copier.copy());
}
@ApiOperationSupport(author = "jack")
@ApiOperation(value = "用户点击活抽奖")
@PostMapping(value = "draw/click")
public RestResult<DrawClickResponse> drawClick(@RequestBody @Valid DrawClickRequest request) throws InterruptedException {
DrawModel drawModel = drawManager.drawClick(request.getPhone());
BeanCopier<DrawClickResponse> beanCopier = BeanCopier.create(drawModel, DrawClickResponse.builder().build(), CopyOptions.create());
DrawClickResponse response = beanCopier.copy();
return RestResultUtil.createSuccessResult(response);
}
@ApiOperationSupport(author = "jack")
@ApiOperation(value = "获得我的奖品")
@PostMapping(value = "gain/mine/prize")
public RestResult<List<MinePrizeGainResponse>> gainMinePrize(@RequestBody @Valid MinePrizeGainRequest request) {
List<DrawModel> drawModelList = drawManager.listMinePrizeList(request.getPhone());
List<MinePrizeGainResponse> minePrizeGainResponseList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(drawModelList)) {
minePrizeGainResponseList = drawModelList.stream().map(drawModel -> {
BeanCopier<MinePrizeGainResponse> copier = BeanCopier.create(drawModel, MinePrizeGainResponse.builder().build(), CopyOptions.create());
MinePrizeGainResponse response = copier.copy();
response.setMyPrizeId(drawModel.getId());
return response;
}).collect(Collectors.toList());
}
return RestResultUtil.createSuccessResult(minePrizeGainResponseList);
}
@ApiOperationSupport(author = "jack")
@ApiOperation(value = "用户填写地址")
@PostMapping(value = "prize/address/modify")
public RestResult<Void> modifyPrizeAddress(@RequestBody @Valid PrizeAddressModifyRequest request) {
drawManager.updateMinePrizeAddress(request.getPhone(), request.getMyPrizeId(), request.getConsigneeName(),
request.getConsigneePhone(), request.getConsigneeAddress(), request.getConsigneeIdcard());
return RestResultUtil.createSuccessResult();
}
@ApiOperationSupport(author = "jack")
@ApiOperation(value = "整体中奖情况")
@PostMapping(value = "prize/draw/list")
public RestResult<List<PrizeDrawListResponse>> prizeDrawList(@RequestBody @Valid PrizeDrawListRequest request) {
List<DrawModel> drawModelList = drawManager.listAllWinningInfo(request.getSize());
List<PrizeDrawListResponse> prizeDrawListResponses = new ArrayList<>();
if (CollectionUtils.isNotEmpty(drawModelList)) {
PrizeDrawListResponse response = PrizeDrawListResponse.builder().build();
prizeDrawListResponses = drawModelList.stream().map(drawModel -> {
BeanCopier<PrizeDrawListResponse> copier = BeanCopier.create(drawModel, response, CopyOptions.create());
return copier.copy();
}).collect(Collectors.toList());
}
return RestResultUtil.createSuccessResult(prizeDrawListResponses);
}
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-08
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Account对象", description="")
public class Account implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "小程序登录授权码")
private String token;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-08
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="AccountPrize对象", description="")
public class AccountPrize implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "账号名称")
private String accountName;
@ApiModelProperty(value = "账户手机")
private String accountPhone;
@ApiModelProperty(value = "奖品id")
private Long prizeId;
@ApiModelProperty(value = "奖品名称")
private String prizeName;
@ApiModelProperty(value = "奖品类型 1实物 2虚拟 3未中奖")
private Integer prizeType;
@ApiModelProperty(value = "收件人姓名")
private String consigneeName;
@ApiModelProperty(value = "收件人手机")
private String consigneePhone;
@ApiModelProperty(value = "收件人地址")
private String consigneeAddress;
@ApiModelProperty(value = "收件人身份证号")
private String consigneeIdcard;
@ApiModelProperty(value = "是否已经同步到十足 0否 1是")
private Integer syncStatus;
@ApiModelProperty(value = "虚拟券发送状态 1已发送 0未发送")
private Integer sendStatus;
@ApiModelProperty(value = "虚拟券发送信息")
private String sendMessage;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ActivityGoods对象", description="")
public class ActivityGoods implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "活动id")
private Long activityId;
@ApiModelProperty(value = "活动商品名称")
private String goodsName;
@ApiModelProperty(value = "货号")
private String code;
@ApiModelProperty(value = "条形码")
private String barcode;
@ApiModelProperty(value = "新小类")
private String newType;
@ApiModelProperty(value = "有效状态 0无效 1有效")
private Integer validState;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ActivityStore对象", description="")
public class ActivityStore implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "活动门店id")
private String storeId;
@ApiModelProperty(value = "活动门店名称")
private String storeName;
@ApiModelProperty(value = "活动id")
private Long activityId;
@ApiModelProperty(value = "有效状态 0无效 1有效")
private Integer validState;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-08
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Prize对象", description="")
public class Prize implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "奖品名称")
private String prizeName;
@ApiModelProperty(value = "奖品图片")
private String prizeImg;
@ApiModelProperty(value = "奖品描述")
private String prizeDesc;
@ApiModelProperty(value = "1实物 2虚拟 3未中奖")
private Integer prizeType;
@ApiModelProperty(value = "虚拟券id")
private String couponId;
@ApiModelProperty(value = "奖品数量")
private Integer prizeNum;
@ApiModelProperty(value = "奖品概率(百万分之一)")
private BigDecimal prizeOdds;
@ApiModelProperty(value = "活动id")
private Long activityId;
@ApiModelProperty(value = "是否有效 0无效 1有效")
private Integer validStatus;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SyncRecord对象", description="")
public class SyncRecord implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "上次同步到的时间")
private LocalDateTime lastSyncTime;
@ApiModelProperty(value = "上次同步到的id")
private Long lastSyncId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SyncTrade对象", description="")
public class SyncTrade implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "十足同步表的主键")
private Long billNo;
@ApiModelProperty(value = "交易ID")
private String tradeIdId;
@ApiModelProperty(value = "交易uuid")
private String uuid;
@ApiModelProperty(value = "交易类型 sale和refund")
private String type;
@ApiModelProperty(value = "pos号")
private String posNo;
@ApiModelProperty(value = "会员关联手机号")
private String phone;
@ApiModelProperty(value = "会员号")
private String memberId;
@ApiModelProperty(value = "交易号")
private String tradeNo;
@ApiModelProperty(value = "门店id")
private String storeId;
@ApiModelProperty(value = "门店名称")
private String storeName;
@ApiModelProperty(value = "交易时间")
private LocalDateTime tranTime;
@ApiModelProperty(value = "商品代码")
private String code;
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "商品条码")
private String barcode;
@ApiModelProperty(value = "商品价格")
private BigDecimal price;
@ApiModelProperty(value = "购买数量")
private BigDecimal qty;
@ApiModelProperty(value = "原总金额")
private BigDecimal stdAmount;
@ApiModelProperty(value = "优惠金额")
private BigDecimal favAmount;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="SyncTradeGood对象", description="")
public class SyncTradeGood implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "交易uuid")
private String tradeUuid;
@ApiModelProperty(value = "商品代码")
private String code;
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "商品条码")
private String barcode;
@ApiModelProperty(value = "商品价格")
private BigDecimal price;
@ApiModelProperty(value = "购买数量")
private BigDecimal qty;
@ApiModelProperty(value = "原总金额")
private BigDecimal stdAmount;
@ApiModelProperty(value = "优惠金额")
private BigDecimal favAmount;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
package com.miya.draw.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Trade对象", description="")
public class Trade implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "序号")
@TableId(value = "billno", type = IdType.AUTO)
private Integer billno;
@ApiModelProperty(value = "交易ID")
@TableField("tradeIdId")
private String tradeidid;
@ApiModelProperty(value = "流水id")
private String uuid;
@ApiModelProperty(value = "门店号")
@TableField("storeId")
private String storeid;
@ApiModelProperty(value = "门店名称")
@TableField("storeName")
private String storename;
@ApiModelProperty(value = "小票号")
@TableField("tradeNo")
private String tradeno;
@ApiModelProperty(value = "POS机号")
@TableField("posNo")
private String posno;
@ApiModelProperty(value = "交易类型")
private String type;
@ApiModelProperty(value = "交易时间")
@TableField("tranTime")
private LocalDateTime trantime;
@ApiModelProperty(value = "货号")
private String code;
@ApiModelProperty(value = "条码")
private String barcode;
@ApiModelProperty(value = "商品名称")
private String name;
@ApiModelProperty(value = "品牌")
@TableField("brandCode")
private String brandcode;
@ApiModelProperty(value = "类别")
@TableField("categoryCode")
private String categorycode;
@ApiModelProperty(value = "包装规格")
@TableField("qpcStr")
private String qpcstr;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "数量")
private Integer qty;
@ApiModelProperty(value = "原总金额")
@TableField("stdAmount")
private BigDecimal stdamount;
@ApiModelProperty(value = "优惠金额")
@TableField("favAmount")
private BigDecimal favamount;
@ApiModelProperty(value = "会员id")
@TableField("memberId")
private String memberid;
@ApiModelProperty(value = "手机号")
@TableField("identityId")
private String identityid;
@ApiModelProperty(value = "插入时间")
private LocalDateTime sendtime;
@ApiModelProperty(value = "更新状态")
private String status;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updatetime;
}
package com.miya.draw.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author jack
* @since 2021-05-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Winner对象", description="")
public class Winner implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long winnerId;
@ApiModelProperty(value = "账号名称")
private String accountName;
@ApiModelProperty(value = "账户手机")
private String accountPhone;
@ApiModelProperty(value = "奖品id")
private Long prizeId;
@ApiModelProperty(value = "奖品名称")
private String prizeName;
@ApiModelProperty(value = "奖品类型 1实物 2虚拟")
private Integer prizeType;
@ApiModelProperty(value = "收件人姓名")
private String consigneeName;
@ApiModelProperty(value = "收件人手机")
private String consigneePhone;
@ApiModelProperty(value = "收件人地址")
private String consigneeAddress;
@ApiModelProperty(value = "收件人身份证号")
private String consigneeIdcard;
@ApiModelProperty(value = "同步id 用于后续更新")
private Long syncId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "更新时间")
private LocalDateTime updateTime;
}
/*
* Miya.com Inc.
* Copyright (c) 2004-2018 All Rights Reserved.
*/
package com.miya.draw.enums;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 错误异常枚举类
*
* @author 15293
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum ErrorEnum {
/**
* 未知异常
*/
UNKNOWN_EXP("000", "未知异常", "不可预知的异常"),
/**
* 系统异常
*/
SYSTEM_EXP("001", "系统异常", "数据库层错误,网络层错误等属于系统本身的异常"),
/**
* HTTP
*/
HTTP_REQ_EXP("002", "HTTP_REQ_EXP", "http调用异常"),
/**
* 重试一定次数后没有成功抛出此异常
*/
RETRY_EXP("003", "RETRY_EXP", "重试失败"),
/**
* 参数效验异常
*/
PARAM_CHECK_EXP("004", "PARAM_CHECK_EXP", "参数效验异常"),
/**
* 抽奖错误
*/
DRAW_CHECK_EXP("005", "DRAW_CHECK_EXP", "抽奖异常"),
/**
* 接口已限流
*/
SENTINEL_FLOW_EXCEPTION("1000", "接口已限流", "接口已限流"),
/**
* 接口已降级
*/
SENTINEL_DEGRADE_EXCEPTION("1001", "接口已降级", "接口已降级"),
/**
* 接口已热点限流
*/
SENTINEL_PARAM_FLOW_EXCEPTION("1002", "接口已热点限流", "接口已热点限流"),
/**
* 接口被系统规则限制 接口被系统规则限制
*/
SENTINEL_SYSTEM_EXCEPTION("1003", "接口被系统规则限制", "接口被系统规则限制"),
/**
* 授权规则不通过
*/
SENTINEL_AUTHORITY_EXCEPTION("1004", "授权规则不通过", "授权规则不通过"),
/**
* 未知限流异常
*/
SENTINEL_UNKNOWN_EXCEPTION("1005", "未知限流异常", "未知限流异常"),
;
private final String code;
private final String message;
private final String description;
}
\ No newline at end of file
package com.miya.draw.enums;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 奖品类型Enum
*
* @author jack
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum PrizeTypeEnum {
/**
* 虚拟
*/
VIRTUAL(2, "虚拟"),
/**
* 实物
*/
PHYSICAL(1, "实物"),
NO_COUPON(3, "未中奖");
private final Integer code;
private final String name;
}
package com.miya.draw.enums;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 交易类型枚举
*
* @author jack
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum TradeTypeEnum {
/**
* 销售
*/
SALE("sale", "销售"),
/**
* 退款
*/
REFUND("refund", "退款");
private final String type;
private final String name;
}
package com.miya.draw.enums;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 是否枚举
* @author jack
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum YesOrNoEnum {
/**
* 成功
*/
YES(1, "成功"),
/**
* 失败
*/
NO(0, "失败");
private final Integer code;
private final String name;
}
This diff is collapsed.
package com.miya.draw.manager;
import com.miya.draw.model.DrawModel;
import com.miya.draw.request.DrawUserInfoGainRequest;
import java.util.List;
/**
* Manager
*/
public interface IDrawManager {
/**
* 获得活动有关的用户信息
*
* @param request request
* @return DrawModel
*/
DrawModel gainActivityUserInfo(DrawUserInfoGainRequest request);
/**
* 获得我的奖品列表
*
* @param phone
* @return
*/
List<DrawModel> listMinePrizeList(String phone);
/**
* 修改我的奖品的地址信息
*
* @param phone
* @param myPrizeId
* @param consigneeName
* @param consigneePhone
* @param consigneeAddress
* @param consigneeIdcard
*/
void updateMinePrizeAddress(String phone, Long myPrizeId, String consigneeName, String consigneePhone, String consigneeAddress, String consigneeIdcard);
/**
* 用户点击抽奖
*
* @param phone
* @return
*/
DrawModel drawClick(String phone) throws InterruptedException;
/**
* 获得所有的中奖信息
* @param size
* @return
*/
List<DrawModel> listAllWinningInfo(Integer size);
}
package com.miya.draw.manager;
import org.springframework.scheduling.annotation.Async;
/**
* 其他处理
* @author jack
*/
public interface IOtherManager {
/**
* 发券
*
* @param couponId 奖品
* @param phone 手机号
* @param accountPrizeId 领奖记录Id
*/
@Async
void sendCoupon(String couponId, String phone, Long accountPrizeId);
}
This diff is collapsed.
package com.miya.draw.mapper;
import com.miya.draw.entity.Account;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author jack
* @since 2021-05-07
*/
public interface AccountMapper extends BaseMapper<Account> {
}
package com.miya.draw.mapper;
import com.miya.draw.entity.AccountPrize;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author jack
* @since 2021-05-07
*/
public interface AccountPrizeMapper extends BaseMapper<AccountPrize> {
}
package com.miya.draw.mapper;
import com.miya.draw.entity.ActivityGoods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author jack
* @since 2021-05-07
*/
public interface ActivityGoodsMapper extends BaseMapper<ActivityGoods> {
}
package com.miya.draw.mapper;
import com.miya.draw.entity.ActivityStore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author jack
* @since 2021-05-07
*/
public interface ActivityStoreMapper extends BaseMapper<ActivityStore> {
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment