Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
data-server
Commits
2a195619
Commit
2a195619
authored
Feb 27, 2021
by
codezwjava
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
d0e182fe
72fc0552
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1146 additions
and
135 deletions
+1146
-135
pom.xml
pom.xml
+31
-0
FileCreateNameUtils.java
...n/java/cn/wisenergy/common/utils/FileCreateNameUtils.java
+53
-0
FrameGrabberKit.java
.../main/java/cn/wisenergy/common/utils/FrameGrabberKit.java
+91
-0
MemberPercentMapper.java
...rc/main/java/cn/wisenergy/mapper/MemberPercentMapper.java
+9
-7
ShopZxMapper.java
...apper/src/main/java/cn/wisenergy/mapper/ShopZxMapper.java
+38
-0
TeamPerformanceMapper.java
.../main/java/cn/wisenergy/mapper/TeamPerformanceMapper.java
+29
-0
UsersMapper.java
...mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
+6
-0
MemberPercentMapper.xml
...-mapper/src/main/resources/mapper/MemberPercentMapper.xml
+22
-8
ShopZxMapper.xml
wisenergy-mapper/src/main/resources/mapper/ShopZxMapper.xml
+63
-0
TeamPerformanceMapper.xml
...apper/src/main/resources/mapper/TeamPerformanceMapper.xml
+109
-0
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+10
-0
wisenergy-mapper.iml
wisenergy-mapper/wisenergy-mapper.iml
+26
-2
MemberPercent.java
...l/src/main/java/cn/wisenergy/model/app/MemberPercent.java
+9
-3
TeamPerformance.java
...src/main/java/cn/wisenergy/model/app/TeamPerformance.java
+64
-0
shopZx.java
...gy-model/src/main/java/cn/wisenergy/model/app/shopZx.java
+17
-81
AccountManager.java
...ain/java/cn/wisenergy/service/Manager/AccountManager.java
+23
-8
PublicManager.java
...main/java/cn/wisenergy/service/Manager/PublicManager.java
+32
-0
AccountService.java
...rc/main/java/cn/wisenergy/service/app/AccountService.java
+1
-1
UploadService.java
...src/main/java/cn/wisenergy/service/app/UploadService.java
+44
-0
UserService.java
...e/src/main/java/cn/wisenergy/service/app/UserService.java
+1
-2
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+107
-19
UploadServiceImpl.java
...java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
+179
-0
UserServiceImpl.java
...n/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
+0
-4
UploadController.java
.../wisenergy/web/admin/controller/app/UploadController.java
+178
-0
MyBatisPlusConfig.java
.../main/java/cn/wisenergy/web/config/MyBatisPlusConfig.java
+4
-0
No files found.
pom.xml
View file @
2a195619
...
@@ -111,6 +111,37 @@
...
@@ -111,6 +111,37 @@
<version>
2.2.6
</version>
<version>
2.2.6
</version>
</dependency>
</dependency>
<!-- 视频获取第一帧 -->
<dependency>
<groupId>
org.bytedeco
</groupId>
<artifactId>
javacv
</artifactId>
<version>
0.8
</version>
</dependency>
<!--<!–druid数据源 –>-->
<!--<dependency>-->
<!--<groupId>com.alibaba</groupId>-->
<!--<artifactId>druid</artifactId>-->
<!--<version>1.1.9</version>-->
<!--</dependency>-->
<!--<!– 文件上传 –>-->
<!--<dependency>-->
<!--<groupId>commons-fileupload</groupId>-->
<!--<artifactId>commons-fileupload</artifactId>-->
<!--<version>1.3.3</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>commons-io</groupId>-->
<!--<artifactId>commons-io</artifactId>-->
<!--<version>2.4</version>-->
<!--</dependency>-->
<!-- 阿里巴巴JSON处理器 -->
<!--<dependency>-->
<!--<groupId>com.alibaba</groupId>-->
<!--<artifactId>fastjson</artifactId>-->
<!--<version>1.2.31</version>-->
<!--</dependency>-->
</dependencies>
</dependencies>
<!-- MVN构建插件 -->
<!-- MVN构建插件 -->
...
...
wisenergy-common/src/main/java/cn/wisenergy/common/utils/FileCreateNameUtils.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
common
.
utils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Random
;
/**
* Created by m1991 on 2021/2/26 11:10
*/
public
class
FileCreateNameUtils
{
public
static
final
String
numberChar
=
"0123456789"
;
/***
* 文件名生成工具类
*/
public
static
String
toCreateName
()
{
return
getNowDatetoString
()
+
generateNum
(
10
);
}
/***
* 生成日期字符串 yyyyMMddHHmm
*
* @author MRC
* @date 2019年4月16日下午2:19:37
* @return
*/
public
static
String
getNowDatetoString
()
{
Date
currentTime
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMddHHmm"
);
String
dateString
=
formatter
.
format
(
currentTime
);
return
dateString
;
}
/***
* 生成随机数
* @author MRC
* @date 2019年4月16日下午2:21:06
* @param len
* @return
*/
public
static
String
generateNum
(
int
len
)
{
StringBuffer
sb
=
new
StringBuffer
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
sb
.
append
(
numberChar
.
charAt
(
random
.
nextInt
(
numberChar
.
length
())));
}
return
sb
.
toString
();
}
}
wisenergy-common/src/main/java/cn/wisenergy/common/utils/FrameGrabberKit.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
common
.
utils
;
import
java.awt.Image
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
javax.imageio.ImageIO
;
import
org.bytedeco.javacpp.opencv_core
;
import
org.bytedeco.javacv.FFmpegFrameGrabber
;
import
org.bytedeco.javacv.Frame
;
/**
* 截取视频图片
* @ClassName: FrameGrabberKit
*/
public
class
FrameGrabberKit
{
/**
* 获取视频图片
* @param videofile 源视频文件路径
* @param framefile 截取帧的图片存放路径
* @param imgfile 视频封面图保存路径
* @return
*/
public
static
String
getVedioImg
(
String
videofile
,
String
framefile
,
String
imgfile
){
String
ImgUrl
=
""
;
//截取封面图
try
{
fetchFrame
(
videofile
,
framefile
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// 完整的ImgUrl
ImgUrl
=
imgfile
;
//视频封面图保存路径
return
ImgUrl
;
}
/**
* 获取指定视频的帧并保存为图片至指定目录
* @param videofile 源视频文件路径
* @param framefile 截取帧的图片存放路径 例:F:\hfkjrecorder\target\4.jpg
* @throws Exception
*/
public
static
void
fetchFrame
(
String
videofile
,
String
framefile
)
throws
Exception
{
long
start
=
System
.
currentTimeMillis
();
File
targetFile
=
new
File
(
framefile
);
FFmpegFrameGrabber
ff
=
new
FFmpegFrameGrabber
(
videofile
);
ff
.
start
();
int
lenght
=
ff
.
getLengthInFrames
();
int
i
=
0
;
int
interceptionFrames
=
30
;
//截取第几帧
//默认截取第50帧,如果第50帧大于视频总帧数的8成直接取长度lenght * 0.3
if
(
interceptionFrames
>=
lenght
*
0.8
)
{
interceptionFrames
=
(
int
)(
lenght
*
0.3
);
}
Frame
f
=
null
;
while
(
i
<
lenght
)
{
// 过滤 前 interceptionFrames 帧,避免出现全黑的图片,依自己情况而定
f
=
ff
.
grabFrame
();
if
((
i
>
interceptionFrames
)
&&
(
f
.
image
!=
null
))
{
break
;
}
i
++;
}
opencv_core
.
IplImage
img
=
f
.
image
;
int
owidth
=
img
.
width
();
int
oheight
=
img
.
height
();
// 对截取的帧进行等比例缩放 宽350、高160
// if(owidth > oheight) {//宽大于高
//
// }else {//高大于宽
//
// }
int
width
=
800
;
int
height
=
(
int
)
(((
double
)
width
/
owidth
)
*
oheight
);
/**
width - 所创建图像的宽度
height - 所创建图像的高度
imageType - 所创建图像的类型
TYPE_3BYTE_BGR - 表示一个具有 8 位 RGB 颜色分量的图像,对应于 Windows 风格的 BGR 颜色模型,具有用 3 字节存储的 Blue、Green 和 Red 三种颜色。
*/
BufferedImage
bi
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_3BYTE_BGR
);
//此方法返回 Graphics2D,但此处是出于向后兼容性的考虑。
bi
.
getGraphics
().
drawImage
(
f
.
image
.
getBufferedImage
().
getScaledInstance
(
width
,
height
,
Image
.
SCALE_SMOOTH
),
0
,
0
,
null
);
ImageIO
.
write
(
bi
,
"jpg"
,
targetFile
);
ff
.
flush
();
ff
.
stop
();
System
.
out
.
println
(
System
.
currentTimeMillis
()
-
start
);
}
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/
Rebate
Mapper.java
→
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/
MemberPercent
Mapper.java
View file @
2a195619
package
cn
.
wisenergy
.
mapper
;
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.
Rebate
;
import
cn.wisenergy.model.app.
MemberPercent
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
/**
/**
* @author 86187
* @author 86187
*/
*/
public
interface
RebateMapper
extends
BaseMapper
<
Rebate
>
{
public
interface
MemberPercentMapper
extends
BaseMapper
<
MemberPercent
>
{
/**
/**
*
*
* @param
rebate
入参
* @param
memberpercent
入参
* @return 1
* @return 1
*/
*/
int
add
(
Rebate
rebate
);
int
add
(
MemberPercent
memberpercent
);
/**
/**
* 编辑
* 编辑
* @param
rebate
入参
* @param
memberpercent
入参
* @return 1
* @return 1
*/
*/
int
edit
(
Rebate
rebate
);
int
edit
(
MemberPercent
memberpercent
);
/**
/**
* 删除
* 删除
...
@@ -34,6 +34,8 @@ public interface RebateMapper extends BaseMapper<Rebate> {
...
@@ -34,6 +34,8 @@ public interface RebateMapper extends BaseMapper<Rebate> {
* @param userLevel 会员等级
* @param userLevel 会员等级
* @return 返佣比例
* @return 返佣比例
*/
*/
Rebate
getByLevel
(
@Param
(
"userLevel"
)
Integer
userLevel
);
MemberPercent
getByLevel
(
@Param
(
"userLevel"
)
Integer
userLevel
);
MemberPercent
getByLevelAndType
(
@Param
(
"userLevel"
)
Integer
userLevel
,
@Param
(
"type"
)
Integer
type
);
}
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ShopZxMapper.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.shopZx
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* Created by m1991 on 2021/2/24 14:50
*/
@Mapper
public
interface
ShopZxMapper
extends
BaseMapper
<
shopZx
>
{
/**
* 添加方法 zxUrl userId zxName zxField imgUrl
* @param
* @return 1
*/
int
zxadd
(
@Param
(
"zxUrl"
)
String
zxUrl
,
@Param
(
"userId"
)
String
userId
,
@Param
(
"zxName"
)
String
zxName
,
@Param
(
"zxField"
)
String
zxField
,
@Param
(
"imgUrl"
)
String
imgUrl
,
@Param
(
"zxAddress"
)
String
zxAddress
);
/**分页 资讯内容倒叙查询
* PageSize int, --每页的记录数量,比如10条
* @param
* @return
*/
List
<
shopZx
>
selectAll
(
@Param
(
"PageSize"
)
int
PageSize
);
// /**查询方法
// * @param
// * @return
// */
// List<shopZx> selectAllNum(@Param("") int ,@Param("") int );
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/TeamPerformanceMapper.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
mapper
;
import
cn.wisenergy.model.app.TeamPerformance
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
/**
* @author 86187
*/
public
interface
TeamPerformanceMapper
extends
BaseMapper
<
TeamPerformance
>
{
int
add
(
TeamPerformance
teamPerformance
);
int
edit
(
TeamPerformance
teamPerformance
);
int
delById
(
@Param
(
"id"
)
Integer
id
);
TeamPerformance
getByUserIdAndTime
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"yearMonth"
)
Date
yearMonth
);
/**
* 统计
* @param userLevel 等级
* @param yearMonth 年月
* @return 等级总金额
*/
Double
countTeamMoney
(
@Param
(
"userLevel"
)
Integer
userLevel
,
@Param
(
"yearMonth"
)
Date
yearMonth
);
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/UsersMapper.java
View file @
2a195619
...
@@ -62,4 +62,10 @@ public interface UsersMapper extends BaseMapper<User> {
...
@@ -62,4 +62,10 @@ public interface UsersMapper extends BaseMapper<User> {
*/
*/
User
getByBeInvitedCode
(
@Param
(
"beInvitedCode"
)
String
beInvitedCode
);
User
getByBeInvitedCode
(
@Param
(
"beInvitedCode"
)
String
beInvitedCode
);
/**
* 获取黄金树以上会员用户
* @return
*/
List
<
User
>
getAllGoldUser
();
}
}
wisenergy-mapper/src/main/resources/mapper/
Rebate
Mapper.xml
→
wisenergy-mapper/src/main/resources/mapper/
MemberPercent
Mapper.xml
View file @
2a195619
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wisenergy.mapper.
Rebate
Mapper"
>
<mapper
namespace=
"cn.wisenergy.mapper.
MemberPercent
Mapper"
>
<resultMap
id=
"userMap"
type=
"cn.wisenergy.model.app.
Rebate
"
>
<resultMap
id=
"userMap"
type=
"cn.wisenergy.model.app.
MemberPercent
"
>
<id
column=
"id"
property=
"id"
/>
<id
column=
"id"
property=
"id"
/>
<result
column=
"user_level"
property=
"userLevel"
/>
<result
column=
"user_level"
property=
"userLevel"
/>
<result
column=
"type"
property=
"type"
/>
<result
column=
"percent"
property=
"percent"
/>
<result
column=
"percent"
property=
"percent"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
</resultMap>
<sql
id=
"table"
>
<sql
id=
"table"
>
rebate
member_percent
</sql>
</sql>
<sql
id=
"cols_all"
>
<sql
id=
"cols_all"
>
...
@@ -20,15 +21,16 @@
...
@@ -20,15 +21,16 @@
</sql>
</sql>
<sql
id=
"cols_exclude_id"
>
<sql
id=
"cols_exclude_id"
>
user_level,percent,create_time,update_time
user_level,
type,
percent,create_time,update_time
</sql>
</sql>
<sql
id=
"vals"
>
<sql
id=
"vals"
>
#{userLevel},#{percent},now(),now()
#{userLevel},#{
type},#{
percent},now(),now()
</sql>
</sql>
<sql
id=
"updateCondition"
>
<sql
id=
"updateCondition"
>
<if
test=
"userLevel != null"
>
user_level = #{userLevel},
</if>
<if
test=
"userLevel != null"
>
user_level = #{userLevel},
</if>
<if
test=
"type != null"
>
type = #{type},
</if>
<if
test=
"percent != null"
>
percent =#{percent},
</if>
<if
test=
"percent != null"
>
percent =#{percent},
</if>
update_time =now()
update_time =now()
</sql>
</sql>
...
@@ -36,12 +38,13 @@
...
@@ -36,12 +38,13 @@
<sql
id=
"criteria"
>
<sql
id=
"criteria"
>
<if
test=
"id != null"
>
id = #{id}
</if>
<if
test=
"id != null"
>
id = #{id}
</if>
<if
test=
"userLevel != null"
>
and user_level = #{userLevel}
</if>
<if
test=
"userLevel != null"
>
and user_level = #{userLevel}
</if>
<if
test=
"type != null"
>
and type = #{type}
</if>
<if
test=
"percent != null"
>
and percent =#{percent}
</if>
<if
test=
"percent != null"
>
and percent =#{percent}
</if>
<if
test=
"createTime != null"
>
and create_time
>
= #{createTime}
</if>
<if
test=
"createTime != null"
>
and create_time
>
= #{createTime}
</if>
<if
test=
"updateTime != null"
>
and #{updateTime}
>
= update_time
</if>
<if
test=
"updateTime != null"
>
and #{updateTime}
>
= update_time
</if>
</sql>
</sql>
<insert
id=
"add"
parameterType=
"cn.wisenergy.model.app.
Rebate
"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
<insert
id=
"add"
parameterType=
"cn.wisenergy.model.app.
MemberPercent
"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into
insert into
<include
refid=
"table"
/>
<include
refid=
"table"
/>
(
<include
refid=
"cols_exclude_id"
/>
)
(
<include
refid=
"cols_exclude_id"
/>
)
...
@@ -50,7 +53,7 @@
...
@@ -50,7 +53,7 @@
)
)
</insert>
</insert>
<update
id=
"edit"
parameterType=
"cn.wisenergy.model.app.
Rebate
"
>
<update
id=
"edit"
parameterType=
"cn.wisenergy.model.app.
MemberPercent
"
>
UPDATE
UPDATE
<include
refid=
"table"
/>
<include
refid=
"table"
/>
<set>
<set>
...
@@ -67,7 +70,7 @@
...
@@ -67,7 +70,7 @@
where id = #{id}
where id = #{id}
</delete>
</delete>
<select
id=
"getByLevel"
resultType=
"cn.wisenergy.model.app.
Rebate
"
>
<select
id=
"getByLevel"
resultType=
"cn.wisenergy.model.app.
MemberPercent
"
>
select
select
<include
refid=
"cols_all"
/>
<include
refid=
"cols_all"
/>
from
from
...
@@ -77,4 +80,15 @@
...
@@ -77,4 +80,15 @@
</where>
</where>
</select>
</select>
<select
id=
"getByLevelAndType"
resultType=
"cn.wisenergy.model.app.MemberPercent"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
user_level=#{userLevel}
and type=#{type}
</where>
</select>
</mapper>
</mapper>
wisenergy-mapper/src/main/resources/mapper/ShopZxMapper.xml
0 → 100644
View file @
2a195619
<?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=
"cn.wisenergy.mapper.ShopZxMapper"
>
<resultMap
id=
"zxMap"
type=
"cn.wisenergy.model.app.shopZx"
>
<id
column=
"zxid"
property=
"zxid"
/>
<result
column=
"zxUrl"
property=
"zxUrl"
/>
<result
column=
"zxLikes"
property=
"zxLikes"
/>
<result
column=
"userid"
property=
"userid"
/>
<result
column=
"zxName"
property=
"zxName"
/>
<result
column=
"zxShenHe"
property=
"zxShenHe"
/>
<result
column=
"zxField"
property=
"zxField"
/>
<result
column=
"zxAddress"
property=
"zxAddress"
/>
<result
column=
"imgUrl"
property=
"imgUrl"
/>
</resultMap>
<sql
id=
"table"
>
shop_zx
</sql>
<sql
id=
"cols_all"
>
zxid,
<include
refid=
"cols_exclude_id"
/>
</sql>
<sql
id=
"cols_exclude_id"
>
zxUrl,userId,zxName,zxField,imgUrl,zxAddress
</sql>
<sql
id=
"vals"
>
#{zxUrl},#{userId},#{zxName},#{zxField},#{imgUrl},#{zxAddress}
</sql>
<!--资讯内容插入-->
<insert
id=
"zxadd"
parameterType=
"cn.wisenergy.model.app.shopZx"
>
insert into
<include
refid=
"table"
/>
(
<include
refid=
"cols_exclude_id"
/>
)
value(
<include
refid=
"vals"
/>
)
</insert>
<!--资讯内容插入-->
<!--<insert id="zxadd" parameterType="cn.wisenergy.model.app.shopZx" >-->
<!--INSERT INTO-->
<!--(zxUrl, userId,zxName,zxField,imgUrl)-->
<!--VALUES(-->
<!--#{zxUrl},#{userid},#{zxName},#{zxField},#{imgUrl}-->
<!--)-->
<!--</insert>-->
<!--资讯内容倒叙查询-->
<select
id=
"selectAll"
parameterType=
"cn.wisenergy.model.app.shopZx"
resultType=
"cn.wisenergy.model.app.shopZx"
>
select zxid as zxid,zxUrl as zxUrl,
zxLikes as zxLikes,userid as userid,zxName as zxName,
zxShenHe as zxShenHe,zxField as zxField,zxDate as zxDate,
imgUrl as imgUrl,zxAddress as zxAddress from shop_zx order by zxid desc LIMIT PageSize,10
</select>
<!--资讯总记录数查询-->
<select
id=
"selectAllNum"
parameterType=
"cn.wisenergy.model.app.shopZx"
>
select count (*) from shop_zx
</select>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/TeamPerformanceMapper.xml
0 → 100644
View file @
2a195619
<?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=
"cn.wisenergy.mapper.TeamPerformanceMapper"
>
<resultMap
id=
"monthMap"
type=
"cn.wisenergy.model.app.TeamPerformance"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"user_id"
property=
"userId"
/>
<result
column=
"user_level"
property=
"userLevel"
/>
<result
column=
"year_month"
property=
"yearMonth"
/>
<result
column=
"month_team_performance"
property=
"monthTeamPerformance"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
<sql
id=
"table"
>
team_performance
</sql>
<sql
id=
"cols_all"
>
id,
<include
refid=
"cols_exclude_id"
/>
</sql>
<sql
id=
"cols_exclude_id"
>
user_id,user_level,year_month,month_team_performance,create_time,update_time
</sql>
<sql
id=
"vals"
>
#{userId},#{userLevel},#{yearMonth},#{monthTeamPerformance},now(),now()
</sql>
<sql
id=
"updateCondition"
>
<if
test=
"userId != null"
>
month_manure_total = #{userId},
</if>
<if
test=
"userLevel != null"
>
user_level = #{userLevel},
</if>
<if
test=
"yearMonth != null"
>
year_month =#{yearMonth},
</if>
<if
test=
"monthTeamPerformance != null"
>
month_team_performance =#{monthTeamPerformance},
</if>
update_time =now()
</sql>
<sql
id=
"criteria"
>
<if
test=
"id != null"
>
id = #{id}
</if>
<if
test=
"userId != null"
>
and month_manure_total = #{userId}
</if>
<if
test=
"userLevel != null"
>
and user_level = #{userLevel}
</if>
<if
test=
"yearMonth != null"
>
and year_month =#{yearMonth}
</if>
<if
test=
"monthTeamPerformance != null"
>
and month_team_performance =#{monthTeamPerformance}
</if>
<if
test=
"createTime != null"
>
and create_time
>
= #{createTime}
</if>
<if
test=
"updateTime != null"
>
and #{updateTime}
>
= update_time
</if>
</sql>
<insert
id=
"add"
parameterType=
"cn.wisenergy.model.app.TeamPerformance"
keyProperty=
"id"
useGeneratedKeys=
"true"
>
insert into
<include
refid=
"table"
/>
(
<include
refid=
"cols_exclude_id"
/>
)
value(
<include
refid=
"vals"
/>
)
</insert>
<update
id=
"edit"
parameterType=
"cn.wisenergy.model.app.TeamPerformance"
>
UPDATE
<include
refid=
"table"
/>
<set>
<include
refid=
"updateCondition"
/>
</set>
<where>
id = #{id}
</where>
</update>
<delete
id=
"delById"
parameterType=
"java.lang.Integer"
>
delete from
<include
refid=
"table"
/>
where id = #{id}
</delete>
<select
id=
"getByUserIdAndTime"
resultType=
"cn.wisenergy.model.app.TeamPerformance"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
<if
test=
"userId != null"
>
user_id = #{userId}
</if>
<if
test=
"yearMonth != null"
>
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
</where>
</select>
<select
id=
"countTeamMoney"
resultType=
"java.lang.Double"
>
select
sum(month_team_performance)
from
<include
refid=
"table"
/>
<where>
<if
test=
"userLevel != null"
>
user_level = #{userLevel}
</if>
<if
test=
"yearMonth != null"
>
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
</where>
</select>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
2a195619
...
@@ -205,6 +205,16 @@
...
@@ -205,6 +205,16 @@
</where>
</where>
</select>
</select>
<select
id=
"getAllGoldUser"
resultType=
"cn.wisenergy.model.app.User"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
user_level >3
</where>
</select>
<!--用户添加-->
<!--用户添加-->
<insert
id=
"save"
>
<insert
id=
"save"
>
insert into user(user_id,password) value (#{userId},#{password})
insert into user(user_id,password) value (#{userId},#{password})
...
...
wisenergy-mapper/wisenergy-mapper.iml
View file @
2a195619
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
</facet>
<facet
type=
"web"
name=
"Web"
>
<configuration>
<webroots
/>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
...
@@ -72,8 +82,6 @@
...
@@ -72,8 +82,6 @@
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.1.7.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.1.7.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-test:5.1.7.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-test:5.1.7.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.xmlunit:xmlunit-core:2.6.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.xmlunit:xmlunit-core:2.6.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.xml.bind:jaxb-api:2.3.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:javax.activation-api:1.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.zaxxer:HikariCP:3.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.zaxxer:HikariCP:3.2.0"
level=
"project"
/>
...
@@ -170,5 +178,21 @@
...
@@ -170,5 +178,21 @@
<orderEntry
type=
"library"
name=
"Maven: org.ow2.asm:asm:4.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.ow2.asm:asm:4.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.26"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.26"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.ehcache:ehcache:3.6.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.ehcache:ehcache:3.6.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco:javacv:0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco:javacpp:0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:opencv:2.4.9-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:ffmpeg:2.2.1-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:flycapture:1.7.17-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:libdc1394:2.2.2-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:libfreenect:0.4-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:videoinput:0.200-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:artoolkitplus:2.3.0-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:opencv:windows-x86_64:2.4.9-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:ffmpeg:windows-x86_64:2.2.1-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:flycapture:windows-x86_64:1.7.17-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:libdc1394:windows-x86_64:2.2.2-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:libfreenect:windows-x86_64:0.4-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:videoinput:windows-x86_64:0.200-0.8"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bytedeco.javacpp-presets:artoolkitplus:windows-x86_64:2.3.0-0.8"
level=
"project"
/>
</component>
</component>
</module>
</module>
\ No newline at end of file
wisenergy-model/src/main/java/cn/wisenergy/model/app/
Rebate
.java
→
wisenergy-model/src/main/java/cn/wisenergy/model/app/
MemberPercent
.java
View file @
2a195619
...
@@ -10,13 +10,14 @@ import java.util.Date;
...
@@ -10,13 +10,14 @@ import java.util.Date;
/**
/**
* @author 86187
* @author 86187
* @ Description:
返佣表实体类
* @ Description:
会员等级优惠百分比
* @ Author : 86187
* @ Author : 86187
* @ Date : 2021/2/22 11:05
* @ Date : 2021/2/22 11:05
*/
*/
@Data
@Data
@ApiModel
(
"Rebate"
)
@ApiModel
(
"MemberPercent"
)
public
class
Rebate
implements
Serializable
{
public
class
MemberPercent
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
3829843983637924282L
;
/**
/**
* 返佣id
* 返佣id
*/
*/
...
@@ -28,6 +29,11 @@ public class Rebate implements Serializable {
...
@@ -28,6 +29,11 @@ public class Rebate implements Serializable {
*/
*/
@ApiModelProperty
(
name
=
"userLevel"
,
value
=
"用户会员等级"
)
@ApiModelProperty
(
name
=
"userLevel"
,
value
=
"用户会员等级"
)
private
Integer
userLevel
;
private
Integer
userLevel
;
/**
* 会员等级百分比类型:1:返佣 2:月度肥料 3:月度最大进步奖 4:运营中心补贴
*/
@ApiModelProperty
(
name
=
"type"
,
value
=
"会员等级百分比类型:1:返佣 2:月度肥料 3:月度最大进步奖 4:运营中心补贴"
)
private
Integer
type
;
/**
/**
* 等级对应的返佣比例
* 等级对应的返佣比例
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/TeamPerformance.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
model
.
app
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @author 86187
* @ Description: 团队业绩实体类
* @ Author : 86187
* @ Date : 2021/2/26 16:31
*/
@Data
@ApiModel
(
"TeamPerformance"
)
public
class
TeamPerformance
implements
Serializable
{
private
static
final
long
serialVersionUID
=
3124781800304763059L
;
/**
* 主键id
*/
@ApiModelProperty
(
value
=
"主键id"
,
name
=
"id"
)
private
Integer
id
;
/**
* 用户id
*/
@ApiModelProperty
(
value
=
"用户id"
,
name
=
"userId"
)
private
String
userId
;
/**
* 用户等级
*/
@ApiModelProperty
(
value
=
"用户等级"
,
name
=
"userLevel"
)
private
Integer
userLevel
;
/**
* 年-月
*/
@ApiModelProperty
(
value
=
"年-月"
,
name
=
"yearMonth"
)
private
Date
yearMonth
;
/**
* 本月团队业绩
*/
@ApiModelProperty
(
value
=
"本月团队业绩"
,
name
=
"monthTeamPerformance"
)
private
BigDecimal
monthTeamPerformance
;
/**
* 创建时间
*/
@ApiModelProperty
(
value
=
"创建时间"
,
name
=
"createTime"
)
private
Date
createTime
;
/**
* 更新时间
*/
@ApiModelProperty
(
value
=
"更新时间"
,
name
=
"updateTime"
)
private
Date
updateTime
;
}
wisenergy-model/src/main/java/cn/wisenergy/model/app/shopZx.java
View file @
2a195619
...
@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
...
@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
/**
...
@@ -28,7 +29,7 @@ public class shopZx extends Model<shopZx> implements Serializable{
...
@@ -28,7 +29,7 @@ public class shopZx extends Model<shopZx> implements Serializable{
private
Integer
zxid
;
private
Integer
zxid
;
/**
/**
* 视频
/图片
存放地址
* 视频存放地址
*/
*/
@ApiModelProperty
(
name
=
"zxUrl"
,
value
=
"视频/图片存放地址"
)
@ApiModelProperty
(
name
=
"zxUrl"
,
value
=
"视频/图片存放地址"
)
private
String
zxUrl
;
private
String
zxUrl
;
...
@@ -64,85 +65,20 @@ public class shopZx extends Model<shopZx> implements Serializable{
...
@@ -64,85 +65,20 @@ public class shopZx extends Model<shopZx> implements Serializable{
private
String
zxField
;
private
String
zxField
;
/**
/**
* 资讯文字输入字段
* 资讯数据创建时间
*/
@ApiModelProperty
(
name
=
"zxDate"
,
value
=
"资讯数据创建时间"
)
private
Date
zxDate
;
/**
* 图片存放地址
*/
@ApiModelProperty
(
name
=
"imgUrl"
,
value
=
"图片存放地址"
)
private
String
imgUrl
;
/**
* 用户发布地址
*/
*/
@ApiModelProperty
(
name
=
"zxField"
,
value
=
"资讯数据创建时间"
)
@ApiModelProperty
(
name
=
"zxAddress"
,
value
=
"用户发布地址"
)
private
Data
zxDate
;
private
String
zxAddress
;
public
Data
getZxDate
()
{
return
zxDate
;
}
public
void
setZxDate
(
Data
zxDate
)
{
this
.
zxDate
=
zxDate
;
}
public
Integer
getZxid
()
{
return
zxid
;
}
public
void
setZxid
(
Integer
zxid
)
{
this
.
zxid
=
zxid
;
}
public
String
getZxUrl
()
{
return
zxUrl
;
}
public
void
setZxUrl
(
String
zxUrl
)
{
this
.
zxUrl
=
zxUrl
;
}
public
String
getUserid
()
{
return
userid
;
}
public
void
setUserid
(
String
userid
)
{
this
.
userid
=
userid
;
}
public
Integer
getZxLikes
()
{
return
zxLikes
;
}
public
void
setZxLikes
(
Integer
zxLikes
)
{
this
.
zxLikes
=
zxLikes
;
}
public
String
getZxName
()
{
return
zxName
;
}
public
void
setZxName
(
String
zxName
)
{
this
.
zxName
=
zxName
;
}
public
Integer
getZxShenHe
()
{
return
zxShenHe
;
}
public
void
setZxShenHe
(
Integer
zxShenHe
)
{
this
.
zxShenHe
=
zxShenHe
;
}
public
String
getZxField
()
{
return
zxField
;
}
public
void
setZxField
(
String
zxField
)
{
this
.
zxField
=
zxField
;
}
@Override
public
String
toString
()
{
return
"shopzx{"
+
"zxid="
+
zxid
+
", zxUrl="
+
zxUrl
+
", userid="
+
userid
+
", zxLikes="
+
zxLikes
+
", zxName="
+
zxName
+
", zxShenHe="
+
zxShenHe
+
", zxField="
+
zxField
+
"}"
;
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/
common
/AccountManager.java
→
wisenergy-service/src/main/java/cn/wisenergy/service/
Manager
/AccountManager.java
View file @
2a195619
package
cn
.
wisenergy
.
service
.
common
;
package
cn
.
wisenergy
.
service
.
Manager
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.OrderMapper
;
import
cn.wisenergy.mapper.OrderMapper
;
import
cn.wisenergy.mapper.TeamPerformanceMapper
;
import
cn.wisenergy.mapper.TradeRecordMapper
;
import
cn.wisenergy.mapper.TradeRecordMapper
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.*
;
import
cn.wisenergy.model.app.OrderInfo
;
import
cn.wisenergy.model.app.Rebate
;
import
cn.wisenergy.model.app.TradeRecord
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
/**
* @author 86187
* @author 86187
...
@@ -33,15 +32,21 @@ public class AccountManager {
...
@@ -33,15 +32,21 @@ public class AccountManager {
@Autowired
@Autowired
private
TradeRecordMapper
recordMapper
;
private
TradeRecordMapper
recordMapper
;
@Autowired
private
TeamPerformanceMapper
teamPerformanceMapper
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateOrderAddMoney
(
OrderInfo
orderInfo
,
AccountInfo
accountInfo
,
Rebate
rebate
)
{
public
Boolean
updateOrderAddMoney
(
OrderInfo
orderInfo
,
AccountInfo
accountInfo
,
MemberPercent
memberpercent
)
{
//1、计算返佣金额
//1、计算返佣金额
BigDecimal
bigDecimal
=
orderInfo
.
getPayment
().
multiply
(
rebate
.
getPercent
());
BigDecimal
bigDecimal
=
orderInfo
.
getPayment
().
multiply
(
memberpercent
.
getPercent
());
BigDecimal
extractMoney
=
accountInfo
.
getExtractMoney
().
add
(
bigDecimal
);
BigDecimal
extractMoney
=
accountInfo
.
getExtractMoney
().
add
(
bigDecimal
);
accountInfo
.
setExtractMoney
(
extractMoney
);
accountInfo
.
setExtractMoney
(
extractMoney
);
BigDecimal
performanceMonth
=
accountInfo
.
getPerformanceMonth
().
add
(
extractMoney
);
BigDecimal
performanceMonth
=
accountInfo
.
getPerformanceMonth
().
add
(
bigDecimal
);
accountInfo
.
setPerformanceMonth
(
performanceMonth
);
accountInfo
.
setPerformanceMonth
(
performanceMonth
);
BigDecimal
performanceTotal
=
accountInfo
.
getPerformanceTotal
().
add
(
bigDecimal
);
accountInfo
.
setPerformanceMonth
(
performanceTotal
);
//2、修改订单返佣状态:已返佣 1
//2、修改订单返佣状态:已返佣 1
orderInfo
.
setRebateStatus
(
1
);
orderInfo
.
setRebateStatus
(
1
);
...
@@ -52,6 +57,9 @@ public class AccountManager {
...
@@ -52,6 +57,9 @@ public class AccountManager {
//3、增加账户可用金额
//3、增加账户可用金额
int
sum
=
accountMapper
.
updateById
(
accountInfo
);
int
sum
=
accountMapper
.
updateById
(
accountInfo
);
if
(
sum
==
0
){
return
false
;
}
//4、添加交易流水记录
//4、添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
TradeRecord
tradeRecord
=
new
TradeRecord
();
...
@@ -65,4 +73,11 @@ public class AccountManager {
...
@@ -65,4 +73,11 @@ public class AccountManager {
return
true
;
return
true
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateAccountPerformanceMonth
(
List
<
TeamPerformance
>
list
)
{
for
(
TeamPerformance
teamPerformance
:
list
)
{
teamPerformanceMapper
.
updateById
(
teamPerformance
);
}
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/PublicManager.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
service
.
Manager
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* @author 86187
* @ Description: 账户管理公共类
* @ Author : 86187
* @ Date : 2021/2/23 10:43
*/
@Component
@Slf4j
public
class
PublicManager
{
public
boolean
isThisMonth
(
Date
time
,
String
pattern
)
{
Date
date
=
new
Date
(
time
.
getTime
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
pattern
);
//参数时间
String
param
=
sdf
.
format
(
date
);
//当前时间
String
now
=
sdf
.
format
(
new
Date
());
if
(
param
.
equals
(
now
))
{
return
true
;
}
return
false
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/AccountService.java
View file @
2a195619
...
@@ -30,7 +30,7 @@ public interface AccountService {
...
@@ -30,7 +30,7 @@ public interface AccountService {
R
<
AccountInfo
>
getByUserId
(
String
userId
);
R
<
AccountInfo
>
getByUserId
(
String
userId
);
/**
/**
* 业绩统计
*
收益和
业绩统计
*
*
* @param list 订单信息
* @param list 订单信息
* @return true or false
* @return true or false
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/UploadService.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
service
.
app
;
import
cn.wisenergy.model.app.shopZx
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by m1991 on 2021/2/24 13:49
*/
public
interface
UploadService
{
/**
* 视频文件上传 zxUrl, userId,zxName,zxField,imgUrl
* @param request
* @return
*/
public
Map
<
String
,
Object
>
uploadVideo
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
;
/**
* 图片文件上传
* @param request
* @return
*/
public
Map
<
String
,
Object
>
uploadImage
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
;
/**
* 项目目录下的图片文件上传
* @param request
* @return
*/
public
Map
<
String
,
Object
>
getImageUrl
(
HttpServletRequest
request
)
throws
Exception
;
/**
* 查询资讯所有信息(分页——10条信息一页)
* @param
* @return
*/
// List<shopZx> getList();
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/UserService.java
View file @
2a195619
...
@@ -9,6 +9,7 @@ import java.util.List;
...
@@ -9,6 +9,7 @@ import java.util.List;
* @ Description: 用户接口
* @ Description: 用户接口
* @ Author : 86187
* @ Author : 86187
* @ Date : 2021/1/6 16:08
* @ Date : 2021/1/6 16:08
* @author 86187
*/
*/
public
interface
UserService
{
public
interface
UserService
{
...
@@ -27,6 +28,4 @@ public interface UserService {
...
@@ -27,6 +28,4 @@ public interface UserService {
*/
*/
User
getByUserId
(
String
userId
);
User
getByUserId
(
String
userId
);
R
<
List
<
User
>>
test
();
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
2a195619
...
@@ -2,14 +2,13 @@ package cn.wisenergy.service.app.impl;
...
@@ -2,14 +2,13 @@ package cn.wisenergy.service.app.impl;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.RebateMapper
;
import
cn.wisenergy.mapper.MemberPercentMapper
;
import
cn.wisenergy.mapper.TeamPerformanceMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.*
;
import
cn.wisenergy.model.app.OrderInfo
;
import
cn.wisenergy.service.Manager.PublicManager
;
import
cn.wisenergy.model.app.Rebate
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.service.app.AccountService
;
import
cn.wisenergy.service.app.AccountService
;
import
cn.wisenergy.service.
common
.AccountManager
;
import
cn.wisenergy.service.
Manager
.AccountManager
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -18,7 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -18,7 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -36,11 +37,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -36,11 +37,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
private
AccountMapper
accountMapper
;
private
AccountMapper
accountMapper
;
@Autowired
@Autowired
private
RebateMapper
rebate
Mapper
;
private
MemberPercentMapper
memberPercent
Mapper
;
@Autowired
@Autowired
private
AccountManager
accountManager
;
private
AccountManager
accountManager
;
@Autowired
private
PublicManager
publicManager
;
@Autowired
private
TeamPerformanceMapper
teamPerformanceMapper
;
private
static
final
String
PATTERN
=
"yyyy-mm"
;
@Override
@Override
public
R
<
Boolean
>
orderRebate
(
List
<
OrderInfo
>
list
)
{
public
R
<
Boolean
>
orderRebate
(
List
<
OrderInfo
>
list
)
{
log
.
info
(
"shop-mall[]AccountServiceImpl[]orderRebate[]input.param.list:{}"
,
list
.
size
());
log
.
info
(
"shop-mall[]AccountServiceImpl[]orderRebate[]input.param.list:{}"
,
list
.
size
());
...
@@ -67,13 +76,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -67,13 +76,13 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
}
//获取返佣比例
//获取返佣比例
Rebate
rebate
=
rebate
Mapper
.
getByLevel
(
user
.
getUserLevel
());
MemberPercent
memberpercent
=
memberPercent
Mapper
.
getByLevel
(
user
.
getUserLevel
());
if
(
null
==
rebate
)
{
if
(
null
==
memberpercent
)
{
continue
;
continue
;
}
}
//修改订单状态为已返佣,账户可用金额增加
//修改订单状态为已返佣,账户可用金额增加
accountManager
.
updateOrderAddMoney
(
orderInfo
,
accountInfo
,
rebate
);
accountManager
.
updateOrderAddMoney
(
orderInfo
,
accountInfo
,
memberpercent
);
}
}
}
}
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
...
@@ -92,9 +101,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -92,9 +101,18 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
}
}
//计算当月所有订单成交额
BigDecimal
totalMoney
=
new
BigDecimal
(
0
);
for
(
OrderInfo
orderInfo
:
list
)
{
boolean
bool
=
publicManager
.
isThisMonth
(
orderInfo
.
getCreateTime
(),
PATTERN
);
if
(
bool
&&
orderInfo
.
getMonthlyTaskStatus
()
==
0
)
{
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
}
//遍历订单
//遍历订单
for
(
OrderInfo
orderInfo
:
list
)
{
for
(
OrderInfo
orderInfo
:
list
)
{
//订单状态创建时间,小于当前时间
//订单状态创建时间,小于当前时间
订单当月处理状态 :未处理
long
createTime
=
orderInfo
.
getCreated
().
getTime
();
long
createTime
=
orderInfo
.
getCreated
().
getTime
();
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
if
(
orderInfo
.
getMonthlyTaskStatus
()
==
0
&&
createTime
<=
time
)
{
if
(
orderInfo
.
getMonthlyTaskStatus
()
==
0
&&
createTime
<=
time
)
{
...
@@ -104,24 +122,52 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -104,24 +122,52 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
continue
;
continue
;
}
}
//获取当前用户的上级用户列表
List
<
TeamPerformance
>
teamPerformances
=
new
ArrayList
<>();
List
<
User
>
userList
=
getByList
(
user
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
userList
)){
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
new
Date
());
if
(
null
==
teamPerformance
)
{
continue
;
continue
;
}
}
//1、统计当前用户月度业绩
BigDecimal
userCount
=
teamPerformance
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
teamPerformance
.
setMonthTeamPerformance
(
userCount
);
teamPerformances
.
add
(
teamPerformance
);
//2、获取当前用户的上级用户列表
//获取账户信息
List
<
User
>
userList
=
getByList
(
user
.
getUserId
());
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
if
(
null
==
accountInfo
)
{
continue
;
continue
;
}
}
//修改订单状态为已返佣,账户可用金额增加
for
(
User
userInfo
:
userList
)
{
//3、统计当前用户上级月度绩效
TeamPerformance
team
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
new
Date
());
if
(
null
==
team
)
{
continue
;
}
//1、统计当前用户月度绩效
BigDecimal
monthCount
=
team
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
team
.
setMonthTeamPerformance
(
monthCount
);
teamPerformances
.
add
(
team
);
}
//4、更新账户月度绩效
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
for
(
User
user
:
userList
)
{
boolean
bool
=
monthlyIncome
(
totalMoney
,
user
);
if
(!
bool
)
{
continue
;
}
}
}
}
}
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
}
}
/**
/**
...
@@ -147,4 +193,46 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -147,4 +193,46 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
getUser
(
list
,
userInfo
.
getUserId
());
getUser
(
list
,
userInfo
.
getUserId
());
}
}
}
}
private
boolean
monthlyIncome
(
BigDecimal
totalMoney
,
User
user
)
{
double
total
=
totalMoney
.
doubleValue
();
BigDecimal
money
;
//当月所有人订单成交总金额/3980/12 向下整
double
moneyMonth
=
Math
.
floor
(
total
/
3980
/
12
);
if
(
moneyMonth
!=
0
)
{
//获取等级优惠百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
user
.
getUserLevel
(),
2
);
if
(
null
!=
memberPercent
)
{
//获取本月团队总金额
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
new
Date
());
//获取该等级团队总金额
Double
teamTotal
=
teamPerformanceMapper
.
countTeamMoney
(
user
.
getUserLevel
(),
new
Date
());
if
(
null
!=
teamPerformance
&&
null
!=
teamTotal
)
{
double
month
=
teamPerformance
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
//计算收益
double
income
=
moneyMonth
*
3980
*
percent
*
month
/
teamTotal
;
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
BigDecimal
bigDecimal
=
new
BigDecimal
(
income
);
BigDecimal
performanceMonth
=
accountInfo
.
getPerformanceMonth
().
add
(
bigDecimal
);
accountInfo
.
setPerformanceMonth
(
performanceMonth
);
BigDecimal
performanceTotal
=
accountInfo
.
getPerformanceTotal
().
add
(
bigDecimal
);
accountInfo
.
setPerformanceMonth
(
performanceTotal
);
//更新月收益
int
count
=
accountMapper
.
updateById
(
accountInfo
);
if
(
count
!=
0
)
{
return
true
;
}
}
}
}
return
false
;
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.utils.FrameGrabberKit
;
import
cn.wisenergy.model.app.shopZx
;
import
cn.wisenergy.service.app.UploadService
;
import
java.io.*
;
import
java.util.*
;
import
javax.servlet.http.HttpServletRequest
;
import
cn.wisenergy.mapper.ShopZxMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.web.multipart.MultipartFile
;
/**
* Created by m1991 on 2021/2/24 13:42
*/
@Slf4j
@Transactional
@Service
(
"UploadService"
)
public
class
UploadServiceImpl
implements
UploadService
{
@Autowired
private
ShopZxMapper
shopZxMapper
;
/**
* 视频文件上传
*/
@Override
public
Map
<
String
,
Object
>
uploadVideo
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
String
basePath
=
request
.
getScheme
()
+
"://"
+
request
.
getServerName
()
+
":"
+
request
.
getServerPort
()+
"/mimi/upload/video/"
;
Long
time
=
new
Date
().
getTime
();
String
zxName
=
file
.
getOriginalFilename
();
//文件原始名称
String
suffixName
=
zxName
.
substring
(
zxName
.
lastIndexOf
(
"."
));
//从最后一个.开始截取。截取zxName的后缀名
String
newzxName
=
time
+
suffixName
;
//文件新名称
//设置文件存储路径,可以存放在你想要指定的路径里面
String
rootPath
=
"D:/mimi/"
+
File
.
separator
+
"upload/video/"
;
//上传视频存放位置
String
filePath
=
rootPath
+
newzxName
;
File
newFile
=
new
File
(
filePath
);
//判断目标文件所在目录是否存在
if
(!
newFile
.
getParentFile
().
exists
()){
//如果目标文件所在的目录不存在,则创建父目录
newFile
.
getParentFile
().
mkdirs
();
}
//将内存中的数据写入磁盘
file
.
transferTo
(
newFile
);
//视频上传保存url
String
zxUrl
=
basePath
+
newzxName
;
//视频封面图处理
String
newImgName
=
time
+
".jpg"
;
String
framefile
=
rootPath
+
newImgName
;
String
imgUrlSave
=
basePath
+
newImgName
;
//图片最终位置路径
//视频截取封面图
String
imgUrl
=
FrameGrabberKit
.
getVedioImg
(
zxUrl
,
framefile
,
imgUrlSave
);
resultMap
.
put
(
"zxUrl"
,
zxUrl
);
resultMap
.
put
(
"imgUrl"
,
imgUrl
);
resultMap
.
put
(
"returnCode"
,
0
);
System
.
out
.
println
(
"上传的文件名为:"
+
zxName
+
",后缀名为:"
+
newzxName
);
shopZxMapper
.
zxadd
(
zxUrl
,
userId
,
zxName
,
zxField
,
imgUrl
,
zxAddress
);
return
resultMap
;
}
/**
* 图片文件上传
*/
@Override
public
Map
<
String
,
Object
>
uploadImage
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
String
basePath
=
request
.
getScheme
()
+
"://"
+
request
.
getServerName
()
+
":"
+
request
.
getServerPort
()+
"/mimi/upload/images/"
;
Long
time
=
new
Date
().
getTime
();
String
zxName
=
file
.
getOriginalFilename
();
//文件原始名称
String
suffixName
=
zxName
.
substring
(
zxName
.
lastIndexOf
(
"."
));
//从最后一个.开始截取。截取zxName的后缀名
String
newzxName
=
time
+
suffixName
;
//文件新名称
//设置文件存储路径,可以存放在你想要指定的路径里面
String
rootPath
=
"D:/mimi/"
+
File
.
separator
+
"upload/images/"
;
//上传图片存放位置
String
filePath
=
rootPath
+
newzxName
;
File
newFile
=
new
File
(
filePath
);
//判断目标文件所在目录是否存在
if
(!
newFile
.
getParentFile
().
exists
()){
//如果目标文件所在的目录不存在,则创建父目录
newFile
.
getParentFile
().
mkdirs
();
}
//将内存中的数据写入磁盘
file
.
transferTo
(
newFile
);
//图片上传保存url
String
imgUrl
=
basePath
+
newzxName
;
resultMap
.
put
(
"imgUrl"
,
imgUrl
);
resultMap
.
put
(
"returnCode"
,
0
);
String
zxUrl
=
""
;
shopZxMapper
.
zxadd
(
zxUrl
,
userId
,
zxName
,
zxField
,
imgUrl
,
zxAddress
);
return
resultMap
;
}
/**
* 项目目录下的图片文件上传
*/
@Override
public
Map
<
String
,
Object
>
getImageUrl
(
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
result
=
new
HashMap
<
String
,
Object
>();
//获取图片在项目路径下的地址
String
basePath
=
ClassUtils
.
getDefaultClassLoader
().
getResource
(
""
).
getPath
();
String
oldPath
=
basePath
+
"/static/images/animate.png"
;
Long
res
=
new
Date
().
getTime
();
//设置文件存储路径,可以存放在你想要指定的路径里面
String
rootPath
=
"D:/mimi/"
+
File
.
separator
+
"upload/images/"
;
// 新文件名
String
newzxName
=
res
+
oldPath
.
substring
(
oldPath
.
lastIndexOf
(
"."
));
//新文件
File
newFile
=
new
File
(
rootPath
+
File
.
separator
+
newzxName
);
//判断文件目录是否存在
if
(!
newFile
.
getParentFile
().
exists
()){
//如果目标文件所在的目录不存在,则创建父目录
newFile
.
getParentFile
().
mkdirs
();
}
//-------把图片文件写入磁盘 start ----------------
FileOutputStream
fos
=
new
FileOutputStream
(
newFile
);
//读取本地文件
File
localFile
=
new
File
(
oldPath
);
//获取本地文件输入流
InputStream
stream
=
new
FileInputStream
(
localFile
);
//写入目标文件
byte
[]
buffer
=
new
byte
[
1024
*
1024
];
int
byteRead
=
0
;
//stream.read(buffer) 每次读到的数据存放在 buffer 数组中
while
((
byteRead
=
stream
.
read
(
buffer
))!=-
1
){
//在 buffer 数组中 取出数据 写到 (输出流)磁盘上
fos
.
write
(
buffer
,
0
,
byteRead
);
fos
.
flush
();
}
fos
.
close
();
stream
.
close
();
//-------把图片文件写入磁盘 end ----------------
//服务器图片地址
String
baseURL
=
request
.
getScheme
()
+
"://"
+
request
.
getServerName
()
+
":"
+
request
.
getServerPort
()+
"/mimi/upload/images/"
;
String
imgUrl
=
baseURL
+
newzxName
;
result
.
put
(
"imgUrl"
,
imgUrl
);
result
.
put
(
"returnCode"
,
0
);
return
result
;
}
// /**
// * 获取资讯分页数据
// * @return
// */
// @Override
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
View file @
2a195619
...
@@ -35,8 +35,4 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
...
@@ -35,8 +35,4 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
return
usersMapper
.
getByUserId
(
userId
);
return
usersMapper
.
getByUserId
(
userId
);
}
}
@Override
public
R
<
List
<
User
>>
test
()
{
return
null
;
}
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/UploadController.java
0 → 100644
View file @
2a195619
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.wisenergy.service.app.UploadService
;
import
io.swagger.annotations.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
static
cn
.
wisenergy
.
common
.
utils
.
exception
.
Result
.
RESULT_FLG
.
SUCCESS
;
/**
* Created by m1991 on 2021/2/24 13:46
*/
@Api
(
tags
=
"资讯管理"
)
@RestController
@RequestMapping
(
"/ZX"
)
@Slf4j
public
class
UploadController
{
@Autowired
private
UploadService
uploadService
;
/**
* @param request
* @return
* @throws Exception
*/
/**
* 视频文件上传
* 资讯主键id* 视频/封面存放地址* 用户id(作者id)
* 获赞数* 视频/图片名称* 审核字段* 资讯文字输入字段
* 资讯创建时间* 图片储存地址* 资讯发表地址
*
* @param file
* @param request
* @param userId
* @param zxField
* @param zxAddress
* @return
* @throws Exception
*/
@ApiOperation
(
value
=
"上传视频,返回路径给前台"
,
notes
=
"上传视频,返回路径给前台"
,
httpMethod
=
"POST"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"zxField"
,
value
=
"资讯文字"
,
required
=
false
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户手机号"
,
required
=
true
,
dataType
=
"String"
)})
@RequestMapping
(
value
=
"/uploadVideo"
,
method
=
RequestMethod
.
POST
)
public
Map
<
String
,
Object
>
uploadVideo
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
{
return
uploadService
.
uploadVideo
(
file
,
request
,
userId
,
zxField
,
zxAddress
);
}
/**
* 单图片文件上传
*
* @param request
* @return
* @throws Exception
*/
@ApiOperation
(
value
=
"上传图片,返回路径给前台"
,
notes
=
"上传图片,返回路径给前台"
,
httpMethod
=
"POST"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"zxField"
,
value
=
"资讯文字"
,
required
=
false
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户手机号"
,
required
=
true
,
dataType
=
"String"
)})
@RequestMapping
(
value
=
"/uploadImage"
,
method
=
RequestMethod
.
POST
)
public
Map
<
String
,
Object
>
uploadImage
(
MultipartFile
file
,
HttpServletRequest
request
,
String
userId
,
String
zxField
,
String
zxAddress
)
throws
Exception
{
return
uploadService
.
uploadImage
(
file
,
request
,
userId
,
zxField
,
zxAddress
);
}
@ApiOperation
(
value
=
"多图片,返回路径给前台"
,
notes
=
"上传图片,返回路径给前台"
,
httpMethod
=
"POST"
)
@RequestMapping
(
"/uploadImg"
)
@ResponseBody
public
void
uploadImg
(
MultipartFile
file
[],
String
areaName
)
throws
Exception
{
System
.
out
.
println
(
"得到的areaName:"
+
areaName
);
// 设置上传的路径是D盘下的picture
String
imgPath
=
"D:/picture/"
;
for
(
MultipartFile
f
:
file
)
{
// 图片的名字用毫秒数+图片原来的名字拼接
System
.
out
.
println
(
f
.
getSize
());
System
.
out
.
println
(
f
.
getBytes
());
String
imgName
=
System
.
currentTimeMillis
()
+
f
.
getOriginalFilename
();
//上传文件
uploadFileUtil
(
f
.
getBytes
(),
imgPath
,
imgName
);
}
}
/**
* 上传文件的方法
* @param file:文件的字节
* @param imgPath:文件的路径
* @param imgName:文件的名字
* @throws Exception
*/
public
void
uploadFileUtil
(
byte
[]
file
,
String
imgPath
,
String
imgName
)
throws
Exception
{
File
targetFile
=
new
File
(
imgPath
);
if
(!
targetFile
.
exists
())
{
targetFile
.
mkdirs
();
}
FileOutputStream
out
=
new
FileOutputStream
(
imgPath
+
imgName
);
out
.
write
(
file
);
out
.
flush
();
out
.
close
();
}
@ApiOperation
(
value
=
"多图片,返回路径给前台"
,
notes
=
"上传图片,返回路径给前台"
,
httpMethod
=
"POST"
)
@RequestMapping
(
"/filesUpload"
)
//requestParam要写才知道是前台的那个数组
public
String
filesUpload
(
@RequestParam
(
"myfiles"
)
MultipartFile
[]
files
,
HttpServletRequest
request
)
{
List
<
String
>
list
=
new
ArrayList
<
String
>();
if
(
files
!=
null
&&
files
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
MultipartFile
file
=
files
[
i
];
// 保存文件
list
=
saveFile
(
request
,
file
,
list
);
}
}
//写着测试,删了就可以
// for (int i = 0; i < list.size(); i++) {
// System.out.println("集合里面的数据" + list.get(i));
// }
return
"index"
;
//跳转的页面
}
private
List
<
String
>
saveFile
(
HttpServletRequest
request
,
MultipartFile
file
,
List
<
String
>
list
)
{
// 判断文件是否为空
if
(!
file
.
isEmpty
())
{
try
{
// 保存的文件路径(如果用的是Tomcat服务器,文件会上传到\\%TOMCAT_HOME%\\webapps\\YourWebProject\\upload\\文件夹中
// )
String
filePath
=
request
.
getSession
().
getServletContext
()
.
getRealPath
(
"/"
)
+
"upload/"
+
file
.
getOriginalFilename
();
list
.
add
(
file
.
getOriginalFilename
());
File
saveDir
=
new
File
(
filePath
);
if
(!
saveDir
.
getParentFile
().
exists
())
saveDir
.
getParentFile
().
mkdirs
();
// 转存文件
file
.
transferTo
(
saveDir
);
return
list
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
list
;
}
// @ApiOperation(value = "资讯分页获取每页10条", notes = "资讯分页获取每页10条", httpMethod = "POST")
// @RequestMapping(value = "/findAll",method = RequestMethod.POST)
// public Object findAll(HttpServletRequest request){
//
// }
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/config/MyBatisPlusConfig.java
View file @
2a195619
...
@@ -8,6 +8,9 @@ import org.springframework.context.annotation.Configuration;
...
@@ -8,6 +8,9 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@Configuration
public
class
MyBatisPlusConfig
{
public
class
MyBatisPlusConfig
{
/**
* 分页插件
*/
@Bean
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
public
PaginationInterceptor
paginationInterceptor
()
{
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
...
@@ -19,4 +22,5 @@ public class MyBatisPlusConfig {
...
@@ -19,4 +22,5 @@ public class MyBatisPlusConfig {
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
paginationInterceptor
.
setCountSqlParser
(
new
JsqlParserCountOptimize
(
true
));
return
paginationInterceptor
;
return
paginationInterceptor
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment