记得上下班打卡 | 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
252739a1
Commit
252739a1
authored
Jun 27, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现xuper相关功能
parent
80456f58
Changes
63
Show whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
5294 additions
and
4 deletions
+5294
-4
pom.xml
...quidnet-common-third/liquidnet-common-third-xuper/pom.xml
+65
-0
XuperCommonBiz.java
.../com/liquidnet/common/third/xuper/biz/XuperCommonBiz.java
+39
-0
XuperConfig.java
.../com/liquidnet/common/third/xuper/config/XuperConfig.java
+87
-0
XuperConstant.java
.../liquidnet/common/third/xuper/constant/XuperConstant.java
+13
-0
XuperEnum.java
.../com/liquidnet/common/third/xuper/constant/XuperEnum.java
+43
-0
XuperErrorEnum.java
...liquidnet/common/third/xuper/constant/XuperErrorEnum.java
+42
-0
Xuper000CreateAccountReqDto.java
...t/common/third/xuper/dto/Xuper000CreateAccountReqDto.java
+40
-0
Xuper000CreateAccountRespDto.java
.../common/third/xuper/dto/Xuper000CreateAccountRespDto.java
+29
-0
Xuper001GetStokenReqDto.java
...idnet/common/third/xuper/dto/Xuper001GetStokenReqDto.java
+47
-0
Xuper001GetStokenRespDto.java
...dnet/common/third/xuper/dto/Xuper001GetStokenRespDto.java
+112
-0
Xuper002CreateAssetReqDto.java
...net/common/third/xuper/dto/Xuper002CreateAssetReqDto.java
+86
-0
Xuper002CreateAssetRespDto.java
...et/common/third/xuper/dto/Xuper002CreateAssetRespDto.java
+29
-0
Xuper003AlterAssetReqDto.java
...dnet/common/third/xuper/dto/Xuper003AlterAssetReqDto.java
+88
-0
Xuper003AlterAssetRespDto.java
...net/common/third/xuper/dto/Xuper003AlterAssetRespDto.java
+28
-0
Xuper004PublishAssetReqDto.java
...et/common/third/xuper/dto/Xuper004PublishAssetReqDto.java
+33
-0
Xuper004PublishAssetRespDto.java
...t/common/third/xuper/dto/Xuper004PublishAssetRespDto.java
+21
-0
Xuper005QueryAssetReqDto.java
...dnet/common/third/xuper/dto/Xuper005QueryAssetReqDto.java
+29
-0
Xuper005QueryAssetRespDto.java
...net/common/third/xuper/dto/Xuper005QueryAssetRespDto.java
+65
-0
Xuper006ListAssetByAddrReqDto.java
...common/third/xuper/dto/Xuper006ListAssetByAddrReqDto.java
+33
-0
Xuper006ListAssetByAddrRespDto.java
...ommon/third/xuper/dto/Xuper006ListAssetByAddrRespDto.java
+31
-0
Xuper007GrantShardReqDto.java
...dnet/common/third/xuper/dto/Xuper007GrantShardReqDto.java
+49
-0
Xuper007GrantShardRespDto.java
...net/common/third/xuper/dto/Xuper007GrantShardRespDto.java
+28
-0
Xuper008TransferShardReqDto.java
...t/common/third/xuper/dto/Xuper008TransferShardReqDto.java
+49
-0
Xuper008TransferShardRespDto.java
.../common/third/xuper/dto/Xuper008TransferShardRespDto.java
+28
-0
Xuper009ConsumeReqDto.java
...quidnet/common/third/xuper/dto/Xuper009ConsumeReqDto.java
+21
-0
Xuper009ConsumeRespDto.java
...uidnet/common/third/xuper/dto/Xuper009ConsumeRespDto.java
+28
-0
Xuper010QuerySdsReqDto.java
...uidnet/common/third/xuper/dto/Xuper010QuerySdsReqDto.java
+33
-0
Xuper010QuerySdsRespDto.java
...idnet/common/third/xuper/dto/Xuper010QuerySdsRespDto.java
+30
-0
Xuper011ListSdsByAddrReqDto.java
...t/common/third/xuper/dto/Xuper011ListSdsByAddrReqDto.java
+21
-0
Xuper011ListSdsByAddrRespDto.java
.../common/third/xuper/dto/Xuper011ListSdsByAddrRespDto.java
+21
-0
Xuper012ListSdsByAstReqDto.java
...et/common/third/xuper/dto/Xuper012ListSdsByAstReqDto.java
+21
-0
Xuper012ListSdsByAstRespDto.java
...t/common/third/xuper/dto/Xuper012ListSdsByAstRespDto.java
+21
-0
Xuper013HistoryReqDto.java
...quidnet/common/third/xuper/dto/Xuper013HistoryReqDto.java
+21
-0
Xuper013HistoryRespDto.java
...uidnet/common/third/xuper/dto/Xuper013HistoryRespDto.java
+21
-0
Xuper014FreezeAssetReqDto.java
...net/common/third/xuper/dto/Xuper014FreezeAssetReqDto.java
+21
-0
Xuper014FreezeAssetRespDto.java
...et/common/third/xuper/dto/Xuper014FreezeAssetRespDto.java
+21
-0
Xuper015GetEvidenceInfoReqDto.java
...common/third/xuper/dto/Xuper015GetEvidenceInfoReqDto.java
+25
-0
Xuper015GetEvidenceInfoRespDto.java
...ommon/third/xuper/dto/Xuper015GetEvidenceInfoRespDto.java
+21
-0
XuperResponseDto.java
...om/liquidnet/common/third/xuper/dto/XuperResponseDto.java
+101
-0
XuperUploadFileReqDto.java
...quidnet/common/third/xuper/dto/XuperUploadFileReqDto.java
+35
-0
XuperUploadFileRespDto.java
...uidnet/common/third/xuper/dto/XuperUploadFileRespDto.java
+29
-0
XupterException.java
...quidnet/common/third/xuper/exception/XupterException.java
+36
-0
TestXuperChain.java
...com/liquidnet/common/third/xuper/util/TestXuperChain.java
+41
-0
XuperSdkUtil.java
...a/com/liquidnet/common/third/xuper/util/XuperSdkUtil.java
+528
-0
config.properties
...t-common-third-xuper/src/main/resources/config.properties
+21
-0
requestFilter.properties
...n-third-xuper/src/main/resources/requestFilter.properties
+4
-0
pom.xml
liquidnet-bus-common/liquidnet-common-third/pom.xml
+1
-0
pom.xml
...et-service-goblin/liquidnet-service-goblin-common/pom.xml
+12
-0
XuperTradeCommonBiz.java
.../service/galaxy/router/xuper/biz/XuperTradeCommonBiz.java
+480
-0
XuperUserCommonBiz.java
...t/service/galaxy/router/xuper/biz/XuperUserCommonBiz.java
+305
-0
GalaxyCommonBiz.java
...ava/com/liquidnet/service/galaxy/biz/GalaxyCommonBiz.java
+32
-4
XuperArtworkBiz.java
...dnet/service/galaxy/router/xuper/biz/XuperArtworkBiz.java
+556
-0
XuperPublishBiz.java
...dnet/service/galaxy/router/xuper/biz/XuperPublishBiz.java
+348
-0
XuperTradeBiz.java
...uidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
+249
-0
XuperTradeQueryBiz.java
...t/service/galaxy/router/xuper/biz/XuperTradeQueryBiz.java
+186
-0
XuperUserBiz.java
...quidnet/service/galaxy/router/xuper/biz/XuperUserBiz.java
+52
-0
GalaxyRouterStrategyXuperArtworkImpl.java
...r/xuper/service/GalaxyRouterStrategyXuperArtworkImpl.java
+48
-0
GalaxyRouterStrategyXuperPublishImpl.java
...r/xuper/service/GalaxyRouterStrategyXuperPublishImpl.java
+41
-0
GalaxyRouterStrategyXuperTradeImpl.java
...ter/xuper/service/GalaxyRouterStrategyXuperTradeImpl.java
+61
-0
GalaxyRouterStrategyXuperTradeQueryImpl.java
...uper/service/GalaxyRouterStrategyXuperTradeQueryImpl.java
+63
-0
GalaxyRouterStrategyXuperUserImpl.java
...uter/xuper/service/GalaxyRouterStrategyXuperUserImpl.java
+42
-0
GalaxyRouterStrategyZxlUserImpl.java
.../router/zxin/service/GalaxyRouterStrategyZxlUserImpl.java
+9
-0
TestXuperSdkUtil.java
...liquidnet/service/goblin/test/xuper/TestXuperSdkUtil.java
+574
-0
No files found.
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/pom.xml
0 → 100644
View file @
252739a1
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
liquidnet-common-third
</artifactId>
<groupId>
com.jlbs
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
liquidnet-common-third-xuper
</artifactId>
<properties>
<maven.compiler.source>
8
</maven.compiler.source>
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>
com.jlbs
</groupId>
<artifactId>
liquidnet-common-base
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.jlbs
</groupId>
<artifactId>
liquidnet-common-cache-redis
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>jakarta.validation</groupId>-->
<!-- <artifactId>jakarta.validation-api</artifactId>-->
<!-- </dependency>-->
<!-- 百度超级链-->
<dependency>
<groupId>
com.baidu.xuper
</groupId>
<artifactId>
xasset-sdk-java
</artifactId>
<version>
1.0.4
</version>
</dependency>
<dependency>
<groupId>
com.baidu.xuper
</groupId>
<artifactId>
xuper-java-sdk
</artifactId>
<version>
0.2.0
</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-bom
</artifactId>
<version>
4.1.59.Final
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
io.projectreactor
</groupId>
<artifactId>
reactor-bom
</artifactId>
<version>
2020.0.4
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
\ No newline at end of file
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/biz/XuperCommonBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
biz
;
import
com.baidu.xasset.auth.XchainAccount
;
import
com.baidu.xasset.client.xasset.Asset
;
import
com.baidu.xasset.common.config.Config
;
import
com.baidu.xuper.api.Account
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.util.logging.Logger
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperCommonBiz
* @Package com.liquidnet.common.third.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 17:59
*/
@Slf4j
@Component
public
class
XuperCommonBiz
{
public
Asset
getAssetApi
(){
long
appId
=
1182282645
;
String
ak
=
"3bdecf4afebd41849628389a20629ecc"
;
String
sk
=
"3f901ef12d454b9c92ba2dde7c029140"
;
Config
.
XassetCliConfig
cfg
=
new
Config
.
XassetCliConfig
();
cfg
.
setCredentials
(
appId
,
ak
,
sk
);
cfg
.
setEndPoint
(
"http://120.48.16.137:8360"
);
// 创建区块链账户
Account
acc
=
XchainAccount
.
newXchainEcdsaAccount
(
XchainAccount
.
mnemStrgthStrong
,
XchainAccount
.
mnemLangEN
);
// 初始化接口类
Asset
handle
=
new
Asset
(
cfg
,
Logger
.
getGlobal
());
return
handle
;
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/config/XuperConfig.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
config
;
import
com.baidu.xasset.auth.XchainAccount
;
import
com.baidu.xasset.client.xasset.Asset
;
import
com.baidu.xasset.common.config.Config
;
import
com.baidu.xuper.api.Account
;
import
com.liquidnet.commons.lang.util.BASE64Util
;
import
com.liquidnet.commons.lang.util.MD5Utils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
import
java.io.UnsupportedEncodingException
;
import
java.util.logging.Logger
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: Xuper配置
* @class: XuperConfig
* @Package com.liquidnet.common.third.xuper.config
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 17:42
*/
@Configuration
public
class
XuperConfig
{
@Value
(
"${liquidnet.service.galaxy.xuper.appId:110381}"
)
private
String
appId
;
@Value
(
"${liquidnet.service.galaxy.xuper.accessKeyID:f3565df21f2b84d999dd7e2817ed80ea}"
)
private
String
accessKeyID
;
@Value
(
"${liquidnet.service.galaxy.xuper.secretAccessKey:b2ee53f6bb5555ee3582198fd52552cc}"
)
private
String
secretAccessKey
;
@Value
(
"${liquidnet.service.galaxy.xuper.nftApiUrl:http://120.48.16.137:8360}"
)
private
String
nftApiUrl
;
private
Asset
asset
=
null
;
private
static
Asset
staticAsset
=
null
;
@PostConstruct
public
void
init
(){
long
_appId
=
Long
.
parseLong
(
appId
);
// String ak = accessKeyID;
// String sk = secretAccessKey;
String
ak
=
MD5Utils
.
md5
(
accessKeyID
);
String
sk
=
MD5Utils
.
md5
(
secretAccessKey
);;
Config
.
XassetCliConfig
cfg
=
new
Config
.
XassetCliConfig
();
cfg
.
setCredentials
(
_appId
,
ak
,
sk
);
cfg
.
setEndPoint
(
nftApiUrl
);
// 初始化接口类
asset
=
new
Asset
(
cfg
,
Logger
.
getGlobal
());
}
//
// static{
// long appId = 1182282645;
// String ak = "";
// String sk = "";
// String apiUrl = "http://120.48.16.137:8360";
//
// Config.XassetCliConfig cfg = new Config.XassetCliConfig();
// cfg.setCredentials(appId, ak, sk);
// cfg.setEndPoint(apiUrl);
//
// // 初始化接口类
// staticAsset = new Asset(cfg, Logger.getGlobal());
// }
public
Asset
getAsset
(){
return
this
.
asset
;
}
public
String
getAppId
()
{
return
appId
;
}
public
String
getAccessKeyID
()
{
return
accessKeyID
;
}
public
String
getSecretAccessKey
()
{
return
secretAccessKey
;
}
public
String
getNftApiUrl
()
{
return
nftApiUrl
;
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/constant/XuperConstant.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
constant
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperConstant
* @Package com.liquidnet.common.third.xuper.constant
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/22 11:49
*/
public
class
XuperConstant
{
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/constant/XuperEnum.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
constant
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperEnum
* @Package com.liquidnet.common.third.xuper.constant
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/22 11:50
*/
public
class
XuperEnum
{
/**
* 资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
*/
public
enum
assetTypeEnum
{
ARTWORK
(
"1"
,
"艺术品"
),
COLLECTION
(
"2"
,
"收藏品"
),
TICKETS
(
"3"
,
"门票"
),
HOTEL
(
"4"
,
"酒店"
);
private
String
code
;
private
String
message
;
assetTypeEnum
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
assetTypeEnum
getEnumByCode
(
String
code
){
assetTypeEnum
[]
arry
=
assetTypeEnum
.
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
;
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/constant/XuperErrorEnum.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
constant
;
import
java.util.Arrays
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperErrorEnum
* @Package com.liquidnet.common.third.xuper.constant
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/21 14:09
*/
public
enum
XuperErrorEnum
{
SECCESS
(
"0"
,
"成功"
),
FAILURE
(
"1"
,
"失败"
),
SYSTEM_ERROR
(
"SYS0010001"
,
"系统异常,请联系管理员"
),
SERVER_INNER_ERROR
(
"SYS0010002"
,
"系统内部错误"
),
SERVER_ERROR
(
"SYS0010003"
,
"服务不可用,调用后端服务失败"
),
INVALID_PARAM_ERROR
(
"XUPER0010001"
,
"参数错误"
),
GENERATE_KEYPAIR_ERROR
(
"XUPER0010002"
,
"生成公私钥错误"
),
SIGN_ERROR
(
"XUPER0010003"
,
"签名错误"
),
VERIFY_ERROR
(
"XUPER0010004"
,
"验签错误"
),
ENCRYPT_ERROR
(
"XUPER0010005"
,
"加密数据错误"
),
DECODE_ERROR
(
"XUPER0010006"
,
"解密数据错误"
),
IMAGE_CHECK_ERROR
(
"XUPER0010007"
,
"图片内容检测未通过"
),
PARAM_FORMAT_ERROR
(
"XUPER0010008"
,
"参数格式错误"
),
ORDER_NOT_FOUND_ERROR
(
"XUPER0010009"
,
"此编号未查到对应信息"
),
UPLOAD_TEMP_SECRET
(
"XUPER0010010"
,
"生成素材上传临时密钥失败"
);
private
String
code
;
private
String
msg
;
XuperErrorEnum
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
this
.
code
;
}
public
String
getMsg
()
{
return
this
.
msg
;
}
public
static
String
errorMsg
(
String
content
)
{
XuperErrorEnum
err
=
Arrays
.<
XuperErrorEnum
>
asList
(
values
()).
stream
().
filter
(
errorEnum
->
errorEnum
.
getCode
().
equals
(
content
)).
findFirst
().
orElse
(
SERVER_INNER_ERROR
);
return
err
.
getMsg
();
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper000CreateAccountReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
java.io.Serializable
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper000CreateAccountReqDto
implements
Serializable
{
/**
* 创建资产账户地址
*/
private
String
addr
;
/**
* 创建资产账户私钥签名
*/
private
String
sign
;
/**
* 创建资产账户公钥
*/
private
String
pkey
;
/**
* 随机数
*/
private
Integer
nonce
;
private
static
final
Xuper000CreateAccountReqDto
obj
=
new
Xuper000CreateAccountReqDto
();
public
static
Xuper000CreateAccountReqDto
getNew
()
{
try
{
return
(
Xuper000CreateAccountReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper000CreateAccountReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper000CreateAccountRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenRespDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper000CreateAccountRespDto
{
private
String
pubKeyStr
;
private
String
priKeyStr
;
private
String
address
;
private
String
mnemonic
;
private
static
final
Xuper000CreateAccountRespDto
obj
=
new
Xuper000CreateAccountRespDto
();
public
static
Xuper000CreateAccountRespDto
getNew
()
{
try
{
return
(
Xuper000CreateAccountRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper000CreateAccountRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper001GetStokenReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper001GetStokenReqDto
implements
Serializable
{
/**
* 助记词
*/
private
String
mnemonic
;
// /**
// * 创建资产账户地址
// */
// private String addr;
// /**
// * 创建资产账户私钥签名,内容为:msg = Sprintf(“%d”, nonce),sign = XassetSignECDSA(account, msg)
// */
// private String sign;
// /**
// * 创建资产账户公钥
// */
// private String pkey;
// /**
// * 随机数,可用sdk内置算法gen_nonce()生成
// */
// private Integer nonce;
private
static
final
Xuper001GetStokenReqDto
obj
=
new
Xuper001GetStokenReqDto
();
public
static
Xuper001GetStokenReqDto
getNew
()
{
try
{
return
(
Xuper001GetStokenReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper001GetStokenReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper001GetStokenRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenRespDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper001GetStokenRespDto
{
/**
* 后端生成,用于问题反馈,建议业务日志纪录
*/
public
long
requestId
;
/**
* 错误码 0为成功,其他可参考常用错误码
*/
public
int
errNo
;
/**
* 错误信息
*/
public
String
errMsg
;
/**
* 获取的临时授权的bos信息
*/
public
AccessInfo
accessInfo
;
@Data
public
static
class
AccessInfo
{
/**
* 存储空间
*/
@JSONField
(
name
=
"bucket"
)
public
String
bucket
;
/**
* 访问域名
*/
@JSONField
(
name
=
"endpoint"
)
public
String
endpoint
;
/**
* 文件路径
*/
@JSONField
(
name
=
"object_path"
)
public
String
objectPath
;
/**
* 访问密钥公钥
*/
@JSONField
(
name
=
"access_key_id"
)
public
String
accessKeyId
;
/**
* 访问密钥私钥
*/
@JSONField
(
name
=
"secret_access_key"
)
public
String
secretAccessKey
;
/**
* 临时有权的token,有效期为30min
*/
@JSONField
(
name
=
"session_token"
)
public
String
sessionToken
;
/**
* 鉴权生效开始时间
*/
@JSONField
(
name
=
"createTime"
)
public
LocalDateTime
createTime
;
/**
* 鉴权失效时间
*/
@JSONField
(
name
=
"expiration"
)
public
LocalDateTime
expiration
;
}
private
static
final
Xuper001GetStokenRespDto
obj
=
new
Xuper001GetStokenRespDto
();
public
static
Xuper001GetStokenRespDto
getNew
()
{
try
{
return
(
Xuper001GetStokenRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper001GetStokenRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper002CreateAssetReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 创造数字资产
* @class: Xuper002CreateAssetReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper002CreateAssetReqDto
{
/**
* 助记词
*/
private
String
mnemonic
;
/**
* 资产碎片数量,小于1和大于200000代表不做库存限制
*/
private
Integer
amount
;
/**
* 藏品显示售卖价格,单位为分
*/
private
Long
price
;
/**
* (可选)业务侧用户标记,必要时请安全处理后设置
*/
private
Long
userId
;
/**
* (可选)要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
*/
private
String
fileHash
;
/**
* 资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
*/
private
Integer
assetCate
;
/**
* 资产名称,小于30个字节
*/
private
String
title
;
/**
* 资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
*/
private
String
thumb
;
/**
* 短文字描述,小于300个字节
*/
private
String
shortDesc
;
/**
* (可选)资产详情介绍长图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
*/
private
String
imgDesc
;
/**
* 资产原始文件。比如图片,图片本身就是资产。格式bos_v1://{bucket}/{object} ,文件大小<10M。文件名采用文件md5值,为了正常展现,需要正确携带文件后缀
*/
private
String
assetUrl
;
/**
* (可选)长文字描述,小于1200个字节
*/
private
String
longDesc
;
/**
* (可选)资产额外描述信息json字符串。比如标签
*/
private
String
assetExt
;
/**
* (可选)资产组id。用于关联业务层酒店/店铺id
*/
private
Long
groupId
;
private
static
final
Xuper002CreateAssetReqDto
obj
=
new
Xuper002CreateAssetReqDto
();
public
static
Xuper002CreateAssetReqDto
getNew
()
{
try
{
return
(
Xuper002CreateAssetReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper002CreateAssetReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper002CreateAssetRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 创造数字资产
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper002CreateAssetRespDto
{
public
long
requestId
;
public
int
errNo
;
public
String
errMsg
;
public
long
assetId
;
private
static
final
Xuper002CreateAssetRespDto
obj
=
new
Xuper002CreateAssetRespDto
();
public
static
Xuper002CreateAssetRespDto
getNew
()
{
try
{
return
(
Xuper002CreateAssetRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper002CreateAssetRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper003AlterAssetReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 修改未发行的数字资产
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper003AlterAssetReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
/**
* 助记词
*/
private
String
mnemonic
;
/**
* 资产碎片数量,小于1和大于200000代表不做库存限制
*/
private
Integer
amount
;
/**
* 藏品显示售卖价格,单位为分
*/
private
Long
price
;
/**
* (可选)业务侧用户标记,必要时请安全处理后设置
*/
private
Long
userId
;
/**
* (可选)要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
*/
private
String
fileHash
;
/**
* 资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
*/
private
Integer
assetCate
;
/**
* 资产名称,小于30个字节
*/
private
String
title
;
/**
* 资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
*/
private
String
thumb
;
/**
* 短文字描述,小于300个字节
*/
private
String
shortDesc
;
/**
* (可选)资产详情介绍长图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
*/
private
String
imgDesc
;
/**
* 资产原始文件。比如图片,图片本身就是资产。格式bos_v1://{bucket}/{object} ,文件大小<10M。文件名采用文件md5值,为了正常展现,需要正确携带文件后缀
*/
private
String
assetUrl
;
/**
* (可选)长文字描述,小于1200个字节
*/
private
String
longDesc
;
/**
* (可选)资产额外描述信息json字符串。比如标签
*/
private
String
assetExt
;
/**
* (可选)资产组id。用于关联业务层酒店/店铺id
*/
private
Long
groupId
;
private
static
final
Xuper003AlterAssetReqDto
obj
=
new
Xuper003AlterAssetReqDto
();
public
static
Xuper003AlterAssetReqDto
getNew
()
{
try
{
return
(
Xuper003AlterAssetReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper003AlterAssetReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper003AlterAssetRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 修改未发行的数字资产
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper003AlterAssetRespDto
{
public
long
requestId
;
public
int
errNo
;
public
String
errMsg
;
private
static
final
Xuper003AlterAssetRespDto
obj
=
new
Xuper003AlterAssetRespDto
();
public
static
Xuper003AlterAssetRespDto
getNew
()
{
try
{
return
(
Xuper003AlterAssetRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper003AlterAssetRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper004PublishAssetReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 链上发行数字资产
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper004PublishAssetReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
/**
* 助记词
*/
private
String
mnemonic
;
private
static
final
Xuper004PublishAssetReqDto
obj
=
new
Xuper004PublishAssetReqDto
();
public
static
Xuper004PublishAssetReqDto
getNew
()
{
try
{
return
(
Xuper004PublishAssetReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper004PublishAssetReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper004PublishAssetRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 链上发行数字资产
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper004PublishAssetRespDto
{
private
static
final
Xuper004PublishAssetRespDto
obj
=
new
Xuper004PublishAssetRespDto
();
public
static
Xuper004PublishAssetRespDto
getNew
()
{
try
{
return
(
Xuper004PublishAssetRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper004PublishAssetRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper005QueryAssetReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 查询数字商品详情
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper005QueryAssetReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
private
static
final
Xuper005QueryAssetReqDto
obj
=
new
Xuper005QueryAssetReqDto
();
public
static
Xuper005QueryAssetReqDto
getNew
()
{
try
{
return
(
Xuper005QueryAssetReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper005QueryAssetReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper005QueryAssetRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
com.alibaba.fastjson.JSONArray
;
import
com.baidu.xasset.client.xasset.XassetDef
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 查询数字商品详情
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper005QueryAssetRespDto
{
private
long
requestId
;
private
int
errNo
;
private
String
errMsg
;
private
AssetMeta
meta
;
@Data
public
static
class
AssetMeta
{
private
long
assetId
;
private
int
assetCate
;
private
String
title
;
private
Thumb
[]
thumb
;
private
String
shortDesc
;
private
String
longDesc
;
private
JSONArray
imgDesc
;
private
JSONArray
assetUrl
;
private
int
amount
;
private
long
price
;
private
int
status
;
private
String
assetExt
;
private
String
createAddr
;
private
long
groupId
;
private
String
txId
;
}
@Data
public
static
class
Thumb
{
private
Urls
urls
;
private
String
width
;
private
String
height
;
}
@Data
public
static
class
Urls
{
private
String
icon
;
private
String
url1
;
private
String
url2
;
private
String
url3
;
}
private
static
final
Xuper005QueryAssetRespDto
obj
=
new
Xuper005QueryAssetRespDto
();
public
static
Xuper005QueryAssetRespDto
getNew
()
{
try
{
return
(
Xuper005QueryAssetRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper005QueryAssetRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper006ListAssetByAddrReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取账户创造资产列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper006ListAssetByAddrReqDto
{
//资产状态。0:全部 1:初试 3:发行中 4:发行成功。默认 0(可选)
private
Integer
status
=
0
;
//要拉取的区块链账户地址
private
String
addr
;
//要拉取页数,第一页为1
private
Integer
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
private
Integer
limit
=
20
;
private
static
final
Xuper006ListAssetByAddrReqDto
obj
=
new
Xuper006ListAssetByAddrReqDto
();
public
static
Xuper006ListAssetByAddrReqDto
getNew
()
{
try
{
return
(
Xuper006ListAssetByAddrReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper006ListAssetByAddrReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper006ListAssetByAddrRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
import
java.util.ArrayList
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取账户创造资产列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper006ListAssetByAddrRespDto
{
public
long
requestId
;
public
int
errNo
;
public
String
errMsg
;
public
ArrayList
list
;
public
int
totalCnt
;
private
static
final
Xuper006ListAssetByAddrRespDto
obj
=
new
Xuper006ListAssetByAddrRespDto
();
public
static
Xuper006ListAssetByAddrRespDto
getNew
()
{
try
{
return
(
Xuper006ListAssetByAddrRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper006ListAssetByAddrRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper007GrantShardReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 授予数字商品碎片
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper007GrantShardReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
/**
* 资产创建者助记词
*/
private
String
mnemonic
;
/**
* 资产碎片id,需要确保asset下唯一,可以使用有序编号,也可以使用随机整数,默认使用sdk提供GenRandId方法生成
*/
private
Long
shardId
;
/**
* 资产接收者区块链地址
*/
private
String
toAddr
;
/**
* (可选)资产接收者用户id
*/
private
Long
toUserId
;
/**
* (可选)碎片价格
*/
private
Long
price
;
private
static
final
Xuper007GrantShardReqDto
obj
=
new
Xuper007GrantShardReqDto
();
public
static
Xuper007GrantShardReqDto
getNew
()
{
try
{
return
(
Xuper007GrantShardReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper007GrantShardReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper007GrantShardRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 授予数字商品碎片
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper007GrantShardRespDto
{
private
long
requestId
;
private
int
errNo
;
private
String
errMsg
;
private
static
final
Xuper007GrantShardRespDto
obj
=
new
Xuper007GrantShardRespDto
();
public
static
Xuper007GrantShardRespDto
getNew
()
{
try
{
return
(
Xuper007GrantShardRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper007GrantShardRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper008TransferShardReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
import
org.aspectj.lang.annotation.DeclareAnnotation
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 转移资产碎片(暂不开放)
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper008TransferShardReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
/**
* 资产拥有者助记词
*/
private
String
mnemonic
;
/**
* 资产碎片id,需要确保asset下唯一,可以使用有序编号,也可以使用随机整数,默认使用sdk提供GenRandId方法生成
*/
private
Long
shardId
;
/**
* 资产接收者区块链地址
*/
private
String
toAddr
;
/**
* (可选)资产接收者用户id
*/
private
Long
toUserId
;
/**
* (可选)碎片价格
*/
private
Long
price
;
private
static
final
Xuper008TransferShardReqDto
obj
=
new
Xuper008TransferShardReqDto
();
public
static
Xuper008TransferShardReqDto
getNew
()
{
try
{
return
(
Xuper008TransferShardReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper008TransferShardReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper008TransferShardRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 转移资产碎片(暂不开放)
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper008TransferShardRespDto
{
private
long
requestId
;
private
int
errNo
;
private
String
errMsg
;
private
static
final
Xuper008TransferShardRespDto
obj
=
new
Xuper008TransferShardRespDto
();
public
static
Xuper008TransferShardRespDto
getNew
()
{
try
{
return
(
Xuper008TransferShardRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper008TransferShardRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper009ConsumeReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 碎片核销
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper009ConsumeReqDto
{
private
static
final
Xuper009ConsumeReqDto
obj
=
new
Xuper009ConsumeReqDto
();
public
static
Xuper009ConsumeReqDto
getNew
()
{
try
{
return
(
Xuper009ConsumeReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper009ConsumeReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper009ConsumeRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 碎片核销
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper009ConsumeRespDto
{
private
long
requestId
;
private
int
errNo
;
private
String
errMsg
;
private
static
final
Xuper009ConsumeRespDto
obj
=
new
Xuper009ConsumeRespDto
();
public
static
Xuper009ConsumeRespDto
getNew
()
{
try
{
return
(
Xuper009ConsumeRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper009ConsumeRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper010QuerySdsReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 查询指定资产碎片信息
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper010QuerySdsReqDto
{
/**
* 资产id
*/
private
Long
assetId
;
/**
* 碎片id
*/
private
Long
shardId
;
private
static
final
Xuper010QuerySdsReqDto
obj
=
new
Xuper010QuerySdsReqDto
();
public
static
Xuper010QuerySdsReqDto
getNew
()
{
try
{
return
(
Xuper010QuerySdsReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper010QuerySdsReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper010QuerySdsRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
com.baidu.xasset.client.xasset.XassetDef
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 查询指定资产碎片信息
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper010QuerySdsRespDto
{
public
long
requestId
;
public
int
errNo
;
public
String
errMsg
;
public
XassetDef
.
ShardMeta
meta
;
private
static
final
Xuper010QuerySdsRespDto
obj
=
new
Xuper010QuerySdsRespDto
();
public
static
Xuper010QuerySdsRespDto
getNew
()
{
try
{
return
(
Xuper010QuerySdsRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper010QuerySdsRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper011ListSdsByAddrReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 分页拉取指定账户持有碎片列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper011ListSdsByAddrReqDto
{
private
static
final
Xuper011ListSdsByAddrReqDto
obj
=
new
Xuper011ListSdsByAddrReqDto
();
public
static
Xuper011ListSdsByAddrReqDto
getNew
()
{
try
{
return
(
Xuper011ListSdsByAddrReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper011ListSdsByAddrReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper011ListSdsByAddrRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 分页拉取指定账户持有碎片列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper011ListSdsByAddrRespDto
{
private
static
final
Xuper011ListSdsByAddrRespDto
obj
=
new
Xuper011ListSdsByAddrRespDto
();
public
static
Xuper011ListSdsByAddrRespDto
getNew
()
{
try
{
return
(
Xuper011ListSdsByAddrRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper011ListSdsByAddrRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper012ListSdsByAstReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 分页拉取指定资产已授予碎片列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper012ListSdsByAstReqDto
{
private
static
final
Xuper012ListSdsByAstReqDto
obj
=
new
Xuper012ListSdsByAstReqDto
();
public
static
Xuper012ListSdsByAstReqDto
getNew
()
{
try
{
return
(
Xuper012ListSdsByAstReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper012ListSdsByAstReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper012ListSdsByAstRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 分页拉取指定资产已授予碎片列表
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper012ListSdsByAstRespDto
{
private
static
final
Xuper012ListSdsByAstRespDto
obj
=
new
Xuper012ListSdsByAstRespDto
();
public
static
Xuper012ListSdsByAstRespDto
getNew
()
{
try
{
return
(
Xuper012ListSdsByAstRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper012ListSdsByAstRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper013HistoryReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取数字商品历史登记记录
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper013HistoryReqDto
{
private
static
final
Xuper013HistoryReqDto
obj
=
new
Xuper013HistoryReqDto
();
public
static
Xuper013HistoryReqDto
getNew
()
{
try
{
return
(
Xuper013HistoryReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper013HistoryReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper013HistoryRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 拉取数字商品历史登记记录
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper013HistoryRespDto
{
private
static
final
Xuper013HistoryRespDto
obj
=
new
Xuper013HistoryRespDto
();
public
static
Xuper013HistoryRespDto
getNew
()
{
try
{
return
(
Xuper013HistoryRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper013HistoryRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper014FreezeAssetReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 冻结发行成功资产,后续授予操作将被禁止
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper014FreezeAssetReqDto
{
private
static
final
Xuper014FreezeAssetReqDto
obj
=
new
Xuper014FreezeAssetReqDto
();
public
static
Xuper014FreezeAssetReqDto
getNew
()
{
try
{
return
(
Xuper014FreezeAssetReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper014FreezeAssetReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper014FreezeAssetRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 冻结发行成功资产,后续授予操作将被禁止
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper014FreezeAssetRespDto
{
private
static
final
Xuper014FreezeAssetRespDto
obj
=
new
Xuper014FreezeAssetRespDto
();
public
static
Xuper014FreezeAssetRespDto
getNew
()
{
try
{
return
(
Xuper014FreezeAssetRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper014FreezeAssetRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper015GetEvidenceInfoReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取商品存证信息
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
Xuper015GetEvidenceInfoReqDto
{
long
assetId
;
private
static
final
Xuper015GetEvidenceInfoReqDto
obj
=
new
Xuper015GetEvidenceInfoReqDto
();
public
static
Xuper015GetEvidenceInfoReqDto
getNew
()
{
try
{
return
(
Xuper015GetEvidenceInfoReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper015GetEvidenceInfoReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/Xuper015GetEvidenceInfoRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取商品存证信息
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
public
class
Xuper015GetEvidenceInfoRespDto
{
private
static
final
Xuper015GetEvidenceInfoRespDto
obj
=
new
Xuper015GetEvidenceInfoRespDto
();
public
static
Xuper015GetEvidenceInfoRespDto
getNew
()
{
try
{
return
(
Xuper015GetEvidenceInfoRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
Xuper015GetEvidenceInfoRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/XuperResponseDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
java.io.Serializable
;
/**
* REDIRECT(-1),
* SUCCESS(0),
* FAIL(1),
* UNAUTH(2),
*/
public
class
XuperResponseDto
<
T
>
implements
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
8377276776600901982L
;
private
String
code
;
private
String
message
;
private
T
data
;
public
boolean
isSuccess
()
{
return
this
.
code
.
equals
(
"0"
);
}
private
XuperResponseDto
()
{
}
private
XuperResponseDto
(
String
code
)
{
this
.
code
=
code
;
}
private
XuperResponseDto
(
String
code
,
T
data
)
{
this
.
code
=
code
;
this
.
data
=
data
;
}
private
XuperResponseDto
(
String
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
private
XuperResponseDto
(
String
code
,
String
message
,
T
data
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
data
=
data
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
/**
* <p>Getter for the field <code>data</code>.</p>
*
* @return a T object.
*/
public
T
getData
()
{
return
data
;
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
success
()
{
return
new
XuperResponseDto
<>(
"0"
);
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
success
(
Object
data
)
{
return
new
XuperResponseDto
<>(
"0"
,
data
);
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
failure
()
{
return
new
XuperResponseDto
<>(
"1"
,
"系统繁忙,请稍后再试"
);
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
failure
(
String
message
)
{
return
new
XuperResponseDto
<>(
"1"
,
message
);
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
failure
(
String
code
,
String
message
)
{
return
new
XuperResponseDto
<>(
code
,
message
);
}
public
static
<
Object
>
XuperResponseDto
<
Object
>
failure
(
String
code
,
String
message
,
Object
data
)
{
return
new
XuperResponseDto
<>(
code
,
message
,
data
);
}
public
<
T
>
T
getParseData
(
Class
<
T
>
clazz
)
{
try
{
if
(
getData
()
!=
null
)
{
return
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
getData
()),
clazz
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
public
String
toJson
()
{
return
JsonUtils
.
toJson
(
this
);
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/XuperUploadFileReqDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenReqDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
XuperUploadFileReqDto
implements
Serializable
{
/**
* 助记词
*/
private
String
mnemonic
;
private
String
fileName
;
private
String
filePath
;
private
byte
[]
dataByte
;
private
String
property
;
private
static
final
XuperUploadFileReqDto
obj
=
new
XuperUploadFileReqDto
();
public
static
XuperUploadFileReqDto
getNew
()
{
try
{
return
(
XuperUploadFileReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
XuperUploadFileReqDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/dto/XuperUploadFileRespDto.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
dto
;
import
lombok.Data
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 获取访问BOS临时STS凭证
* @class: Xuper001GetStokenRespDto
* @Package com.liquidnet.common.third.xuper.dto
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 15:10
*/
@Data
public
class
XuperUploadFileRespDto
{
private
String
pubKeyStr
;
private
String
priKeyStr
;
private
String
address
;
private
String
mnemonic
;
private
static
final
XuperUploadFileRespDto
obj
=
new
XuperUploadFileRespDto
();
public
static
XuperUploadFileRespDto
getNew
()
{
try
{
return
(
XuperUploadFileRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
XuperUploadFileRespDto
();
}
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/exception/XupterException.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
exception
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: Xupter
* @Package com.liquidnet.common.third.xuper.exception
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/15 16:05
*/
public
class
XupterException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
-
3916918823313768482L
;
private
String
code
;
private
String
msg
;
public
XupterException
(
String
code
,
String
msg
)
{
super
(
msg
);
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
XupterException
(
String
code
,
String
msg
,
Throwable
t
)
{
super
(
msg
,
t
);
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/util/TestXuperChain.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
util
;
import
com.baidu.xasset.auth.XchainAccount
;
import
com.baidu.xasset.client.base.BaseDef.*
;
import
com.baidu.xasset.client.xasset.Asset
;
import
com.baidu.xasset.client.xasset.XassetDef.*
;
import
com.baidu.xasset.common.config.Config.*
;
import
com.baidu.xuper.api.Account
;
import
java.util.logging.Logger
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestXuperChain
* @Package com.liquidnet.common.third.xuper.util
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/4/18 13:21
*/
public
class
TestXuperChain
{
public
static
void
main
(
String
[]
args
)
{
// 配置AK/SK
long
appId
=
0
;
String
ak
=
"12121212121212121"
;
String
sk
=
"1212121212122"
;
XassetCliConfig
cfg
=
new
XassetCliConfig
();
cfg
.
setCredentials
(
appId
,
ak
,
sk
);
cfg
.
setEndPoint
(
"http://120.48.16.137:8360"
);
// 创建区块链账户
Account
acc
=
XchainAccount
.
newXchainEcdsaAccount
(
XchainAccount
.
mnemStrgthStrong
,
XchainAccount
.
mnemLangEN
);
// 初始化接口类
Asset
handle
=
new
Asset
(
cfg
,
Logger
.
getGlobal
());
// 调用方法
Resp
<
GetStokenResp
>
result
=
handle
.
getStoken
(
acc
);
System
.
out
.
println
(
result
);
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/java/com/liquidnet/common/third/xuper/util/XuperSdkUtil.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
common
.
third
.
xuper
.
util
;
import
com.baidu.xasset.auth.XchainAccount
;
import
com.baidu.xasset.client.base.BaseDef
;
import
com.baidu.xasset.client.xasset.Asset
;
import
com.baidu.xasset.client.xasset.XassetDef
;
import
com.baidu.xuper.api.Account
;
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
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperSdkUtil
* @Package com.liquidnet.common.third.xuper.util
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/15 15:50
*/
@Slf4j
@Component
public
class
XuperSdkUtil
{
@Autowired
private
XuperConfig
xuperConfig
;
private
Asset
getAsset
(){
return
xuperConfig
.
getAsset
();
}
private
Account
createAccount
(){
return
XchainAccount
.
newXchainEcdsaAccount
(
XchainAccount
.
mnemStrgthStrong
,
XchainAccount
.
mnemLangEN
);
}
public
Account
getAccount
(
String
mnemonic
){
return
XchainAccount
.
retrieveAccByMnemonic
(
mnemonic
,
XchainAccount
.
mnemLangEN
);
}
private
Account
getAccount
(){
return
null
;
}
/**
* 001获取访问BOS临时STS凭证
* @param reqDto
* @return
*/
public
XuperResponseDto
<
XuperUploadFileRespDto
>
xuperUploadFile
(
XuperUploadFileReqDto
reqDto
){
XuperUploadFileRespDto
respDto
=
XuperUploadFileRespDto
.
getNew
();
try
{
Account
account
=
this
.
getAccount
(
reqDto
.
getMnemonic
());
String
fileName
=
reqDto
.
getFileName
();
String
filePath
=
reqDto
.
getFilePath
();
byte
[]
dataByte
=
reqDto
.
getDataByte
();
String
property
=
reqDto
.
getProperty
();
XassetDef
.
UploadFile
uploadFile
=
getAsset
().
uploadFile
(
account
,
fileName
,
filePath
,
dataByte
,
property
);
log
.
info
(
"xuperUploadFile resp : "
+
JsonUtils
.
toJson
(
uploadFile
));
}
catch
(
Exception
e
){
log
.
error
(
"error msg "
+
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 000创建数字账户
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper000CreateAccountRespDto
>
xuper000CreateAccount
(
Xuper000CreateAccountReqDto
reqDto
){
Xuper000CreateAccountRespDto
respDto
=
Xuper000CreateAccountRespDto
.
getNew
();
try
{
// 创建区块链账户
Account
acc
=
this
.
createAccount
();
respDto
.
setPubKeyStr
(
acc
.
getKeyPair
().
getJSONPublicKey
());
respDto
.
setPriKeyStr
(
acc
.
getKeyPair
().
getJSONPrivateKey
());
respDto
.
setAddress
(
acc
.
getAddress
());
respDto
.
setMnemonic
(
acc
.
getMnemonic
());
log
.
info
(
"xuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 001获取访问BOS临时STS凭证
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper001GetStokenRespDto
>
xuper001GetStoken
(
Xuper001GetStokenReqDto
reqDto
){
Xuper001GetStokenRespDto
respDto
=
Xuper001GetStokenRespDto
.
getNew
();
try
{
Account
acc
=
this
.
getAccount
(
reqDto
.
getMnemonic
());
BaseDef
.
Resp
<
XassetDef
.
GetStokenResp
>
getStokenResp
=
getAsset
().
getStoken
(
acc
);
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
.
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
){
log
.
error
(
"error msg "
+
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 002创造数字资产
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper002CreateAssetRespDto
>
xuper002CreateAsset
(
Xuper002CreateAssetReqDto
reqDto
){
Xuper002CreateAssetRespDto
respDto
=
Xuper002CreateAssetRespDto
.
getNew
();
try
{
//创建资产区块链账户
Account
account
=
getAccount
(
reqDto
.
getMnemonic
());
//数字资产数量。0:无限授予碎片
long
amount
=
reqDto
.
getAmount
();
//藏品显示售卖价格,单位为分
final
long
price
=
reqDto
.
getPrice
();
//数字资产信息
int
assetCate
=
reqDto
.
getAssetCate
();
String
title
=
reqDto
.
getTitle
();
String
[]
thumb
=
{
reqDto
.
getThumb
()};
String
shortDesc
=
reqDto
.
getShortDesc
();
String
[]
imgDesc
=
{
reqDto
.
getImgDesc
()};
String
[]
assetUrl
=
{
reqDto
.
getAssetUrl
()};
String
longDesc
=
reqDto
.
getLongDesc
();
String
assetExt
=
reqDto
.
getAssetExt
();
long
groupId
=
reqDto
.
getGroupId
();
XassetDef
.
AssetInfo
assetInfo
=
new
XassetDef
.
AssetInfo
(
assetCate
,
title
,
thumb
,
shortDesc
,
imgDesc
,
assetUrl
,
longDesc
,
assetExt
,
groupId
);
//业务侧用户id(可选)
long
userId
=
reqDto
.
getUserId
();
//要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
String
fileHash
=
reqDto
.
getFileHash
();
BaseDef
.
Resp
<
XassetDef
.
CreateAssetResp
>
createAssetResp
=
getAsset
().
createAsset
(
account
,
amount
,
assetInfo
,
userId
,
price
);
BaseDef
.
RequestRes
requestRes
=
createAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
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
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 003修改未发行的数字资产
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper003AlterAssetRespDto
>
xuper003AlterAsset
(
Xuper003AlterAssetReqDto
reqDto
){
Xuper003AlterAssetRespDto
respDto
=
Xuper003AlterAssetRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
//创建资产区块链账户
Account
account
=
getAccount
(
reqDto
.
getMnemonic
());
//数字资产数量。0:无限授予碎片
long
amount
=
reqDto
.
getAmount
();
//藏品显示售卖价格,单位为分
final
long
price
=
reqDto
.
getPrice
();
//数字资产信息
int
assetCate
=
reqDto
.
getAssetCate
();
String
title
=
reqDto
.
getTitle
();
String
[]
thumb
=
{
reqDto
.
getThumb
()};
String
shortDesc
=
reqDto
.
getShortDesc
();
String
[]
imgDesc
=
{
reqDto
.
getImgDesc
()};
String
[]
assetUrl
=
{
reqDto
.
getAssetUrl
()};
String
longDesc
=
reqDto
.
getLongDesc
();
String
assetExt
=
reqDto
.
getAssetExt
();
long
groupId
=
reqDto
.
getGroupId
();
XassetDef
.
AssetInfo
assetInfo
=
new
XassetDef
.
AssetInfo
(
assetCate
,
title
,
thumb
,
shortDesc
,
imgDesc
,
assetUrl
,
longDesc
,
assetExt
,
groupId
);
//业务侧用户id(可选)
long
userId
=
reqDto
.
getUserId
();
//要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
String
fileHash
=
reqDto
.
getFileHash
();
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
alterAssetResp
=
getAsset
().
alterAsset
(
account
,
assetId
,
amount
,
assetInfo
,
price
);
BaseDef
.
RequestRes
requestRes
=
alterAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
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
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 004链上发行数字资产
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuper004PublishAsset
(
Xuper004PublishAssetReqDto
reqDto
){
Xuper004PublishAssetRespDto
respDto
=
Xuper004PublishAssetRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
//创建资产区块链账户
Account
account
=
getAccount
(
reqDto
.
getMnemonic
());
//是否存证。0:不存证 1:普通存证。默认 0(可选)
int
isEvidence
=
0
;
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
publishAssetResp
=
getAsset
().
publishAsset
(
account
,
assetId
,
isEvidence
);
log
.
info
(
"xuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
publishAssetResp
));
BaseDef
.
RequestRes
requestRes
=
publishAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper004PublishAsset apiResp : "
+
JsonUtils
.
toJson
(
publishAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
publishAssetResp
.
apiResp
),
new
TypeReference
<
Xuper004PublishAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 005查询数字商品详情
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper005QueryAssetRespDto
>
xuper005QueryAsset
(
Xuper005QueryAssetReqDto
reqDto
){
Xuper005QueryAssetRespDto
respDto
=
Xuper005QueryAssetRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
BaseDef
.
Resp
<
XassetDef
.
QueryAssetResp
>
queryAssetResp
=
getAsset
().
queryAsset
(
assetId
);
log
.
info
(
"xuper005QueryAsset resp : "
+
JsonUtils
.
toJson
(
queryAssetResp
));
BaseDef
.
RequestRes
requestRes
=
queryAssetResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper005QueryAsset apiResp : "
+
JsonUtils
.
toJson
(
queryAssetResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
queryAssetResp
.
apiResp
),
new
TypeReference
<
Xuper005QueryAssetRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 006拉取账户创造资产列表
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper006ListAssetByAddrRespDto
>
xuper006ListAssetByAddr
(
Xuper006ListAssetByAddrReqDto
reqDto
){
Xuper006ListAssetByAddrRespDto
respDto
=
Xuper006ListAssetByAddrRespDto
.
getNew
();
try
{
//资产状态。0:全部 1:初试 3:发行中 4:发行成功。默认 0(可选)
int
status
=
reqDto
.
getStatus
();
//要拉取的区块链账户地址
String
addr
=
reqDto
.
getAddr
();
//要拉取页数,第一页为1
int
page
=
reqDto
.
getPage
();
//每页拉取数量,默认20,最大50(可选)
int
limit
=
reqDto
.
getLimit
();
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
listAssetsByAddr
(
status
,
addr
,
page
,
limit
);
log
.
info
(
"xuper006ListAssetByAddr resp : "
+
JsonUtils
.
toJson
(
listPageResp
));
BaseDef
.
RequestRes
requestRes
=
listPageResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper006ListAssetByAddr apiResp : "
+
JsonUtils
.
toJson
(
listPageResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
listPageResp
.
apiResp
),
new
TypeReference
<
Xuper006ListAssetByAddrRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 007授予数字商品碎片
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper007GrantShardRespDto
>
xuper007GrantShard
(
Xuper007GrantShardReqDto
reqDto
){
Xuper007GrantShardRespDto
respDto
=
Xuper007GrantShardRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
//创建资产区块链账户
Account
account
=
getAccount
(
reqDto
.
getMnemonic
());
//碎片id
long
shardId
=
reqDto
.
getShardId
();
//资产接收者区块链地址
String
toAddr
=
reqDto
.
getToAddr
();
//资产接收者用户id(可选)
long
toUserId
=
reqDto
.
getToUserId
();
//碎片价格(可选)
long
price
=
reqDto
.
getPrice
();
BaseDef
.
Resp
<
XassetDef
.
GrantShardResp
>
grantShardResp
=
getAsset
().
grantShard
(
account
,
assetId
,
shardId
,
toAddr
,
toUserId
,
price
);
log
.
info
(
"xuper007GrantShard resp : "
+
JsonUtils
.
toJson
(
grantShardResp
));
BaseDef
.
RequestRes
requestRes
=
grantShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper007GrantShard apiResp : "
+
JsonUtils
.
toJson
(
grantShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
grantShardResp
.
apiResp
),
new
TypeReference
<
Xuper007GrantShardRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 008转移资产碎片(暂不开放)
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper008TransferShardRespDto
>
xuper008TransferShard
(
Xuper008TransferShardReqDto
reqDto
){
Xuper008TransferShardRespDto
respDto
=
Xuper008TransferShardRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
//资产拥有者区块链账户
Account
account
=
getAccount
(
reqDto
.
getMnemonic
());
//碎片id
long
shardId
=
reqDto
.
getShardId
();
//资产接收者区块链地址
String
toAddr
=
reqDto
.
getToAddr
();
//资产接收者用户id(可选)
long
toUserId
=
reqDto
.
getToUserId
();
//碎片价格(可选)
long
price
=
reqDto
.
getPrice
();
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
transferShardResp
=
getAsset
().
transferShard
(
account
,
assetId
,
shardId
,
toAddr
,
toUserId
,
price
);
log
.
info
(
"xuper008TransferShard resp : "
+
JsonUtils
.
toJson
(
transferShardResp
));
BaseDef
.
RequestRes
requestRes
=
transferShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper008TransferShard apiResp : "
+
JsonUtils
.
toJson
(
transferShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
transferShardResp
.
apiResp
),
new
TypeReference
<
Xuper008TransferShardRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 009碎片核销
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper009ConsumeRespDto
>
xuper009Consume
(
Xuper009ConsumeReqDto
reqDto
){
Xuper009ConsumeRespDto
respDto
=
Xuper009ConsumeRespDto
.
getNew
();
try
{
//资产创建者区块链账户
Account
cAccount
=
null
;
//资产碎片拥有者账户
Account
uAccount
=
null
;
//资产id
long
assetId
=
123
;
//碎片id
long
shardId
=
123
;
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
consumeShardResp
=
getAsset
().
consumeShard
(
cAccount
,
uAccount
,
assetId
,
shardId
);
log
.
info
(
"xuper009Consume resp : "
+
JsonUtils
.
toJson
(
consumeShardResp
));
BaseDef
.
RequestRes
requestRes
=
consumeShardResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper009Consume apiResp : "
+
JsonUtils
.
toJson
(
consumeShardResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
consumeShardResp
.
apiResp
),
new
TypeReference
<
Xuper009ConsumeRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 010查询指定资产碎片信息
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper010QuerySdsRespDto
>
xuper010QuerySds
(
Xuper010QuerySdsReqDto
reqDto
){
Xuper010QuerySdsRespDto
respDto
=
Xuper010QuerySdsRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
reqDto
.
getAssetId
();
//碎片id
long
shardId
=
reqDto
.
getShardId
();
BaseDef
.
Resp
<
XassetDef
.
QueryShardsResp
>
queryShardsResp
=
getAsset
().
queryShards
(
assetId
,
shardId
);
log
.
info
(
"xuper010QuerySds resp : "
+
JsonUtils
.
toJson
(
queryShardsResp
));
BaseDef
.
RequestRes
requestRes
=
queryShardsResp
.
res
;
if
(
requestRes
.
httpCode
==
200
){
log
.
info
(
"xuper010QuerySds apiResp : "
+
JsonUtils
.
toJson
(
queryShardsResp
.
apiResp
));
respDto
=
JsonUtils
.
fromJson
(
JsonUtils
.
toJson
(
queryShardsResp
.
apiResp
),
new
TypeReference
<
Xuper010QuerySdsRespDto
>(){});
}
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 011分页拉取指定账户持有碎片列表
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper011ListSdsByAddrRespDto
>
xuper011ListSdsByAddr
(
Xuper011ListSdsByAddrReqDto
reqDto
){
Xuper011ListSdsByAddrRespDto
respDto
=
Xuper011ListSdsByAddrRespDto
.
getNew
();
try
{
//要拉取的区块链账户地址
String
addr
=
""
;
//要拉取页数,第一页为1
int
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
int
limit
=
20
;
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
listShardsAddr
(
addr
,
page
,
limit
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 012分页拉取指定资产已授予碎片列表
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper012ListSdsByAstRespDto
>
xuper012ListSdsByAst
(
Xuper012ListSdsByAstReqDto
reqDto
){
Xuper012ListSdsByAstRespDto
respDto
=
Xuper012ListSdsByAstRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
123
;
//分页游标,首页设置空字符串(可选)
String
cursor
=
"123"
;
//每页拉取数量,默认20,最多50(可选)
int
limit
=
20
;
BaseDef
.
Resp
<
BaseDef
.
ListCursorResp
>
listCursorResp
=
getAsset
().
listShardsByAsset
(
assetId
,
cursor
,
limit
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 013拉取数字商品历史登记记录
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper013HistoryRespDto
>
xuper013History
(
Xuper013HistoryReqDto
reqDto
){
Xuper013HistoryRespDto
respDto
=
Xuper013HistoryRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
123
;
//要拉取页数,第一页为1
int
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
int
limit
=
20
;
BaseDef
.
Resp
<
BaseDef
.
ListPageResp
>
listPageResp
=
getAsset
().
history
(
assetId
,
page
,
limit
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 014冻结发行成功资产,后续授予操作将被禁止
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper014FreezeAssetRespDto
>
xuper014FreezeAsset
(
Xuper014FreezeAssetReqDto
reqDto
){
Xuper014FreezeAssetRespDto
respDto
=
Xuper014FreezeAssetRespDto
.
getNew
();
try
{
//创建资产区块链账户
Account
account
=
null
;
//资产id
long
assetId
=
123
;
BaseDef
.
Resp
<
BaseDef
.
BaseResp
>
baseResp
=
getAsset
().
freezeAsset
(
assetId
,
account
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
/**
* 015获取商品存证信息
* @param reqDto
* @return
*/
public
XuperResponseDto
<
Xuper015GetEvidenceInfoRespDto
>
xuper015GetEvidenceInfo
(
Xuper015GetEvidenceInfoReqDto
reqDto
){
Xuper015GetEvidenceInfoRespDto
respDto
=
Xuper015GetEvidenceInfoRespDto
.
getNew
();
try
{
//资产id
long
assetId
=
123
;
BaseDef
.
Resp
<
XassetDef
.
GetEvidenceInfoResp
>
evidenceInfoResp
=
getAsset
().
getEvidenceInfo
(
assetId
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
XupterException
(
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getCode
(),
XuperErrorEnum
.
SERVER_INNER_ERROR
.
getMsg
());
}
return
XuperResponseDto
.
success
(
respDto
);
}
}
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/resources/config.properties
0 → 100644
View file @
252739a1
# prod
host
=
https://sdk.zxinchain.com
# user learn
#host=https://testsdk.zxchain.net:9087
# test
#host=https://testsdk.zxchain.net:9086
#host=http://127.0.0.1:7082
connectTimeout
=
30000
connectionRequestTimeout
=
10000
socketTimeout
=
6000
#是否使用默认证书库(jdk)
isDefaultTrustStore
=
true
trustStore
=
/home/dev/access.keystore
trustStorePassword
=
123456
proxy
=
false
proxy.host
=
182.140.146.66
proxy.port
=
10081
xl.cert.path
=
/api/v1/spider/sdk/certificate
xl.ev.path
=
/api/v1/spider/evidence
xl.ev.query.path
=
/api/v1/spider/sdk/evidence
sdk.version
=
java-v2.0.0
\ No newline at end of file
liquidnet-bus-common/liquidnet-common-third/liquidnet-common-third-xuper/src/main/resources/requestFilter.properties
0 → 100644
View file @
252739a1
# 新增转发请求接口路由
xl.al.manager.request.fun
=
/api/v1/spider/sdk/req/forward
# 新增文件转发接口路由
xl.al.manager.file.request.fun
=
/api/v1/spider/sdk/req/file/forward
liquidnet-bus-common/liquidnet-common-third/pom.xml
View file @
252739a1
...
...
@@ -15,5 +15,6 @@
<module>
liquidnet-common-third-shumei
</module>
<module>
liquidnet-common-third-zxlnft
</module>
<module>
liquidnet-common-third-antchain
</module>
<module>
liquidnet-common-third-xuper
</module>
</modules>
</project>
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-common/pom.xml
View file @
252739a1
...
...
@@ -41,5 +41,17 @@
<artifactId>
liquidnet-service-adam-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.jlbs
</groupId>
<artifactId>
liquidnet-common-third-xuper
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
<exclusions>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-common/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperTradeCommonBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.*
;
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.GalaxySeriesNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto
;
import
com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo
;
import
com.liquidnet.service.galaxy.exception.GalaxyNftBuyException
;
import
com.liquidnet.service.galaxy.exception.GalaxyNftPublishException
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.UnsupportedEncodingException
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinTradeBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/6/27 13:08
*/
@Slf4j
@Component
public
class
XuperTradeCommonBiz
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
ZxlnftBiz
zxlnftBiz
;
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
@Autowired
private
GalaxyBeanTransferBiz
galaxyBeanTransferBiz
;
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
log
.
info
(
"开始执行nftPublishAndBuy 请求参数:{}"
,
reqDto
.
toString
());
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
if
(
StringUtil
.
isNull
(
userInfoBo
)){
log
.
error
(
"开始执行nftPublishAndBuy error msg:{}"
,
GalaxyErrorEnum
.
NFT_BUY_FAIL_USER_NOT_EXIST
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_FAIL_USER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_FAIL_USER_NOT_EXIST
.
getMessage
());
}
//获取sku信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftInfoBo
)||
StringUtil
.
isEmpty
(
seriesNftInfoBo
.
getSeriesId
())){
log
.
error
(
"开始执行nftPublishAndBuy error msg:{}"
,
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
}
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
//初始化订单数据
if
(
nftOrderBo
==
null
){
nftOrderBo
=
galaxyBeanTransferBiz
.
buildNftOrderBo
(
reqDto
.
getNftOrderPayId
(),
userInfoBo
,
seriesNftInfoBo
);
dataUtils
.
setNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
}
else
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)){
if
(
nftOrderBo
.
getNftPublishStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())
&&
nftOrderBo
.
getNftBuyStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
GalaxyNftPublishAndBuyRespDto
.
getNew
();
nftPublishAndBuyRespDto
.
setUserId
(
reqDto
.
getUserId
());
nftPublishAndBuyRespDto
.
setNftId
(
nftOrderBo
.
getNftId
());
log
.
error
(
"开始执行nftPublishAndBuy error msg:{}"
,
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
toString
());
return
ResponseDto
.
success
(
nftPublishAndBuyRespDto
);
}
if
(
nftOrderBo
.
getNftPublishStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())
&&(
nftOrderBo
.
getNftBuyStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
INIT
.
getCode
())
||
nftOrderBo
.
getNftBuyStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
()))){
//再次发起购买
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
this
.
executeBuyBusiness
(
reqDto
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
if
(
StringUtil
.
isNotNull
(
nftPublishAndBuyRespDto
)&&
StringUtil
.
isNotEmpty
(
nftPublishAndBuyRespDto
.
getNftId
())){
return
ResponseDto
.
success
(
nftPublishAndBuyRespDto
);
}
else
{
log
.
error
(
"开始执行nftPublishAndBuy-->executeBuyBusiness error msg:{}"
,
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getMessage
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getMessage
());
}
}
}
String
author
=
seriesNftInfoBo
.
getAuthor
();
String
nftName
=
seriesNftInfoBo
.
getNftName
();
String
nftUrl
=
seriesNftInfoBo
.
getNftUrl
();
String
displayUrl
=
seriesNftInfoBo
.
getDisplayUrl
();
String
nftDesc
=
seriesNftInfoBo
.
getNftDesc
();
String
nftFlag
=
seriesNftInfoBo
.
getNftFlag
();
//发行个数
Long
publishCount
=
1L
;
//开始索引
Integer
seriesBeginIndex
=
null
;
//发行金额
Long
sellCount
=
seriesNftInfoBo
.
getSellCount
().
longValue
();
//积分
/**
* 根据sku获取系列Id
*/
String
seriesId
=
seriesNftInfoBo
.
getSeriesId
();
//返回参数nftId
String
nftId
=
null
;
String
publishTaskId
=
null
;
Long
nftPublishChainTimestamp
=
null
;
Integer
nftPublishStatus
=
null
;
String
nftPublishTradeHash
=
null
;
//定义失败信息
String
failDesc
=
null
;
try
{
/**
* 获取订单和nft绑定信息
*/
GalaxyNftOrderBindBo
nftOrderBindBo
=
dataUtils
.
getGalaxyNftOrderBindBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBindBo
)){
//获取发行索引
long
nftIdNo
=
dataUtils
.
incrNftIdNo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
//如果发行数大于最大发行数量
if
(
nftIdNo
>
seriesNftInfoBo
.
getNftTotalCount
()){
//发行失败
throw
new
GalaxyNftPublishException
(
GalaxyErrorEnum
.
NFT_PUBLISH_ERROR
.
getCode
(),
"该sku:"
+
reqDto
.
getSkuId
()+
" 总共"
+
seriesNftInfoBo
.
getNftTotalCount
()+
"个NFT已经发行完毕,没有剩余库存!"
);
}
nftOrderBindBo
=
GalaxyNftOrderBindBo
.
getNew
();
nftOrderBindBo
.
setNftOrderPayId
(
reqDto
.
getNftOrderPayId
());
nftOrderBindBo
.
setSeriesId
(
seriesNftInfoBo
.
getSeriesId
());
nftOrderBindBo
.
setSeriesCode
(
seriesNftInfoBo
.
getSeriesCode
());
nftOrderBindBo
.
setNftIdIndex
(
Integer
.
valueOf
(
String
.
valueOf
(
nftIdNo
)));
nftOrderBindBo
.
setRouterType
(
reqDto
.
getRouterType
());
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
LocalDateTime
.
now
());
nftOrderBindBo
.
setCreatedAt
(
nowTimeStr
);
dataUtils
.
setGalaxyNftOrderBindBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBindBo
);
}
seriesBeginIndex
=
nftOrderBindBo
.
getNftIdIndex
();
// //查询系列信息(暂时不通过系列查询获取发行序列号)
// Nft032SeriesReqDto nft032ReqDto = Nft032SeriesReqDto.getNew();
// nft032ReqDto.setSeriesId(seriesId);
// ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(nft032ReqDto);
//
// if(resp.isSuccess()){
// //该系列已经发行多少个nft
// Long crtCount = resp.getData().getSeriesInfo().getCrtCount();
// log.info("系列:{} 已发行 :{}", seriesId, crtCount);
// //设置开始索引
// seriesBeginIndex = Integer.parseInt(String.valueOf(crtCount.longValue() + 1));
// }
/**
* 如果已经发行购买成功
*/
if
(
nftOrderBo
.
getNftPublishStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
())){
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftPublishTaskId
())){
publishTaskId
=
nftOrderBo
.
getNftPublishTaskId
();
}
}
else
if
(
nftOrderBo
.
getNftPublishStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
INIT
.
getCode
())){
//3.1.2调用NFT发行接口
/**
* 发行无限制系列
*/
Nft034PublishReqDto
nft034ReqDto
=
Nft034PublishReqDto
.
getNew
();
nft034ReqDto
.
setAuthor
(
author
);
nft034ReqDto
.
setName
(
nftName
);
nft034ReqDto
.
setUrl
(
nftUrl
);
nft034ReqDto
.
setDisplayUrl
(
displayUrl
);
nft034ReqDto
.
setDesc
(
nftDesc
);
nft034ReqDto
.
setFlag
(
nftFlag
);
nft034ReqDto
.
setPublishCount
(
publishCount
);
//无限制零系列
nft034ReqDto
.
setSeriesId
(
seriesId
);
nft034ReqDto
.
setSeriesBeginIndex
(
seriesBeginIndex
);
nft034ReqDto
.
setSellStatus
(
Integer
.
parseInt
(
ZxlnftEnum
.
SellStatusEnum
.
CAN_SELL
.
getCode
()));
nft034ReqDto
.
setSellCount
(
sellCount
);
nft034ReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
nft034ReqDto
.
setMetaData
(
seriesNftInfoBo
.
getNftHash
());
ZxlnftResponseDto
<
Nft034PublishRespDto
>
nft034RespDto
=
zxlnftSdkUtil
.
nft034Publish
(
nft034ReqDto
);
if
(
nft034RespDto
.
isSuccess
()){
publishTaskId
=
nft034RespDto
.
getData
().
getTaskId
();
nftOrderBo
.
setNftPublishTaskId
(
publishTaskId
);
}
}
if
(
StringUtil
.
isNotEmpty
(
publishTaskId
)){
try
{
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto
nft035ReqDto
=
Nft035PublishResultReqDto
.
getNew
();
nft035ReqDto
.
setTaskId
(
publishTaskId
);
int
count
=
0
;
String
nftIdBegin
=
null
;
long
timeStart
=
System
.
currentTimeMillis
();
while
(
StringUtil
.
isEmpty
(
nftIdBegin
))
{
Thread
.
sleep
(
500
l
);
count
++;
ZxlnftResponseDto
<
Nft035PublishResultRespDto
>
nft035RespDtoTemp
=
zxlnftSdkUtil
.
nft035PublishResult
(
nft035ReqDto
);
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
count
,
nft035ReqDto
.
getTaskId
());
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
()))
{
nftIdBegin
=
nft035RespDtoTemp
.
getData
().
getNftIdBegin
();
nftPublishChainTimestamp
=
nft035RespDtoTemp
.
getData
().
getChainTimestamp
();
nftPublishStatus
=
nft035RespDtoTemp
.
getData
().
getTaskStatus
();
nftPublishTradeHash
=
nft035RespDtoTemp
.
getData
().
getTxHash
();
}
else
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
()))
{
log
.
info
(
"任务执行失败!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
nftPublishStatus
=
nft035RespDtoTemp
.
getData
().
getTaskStatus
();
//发行失败
throw
new
GalaxyNftPublishException
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
"nft035PublishResult_resp:"
+
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
else
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
())){
log
.
info
(
"任务执行中!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
nftPublishStatus
=
nft035RespDtoTemp
.
getData
().
getTaskStatus
();
}
if
(
count
==
20
)
{
log
.
info
(
"=======查询共20次,跳出循环!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
break
;
}
}
//赋值返回参数
nftId
=
nftIdBegin
;
nftOrderBo
.
setNftId
(
nftId
);
log
.
info
(
"发行NFT后返回给前端nftID:{}"
,
nftIdBegin
);
log
.
info
(
"总共执行了{}次查询 总耗时:{} MS"
,
count
,
(
System
.
currentTimeMillis
()
-
timeStart
));
}
catch
(
GalaxyNftPublishException
e
){
throw
new
GalaxyNftPublishException
(
e
.
getCode
(),
e
.
getMessage
());
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
//发行失败
throw
new
GalaxyNftPublishException
(
GalaxyErrorEnum
.
NFT_PUBLISH_ERROR
.
getCode
(),
"nft035PublishResult_exception:"
+
e
.
getMessage
());
}
}
else
{
//发行失败
throw
new
GalaxyNftPublishException
(
GalaxyErrorEnum
.
NFT_PUBLISH_ERROR
.
getCode
(),
"nft034Publish_resp:taskId : "
+
publishTaskId
);
}
}
catch
(
GalaxyNftPublishException
e
)
{
failDesc
=
e
.
getMessage
();
}
catch
(
Exception
e
){
failDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
StringUtil
.
isNotEmpty
(
failDesc
)){
//记录发行异常信息
try
{
//发行异常或者失败记录任务id
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)&&
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftPublishTaskId
())){
nftOrderBo
.
setNftPublishStatus
(
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
());
nftOrderBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
//更新nft发行状态为处理中
dataUtils
.
updateNftOrderPublishInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
}
else
{
//记录错误信息
GalaxyNftOrderFailLogVo
nftOrderFailLogVo
=
galaxyBeanTransferBiz
.
buildNftOrderFailLogVo
(
GalaxyEnum
.
TradeTypeEnum
.
TRADE_PUBLISH
,
reqDto
,
GalaxyEnum
.
OrderDealWithStatusEnum
.
DATA_INIT
,
failDesc
,
null
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
dataUtils
.
setNftOrderFailLogVo
(
reqDto
.
getRouterType
(),
nftOrderFailLogVo
);
}
}
catch
(
Exception
e
){
log
.
error
(
reqDto
.
getNftOrderPayId
()+
"发行setNftOrderFailLogVo记录异常:"
+
e
.
getMessage
(),
e
);
}
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
//更新订单缓存数据状态
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftId
())){
if
(
StringUtil
.
isNotNull
(
nftPublishChainTimestamp
)){
//设置时间
String
nftPublishChainTimestampStr
=
DateUtil
.
format
(
new
Date
(
nftPublishChainTimestamp
*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
nftOrderBo
.
setNftPublishChainTimestamp
(
nftPublishChainTimestampStr
);
}
if
(
StringUtil
.
isNotNull
(
nftPublishStatus
)){
//转换任务状态
String
nftPublishStatusStr
=
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
nftPublishStatus
.
toString
()).
getCode
();
nftOrderBo
.
setNftPublishStatus
(
nftPublishStatusStr
);
}
nftOrderBo
.
setNftPublishTradeHash
(
nftPublishTradeHash
);
nftOrderBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
//先更新nft发行数据
dataUtils
.
updateNftOrderPublishInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
}
//第二步:执行购买逻辑
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftId
())){
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
this
.
executeBuyBusiness
(
reqDto
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
if
(
StringUtil
.
isNotNull
(
nftPublishAndBuyRespDto
)&&
StringUtil
.
isNotEmpty
(
nftPublishAndBuyRespDto
.
getNftId
())){
return
ResponseDto
.
success
(
nftPublishAndBuyRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getCode
(),
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getMessage
());
}
}
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
private
GalaxyNftPublishAndBuyRespDto
executeBuyBusiness
(
GalaxyNftPublishAndBuyReqDto
reqDto
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesNftInfoBo
seriesNftInfoBo
,
GalaxyNftOrderBo
nftOrderBo
){
String
buyFailDesc
=
null
;
//执行购买逻辑
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
GalaxyNftPublishAndBuyRespDto
.
getNew
();
try
{
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusinessSync
(
reqDto
.
getRouterType
(),
nftOrderBo
.
getNftId
(),
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
BeanUtil
.
copy
(
nftBuyRespDto
,
nftPublishAndBuyRespDto
);
}
catch
(
GalaxyNftBuyException
e
){
buyFailDesc
=
e
.
getMessage
();
}
catch
(
Exception
e
){
buyFailDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
StringUtil
.
isNotEmpty
(
buyFailDesc
)){
//记录购买异常信息
try
{
GalaxyNftOrderFailLogVo
nftOrderFailLogVo
=
galaxyBeanTransferBiz
.
buildNftOrderFailLogVo
(
GalaxyEnum
.
TradeTypeEnum
.
TRADE_BUY
,
reqDto
,
GalaxyEnum
.
OrderDealWithStatusEnum
.
DATA_INIT
,
buyFailDesc
,
null
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
dataUtils
.
setNftOrderFailLogVo
(
reqDto
.
getRouterType
(),
nftOrderFailLogVo
);
}
catch
(
Exception
e
){
log
.
error
(
reqDto
.
getNftOrderPayId
()+
"购买setNftOrderFailLogVo记录异常:"
+
e
.
getMessage
(),
e
);
}
}
return
nftPublishAndBuyRespDto
;
}
/**
* 保持线程循环查询
* @param nftId
* @param userInfoBo
* @param seriesNftInfoBo
* @return
*/
private
GalaxyNftBuyRespDto
nftBuyBusinessSync
(
String
routerType
,
String
nftId
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesNftInfoBo
seriesNftInfoBo
,
GalaxyNftOrderBo
nftOrderBo
){
//定义返回参数
String
nftBuyTaskId
=
null
;
Long
nftBuyChainTimestamp
=
null
;
Integer
nftBuyStatus
=
null
;
String
nftBuyTradeHash
=
null
;
String
nftBuyPayTaskId
=
null
;
//如果购买任务不为空,则直接进行购买任务查询
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftBuyTaskId
())){
nftBuyTaskId
=
nftOrderBo
.
getNftBuyTaskId
();
}
if
(
StringUtil
.
isEmpty
(
nftBuyTaskId
)){
// 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
();
}
nft043BuyReqDto
.
setPointReceiverAddr
(
zxlnftConfig
.
getNftPlatformAddress
());
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
);
ZxlnftResponseDto
<
Nft043BuyRespDto
>
nft043RespDto
=
zxlnftSdkUtil
.
nft043Buy
(
nft043BuyReqDto
);
if
(
nft043RespDto
.
isSuccess
()){
nftBuyTaskId
=
nft043RespDto
.
getData
().
getTaskId
();
nftOrderBo
.
setNftBuyTaskId
(
nftBuyTaskId
);
}
}
//如果购买任务id不为空
if
(
StringUtil
.
isNotEmpty
(
nftBuyTaskId
)){
try
{
//3.2.4查询NFT购买结果
Nft044BuyResultReqDto
nft044ReqDto
=
Nft044BuyResultReqDto
.
getNew
();
nft044ReqDto
.
setTaskId
(
nftBuyTaskId
);
long
timeStart
=
System
.
currentTimeMillis
();
int
count
=
0
;
while
(
nftBuyPayTaskId
==
null
){
Thread
.
sleep
(
500
l
);
count
++;
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
count
,
nft044ReqDto
.
getTaskId
());
ZxlnftResponseDto
<
Nft044BuyResultRespDto
>
nft044RespDto
=
zxlnftSdkUtil
.
nft044BuyResult
(
nft044ReqDto
);
if
(
nft044RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
nftBuyPayTaskId
=
nft044RespDto
.
getData
().
getPayTaskId
();
nftBuyChainTimestamp
=
nft044RespDto
.
getData
().
getChainTimestamp
();
nftBuyStatus
=
nft044RespDto
.
getData
().
getTaskStatus
();
nftBuyTradeHash
=
nft044RespDto
.
getData
().
getTxHash
();
}
else
if
(
nft044RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
())){
log
.
info
(
"任务执行失败!taskId:{}"
,
nft044ReqDto
.
getTaskId
());
nftBuyStatus
=
nft044RespDto
.
getData
().
getTaskStatus
();
//购买失败
throw
new
GalaxyNftBuyException
(
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getCode
(),
"nft044BuyResult_resp:"
+
GalaxyErrorEnum
.
NFT_BUY_FAIL
.
getMessage
());
}
else
if
(
nft044RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
())){
log
.
info
(
"任务执行中!taskId:{}"
,
nft044ReqDto
.
getTaskId
());
nftBuyStatus
=
nft044RespDto
.
getData
().
getTaskStatus
();
}
if
(
count
==
20
){
//查询超过20次,则把nftId设置为空,为后续重新入队
nftId
=
null
;
log
.
info
(
"=======查询共5次,跳出循环!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);
// }
}
catch
(
GalaxyNftBuyException
e
){
throw
new
GalaxyNftBuyException
(
e
.
getCode
(),
e
.
getMessage
());
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
//发行失败
throw
new
GalaxyNftBuyException
(
GalaxyErrorEnum
.
NFT_BUY_ERROR
.
getCode
(),
"nft044BuyResult_exception:"
+
e
.
getMessage
());
}
//更新订单缓存数据状态
if
(
StringUtil
.
isNotNull
(
nftBuyChainTimestamp
)){
//设置时间
String
nftBuyChainTimestampStr
=
DateUtil
.
format
(
new
Date
(
nftBuyChainTimestamp
*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
nftOrderBo
.
setNftBuyChainTimestamp
(
nftBuyChainTimestampStr
);
}
if
(
StringUtil
.
isNotNull
(
nftBuyStatus
)){
//转换任务状态
String
nftBuyStatusStr
=
GalaxyEnumBiz
.
getTaskStatusEnum
(
routerType
,
nftBuyStatus
.
toString
()).
getCode
();
nftOrderBo
.
setNftBuyStatus
(
nftBuyStatusStr
);
}
nftOrderBo
.
setNftBuyTradeHash
(
nftBuyTradeHash
);
nftOrderBo
.
setNftBuyPayTaskId
(
nftBuyPayTaskId
);
nftOrderBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
//先更新nft购买数据
dataUtils
.
updateNftOrderBuyInfo
(
routerType
,
nftOrderBo
.
getNftOrderPayId
(),
nftOrderBo
);
}
else
{
//购买失败
throw
new
GalaxyNftBuyException
(
GalaxyErrorEnum
.
NFT_BUY_ERROR
.
getCode
(),
"nft043Buy_resp: nftBuyTaskId:"
+
nftBuyTaskId
);
}
GalaxyNftBuyRespDto
nftBuyRespDto
=
GalaxyNftBuyRespDto
.
getNew
();
nftBuyRespDto
.
setUserId
(
userInfoBo
.
getUserId
());
nftBuyRespDto
.
setNftId
(
nftId
);
return
nftBuyRespDto
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-common/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperUserCommonBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.baidu.xuper.api.Account
;
import
com.liquidnet.common.third.xuper.dto.Xuper000CreateAccountReqDto
;
import
com.liquidnet.common.third.xuper.dto.Xuper000CreateAccountRespDto
;
import
com.liquidnet.common.third.xuper.dto.XuperResponseDto
;
import
com.liquidnet.common.third.xuper.exception.XupterException
;
import
com.liquidnet.common.third.xuper.util.XuperSdkUtil
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum
;
import
com.liquidnet.common.third.zxlnft.exception.ZxlNftException
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.adam.constant.AdamEnum
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
com.liquidnet.service.galaxy.exception.GalaxyNftUserException
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.constant.NftAccStatusEnum
;
import
com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinUserCommonBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/6/27 13:08
*/
@Slf4j
@Component
public
class
XuperUserCommonBiz
{
@Autowired
private
XuperSdkUtil
xuperSdkUtil
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
@Value
(
"${liquidnet.service.adam.url}"
)
private
String
adamUrl
;
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
long
startTime
=
System
.
currentTimeMillis
();
String
userId
=
reqDto
.
getUserId
();
String
userName
=
reqDto
.
getUserName
();
String
mobile
=
reqDto
.
getMobile
();
String
idCardType
=
reqDto
.
getIdCardType
();
String
idCard
=
reqDto
.
getIdCard
();
String
mnemonic
=
null
;
Long
index
=
0L
;
String
userIdentification
=
null
;
String
address
=
null
;
String
userPubKey
=
null
;
String
userPriKey
=
null
;
//业务失败信息
String
bizFailDesc
=
null
;
//系统失败信息
String
sysFailDesc
=
null
;
//是否实名认证成功
boolean
isRealNameAuthSuccess
=
true
;
//是否绑定区块链地址
boolean
isBindBlockAddressSuccess
=
false
;
GalaxyUserRegisterRespDto
respDto
=
GalaxyUserRegisterRespDto
.
getNew
();
//用户信息
GalaxyUserInfoBo
userInfoBo
=
null
;
try
{
/**
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
userId
);
if
(
userInfoBo
!=
null
){
mnemonic
=
userInfoBo
.
getMnemonic
();
if
(
StringUtil
.
isNotEmpty
(
userInfoBo
.
getBlockChainAddress
())){
try
{
//同步用户数字账户开通信息
boolean
isOpenAccount
=
syncOpenAccount
(
reqDto
,
respDto
.
getBlockChainAddress
(),
bizFailDesc
,
sysFailDesc
,
true
,
true
);
log
.
info
(
"用户 {} 数字账户开通结果:{}"
,
reqDto
.
getUserId
(),
isOpenAccount
);
}
catch
(
Exception
e
){
log
.
error
(
"同步用户数字账户开通信息异常:"
+
e
.
getMessage
(),
e
);
}
return
ResponseDto
.
failure
(
"已经开通过数字账户"
);
}
}
else
{
Xuper000CreateAccountReqDto
xuper000CreateAccountReqDto
=
Xuper000CreateAccountReqDto
.
getNew
();
// 创建区块链账户
Xuper000CreateAccountRespDto
xuper000CreateAccountRespDto
=
null
;
try
{
XuperResponseDto
<
Xuper000CreateAccountRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper000CreateAccount
(
xuper000CreateAccountReqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
xuper000CreateAccountRespDto
=
xuperResponseDto
.
getParseData
(
Xuper000CreateAccountRespDto
.
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
(
"testXuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
xuper000CreateAccountRespDto
));
mnemonic
=
xuper000CreateAccountRespDto
.
getMnemonic
();
}
if
(
StringUtil
.
isNotEmpty
(
mnemonic
)){
Account
account
=
xuperSdkUtil
.
getAccount
(
mnemonic
);
userPubKey
=
BASE64Util
.
encoded
(
account
.
getKeyPair
().
getJSONPublicKey
());
userPriKey
=
BASE64Util
.
encoded
(
account
.
getKeyPair
().
getJSONPrivateKey
());
userIdentification
=
account
.
getAddress
();
address
=
account
.
getAddress
();
}
if
(
StringUtil
.
isNull
(
userInfoBo
)){
//初始化用户信息
try
{
//构造缓存数据
userInfoBo
=
GalaxyUserInfoBo
.
getNew
();
userInfoBo
.
setUserId
(
userId
);
userInfoBo
.
setUserName
(
userName
);
userInfoBo
.
setMobile
(
mobile
);
userInfoBo
.
setIdCardType
(
idCardType
);
userInfoBo
.
setIdCard
(
idCard
);
userInfoBo
.
setMnemonic
(
mnemonic
);
userInfoBo
.
setIndex
(
index
.
toString
());
userInfoBo
.
setUserIdentification
(
userIdentification
);
userInfoBo
.
setUserPubKey
(
userPubKey
);
userInfoBo
.
setUserPriKey
(
userPriKey
);
userInfoBo
.
setRouterType
(
GalaxyEnum
.
RouterTypeEnum
.
ZXINCHAIN
.
getCode
());
userInfoBo
.
setBlockChainAddress
(
address
);
dataUtils
.
setGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
(),
userInfoBo
);
}
catch
(
Exception
e
){
log
.
error
(
"设置用户信息异常 msg:{}"
,
e
.
getMessage
(),
e
);
throw
new
ZxlNftException
(
ZxlErrorEnum
.
FAILURE
.
getCode
(),
"设置用户信息异常"
);
}
}
}
catch
(
GalaxyNftUserException
e
)
{
bizFailDesc
=
e
.
getMessage
();
log
.
info
(
e
.
getMessage
());
}
catch
(
ZxlNftException
e
){
sysFailDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
){
sysFailDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
//如果实名认证成功-更新数据库
if
(
isRealNameAuthSuccess
){
if
(
StringUtil
.
isNotNull
(
userInfoBo
)){
userInfoBo
.
setUserName
(
userName
);
userInfoBo
.
setMobile
(
mobile
);
userInfoBo
.
setIdCardType
(
idCardType
);
userInfoBo
.
setIdCard
(
idCard
);
userInfoBo
.
setUserIdentification
(
userIdentification
);
dataUtils
.
updateGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
(),
userInfoBo
);
}
}
try
{
//同步用户数字账户开通信息
boolean
isOpenAccount
=
syncOpenAccount
(
reqDto
,
respDto
.
getBlockChainAddress
(),
bizFailDesc
,
sysFailDesc
,
isRealNameAuthSuccess
,
isBindBlockAddressSuccess
);
log
.
info
(
"用户 {} 数字账户开通结果:{}"
,
reqDto
.
getUserId
(),
isOpenAccount
);
}
catch
(
Exception
e
){
log
.
error
(
"同步用户数字账户开通信息异常:"
+
e
.
getMessage
(),
e
);
}
long
endTime
=
System
.
currentTimeMillis
();
log
.
info
(
"开通数字账户userRegister总耗时:{} "
,
endTime
-
startTime
);
if
(
StringUtil
.
isNotEmpty
(
sysFailDesc
)){
return
ResponseDto
.
failure
(
sysFailDesc
);
}
if
(
StringUtil
.
isNotEmpty
(
bizFailDesc
)){
return
ResponseDto
.
failure
(
bizFailDesc
);
}
return
ResponseDto
.
success
(
respDto
);
}
/**
* 同步用户数字账户开通信息
* @param reqDto
* @param bizFailDesc
* @param sysFailDesc
* @param isRealNameAuthSuccess
* @param isBindBlockAddressSuccess
* @return
*/
private
boolean
syncOpenAccount
(
GalaxyUserRegisterReqDto
reqDto
,
String
blockChainAddress
,
String
bizFailDesc
,
String
sysFailDesc
,
boolean
isRealNameAuthSuccess
,
boolean
isBindBlockAddressSuccess
){
long
startTime
=
System
.
currentTimeMillis
();
long
openAccSuccessKeyExpireTime
=
3600
*
24
*
30
*
3
;
long
openAccFailKeyExpireTime
=
60
*
5
;
//是否开通数字账户
boolean
isOpenAccount
=
false
;
//开通失败错误信息
String
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
ING
.
getCode
();
String
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
ING
.
getMsg
();
//实名成功+绑定区块链地址成功
if
(
isRealNameAuthSuccess
&&
isBindBlockAddressSuccess
){
isOpenAccount
=
true
;
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
SUCCESS
.
getCode
();
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
SUCCESS
.
getMsg
();
}
//开通数字账户失败
if
(!
isOpenAccount
){
//实名失败
if
(!
isRealNameAuthSuccess
){
if
(
StringUtil
.
isNotEmpty
(
bizFailDesc
)){
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE1
.
getCode
();
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE1
.
getMsg
();
}
else
if
(
StringUtil
.
isNotEmpty
(
sysFailDesc
)){
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE2
.
getCode
();
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE2
.
getMsg
();
}
}
else
{
//地址绑定失败
if
(!
isBindBlockAddressSuccess
){
if
(
StringUtil
.
isNotEmpty
(
bizFailDesc
)){
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE3
.
getCode
();
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE3
.
getMsg
();
}
else
if
(
StringUtil
.
isNotEmpty
(
sysFailDesc
)){
resultCode
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE2
.
getCode
();
resultMessage
=
NftAccStatusEnum
.
StatusAcc
.
FAILURE2
.
getMsg
();
}
}
}
}
//更新至信链开户状态
GoblinUserNftAccInfoVo
goblinUserNftAccInfoVo
=
GoblinUserNftAccInfoVo
.
getNew
();
goblinUserNftAccInfoVo
.
setCode
(
resultCode
);
goblinUserNftAccInfoVo
.
setMsg
(
resultMessage
);
goblinUserNftAccInfoVo
.
setTime
(
LocalDateTime
.
now
());
if
(
isOpenAccount
){
//更新开户状态
dataUtils
.
getRedisUtil
().
set
(
GoblinRedisConst
.
REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO
.
concat
(
reqDto
.
getUserId
())
,
goblinUserNftAccInfoVo
);
//同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
syncUserAccountInfoToAdam
(
reqDto
);
//同步业务账号关联关系到adam
dataUtils
.
getQueueUtil
().
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_STORE
.
getKey
(),
SqlMapping
.
get
(
"adam_user_busi_acct.add"
,
reqDto
.
getUserId
(),
AdamEnum
.
BizAcct
.
NFT_ZX
.
name
(),
blockChainAddress
,
null
,
null
,
1
,
LocalDateTime
.
now
())
);
//开户成功记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils
.
getRedisUtil
().
set
(
GoblinRedisConst
.
REDIS_GOBLIN_NFT_CERTMETA
.
concat
(
reqDto
.
getIdCardType
().
concat
(
reqDto
.
getIdCard
()))
,
reqDto
.
getUserName
().
concat
(
","
).
concat
(
reqDto
.
getMobile
()),
openAccSuccessKeyExpireTime
);
}
else
{
//更新开户状态
dataUtils
.
getRedisUtil
().
set
(
GoblinRedisConst
.
REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO
.
concat
(
reqDto
.
getUserId
())
,
goblinUserNftAccInfoVo
);
}
//设置错误信息到redis
if
(
StringUtil
.
isNotEmpty
(
resultCode
)&&
resultCode
.
equalsIgnoreCase
(
NftAccStatusEnum
.
StatusAcc
.
FAILURE1
.
getCode
())){
//开户失败记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils
.
getRedisUtil
().
set
(
GoblinRedisConst
.
REDIS_GOBLIN_NFT_CERTMETA_JUNK
.
concat
(
reqDto
.
getIdCardType
().
concat
(
reqDto
.
getIdCard
()))
,
reqDto
.
getUserName
().
concat
(
","
).
concat
(
reqDto
.
getMobile
()),
openAccFailKeyExpireTime
);
}
long
endTime
=
System
.
currentTimeMillis
();
log
.
info
(
"同步数字账户syncOpenAccount总耗时:{} "
,
endTime
-
startTime
);
return
isOpenAccount
;
}
/**
* 同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
* @param reqDto
* @return
*/
private
boolean
syncUserAccountInfoToAdam
(
GalaxyUserRegisterReqDto
reqDto
)
{
try
{
String
certmetaInfo
=
reqDto
.
getUserId
().
concat
(
","
)
.
concat
(
reqDto
.
getMobile
()).
concat
(
","
)
.
concat
(
reqDto
.
getIdCardType
().
concat
(
reqDto
.
getIdCard
())).
concat
(
","
)
.
concat
(
reqDto
.
getUserName
());
//加密用户信息
DESUtils
desUtils
=
DESUtils
.
DES
();
// MultiValueMap<String, String> params = new LinkedMultiValueMap();
// params.add("certmeta",desUtils.encrypt(certmetaInfo));
//
// HttpUtil.post(adamUrl + GalaxyConstant.ADAM_USER_SYNC_URL, params);
HttpUtil
.
postJson
(
adamUrl
+
GalaxyConstant
.
ADAM_USER_SYNC_URL
,
desUtils
.
encrypt
(
certmetaInfo
));
}
catch
(
Exception
e
)
{
log
.
error
(
"同步用户信息到adam异常:{}"
,
JsonUtils
.
toJson
(
reqDto
),
e
);
return
false
;
}
return
true
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/biz/GalaxyCommonBiz.java
View file @
252739a1
...
...
@@ -4,10 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
...
...
@@ -66,4 +63,35 @@ public class GalaxyCommonBiz {
return
null
;
}
}
/*读取文件的字节数组*/
public
static
byte
[]
toByteArray
(
File
file
)
throws
IOException
{
File
f
=
file
;
if
(!
f
.
exists
())
{
throw
new
FileNotFoundException
(
"file not exists"
);
}
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
((
int
)
f
.
length
());
BufferedInputStream
in
=
null
;
try
{
in
=
new
BufferedInputStream
(
new
FileInputStream
(
f
));
int
buf_size
=
1024
;
byte
[]
buffer
=
new
byte
[
buf_size
];
int
len
=
0
;
while
(-
1
!=
(
len
=
in
.
read
(
buffer
,
0
,
buf_size
)))
{
bos
.
write
(
buffer
,
0
,
len
);
}
return
bos
.
toByteArray
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
e
;
}
finally
{
try
{
in
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
bos
.
close
();
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperArtworkBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.UploadToCosReq
;
import
com.liquidnet.common.third.zxlnft.dto.wallet.UploadToCosResp
;
import
com.liquidnet.common.third.zxlnft.exception.ZxlNftException
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.biz.GalaxyCommonBiz
;
import
com.liquidnet.service.galaxy.biz.GalaxyEnumBiz
;
import
com.liquidnet.service.galaxy.constant.GalaxyConstant
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.constant.GalaxyErrorEnum
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftUploadBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftUploadTempSecretBo
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperArtworkBiz
* @Package com.liquidnet.service.galaxy.router.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:10
*/
@Slf4j
@Component
public
class
XuperArtworkBiz
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
ZxlWalletSdkUtil
zxlWalletSdkUtil
;
@Autowired
private
ZxlnftBiz
zxlnftBiz
;
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
@Autowired
private
GalaxyCommonBiz
galaxyCommonBiz
;
public
ResponseDto
<
GalaxyNftImageRespDto
>
nftImageCheck
(
GalaxyNftImageReqDto
reqDto
)
{
Nft008QueryImageModerationReqDto
nft008ReqDto
=
Nft008QueryImageModerationReqDto
.
getNew
();
nft008ReqDto
.
setImageUrl
(
reqDto
.
getNftOriginalUrl
());
ZxlnftResponseDto
<
Nft008QueryImageModerationRespDto
>
nft008RespDto
=
zxlnftSdkUtil
.
nft008QueryImageModeration
(
nft008ReqDto
);
if
(!
nft008RespDto
.
isSuccess
()){
throw
new
ZxlNftException
(
ZxlErrorEnum
.
IMAGE_CHECK_ERROR
.
getCode
(),
ZxlErrorEnum
.
IMAGE_CHECK_ERROR
.
getMsg
());
}
GalaxyNftImageRespDto
nftImageRespDto
=
GalaxyNftImageRespDto
.
getNew
();
BeanUtil
.
copy
(
nft008RespDto
.
getData
(),
nftImageRespDto
);
return
ResponseDto
.
success
(
nftImageRespDto
);
}
public
ResponseDto
<
GalaxyNftUploadRespDto
>
nftUpload
(
GalaxyNftUploadReqDto
reqDto
)
{
/**
* 系列缓存初始化
*/
//获取任务ID
GalaxySeriesNftUploadBo
seriesNftUploadBo
=
dataUtils
.
getSeriesNftUploadBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNotNull
(
seriesNftUploadBo
)){
return
ResponseDto
.
failure
(
"素材已经上传过!"
);
}
String
originalNftUrl
=
reqDto
.
getOriginalNftUrl
();
String
originalDisplayUrl
=
reqDto
.
getOriginalDisplayUrl
();
//上传系列名只用来目录区分
String
seriesName
=
GalaxyConstant
.
SERIES_NAME_PREFIX
+
reqDto
.
getSkuId
();
//素材存储目录
//返回素材上传结果
GalaxyNftUploadRespDto
galaxyNftUploadRespDto
=
GalaxyNftUploadRespDto
.
getNew
();
try
{
galaxyNftUploadRespDto
.
setSkuId
(
reqDto
.
getSkuId
());
galaxyNftUploadRespDto
.
setNftUrl
(
this
.
getFullFilePath
(
seriesName
,
originalNftUrl
));
galaxyNftUploadRespDto
.
setOriginalNftUrl
(
reqDto
.
getOriginalNftUrl
());
galaxyNftUploadRespDto
.
setDisplayUrl
(
this
.
getFullFilePath
(
seriesName
,
originalDisplayUrl
));
galaxyNftUploadRespDto
.
setOriginalDisplayUrl
(
reqDto
.
getOriginalDisplayUrl
());
}
catch
(
ZxlNftException
e
){
log
.
error
(
e
.
getMessage
());
return
ResponseDto
.
failure
(
e
.
getCode
(),
e
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
seriesNftUploadBo
=
GalaxySeriesNftUploadBo
.
getNew
();
seriesNftUploadBo
.
setSkuId
(
reqDto
.
getSkuId
());
seriesNftUploadBo
.
setOriginalNftUrl
(
originalNftUrl
);
seriesNftUploadBo
.
setOriginalDisplayUrl
(
originalDisplayUrl
);
seriesNftUploadBo
.
setNftUrl
(
galaxyNftUploadRespDto
.
getNftUrl
());
seriesNftUploadBo
.
setDisplayUrl
(
galaxyNftUploadRespDto
.
getDisplayUrl
());
dataUtils
.
setSeriesNftUploadBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
(),
seriesNftUploadBo
);
return
ResponseDto
.
success
(
galaxyNftUploadRespDto
);
// 1.4.4调用查询素材地址接口 -- 非必需
// Nft021UploadUrlReqDto nft021ReqDto = Nft021UploadUrlReqDto.getNew();
// nft021ReqDto.setSeriesName(seriesName);
// nft021ReqDto.setPlatformIdentification(zxlnftConfig.getPlatformIdentification());
// //如果上传人就是平台管理员,以下需要注释掉,因为会导致返回的地址多了一级目录
//// nft021ReqDto.setUserIdentification(zxlnftConfig.getPlatformIdentification());
// ZxlnftResponseDto<Nft021UploadUrlRespDto> resp = zxlnftSdkUtil.nft021UploadUrl(nft021ReqDto);
}
public
ResponseDto
<
GalaxyArtSeriesClaimRespDto
>
seriesClaim
(
GalaxyArtSeriesClaimReqDto
reqDto
)
{
//系列声明用到参数
String
skuId
=
reqDto
.
getSkuId
();
//以下系列名称可以用spu名称代替
String
seriesName
=
GalaxyConstant
.
SERIES_NAME_PREFIX
.
concat
(
skuId
);
String
seriesCode
=
GalaxyConstant
.
SERIES_NAME_PREFIX
.
concat
(
skuId
);
Long
totalCount
=
reqDto
.
getTotalCount
();
String
coverUrl
=
reqDto
.
getCoverUrl
();
//暂时用nftUrl
String
seriesDesc
=
reqDto
.
getSeriesDesc
();
//发行用到的相关信息
// String author = reqDto.getAuthor();
// String nftName = reqDto.getNftName();
// String nftUrl = reqDto.getNftUrl();
// String displayUrl = reqDto.getDisplayUrl();
// String nftDesc = reqDto.getNftDesc();
// String nftFlag = reqDto.getNftFlag();
// String sellCount = reqDto.getSellCount();
//根据skuId获取原始上传信息
GalaxySeriesNftUploadBo
seriesNftUploadBo
=
dataUtils
.
getSeriesNftUploadBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftUploadBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_NOT_EXIST
.
getMessage
());
}
//目前一个系列上传一个nft
GalaxySeriesInfoBo
seriesInfoBo
=
dataUtils
.
getSeriesInfoBo
(
reqDto
.
getRouterType
(),
seriesCode
);
if
(
StringUtil
.
isNotNull
(
seriesInfoBo
)){
/**
* 如果系列声明成功,则不允许继续声明
*/
if
(
seriesInfoBo
.
getSeriesClaimStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
PROCESSING
.
getCode
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_PROCESSING
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_PROCESSING
.
getMessage
());
}
else
if
(
seriesInfoBo
.
getSeriesClaimStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
SUCCESS
.
getCode
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_SUCCESSED
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_SUCCESSED
.
getMessage
());
}
}
//业务失败信息
String
bizFailDesc
=
null
;
//系统失败信息
String
sysFailDesc
=
null
;
GalaxyArtSeriesClaimRespDto
seriesClaimRespDto
=
null
;
try
{
/**
* 进行系列声明
*/
Nft030SeriesClaimReqDto
nft030ReqDto
=
Nft030SeriesClaimReqDto
.
getNew
();
nft030ReqDto
.
setPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
nft030ReqDto
.
setSeriesName
(
seriesName
);
//无限制系列 设置为0
nft030ReqDto
.
setTotalCount
(
totalCount
);
nft030ReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
//系列封面
nft030ReqDto
.
setCoverUrl
(
coverUrl
);
nft030ReqDto
.
setDesc
(
seriesDesc
);
nft030ReqDto
.
setMaxPublishCount
(
0
);
nft030ReqDto
.
setSeriesBeginFromZero
(
false
);
ZxlnftResponseDto
<
Nft030SeriesClaimRespDto
>
nft30RespDto
=
zxlnftSdkUtil
.
nft030SeriesClaim
(
nft030ReqDto
);
//返回参数
String
seriesId
=
null
;
String
taskId
=
null
;
seriesClaimRespDto
=
GalaxyArtSeriesClaimRespDto
.
getNew
();
if
(
nft30RespDto
.
isSuccess
()){
//第零个系列 无限制系列
taskId
=
nft30RespDto
.
getData
().
getTaskId
();
//构造缓存数据
if
(
StringUtil
.
isNull
(
seriesInfoBo
)){
//
String
publishStatus
=
GalaxyEnum
.
SeriesClaimStatusEnum
.
PROCESSING
.
getCode
();
//设置系列声明状态
seriesClaimRespDto
.
setSeriesClaimStatus
(
publishStatus
);
//构造系列信息
seriesInfoBo
=
this
.
buildSeriesInfoBo
(
reqDto
,
taskId
,
publishStatus
);
//等一个系列支持多个藏品后需要从请求参数获取
seriesInfoBo
.
setSeriesName
(
seriesName
);
seriesInfoBo
.
setSeriesCode
(
seriesCode
);
dataUtils
.
setSeriesInfoBo
(
reqDto
.
getRouterType
(),
seriesCode
,
seriesInfoBo
);
//构造系列nft信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
this
.
buildSeriesNftInfoBo
(
reqDto
,
seriesInfoBo
,
seriesNftUploadBo
);
dataUtils
.
setSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
(),
seriesInfoBo
,
seriesNftInfoBo
);
if
(
StringUtil
.
isEmpty
(
seriesNftInfoBo
.
getNftHash
())){
log
.
error
(
"生成nftHash error skuId:{} nftUrl is :{} "
,
seriesNftInfoBo
.
getSkuId
(),
seriesNftInfoBo
.
getNftUrl
());
throw
new
ZxlNftException
(
GalaxyErrorEnum
.
SERIES_NFT_HASH_CREATE_FAIL
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_HASH_CREATE_FAIL
.
getMessage
());
}
}
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getMessage
());
}
seriesClaimRespDto
.
setSkuId
(
skuId
);
seriesClaimRespDto
.
setNftUrl
(
seriesNftUploadBo
.
getNftUrl
());
seriesClaimRespDto
.
setDisplayUrl
(
seriesNftUploadBo
.
getDisplayUrl
());
seriesClaimRespDto
.
setSeriesId
(
seriesId
);
seriesClaimRespDto
.
setSeriesName
(
seriesName
);
}
catch
(
ZxlNftException
e
){
sysFailDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
){
sysFailDesc
=
e
.
getMessage
();
log
.
error
(
e
.
getMessage
(),
e
);
}
if
(
StringUtil
.
isNotEmpty
(
sysFailDesc
)){
return
ResponseDto
.
failure
(
sysFailDesc
);
}
if
(
StringUtil
.
isNotEmpty
(
bizFailDesc
)){
return
ResponseDto
.
failure
(
bizFailDesc
);
}
return
ResponseDto
.
success
(
seriesClaimRespDto
);
}
public
ResponseDto
<
GalaxyArtSeriesClaimRespDto
>
seriesClaimBackup
(
GalaxyArtSeriesClaimReqDto
reqDto
)
{
//系列声明用到参数
String
skuId
=
reqDto
.
getSkuId
();
String
seriesName
=
GalaxyConstant
.
SERIES_NAME_PREFIX
.
concat
(
skuId
);
Long
totalCount
=
reqDto
.
getTotalCount
();
String
coverUrl
=
reqDto
.
getCoverUrl
();
//暂时用nftUrl
String
seriesDesc
=
reqDto
.
getSeriesDesc
();
//发行用到的相关信息
String
author
=
reqDto
.
getAuthor
();
String
nftName
=
reqDto
.
getNftName
();
String
nftUrl
=
reqDto
.
getNftUrl
();
String
displayUrl
=
reqDto
.
getDisplayUrl
();
String
nftDesc
=
reqDto
.
getNftDesc
();
String
nftFlag
=
reqDto
.
getNftFlag
();
String
sellCount
=
reqDto
.
getSellCount
();
//返回参数
String
seriesId
=
null
;
String
taskId
=
null
;
GalaxySeriesInfoBo
seriesInfoBo
=
dataUtils
.
getSeriesInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNotNull
(
seriesInfoBo
)){
/**
* 如果系列声明成功,则不允许继续声明
*/
if
(
seriesInfoBo
.
getSeriesClaimStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
SUCCESS
.
getCode
())){
GalaxyArtSeriesClaimRespDto
seriesClaimRespDto
=
GalaxyArtSeriesClaimRespDto
.
getNew
();
seriesClaimRespDto
.
setSkuId
(
skuId
);
seriesClaimRespDto
.
setNftUrl
(
nftUrl
);
seriesClaimRespDto
.
setSeriesId
(
seriesInfoBo
.
getSeriesId
());
seriesClaimRespDto
.
setSeriesName
(
seriesInfoBo
.
getSeriesName
());
return
ResponseDto
.
success
(
seriesClaimRespDto
);
}
}
/**
* 进行系列声明
*/
Nft030SeriesClaimReqDto
nft030ReqDto
=
Nft030SeriesClaimReqDto
.
getNew
();
nft030ReqDto
.
setPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
nft030ReqDto
.
setSeriesName
(
seriesName
);
//无限制系列 设置为0
nft030ReqDto
.
setTotalCount
(
totalCount
);
nft030ReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
//系列封面
nft030ReqDto
.
setCoverUrl
(
coverUrl
);
nft030ReqDto
.
setDesc
(
seriesDesc
);
nft030ReqDto
.
setMaxPublishCount
(
0
);
nft030ReqDto
.
setSeriesBeginFromZero
(
false
);
ZxlnftResponseDto
<
Nft030SeriesClaimRespDto
>
nft30RespDto
=
zxlnftSdkUtil
.
nft030SeriesClaim
(
nft030ReqDto
);
//{"taskId":"49d1cccc-e62c-40bc-923c-bfac31325351_nft-series-claim_1"}
if
(
nft30RespDto
.
isSuccess
()){
//系列声明结果查询
Nft031SeriesClaimResultReqDto
nft031ReqDto
=
Nft031SeriesClaimResultReqDto
.
getNew
();
//第零个系列 无限制系列
taskId
=
nft30RespDto
.
getData
().
getTaskId
();
nft031ReqDto
.
setTaskId
(
taskId
);
int
count
=
0
;
while
(
StringUtil
.
isEmpty
(
seriesId
)){
count
++;
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
count
,
nft031ReqDto
.
getTaskId
());
ZxlnftResponseDto
<
Nft031SeriesClaimResultRespDto
>
nft031RespDtoTemp
=
zxlnftSdkUtil
.
nft031SeriesClaimResult
(
nft031ReqDto
);
if
(
nft031RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
seriesId
=
nft031RespDtoTemp
.
getData
().
getSeriesId
();
break
;
}
else
if
(
nft031RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
())){
log
.
info
(
"任务执行失败!taskId:{}"
,
nft031ReqDto
.
getTaskId
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getMessage
());
}
if
(
count
==
5
){
log
.
info
(
"=======查询共5次,跳出循环!taskId:{}"
,
nft031ReqDto
.
getTaskId
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR_FIVE_TIMES
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR_FIVE_TIMES
.
getMessage
());
}
}
log
.
info
(
"系列声明结果查询 seriesId :{}"
,
seriesId
);
}
GalaxyArtSeriesClaimRespDto
seriesClaimRespDto
=
GalaxyArtSeriesClaimRespDto
.
getNew
();
seriesClaimRespDto
.
setSkuId
(
skuId
);
seriesClaimRespDto
.
setNftUrl
(
nftUrl
);
seriesClaimRespDto
.
setSeriesId
(
seriesId
);
seriesClaimRespDto
.
setSeriesName
(
seriesName
);
//构造缓存数据
if
(
seriesInfoBo
==
null
){
//设置为处理中
String
publishStatus
=
GalaxyEnum
.
SeriesClaimStatusEnum
.
PROCESSING
.
getCode
();
seriesInfoBo
=
this
.
buildSeriesInfoBo
(
reqDto
,
null
,
publishStatus
);
dataUtils
.
setSeriesInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
(),
seriesInfoBo
);
}
return
ResponseDto
.
success
(
seriesClaimRespDto
);
}
public
ResponseDto
<
GalaxyArtSeriesClaimResultQueryRespDto
>
seriesClaimResultQuery
(
GalaxyArtSeriesClaimResultQueryReqDto
reqDto
)
{
//根据skuId获取系列nft信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftInfoBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
}
String
seriesCode
=
seriesNftInfoBo
.
getSeriesCode
();
//如果nftUrl介质hash为空,则重新生成
if
(
StringUtil
.
isEmpty
(
seriesNftInfoBo
.
getNftHash
())){
//更新系列对应的系列nft状态
seriesNftInfoBo
.
setNftHash
(
zxlnftBiz
.
getHashString
(
seriesNftInfoBo
.
getNftUrl
()));
dataUtils
.
updateSeriesNftStatus
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
(),
seriesNftInfoBo
);
}
//获取任务ID
GalaxySeriesInfoBo
seriesInfoBo
=
dataUtils
.
getSeriesInfoBo
(
reqDto
.
getRouterType
(),
seriesCode
);
if
(
StringUtil
.
isNull
(
seriesInfoBo
)||
StringUtil
.
isEmpty
(
seriesInfoBo
.
getSeriesClaimTaskId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NOT_EXIST
.
getMessage
());
}
if
(
seriesInfoBo
.
getSeriesClaimStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
SUCCESS
.
getCode
())){
GalaxyArtSeriesClaimResultQueryRespDto
resultQueryRespDto
=
this
.
buildGalaxyArtSeriesClaimResultQueryRespDto
(
reqDto
,
seriesInfoBo
,
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
());
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
//查询NFT系列声明结果
Nft031SeriesClaimResultReqDto
nft031SeriesClaimResultReqDto
=
Nft031SeriesClaimResultReqDto
.
getNew
();
nft031SeriesClaimResultReqDto
.
setTaskId
(
seriesInfoBo
.
getSeriesClaimTaskId
());
nft031SeriesClaimResultReqDto
.
setPlatformPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
ZxlnftResponseDto
<
Nft031SeriesClaimResultRespDto
>
resp
=
zxlnftSdkUtil
.
nft031SeriesClaimResult
(
nft031SeriesClaimResultReqDto
);
if
(
resp
.
isSuccess
()){
if
(
resp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
//设置系列声明状态
seriesInfoBo
.
setSeriesClaimStatus
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
SUCCESS
.
getCode
());
String
nowTimeStr
=
DateUtil
.
format
(
new
Date
(
resp
.
getData
().
getChainTimestamp
().
longValue
()*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
seriesInfoBo
.
setChainTimestamp
(
nowTimeStr
);
seriesInfoBo
.
setTradeHash
(
resp
.
getData
().
getTxHash
());
seriesInfoBo
.
setSeriesId
(
resp
.
getData
().
getSeriesId
());
seriesInfoBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
//根据系列编号更新系列声明状态 1对多skuId
// dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据skuId更新系列声明状态 1对1
dataUtils
.
updateSeriesClaimStatus
(
reqDto
.
getRouterType
(),
seriesCode
,
seriesInfoBo
,
reqDto
.
getSkuId
());
//设置成功返回参数
GalaxyArtSeriesClaimResultQueryRespDto
resultQueryRespDto
=
this
.
buildGalaxyArtSeriesClaimResultQueryRespDto
(
reqDto
,
seriesInfoBo
,
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
());
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
else
if
(
resp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
())){
seriesInfoBo
.
setSeriesClaimStatus
(
GalaxyEnum
.
SeriesClaimStatusEnum
.
FAIL
.
getCode
());
seriesInfoBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
//根据系列编号更新系列声明状态 1对多skuId
// dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据skuId更新系列声明状态 1对1
dataUtils
.
updateSeriesClaimStatus
(
reqDto
.
getRouterType
(),
seriesCode
,
seriesInfoBo
,
reqDto
.
getSkuId
());
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getMessage
());
}
}
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getCode
(),
GalaxyErrorEnum
.
SERIES_CLAIM_ERROR
.
getMessage
());
}
private
String
getFullFilePath
(
String
seriesName
,
String
originalUrl
){
String
filePath
=
null
;
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
=
IDGenerator
.
getZxlNftImageCosCode
()
+
imageType
;
//通过图片url地址上传
File
cosFile
=
galaxyCommonBiz
.
inputStreamToFile
(
originalUrl
,
fileName
);
filePath
=
cosFile
.
getAbsolutePath
();
log
.
info
(
"cosFile.getPath() :{}"
,
cosFile
.
getPath
());
log
.
info
(
"cosFile.getAbsoluteFile() :{}"
,
cosFile
.
getAbsoluteFile
());
//完整全路径 https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/NOW_ZXL_NFT_PIC001_test_skuId001/2022-03-04/ZXLNFTIMAGE202203041707466694345291.jpg
String
fullFilePath
=
null
;
//需要保存,返回给调用者
// 1.4.3调用sdk接口-上传cos接口
GalaxySeriesNftUploadTempSecretBo
seriesNftUploadTempSecretBo
=
this
.
getSeriesNftUploadTempSecret
(
seriesName
);
if
(
StringUtil
.
isNotNull
(
seriesNftUploadTempSecretBo
)){
fullFilePath
=
seriesNftUploadTempSecretBo
.
getUploadAddress
().
concat
(
fileName
);
UploadToCosReq
req
=
UploadToCosReq
.
getNew
();
req
.
setCosPath
(
fullFilePath
);
req
.
setTempSecretId
(
seriesNftUploadTempSecretBo
.
getTempSecretId
());
req
.
setTempSecretKey
(
seriesNftUploadTempSecretBo
.
getTempSecretKey
());
req
.
setSessionToken
(
seriesNftUploadTempSecretBo
.
getSessionToken
());
req
.
setFilePath
(
filePath
);
UploadToCosResp
uploadToCosResp
=
zxlWalletSdkUtil
.
uploadToCos
(
req
);
}
log
.
info
(
"完整的素材访问fullFilePath url:{}"
,
fullFilePath
);
return
fullFilePath
;
}
public
GalaxySeriesNftUploadTempSecretBo
getSeriesNftUploadTempSecret
(
String
seriesName
){
//获取临时密钥
GalaxySeriesNftUploadTempSecretBo
seriesNftUploadTempSecretBo
=
dataUtils
.
getSeriesNftUploadTempSecretBo
(
seriesName
);
if
(
StringUtil
.
isNull
(
seriesNftUploadTempSecretBo
)){
// 1.4.2调用生成素材上传临时密钥接口
Nft022UploadSecretReqDto
nft022ReqDto
=
Nft022UploadSecretReqDto
.
getNew
();
nft022ReqDto
.
setSeriesName
(
seriesName
);
nft022ReqDto
.
setTimestamp
(
DateUtil
.
getNowSeconds
().
toString
());
nft022ReqDto
.
setUserPubKey
(
zxlnftConfig
.
getNftPlatformPubKey
());
//系列为空
String
userData
=
nft022ReqDto
.
getTimestamp
();
//系列不为空
if
(
StringUtil
.
isNotEmpty
(
nft022ReqDto
.
getSeriesName
())){
userData
=
nft022ReqDto
.
getTimestamp
()
+
"_"
+
nft022ReqDto
.
getSeriesName
();
}
nft022ReqDto
.
setUserSignedData
(
zxlnftBiz
.
createSign
(
zxlnftConfig
.
getNftPlatformPriKey
(),
userData
));
ZxlnftResponseDto
<
Nft022UploadSecretRespDto
>
nft022RespDto
=
zxlnftSdkUtil
.
nft022UploadSecret
(
nft022ReqDto
);
if
(!
nft022RespDto
.
isSuccess
()){
throw
new
ZxlNftException
(
ZxlErrorEnum
.
UPLOAD_TEMP_SECRET
.
getCode
(),
ZxlErrorEnum
.
UPLOAD_TEMP_SECRET
.
getMsg
());
}
else
{
seriesNftUploadTempSecretBo
=
GalaxySeriesNftUploadTempSecretBo
.
getNew
();
seriesNftUploadTempSecretBo
.
setTempSecretId
(
nft022RespDto
.
getData
().
getTempSecretId
());
seriesNftUploadTempSecretBo
.
setTempSecretKey
(
nft022RespDto
.
getData
().
getTempSecretKey
());
seriesNftUploadTempSecretBo
.
setSessionToken
(
nft022RespDto
.
getData
().
getSessionToken
());
seriesNftUploadTempSecretBo
.
setUploadAddress
(
nft022RespDto
.
getData
().
getUploadAddress
());
seriesNftUploadTempSecretBo
.
setTimestamp
(
DateUtil
.
getNowTime
());
dataUtils
.
setSeriesNftUploadTempSecretBo
(
seriesName
,
seriesNftUploadTempSecretBo
);
}
}
return
seriesNftUploadTempSecretBo
;
}
private
GalaxySeriesInfoBo
buildSeriesInfoBo
(
GalaxyArtSeriesClaimReqDto
reqDto
,
String
taskId
,
String
publishStatus
){
String
seriesName
=
reqDto
.
getSkuId
();
GalaxySeriesInfoBo
seriesInfoBo
=
GalaxySeriesInfoBo
.
getNew
();
seriesInfoBo
.
setSeriesInfoId
(
IDGenerator
.
get32UUID
());
seriesInfoBo
.
setSeriesName
(
reqDto
.
getNftName
());
seriesInfoBo
.
setSeriesCode
(
seriesName
);
seriesInfoBo
.
setSeriesId
(
null
);
seriesInfoBo
.
setTotalCount
(
reqDto
.
getTotalCount
());
seriesInfoBo
.
setCrtCount
(
0L
);
seriesInfoBo
.
setSeriesClaimTaskId
(
taskId
);
seriesInfoBo
.
setSeriesClaimStatus
(
publishStatus
);
seriesInfoBo
.
setCoverUrl
(
reqDto
.
getCoverUrl
());
seriesInfoBo
.
setSeriesDesc
(
reqDto
.
getSeriesDesc
());
seriesInfoBo
.
setNftCount
(
1
);
//系列中nft个数 默认为1
seriesInfoBo
.
setRouterType
(
reqDto
.
getRouterType
());
seriesInfoBo
.
setCreatedAt
(
LocalDateTime
.
now
());
seriesInfoBo
.
setUpdatedAt
(
null
);
return
seriesInfoBo
;
}
private
GalaxySeriesNftInfoBo
buildSeriesNftInfoBo
(
GalaxyArtSeriesClaimReqDto
reqDto
,
GalaxySeriesInfoBo
seriesInfoBo
,
GalaxySeriesNftUploadBo
seriesNftUploadBo
){
//根据请求参数传入,如有4个skuId,依次传入1,2,3,4
int
nftPublishNumber
=
1
;
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
GalaxySeriesNftInfoBo
.
getNew
();
seriesNftInfoBo
.
setSeriesNftInfoId
(
IDGenerator
.
get32UUID
());
seriesNftInfoBo
.
setSeriesInfoId
(
seriesInfoBo
.
getSeriesInfoId
());
seriesNftInfoBo
.
setSkuId
(
reqDto
.
getSkuId
());
seriesNftInfoBo
.
setSeriesName
(
seriesInfoBo
.
getSeriesName
());
seriesNftInfoBo
.
setSeriesCode
(
seriesInfoBo
.
getSeriesCode
());
seriesNftInfoBo
.
setSeriesId
(
seriesInfoBo
.
getSeriesId
());
//目前要求发行总数必须能整除
Integer
nftTotalCount
=
BigDecimal
.
valueOf
(
seriesInfoBo
.
getTotalCount
()).
divide
(
BigDecimal
.
valueOf
(
seriesInfoBo
.
getNftCount
())).
intValue
();
seriesNftInfoBo
.
setNftTotalCount
(
Long
.
valueOf
(
nftTotalCount
.
toString
()));
seriesNftInfoBo
.
setNftCrtCount
(
0L
);
seriesNftInfoBo
.
setNftIdBegin
(
null
);
seriesNftInfoBo
.
setNftIdBeginIndex
(
BigDecimal
.
valueOf
(
nftTotalCount
).
multiply
(
BigDecimal
.
valueOf
(
nftPublishNumber
-
1
)).
intValue
()+
1
);
seriesNftInfoBo
.
setNftPublishNumber
(
nftPublishNumber
);
seriesNftInfoBo
.
setOriginalNftUrl
(
seriesNftUploadBo
.
getOriginalNftUrl
());
seriesNftInfoBo
.
setOriginalDisplayUrl
(
seriesNftUploadBo
.
getOriginalDisplayUrl
());
//以下为购买信息
seriesNftInfoBo
.
setAuthor
(
reqDto
.
getAuthor
());
seriesNftInfoBo
.
setNftName
(
reqDto
.
getNftName
());
seriesNftInfoBo
.
setNftUrl
(
reqDto
.
getNftUrl
());
seriesNftInfoBo
.
setDisplayUrl
(
reqDto
.
getDisplayUrl
());
seriesNftInfoBo
.
setNftDesc
(
reqDto
.
getNftDesc
());
seriesNftInfoBo
.
setNftFlag
(
reqDto
.
getNftFlag
());
BigDecimal
sellCount
=
new
BigDecimal
(
reqDto
.
getSellCount
()).
multiply
(
BigDecimal
.
valueOf
(
100
l
));
//积分
seriesNftInfoBo
.
setSellCount
(
sellCount
);
seriesNftInfoBo
.
setNftHash
(
zxlnftBiz
.
getHashString
(
reqDto
.
getNftUrl
()));
seriesNftInfoBo
.
setRouterType
(
reqDto
.
getRouterType
());
seriesNftInfoBo
.
setCreatedAt
(
LocalDateTime
.
now
());
return
seriesNftInfoBo
;
}
private
GalaxyArtSeriesClaimResultQueryRespDto
buildGalaxyArtSeriesClaimResultQueryRespDto
(
GalaxyArtSeriesClaimResultQueryReqDto
reqDto
,
GalaxySeriesInfoBo
seriesInfoBo
,
String
taskStatus
){
GalaxyArtSeriesClaimResultQueryRespDto
resultQueryRespDto
=
GalaxyArtSeriesClaimResultQueryRespDto
.
getNew
();
resultQueryRespDto
.
setSeriesId
(
seriesInfoBo
.
getSeriesId
());
resultQueryRespDto
.
setChainTimestamp
(
seriesInfoBo
.
getChainTimestamp
());
resultQueryRespDto
.
setTxHash
(
seriesInfoBo
.
getTradeHash
());
resultQueryRespDto
.
setTaskStatus
(
Integer
.
valueOf
(
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
taskStatus
).
getCode
()));
//获取sku对应nft信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
resultQueryRespDto
.
setNftHash
(
seriesNftInfoBo
.
getNftHash
());
return
resultQueryRespDto
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperPublishBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
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.GalaxySeriesNftInfoBo
;
import
com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryRespDto
;
import
com.liquidnet.service.galaxy.utils.GalaxyDataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperPublishBiz
* @Package com.liquidnet.service.galaxy.router.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:10
*/
@Slf4j
@Component
public
class
XuperPublishBiz
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
@Autowired
private
GalaxyBeanTransferBiz
galaxyBeanTransferBiz
;
/**
* nft发行
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishRespDto
>
nftPublish
(
GalaxyNftPublishReqDto
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
());
}
//获取sku信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftInfoBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
}
/**
* 获取订单和nft绑定信息
*/
GalaxyNftOrderBindBo
nftOrderBindBo
=
dataUtils
.
getGalaxyNftOrderBindBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBindBo
)){
//获取发行索引
long
nftIdNo
=
dataUtils
.
incrNftIdNo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
nftOrderBindBo
=
GalaxyNftOrderBindBo
.
getNew
();
nftOrderBindBo
.
setNftOrderPayId
(
reqDto
.
getNftOrderPayId
());
nftOrderBindBo
.
setSeriesId
(
seriesNftInfoBo
.
getSeriesId
());
nftOrderBindBo
.
setSeriesCode
(
seriesNftInfoBo
.
getSeriesCode
());
nftOrderBindBo
.
setNftIdIndex
(
Integer
.
valueOf
(
String
.
valueOf
(
nftIdNo
)));
nftOrderBindBo
.
setRouterType
(
reqDto
.
getRouterType
());
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
LocalDateTime
.
now
());
nftOrderBindBo
.
setCreatedAt
(
nowTimeStr
);
dataUtils
.
setGalaxyNftOrderBindBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBindBo
);
}
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
String
author
=
seriesNftInfoBo
.
getAuthor
();
String
nftName
=
seriesNftInfoBo
.
getNftName
();
String
nftUrl
=
seriesNftInfoBo
.
getNftUrl
();
String
displayUrl
=
seriesNftInfoBo
.
getDisplayUrl
();
String
nftDesc
=
seriesNftInfoBo
.
getNftDesc
();
String
nftFlag
=
seriesNftInfoBo
.
getNftFlag
();
//发行个数
Long
publishCount
=
1L
;
//开始索引
Integer
seriesBeginIndex
=
nftOrderBindBo
.
getNftIdIndex
();;
Long
sellCount
=
seriesNftInfoBo
.
getSellCount
().
longValue
();
//积分
/**
* 根据sku获取系列Id
*/
String
seriesId
=
seriesNftInfoBo
.
getSeriesId
();
//返回参数nftId
String
nftId
=
null
;
String
taskId
=
null
;
//查询系列信息 暂时不通过系列信息控制发行索引
// Nft032SeriesReqDto nft032ReqDto = Nft032SeriesReqDto.getNew();
// nft032ReqDto.setSeriesId(seriesId);
// ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(nft032ReqDto);
//
// if(resp.isSuccess()){
// //该系列已经发行多少个nft
// Long crtCount = resp.getData().getSeriesInfo().getCrtCount();
// log.info("系列:{} 已发行 :{}", seriesId, crtCount);
// //设置开始索引
// seriesBeginIndex = Integer.parseInt(String.valueOf(crtCount.longValue() + 1));
// }
//3.1.2调用NFT发行接口
/**
* 发行无限制系列
*/
Nft034PublishReqDto
nft034ReqDto
=
Nft034PublishReqDto
.
getNew
();
nft034ReqDto
.
setAuthor
(
author
);
nft034ReqDto
.
setName
(
nftName
);
nft034ReqDto
.
setUrl
(
nftUrl
);
nft034ReqDto
.
setDisplayUrl
(
displayUrl
);
nft034ReqDto
.
setDesc
(
nftDesc
);
nft034ReqDto
.
setFlag
(
nftFlag
);
nft034ReqDto
.
setPublishCount
(
publishCount
);
//无限制零系列
nft034ReqDto
.
setSeriesId
(
seriesId
);
nft034ReqDto
.
setSeriesBeginIndex
(
seriesBeginIndex
);
nft034ReqDto
.
setSellStatus
(
Integer
.
parseInt
(
ZxlnftEnum
.
SellStatusEnum
.
CAN_SELL
.
getCode
()));
nft034ReqDto
.
setSellCount
(
sellCount
);
nft034ReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
nft034ReqDto
.
setMetaData
(
""
);
ZxlnftResponseDto
<
Nft034PublishRespDto
>
nft034RespDto
=
zxlnftSdkUtil
.
nft034Publish
(
nft034ReqDto
);
if
(
nft034RespDto
.
isSuccess
())
{
taskId
=
nft034RespDto
.
getData
().
getTaskId
();
}
GalaxyNftPublishRespDto
nftPublishRespDto
=
GalaxyNftPublishRespDto
.
getNew
();
nftPublishRespDto
.
setUserId
(
reqDto
.
getUserId
());
nftPublishRespDto
.
setNftId
(
nftId
);
//构造缓存数据
if
(
nftOrderBo
==
null
){
nftOrderBo
=
galaxyBeanTransferBiz
.
buildNftOrderBo
(
reqDto
.
getNftOrderPayId
(),
userInfoBo
,
seriesNftInfoBo
);
nftOrderBo
.
setNftId
(
nftId
);
nftOrderBo
.
setNftPublishTaskId
(
taskId
);
nftOrderBo
.
setNftPublishStatus
(
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
());
dataUtils
.
setNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
}
return
ResponseDto
.
success
(
nftPublishRespDto
);
}
/**
* nft发行结果查询
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishResultQueryRespDto
>
nftPublishResultQuery
(
GalaxyNftPublishResultQueryReqDto
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
());
}
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto
nft035ReqDto
=
Nft035PublishResultReqDto
.
getNew
();
nft035ReqDto
.
setTaskId
(
nftOrderBo
.
getNftPublishTaskId
());
ZxlnftResponseDto
<
Nft035PublishResultRespDto
>
nft035RespDtoTemp
=
zxlnftSdkUtil
.
nft035PublishResult
(
nft035ReqDto
);
if
(
nft035RespDtoTemp
.
isSuccess
()){
//设置时间
String
nftPublishChainTimestampStr
=
DateUtil
.
format
(
new
Date
(
nft035RespDtoTemp
.
getData
().
getChainTimestamp
().
longValue
()*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
//转换任务状态
String
nftPublishStatusStr
=
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
()).
getCode
();
//更新缓存数据状态
nftOrderBo
.
setNftId
(
nft035RespDtoTemp
.
getData
().
getNftIdBegin
());
nftOrderBo
.
setNftPublishChainTimestamp
(
nftPublishChainTimestampStr
);
nftOrderBo
.
setNftPublishStatus
(
nftPublishStatusStr
);
nftOrderBo
.
setNftPublishTradeHash
(
nft035RespDtoTemp
.
getData
().
getTxHash
());
nftOrderBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
dataUtils
.
updateNftOrderPublishInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
//构造返回结果
GalaxyNftPublishResultQueryRespDto
nftPublishResultQueryRespDto
=
GalaxyNftPublishResultQueryRespDto
.
getNew
();
BeanUtil
.
copy
(
nft035RespDtoTemp
.
getData
(),
nftPublishResultQueryRespDto
);
nftPublishResultQueryRespDto
.
setChainTimestamp
(
nftPublishChainTimestampStr
);
nftPublishResultQueryRespDto
.
setTaskStatus
(
Integer
.
valueOf
(
nftPublishStatusStr
));
return
ResponseDto
.
success
(
nftPublishResultQueryRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
}
/**
* 以下为nft发行同步返回方法(暂时废弃)
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishRespDto
>
nftPublishSync
(
GalaxyNftPublishReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)&&
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getMessage
());
}
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
//获取sku信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
String
author
=
seriesNftInfoBo
.
getAuthor
();
String
nftName
=
seriesNftInfoBo
.
getNftName
();
String
nftUrl
=
seriesNftInfoBo
.
getNftUrl
();
String
displayUrl
=
seriesNftInfoBo
.
getDisplayUrl
();
String
nftDesc
=
seriesNftInfoBo
.
getNftDesc
();
String
nftFlag
=
seriesNftInfoBo
.
getNftFlag
();
//发行个数
Long
publishCount
=
1L
;
//开始索引
Integer
seriesBeginIndex
=
0
;
Long
sellCount
=
Long
.
valueOf
(
seriesNftInfoBo
.
getSellCount
().
multiply
(
BigDecimal
.
valueOf
(
100
l
)).
longValue
());
//积分
/**
* 根据sku获取系列Id
*/
String
seriesId
=
seriesNftInfoBo
.
getSeriesId
();
//返回参数nftId
String
nftId
=
null
;
String
taskId
=
null
;
Long
nftPublishChainTimestamp
=
null
;
Integer
nftPublishStatus
=
null
;
String
nftPublishTradeHash
=
null
;
//查询系列信息
Nft032SeriesReqDto
nft032ReqDto
=
Nft032SeriesReqDto
.
getNew
();
nft032ReqDto
.
setSeriesId
(
seriesId
);
ZxlnftResponseDto
<
Nft032SeriesRespDto
>
resp
=
zxlnftSdkUtil
.
nft032Series
(
nft032ReqDto
);
if
(
resp
.
isSuccess
()){
//该系列已经发行多少个nft
Long
crtCount
=
resp
.
getData
().
getSeriesInfo
().
getCrtCount
();
log
.
info
(
"系列:{} 已发行 :{}"
,
seriesId
,
crtCount
);
//设置开始索引
seriesBeginIndex
=
Integer
.
parseInt
(
String
.
valueOf
(
crtCount
.
longValue
()
+
1
));
}
//3.1.2调用NFT发行接口
/**
* 发行无限制系列
*/
Nft034PublishReqDto
nft034ReqDto
=
Nft034PublishReqDto
.
getNew
();
nft034ReqDto
.
setAuthor
(
author
);
nft034ReqDto
.
setName
(
nftName
);
nft034ReqDto
.
setUrl
(
nftUrl
);
nft034ReqDto
.
setDisplayUrl
(
displayUrl
);
nft034ReqDto
.
setDesc
(
nftDesc
);
nft034ReqDto
.
setFlag
(
nftFlag
);
nft034ReqDto
.
setPublishCount
(
publishCount
);
//无限制零系列
nft034ReqDto
.
setSeriesId
(
seriesId
);
nft034ReqDto
.
setSeriesBeginIndex
(
seriesBeginIndex
);
nft034ReqDto
.
setSellStatus
(
Integer
.
parseInt
(
ZxlnftEnum
.
SellStatusEnum
.
CAN_SELL
.
getCode
()));
nft034ReqDto
.
setSellCount
(
sellCount
);
nft034ReqDto
.
setOperateId
(
IDGenerator
.
get32UUID
());
nft034ReqDto
.
setMetaData
(
""
);
ZxlnftResponseDto
<
Nft034PublishRespDto
>
nft034RespDto
=
zxlnftSdkUtil
.
nft034Publish
(
nft034ReqDto
);
if
(
nft034RespDto
.
isSuccess
())
{
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto
nft035ReqDto
=
Nft035PublishResultReqDto
.
getNew
();
taskId
=
nft034RespDto
.
getData
().
getTaskId
();
nft035ReqDto
.
setTaskId
(
taskId
);
int
count
=
0
;
String
nftIdBegin
=
null
;
long
timeStart
=
System
.
currentTimeMillis
();
while
(
StringUtil
.
isEmpty
(
nftIdBegin
))
{
count
++;
ZxlnftResponseDto
<
Nft035PublishResultRespDto
>
nft035RespDtoTemp
=
zxlnftSdkUtil
.
nft035PublishResult
(
nft035ReqDto
);
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
count
,
nft035ReqDto
.
getTaskId
());
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
()))
{
nftIdBegin
=
nft035RespDtoTemp
.
getData
().
getNftIdBegin
();
nftPublishChainTimestamp
=
nft035RespDtoTemp
.
getData
().
getChainTimestamp
();
nftPublishStatus
=
nft035RespDtoTemp
.
getData
().
getTaskStatus
();
nftPublishTradeHash
=
nft035RespDtoTemp
.
getData
().
getTxHash
();
}
else
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
()))
{
log
.
info
(
"任务执行失败!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
return
null
;
}
if
(
count
==
5
)
{
log
.
info
(
"=======查询共5次,跳出循环!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
break
;
}
}
//赋值返回参数
nftId
=
nftIdBegin
;
log
.
info
(
"发行NFT后返回给前端nftID:{}"
,
nftIdBegin
);
log
.
info
(
"总共执行了{}次查询 总耗时:{} MS"
,
count
,
(
System
.
currentTimeMillis
()
-
timeStart
));
}
if
(
StringUtil
.
isEmpty
(
nftId
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
GalaxyNftPublishRespDto
nftPublishRespDto
=
GalaxyNftPublishRespDto
.
getNew
();
nftPublishRespDto
.
setUserId
(
reqDto
.
getUserId
());
nftPublishRespDto
.
setNftId
(
nftId
);
//构造缓存数据
if
(
nftOrderBo
==
null
){
nftOrderBo
=
galaxyBeanTransferBiz
.
buildNftOrderBo
(
reqDto
.
getNftOrderPayId
(),
userInfoBo
,
seriesNftInfoBo
);
nftOrderBo
.
setNftId
(
nftId
);
nftOrderBo
.
setNftPublishTaskId
(
taskId
);
//设置时间
String
nftPublishChainTimestampStr
=
DateUtil
.
format
(
new
Date
(
nftPublishChainTimestamp
*
1000
),
DateUtil
.
Formatter
.
yyyyMMddHHmmss
);
//转换任务状态
String
nftPublishStatusStr
=
GalaxyEnumBiz
.
getTaskStatusEnum
(
reqDto
.
getRouterType
(),
nftPublishStatus
.
toString
()).
getCode
();
nftOrderBo
.
setNftPublishChainTimestamp
(
nftPublishChainTimestampStr
);
nftOrderBo
.
setNftPublishStatus
(
nftPublishStatusStr
);
nftOrderBo
.
setNftPublishTradeHash
(
nftPublishTradeHash
);
nftOrderBo
.
setUpdatedAt
(
LocalDateTime
.
now
());
dataUtils
.
setNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
(),
nftOrderBo
);
}
return
ResponseDto
.
success
(
nftPublishRespDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperTradeBiz.java
0 → 100644
View file @
252739a1
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.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.*
;
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
;
import
com.liquidnet.service.galaxy.utils.QueueUtil
;
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
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperTradeBiz
* @Package com.liquidnet.service.galaxy.router.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:11
*/
@Slf4j
@Component
public
class
XuperTradeBiz
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
ZxlnftBiz
zxlnftBiz
;
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
@Autowired
private
GalaxyBeanTransferBiz
galaxyBeanTransferBiz
;
@Autowired
private
ZxinPublishBiz
zxinPublishBiz
;
@Autowired
private
XuperTradeCommonBiz
xuperTradeCommonBiz
;
@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
());
}
}
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发行和购买
* @param reqDto
* @return
*/
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
GalaxyNftPublishAndBuyResultQueryReqDto
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
());
}
/**
* TODO 如果订单信息是购买失败,则直接调用至信链查询购买结果
*/
//是否需要发起二次购买
boolean
isNeedSecondBuy
=
false
;
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftPublishStatus
())
&&
(
GalaxyEnum
.
TaskStatusEnum
.
INIT
.
getCode
().
equalsIgnoreCase
(
nftOrderBo
.
getNftPublishStatus
())
||
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
().
equalsIgnoreCase
(
nftOrderBo
.
getNftPublishStatus
()))){
//判断是否需要二次购买
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftPublishTaskId
())){
isNeedSecondBuy
=
true
;
}
//执行nft发行结果查询
GalaxyNftPublishResultQueryReqDto
nftPublishResultQueryReqDto
=
GalaxyNftPublishResultQueryReqDto
.
getNew
();
nftPublishResultQueryReqDto
.
setNftOrderPayId
(
reqDto
.
getNftOrderPayId
());
nftPublishResultQueryReqDto
.
setRouterType
(
reqDto
.
getRouterType
());
ResponseDto
<
GalaxyNftPublishResultQueryRespDto
>
publishResultQueryRespDto
=
zxinPublishBiz
.
nftPublishResultQuery
(
nftPublishResultQueryReqDto
);
if
(
publishResultQueryRespDto
.
isSuccess
()){
GalaxyNftPublishResultQueryRespDto
nftPublishResultQueryRespDtoTemp
=
publishResultQueryRespDto
.
getData
();
BeanUtil
.
copy
(
nftPublishResultQueryRespDtoTemp
,
nftOrderBo
);
}
}
else
if
(
StringUtil
.
isNotEmpty
(
nftOrderBo
.
getNftBuyStatus
())
&&
(
GalaxyEnum
.
TaskStatusEnum
.
INIT
.
getCode
().
equalsIgnoreCase
(
nftOrderBo
.
getNftBuyStatus
())
||
GalaxyEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
().
equalsIgnoreCase
(
nftOrderBo
.
getNftBuyStatus
()))){
//判断是否需要二次购买
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftBuyTaskId
())){
isNeedSecondBuy
=
true
;
}
//执行nft购买结果查询
GalaxyNftBuyResultQueryReqDto
nftBuyResultQueryReqDto
=
GalaxyNftBuyResultQueryReqDto
.
getNew
();
nftBuyResultQueryReqDto
.
setNftOrderPayId
(
reqDto
.
getNftOrderPayId
());
nftBuyResultQueryReqDto
.
setRouterType
(
reqDto
.
getRouterType
());
ResponseDto
<
GalaxyNftBuyResultQueryRespDto
>
buyResultQueryRespDto
=
this
.
nftBuyResultQuery
(
nftBuyResultQueryReqDto
);
if
(
buyResultQueryRespDto
.
isSuccess
()){
GalaxyNftBuyResultQueryRespDto
nftBuyResultQueryRespDtoTemp
=
buyResultQueryRespDto
.
getData
();
BeanUtil
.
copy
(
nftBuyResultQueryRespDtoTemp
,
nftOrderBo
);
}
}
//判断是否需要二次购买
// if(isNeedSecondBuy){
// GalaxyNftPublishAndBuyReqDto galaxyNftPublishAndBuyReqDto = GalaxyNftPublishAndBuyReqDto.getNew();
// BeanUtil.copy(reqDto,galaxyNftPublishAndBuyReqDto);
// galaxyNftPublishAndBuyReqDto.setSkuId(nftOrderBo.getSkuId());
// galaxyNftPublishAndBuyReqDto.setBuyTimestamp(DateUtil.getNowTime());
// queueUtil.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey(), JsonUtils.toJson(galaxyNftPublishAndBuyReqDto));
// }
GalaxyNftPublishAndBuyResultQueryRespDto
resultQueryRespDto
=
GalaxyNftPublishAndBuyResultQueryRespDto
.
getNew
();
if
(
nftOrderBo
.
getNftPublishStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())&&
nftOrderBo
.
getNftBuyStatus
().
equalsIgnoreCase
(
GalaxyEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
())){
BeanUtil
.
copy
(
nftOrderBo
,
resultQueryRespDto
);
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
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
();
}
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
());
}
//更新缓存数据状态
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
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperTradeQueryBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.dto.nft.Nft032SeriesResp
;
import
com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
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.utils.GalaxyDataUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperTradeQueryBiz
* @Package com.liquidnet.service.galaxy.router.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:11
*/
@Slf4j
@Component
public
class
XuperTradeQueryBiz
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
ZxlWalletSdkUtil
zxlWalletSdkUtil
;
@Autowired
private
ZxlnftBiz
zxlnftBiz
;
@Autowired
private
GalaxyDataUtils
dataUtils
;
public
ResponseDto
<
GalaxyQueryNftInfoRespDto
>
queryNftInfo
(
GalaxyQueryNftInfoReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_QUERY_FAIL_ORDER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_QUERY_FAIL_ORDER_NOT_EXIST
.
getMessage
());
}
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_QUERY_FAIL_NFT_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_QUERY_FAIL_NFT_NOT_EXIST
.
getMessage
());
}
Nft036InfoReqDto
nft036InfoReqDto
=
Nft036InfoReqDto
.
getNew
();
nft036InfoReqDto
.
setNftId
(
nftOrderBo
.
getNftId
());
ZxlnftResponseDto
<
Nft036InfoRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft036Info
(
nft036InfoReqDto
);
//查询结果
GalaxyQueryNftInfoRespDto
queryNftInfoRespDto
=
GalaxyQueryNftInfoRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
().
getNftInfo
(),
queryNftInfoRespDto
);
return
ResponseDto
.
success
(
queryNftInfoRespDto
);
}
return
ResponseDto
.
failure
();
}
public
ResponseDto
<
GalaxyQueryNftTradeListRespDto
>
queryNftTradeList
(
GalaxyQueryNftTradeListReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_QUERY_FAIL_ORDER_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_QUERY_FAIL_ORDER_NOT_EXIST
.
getMessage
());
}
if
(
StringUtil
.
isEmpty
(
nftOrderBo
.
getNftId
())){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
NFT_QUERY_FAIL_NFT_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
NFT_QUERY_FAIL_NFT_NOT_EXIST
.
getMessage
());
}
Nft039TradeListReqDto
nft039TradeListReqDto
=
Nft039TradeListReqDto
.
getNew
();
nft039TradeListReqDto
.
setNftId
(
nftOrderBo
.
getNftId
());
nft039TradeListReqDto
.
setLimit
(
1000
l
);
ZxlnftResponseDto
<
Nft039TradeListRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft039TradeList
(
nft039TradeListReqDto
);
//查询结果
GalaxyQueryNftTradeListRespDto
queryNftTradeListRespDto
=
GalaxyQueryNftTradeListRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
(),
queryNftTradeListRespDto
);
return
ResponseDto
.
success
(
queryNftTradeListRespDto
);
}
return
ResponseDto
.
failure
();
}
public
ResponseDto
<
GalaxyQuerySeriesInfoRespDto
>
querySeriesInfo
(
GalaxyQuerySeriesInfoReqDto
reqDto
)
{
//获取sku信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftInfoBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
}
Nft032SeriesReqDto
nft032SeriesReqDto
=
Nft032SeriesReqDto
.
getNew
();
nft032SeriesReqDto
.
setSeriesId
(
seriesNftInfoBo
.
getSeriesId
());
ZxlnftResponseDto
<
Nft032SeriesRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft032Series
(
nft032SeriesReqDto
);
//查询结果
GalaxyQuerySeriesInfoRespDto
querySeriesInfoRespDto
=
GalaxyQuerySeriesInfoRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
Nft032SeriesResp
.
SeriesInfo
seriesInfo
=
zxlnftResponseDto
.
getData
().
getSeriesInfo
();
BeanUtil
.
copy
(
seriesInfo
,
querySeriesInfoRespDto
);
querySeriesInfoRespDto
.
setTotalCount
(
seriesInfo
.
getTotalCount
().
toString
());
querySeriesInfoRespDto
.
setSeriesBeginFromZero
(
Boolean
.
toString
(
seriesInfo
.
isSeriesBeginFromZero
()));
querySeriesInfoRespDto
.
setCrtCount
(
seriesInfo
.
getCrtCount
().
toString
());
querySeriesInfoRespDto
.
setCreateTimeStamp
(
seriesInfo
.
getCreateTimeStamp
().
toString
());
return
ResponseDto
.
success
(
querySeriesInfoRespDto
);
}
return
ResponseDto
.
failure
();
}
public
ResponseDto
<
GalaxyQueryUserSeriesNftListRespDto
>
queryUserSeriesNftList
(
GalaxyQueryUserSeriesNftListReqDto
reqDto
)
{
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
//获取sku信息
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
dataUtils
.
getSeriesNftInfoBo
(
reqDto
.
getRouterType
(),
reqDto
.
getSkuId
());
if
(
StringUtil
.
isNull
(
seriesNftInfoBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getCode
(),
GalaxyErrorEnum
.
SERIES_NFT_INFO_NOT_EXIST
.
getMessage
());
}
Nft037AddressListReqDto
nft037ReqDto
=
Nft037AddressListReqDto
.
getNew
();
nft037ReqDto
.
setAddr
(
userInfoBo
.
getBlockChainAddress
());
nft037ReqDto
.
setSeriesId
(
seriesNftInfoBo
.
getSeriesId
());
nft037ReqDto
.
setLimit
(
1000
l
);
ZxlnftResponseDto
<
Nft037AddressListRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft037AddressList
(
nft037ReqDto
);
GalaxyQueryUserSeriesNftListRespDto
queryNftListRespDto
=
GalaxyQueryUserSeriesNftListRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
(),
queryNftListRespDto
);
queryNftListRespDto
.
setUserId
(
reqDto
.
getUserId
());
queryNftListRespDto
.
setSeriesId
(
seriesNftInfoBo
.
getSeriesId
());
}
else
{
return
ResponseDto
.
failure
();
}
return
ResponseDto
.
success
(
queryNftListRespDto
);
}
public
ResponseDto
<
GalaxyQueryUserTradeAllListRespDto
>
queryUserTradeAllList
(
GalaxyQueryUserTradeAllListReqDto
reqDto
)
{
Nft042TradeAllListReqDto
nft042TradeAllListReqDto
=
Nft042TradeAllListReqDto
.
getNew
();
nft042TradeAllListReqDto
.
setAddr
(
reqDto
.
getBlockChainAddress
());
nft042TradeAllListReqDto
.
setLimit
(
1000
l
);
ZxlnftResponseDto
<
Nft042TradeAllListRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft042TradeAllList
(
nft042TradeAllListReqDto
);
GalaxyQueryUserTradeAllListRespDto
queryUserTradeAllListRespDto
=
GalaxyQueryUserTradeAllListRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
(),
queryUserTradeAllListRespDto
);
}
else
{
return
ResponseDto
.
failure
();
}
return
ResponseDto
.
success
(
queryUserTradeAllListRespDto
);
}
public
ResponseDto
<
GalaxyQueryUserTradeInListRespDto
>
queryUserTradeInList
(
GalaxyQueryUserTradeInListReqDto
reqDto
)
{
Nft040TradeInListReqDto
nft040TradeInListReqDto
=
Nft040TradeInListReqDto
.
getNew
();
nft040TradeInListReqDto
.
setAddr
(
reqDto
.
getBlockChainAddress
());
nft040TradeInListReqDto
.
setLimit
(
1000
l
);
ZxlnftResponseDto
<
Nft040TradeInListRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft040TradeInList
(
nft040TradeInListReqDto
);
GalaxyQueryUserTradeInListRespDto
queryUserTradeInListRespDto
=
GalaxyQueryUserTradeInListRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
(),
queryUserTradeInListRespDto
);
}
else
{
return
ResponseDto
.
failure
();
}
return
ResponseDto
.
success
(
queryUserTradeInListRespDto
);
}
public
ResponseDto
<
GalaxyQueryUserTradeOutListRespDto
>
queryUserTradeOutList
(
GalaxyQueryUserTradeOutListReqDto
reqDto
)
{
Nft041TradeOutListReqDto
nft041TradeOutListReqDto
=
Nft041TradeOutListReqDto
.
getNew
();
nft041TradeOutListReqDto
.
setAddr
(
reqDto
.
getBlockChainAddress
());
nft041TradeOutListReqDto
.
setLimit
(
1000
l
);
ZxlnftResponseDto
<
Nft041TradeOutListRespDto
>
zxlnftResponseDto
=
zxlnftSdkUtil
.
nft041TradeOutList
(
nft041TradeOutListReqDto
);
GalaxyQueryUserTradeOutListRespDto
queryUserTradeOutListRespDto
=
GalaxyQueryUserTradeOutListRespDto
.
getNew
();
if
(
zxlnftResponseDto
.
isSuccess
()){
BeanUtil
.
copy
(
zxlnftResponseDto
.
getData
(),
queryUserTradeOutListRespDto
);
}
else
{
return
ResponseDto
.
failure
();
}
return
ResponseDto
.
success
(
queryUserTradeOutListRespDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/biz/XuperUserBiz.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
biz
;
import
com.liquidnet.common.third.xuper.util.XuperSdkUtil
;
import
com.liquidnet.common.third.zxlnft.dto.Nft016IdentityBindQueryReqDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: XuperUserBiz
* @Package com.liquidnet.service.galaxy.router.xuper.biz
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:11
*/
@Slf4j
@Component
public
class
XuperUserBiz
{
@Autowired
private
XuperSdkUtil
xuperSdkUtil
;
@Autowired
private
XuperUserCommonBiz
xuperUserCommonBiz
;
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
return
xuperUserCommonBiz
.
userRegister
(
reqDto
);
}
public
ResponseDto
<
GalaxyUserBindStatusQueryRespDto
>
userBindStatusQuery
(
GalaxyUserBindStatusQueryReqDto
reqDto
){
Nft016IdentityBindQueryReqDto
nft016ReqDto
=
Nft016IdentityBindQueryReqDto
.
getNew
();
nft016ReqDto
.
setAddressList
(
reqDto
.
getBlockChainAddress
());
// ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> zxlnftResponseDto = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
//
GalaxyUserBindStatusQueryRespDto
userBindStatusQueryRespDto
=
GalaxyUserBindStatusQueryRespDto
.
getNew
();
// if(zxlnftResponseDto.isSuccess()){
// Nft016QueryRsData nft016QueryRsData = zxlnftResponseDto.getData().getList().get(0);
// userBindStatusQueryRespDto.setBlockChainAddress(nft016QueryRsData.getAddress());
// Integer userBindStatus = Integer.valueOf(GalaxyEnumBiz.getUserBindStatusEnum(reqDto.getRouterType(),nft016QueryRsData.getStatus()).getCode());
// userBindStatusQueryRespDto.setUserBindStatus(userBindStatus);
// }else{
// return ResponseDto.failure();
// }
return
ResponseDto
.
success
(
userBindStatusQueryRespDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperArtworkImpl.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyArtwork
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterArtworkHandler
;
import
com.liquidnet.service.galaxy.router.xuper.biz.XuperArtworkBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyRouterStrategyXuperArtworkImpl
* @Package com.liquidnet.service.galaxy.router.xuper.service
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:03
*/
@Slf4j
@Component
@StrategyGalaxyRouterArtworkHandler
(
GalaxyEnum
.
RouterTypeEnum
.
XUPER
)
public
class
GalaxyRouterStrategyXuperArtworkImpl
implements
IGalaxyRouterStrategyArtwork
{
@Autowired
private
XuperArtworkBiz
xuperArtworkBiz
;
@Override
public
ResponseDto
<
GalaxyNftImageRespDto
>
nftImageCheck
(
GalaxyNftImageReqDto
reqDto
)
{
return
xuperArtworkBiz
.
nftImageCheck
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftUploadRespDto
>
nftUpload
(
GalaxyNftUploadReqDto
reqDto
)
{
return
xuperArtworkBiz
.
nftUpload
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyArtSeriesClaimRespDto
>
seriesClaim
(
GalaxyArtSeriesClaimReqDto
reqDto
)
{
return
xuperArtworkBiz
.
seriesClaim
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyArtSeriesClaimResultQueryRespDto
>
seriesClaimResultQuery
(
GalaxyArtSeriesClaimResultQueryReqDto
reqDto
)
{
return
xuperArtworkBiz
.
seriesClaimResultQuery
(
reqDto
);
}
}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperPublishImpl.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryRespDto
;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyPublish
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterPublishHandler
;
import
com.liquidnet.service.galaxy.router.xuper.biz.XuperPublishBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyRouterStrategyXuperPublishImpl
* @Package com.liquidnet.service.galaxy.router.xuper.service
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:03
*/
@Slf4j
@Component
@StrategyGalaxyRouterPublishHandler
(
GalaxyEnum
.
RouterTypeEnum
.
XUPER
)
public
class
GalaxyRouterStrategyXuperPublishImpl
implements
IGalaxyRouterStrategyPublish
{
@Autowired
private
XuperPublishBiz
xuperPublishBiz
;
@Override
public
ResponseDto
<
GalaxyNftPublishRespDto
>
nftPublish
(
GalaxyNftPublishReqDto
reqDto
)
{
return
xuperPublishBiz
.
nftPublish
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftPublishResultQueryRespDto
>
nftPublishResultQuery
(
GalaxyNftPublishResultQueryReqDto
reqDto
)
{
return
xuperPublishBiz
.
nftPublishResultQuery
(
reqDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperTradeImpl.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
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.xuper.biz.XuperTradeBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyRouterStrategyXuperTradeImpl
* @Package com.liquidnet.service.galaxy.router.xuper.service
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:04
*/
@Slf4j
@Component
@StrategyGalaxyRouterTradeHandler
(
GalaxyEnum
.
RouterTypeEnum
.
XUPER
)
public
class
GalaxyRouterStrategyXuperTradeImpl
implements
IGalaxyRouterStrategyTrade
{
@Autowired
private
XuperTradeBiz
xuperTradeBiz
;
@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
);
}
@Override
public
ResponseDto
<
GalaxyNftBuyResultQueryRespDto
>
nftBuyResultQuery
(
GalaxyNftBuyResultQueryReqDto
reqDto
)
{
return
xuperTradeBiz
.
nftBuyResultQuery
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftBuyPayResultQueryRespDto
>
nftBuyPayResultQuery
(
GalaxyNftBuyPayResultQueryReqDto
reqDto
)
{
return
null
;
}
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
)
{
return
xuperTradeBiz
.
nftPublishAndBuyResultQuery
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyRouterBatchQueryRespDto
>
nftPublishAndBuyResultBatchQuery
(
GalaxyNftPublishAndBuyRouterBatchQueryReqDto
reqDto
)
{
return
null
;
}
@Override
public
ResponseDto
<
GalaxyNftBuyRespDto
>
nftBuy
(
GalaxyNftBuyReqDto
reqDto
)
{
return
xuperTradeBiz
.
nftBuy
(
reqDto
);
}
}
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperTradeQueryImpl.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.param.*
;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyTradeQuery
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterTradeQueryHandler
;
import
com.liquidnet.service.galaxy.router.xuper.biz.XuperTradeQueryBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyRouterStrategyXuperTradeQueryImpl
* @Package com.liquidnet.service.galaxy.router.xuper.service
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:04
*/
@Slf4j
@Component
@StrategyGalaxyRouterTradeQueryHandler
(
GalaxyEnum
.
RouterTypeEnum
.
XUPER
)
public
class
GalaxyRouterStrategyXuperTradeQueryImpl
implements
IGalaxyRouterStrategyTradeQuery
{
@Autowired
private
XuperTradeQueryBiz
xuperTradeQueryBiz
;
@Override
public
ResponseDto
<
GalaxyQueryNftInfoRespDto
>
queryNftInfo
(
GalaxyQueryNftInfoReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryNftInfo
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQueryNftTradeListRespDto
>
queryNftTradeList
(
GalaxyQueryNftTradeListReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryNftTradeList
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQuerySeriesInfoRespDto
>
querySeriesInfo
(
GalaxyQuerySeriesInfoReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
querySeriesInfo
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQueryUserSeriesNftListRespDto
>
queryUserSeriesNftList
(
GalaxyQueryUserSeriesNftListReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryUserSeriesNftList
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQueryUserTradeAllListRespDto
>
queryUserTradeAllList
(
GalaxyQueryUserTradeAllListReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryUserTradeAllList
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQueryUserTradeInListRespDto
>
queryUserTradeInList
(
GalaxyQueryUserTradeInListReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryUserTradeInList
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyQueryUserTradeOutListRespDto
>
queryUserTradeOutList
(
GalaxyQueryUserTradeOutListReqDto
reqDto
)
{
return
xuperTradeQueryBiz
.
queryUserTradeOutList
(
reqDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/xuper/service/GalaxyRouterStrategyXuperUserImpl.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
galaxy
.
router
.
xuper
.
service
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.galaxy.constant.GalaxyEnum
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto
;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyUser
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterUserHandler
;
import
com.liquidnet.service.galaxy.router.xuper.biz.XuperUserBiz
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyRouterStrategyXuperUserImpl
* @Package com.liquidnet.service.galaxy.router.xuper.service
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/27 11:05
*/
@Slf4j
@Component
@StrategyGalaxyRouterUserHandler
(
GalaxyEnum
.
RouterTypeEnum
.
XUPER
)
public
class
GalaxyRouterStrategyXuperUserImpl
implements
IGalaxyRouterStrategyUser
{
@Autowired
private
XuperUserBiz
xuperUserBiz
;
@Override
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
return
xuperUserBiz
.
userRegister
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyUserBindStatusQueryRespDto
>
userBindStatusQuery
(
GalaxyUserBindStatusQueryReqDto
reqDto
)
{
return
xuperUserBiz
.
userBindStatusQuery
(
reqDto
);
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/service/GalaxyRouterStrategyZxlUserImpl.java
View file @
252739a1
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.GalaxyUserBindStatusQueryReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto
;
...
...
@@ -9,6 +11,7 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import
com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyUser
;
import
com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterUserHandler
;
import
com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserBiz
;
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,8 +32,14 @@ public class GalaxyRouterStrategyZxlUserImpl implements IGalaxyRouterStrategyUse
@Autowired
private
ZxinUserBiz
zxinUserBiz
;
@Autowired
private
QueueUtil
queueUtil
;
@Override
public
ResponseDto
<
GalaxyUserRegisterRespDto
>
userRegister
(
GalaxyUserRegisterReqDto
reqDto
)
{
//测试发送队列
queueUtil
.
sendMsgByRedis
(
MQConst
.
GalaxyQueue
.
JSON_NFT_USER_REGISTER
.
getKey
(),
JsonUtils
.
toJson
(
reqDto
));
// return ResponseDto.success();
return
zxinUserBiz
.
userRegister
(
reqDto
);
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/test/java/com/liquidnet/service/goblin/test/xuper/TestXuperSdkUtil.java
0 → 100644
View file @
252739a1
package
com
.
liquidnet
.
service
.
goblin
.
test
.
xuper
;
import
com.baidu.xuper.crypto.Hash
;
import
com.liquidnet.common.third.xuper.config.XuperConfig
;
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.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
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
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
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestXuperSdkUtil
* @Package com.liquidnet.common.third.xuper.test
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/20 13:53
*/
@Slf4j
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
TestXuperSdkUtil
{
@Autowired
private
XuperConfig
xuperConfig
;
@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"
;
@Test
public
void
test
(){
byte
[]
byteArrays
=
Hash
.
doubleSha256
(
"百"
.
getBytes
());
System
.
out
.
println
(
new
String
(
byteArrays
));
}
@Test
public
void
getImageWidthHeight
(){
String
file
=
"/Users/anjiabin/Downloads/zxl_image_test_001.jpg"
;
BufferedImage
bufferedImage
=
null
;
try
{
bufferedImage
=
ImageIO
.
read
(
new
FileInputStream
(
file
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
int
height
=
bufferedImage
.
getHeight
();
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
(
"testXuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuperConfig
(){
log
.
info
(
xuperConfig
.
getAppId
());
log
.
info
(
xuperConfig
.
getAccessKeyID
());
log
.
info
(
xuperConfig
.
getSecretAccessKey
());
log
.
info
(
xuperConfig
.
getNftApiUrl
());
}
/**
* 000创建数字账户
*/
@Test
public
void
testXuper000CreateAccount
(){
Xuper000CreateAccountReqDto
reqDto
=
Xuper000CreateAccountReqDto
.
getNew
();
// 创建区块链账户
Xuper000CreateAccountRespDto
respDto
=
null
;
try
{
XuperResponseDto
<
Xuper000CreateAccountRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper000CreateAccount
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper000CreateAccountRespDto
.
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
(
"testXuper000CreateAccount resp : "
+
JsonUtils
.
toJson
(
respDto
));
//执行结果
// {
// "pubKeyStr": "{\"Curvname\":\"P-256\",\"X\":26900004144763996911563948656450421861897438918108431880582510031552805599402,\"Y\":94599997406045773386654355342143942267529588691485440470001050827093124326536}",
// "priKeyStr": "{\"Curvname\":\"P-256\",\"X\":26900004144763996911563948656450421861897438918108431880582510031552805599402,\"Y\":94599997406045773386654355342143942267529588691485440470001050827093124326536,\"D\":37550310545913595104324496882710663834766010721178384935047209133379369071036}",
// "address": "YqsYxgBSP74piDhNQHTjWMH9wXnXxZbt8",
// "mnemonic": "person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe"
// }
}
/**
* 001获取访问BOS临时STS凭证
*/
@Test
public
void
testXuper001GetStoken
(){
Xuper001GetStokenReqDto
reqDto
=
Xuper001GetStokenReqDto
.
getNew
();
// 创建区块链账户
Xuper001GetStokenRespDto
respDto
=
null
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
XuperResponseDto
<
Xuper001GetStokenRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper001GetStoken
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper001GetStokenRespDto
.
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
(
"testXuper001GetStoken resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 002创造数字资产
* 注意:上传一次就会生成一个资产id,接口不校验资产唯一
*/
@Test
public
void
testXuper002CreateAsset
(){
Xuper002CreateAssetReqDto
reqDto
=
Xuper002CreateAssetReqDto
.
getNew
();
// 创建区块链账户
Xuper002CreateAssetRespDto
respDto
=
null
;
String
nftUrl
=
"bos_v1://xasset-offline/110381/ZXLNFTIMAGE202206231042217867523750.jpg/"
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
//资产碎片数量,小于1和大于200000代表不做库存限制
reqDto
.
setAmount
(
100
);
//藏品显示售卖价格,单位为分
reqDto
.
setPrice
(
1000
l
);
//资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
reqDto
.
setAssetCate
(
Integer
.
valueOf
(
XuperEnum
.
assetTypeEnum
.
COLLECTION
.
getCode
()));
//资产名称,小于30个字节
reqDto
.
setTitle
(
"百度超级链-数字藏品-测试20220622-001"
);
//资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
reqDto
.
setThumb
(
nftUrl
.
concat
(
"1000_500"
));
//短文字描述,小于300个字节
reqDto
.
setShortDesc
(
reqDto
.
getTitle
().
concat
(
"-短文字描述小于300个字节"
));
//(可选)资产详情介绍长图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
reqDto
.
setImgDesc
(
nftUrl
.
concat
(
"1000_500"
));
//资产原始文件。比如图片,图片本身就是资产。格式bos_v1://{bucket}/{object} ,文件大小<10M。文件名采用文件md5值,为了正常展现,需要正确携带文件后缀
reqDto
.
setAssetUrl
(
nftUrl
.
concat
(
"900_1200"
));
//(可选)长文字描述,小于1200个字节
reqDto
.
setLongDesc
(
reqDto
.
getTitle
().
concat
(
"-长文字描述,小于1200个字节"
));
//(可选)资产额外描述信息json字符串。比如标签
reqDto
.
setAssetExt
(
"{\"tags\":[\"艺术品\",\"古董\"]} "
);
//(可选)资产组id。用于关联业务层酒店/店铺id
reqDto
.
setGroupId
(
123123
l
);
//(可选)业务侧用户标记,必要时请安全处理后设置
reqDto
.
setUserId
(
123123
l
);
//(可选)要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
reqDto
.
setFileHash
(
new
String
(
Hash
.
doubleSha256
(
reqDto
.
getAssetUrl
().
getBytes
())));
XuperResponseDto
<
Xuper002CreateAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper002CreateAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper002CreateAssetRespDto
.
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
(
"testXuper002CreateAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 003修改未发行的数字资产
* 注意:已发行的资产不可以修改,错误为 40312 资产状态错误,不允许操作
*/
@Test
public
void
testXuper003AlterAsset
(){
Xuper003AlterAssetReqDto
reqDto
=
Xuper003AlterAssetReqDto
.
getNew
();
// 创建区块链账户
Xuper003AlterAssetRespDto
respDto
=
null
;
try
{
reqDto
.
setAssetId
(
1710956158450194370
l
);
//设置助记词
reqDto
.
setMnemonic
(
creatorMnemonic
);
//资产碎片数量,小于1和大于200000代表不做库存限制
reqDto
.
setAmount
(
100
);
//藏品显示售卖价格,单位为分
reqDto
.
setPrice
(
1000
l
);
//资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
reqDto
.
setAssetCate
(
Integer
.
valueOf
(
XuperEnum
.
assetTypeEnum
.
COLLECTION
.
getCode
()));
//资产名称,小于30个字节
reqDto
.
setTitle
(
"百度超级链-数字藏品-测试20220622-001"
);
//资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
reqDto
.
setThumb
(
"bos_v1://xasset-trade/100100/md5.jpeg/1000_500"
);
//短文字描述,小于300个字节
reqDto
.
setShortDesc
(
reqDto
.
getTitle
().
concat
(
"-短文字描述小于300个字节"
));
//(可选)资产详情介绍长图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
reqDto
.
setImgDesc
(
"bos_v1://xasset-trade/100100/md5.jpeg/1000_500"
);
//资产原始文件。比如图片,图片本身就是资产。格式bos_v1://{bucket}/{object} ,文件大小<10M。文件名采用文件md5值,为了正常展现,需要正确携带文件后缀
reqDto
.
setAssetUrl
(
"bos_v1://xasset-trade/100100/md5.gltf"
);
//(可选)长文字描述,小于1200个字节
reqDto
.
setLongDesc
(
reqDto
.
getTitle
().
concat
(
"-长文字描述,小于1200个字节"
));
//(可选)资产额外描述信息json字符串。比如标签
reqDto
.
setAssetExt
(
"{\"tags\":[\"艺术品\",\"古董\"]} "
);
//(可选)资产组id。用于关联业务层酒店/店铺id
reqDto
.
setGroupId
(
123123
l
);
//(可选)业务侧用户标记,必要时请安全处理后设置
reqDto
.
setUserId
(
123123
l
);
//(可选)要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
reqDto
.
setFileHash
(
new
String
(
Hash
.
doubleSha256
(
reqDto
.
getAssetUrl
().
getBytes
())));
XuperResponseDto
<
Xuper003AlterAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper003AlterAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper003AlterAssetRespDto
.
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
(
"testXuper003AlterAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 004链上发行数字资产
*/
@Test
public
void
testXuper004PublishAsset
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
// long assetId = 171095615845019437l;
long
assetId
=
1532351545249738541
l
;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 005查询数字商品详情
*/
@Test
public
void
testXuper005QueryAsset
(){
Xuper005QueryAssetReqDto
reqDto
=
Xuper005QueryAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper005QueryAssetRespDto
respDto
=
null
;
long
assetId
=
166759372822785837
l
;
//第1个
try
{
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper005QueryAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper005QueryAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper005QueryAssetRespDto
.
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
(
"testXuper005QueryAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 006拉取账户创造资产列表
*/
@Test
public
void
testXuper006ListAssetByAddr
(){
Xuper006ListAssetByAddrReqDto
reqDto
=
Xuper006ListAssetByAddrReqDto
.
getNew
();
// 定义返回结果对象
Xuper006ListAssetByAddrRespDto
respDto
=
null
;
try
{
//资产状态。0:全部 1:初试 3:发行中 4:发行成功。默认 0(可选)
int
status
=
0
;
//要拉取的区块链账户地址
String
addr
=
xuperSdkUtil
.
getAccount
(
creatorMnemonic
).
getAddress
();
//要拉取页数,第一页为1
int
page
=
1
;
//每页拉取数量,默认20,最大50(可选)
int
limit
=
20
;
reqDto
.
setStatus
(
status
);
reqDto
.
setAddr
(
addr
);
reqDto
.
setPage
(
page
);
reqDto
.
setLimit
(
limit
);
XuperResponseDto
<
Xuper006ListAssetByAddrRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper006ListAssetByAddr
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper006ListAssetByAddrRespDto
.
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
(
"testXuper006ListAssetByAddr resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
/**
* 007授予数字商品碎片
*/
@Test
public
void
testXuper007GrantShard
(){
Xuper007GrantShardReqDto
reqDto
=
Xuper007GrantShardReqDto
.
getNew
();
// 定义返回结果对象
Xuper007GrantShardRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
1
l
);
reqDto
.
setToAddr
(
xuperSdkUtil
.
getAccount
(
customerMnemonic
).
getAddress
());
reqDto
.
setToUserId
(
100000
l
);
reqDto
.
setPrice
(
1234
l
);
XuperResponseDto
<
Xuper007GrantShardRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper007GrantShard
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper007GrantShardRespDto
.
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
(
"testXuper007GrantShard resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper008TransferShard
(){
Xuper008TransferShardReqDto
reqDto
=
Xuper008TransferShardReqDto
.
getNew
();
// 定义返回结果对象
Xuper008TransferShardRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
customerMnemonic
);
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
1
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
);
}
}
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
(
respDto
));
}
@Test
public
void
testXuper009Consume
(){
Xuper009ConsumeReqDto
reqDto
=
Xuper009ConsumeReqDto
.
getNew
();
// 定义返回结果对象
Xuper009ConsumeRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
// reqDto.setMnemonic(creatorMnemonic);
// reqDto.setAssetId(assetId);
XuperResponseDto
<
Xuper009ConsumeRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper009Consume
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper009ConsumeRespDto
.
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
(
"testXuper009Consume resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper010QuerySds
(){
Xuper010QuerySdsReqDto
reqDto
=
Xuper010QuerySdsReqDto
.
getNew
();
// 定义返回结果对象
Xuper010QuerySdsRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
long
shardId
=
1
l
;
try
{
reqDto
.
setAssetId
(
assetId
);
reqDto
.
setShardId
(
shardId
);
XuperResponseDto
<
Xuper010QuerySdsRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper010QuerySds
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper010QuerySdsRespDto
.
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
(
"testXuper010QuerySds resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper011ListSdsByAddr
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper012ListSdsByAst
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper013History
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper014FreezeAsset
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
@Test
public
void
testXuper015GetEvidenceInfo
(){
Xuper004PublishAssetReqDto
reqDto
=
Xuper004PublishAssetReqDto
.
getNew
();
// 定义返回结果对象
Xuper004PublishAssetRespDto
respDto
=
null
;
long
assetId
=
171095615845019437
l
;
// long assetId = 1532351545249738541l;
try
{
reqDto
.
setMnemonic
(
creatorMnemonic
);
reqDto
.
setAssetId
(
assetId
);
XuperResponseDto
<
Xuper004PublishAssetRespDto
>
xuperResponseDto
=
xuperSdkUtil
.
xuper004PublishAsset
(
reqDto
);
if
(
xuperResponseDto
.
isSuccess
()){
respDto
=
xuperResponseDto
.
getParseData
(
Xuper004PublishAssetRespDto
.
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
(
"testXuper004PublishAsset resp : "
+
JsonUtils
.
toJson
(
respDto
));
}
}
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