记得上下班打卡 | 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
48edea42
Commit
48edea42
authored
Aug 15, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现百度链转让接口
parent
26d4b13a
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
643 additions
and
183 deletions
+643
-183
GalaxyEnum.java
...ava/com/liquidnet/service/galaxy/constant/GalaxyEnum.java
+37
-0
GalaxyErrorEnum.java
...om/liquidnet/service/galaxy/constant/GalaxyErrorEnum.java
+6
-2
GalaxyTransferNftInfoBo.java
...uidnet/service/galaxy/dto/bo/GalaxyTransferNftInfoBo.java
+37
-4
GalaxyNftTransferQueryReqDto.java
...ervice/galaxy/dto/param/GalaxyNftTransferQueryReqDto.java
+9
-2
GalaxyNftTransferQueryRespDto.java
...rvice/galaxy/dto/param/GalaxyNftTransferQueryRespDto.java
+22
-4
GalaxyNftTransferRespDto.java
...et/service/galaxy/dto/param/GalaxyNftTransferRespDto.java
+16
-1
pom.xml
...quidnet-common-third/liquidnet-common-third-xuper/pom.xml
+1
-1
Xuper010QuerySdsRespDto.java
...idnet/common/third/xuper/dto/Xuper010QuerySdsRespDto.java
+1
-1
Xuper011ListSdsByAddrReqDto.java
...t/common/third/xuper/dto/Xuper011ListSdsByAddrReqDto.java
+4
-2
Xuper013HistoryReqDto.java
...quidnet/common/third/xuper/dto/Xuper013HistoryReqDto.java
+8
-4
Xuper013HistoryRespDto.java
...uidnet/common/third/xuper/dto/Xuper013HistoryRespDto.java
+68
-5
XuperSdkUtil.java
...a/com/liquidnet/common/third/xuper/util/XuperSdkUtil.java
+37
-32
GalaxyBeanTransferBiz.java
...m/liquidnet/service/galaxy/biz/GalaxyBeanTransferBiz.java
+49
-0
AbstractDataUtils.java
...com/liquidnet/service/galaxy/utils/AbstractDataUtils.java
+48
-0
GalaxyTradeController.java
...dnet/service/galaxy/controller/GalaxyTradeController.java
+0
-10
XuperTradeBiz.java
...uidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
+194
-5
GalaxyRouterStrategyXuperTradeImpl.java
...ter/xuper/service/GalaxyRouterStrategyXuperTradeImpl.java
+0
-3
GalaxyRouterStrategyZxlTradeImpl.java
...router/zxin/service/GalaxyRouterStrategyZxlTradeImpl.java
+1
-12
GalaxyTradeServiceImpl.java
...t/service/galaxy/service/impl/GalaxyTradeServiceImpl.java
+20
-2
TestXuperSdkUtil.java
...liquidnet/service/goblin/test/xuper/TestXuperSdkUtil.java
+85
-93
No files found.
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/constant/GalaxyEnum.java
View file @
48edea42
...
...
@@ -336,4 +336,41 @@ public class GalaxyEnum {
System
.
out
.
println
(
"支付成功"
);
}
}
/**
* nft转让状态
*/
public
enum
NftTransferStatusEnum
{
INIT
(
"-1"
,
"数据初始化"
),
PROCESSING
(
"0"
,
"转让中"
),
SUCCESS
(
"1"
,
"转让成功"
),
FAIL
(
"2"
,
"转让失败"
);
private
String
code
;
private
String
message
;
NftTransferStatusEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
NftTransferStatusEnum
getEnumByCode
(
String
code
){
NftTransferStatusEnum
[]
arry
=
NftTransferStatusEnum
.
values
();
for
(
int
i
=
0
;
i
<
arry
.
length
;
i
++)
{
if
(
arry
[
i
].
getCode
().
equals
(
code
))
{
return
arry
[
i
];
}
}
return
null
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMessage
(){
return
message
;
}
}
}
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/constant/GalaxyErrorEnum.java
View file @
48edea42
...
...
@@ -36,8 +36,12 @@ public enum GalaxyErrorEnum {
SERIES_NFT_INFO_NOT_EXIST
(
"NFT0010024"
,
"系列NFT信息查询不存在!"
),
SERIES_NFT_HASH_CREATE_FAIL
(
"NFT0010025"
,
"系列NFT的介质hash生成失败!"
),
NFT_TRANSFER_FAIL
(
"NFT0010026"
,
"NFT转让失败"
),
NFT_TRANSFER_OWNER_ERROR
(
"NFT0010027"
,
"NFT转让失败,拥有者不匹配"
),
NFT_TRANSFERING_ERROR
(
"NFT0010028"
,
"NFT正在转让中,不允许再次操作!"
);
NFT_TRANSFER_FAIL_OWNER_NOT_EXIST
(
"NFT0010027"
,
"NFT转让失败,拥有者不存在!"
),
NFT_TRANSFER_FAIL_RECEIVER_NOT_EXIST
(
"NFT0010028"
,
"NFT转让失败,接收者不存在!"
),
NFT_TRANSFER_OWNER_MATCH_ERROR
(
"NFT0010029"
,
"NFT转让失败,拥有者不匹配"
),
NFT_TRANSFERING_ERROR
(
"NFT0010030"
,
"NFT正在转让中,不允许再次操作!"
),
NFT_TRANSFER_NFTID_FORMAT_ERROR
(
"NFT0010031"
,
"NFT转让失败,nftid格式错误!"
),
NFT_TRANSFER_QUERY_ERROR
(
"NFT0010032"
,
"NFT转让结果查询失败,nft信息不存在!"
);
private
String
code
;
...
...
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/bo/GalaxyTransferNftInfoBo.java
View file @
48edea42
...
...
@@ -21,13 +21,33 @@ public class GalaxyTransferNftInfoBo implements Serializable,Cloneable{
*/
private
String
nftId
;
/**
*
nft当前拥有者addr
*
转让发起人用户id
*/
private
String
ownerAddr
;
private
String
userId
;
/**
*
nft历史拥有者addr
*
转让发起人区块链地址
*/
private
String
fromAddr
;
private
String
address
;
/**
* 接收者userId
*/
private
String
receiveUserId
;
/**
* 接收者区块链地址
*/
private
String
receiveAddress
;
/**
* nft当前拥有者用户id(转让成功后更新)
*/
private
String
ownerUserId
;
/**
* nft当前拥有者addr(转让成功后更新)
*/
private
String
ownerAddress
;
/**
* 转让hash
*/
private
String
transferHash
;
/**
* 系列的唯一Id
*/
...
...
@@ -36,6 +56,19 @@ public class GalaxyTransferNftInfoBo implements Serializable,Cloneable{
* 路由类型
*/
private
String
routerType
;
/**
* 转让状态(0转让中 1转让成功 2转让失败 )
*/
private
String
transferStatus
;
/**
* 错误码
*/
private
String
errorCode
;
/**
* 错误信息
*/
private
String
errorMsg
;
/**
* 创建时间
*/
...
...
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftTransferQueryReqDto.java
View file @
48edea42
...
...
@@ -16,19 +16,26 @@ import java.io.Serializable;
* @class: GalaxyNftTransferReqDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/8/
4 18
:42
* @date 2022/8/
15 14
:42
*/
@ApiModel
(
value
=
"GalaxyNftTransferQueryReqDto"
,
description
=
"NFT转让结果查询"
)
@Data
public
class
GalaxyNftTransferQueryReqDto
extends
GalaxyBaseReqDto
implements
Serializable
,
Cloneable
{
/**
*
以下为发行参数***********************************
*
用户id
*/
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"用户ID[30]"
)
@NotBlank
(
message
=
"用户ID不能为空!"
)
@Size
(
min
=
1
,
max
=
30
,
message
=
"用户ID限制2-30位且不能包含特殊字符"
)
private
String
userId
;
/**
* nftId
*/
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"nft唯一id"
)
@NotBlank
(
message
=
"nft唯一id不能为空!"
)
private
String
nftId
;
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
...
...
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftTransferQueryRespDto.java
View file @
48edea42
...
...
@@ -19,12 +19,30 @@ import java.io.Serializable;
@ApiModel
(
value
=
"GalaxyNftTransferQueryRespDto"
,
description
=
"NFT转让结果查询"
)
@Data
public
class
GalaxyNftTransferQueryRespDto
implements
Serializable
,
Cloneable
{
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"用户Id"
)
private
String
userId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"用户购买的nftId"
)
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"nft唯一id"
)
private
String
nftId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"拥有者用户ID"
)
private
String
ownerUserId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"拥有者地址"
)
private
String
ownerAddress
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转出者用户ID"
)
private
String
fromUserId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转出者地址"
)
private
String
fromAddress
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转让时间"
)
private
String
transferTime
;
@ApiModelProperty
(
position
=
3
,
required
=
true
,
value
=
"路由类型"
)
private
String
routerType
;
@ApiModelProperty
(
position
=
4
,
required
=
true
,
value
=
"转让hash"
)
private
String
transferHash
;
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
...
...
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftTransferRespDto.java
View file @
48edea42
...
...
@@ -19,15 +19,30 @@ import java.io.Serializable;
@ApiModel
(
value
=
"GalaxyNftTransferRespDto"
,
description
=
"NFT转让结果"
)
@Data
public
class
GalaxyNftTransferRespDto
implements
Serializable
,
Cloneable
{
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"nft唯一id"
)
private
String
nftId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"拥有者用户ID"
)
private
String
ownerUserId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转让者用户ID"
)
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"拥有者地址"
)
private
String
ownerAddress
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转出者用户ID"
)
private
String
fromUserId
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转出者地址"
)
private
String
fromAddress
;
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"转让时间"
)
private
String
transferTime
;
@ApiModelProperty
(
position
=
3
,
required
=
true
,
value
=
"路由类型"
)
private
String
routerType
;
@ApiModelProperty
(
position
=
4
,
required
=
true
,
value
=
"转让hash"
)
private
String
transferHash
;
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/pom.xml
View file @
48edea42
...
...
@@ -35,7 +35,7 @@
<dependency>
<groupId>
com.baidu.xuper
</groupId>
<artifactId>
xasset-sdk-java
</artifactId>
<version>
1.0.
4
</version>
<version>
1.0.
7
</version>
</dependency>
<dependency>
<groupId>
com.baidu.xuper
</groupId>
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper010QuerySdsRespDto.java
View file @
48edea42
...
...
@@ -25,7 +25,7 @@ public class Xuper010QuerySdsRespDto {
public
String
ownerAddr
;
public
long
uid
;
public
long
price
;
public
int
status
;
public
int
status
;
//0:已上链 1:授予中 4:转移中 5: 核销中 6: 已核销 10:异常详情参考错误码和状态码
public
String
txId
;
public
ShardAssetInfo
assetInfo
;
public
long
ctime
;
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper011ListSdsByAddrReqDto.java
View file @
48edea42
...
...
@@ -16,9 +16,11 @@ public class Xuper011ListSdsByAddrReqDto {
//要拉取的区块链账户地址
private
String
addr
=
""
;
//要拉取页数,第一页为1
private
int
page
=
1
;
private
Integer
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
private
int
limit
=
50
;
private
Integer
limit
=
50
;
//资产id
private
Long
assetId
;
private
static
final
Xuper011ListSdsByAddrReqDto
obj
=
new
Xuper011ListSdsByAddrReqDto
();
public
static
Xuper011ListSdsByAddrReqDto
getNew
()
{
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper013HistoryReqDto.java
View file @
48edea42
...
...
@@ -6,7 +6,7 @@ import lombok.Data;
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取数字商品历史登记记录
* @class: Xuper0
01GetStoken
ReqDto
* @class: Xuper0
13History
ReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
...
...
@@ -14,11 +14,15 @@ import lombok.Data;
@Data
public
class
Xuper013HistoryReqDto
{
//资产id
private
l
ong
assetId
;
private
L
ong
assetId
;
//要拉取页数,第一页为1
private
int
page
=
1
;
private
Integer
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
private
int
limit
=
20
;
private
Integer
limit
=
20
;
/**
* 碎片id
*/
private
Long
shardId
;
private
static
final
Xuper013HistoryReqDto
obj
=
new
Xuper013HistoryReqDto
();
public
static
Xuper013HistoryReqDto
getNew
()
{
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper013HistoryRespDto.java
View file @
48edea42
...
...
@@ -8,21 +8,20 @@ import java.util.ArrayList;
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取数字商品历史登记记录
* @class: Xuper0
01GetStokenReq
Dto
* @class: Xuper0
13HistoryResp
Dto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/
4/18 15:1
0
* @date 2022/
8/12 17:5
0
*/
@Data
public
class
Xuper013HistoryRespDto
{
public
long
requestId
;
public
int
errNo
;
public
String
errMsg
;
public
ArrayList
<
AssetInfo
>
list
;
public
ArrayList
<
History
>
list
;
public
int
totalCnt
;
@Data
public
static
class
AssetInfo
{
public
static
class
History
{
public
long
assetId
;
public
long
type
;
public
long
shardId
;
...
...
@@ -31,6 +30,70 @@ public class Xuper013HistoryRespDto {
public
String
from
;
public
String
to
;
public
long
ctime
;
public
long
getAssetId
()
{
return
assetId
;
}
public
void
setAssetId
(
long
assetId
)
{
this
.
assetId
=
assetId
;
}
public
long
getType
()
{
return
type
;
}
public
void
setType
(
long
type
)
{
this
.
type
=
type
;
}
public
long
getShardId
()
{
return
shardId
;
}
public
void
setShardId
(
long
shardId
)
{
this
.
shardId
=
shardId
;
}
public
long
getPrice
()
{
return
price
;
}
public
void
setPrice
(
long
price
)
{
this
.
price
=
price
;
}
public
String
getTxId
()
{
return
txId
;
}
public
void
setTxId
(
String
txId
)
{
this
.
txId
=
txId
;
}
public
String
getFrom
()
{
return
from
;
}
public
void
setFrom
(
String
from
)
{
this
.
from
=
from
;
}
public
String
getTo
()
{
return
to
;
}
public
void
setTo
(
String
to
)
{
this
.
to
=
to
;
}
public
long
getCtime
()
{
return
ctime
;
}
public
void
setCtime
(
long
ctime
)
{
this
.
ctime
=
ctime
;
}
}
...
...
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/util/XuperSdkUtil.java
View file @
48edea42
...
...
@@ -9,7 +9,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
import
com.liquidnet.common.third.xuper.config.XuperConfig
;
import
com.liquidnet.common.third.xuper.constant.XuperErrorEnum
;
import
com.liquidnet.common.third.xuper.dto.*
;
import
com.liquidnet.common.third.xuper.exception.XupterException
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -62,10 +61,10 @@ public class XuperSdkUtil {
XassetDef
.
UploadFile
uploadFile
=
getAsset
().
uploadFile
(
account
,
fileName
,
filePath
,
dataByte
,
property
);
BaseDef
.
RequestRes
requestRes
=
uploadFile
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuperUploadFile resp : "
+
JsonUtils
.
toJson
(
uploadFile
));
log
.
info
(
"xuperUploadFile resp : "
+
JsonUtils
.
toJson
(
uploadFile
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
uploadFile
),
new
TypeReference
<
XuperUploadFileRespDto
>(){});
}
log
.
debug
(
"xuperUploadFile resp : "
+
JsonUtils
.
toJson
(
respDto
));
log
.
info
(
"xuperUploadFile resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
catch
(
Exception
e
){
log
.
error
(
"error msg "
+
e
.
getMessage
(),
e
);
return
XuperResponseDto
.
failure
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
...
...
@@ -88,7 +87,7 @@ public class XuperSdkUtil {
respDto
.
setPriKeyStr
(
acc
.
getKeyPair
().
getJSONPrivateKey
());
respDto
.
setAddress
(
acc
.
getAddress
());
respDto
.
setMnemonic
(
acc
.
getMnemonic
());
log
.
debug
(
"xuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
log
.
info
(
"xuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
return
XuperResponseDto
.
failure
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
...
...
@@ -106,14 +105,14 @@ public class XuperSdkUtil {
try
{
Account
acc
=
this
.
getAccount
(
reqDto
.
getMnemonic
());
BaseDef
.
Resp
<
XassetDef
.
GetStokenResp
>
getStokenResp
=
getAsset
().
getStoken
(
acc
);
log
.
debug
(
"pubKeyStr ===> {}"
,
acc
.
getKeyPair
().
getJSONPublicKey
());
log
.
debug
(
"priKeyStr ===> {}"
,
acc
.
getKeyPair
().
getJSONPrivateKey
());
log
.
debug
(
"address ===> {}"
,
acc
.
getAddress
());
log
.
debug
(
"address ===> {}"
,
acc
.
getMnemonic
());
log
.
info
(
"pubKeyStr ===> {}"
,
acc
.
getKeyPair
().
getJSONPublicKey
());
log
.
info
(
"priKeyStr ===> {}"
,
acc
.
getKeyPair
().
getJSONPrivateKey
());
log
.
info
(
"address ===> {}"
,
acc
.
getAddress
());
log
.
info
(
"address ===> {}"
,
acc
.
getMnemonic
());
BaseDef
.
RequestRes
requestRes
=
getStokenResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper001GetStoken resp : "
+
JsonUtils
.
toJson
(
getStokenResp
));
log
.
debug
(
"xuper001GetStoken apiResp : "
+
JsonUtils
.
toJson
(
getStokenResp
.
apiResp
));
log
.
info
(
"xuper001GetStoken resp : "
+
JsonUtils
.
toJson
(
getStokenResp
));
log
.
info
(
"xuper001GetStoken apiResp : "
+
JsonUtils
.
toJson
(
getStokenResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
getStokenResp
.
apiResp
),
new
TypeReference
<
Xuper001GetStokenRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -158,8 +157,8 @@ public class XuperSdkUtil {
BaseDef
.
Resp
<
XassetDef
.
CreateAssetResp
>
createAssetResp
=
getAsset
().
createAsset
(
account
,
amount
,
assetInfo
,
userId
,
price
);
BaseDef
.
RequestRes
requestRes
=
createAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper002CreateAsset resp : "
+
JsonUtils
.
toJson
(
createAssetResp
));
log
.
debug
(
"xuper002CreateAsset apiResp : "
+
JsonUtils
.
toJson
(
createAssetResp
.
apiResp
));
log
.
info
(
"xuper002CreateAsset resp : "
+
JsonUtils
.
toJson
(
createAssetResp
));
log
.
info
(
"xuper002CreateAsset apiResp : "
+
JsonUtils
.
toJson
(
createAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
createAssetResp
.
apiResp
),
new
TypeReference
<
Xuper002CreateAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -206,8 +205,8 @@ public class XuperSdkUtil {
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
alterAssetResp
=
getAsset
().
alterAsset
(
account
,
assetId
,
amount
,
assetInfo
,
price
);
BaseDef
.
RequestRes
requestRes
=
alterAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper003AlterAsset resp : "
+
JsonUtils
.
toJson
(
alterAssetResp
));
log
.
debug
(
"xuper003AlterAsset apiResp : "
+
JsonUtils
.
toJson
(
alterAssetResp
.
apiResp
));
log
.
info
(
"xuper003AlterAsset resp : "
+
JsonUtils
.
toJson
(
alterAssetResp
));
log
.
info
(
"xuper003AlterAsset apiResp : "
+
JsonUtils
.
toJson
(
alterAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
alterAssetResp
.
apiResp
),
new
TypeReference
<
Xuper003AlterAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -233,10 +232,10 @@ public class XuperSdkUtil {
int
isEvidence
=
0
;
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
publishAssetResp
=
getAsset
().
publishAsset
(
account
,
assetId
,
isEvidence
);
log
.
debug
(
"xuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
publishAssetResp
));
log
.
info
(
"xuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
publishAssetResp
));
BaseDef
.
RequestRes
requestRes
=
publishAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper004PublishAsset apiResp : "
+
JsonUtils
.
toJson
(
publishAssetResp
.
apiResp
));
log
.
info
(
"xuper004PublishAsset apiResp : "
+
JsonUtils
.
toJson
(
publishAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
publishAssetResp
.
apiResp
),
new
TypeReference
<
Xuper004PublishAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -257,10 +256,10 @@ public class XuperSdkUtil {
//资产id
long
assetId
=
reqDto
.
getAssetId
();
BaseDef
.
Resp
<
XassetDef
.
QueryAssetResp
>
queryAssetResp
=
getAsset
().
queryAsset
(
assetId
);
log
.
debug
(
"xuper005QueryAsset resp : "
+
JsonUtils
.
toJson
(
queryAssetResp
));
log
.
info
(
"xuper005QueryAsset resp : "
+
JsonUtils
.
toJson
(
queryAssetResp
));
BaseDef
.
RequestRes
requestRes
=
queryAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper005QueryAsset apiResp : "
+
JsonUtils
.
toJson
(
queryAssetResp
.
apiResp
));
log
.
info
(
"xuper005QueryAsset apiResp : "
+
JsonUtils
.
toJson
(
queryAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
queryAssetResp
.
apiResp
),
new
TypeReference
<
Xuper005QueryAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -288,10 +287,10 @@ public class XuperSdkUtil {
int
limit
=
reqDto
.
getLimit
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
listAssetsByAddr
(
status
,
addr
,
page
,
limit
);
log
.
debug
(
"xuper006ListAssetByAddr resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
log
.
info
(
"xuper006ListAssetByAddr resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
BaseDef
.
RequestRes
requestRes
=
listPageResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper006ListAssetByAddr apiResp : "
+
JsonUtils
.
toJson
(
listPageResp
.
apiResp
));
log
.
info
(
"xuper006ListAssetByAddr apiResp : "
+
JsonUtils
.
toJson
(
listPageResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
listPageResp
.
apiResp
),
new
TypeReference
<
Xuper006ListAssetByAddrRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -323,10 +322,10 @@ public class XuperSdkUtil {
long
price
=
reqDto
.
getPrice
();
BaseDef
.
Resp
<
XassetDef
.
GrantShardResp
>
grantShardResp
=
getAsset
().
grantShard
(
account
,
assetId
,
shardId
,
toAddr
,
toUserId
,
price
);
log
.
debug
(
"xuper007GrantShard resp : "
+
JsonUtils
.
toJson
(
grantShardResp
));
log
.
info
(
"xuper007GrantShard resp : "
+
JsonUtils
.
toJson
(
grantShardResp
));
BaseDef
.
RequestRes
requestRes
=
grantShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper007GrantShard apiResp : "
+
JsonUtils
.
toJson
(
grantShardResp
.
apiResp
));
log
.
info
(
"xuper007GrantShard apiResp : "
+
JsonUtils
.
toJson
(
grantShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
grantShardResp
.
apiResp
),
new
TypeReference
<
Xuper007GrantShardRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -358,10 +357,10 @@ public class XuperSdkUtil {
long
price
=
reqDto
.
getPrice
();
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
transferShardResp
=
getAsset
().
transferShard
(
account
,
assetId
,
shardId
,
toAddr
,
toUserId
,
price
);
log
.
debug
(
"xuper008TransferShard resp : "
+
JsonUtils
.
toJson
(
transferShardResp
));
log
.
info
(
"xuper008TransferShard resp : "
+
JsonUtils
.
toJson
(
transferShardResp
));
BaseDef
.
RequestRes
requestRes
=
transferShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper008TransferShard apiResp : "
+
JsonUtils
.
toJson
(
transferShardResp
.
apiResp
));
log
.
info
(
"xuper008TransferShard apiResp : "
+
JsonUtils
.
toJson
(
transferShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
transferShardResp
.
apiResp
),
new
TypeReference
<
Xuper008TransferShardRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -388,10 +387,10 @@ public class XuperSdkUtil {
//碎片id
long
shardId
=
123
;
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
consumeShardResp
=
getAsset
().
consumeShard
(
cAccount
,
uAccount
,
assetId
,
shardId
);
log
.
debug
(
"xuper009Consume resp : "
+
JsonUtils
.
toJson
(
consumeShardResp
));
log
.
info
(
"xuper009Consume resp : "
+
JsonUtils
.
toJson
(
consumeShardResp
));
BaseDef
.
RequestRes
requestRes
=
consumeShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper009Consume apiResp : "
+
JsonUtils
.
toJson
(
consumeShardResp
.
apiResp
));
log
.
info
(
"xuper009Consume apiResp : "
+
JsonUtils
.
toJson
(
consumeShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
consumeShardResp
.
apiResp
),
new
TypeReference
<
Xuper009ConsumeRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -414,10 +413,10 @@ public class XuperSdkUtil {
//碎片id
long
shardId
=
reqDto
.
getShardId
();
BaseDef
.
Resp
<
XassetDef
.
QueryShardsResp
>
queryShardsResp
=
getAsset
().
queryShards
(
assetId
,
shardId
);
log
.
debug
(
"xuper010QuerySds resp : "
+
JsonUtils
.
toJson
(
queryShardsResp
));
log
.
info
(
"xuper010QuerySds resp : "
+
JsonUtils
.
toJson
(
queryShardsResp
));
BaseDef
.
RequestRes
requestRes
=
queryShardsResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper010QuerySds apiResp : "
+
JsonUtils
.
toJson
(
queryShardsResp
.
apiResp
));
log
.
info
(
"xuper010QuerySds apiResp : "
+
JsonUtils
.
toJson
(
queryShardsResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
queryShardsResp
.
apiResp
),
new
TypeReference
<
Xuper010QuerySdsRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -441,11 +440,14 @@ public class XuperSdkUtil {
int
page
=
reqDto
.
getPage
();
//每页拉取数量,默认20,最大50(可选)
int
limit
=
reqDto
.
getLimit
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
listShardsAddr
(
addr
,
page
,
limit
);
log
.
debug
(
"xuper011ListSdsByAddr resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
//资产id
long
assetId
=
reqDto
.
getAssetId
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
listShardsByAddr
(
addr
,
page
,
limit
,
assetId
);
log
.
info
(
"xuper011ListSdsByAddr resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
BaseDef
.
RequestRes
requestRes
=
listPageResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
debug
(
"xuper011ListSdsByAddr apiResp : "
+
JsonUtils
.
toJson
(
listPageResp
.
apiResp
));
log
.
info
(
"xuper011ListSdsByAddr apiResp : "
+
JsonUtils
.
toJson
(
listPageResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
listPageResp
.
apiResp
),
new
TypeReference
<
Xuper011ListSdsByAddrRespDto
>(){});
}
}
catch
(
Exception
e
){
...
...
@@ -497,7 +499,10 @@ public class XuperSdkUtil {
int
page
=
reqDto
.
getPage
();
//每页拉取数量,默认20,最大50(可选)
int
limit
=
reqDto
.
getLimit
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
history
(
assetId
,
page
,
limit
);
//碎片id
long
shardId
=
reqDto
.
getShardId
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
history
(
assetId
,
page
,
limit
,
shardId
);
log
.
info
(
"xuper013History resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
BaseDef
.
RequestRes
requestRes
=
listPageResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-common/src/main/java/com/liquidnet/service/galaxy/biz/GalaxyBeanTransferBiz.java
View file @
48edea42
...
...
@@ -6,8 +6,11 @@ import com.liquidnet.commons.lang.util.StringUtil;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyTransferNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftTransferReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftTransferRespDto
;
import
com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo
;
import
com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftTradeVo
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
...
...
@@ -136,4 +139,50 @@ public class GalaxyBeanTransferBiz {
nftTradeVo
.
setCreatedAt
(
DateUtil
.
getNowTime
());
return
nftTradeVo
;
}
/**
* 构造nft转让信息
* @param reqDto
* @param userInfoBo
* @param receiveUserInfoBo
* @return
*/
public
GalaxyTransferNftInfoBo
buildTransferNftInfoBo
(
GalaxyNftTransferReqDto
reqDto
,
GalaxyUserInfoBo
userInfoBo
,
GalaxyUserInfoBo
receiveUserInfoBo
){
GalaxyTransferNftInfoBo
transferNftInfoBo
=
GalaxyTransferNftInfoBo
.
getNew
();
transferNftInfoBo
.
setNftId
(
reqDto
.
getNftId
());
transferNftInfoBo
.
setUserId
(
reqDto
.
getUserId
());
transferNftInfoBo
.
setAddress
(
userInfoBo
.
getBlockChainAddress
());
transferNftInfoBo
.
setReceiveUserId
(
reqDto
.
getReceiveUserId
());
transferNftInfoBo
.
setReceiveAddress
(
receiveUserInfoBo
.
getBlockChainAddress
());
transferNftInfoBo
.
setOwnerUserId
(
null
);
transferNftInfoBo
.
setOwnerAddress
(
null
);
transferNftInfoBo
.
setSeriesId
(
null
);
transferNftInfoBo
.
setRouterType
(
reqDto
.
getRouterType
());
transferNftInfoBo
.
setTransferStatus
(
GalaxyEnum
.
NftTransferStatusEnum
.
INIT
.
getCode
());
transferNftInfoBo
.
setTransferHash
(
null
);
transferNftInfoBo
.
setErrorCode
(
null
);
transferNftInfoBo
.
setErrorMsg
(
null
);
transferNftInfoBo
.
setCreatedAt
(
DateUtil
.
getNowTime
());
transferNftInfoBo
.
setUpdatedAt
(
null
);
return
transferNftInfoBo
;
}
/**
* 构造nft转让返回结果
* @param reqDto
* @param userInfoBo
* @param receiveUserInfoBo
* @return
*/
public
GalaxyNftTransferRespDto
buildNftTransferRespDto
(
GalaxyNftTransferReqDto
reqDto
,
GalaxyUserInfoBo
userInfoBo
,
GalaxyUserInfoBo
receiveUserInfoBo
,
GalaxyTransferNftInfoBo
transferNftInfoBo
){
GalaxyNftTransferRespDto
respDto
=
GalaxyNftTransferRespDto
.
getNew
();
respDto
.
setNftId
(
reqDto
.
getNftId
());
respDto
.
setOwnerUserId
(
receiveUserInfoBo
.
getUserId
());
respDto
.
setOwnerAddress
(
receiveUserInfoBo
.
getBlockChainAddress
());
respDto
.
setFromUserId
(
userInfoBo
.
getUserId
());
respDto
.
setFromAddress
(
userInfoBo
.
getBlockChainAddress
());
respDto
.
setTransferTime
(
DateUtil
.
getNowTime
());
respDto
.
setTransferHash
(
transferNftInfoBo
.
getTransferHash
());
return
respDto
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-common/src/main/java/com/liquidnet/service/galaxy/utils/AbstractDataUtils.java
View file @
48edea42
...
...
@@ -532,4 +532,52 @@ public abstract class AbstractDataUtils {
}
return
null
;
}
/**
* 创建nft转让信息
* @param routerType
* @param nftId
* @param transferNftInfoBo
*/
public
void
setGalaxyTransferNftInfoBo
(
String
routerType
,
String
nftId
,
GalaxyTransferNftInfoBo
transferNftInfoBo
)
{
this
.
getRedisUtil
().
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_TRANSFER_NFTID
.
concat
(
routerType
).
concat
(
":"
)
+
nftId
,
transferNftInfoBo
);
}
/**
* 获取nft转让信息
* @param routerType
* @param nftId
* @return
*/
public
GalaxyTransferNftInfoBo
getGalaxyTransferNftInfoBo
(
String
routerType
,
String
nftId
)
{
String
redisKey
=
GalaxyConstant
.
REDIS_KEY_GALAXY_TRANSFER_NFTID
.
concat
(
routerType
).
concat
(
":"
)
+
nftId
;
Object
obj
=
this
.
getRedisUtil
().
get
(
redisKey
);
if
(
obj
!=
null
){
return
(
GalaxyTransferNftInfoBo
)
obj
;
}
return
null
;
}
/**
* 更新nft转移信息
* @param routerType
* @param nftId
* @param transferNftInfoBo
*/
public
void
updateTransferNftInfoBo
(
String
routerType
,
String
nftId
,
GalaxyTransferNftInfoBo
transferNftInfoBo
)
{
this
.
getRedisUtil
().
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_TRANSFER_NFTID
.
concat
(
routerType
).
concat
(
":"
)
+
nftId
,
transferNftInfoBo
);
// try{
// this.getQueueUtil().sendMySqlRedis(
// SqlMapping.get("galaxy_nft_order_info.updateNftBuyInfo"),
// new Object[]{nftOrderBo.getNftBuyTaskId(),nftOrderBo.getNftBuyChainTimestamp(),nftOrderBo.getNftBuyStatus()
// ,nftOrderBo.getNftBuyTradeHash(),nftOrderBo.getNftBuyPayTaskId()
// ,LocalDateTime.now(),nftOrderBo.getNftOrderPayId()}
// , MQConst.GalaxyQueue.SQL_NFT_ORDER_INFO.getKey()
// );
// }catch(Exception e){
// log.error(e.getMessage(),e);
// log.error("#setNftTradeInfo error ==> MESSAGE:{}",e.getMessage());
// }
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/controller/GalaxyTradeController.java
View file @
48edea42
...
...
@@ -64,11 +64,6 @@ public class GalaxyTradeController {
@ApiOperation
(
value
=
"NFT发行购买结果查询"
)
@PostMapping
(
value
=
{
"nftPublishAndBuyResultQuery"
})
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
@Valid
@RequestBody
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
){
try
{
Thread
.
sleep
(
2000
l
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
galaxyTradeService
.
nftPublishAndBuyResultQuery
(
reqDto
);
}
...
...
@@ -85,11 +80,6 @@ public class GalaxyTradeController {
@ApiOperation
(
value
=
"NFT转让结果查询"
)
@PostMapping
(
value
=
{
"nftTransferResultQuery"
})
public
ResponseDto
<
GalaxyNftTransferQueryRespDto
>
nftTransferResultQuery
(
@Valid
@RequestBody
GalaxyNftTransferQueryReqDto
reqDto
){
try
{
Thread
.
sleep
(
2000
l
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
return
galaxyTradeService
.
nftTransferQuery
(
reqDto
);
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
View file @
48edea42
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.exception.constant.ErrorCode
;
import
com.liquidnet.common.third.xuper.dto.Xuper010QuerySdsReqDto
;
import
com.liquidnet.common.third.xuper.dto.Xuper010QuerySdsRespDto
;
import
com.liquidnet.common.third.xuper.dto.XuperResponseDto
;
import
com.liquidnet.common.third.xuper.constant.XuperEnum
;
import
com.liquidnet.common.third.xuper.dto.*
;
import
com.liquidnet.common.third.xuper.exception.XupterException
;
import
com.liquidnet.common.third.xuper.util.XuperSdkUtil
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
...
...
@@ -11,11 +10,14 @@ import com.liquidnet.commons.lang.util.DateUtil;
import
com.liquidnet.commons.lang.util.JsonUtils
;
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.GalaxyNftOrderBindBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyTransferNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -49,6 +51,9 @@ public class XuperTradeBiz {
@Autowired
private
XuperPublishBiz
xuperPublishBiz
;
@Autowired
private
GalaxyBeanTransferBiz
galaxyBeanTransferBiz
;
/**
* 发行和购买
* @param reqDto
...
...
@@ -174,7 +179,109 @@ public class XuperTradeBiz {
* @return
*/
public
ResponseDto
<
GalaxyNftTransferRespDto
>
nftTransfer
(
GalaxyNftTransferReqDto
reqDto
)
{
return
null
;
log
.
info
(
"nftTransfer request param:{}"
,
JsonUtils
.
toJson
(
reqDto
));
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
if
(
StringUtil
.
isNull
(
userInfoBo
)){
log
.
error
(
"开始执行 nftTransfer nft owner not exist error msg:{}"
,
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_OWNER_NOT_EXIST
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_OWNER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_OWNER_NOT_EXIST
.
getMessage
());
}
//获取用户信息
GalaxyUserInfoBo
receiveUserInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getReceiveUserId
());
if
(
StringUtil
.
isNull
(
userInfoBo
)){
log
.
error
(
"开始执行 nftTransfer nft receiver not exist error msg:{}"
,
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_RECEIVER_NOT_EXIST
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_RECEIVER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL_RECEIVER_NOT_EXIST
.
getMessage
());
}
GalaxyTransferNftInfoBo
transferNftInfoBo
=
dataUtils
.
getGalaxyTransferNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftId
());
//初始化转让信息
if
(
transferNftInfoBo
==
null
){
transferNftInfoBo
=
galaxyBeanTransferBiz
.
buildTransferNftInfoBo
(
reqDto
,
userInfoBo
,
receiveUserInfoBo
);
dataUtils
.
setGalaxyTransferNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftId
(),
transferNftInfoBo
);
}
else
{
//判断藏品当前拥有者是否匹配
if
(
transferNftInfoBo
.
getUserId
().
equalsIgnoreCase
(
reqDto
.
getUserId
())){
if
(
transferNftInfoBo
.
getTransferStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
NftTransferStatusEnum
.
PROCESSING
.
getCode
())){
//获取查询结果
return
ResponseDto
.
success
();
}
else
if
(
transferNftInfoBo
.
getTransferStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
NftTransferStatusEnum
.
SUCCESS
.
getCode
())){
GalaxyNftTransferRespDto
galaxyNftTransferRespDto
=
galaxyBeanTransferBiz
.
buildNftTransferRespDto
(
reqDto
,
userInfoBo
,
receiveUserInfoBo
,
transferNftInfoBo
);
return
ResponseDto
.
success
(
galaxyNftTransferRespDto
);
}
else
if
(
transferNftInfoBo
.
getTransferStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
NftTransferStatusEnum
.
FAIL
.
getCode
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFERING_ERROR
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFERING_ERROR
.
getMessage
());
}
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_OWNER_MATCH_ERROR
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_OWNER_MATCH_ERROR
.
getMessage
());
}
}
//资产id
Long
assetId
=
null
;
//碎片id
Long
shardId
=
null
;
//拆分nftId 格式 {assetId_shardId}
if
(
StringUtil
.
isNotEmpty
(
reqDto
.
getNftId
())){
assetId
=
Long
.
parseLong
(
reqDto
.
getNftId
().
substring
(
0
,
reqDto
.
getNftId
().
lastIndexOf
(
"_"
)));
shardId
=
Long
.
parseLong
(
reqDto
.
getNftId
().
substring
(
reqDto
.
getNftId
().
lastIndexOf
(
"_"
)+
1
,
reqDto
.
getNftId
().
length
()));
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_NFTID_FORMAT_ERROR
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_NFTID_FORMAT_ERROR
.
getMessage
());
}
//nft信息核对
if
(
StringUtil
.
isNotNull
(
assetId
)&&
StringUtil
.
isNotNull
(
shardId
)){
boolean
checkNftOwnerFlag
=
this
.
checkNftOwner
(
userInfoBo
,
reqDto
.
getNftId
(),
assetId
,
shardId
);
log
.
info
(
"nftTransfer checkNftOwnerFlag:{}"
,
checkNftOwnerFlag
);
//拥有者匹配 可以转让
if
(
checkNftOwnerFlag
){
Xuper008TransferShardReqDto
xuper008TransferShardReqDto
=
Xuper008TransferShardReqDto
.
getNew
();
// 定义返回结果对象
Xuper008TransferShardRespDto
xuper008TransferShardRespDto
=
null
;
try
{
xuper008TransferShardReqDto
.
setMnemonic
(
userInfoBo
.
getMnemonic
());
xuper008TransferShardReqDto
.
setAssetId
(
assetId
);
xuper008TransferShardReqDto
.
setShardId
(
shardId
);
xuper008TransferShardReqDto
.
setToAddr
(
xuperSdkUtil
.
getAccount
(
receiveUserInfoBo
.
getMnemonic
()).
getAddress
());
xuper008TransferShardReqDto
.
setToUserId
(
Long
.
parseLong
(
String
.
valueOf
(
receiveUserInfoBo
.
getUserId
().
hashCode
())));
xuper008TransferShardReqDto
.
setPrice
(
0
l
);
XuperResponseDto
<
Xuper008TransferShardRespDto
>
transferResponseDto
=
xuperSdkUtil
.
xuper008TransferShard
(
xuper008TransferShardReqDto
);
if
(
transferResponseDto
.
isSuccess
()){
xuper008TransferShardRespDto
=
transferResponseDto
.
getParseData
(
Xuper008TransferShardRespDto
.
class
);
if
(
String
.
valueOf
(
xuper008TransferShardRespDto
.
getErrNo
()).
equalsIgnoreCase
(
ErrorCode
.
SUCCESS
.
getCode
())){
//查询获取交易hash
String
transferHash
=
this
.
getTransferHash
(
receiveUserInfoBo
,
reqDto
.
getNftId
(),
assetId
,
shardId
);
//更新转让状态和拥有者信息(只有成功才更新拥有者信息)
transferNftInfoBo
.
setOwnerUserId
(
transferNftInfoBo
.
getReceiveUserId
());
transferNftInfoBo
.
setOwnerAddress
(
transferNftInfoBo
.
getReceiveAddress
());
transferNftInfoBo
.
setSeriesId
(
null
);
transferNftInfoBo
.
setTransferStatus
(
GalaxyEnum
.
NftTransferStatusEnum
.
SUCCESS
.
getCode
());
transferNftInfoBo
.
setTransferHash
(
transferHash
);
transferNftInfoBo
.
setErrorCode
(
null
);
transferNftInfoBo
.
setErrorMsg
(
null
);
transferNftInfoBo
.
setUpdatedAt
(
DateUtil
.
getNowTime
());
dataUtils
.
updateTransferNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftId
(),
transferNftInfoBo
);
//构造返回结果
GalaxyNftTransferRespDto
galaxyNftTransferRespDto
=
galaxyBeanTransferBiz
.
buildNftTransferRespDto
(
reqDto
,
userInfoBo
,
receiveUserInfoBo
,
transferNftInfoBo
);
return
ResponseDto
.
success
(
galaxyNftTransferRespDto
);
}
}
}
catch
(
XupterException
e
)
{
log
.
error
(
"biz error msg "
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"sys error msg "
+
e
.
getMessage
(),
e
);
}
log
.
info
(
"testXuper008TransferShard resp : "
+
JsonUtils
.
toJson
(
xuper008TransferShardRespDto
));
}
}
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL
.
getMessage
());
}
/**
...
...
@@ -183,6 +290,88 @@ public class XuperTradeBiz {
* @return
*/
public
ResponseDto
<
GalaxyNftTransferQueryRespDto
>
nftTransferQuery
(
GalaxyNftTransferQueryReqDto
reqDto
)
{
return
null
;
GalaxyTransferNftInfoBo
transferNftInfoBo
=
dataUtils
.
getGalaxyTransferNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftId
());
//初始化转让信息
if
(
transferNftInfoBo
==
null
){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_QUERY_ERROR
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_QUERY_ERROR
.
getMessage
());
}
if
(
transferNftInfoBo
.
getTransferStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
NftTransferStatusEnum
.
SUCCESS
.
getCode
())){
GalaxyNftTransferQueryRespDto
nftTransferQueryRespDto
=
GalaxyNftTransferQueryRespDto
.
getNew
();
nftTransferQueryRespDto
.
setNftId
(
transferNftInfoBo
.
getNftId
());
nftTransferQueryRespDto
.
setOwnerUserId
(
transferNftInfoBo
.
getOwnerUserId
());
nftTransferQueryRespDto
.
setOwnerAddress
(
transferNftInfoBo
.
getOwnerAddress
());
nftTransferQueryRespDto
.
setFromUserId
(
transferNftInfoBo
.
getUserId
());
nftTransferQueryRespDto
.
setFromAddress
(
transferNftInfoBo
.
getAddress
());
nftTransferQueryRespDto
.
setTransferTime
(
transferNftInfoBo
.
getCreatedAt
());
nftTransferQueryRespDto
.
setRouterType
(
transferNftInfoBo
.
getRouterType
());
nftTransferQueryRespDto
.
setTransferHash
(
transferNftInfoBo
.
getTransferHash
());
return
ResponseDto
.
success
(
nftTransferQueryRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_TRANSFER_QUERY_ERROR
.
getCode
(),
GalaxyErrorEnum
.
NFT_TRANSFER_QUERY_ERROR
.
getMessage
());
}
}
/**
* 核对nft当前拥有者是否匹配
* @param userInfoBo
* @param nftId
* @param assetId
* @param shardId
* @return
*/
private
Boolean
checkNftOwner
(
GalaxyUserInfoBo
userInfoBo
,
String
nftId
,
Long
assetId
,
Long
shardId
){
Boolean
checkNftOwner
=
false
;
//判断nftid是否状态正常
Xuper010QuerySdsReqDto
xuper010QuerySdsReqDto
=
Xuper010QuerySdsReqDto
.
getNew
();
xuper010QuerySdsReqDto
.
setAssetId
(
assetId
);
xuper010QuerySdsReqDto
.
setShardId
(
shardId
);
XuperResponseDto
<
Xuper010QuerySdsRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper010QuerySds
(
xuper010QuerySdsReqDto
);
Xuper010QuerySdsRespDto
xuper010QuerySdsRespDto
=
null
;
if
(
xuperResponseDto
.
isSuccess
()){
xuper010QuerySdsRespDto
=
xuperResponseDto
.
getParseData
(
Xuper010QuerySdsRespDto
.
class
);
Xuper010QuerySdsRespDto
.
ShardMeta
shardMeta
=
xuper010QuerySdsRespDto
.
getMeta
();
//已上链
if
(
shardMeta
.
getStatus
()
==
Integer
.
parseInt
(
XuperEnum
.
AssetGrantStatusEnum
.
GRANT_SUCCESS
.
getCode
())){
if
(
shardMeta
.
getOwnerAddr
().
equalsIgnoreCase
(
userInfoBo
.
getBlockChainAddress
())){
checkNftOwner
=
true
;
}
}
}
else
{
log
.
error
(
"nftTransfer error : nftId:{} not exits on xuper blockchain :{} "
,
nftId
,
JsonUtils
.
toJson
(
xuperResponseDto
));
}
return
checkNftOwner
;
}
/**
* 获取转让成功后的hash值
* @param userInfoBo
* @param nftId
* @param assetId
* @param shardId
* @return
*/
private
String
getTransferHash
(
GalaxyUserInfoBo
userInfoBo
,
String
nftId
,
Long
assetId
,
Long
shardId
){
String
transferHash
=
null
;
//判断nftid是否状态正常
Xuper010QuerySdsReqDto
xuper010QuerySdsReqDto
=
Xuper010QuerySdsReqDto
.
getNew
();
xuper010QuerySdsReqDto
.
setAssetId
(
assetId
);
xuper010QuerySdsReqDto
.
setShardId
(
shardId
);
XuperResponseDto
<
Xuper010QuerySdsRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper010QuerySds
(
xuper010QuerySdsReqDto
);
Xuper010QuerySdsRespDto
xuper010QuerySdsRespDto
=
null
;
if
(
xuperResponseDto
.
isSuccess
()){
xuper010QuerySdsRespDto
=
xuperResponseDto
.
getParseData
(
Xuper010QuerySdsRespDto
.
class
);
Xuper010QuerySdsRespDto
.
ShardMeta
shardMeta
=
xuper010QuerySdsRespDto
.
getMeta
();
//已上链
if
(
shardMeta
.
getStatus
()
==
Integer
.
parseInt
(
XuperEnum
.
AssetGrantStatusEnum
.
GRANT_SUCCESS
.
getCode
())){
if
(
shardMeta
.
getOwnerAddr
().
equalsIgnoreCase
(
userInfoBo
.
getBlockChainAddress
())){
transferHash
=
shardMeta
.
getTxId
();
}
}
}
else
{
log
.
error
(
"getTransferHash error : nftId:{} not exits on xuper blockchain :{} "
,
nftId
,
JsonUtils
.
toJson
(
xuperResponseDto
));
}
return
transferHash
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperTradeImpl.java
View file @
48edea42
...
...
@@ -28,9 +28,6 @@ public class GalaxyRouterStrategyXuperTradeImpl implements IGalaxyRouterStrategy
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
//测试发送队列
// queueUtil.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey(), JsonUtils.toJson(reqDto));
// return ResponseDto.success();
return
xuperTradeBiz
.
nftPublishAndBuy
(
reqDto
);
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/service/GalaxyRouterStrategyZxlTradeImpl.java
View file @
48edea42
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
zxin
.
service
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyTrade
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterTradeHandler
;
import
com.liquidnet.service.galaxy.router.zxin.biz.ZxinTradeBiz
;
import
com.liquidnet.service.galaxy.utils.QueueUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -29,17 +26,9 @@ public class GalaxyRouterStrategyZxlTradeImpl implements IGalaxyRouterStrategyTr
@Autowired
private
ZxinTradeBiz
zxinTradeBiz
;
@Autowired
private
QueueUtil
queueUtil
;
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
//测试发送队列
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
responseDto
=
zxinTradeBiz
.
nftPublishAndBuy
(
reqDto
);
if
(!
responseDto
.
isSuccess
()){
queueUtil
.
sendMsgByRedis
(
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getKey
(),
JsonUtils
.
toJson
(
reqDto
));
}
return
ResponseDto
.
success
();
return
zxinTradeBiz
.
nftPublishAndBuy
(
reqDto
);
}
@Deprecated
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/service/impl/GalaxyTradeServiceImpl.java
View file @
48edea42
package
com
.
liquidnet
.
service
.
galaxy
.
service
.
impl
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.galaxy.constant.GalaxyErrorEnum
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.router.strategy.GalaxyRouterStrategyContext
;
import
com.liquidnet.service.galaxy.service.IGalaxyTradeService
;
import
com.liquidnet.service.galaxy.utils.QueueUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,6 +24,9 @@ import org.springframework.stereotype.Service;
@Slf4j
@Service
(
"galaxyTradeServiceImpl"
)
public
class
GalaxyTradeServiceImpl
implements
IGalaxyTradeService
{
@Autowired
private
QueueUtil
queueUtil
;
@Autowired
private
GalaxyRouterStrategyContext
galaxyRouterStrategyContext
;
...
...
@@ -31,7 +38,11 @@ public class GalaxyTradeServiceImpl implements IGalaxyTradeService {
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
return
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftPublishAndBuy
(
reqDto
);
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
responseDto
=
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftPublishAndBuy
(
reqDto
);
if
(!
responseDto
.
isSuccess
()){
queueUtil
.
sendMsgByRedis
(
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getKey
(),
JsonUtils
.
toJson
(
reqDto
));
}
return
ResponseDto
.
success
();
}
@Override
...
...
@@ -59,7 +70,14 @@ public class GalaxyTradeServiceImpl implements IGalaxyTradeService {
@Override
public
ResponseDto
<
GalaxyNftTransferRespDto
>
nftTransfer
(
GalaxyNftTransferReqDto
reqDto
)
{
return
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftTransfer
(
reqDto
);
ResponseDto
<
GalaxyNftTransferRespDto
>
responseDto
=
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftTransfer
(
reqDto
);
if
(!
responseDto
.
isSuccess
()){
//系统异常允许重试,业务异常不允许重试
if
(
responseDto
.
getCode
().
equalsIgnoreCase
(
GalaxyErrorEnum
.
NFT_TRANSFER_FAIL
.
getCode
())){
queueUtil
.
sendMsgByRedis
(
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getKey
(),
JsonUtils
.
toJson
(
reqDto
));
}
}
return
ResponseDto
.
success
();
}
@Override
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/test/java/com/liquidnet/service/goblin/test/xuper/TestXuperSdkUtil.java
View file @
48edea42
package
com
.
liquidnet
.
service
.
goblin
.
test
.
xuper
;
package
com
.
liquidnet
.
common
.
third
.
xuper
;
import
com.baidu.xuper.crypto.Hash
;
import
com.liquidnet.common.third.xuper.config.XuperConfig
;
...
...
@@ -7,9 +7,7 @@ import com.liquidnet.common.third.xuper.dto.*;
import
com.liquidnet.common.third.xuper.exception.XupterException
;
import
com.liquidnet.common.third.xuper.util.XuperSdkUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.galaxy.biz.GalaxyCommonBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -19,7 +17,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.Date
;
...
...
@@ -42,12 +39,34 @@ public class TestXuperSdkUtil {
@Autowired
private
XuperSdkUtil
xuperSdkUtil
;
@Autowired
private
GalaxyCommonBiz
galaxyCommonBiz
;
private
static
String
creatorMnemonic
=
"person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe"
;
private
static
String
customerMnemonic
=
"person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe"
;
private
static
String
customerMnemonic2
=
"person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe"
;
private
static
String
customerMnemonic
=
"resemble dust palm discover lab improve fix decide blossom economy gadget fit behave win pulp mass chunk rude estate street hurdle chat labor brown"
;
//安家宾
private
static
String
customerMnemonic2
=
"soup picture whisper true follow same merit antenna glimpse animal sand kind poverty supreme cost skirt various table tunnel casual kidney rebel unable account"
;
//测试 王斐
private
static
String
customerMnemonic_wangfei
=
"echo walk term near win claim kangaroo series ecology economy cook loop million grid raise shadow yellow library pact filter rally voice begin ability"
;
private
static
String
creatorAddress
=
"YqsYxgBSP74piDhNQHTjWMH9wXnXxZbt8"
;
private
static
String
customerAddress1
=
"YGvfJh2PjgYZz3hXu7FFH9VYNfgJQ2TQv"
;
private
static
String
customerAddress2
=
"TAthqnEuqPS8ijrFG3yYxTXH4EgZQxyYF"
;
private
static
String
customerAddress_wangfei
=
"TRLTrmFX91eNZvhL3QDqHot35iKKPZHz7"
;
long
assetId
=
918386921886035729
l
;
@Test
public
void
getAccount
(){
//要拉取的区块链账户地址
String
addr
=
xuperSdkUtil
.
getAccount
(
creatorMnemonic
).
getAddress
();
System
.
out
.
println
(
"addr===="
+
addr
);
String
addr1
=
xuperSdkUtil
.
getAccount
(
customerMnemonic
).
getAddress
();
System
.
out
.
println
(
"addr1===="
+
addr1
);
String
addr2
=
xuperSdkUtil
.
getAccount
(
customerMnemonic2
).
getAddress
();
System
.
out
.
println
(
"addr2===="
+
addr2
);
String
addr_wangfei
=
xuperSdkUtil
.
getAccount
(
customerMnemonic_wangfei
).
getAddress
();
System
.
out
.
println
(
"addr_wangfei===="
+
addr_wangfei
);
}
@Test
public
void
test
(){
// byte[] byteArrays = Hash.doubleSha256("百".getBytes());
...
...
@@ -70,60 +89,6 @@ public class TestXuperSdkUtil {
int
width
=
bufferedImage
.
getWidth
();
System
.
out
.
println
(
"width=="
+
width
+
" height=="
+
height
);
}
@Test
public
void
testXuperUploadFile
(){
XuperUploadFileReqDto
reqDto
=
XuperUploadFileReqDto
.
getNew
();
// 创建区块链账户
XuperUploadFileRespDto
respDto
=
null
;
try
{
// String originalUrl = "/Users/anjiabin/Downloads/zxl_image_test_002.jpeg";
// String originalUrl = "/Users/anjiabin/Downloads/zxl_image_series_test_001.jpeg";
String
originalUrl
=
"/Users/anjiabin/Downloads/zxl_image_test_001.jpg"
;
// String originalUrl = "https://img.zhengzai.tv/other/2022/03/09/1f88d2bc6fea40e19430227326410cb3.jpg";
// String originalUrl = "/Users/anjiabin/Downloads/春季花卉TEST001.mp4";
String
imageType
=
null
;
if
(
originalUrl
.
lastIndexOf
(
"?"
)!=-
1
){
String
tempUrl
=
originalUrl
.
substring
(
0
,
originalUrl
.
lastIndexOf
(
"?"
));
imageType
=
tempUrl
.
substring
(
tempUrl
.
lastIndexOf
(
"."
),
tempUrl
.
length
());
}
else
{
imageType
=
originalUrl
.
substring
(
originalUrl
.
lastIndexOf
(
"."
),
originalUrl
.
length
());
}
// String fileName = DateUtil.getNowTime(DateUtil.DATE_SMALL_STR)+"/"+ IDGenerator.getZxlNftImageCosCode() + imageType;
String
fileName
=
IDGenerator
.
getZxlNftImageCosCode
()
+
imageType
;
//通过图片url地址上传
// File cosFile = galaxyCommonBiz.inputStreamToFile(originalUrl,fileName);
// String filePath = cosFile.getAbsolutePath();
// log.info("cosFile.getPath() :{}",cosFile.getPath());
// log.info("cosFile.getAbsoluteFile() :{}",cosFile.getAbsoluteFile());
String
filePath
=
originalUrl
;
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setFileName
(
fileName
);
reqDto
.
setFilePath
(
filePath
);
byte
[]
fileByte
=
new
byte
[
0
];
try
{
fileByte
=
galaxyCommonBiz
.
toByteArray
(
new
File
(
filePath
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
reqDto
.
setDataByte
(
fileByte
);
reqDto
.
setProperty
(
""
);
XuperResponseDto
<
XuperUploadFileRespDto
>
uploadFileResp
=
xuperSdkUtil
.
xuperUploadFile
(
reqDto
);
if
(
uploadFileResp
.
isSuccess
()){
respDto
=
uploadFileResp
.
getParseData
(
XuperUploadFileRespDto
.
class
);
}
}
catch
(
XupterException
e
)
{
log
.
error
(
"biz error msg "
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"sys error msg "
+
e
.
getMessage
(),
e
);
}
log
.
info
(
"testXuperUploadFile resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuperConfig
(){
...
...
@@ -151,7 +116,7 @@ public class TestXuperSdkUtil {
}
catch
(
Exception
e
)
{
log
.
error
(
"sys error msg "
+
e
.
getMessage
(),
e
);
}
log
.
info
(
"testXuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
log
.
info
(
"testXuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
//执行结果
// {
// "pubKeyStr": "{\"Curvname\":\"P-256\",\"X\":26900004144763996911563948656450421861897438918108431880582510031552805599402,\"Y\":94599997406045773386654355342143942267529588691485440470001050827093124326536}",
...
...
@@ -192,7 +157,7 @@ public class TestXuperSdkUtil {
Xuper002CreateAssetReqDto
reqDto
=
Xuper002CreateAssetReqDto
.
getNew
();
// 创建区块链账户
Xuper002CreateAssetRespDto
respDto
=
null
;
String
nftUrl
=
"bos_v1://xasset-offline/1103
81/ZXLNFTIMAGE20220623104221786752375
0.jpg/"
;
String
nftUrl
=
"bos_v1://xasset-offline/1103
53/ZXLNFTIMAGE20220713163813977880128
0.jpg/"
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
//资产碎片数量,小于1和大于200000代表不做库存限制
...
...
@@ -202,7 +167,7 @@ public class TestXuperSdkUtil {
//资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
reqDto
.
setAssetCate
(
Integer
.
valueOf
(
XuperEnum
.
assetTypeEnum
.
COLLECTION
.
getCode
()));
//资产名称,小于30个字节
reqDto
.
setTitle
(
"百度超级链-数字藏品-测试20220
622
-001"
);
reqDto
.
setTitle
(
"百度超级链-数字藏品-测试20220
713
-001"
);
//资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
reqDto
.
setThumb
(
nftUrl
.
concat
(
"1000_500"
));
//短文字描述,小于300个字节
...
...
@@ -293,7 +258,8 @@ public class TestXuperSdkUtil {
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
// long assetId = 171095615845019437l;
long
assetId
=
1532351545249738541
l
;
// long assetId = 1532351545249738541l;
long
assetId
=
1997357095448588049
l
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
...
...
@@ -317,7 +283,13 @@ public class TestXuperSdkUtil {
Xuper005QueryAssetReqDto
reqDto
=
Xuper005QueryAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper005QueryAssetRespDto
respDto
=
null
;
long
assetId
=
166759372822785837
l
;
//第1个
long
assetId
=
2206771595529269009
l
;
//第1个
assetId
=
15486733533687569
l
;
//第2个
assetId
=
2137832444854906641
l
;
//第3个
// long assetId = 1681769488660410129l; //生产 第1个
assetId
=
918386921886035729
l
;
//测试 第1个
try
{
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper005QueryAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper005QueryAsset
(
reqDto
);
...
...
@@ -374,13 +346,12 @@ public class TestXuperSdkUtil {
Xuper007GrantShardReqDto
reqDto
=
Xuper007GrantShardReqDto
.
getNew
();
// 定义返回结果对象
Xuper007GrantShardRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
long
assetId
=
2137832444854906641
l
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
1
l
);
reqDto
.
setShardId
(
2
l
);
reqDto
.
setToAddr
(
xuperSdkUtil
.
getAccount
(
customerMnemonic
).
getAddress
());
reqDto
.
setToUserId
(
100000
l
);
reqDto
.
setPrice
(
1234
l
);
...
...
@@ -401,15 +372,34 @@ public class TestXuperSdkUtil {
Xuper008TransferShardReqDto
reqDto
=
Xuper008TransferShardReqDto
.
getNew
();
// 定义返回结果对象
Xuper008TransferShardRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
// long assetId = 2137832444854906641l;
// assetId = 2137832444854906641l;
long
shardId
=
1
l
;
try
{
reqDto
.
setMnemonic
(
customerMnemonic
);
// reqDto.setMnemonic(customerMnemonic_wangfei);
// reqDto.setAssetId(assetId);
// reqDto.setShardId(shardId);
// reqDto.setToAddr(xuperSdkUtil.getAccount(customerMnemonic).getAddress());
// reqDto.setToUserId(100000l);
// reqDto.setPrice(1234l);
// reqDto.setMnemonic(customerMnemonic);
// reqDto.setAssetId(assetId);
// reqDto.setShardId(shardId);
// reqDto.setToAddr(xuperSdkUtil.getAccount(customerMnemonic2).getAddress());
// reqDto.setToUserId(100000l);
// reqDto.setPrice(1234l);
reqDto
.
setMnemonic
(
customerMnemonic_wangfei
);
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
1
l
);
reqDto
.
setShardId
(
4
l
);
reqDto
.
setToAddr
(
xuperSdkUtil
.
getAccount
(
customerMnemonic2
).
getAddress
());
reqDto
.
setToUserId
(
100000
l
);
reqDto
.
setPrice
(
1234
l
);
XuperResponseDto
<
Xuper008TransferShardRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper008TransferShard
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper008TransferShardRespDto
.
class
);
...
...
@@ -449,16 +439,17 @@ public class TestXuperSdkUtil {
Xuper010QuerySdsReqDto
reqDto
=
Xuper010QuerySdsReqDto
.
getNew
();
// 定义返回结果对象
Xuper010QuerySdsRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// assetId = 477060752401870637l;
assetId
=
2203931451566698285
l
;
long
shardId
=
1
l
;
// long assetId = 171095615845019437l;
// assetId = 918386921886035729l;
long
shardId
=
4
l
;
try
{
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
shardId
);
XuperResponseDto
<
Xuper010QuerySdsRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper010QuerySds
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper010QuerySdsRespDto
.
class
);
}
else
{
log
.
info
(
"testXuper010QuerySds resp error: "
+
JsonUtils
.
toJson
(
xuperResponseDto
));
}
}
catch
(
XupterException
e
)
{
log
.
error
(
"biz error msg "
+
e
.
getMessage
(),
e
);
...
...
@@ -468,12 +459,17 @@ public class TestXuperSdkUtil {
log
.
info
(
"testXuper010QuerySds resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 该接口只能查询购买人的地址 创建人不支持
*/
@Test
public
void
testXuper011ListSdsByAddr
(){
//要查询的区块链账户地址
String
addr
=
xuperConfig
.
getNftPlatformAddress
();
//xuper-userid-002
addr
=
"acsuf4Mrz9r38KERQGabsoDsa4MPEcF85"
;
addr
=
creatorAddress
;
addr
=
customerAddress1
;
addr
=
customerAddress2
;
// addr = "TRLTrmFX91eNZvhL3QDqHot35iKKPZHz7";
Xuper011ListSdsByAddrReqDto
reqDto
=
Xuper011ListSdsByAddrReqDto
.
getNew
();
// 定义返回结果对象
Xuper011ListSdsByAddrRespDto
respDto
=
null
;
...
...
@@ -481,6 +477,8 @@ public class TestXuperSdkUtil {
reqDto
.
setAddr
(
addr
);
reqDto
.
setPage
(
1
);
reqDto
.
setLimit
(
50
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper011ListSdsByAddrRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper011ListSdsByAddr
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper011ListSdsByAddrRespDto
.
class
);
...
...
@@ -499,11 +497,8 @@ public class TestXuperSdkUtil {
// 定义返回结果对象
Xuper012ListSdsByAstRespDto
respDto
=
null
;
//xuper-skuid-003
long
assetId
=
477060752401870637
l
;
//xuper-skuid-004
assetId
=
2203931451566698285
l
;
//xuper-skuid-008
assetId
=
139521326019882797
l
;
// long assetId = 477060752401870637l;
// assetId = 918386921886035729l; //测试1
try
{
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setCursor
(
""
);
...
...
@@ -525,15 +520,12 @@ public class TestXuperSdkUtil {
Xuper013HistoryReqDto
reqDto
=
Xuper013HistoryReqDto
.
getNew
();
// 定义返回结果对象
Xuper013HistoryRespDto
respDto
=
null
;
//xuper-skuid-003
long
assetId
=
477060752401870637
l
;
//xuper-skuid-004
assetId
=
2203931451566698285
l
;
//xuper-skuid-008
assetId
=
139521326019882797
l
;
// long assetId = 477060752401870637l;
// assetId = 918386921886035729l; //测试1
long
shardId
=
4
l
;
try
{
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
shardId
);
reqDto
.
setPage
(
1
);
reqDto
.
setLimit
(
20
);
XuperResponseDto
<
Xuper013HistoryRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper013History
(
reqDto
);
...
...
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