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
6e6dddcb
Commit
6e6dddcb
authored
Mar 16, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化月度最大进步奖
parent
ba26390e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
8 deletions
+70
-8
AccountManager.java
...ain/java/cn/wisenergy/service/Manager/AccountManager.java
+44
-1
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+12
-2
MonthTaskServiceImpl.java
...a/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
+14
-5
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
View file @
6e6dddcb
...
...
@@ -126,7 +126,8 @@ public class AccountManager {
* @param prizes 上一次统计的进步奖 对象
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateOrSavePrize
(
List
<
TeamPerformanceSortVo
>
listVo
,
List
<
AccountInfo
>
accountInfoList
,
List
<
ProgressPrize
>
prizes
)
{
public
Boolean
updateOrSavePrize
(
List
<
TeamPerformanceSortVo
>
listVo
,
List
<
AccountInfo
>
accountInfoList
,
List
<
ProgressPrize
>
prizes
)
{
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
...
...
@@ -251,6 +252,48 @@ public class AccountManager {
return
true
;
}
/**
* 更新账户信息和保存交易流水记录保存最大进步奖信息
*
* @param accountInfoList 账户列表
* @param recordList 交易流水信息
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateAccountAddRecordAddPrize
(
List
<
AccountInfo
>
accountInfoList
,
List
<
TradeRecord
>
recordList
,
List
<
ProgressPrize
>
prizeList
)
{
//更新月收益
if
(!
CollectionUtils
.
isEmpty
(
accountInfoList
))
{
for
(
AccountInfo
accountInfo
:
accountInfoList
)
{
int
count
=
accountMapper
.
edit
(
accountInfo
);
if
(
count
==
0
)
{
return
false
;
}
}
}
//新增交易流水记录
if
(!
CollectionUtils
.
isEmpty
(
recordList
))
{
for
(
TradeRecord
tradeRecord
:
recordList
)
{
int
count
=
tradeRecordMapper
.
add
(
tradeRecord
);
if
(
count
==
0
)
{
return
false
;
}
}
}
//新增最大进步奖信息
if
(!
CollectionUtils
.
isEmpty
(
prizeList
))
{
for
(
ProgressPrize
progressPrize
:
prizeList
)
{
int
count
=
progressPrizeMapper
.
add
(
progressPrize
);
if
(
count
==
0
)
{
return
false
;
}
}
}
return
true
;
}
/**
* 更新账户信息和保存交易流水记录、保存上月剩余月度肥料奖金
*
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
6e6dddcb
...
...
@@ -20,8 +20,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -268,6 +268,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
Double
twentyTotal
=
teamPerformanceMapper
.
countTwenty
(
yearMonth
);
List
<
AccountInfo
>
accountInfoList
=
new
ArrayList
<>();
List
<
TradeRecord
>
tradeRecordList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
prizeList
=
new
ArrayList
<>();
for
(
TeamPerformance
user
:
list
)
{
//用户是普通用户的,不计算最大进步奖
if
(
user
.
getUserLevel
().
equals
(
UserLevelEnum
.
NORMAL_USER
.
getCode
()))
{
...
...
@@ -295,6 +296,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
accountInfo
.
setEarningsTotal
(
earningsTotal
);
accountInfoList
.
add
(
accountInfo
);
//添加最大进步奖信息
ProgressPrize
prize
=
new
ProgressPrize
();
BigDecimal
awardMoney
=
new
BigDecimal
(
income
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
prize
.
setAwardMoney
(
awardMoney
.
doubleValue
());
prize
.
setUserId
(
user
.
getUserId
());
prize
.
setGrowthRate
(
0.0
);
prize
.
setYearMonth
(
yearMonth
);
prizeList
.
add
(
prize
);
//添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
user
.
getUserId
());
...
...
@@ -306,7 +316,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
//更新账户信息,添加交易流水记录
boolean
bool
=
accountManager
.
updateAccountAddRecord
(
accountInfoList
,
tradeRecord
List
);
boolean
bool
=
accountManager
.
updateAccountAddRecord
AddPrize
(
accountInfoList
,
tradeRecordList
,
prize
List
);
if
(!
bool
)
{
return
R
.
ok
(
1
,
false
);
}
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
View file @
6e6dddcb
...
...
@@ -219,6 +219,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
Double
twentyTotal
=
teamPerformanceMapper
.
countTwenty
(
lastMonth
);
List
<
AccountInfo
>
accountInfoList
=
new
ArrayList
<>();
List
<
TradeRecord
>
tradeRecordList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
prizeList
=
new
ArrayList
<>();
for
(
TeamPerformance
user
:
list
)
{
//用户是普通用户的,不计算最大进步奖
if
(
user
.
getUserLevel
().
equals
(
UserLevelEnum
.
NORMAL_USER
.
getCode
()))
{
...
...
@@ -231,7 +232,6 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//计算收益
double
userTeamPerformance
=
user
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
double
income
=
Math
.
floor
(
number
*
3980
*
percent
*
userTeamPerformance
/
twentyTotal
);
//获取账户信息
...
...
@@ -239,25 +239,34 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//用户月收益 =其他收益+最大进步奖收益
BigDecimal
earningsMonth
=
accountInfo
.
getEarningsMonth
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsMonth
(
earningsMonth
);
accountInfo
.
setEarningsMonth
(
earningsMonth
.
setScale
(
2
,
RoundingMode
.
HALF_UP
)
);
//用户总收益 =其他总收益 + earningsMonth
BigDecimal
earningsTotal
=
accountInfo
.
getEarningsTotal
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsTotal
(
earningsTotal
);
accountInfo
.
setEarningsTotal
(
earningsTotal
.
setScale
(
2
,
RoundingMode
.
HALF_UP
)
);
accountInfoList
.
add
(
accountInfo
);
//添加最大进步奖信息
ProgressPrize
prize
=
new
ProgressPrize
();
BigDecimal
awardMoney
=
new
BigDecimal
(
income
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
prize
.
setAwardMoney
(
awardMoney
.
doubleValue
());
prize
.
setUserId
(
user
.
getUserId
());
prize
.
setGrowthRate
(
0.0
);
prize
.
setYearMonth
(
lastMonth
);
prizeList
.
add
(
prize
);
//添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
user
.
getUserId
());
tradeRecord
.
setTradeType
(
TradeRecordEnum
.
PROGRESS_PRIZE
.
getCode
());
tradeRecord
.
setTradeNo
(
null
);
tradeRecord
.
setStatus
(
TradeStatusEnum
.
ALREADY_SETTLE_ACCOUNTS
.
getCode
());
tradeRecord
.
setMoney
(
BigDecimal
.
valueOf
(
income
));
tradeRecord
.
setMoney
(
BigDecimal
.
valueOf
(
income
)
.
setScale
(
2
,
RoundingMode
.
HALF_UP
)
);
tradeRecordList
.
add
(
tradeRecord
);
}
//更新账户信息,添加交易流水记录
boolean
bool
=
accountManager
.
updateAccountAddRecord
(
accountInfoList
,
tradeRecord
List
);
boolean
bool
=
accountManager
.
updateAccountAddRecord
AddPrize
(
accountInfoList
,
tradeRecordList
,
prize
List
);
if
(!
bool
)
{
return
R
.
ok
(
1
,
false
);
}
...
...
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