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
e5587b8f
Commit
e5587b8f
authored
Feb 28, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度最大进步奖 实现
parent
b47dffae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
215 additions
and
77 deletions
+215
-77
TeamPerformanceMapper.java
.../main/java/cn/wisenergy/mapper/TeamPerformanceMapper.java
+38
-4
TeamPerformanceMapper.xml
...apper/src/main/resources/mapper/TeamPerformanceMapper.xml
+58
-0
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+0
-70
TeamPerformanceSortVo.java
...ain/java/cn/wisenergy/model/vo/TeamPerformanceSortVo.java
+14
-0
AccountService.java
...rc/main/java/cn/wisenergy/service/app/AccountService.java
+13
-0
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+92
-3
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/TeamPerformanceMapper.java
View file @
e5587b8f
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author 86187
...
...
@@ -17,13 +18,46 @@ public interface TeamPerformanceMapper extends BaseMapper<TeamPerformance> {
int
delById
(
@Param
(
"id"
)
Integer
id
);
TeamPerformance
getByUserIdAndTime
(
@Param
(
"userId"
)
String
userId
,
@Param
(
"yearMonth"
)
Date
yearMonth
);
/**
* 用户id和时间获取用户月业绩
*
* @param userId 用户id
* @param yearMonth 时间
* @return 用户月业绩
*/
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
);
/**
* 获取时间前的 月业绩列表
*
* @param yearMonth 时间
* @return 月业绩列表
*/
List
<
TeamPerformance
>
getByBeforeTime
(
@Param
(
"yearMonth"
)
Date
yearMonth
);
/**
* 根据时间统计 所有用户业绩和
*
* @param yearMonth 时间
* @return 所有用户业绩和
*/
Double
countByTime
(
@Param
(
"yearMonth"
)
Date
yearMonth
);
/**
* 月业绩排名前20人 业绩和
* @param yearMonth 时间
* @return 业绩和
*/
Double
countTwenty
(
@Param
(
"yearMonth"
)
Date
yearMonth
);
List
<
TeamPerformance
>
userTwenty
(
@Param
(
"yearMonth"
)
Date
yearMonth
);
}
wisenergy-mapper/src/main/resources/mapper/TeamPerformanceMapper.xml
View file @
e5587b8f
...
...
@@ -106,4 +106,62 @@
</where>
</select>
<select
id=
"getByBeforeTime"
resultType=
"cn.wisenergy.model.app.TeamPerformance"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
<if
test=
"yearMonth != null"
>
year_month
<
#{yearMonth}
</if>
</where>
</select>
<select
id=
"countByTime"
resultType=
"java.lang.Double"
>
select
sum(month_team_performance)
from
<include
refid=
"table"
/>
<where>
<if
test=
"yearMonth != null"
>
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
</where>
</select>
<select
id=
"countTwenty"
resultType=
"java.lang.Double"
>
select
sum(month_team_performance)
from
<include
refid=
"table"
/>
<where>
<if
test=
"yearMonth != null"
>
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
order by month_team_performance desc
limit 20
</where>
</select>
<select
id=
"userTwenty"
resultType=
"cn.wisenergy.model.app.TeamPerformance"
>
select
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
<if
test=
"yearMonth != null"
>
AND(
YEAR(year_month) = YEAR(#{yearMonth})
AND MONTH(year_month) = MONTH(#{yearMonth}))
</if>
order by month_team_performance desc
limit 20
</where>
</select>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
e5587b8f
...
...
@@ -13,16 +13,6 @@
<result
column=
"fans_id"
property=
"fansId"
/>
<result
column=
"invite_code"
property=
"inviteCode"
/>
<result
column=
"be_invited_code"
property=
"beInvitedCode"
/>
<!-- <result column="team_members_num" property="teamMembersNum"/>-->
<!-- <result column="normal_user_num" property="normalUserNum"/>-->
<!-- <result column="seedling_num" property="seedlingNum"/>-->
<!-- <result column="bronze_tree_num" property="bronzeTreeNum"/>-->
<!-- <result column="silver_tree_num" property="silverTreeNum"/>-->
<!-- <result column="gold_tree_num" property="goldTreeNum"/>-->
<!-- <result column="farmer_num" property="farmerNum"/>-->
<!-- <result column="forest_start_num" property="forestStartNum"/>-->
<!-- <result column="partner_num" property="partnerNum"/>-->
<!-- <result column="referrer_num" property="referrerNum"/>-->
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
</resultMap>
...
...
@@ -36,66 +26,6 @@
<include
refid=
"cols_exclude_id"
/>
</sql>
<!-- <sql id="cols_exclude_id">-->
<!-- user_id,password, user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,-->
<!-- be_invited_code,team_members_num,normal_user_num,seedling_num,bronze_tree_num,silver_tree_num,-->
<!-- gold_tree_num,farmer_num,forest_start_num,partner_num,referrer_num,create_time,update_time-->
<!-- </sql>-->
<!-- <sql id="vals">-->
<!-- #{userId},#{password},#{userLevel},#{crossBorderLine},#{idCardNumber},#{fansNickname},#{fansId},#{inviteCode},-->
<!-- #{beInvitedCode}, #{teamMembersNum},#{normalUserNum},#{seedlingNum},#{bronzeTreeNum},#{silverTreeNum},-->
<!-- #{goldTreeNum}, #{farmerNum},#{forestStartNum},#{partnerNum},#{referrerNum},now(),now()-->
<!-- </sql>-->
<!-- <sql id="updateCondition">-->
<!-- <if test="userId != null">user_id = #{userId},</if>-->
<!-- <if test="password != null">password =#{password},</if>-->
<!-- <if test="userLevel != null">user_level =#{userLevel},</if>-->
<!-- <if test="crossBorderLine != null">cross_border_line =#{crossBorderLine},</if>-->
<!-- <if test="idCardNumber != null">id_card_number = #{idCardNumber},</if>-->
<!-- <if test="fansNickname != null">fans_nickname =#{fansNickname},</if>-->
<!-- <if test="fansId != null">fans_id =#{fansId},</if>-->
<!-- <if test="inviteCode != null">invite_code =#{inviteCode},</if>-->
<!-- <if test="beInvitedCode != null">be_invited_code = #{beInvitedCode},</if>-->
<!-- <if test="teamMembersNum != null">team_members_num = #{teamMembersNum},</if>-->
<!-- <if test="normalUserNum != null">normal_user_num = #{normalUserNum},</if>-->
<!-- <if test="seedlingNum != null">seedling_num = #{seedlingNum},</if>-->
<!-- <if test="bronzeTreeNum != null">bronze_tree_num = #{bronzeTreeNum},</if>-->
<!-- <if test="silverTreeNum != null">silver_tree_num = #{silverTreeNum},</if>-->
<!-- <if test="goldTreeNum != null">gold_tree_num = #{goldTreeNum},</if>-->
<!-- <if test="farmerNum != null">farmer_num = #{farmerNum},</if>-->
<!-- <if test="forestStartNum != null">forest_start_num = #{forestStartNum},</if>-->
<!-- <if test="partnerNum != null">partner_num = #{partnerNum},</if>-->
<!-- <if test="referrerNum != null">referrer_num = #{referrerNum},</if>-->
<!-- update_time =now()-->
<!-- </sql>-->
<!-- <sql id="criteria">-->
<!-- <if test="id != null">id = #{id}</if>-->
<!-- <if test="userId != null">and user_id = #{userId}</if>-->
<!-- <if test="password != null">and password =#{password}</if>-->
<!-- <if test="userLevel != null">and user_level =#{userLevel}</if>-->
<!-- <if test="crossBorderLine != null">and cross_border_line =#{crossBorderLine}</if>-->
<!-- <if test="idCardNumber != null">and id_card_number = #{idCardNumber}</if>-->
<!-- <if test="fansNickname != null">and fans_nickname =#{fansNickname}</if>-->
<!-- <if test="fansId != null">and fans_id =#{fansId}</if>-->
<!-- <if test="inviteCode != null">and invite_code =#{inviteCode}</if>-->
<!-- <if test="beInvitedCode != null">and be_invited_code = #{beInvitedCode}</if>-->
<!-- <if test="teamMembersNum != null">and team_members_num = #{teamMembersNum}</if>-->
<!-- <if test="normalUserNum != null">and normal_user_num = #{normalUserNum}</if>-->
<!-- <if test="seedlingNum != null">and seedling_num = #{seedlingNum}</if>-->
<!-- <if test="bronzeTreeNum != null">and bronze_tree_num = #{bronzeTreeNum}</if>-->
<!-- <if test="silverTreeNum != null">and silver_tree_num = #{silverTreeNum}</if>-->
<!-- <if test="goldTreeNum != null">and gold_tree_num = #{goldTreeNum}</if>-->
<!-- <if test="farmerNum != null">and farmer_num = #{farmerNum}</if>-->
<!-- <if test="forestStartNum != null">and forest_start_num = #{forestStartNum}</if>-->
<!-- <if test="partnerNum != null">and partner_num = #{partnerNum}</if>-->
<!-- <if test="referrerNum != null">and referrer_num = #{referrerNum}</if>-->
<!-- <if test="createTime != null">and create_time >= #{createTime}</if>-->
<!-- <if test="updateTime != null">and #{updateTime} >= update_time</if>-->
<!-- </sql>-->
<sql
id=
"cols_exclude_id"
>
user_id,password, user_level,cross_border_line,id_card_number,fans_nickname,fans_id, invite_code,
be_invited_code,create_time,update_time
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/vo/TeamPerformanceSortVo.java
0 → 100644
View file @
e5587b8f
package
cn
.
wisenergy
.
model
.
vo
;
import
cn.wisenergy.model.app.TeamPerformance
;
import
lombok.Data
;
/**
* @author 86187
*/
@Data
public
class
TeamPerformanceSortVo
{
private
Double
growthRate
;
private
TeamPerformance
teamPerformance
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/AccountService.java
View file @
e5587b8f
...
...
@@ -37,5 +37,18 @@ public interface AccountService {
*/
R
<
Boolean
>
performanceCount
(
List
<
OrderInfo
>
list
);
/**
* 获取用户的商机信息
*
* @param userId 用户id
* @return 用户商机列表
*/
List
<
User
>
getByList
(
String
userId
);
/**
* 进步奖收益统计
* @return true or false
*/
R
<
Boolean
>
progressPrizeCount
();
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
e5587b8f
...
...
@@ -6,21 +6,21 @@ import cn.wisenergy.mapper.MemberPercentMapper;
import
cn.wisenergy.mapper.TeamPerformanceMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.*
;
import
cn.wisenergy.model.vo.TeamPerformanceSortVo
;
import
cn.wisenergy.service.Manager.PublicManager
;
import
cn.wisenergy.service.app.AccountService
;
import
cn.wisenergy.service.Manager.AccountManager
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
/**
...
...
@@ -185,6 +185,95 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
return
list
;
}
@Override
public
R
<
Boolean
>
progressPrizeCount
()
{
log
.
info
(
"shop-mall[]AccountServiceImpl[]performanceCount[]input.method"
);
//1、判断当前月是否是业绩开始的第一个月
List
<
TeamPerformance
>
teamPerformances
=
teamPerformanceMapper
.
getByBeforeTime
(
new
Date
());
//2、集合为空 是业绩开始的第一个月
if
(
CollectionUtils
.
isEmpty
(
teamPerformances
))
{
//获取当月所有人业绩总额
Double
totalMoney
=
teamPerformanceMapper
.
countByTime
(
new
Date
());
double
number
=
Math
.
floor
(
totalMoney
/
3980
/
12
);
if
(
number
!=
0
)
{
//获取月业绩前20用户
List
<
TeamPerformance
>
list
=
teamPerformanceMapper
.
userTwenty
(
new
Date
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
R
.
ok
(
0
,
true
);
}
//获取20名进步最大的月业绩和
Double
twentyTotal
=
teamPerformanceMapper
.
countTwenty
(
new
Date
());
for
(
TeamPerformance
user
:
list
)
{
//获取最大进步奖 百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
user
.
getUserLevel
(),
3
);
//计算收益
double
userTeamPerformance
=
user
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
double
income
=
number
*
3980
*
percent
*
userTeamPerformance
/
twentyTotal
;
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
accountInfo
.
setPerformanceMonth
(
new
BigDecimal
(
income
));
//更新用户账户表
accountMapper
.
updateById
(
accountInfo
);
}
}
return
R
.
ok
(
0
,
true
);
}
//3、集合不为空 不是业绩开始的第一个月
//获取用户列表
List
<
User
>
userList
=
usersMapper
.
findAll
();
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
return
R
.
ok
(
0
,
true
);
}
//遍历 计算业绩增长率
List
<
TeamPerformanceSortVo
>
listVo
=
new
ArrayList
<>();
for
(
User
user
:
userList
)
{
TeamPerformanceSortVo
teamVo
=
new
TeamPerformanceSortVo
();
double
growthRate
;
//获取当月业绩
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
new
Date
());
//获取上月业绩
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
new
Date
());
cal
.
add
(
Calendar
.
MONTH
,
-
1
);
Date
date
=
cal
.
getTime
();
TeamPerformance
lastMonth
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
date
);
if
(
null
==
teamPerformance
||
null
==
lastMonth
)
{
growthRate
=
0.00
;
}
else
{
double
month
=
teamPerformance
.
getMonthTeamPerformance
().
doubleValue
();
double
last
=
lastMonth
.
getMonthTeamPerformance
().
doubleValue
();
if
(
last
>=
month
)
{
growthRate
=
0.00
;
}
else
{
growthRate
=
(
month
-
last
)
/
month
;
}
}
teamVo
.
setGrowthRate
(
growthRate
);
teamVo
.
setTeamPerformance
(
teamPerformance
);
listVo
.
add
(
teamVo
);
}
//对集合进行排序
listVo
.
sort
(
Comparator
.
comparing
(
TeamPerformanceSortVo:
:
getGrowthRate
).
reversed
());
//取排名前20的
listVo
.
subList
(
0
,
20
);
return
R
.
ok
(
0
,
true
);
}
public
void
getUser
(
List
<
User
>
list
,
String
userId
)
{
User
user
=
usersMapper
.
getByUserId
(
userId
);
list
.
add
(
user
);
...
...
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