Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
263c9527
提交
263c9527
authored
10月 19, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
705d3a0a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
30 行增加
和
14 行删除
+30
-14
BonusController.java
.../com/example/afrishop_v3/controllers/BonusController.java
+10
-7
PostController.java
...a/com/example/afrishop_v3/controllers/PostController.java
+1
-0
WithdrawController.java
...m/example/afrishop_v3/controllers/WithdrawController.java
+2
-2
Bonus.java
src/main/java/com/example/afrishop_v3/models/Bonus.java
+7
-5
PostHashtagRepository.java
...example/afrishop_v3/repository/PostHashtagRepository.java
+10
-0
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/BonusController.java
浏览文件 @
263c9527
...
...
@@ -11,6 +11,8 @@ import org.springframework.web.bind.annotation.*;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.util.*
;
...
...
@@ -150,8 +152,8 @@ public class BonusController extends Controller {
String
sharer
=
bonus
.
getSharer
();
double
amount
=
bonus
.
getAmount
();
bonus
.
setAmount
(
amount
*
5
/
100
);
BigDecimal
amount
=
bonus
.
getAmount
();
bonus
.
setAmount
(
amount
.
multiply
(
BigDecimal
.
valueOf
(
5
)).
divide
(
BigDecimal
.
valueOf
(
5
),
RoundingMode
.
CEILING
)
);
bonus
.
setPercentage
(
5
);
if
(
sharer
!=
null
&&
userRepository
.
existsByCode
(
sharer
))
{
...
...
@@ -161,7 +163,7 @@ public class BonusController extends Controller {
bonus1
.
setStationItem
(
itemOptional
.
get
());
bonus1
.
setPost
(
post
);
bonus1
.
setUserInfo
(
byId
.
get
());
bonus1
.
setAmount
(
amount
*
10
/
100
);
bonus1
.
setAmount
(
amount
.
multiply
(
BigDecimal
.
valueOf
(
10
)).
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
)
);
bonus1
.
setPercentage
(
10.0
);
repository
.
save
(
bonus1
);
}
...
...
@@ -199,7 +201,7 @@ public class BonusController extends Controller {
}
double
amount
=
bonus
.
getAmount
();
BigDecimal
amount
=
bonus
.
getAmount
();
if
(
userIdOptional
.
isPresent
())
{
...
...
@@ -223,7 +225,7 @@ public class BonusController extends Controller {
if
(
user
.
invited
())
{
double
v
=
amount
*
10
/
100
;
BigDecimal
v
=
amount
.
multiply
(
BigDecimal
.
valueOf
(
10
)).
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
)
;
bonus
.
setAmount
(
v
);
bonus
.
setUserInfo
(
user
);
bonus
.
setPercentage
(
10
);
...
...
@@ -243,14 +245,15 @@ public class BonusController extends Controller {
return
new
Result
<>(
bonus
);
}
private
TbCfUserInfo
runBonusInc
(
TbCfUserInfo
user
,
double
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
.
findByNetworkInfoCode
(
user
.
getCode
());
if
(
userCode
.
isPresent
()
||
direct
)
{
TbCfUserInfo
userInfo
=
direct
?
user
:
userCode
.
get
().
getUserInfo
();
Bonus
bonus
=
new
Bonus
();
bonus
.
setUserInfo
(
userInfo
);
double
v
=
amount
*
percent
/
100
;
BigDecimal
v
=
amount
.
multiply
(
BigDecimal
.
valueOf
(
percent
));
v
=
v
.
divide
(
BigDecimal
.
valueOf
(
100
),
RoundingMode
.
CEILING
);
bonus
.
setAmount
(
v
);
bonus
.
setPercentage
(
percent
);
bonus
.
setOrderId
(
orderId
);
...
...
src/main/java/com/example/afrishop_v3/controllers/PostController.java
浏览文件 @
263c9527
...
...
@@ -185,6 +185,7 @@ public class PostController {
visitRepository
.
removeByPost_Id
(
id
);
bonusRepository
.
removeByPost_Id
(
id
);
contentRepository
.
removeByPost_Id
(
id
);
postHashtagRepository
.
removeByPost_Id
(
id
);
repository
.
deleteById
(
id
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
...
...
src/main/java/com/example/afrishop_v3/controllers/WithdrawController.java
浏览文件 @
263c9527
...
...
@@ -38,14 +38,14 @@ public class WithdrawController {
code
=
0
;
}
Optional
<
TbCfUserInfo
>
byId
=
userRepository
.
findById
(
withdraw
.
getUserId
());
Optional
<
TbCfUserInfo
>
byId
=
withdraw
.
getUserId
()
==
null
?
Optional
.
empty
()
:
userRepository
.
findById
(
withdraw
.
getUserId
());
if
(
!
byId
.
isPresent
()
){
code
=
0
;
message
=
"Service Error"
;
}
if
(
byId
.
isPresent
()
&&
byId
.
get
().
getWallet
()
<
withdraw
.
getAmount
()
){
if
(
byId
.
isPresent
()
&&
byId
.
get
().
getWallet
()
<
withdraw
.
getAmount
()
.
doubleValue
()
){
code
=
0
;
message
=
"Insufficient balance"
;
}
...
...
src/main/java/com/example/afrishop_v3/models/Bonus.java
浏览文件 @
263c9527
...
...
@@ -7,6 +7,8 @@ import javax.persistence.Column;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Transient
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
import
java.util.Optional
;
...
...
@@ -26,7 +28,7 @@ public class Bonus extends Model {
@ManyToOne
()
private
TbCfStationItem
stationItem
;
private
double
amount
;
private
BigDecimal
amount
;
private
String
orderId
;
...
...
@@ -79,11 +81,11 @@ public class Bonus extends Model {
return
productSharer
;
}
public
double
getAmount
()
{
return
amount
;
public
BigDecimal
getAmount
()
{
return
amount
==
null
?
BigDecimal
.
ZERO
:
amount
.
setScale
(
2
,
RoundingMode
.
CEILING
)
;
}
public
void
setAmount
(
double
amount
)
{
public
void
setAmount
(
BigDecimal
amount
)
{
this
.
amount
=
amount
;
}
...
...
@@ -93,7 +95,7 @@ public class Bonus extends Model {
public
void
reverseAmount
(){
this
.
withDrawChange
();
amount
*=
-
1
;
amount
=
getAmount
().
multiply
(
BigDecimal
.
valueOf
(-
1
))
;
}
public
String
getUserId
(){
...
...
src/main/java/com/example/afrishop_v3/repository/PostHashtagRepository.java
浏览文件 @
263c9527
package
com
.
example
.
afrishop_v3
.
repository
;
import
com.example.afrishop_v3.models.PostHashtag
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.transaction.annotation.Transactional
;
public
interface
PostHashtagRepository
extends
PagingAndSortingRepository
<
PostHashtag
,
String
>
{
boolean
existsByHashtagNameAndPostId
(
String
hashtag_name
,
String
post_id
);
@Query
(
value
=
"delete c from post_hashtag_v2 c WHERE c.post_id=:post"
,
nativeQuery
=
true
)
@Modifying
@Transactional
void
removeByPost_Id
(
@Param
(
"post"
)
String
post_id
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论