记得上下班打卡 | 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
6982f6fe
Commit
6982f6fe
authored
Jun 27, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现xuper相关艺术品上传
parent
f5f91961
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
115 deletions
+32
-115
XuperTradeBiz.java
...uidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
+32
-115
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
View file @
6982f6fe
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
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.dto.*
;
import
com.liquidnet.common.third.zxlnft.dto.Nft044BuyResultReqDto
;
import
com.liquidnet.common.third.zxlnft.dto.Nft044BuyResultRespDto
;
import
com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz
;
import
com.liquidnet.service.galaxy.biz.GalaxyEnumBiz
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.constant.GalaxyErrorEnum
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.router.zxin.biz.ZxinPublishBiz
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
...
...
@@ -22,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Date
;
/**
...
...
@@ -60,61 +60,15 @@ public class XuperTradeBiz {
@Autowired
private
QueueUtil
queueUtil
;
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信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
nftBuyReqDto
.
getRouterType
(),
nftBuyReqDto
.
getSkuId
());
//返回参数nftId
String
nftId
=
null
;
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)){
nftId
=
nftOrderBo
.
getNftId
();
}
if
(
StringUtil
.
isNotEmpty
(
nftId
)){
//执行购买逻辑
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
nftBuyReqDto
.
getRouterType
(),
nftId
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
return
ResponseDto
.
success
(
nftBuyRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getMessage
());
}
/**
* 发行和购买
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
return
xuperTradeCommonBiz
.
nftPublishAndBuy
(
reqDto
);
}
public
ResponseDto
<
GalaxyNftBuyResultQueryRespDto
>
nftBuyResultQuery
(
GalaxyNftBuyResultQueryReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_ORDER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_ORDER_NOT_EXIST
.
getMessage
());
}
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftBuyTaskId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_TASK_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_TASK_NOT_EXIST
.
getMessage
());
}
//3.2.4查询NFT购买结果
Nft044BuyResultReqDto
nft044ReqDto
=
Nft044BuyResultReqDto
.
getNew
();
nft044ReqDto
.
setTaskId
(
nftOrderBo
.
getNftBuyTaskId
());
ZxlnftResponseDto
<
Nft044BuyResultRespDto
>
nft044RespDto
=
zxlnftSdkUtil
.
nft044BuyResult
(
nft044ReqDto
);
GalaxyNftBuyResultQueryRespDto
resultQueryRespDto
=
GalaxyNftBuyResultQueryRespDto
.
getNew
();
BeanUtil
.
copy
(
nft044RespDto
.
getData
(),
resultQueryRespDto
);
String
nowTimeStr
=
DateUtil
.
format
(
new
Date
(
nft044RespDto
.
getData
().
getChainTimestamp
().
longValue
()*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
//转换任务状态
Integer
taskStatus
=
Integer
.
valueOf
(
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
nft044RespDto
.
getData
().
getTaskStatus
().
toString
()).
getCode
());
resultQueryRespDto
.
setTaskStatus
(
taskStatus
);
resultQueryRespDto
.
setChainTimestamp
(
nowTimeStr
);
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
/**
* NFT发行和购买
...
...
@@ -185,65 +139,28 @@ public class XuperTradeBiz {
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_PUBLISH_AND_BUY_QUERY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT_PUBLISH_AND_BUY_QUERY_FAIL
.
getMessage
(),
resultQueryRespDto
);
}
private
GalaxyNftBuyRespDto
nftBuyBusiness
(
String
routerType
,
String
nftId
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesNftInfoBo
seriesNftInfoBo
,
GalaxyNftOrderBo
nftOrderBo
){
// 3.2.2调用购买NFT接口
Nft043BuyReqDto
nft043BuyReqDto
=
Nft043BuyReqDto
.
getNew
();
nft043BuyReqDto
.
setNftId
(
nftId
);
nft043BuyReqDto
.
setApplyScore
(
seriesNftInfoBo
.
getSellCount
().
intValue
());
try
{
nft043BuyReqDto
.
setReceiverPubKey
(
BASE64Util
.
decode
(
userInfoBo
.
getUserPubKey
()));
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
public
ResponseDto
<
GalaxyNftBuyResultQueryRespDto
>
nftBuyResultQuery
(
GalaxyNftBuyResultQueryReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_ORDER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_ORDER_NOT_EXIST
.
getMessage
());
}
nft043BuyReqDto
.
setPointReceiverAddr
(
userInfoBo
.
getBlockChainAddress
());
nft043BuyReqDto
.
setOfferCount
(
seriesNftInfoBo
.
getSellCount
().
longValue
());
nft043BuyReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
/**
* 接收人的私钥签名,签名对象是(platformPubKey_receiverPubKey_pointReceiverAddr_applyScore_接口名_nftId_offerCount_operateId)
* 接口名:buy_nft
*/
String
signMetaData
=
zxlnftConfig
.
getNftPlatformPubKey
()
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getReceiverPubKey
())
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getPointReceiverAddr
())
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getApplyScore
().
toString
())
.
concat
(
"_"
).
concat
(
"buy_nft"
)
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getNftId
())
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getOfferCount
().
toString
())
.
concat
(
"_"
).
concat
(
nft043BuyReqDto
.
getOperateId
());
String
signature
=
null
;
try
{
signature
=
zxlnftBiz
.
createSign
(
BASE64Util
.
decode
(
userInfoBo
.
getUserPriKey
()),
signMetaData
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
nft043BuyReqDto
.
setSignature
(
signature
);
String
nftBuyTaskId
=
null
;
ZxlnftResponseDto
<
Nft043BuyRespDto
>
nft043RespDto
=
zxlnftSdkUtil
.
nft043Buy
(
nft043BuyReqDto
);
if
(
nft043RespDto
.
isSuccess
()){
nftBuyTaskId
=
nft043RespDto
.
getData
().
getTaskId
();
}
else
{
throw
new
LiquidnetServiceException
(
nft043RespDto
.
getCode
(),
nft043RespDto
.
getMessage
());
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftBuyTaskId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_TASK_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_TASK_NOT_EXIST
.
getMessage
());
}
//3.2.4查询NFT购买结果
Nft044BuyResultReqDto
nft044ReqDto
=
Nft044BuyResultReqDto
.
getNew
();
nft044ReqDto
.
setTaskId
(
nftOrderBo
.
getNftBuyTaskId
());
ZxlnftResponseDto
<
Nft044BuyResultRespDto
>
nft044RespDto
=
zxlnftSdkUtil
.
nft044BuyResult
(
nft044ReqDto
);
//更新缓存数据状态
nftOrderBo
.
setNftBuyTaskId
(
nftBuyTaskId
);
nftOrderBo
.
setNftBuyStatus
(
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
());
dataUtils
.
updateNftOrderBuyInfo
(
routerType
,
nftOrderBo
.
getNftOrderPayId
(),
nftOrderBo
);
GalaxyNftBuyRespDto
nftBuyRespDto
=
GalaxyNftBuyRespDto
.
getNew
();
nftBuyRespDto
.
setUserId
(
userInfoBo
.
getUserId
());
nftBuyRespDto
.
setNftId
(
null
);
return
nftBuyRespDto
;
}
/**
* 发行和购买
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
return
xuperTradeCommonBiz
.
nftPublishAndBuy
(
reqDto
);
GalaxyNftBuyResultQueryRespDto
resultQueryRespDto
=
GalaxyNftBuyResultQueryRespDto
.
getNew
();
BeanUtil
.
copy
(
nft044RespDto
.
getData
(),
resultQueryRespDto
);
String
nowTimeStr
=
DateUtil
.
format
(
new
Date
(
nft044RespDto
.
getData
().
getChainTimestamp
().
longValue
()*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
//转换任务状态
Integer
taskStatus
=
Integer
.
valueOf
(
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
nft044RespDto
.
getData
().
getTaskStatus
().
toString
()).
getCode
());
resultQueryRespDto
.
setTaskStatus
(
taskStatus
);
resultQueryRespDto
.
setChainTimestamp
(
nowTimeStr
);
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
}
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