Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
44d19908
提交
44d19908
authored
10月 13, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
06ea64ad
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
33 行增加
和
7 行删除
+33
-7
BonusController.java
.../com/example/afrishop_v3/controllers/BonusController.java
+31
-7
BonusRepository.java
...a/com/example/afrishop_v3/repository/BonusRepository.java
+2
-0
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/BonusController.java
浏览文件 @
44d19908
package
com
.
example
.
afrishop_v3
.
controllers
;
import
com.example.afrishop_v3.base.Result
;
import
com.example.afrishop_v3.enums.OrderStatusEnum
;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.models.*
;
import
com.example.afrishop_v3.repository.*
;
import
com.example.afrishop_v3.security.services.AuthenticationUser
;
...
...
@@ -8,8 +11,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.util.*
;
...
...
@@ -24,8 +25,9 @@ public class BonusController extends Controller {
private
final
NetworkRepository
networkRepository
;
private
final
EntityManager
entityManager
;
private
final
AuthenticationUser
user
;
private
final
TbCfOrderRepository
orderRepository
;
public
BonusController
(
BonusRepository
repository
,
TbCfStationItemRepository
itemRepository
,
UserRepository
userRepository
,
PostRepository
postRepository
,
NetworkRepository
networkRepository
,
EntityManager
entityManager
,
AuthenticationUser
user
)
{
public
BonusController
(
BonusRepository
repository
,
TbCfStationItemRepository
itemRepository
,
UserRepository
userRepository
,
PostRepository
postRepository
,
NetworkRepository
networkRepository
,
EntityManager
entityManager
,
AuthenticationUser
user
,
TbCfOrderRepository
orderRepository
)
{
this
.
repository
=
repository
;
this
.
itemRepository
=
itemRepository
;
this
.
userRepository
=
userRepository
;
...
...
@@ -33,6 +35,7 @@ public class BonusController extends Controller {
this
.
networkRepository
=
networkRepository
;
this
.
entityManager
=
entityManager
;
this
.
user
=
user
;
this
.
orderRepository
=
orderRepository
;
}
@Deprecated
...
...
@@ -169,12 +172,33 @@ public class BonusController extends Controller {
}
@PostMapping
(
value
=
"/saveNetworkMarketing"
)
public
Bonus
saveNetworkMarketing
(
@ModelAttribute
(
"Bonus"
)
Bonus
bonus
)
{
public
Result
saveNetworkMarketing
(
@ModelAttribute
(
"Bonus"
)
Bonus
bonus
)
{
TbCfUserInfo
info
=
user
.
user
();
Optional
<
String
>
userIdOptional
=
bonus
.
userId
();
String
orderId
=
bonus
.
getOrderId
();
if
(
orderId
==
null
)
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Order is missing !!!"
);
Optional
<
TbCfOrder
>
orderOptional
=
orderRepository
.
findById
(
orderId
);
if
(
!
orderOptional
.
isPresent
()
)
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Order is missing !!!"
);
TbCfOrder
order
=
orderOptional
.
get
();
if
(
!
OrderStatusEnum
.
PAID
.
getValue
().
equals
(
order
.
getPayStatus
())
){
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid order status"
);
}
if
(
repository
.
existsById
(
orderId
)
){
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Transaction already done !!!"
);
}
double
amount
=
bonus
.
getAmount
();
if
(
userIdOptional
.
isPresent
())
{
...
...
@@ -210,13 +234,13 @@ public class BonusController extends Controller {
}
TbCfUserInfo
bonusInc
=
runBonusInc
(
user
,
amount
,
5
,
false
,
bonus
.
getOrderId
()
);
runBonusInc
(
sharer
.
orElseGet
(()
->
postOptional
.
isPresent
()
?
postOptional
.
get
().
getRealUser
()
:
bonusInc
),
amount
,
5
,
postOptional
.
isPresent
()
||
sharer
.
isPresent
(),
bonus
.
getOrderId
()
);
TbCfUserInfo
bonusInc
=
runBonusInc
(
user
,
amount
,
5
,
false
,
orderId
);
runBonusInc
(
sharer
.
orElseGet
(()
->
postOptional
.
isPresent
()
?
postOptional
.
get
().
getRealUser
()
:
bonusInc
),
amount
,
5
,
postOptional
.
isPresent
()
||
sharer
.
isPresent
(),
orderId
);
//runBonusInc(bonusInc, amount, 0);
}
}
return
bonus
;
return
new
Result
<>(
bonus
)
;
}
private
TbCfUserInfo
runBonusInc
(
TbCfUserInfo
user
,
double
amount
,
int
percent
,
boolean
direct
,
String
orderId
)
{
...
...
src/main/java/com/example/afrishop_v3/repository/BonusRepository.java
浏览文件 @
44d19908
...
...
@@ -23,6 +23,8 @@ public interface BonusRepository extends JpaRepository<Bonus,String> {
@Transactional
void
removeByPost_Id
(
@Param
(
"post"
)
String
post_id
);
boolean
existsByOrderId
(
String
orderId
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论