Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
c14cc3db
提交
c14cc3db
authored
1月 07, 2021
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改佣金bug
上级
0fed986b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
17 行删除
+21
-17
BonusController.java
.../com/example/afrishop_v3/controllers/BonusController.java
+21
-17
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/BonusController.java
浏览文件 @
c14cc3db
...
...
@@ -28,13 +28,12 @@ public class BonusController extends Controller {
private
final
NetworkRepository
networkRepository
;
// @PersistenceContext(unitName = "afrishop_v3")
// @PersistenceContext(unitName = "afrishop_v3")
private
final
EntityManager
entityManager
;
private
final
AuthenticationUser
user
;
private
final
TbCfOrderRepository
orderRepository
;
public
BonusController
(
BonusRepository
repository
,
TbCfStationItemRepository
itemRepository
,
UserRepository
userRepository
,
PostRepository
postRepository
,
NetworkRepository
networkRepository
,
AuthenticationUser
user
,
TbCfOrderRepository
orderRepository
,
EntityManager
entityManager
)
{
public
BonusController
(
BonusRepository
repository
,
TbCfStationItemRepository
itemRepository
,
UserRepository
userRepository
,
PostRepository
postRepository
,
NetworkRepository
networkRepository
,
AuthenticationUser
user
,
TbCfOrderRepository
orderRepository
,
EntityManager
entityManager
)
{
this
.
repository
=
repository
;
this
.
itemRepository
=
itemRepository
;
this
.
userRepository
=
userRepository
;
...
...
@@ -69,8 +68,8 @@ public class BonusController extends Controller {
//Get bonuses in current month
@GetMapping
(
value
=
"/list/currentMonth"
)
//@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')")
public
Map
<
String
,
Object
>
getListByUserAndCurrentMonth
(
@RequestParam
(
value
=
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
)
{
return
getListByUserAndCurrentMonth
(
user
.
userId
(),
pageNo
,
pageSize
);
public
Map
<
String
,
Object
>
getListByUserAndCurrentMonth
(
@RequestParam
(
value
=
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
)
{
return
getListByUserAndCurrentMonth
(
user
.
userId
(),
pageNo
,
pageSize
);
}
@Deprecated
...
...
@@ -90,7 +89,7 @@ public class BonusController extends Controller {
nativeQuery
.
setParameter
(
"year"
,
year
);
List
<
Bonus
>
bonuses
=
repository
.
findAllByUser_IdAndCreateDateMonthAndCreateDateYear
(
byId
.
get
(),
month
,
year
,
PageRequest
.
of
(
pageNo
,
pageSize
)).
toList
();
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"list"
,
bonuses
);
return
hashMap
;
}
...
...
@@ -99,7 +98,7 @@ public class BonusController extends Controller {
@GetMapping
(
value
=
"/list/prevMonth"
)
//@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')")
public
Map
<
String
,
Object
>
getListByUserAndPreviousMonth
(
@RequestParam
(
value
=
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
)
{
return
getListByUserAndPreviousMonth
(
user
.
userId
(),
pageNo
,
pageSize
);
return
getListByUserAndPreviousMonth
(
user
.
userId
(),
pageNo
,
pageSize
);
}
@Deprecated
...
...
@@ -110,6 +109,11 @@ public class BonusController extends Controller {
LocalDate
localDate
=
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
();
int
month
=
localDate
.
getMonthValue
()
-
1
;
int
year
=
localDate
.
getYear
();
//如果是1月,上个月则是去年12月
if
(
localDate
.
getMonthValue
()
==
1
)
{
month
=
12
;
year
=
year
-
1
;
}
Optional
<
TbCfUserInfo
>
byId
=
userRepository
.
findById
(
id
);
if
(!
byId
.
isPresent
())
return
null
;
//Calculate sum of bonus in single month
...
...
@@ -119,7 +123,7 @@ public class BonusController extends Controller {
nativeQuery
.
setParameter
(
"year"
,
year
);
List
<
Bonus
>
bonuses
=
repository
.
findAllByUser_IdAndCreateDateMonthAndCreateDateYear
(
byId
.
get
(),
month
,
year
,
PageRequest
.
of
(
pageNo
,
pageSize
)).
toList
();
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"list"
,
bonuses
);
return
hashMap
;
}
...
...
@@ -127,7 +131,7 @@ public class BonusController extends Controller {
@GetMapping
(
value
=
"/list/today"
)
//@PreAuthorize("hasAuthority('ADMIN_USER') or hasAuthority('STANDARD_USER')")
public
Map
<
String
,
Object
>
getListByUserAndToday
(
@RequestParam
(
value
=
"pageNo"
)
Integer
pageNo
,
@RequestParam
(
value
=
"pageSize"
)
Integer
pageSize
)
{
return
getListByUserAndToday
(
user
.
userId
(),
pageNo
,
pageSize
);
return
getListByUserAndToday
(
user
.
userId
(),
pageNo
,
pageSize
);
}
@Deprecated
...
...
@@ -147,7 +151,7 @@ public class BonusController extends Controller {
nativeQuery
.
setParameter
(
"year"
,
year
);
List
<
Bonus
>
bonuses
=
repository
.
findAllByUser_IdAndCreateDate
(
byId
.
get
(),
dayOfYear
,
year
,
PageRequest
.
of
(
pageNo
,
pageSize
)).
toList
();
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"total"
,
BigDecimal
.
valueOf
((
double
)
nativeQuery
.
getSingleResult
()).
setScale
(
3
,
RoundingMode
.
HALF_UP
));
hashMap
.
put
(
"list"
,
bonuses
);
return
hashMap
;
}
...
...
@@ -174,7 +178,7 @@ public class BonusController extends Controller {
bonus1
.
setStationItem
(
itemOptional
.
get
());
bonus1
.
setPost
(
post
);
bonus1
.
setUserInfo
(
byId
.
get
());
bonus1
.
setAmount
(
amount
.
multiply
(
BigDecimal
.
valueOf
(
10
)).
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
));
bonus1
.
setAmount
(
amount
.
multiply
(
BigDecimal
.
valueOf
(
10
)).
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
));
bonus1
.
setPercentage
(
10.0
);
repository
.
save
(
bonus1
);
}
...
...
@@ -260,23 +264,23 @@ public class BonusController extends Controller {
return
new
Result
<>(
bonus
);
}
private
TbCfUserInfo
runBonusInc
(
TbCfUserInfo
user
,
BigDecimal
amount
,
int
percent
,
boolean
direct
,
String
orderId
)
{
private
TbCfUserInfo
runBonusInc
(
TbCfUserInfo
user
,
BigDecimal
amount
,
int
percent
,
boolean
direct
,
String
orderId
)
{
if
(
user
==
null
)
return
null
;
Optional
<
Network
>
userCode
=
networkRepository
.
findFirstByNetworkInfoCode
(
user
.
getCode
());
if
(
userCode
.
isPresent
()
||
direct
)
{
TbCfUserInfo
userInfo
=
direct
?
user
:
userCode
.
get
().
getUserInfo
();
Bonus
bonus
=
new
Bonus
();
bonus
.
setUserInfo
(
userInfo
);
BigDecimal
v
=
amount
.
multiply
(
BigDecimal
.
valueOf
(
percent
));
v
=
v
.
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
);
BigDecimal
v
=
amount
.
multiply
(
BigDecimal
.
valueOf
(
percent
));
v
=
v
.
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
);
bonus
.
setAmount
(
v
);
bonus
.
setPercentage
(
percent
);
bonus
.
setOrderId
(
orderId
);
if
(
userInfo
.
invited
()){
if
(
userInfo
.
invited
())
{
repository
.
save
(
bonus
);
bonus
=
repository
.
save
(
bonus
);
if
(
userInfo
.
hasFcm
()
)
{
sendNotification
(
userInfo
.
getFcm
(),
"Bonus alert !!"
,
userInfo
.
display
()+
", You received bonus of $"
+
formatter
.
format
(
v
)+
" in your account"
);
if
(
userInfo
.
hasFcm
())
{
sendNotification
(
userInfo
.
getFcm
(),
"Bonus alert !!"
,
userInfo
.
display
()
+
", You received bonus of $"
+
formatter
.
format
(
v
)
+
" in your account"
);
}
}
return
userInfo
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论