Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
1c56ec2c
Commit
1c56ec2c
authored
Nov 12, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
版本3.5,拍卖保证金兼容上一版本
parent
10871d61
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
3 deletions
+52
-3
ch-dao/src/main/java/com/wwdz/ch/db/dao/openShop/EarnestRecordDao.java
...in/java/com/wwdz/ch/db/dao/openShop/EarnestRecordDao.java
+8
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/openShop/EarnestRecordDaoImpl.java
...va/com/wwdz/ch/db/impl/openShop/EarnestRecordDaoImpl.java
+14
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/openShop/AuctionEarnestServiceImpl.java
...m/wwdz/ch/wx/impl/openShop/AuctionEarnestServiceImpl.java
+30
-3
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/openShop/EarnestRecordDao.java
View file @
1c56ec2c
...
@@ -45,4 +45,12 @@ public interface EarnestRecordDao {
...
@@ -45,4 +45,12 @@ public interface EarnestRecordDao {
* @return
* @return
*/
*/
long
sumForOccupy
(
EarnestRecordRequestDto
dto
);
long
sumForOccupy
(
EarnestRecordRequestDto
dto
);
/**
* 检查是否存在被保证金记录
* 兼容之前没有保证金的逻辑
* @param dto
* @return
*/
boolean
isExisted
(
EarnestRecordRequestDto
dto
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/openShop/EarnestRecordDaoImpl.java
View file @
1c56ec2c
...
@@ -68,4 +68,18 @@ public class EarnestRecordDaoImpl implements EarnestRecordDao {
...
@@ -68,4 +68,18 @@ public class EarnestRecordDaoImpl implements EarnestRecordDao {
JdbcHelper
.
ifPresent
(
dto
.
getState
(),
criteria
::
andStateEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getState
(),
criteria
::
andStateEqualTo
);
return
earnestRecordMapper
.
sumForOccupy
(
example
);
return
earnestRecordMapper
.
sumForOccupy
(
example
);
}
}
@Override
public
boolean
isExisted
(
EarnestRecordRequestDto
dto
)
{
EarnestRecordExample
example
=
new
EarnestRecordExample
();
EarnestRecordExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
dto
.
getUserId
(),
criteria
::
andUserIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getItemId
(),
criteria
::
andItemIdEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getType
(),
criteria
::
andTypeEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getState
(),
criteria
::
andStateEqualTo
);
JdbcHelper
.
ifPresent
(
dto
.
getTypeList
(),
criteria
::
andTypeIn
);
JdbcHelper
.
ifPresent
(
dto
.
getFilterTypeList
(),
criteria
::
andTypeNotIn
);
return
earnestRecordMapper
.
countByExample
(
example
)
>
0
;
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/openShop/AuctionEarnestServiceImpl.java
View file @
1c56ec2c
...
@@ -15,6 +15,7 @@ import com.wwdz.ch.db.domain.openShop.UserAccount;
...
@@ -15,6 +15,7 @@ import com.wwdz.ch.db.domain.openShop.UserAccount;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
import
com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto
;
import
com.wwdz.ch.db.dto.request.openShop.EarnestOrderRequestDto
;
import
com.wwdz.ch.db.dto.request.openShop.EarnestOrderRequestDto
;
import
com.wwdz.ch.db.dto.request.openShop.EarnestRecordRequestDto
;
import
com.wwdz.ch.db.dto.request.openShop.EarnestRecordRequestDto
;
import
com.wwdz.ch.wx.service.UserAccountService
;
import
com.wwdz.ch.wx.service.openShop.AuctionEarnestService
;
import
com.wwdz.ch.wx.service.openShop.AuctionEarnestService
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
...
@@ -50,6 +51,9 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
...
@@ -50,6 +51,9 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
@Autowired
@Autowired
RedissonClient
redissonClient
;
RedissonClient
redissonClient
;
@Autowired
UserAccountService
userAccountService
;
@Override
@Override
public
Result
payEarnest
(
EarnestOrderRequestDto
dto
)
{
public
Result
payEarnest
(
EarnestOrderRequestDto
dto
)
{
try
{
try
{
...
@@ -200,6 +204,19 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
...
@@ -200,6 +204,19 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
if
(!
lock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
))
{
if
(!
lock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
))
{
return
Result
.
failed
(
"操作过快,稍后再试"
);
return
Result
.
failed
(
"操作过快,稍后再试"
);
}
}
userAccountService
.
initAccount
(
dto
.
getUserId
());
//检查该用户是否有被占用的保证金,兼容之前没有保证金的逻辑
EarnestRecordRequestDto
checkDto
=
new
EarnestRecordRequestDto
();
checkDto
.
setUserId
(
dto
.
getUserId
());
checkDto
.
setItemId
(
dto
.
getItemId
());
checkDto
.
setType
(
EarnestEnum
.
TypeEnum
.
OCCUPY
.
getCode
());
checkDto
.
setState
(
EarnestEnum
.
StateEnum
.
VALID
.
getCode
());
if
(!
earnestRecordDao
.
isExisted
(
checkDto
))
{
logger
.
info
(
"该用户之前没有被占用过保证金,无需释放额度"
);
return
Result
.
success
();
}
long
auctionPrice
=
dto
.
getAuctionPrice
();
long
auctionPrice
=
dto
.
getAuctionPrice
();
BigDecimal
earnestAmount
=
new
BigDecimal
(
String
.
valueOf
(
auctionPrice
)).
multiply
(
new
BigDecimal
(
CommConsts
.
EARNEST_REBATE
));
BigDecimal
earnestAmount
=
new
BigDecimal
(
String
.
valueOf
(
auctionPrice
)).
multiply
(
new
BigDecimal
(
CommConsts
.
EARNEST_REBATE
));
//换算成对应占用的保证金
//换算成对应占用的保证金
...
@@ -250,15 +267,25 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
...
@@ -250,15 +267,25 @@ public class AuctionEarnestServiceImpl implements AuctionEarnestService {
@Override
@Override
public
Result
deductEarnest
(
EarnestRecordRequestDto
dto
)
{
public
Result
deductEarnest
(
EarnestRecordRequestDto
dto
)
{
/*if (CommConsts.NOT_SEND_MSG_USERID.contains(dto.getUserId())) {
return Result.success();
}*/
String
itemIdKey
=
CommConsts
.
EARNEST_ACCOUNT_LOCK
+
dto
.
getUserId
();
String
itemIdKey
=
CommConsts
.
EARNEST_ACCOUNT_LOCK
+
dto
.
getUserId
();
RLock
lock
=
redissonClient
.
getLock
(
itemIdKey
);
RLock
lock
=
redissonClient
.
getLock
(
itemIdKey
);
try
{
try
{
if
(!
lock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
))
{
if
(!
lock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
))
{
return
Result
.
failed
(
"操作过快,稍后再试"
);
return
Result
.
failed
(
"操作过快,稍后再试"
);
}
}
userAccountService
.
initAccount
(
dto
.
getUserId
());
//检查该用户是否有被占用的保证金,兼容之前没有保证金的逻辑
EarnestRecordRequestDto
checkDto
=
new
EarnestRecordRequestDto
();
checkDto
.
setUserId
(
dto
.
getUserId
());
checkDto
.
setItemId
(
dto
.
getItemId
());
checkDto
.
setType
(
EarnestEnum
.
TypeEnum
.
OCCUPY
.
getCode
());
checkDto
.
setState
(
EarnestEnum
.
StateEnum
.
VALID
.
getCode
());
if
(!
earnestRecordDao
.
isExisted
(
checkDto
))
{
logger
.
info
(
"该用户之前没有被占用过保证金,无需扣除"
);
return
Result
.
success
();
}
long
auctionPrice
=
dto
.
getAuctionPrice
();
long
auctionPrice
=
dto
.
getAuctionPrice
();
BigDecimal
earnestAmount
=
new
BigDecimal
(
String
.
valueOf
(
auctionPrice
)).
multiply
(
new
BigDecimal
(
CommConsts
.
EARNEST_REBATE
));
BigDecimal
earnestAmount
=
new
BigDecimal
(
String
.
valueOf
(
auctionPrice
)).
multiply
(
new
BigDecimal
(
CommConsts
.
EARNEST_REBATE
));
//换算成对应占用的保证金
//换算成对应占用的保证金
...
...
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