记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
4ca2db0b
Commit
4ca2db0b
authored
Mar 24, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化相关策略实现
parent
ed9c2d28
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
45 deletions
+68
-45
GalaxyErrorEnum.java
...om/liquidnet/service/galaxy/constant/GalaxyErrorEnum.java
+3
-1
GalaxyUserInfoBo.java
...com/liquidnet/service/galaxy/dto/bo/GalaxyUserInfoBo.java
+22
-0
ZxinTradeBiz.java
...iquidnet/service/galaxy/router/zxin/biz/ZxinTradeBiz.java
+31
-44
DataUtils.java
...in/java/com/liquidnet/service/galaxy/utils/DataUtils.java
+12
-0
No files found.
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/constant/GalaxyErrorEnum.java
View file @
4ca2db0b
...
...
@@ -21,7 +21,9 @@ public enum GalaxyErrorEnum {
SERIES_CLAIM_SUCCESSED
(
"NFT0010009"
,
"系列已声明成功,不允许重复声明!"
),
SERIES_CLAIM_NOT_EXIST
(
"NFT0010010"
,
"系列声明初始化信息不存在,请检查是否已上传对应素材!"
),
PUBLISH_ORDER_NOT_EXIST
(
"NFT0010011"
,
"NFT购买订单不存在!"
),
NFT_BUY_TASK_NOT_EXIST
(
"NFT0010012"
,
"NFT购买执行任务不存在"
);
NFT_BUY_TASK_NOT_EXIST
(
"NFT0010012"
,
"NFT购买执行任务不存在"
),
NFT_BUY_TASK_HAVE_EXIST
(
"NFT0010013"
,
"NFT购买执行任务已存在,不可以重复购买!"
),
NFT_BUY_FAIL
(
"NFT0010014"
,
"NFT购买失败,nftId不存在!"
);
private
String
code
;
private
String
message
;
...
...
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/bo/GalaxyUserInfoBo.java
View file @
4ca2db0b
package
com
.
liquidnet
.
service
.
galaxy
.
dto
.
bo
;
import
com.liquidnet.commons.lang.util.BASE64Util
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.io.UnsupportedEncodingException
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
...
...
@@ -29,6 +31,26 @@ public class GalaxyUserInfoBo implements Serializable,Cloneable{
private
String
routerType
;
private
String
blockChainAddress
;
public
String
getUserPubKey
()
{
String
pubKey
=
null
;
try
{
pubKey
=
BASE64Util
.
decode
(
userPubKey
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
pubKey
;
}
public
String
getUserPriKey
()
{
String
priKey
=
null
;
try
{
priKey
=
BASE64Util
.
decode
(
userPriKey
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
priKey
;
}
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/biz/ZxinTradeBiz.java
View file @
4ca2db0b
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
zxin
.
biz
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
...
...
@@ -53,14 +54,18 @@ public class ZxinTradeBiz {
private
DataUtils
dataUtils
;
public
ResponseDto
<
GalaxyNftBuyRespDto
>
nftBuy
(
GalaxyNftBuyReqDto
nftBuyReqDto
){
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
nftBuyReqDto
.
getRouterType
(),
nftBuyReqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)&&
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftBuyTaskId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_TASK_HAVE_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_TASK_HAVE_EXIST
.
getMessage
());
}
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
nftBuyReqDto
.
getRouterType
(),
nftBuyReqDto
.
getUserId
());
//获取sku信息
GalaxySeriesInfoBo
seriesInfoBo
=
dataUtils
.
getSeriesInfoBo
(
nftBuyReqDto
.
getRouterType
(),
nftBuyReqDto
.
getSkuId
());
//获取nftOrder信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
nftBuyReqDto
.
getRouterType
(),
nftBuyReqDto
.
getNftOrderPayId
());
//返回参数nftId
String
nftId
=
null
;
...
...
@@ -70,14 +75,21 @@ public class ZxinTradeBiz {
if
(
StringUtil
.
isNotEmpty
(
nftId
)){
//执行购买逻辑
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
nft
Id
,
userInfoBo
,
seriesInfo
Bo
);
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
nft
BuyReqDto
.
getRouterType
(),
nftId
,
userInfoBo
,
seriesInfoBo
,
nftOrder
Bo
);
return
ResponseDto
.
success
(
nftBuyRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_BUY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH
_BUY_FAIL
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT
_BUY_FAIL
.
getMessage
());
}
}
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getMessage
());
}
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
...
...
@@ -208,7 +220,7 @@ public class ZxinTradeBiz {
if
(
StringUtil
.
isNotEmpty
(
nftId
)){
//执行购买逻辑
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
GalaxyNftPublishAndBuyRespDto
.
getNew
();
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
nftId
,
userInfoBo
,
seriesInfo
Bo
);
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
reqDto
.
getRouterType
(),
nftId
,
userInfoBo
,
seriesInfoBo
,
nftOrder
Bo
);
BeanUtil
.
copy
(
nftBuyRespDto
,
nftPublishAndBuyRespDto
);
return
ResponseDto
.
success
(
nftPublishAndBuyRespDto
);
}
else
{
...
...
@@ -263,7 +275,7 @@ public class ZxinTradeBiz {
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
private
GalaxyNftBuyRespDto
nftBuyBusiness
(
String
nftId
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesInfoBo
seriesInfo
Bo
){
private
GalaxyNftBuyRespDto
nftBuyBusiness
(
String
routerType
,
String
nftId
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesInfoBo
seriesInfoBo
,
GalaxyNftOrderBo
nftOrder
Bo
){
// 3.2.2调用购买NFT接口
Nft043BuyReqDto
nft043BuyReqDto
=
Nft043BuyReqDto
.
getNew
();
nft043BuyReqDto
.
setNftId
(
nftId
);
...
...
@@ -288,47 +300,22 @@ public class ZxinTradeBiz {
String
signature
=
zxlnftBiz
.
createSign
(
userInfoBo
.
getUserPriKey
(),
signMetaData
);
nft043BuyReqDto
.
setSignature
(
signature
);
String
nftBuyTaskId
=
null
;
ZxlnftResponseDto
<
Nft043BuyRespDto
>
nft043RespDto
=
zxlnftSdkUtil
.
nft043Buy
(
nft043BuyReqDto
);
if
(
nft043RespDto
.
isSuccess
()){
//3.2.4查询NFT购买结果
Nft044BuyResultReqDto
nft044ReqDto
=
Nft044BuyResultReqDto
.
getNew
();
nft044ReqDto
.
setTaskId
(
nft043RespDto
.
getData
().
getTaskId
());
long
timeStart
=
System
.
currentTimeMillis
();
ZxlnftResponseDto
<
Nft044BuyResultRespDto
>
nft044RespDto
=
zxlnftSdkUtil
.
nft044BuyResult
(
nft044ReqDto
);
if
(
nft044RespDto
.
isSuccess
()){
int
count
=
1
;
String
payTaskId
=
null
;
while
(
payTaskId
==
null
){
try
{
Thread
.
sleep
(
1000
l
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
count
++;
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
1
,
nft044ReqDto
.
getTaskId
());
ZxlnftResponseDto
<
Nft044BuyResultRespDto
>
nft044RespDtoTemp
=
zxlnftSdkUtil
.
nft044BuyResult
(
nft044ReqDto
);
if
(
nft044RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
payTaskId
=
nft044RespDtoTemp
.
getData
().
getPayTaskId
();
}
else
if
(
nft044RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
())){
log
.
info
(
"任务执行失败!taskId:{}"
,
nft044ReqDto
.
getTaskId
());
return
null
;
}
if
(
count
==
6
){
log
.
info
(
"=======查询共6次,跳出循环!taskId:{}"
,
nft044ReqDto
.
getTaskId
());
break
;
}
}
log
.
info
(
"总共执行了多少次查询:{} 总耗时:{}"
,
count
,
System
.
currentTimeMillis
()
-
timeStart
);
if
(
StringUtil
.
isNotEmpty
(
payTaskId
)){
//3.2.5查询NFT购买支付结果
Nft045BuyPayResultReqDto
nft045ReqDto
=
Nft045BuyPayResultReqDto
.
getNew
();
nft045ReqDto
.
setTaskId
(
payTaskId
);
ZxlnftResponseDto
<
Nft045BuyPayResultRespDto
>
nft045RespDto
=
zxlnftSdkUtil
.
nft045BuyPayResult
(
nft045ReqDto
);
}
}
nftBuyTaskId
=
nft043RespDto
.
getData
().
getTaskId
();
}
else
{
throw
new
LiquidnetServiceException
(
nft043RespDto
.
getCode
(),
nft043RespDto
.
getMessage
());
}
return
null
;
//更新缓存数据状态
nftOrderBo
.
setNftBuyPayTaskId
(
nftBuyTaskId
);
dataUtils
.
updateNftOrderBuyTaskId
(
routerType
,
nftOrderBo
.
getNftOrderPayId
(),
nftOrderBo
);
GalaxyNftBuyRespDto
nftBuyRespDto
=
GalaxyNftBuyRespDto
.
getNew
();
nftBuyRespDto
.
setUserId
(
userInfoBo
.
getUserId
());
nftBuyRespDto
.
setNftId
(
null
);
return
nftBuyRespDto
;
}
/**
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/utils/DataUtils.java
View file @
4ca2db0b
...
...
@@ -122,4 +122,16 @@ public class DataUtils {
log
.
info
(
"updateNftOrderInfo result:{}"
,
result
.
toString
());
}
public
void
updateNftOrderBuyTaskId
(
String
routeType
,
String
nftOrderPayId
,
GalaxyNftOrderBo
nftOrderBo
)
{
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KET_GALAXY_TRADE
.
concat
(
routeType
).
concat
(
":"
)
+
nftOrderPayId
,
nftOrderBo
,
keyExpireTime
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"nftOrderPayId"
).
is
(
nftOrderPayId
));
Update
update
=
Update
.
fromDocument
(
Document
.
parse
(
JsonUtils
.
toJson
(
nftOrderBo
)));
update
.
set
(
"nftBuyTaskId"
,
nftOrderBo
.
getNftBuyTaskId
());
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
LocalDateTime
.
now
());
update
.
set
(
"updatedAt"
,
nowTimeStr
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
query
,
update
,
GalaxyNftOrderBo
.
class
,
GalaxyNftOrderBo
.
class
.
getSimpleName
());
log
.
info
(
"updateNftOrderInfo result:{}"
,
result
.
toString
());
}
}
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