记得上下班打卡 | 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
d9b88b7f
Commit
d9b88b7f
authored
Mar 29, 2022
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并发行与购买
parent
9f4e12d2
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
861 additions
and
71 deletions
+861
-71
GalaxyNftPublishAndBuyResultQueryReqDto.java
...xy/dto/param/GalaxyNftPublishAndBuyResultQueryReqDto.java
+46
-0
GalaxyNftPublishAndBuyResultQueryRespDto.java
...y/dto/param/GalaxyNftPublishAndBuyResultQueryRespDto.java
+43
-0
GalaxyNftTradeDto.java
...liquidnet/service/galaxy/dto/param/GalaxyNftTradeDto.java
+81
-0
IGalaxyTradeService.java
...liquidnet/service/galaxy/service/IGalaxyTradeService.java
+2
-0
ObjectUtil.java
...n/java/com/liquidnet/service/galaxy/utils/ObjectUtil.java
+51
-0
MQConst.java
...ain/java/com/liquidnet/service/base/constant/MQConst.java
+1
-0
pom.xml
...ce-consumer-all/liquidnet-service-consumer-galaxy/pom.xml
+14
-0
ConsumerSqlNftOrderInfoConfig.java
...consumer/galaxy/config/ConsumerSqlNftOrderInfoConfig.java
+2
-2
ConsumerSqlNftTradeInfoConfig.java
...consumer/galaxy/config/ConsumerSqlNftTradeInfoConfig.java
+2
-2
ConsumerSqlSeriesInfoConfig.java
...e/consumer/galaxy/config/ConsumerSqlSeriesInfoConfig.java
+2
-2
ConsumerSqlUserInfoConfig.java
...ice/consumer/galaxy/config/ConsumerSqlUserInfoConfig.java
+2
-2
AbstractJsonRedisReceiver.java
...e/consumer/galaxy/receiver/AbstractJsonRedisReceiver.java
+69
-0
AbstractSqlRedisReceiver.java
...ce/consumer/galaxy/receiver/AbstractSqlRedisReceiver.java
+1
-1
RedisJsonNftPublishAndBuyReceiver.java
...er/galaxy/receiver/RedisJsonNftPublishAndBuyReceiver.java
+20
-0
SqlRedisSqlNftOrderInfoReceiver.java
...umer/galaxy/receiver/SqlRedisSqlNftOrderInfoReceiver.java
+1
-1
SqlRedisSqlNftTradeInfoReceiver.java
...umer/galaxy/receiver/SqlRedisSqlNftTradeInfoReceiver.java
+1
-1
SqlRedisSqlSeriesInfoReceiver.java
...nsumer/galaxy/receiver/SqlRedisSqlSeriesInfoReceiver.java
+1
-1
SqlRedisSqlUserInfoReceiver.java
...consumer/galaxy/receiver/SqlRedisSqlUserInfoReceiver.java
+1
-1
ConsumerJsonNftPublishAndBuyProcessor.java
...vice/processor/ConsumerJsonNftPublishAndBuyProcessor.java
+249
-0
DataUtils.java
...om/liquidnet/service/consumer/galaxy/utils/DataUtils.java
+114
-0
QueueUtil.java
...om/liquidnet/service/consumer/galaxy/utils/QueueUtil.java
+53
-0
GalaxyTradeController.java
...dnet/service/galaxy/controller/GalaxyTradeController.java
+15
-7
ZxinTradeBiz.java
...iquidnet/service/galaxy/router/zxin/biz/ZxinTradeBiz.java
+29
-0
GalaxyRouterStrategyZxlTradeImpl.java
...router/zxin/service/GalaxyRouterStrategyZxlTradeImpl.java
+5
-0
GalaxyTradeServiceImpl.java
...t/service/galaxy/service/impl/GalaxyTradeServiceImpl.java
+5
-0
ObjectUtil.java
...n/java/com/liquidnet/service/galaxy/utils/ObjectUtil.java
+51
-51
No files found.
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftPublishAndBuyResultQueryReqDto.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
galaxy
.
dto
.
param
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.Size
;
import
java.io.Serializable
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 发行+购买结果查询
* @class: GalaxyNftPublishResultQueryReqDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/28 11:22
*/
@ApiModel
(
value
=
"GalaxyNftPublishResultQueryReqDto"
,
description
=
"NFT发行结果查询"
)
@Data
public
class
GalaxyNftPublishAndBuyResultQueryReqDto
extends
GalaxyBaseReqDto
implements
Serializable
,
Cloneable
{
/**
* nftOrderPayId
*/
@ApiModelProperty
(
position
=
1
,
required
=
true
,
value
=
"nft订单支付id(保证唯一),不超过30个字符"
)
@NotBlank
(
message
=
"nft订单支付id不能为空"
)
@Size
(
min
=
2
,
max
=
30
,
message
=
"nft订单支付id限制2-30位且不能包含特殊字符"
)
private
String
nftOrderPayId
;
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
}
private
static
final
GalaxyNftPublishAndBuyResultQueryReqDto
obj
=
new
GalaxyNftPublishAndBuyResultQueryReqDto
();
public
static
GalaxyNftPublishAndBuyResultQueryReqDto
getNew
()
{
try
{
return
(
GalaxyNftPublishAndBuyResultQueryReqDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GalaxyNftPublishAndBuyResultQueryReqDto
();
}
}
}
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftPublishAndBuyResultQueryRespDto.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
galaxy
.
dto
.
param
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 发行+购买结果查询
* @class: GalaxyNftPublishResultQueryRespDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/28 11:22
*/
@ApiModel
(
value
=
"GalaxyNftPublishResultQueryRespDto"
,
description
=
"NFT发行结果查询"
)
@Data
public
class
GalaxyNftPublishAndBuyResultQueryRespDto
implements
Serializable
,
Cloneable
{
/**
* nftId格式,发行人公钥hash_系列_系列索引id,申请多少个,最后一段计算出来即可,
* 比如申请10个,nftIdBegin位xx_xx_1,那么就可以推导出x_xx_1到x_xx_10
*/
@ApiModelProperty
(
position
=
3
,
required
=
true
,
value
=
"nftId格式"
)
private
String
nftIdBegin
;
@Override
public
String
toString
()
{
return
JsonUtils
.
toJson
(
this
);
}
private
static
final
GalaxyNftPublishAndBuyResultQueryRespDto
obj
=
new
GalaxyNftPublishAndBuyResultQueryRespDto
();
public
static
GalaxyNftPublishAndBuyResultQueryRespDto
getNew
()
{
try
{
return
(
GalaxyNftPublishAndBuyResultQueryRespDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GalaxyNftPublishAndBuyResultQueryRespDto
();
}
}
}
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/dto/param/GalaxyNftTradeDto.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
galaxy
.
dto
.
param
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyNftTradeDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/29 15:57
*/
@Data
public
class
GalaxyNftTradeDto
implements
Serializable
,
Cloneable
{
/**
* 应用系统购买系列唯一ID
*/
private
String
nftId
;
/**
* 系列的唯一Id
*/
private
String
seriesId
;
/**
* nftId
*/
private
String
tradeHash
;
/**
* nft价格
*/
private
String
chainTimestamp
;
/**
* 转出方地址
*/
private
String
fromAddress
;
/**
* 转入方地址
*/
private
String
toAddress
;
/**
* nft发行任务ID
*/
private
Long
tradePrice
;
/**
* nft购买任务id(交易类别 1发行 2购买 3转移 4设置价格 5设置状态)
* @return
*/
private
String
tradeType
;
/**
* 创建时间
*/
private
LocalDateTime
createdAt
;
/**
* 更新时间
*/
private
LocalDateTime
updatedAt
;
@Override
public
String
toString
(){
return
JsonUtils
.
toJson
(
this
);
}
private
static
final
GalaxyNftTradeDto
obj
=
new
GalaxyNftTradeDto
();
public
static
GalaxyNftTradeDto
getNew
()
{
try
{
return
(
GalaxyNftTradeDto
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GalaxyNftTradeDto
();
}
}
}
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/service/IGalaxyTradeService.java
View file @
d9b88b7f
...
...
@@ -21,4 +21,6 @@ public interface IGalaxyTradeService {
ResponseDto
<
GalaxyNftBuyResultQueryRespDto
>
nftBuyResultQuery
(
GalaxyNftBuyResultQueryReqDto
reqDto
);
ResponseDto
<
GalaxyNftBuyPayResultQueryRespDto
>
nftBuyPayResultQuery
(
GalaxyNftBuyPayResultQueryReqDto
reqDto
);
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
);
}
liquidnet-bus-api/liquidnet-service-galaxy-api/src/main/java/com/liquidnet/service/galaxy/utils/ObjectUtil.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
galaxy
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ObjectUtil
* @Package com.liquidnet.service.dragon.utils
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 16:00
*/
@Component
public
class
ObjectUtil
{
private
static
final
LinkedList
<
Object
[]>
linkedListObj
=
new
LinkedList
<
Object
[]>();
private
static
final
LinkedList
<
String
>
linkedListStr
=
new
LinkedList
<
String
>();
private
static
final
HashMap
<
String
,
String
>
hashMapStringAndString
=
new
HashMap
<>();
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
LinkedMultiValueMap
<
String
,
String
>
linkedMultiValueMapStringAndString
=
new
LinkedMultiValueMap
<
String
,
String
>();
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
}
public
static
LinkedList
<
String
>
cloneLinkedListStr
()
{
return
(
LinkedList
<
String
>)
linkedListStr
.
clone
();
}
public
static
HashMap
<
String
,
String
>
cloneHashMapStringAndString
()
{
return
(
HashMap
<
String
,
String
>)
hashMapStringAndString
.
clone
();
}
public
static
HashMap
<
String
,
Object
>
cloneHashMapStringAndObj
()
{
return
(
HashMap
<
String
,
Object
>)
hashMapStringAndObj
.
clone
();
}
public
static
JSONObject
cloneJsonObjectObj
()
{
return
(
JSONObject
)
jsonObjectObj
.
clone
();
}
public
static
LinkedMultiValueMap
<
String
,
String
>
cloneLinkedMultiValueMapStringAndString
()
{
return
linkedMultiValueMapStringAndString
.
clone
();
}
}
liquidnet-bus-common/liquidnet-common-service-base/src/main/java/com/liquidnet/service/base/constant/MQConst.java
View file @
d9b88b7f
...
...
@@ -289,6 +289,7 @@ public class MQConst {
SQL_SERIES_INFO
(
"galaxy:stream:rk.sql.seriesInfo"
,
"group.sql.seriesInfo"
,
"系列信息"
),
SQL_NFT_ORDER_INFO
(
"galaxy:stream:rk.sql.nftOrderInfo"
,
"group.sql.nftOrderInfo"
,
"订单信息"
),
SQL_NFT_TRADE_INFO
(
"galaxy:stream:rk.sql.nftTradeInfo"
,
"group.sql.nftTradeInfo"
,
"交易信息"
),
JSON_NFT_PUBLISH_AND_BUY
(
"galaxy:stream:rk.json.nftPublishAndBuy"
,
"group.sql.nftPublishAndBuy"
,
"NFT发行和购买"
),
;
private
final
String
key
;
private
final
String
group
;
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/pom.xml
View file @
d9b88b7f
...
...
@@ -17,6 +17,10 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
...
...
@@ -26,6 +30,16 @@
<artifactId>
liquidnet-common-cache-redis
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-third-zxlnft
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-third-antchain
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-service-galaxy-api
</artifactId>
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/config/ConsumerSqlNftOrderInfoConfig.java
View file @
d9b88b7f
...
...
@@ -2,7 +2,7 @@ package com.liquidnet.service.consumer.galaxy.config;
import
com.liquidnet.common.cache.redis.config.RedisStreamConfig
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.galaxy.receiver.RedisSqlSeriesInfoReceiver
;
import
com.liquidnet.service.consumer.galaxy.receiver.
Sql
RedisSqlSeriesInfoReceiver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@Configuration
public
class
ConsumerSqlNftOrderInfoConfig
extends
RedisStreamConfig
{
@Autowired
private
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
private
Sql
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/config/ConsumerSqlNftTradeInfoConfig.java
View file @
d9b88b7f
...
...
@@ -2,7 +2,7 @@ package com.liquidnet.service.consumer.galaxy.config;
import
com.liquidnet.common.cache.redis.config.RedisStreamConfig
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.galaxy.receiver.RedisSqlSeriesInfoReceiver
;
import
com.liquidnet.service.consumer.galaxy.receiver.
Sql
RedisSqlSeriesInfoReceiver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@Configuration
public
class
ConsumerSqlNftTradeInfoConfig
extends
RedisStreamConfig
{
@Autowired
private
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
private
Sql
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/config/ConsumerSqlSeriesInfoConfig.java
View file @
d9b88b7f
...
...
@@ -2,7 +2,7 @@ package com.liquidnet.service.consumer.galaxy.config;
import
com.liquidnet.common.cache.redis.config.RedisStreamConfig
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.galaxy.receiver.RedisSqlSeriesInfoReceiver
;
import
com.liquidnet.service.consumer.galaxy.receiver.
Sql
RedisSqlSeriesInfoReceiver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@Configuration
public
class
ConsumerSqlSeriesInfoConfig
extends
RedisStreamConfig
{
@Autowired
private
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
private
Sql
RedisSqlSeriesInfoReceiver
sqlSeriesInfoReceiver
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/config/ConsumerSqlUserInfoConfig.java
View file @
d9b88b7f
...
...
@@ -2,7 +2,7 @@ package com.liquidnet.service.consumer.galaxy.config;
import
com.liquidnet.common.cache.redis.config.RedisStreamConfig
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.consumer.galaxy.receiver.RedisSqlUserInfoReceiver
;
import
com.liquidnet.service.consumer.galaxy.receiver.
Sql
RedisSqlUserInfoReceiver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@Configuration
public
class
ConsumerSqlUserInfoConfig
extends
RedisStreamConfig
{
@Autowired
private
RedisSqlUserInfoReceiver
sqlUserInfoReceiver
;
private
Sql
RedisSqlUserInfoReceiver
sqlUserInfoReceiver
;
@Autowired
StringRedisTemplate
stringRedisTemplate
;
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/AbstractJsonRedisReceiver.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
consumer
.
galaxy
.
receiver
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.consumer.galaxy.service.processor.ConsumerJsonNftPublishAndBuyProcessor
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.stream.StreamListener
;
import
java.util.HashMap
;
@Slf4j
public
abstract
class
AbstractJsonRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
ConsumerJsonNftPublishAndBuyProcessor
jsonNftPublishAndBuyProcessor
;
@Override
public
void
onMessage
(
MapRecord
<
String
,
String
,
String
>
message
)
{
String
redisStreamKey
=
this
.
getRedisStreamKey
();
log
.
debug
(
"CONSUMER MSG[streamKey:{},messageId:{},stream:{},body:{}]"
,
redisStreamKey
,
message
.
getId
(),
message
.
getStream
(),
message
.
getValue
());
boolean
result
=
this
.
consumerMessageHandler
(
message
.
getValue
().
get
(
"message"
));
log
.
info
(
"CONSUMER MSG RESULT:{} ==> [{}]MESSAGE_ID:{}"
,
result
,
redisStreamKey
,
message
.
getId
());
try
{
stringRedisTemplate
.
opsForStream
().
acknowledge
(
getRedisStreamGroup
(),
message
);
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_ACK ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
try
{
stringRedisTemplate
.
opsForStream
().
delete
(
redisStreamKey
,
message
.
getId
());
}
catch
(
Exception
e
)
{
log
.
error
(
"#CONSUMER MSG EX_DEL ==> [{}]RESULT:{},MESSAGE:{}"
,
redisStreamKey
,
result
,
message
.
getValue
(),
e
);
}
}
private
boolean
consumerMessageHandler
(
String
msg
)
{
boolean
aBoolean
=
false
;
try
{
GalaxyNftPublishAndBuyReqDto
textMessage
=
JsonUtils
.
fromJson
(
msg
,
GalaxyNftPublishAndBuyReqDto
.
class
);
if
(
textMessage
==
null
)
{
aBoolean
=
true
;
}
else
{
//执行计数
jsonNftPublishAndBuyProcessor
.
nftPublishAndBuy
(
textMessage
);
aBoolean
=
true
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CONSUMER MSG EX_HANDLE ==> [{}]:{}"
,
this
.
getRedisStreamKey
(),
msg
,
e
);
}
finally
{
if
(!
aBoolean
)
{
HashMap
<
String
,
String
>
map
=
CollectionUtil
.
mapStringString
();
map
.
put
(
"message"
,
msg
);
stringRedisTemplate
.
opsForStream
().
add
(
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
this
.
getRedisStreamKey
()));
}
}
return
aBoolean
;
}
protected
abstract
String
getRedisStreamKey
();
protected
abstract
String
getRedisStreamGroup
();
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/AbstractRedisReceiver.java
→
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/Abstract
Sql
RedisReceiver.java
View file @
d9b88b7f
...
...
@@ -23,7 +23,7 @@ import java.util.HashMap;
* @date 2022/7/22 20:28
*/
@Slf4j
public
abstract
class
AbstractRedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
public
abstract
class
Abstract
Sql
RedisReceiver
implements
StreamListener
<
String
,
MapRecord
<
String
,
String
,
String
>>
{
@Autowired
private
IBaseDao
baseDao
;
@Autowired
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/RedisJsonNftPublishAndBuyReceiver.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
consumer
.
galaxy
.
receiver
;
import
com.liquidnet.service.base.constant.MQConst
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
@Slf4j
@Component
public
class
RedisJsonNftPublishAndBuyReceiver
extends
AbstractJsonRedisReceiver
{
@Override
protected
String
getRedisStreamKey
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getKey
();
}
@Override
protected
String
getRedisStreamGroup
()
{
return
MQConst
.
GalaxyQueue
.
JSON_NFT_PUBLISH_AND_BUY
.
getGroup
();
}
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/RedisSqlNftOrderInfoReceiver.java
→
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/
Sql
RedisSqlNftOrderInfoReceiver.java
View file @
d9b88b7f
...
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public
class
RedisSqlNftOrderInfoReceiver
extends
Abstract
RedisReceiver
{
public
class
SqlRedisSqlNftOrderInfoReceiver
extends
AbstractSql
RedisReceiver
{
@Override
protected
String
getRedisStreamKey
()
{
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/RedisSqlNftTradeInfoReceiver.java
→
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/
Sql
RedisSqlNftTradeInfoReceiver.java
View file @
d9b88b7f
...
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public
class
RedisSqlNftTradeInfoReceiver
extends
Abstract
RedisReceiver
{
public
class
SqlRedisSqlNftTradeInfoReceiver
extends
AbstractSql
RedisReceiver
{
@Override
protected
String
getRedisStreamKey
()
{
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/RedisSqlSeriesInfoReceiver.java
→
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/
Sql
RedisSqlSeriesInfoReceiver.java
View file @
d9b88b7f
...
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public
class
RedisSqlSeriesInfoReceiver
extends
Abstract
RedisReceiver
{
public
class
SqlRedisSqlSeriesInfoReceiver
extends
AbstractSql
RedisReceiver
{
@Override
protected
String
getRedisStreamKey
()
{
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/RedisSqlUserInfoReceiver.java
→
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/receiver/
Sql
RedisSqlUserInfoReceiver.java
View file @
d9b88b7f
...
...
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public
class
RedisSqlUserInfoReceiver
extends
Abstract
RedisReceiver
{
public
class
SqlRedisSqlUserInfoReceiver
extends
AbstractSql
RedisReceiver
{
@Override
protected
String
getRedisStreamKey
()
{
...
...
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/service/processor/ConsumerJsonNftPublishAndBuyProcessor.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
consumer
.
galaxy
.
service
.
processor
;
import
com.liquidnet.common.exception.LiquidnetServiceException
;
import
com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz
;
import
com.liquidnet.common.third.zxlnft.config.ZxlnftConfig
;
import
com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum
;
import
com.liquidnet.common.third.zxlnft.dto.*
;
import
com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil
;
import
com.liquidnet.commons.lang.util.BASE64Util
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.consumer.galaxy.utils.DataUtils
;
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.GalaxyNftBuyRespDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto
;
import
com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.io.UnsupportedEncodingException
;
import
java.math.BigDecimal
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerJsonNftPublishAndBuyProcessor
* @Package com.liquidnet.service.consumer.galaxy.service.processor
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/29 17:04
*/
@Slf4j
@Data
public
class
ConsumerJsonNftPublishAndBuyProcessor
{
@Autowired
private
ZxlnftSdkUtil
zxlnftSdkUtil
;
@Autowired
private
ZxlnftBiz
zxlnftBiz
;
@Autowired
private
ZxlnftConfig
zxlnftConfig
;
@Autowired
private
DataUtils
dataUtils
;
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
GalaxyNftPublishAndBuyReqDto
reqDto
)
{
//获取订单信息
GalaxyNftOrderBo
nftOrderBo
=
dataUtils
.
getNftOrderBo
(
reqDto
.
getRouterType
(),
reqDto
.
getNftOrderPayId
());
if
(
StringUtil
.
isNotNull
(
nftOrderBo
)){
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL_ALREADY_EXIST
.
getMessage
());
}
//获取用户信息
GalaxyUserInfoBo
userInfoBo
=
dataUtils
.
getGalaxyUserInfo
(
reqDto
.
getRouterType
(),
reqDto
.
getUserId
());
//获取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
.
getSkuId
();
//返回参数nftId
String
nftId
=
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
();
nft035ReqDto
.
setTaskId
(
nft034RespDto
.
getData
().
getTaskId
());
//休眠1秒钟,等待执行结果
try
{
Thread
.
sleep
(
1000
l
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
long
timeStart
=
System
.
currentTimeMillis
();
log
.
info
(
"=======执行第{}次查询,taskId:{}"
,
1
,
nft035ReqDto
.
getTaskId
());
ZxlnftResponseDto
<
Nft035PublishResultRespDto
>
nft035RespDto
=
zxlnftSdkUtil
.
nft035PublishResult
(
nft035ReqDto
);
if
(
nft035RespDto
.
isSuccess
())
{
if
(
nft035RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
()))
{
log
.
info
(
"任务执行失败!taskId:{} taskMsg:{}"
,
nft035ReqDto
.
getTaskId
(),
nft035RespDto
.
getData
().
getTaskMsg
());
return
null
;
}
int
count
=
1
;
String
nftIdBegin
=
nft035RespDto
.
getData
().
getNftIdBegin
();
if
(
nft035RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
PROCESSING
.
getCode
()))
{
log
.
info
(
ZxlnftEnum
.
TaskStatusEnum
.
PROCESSING
.
getMessage
());
while
(
StringUtil
.
isEmpty
(
nftIdBegin
))
{
//休眠1秒钟,等待执行结果
try
{
Thread
.
sleep
(
1000
l
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
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
();
}
else
if
(
nft035RespDtoTemp
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_FAIL
.
getCode
()))
{
log
.
info
(
"任务执行失败!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
return
null
;
}
if
(
count
==
6
)
{
log
.
info
(
"=======查询共6次,跳出循环!taskId:{}"
,
nft035ReqDto
.
getTaskId
());
break
;
}
}
}
else
if
(
nft035RespDto
.
getData
().
getTaskStatus
().
toString
().
equals
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getCode
()))
{
log
.
info
(
ZxlnftEnum
.
TaskStatusEnum
.
TASK_SUCCESS
.
getMessage
());
}
log
.
info
(
"发行NFT后返回给前端nftID:{}"
,
nftIdBegin
);
log
.
info
(
"总共执行了{}次查询 总耗时:{} MS"
,
count
,
(
System
.
currentTimeMillis
()
-
timeStart
));
if
(
StringUtil
.
isNotEmpty
(
nftIdBegin
))
{
nftId
=
nftIdBegin
;
//3.1.3调用NFT查询接口
Nft036InfoReqDto
nft036ReqDto
=
Nft036InfoReqDto
.
getNew
();
nft036ReqDto
.
setNftId
(
nftIdBegin
);
ZxlnftResponseDto
<
Nft036InfoRespDto
>
nft036RespDto
=
zxlnftSdkUtil
.
nft036Info
(
nft036ReqDto
);
log
.
info
(
"调用NFT查询接口 : {}"
,
nft036RespDto
.
toJson
());
}
}
}
if
(
StringUtil
.
isNotEmpty
(
nftId
)){
//执行购买逻辑
GalaxyNftPublishAndBuyRespDto
nftPublishAndBuyRespDto
=
GalaxyNftPublishAndBuyRespDto
.
getNew
();
GalaxyNftBuyRespDto
nftBuyRespDto
=
this
.
nftBuyBusiness
(
reqDto
.
getRouterType
(),
nftId
,
userInfoBo
,
seriesNftInfoBo
,
nftOrderBo
);
BeanUtil
.
copy
(
nftBuyRespDto
,
nftPublishAndBuyRespDto
);
return
ResponseDto
.
success
(
nftPublishAndBuyRespDto
);
}
else
{
return
ResponseDto
.
failure
(
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getCode
(),
GalaxyErrorEnum
.
PUBLISH_FAIL
.
getMessage
());
}
}
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
);
dataUtils
.
updateNftOrderBuyTaskId
(
routerType
,
nftOrderBo
.
getNftOrderPayId
(),
nftOrderBo
);
GalaxyNftBuyRespDto
nftBuyRespDto
=
GalaxyNftBuyRespDto
.
getNew
();
nftBuyRespDto
.
setUserId
(
userInfoBo
.
getUserId
());
nftBuyRespDto
.
setNftId
(
null
);
return
nftBuyRespDto
;
}
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/utils/DataUtils.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
consumer
.
galaxy
.
utils
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
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.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.vo.mongo.GalaxyNftOrderVo
;
import
com.liquidnet.service.galaxy.dto.vo.mongo.GalaxySeriesNftInfoVo
;
import
com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyUserInfoVo
;
import
com.mongodb.client.result.UpdateResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Component
;
import
java.time.LocalDateTime
;
@Slf4j
@Component
public
class
DataUtils
{
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
QueueUtil
queueUtil
;
private
long
keyExpireTime
=
3600
*
24
*
30
;
public
GalaxyUserInfoBo
getGalaxyUserInfo
(
String
routerType
,
String
userId
)
{
Object
obj
=
redisUtil
.
get
(
GalaxyConstant
.
REDIS_KEY_GALAXY_USER
.
concat
(
routerType
).
concat
(
":"
)
+
userId
);
if
(
obj
!=
null
){
return
(
GalaxyUserInfoBo
)
obj
;
}
else
{
GalaxyUserInfoVo
userInfoVo
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"userId"
).
is
(
userId
)),
GalaxyUserInfoVo
.
class
,
GalaxyUserInfoVo
.
class
.
getSimpleName
());
if
(
userInfoVo
==
null
)
{
return
null
;
}
GalaxyUserInfoBo
userInfoBo
=
GalaxyUserInfoBo
.
getNew
();
BeanUtil
.
copy
(
userInfoVo
,
userInfoBo
);
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_USER
.
concat
(
routerType
).
concat
(
":"
)
+
userId
,
userInfoBo
);
return
userInfoBo
;
}
}
public
GalaxyNftOrderBo
getNftOrderBo
(
String
routerType
,
String
nftOrderPayId
)
{
Object
obj
=
redisUtil
.
get
(
GalaxyConstant
.
REDIS_KEY_GALAXY_TRADE
.
concat
(
routerType
).
concat
(
":"
)
+
nftOrderPayId
);
if
(
obj
!=
null
){
return
(
GalaxyNftOrderBo
)
obj
;
}
else
{
GalaxyNftOrderVo
nftOrderVo
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"nftOrderPayId"
).
is
(
nftOrderPayId
)),
GalaxyNftOrderVo
.
class
,
GalaxyNftOrderVo
.
class
.
getSimpleName
());
if
(
nftOrderVo
==
null
)
{
return
null
;
}
GalaxyNftOrderBo
nftOrderBo
=
GalaxyNftOrderBo
.
getNew
();
BeanUtil
.
copy
(
nftOrderVo
,
nftOrderBo
);
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_TRADE
.
concat
(
routerType
).
concat
(
":"
)
+
nftOrderPayId
,
nftOrderBo
);
return
nftOrderBo
;
}
}
public
GalaxySeriesNftInfoBo
getSeriesNftInfoBo
(
String
routerType
,
String
skuId
)
{
Object
obj
=
redisUtil
.
get
(
GalaxyConstant
.
REDIS_KEY_GALAXY_SERIES_NFT
.
concat
(
routerType
).
concat
(
":"
)
+
skuId
);
if
(
obj
!=
null
){
return
(
GalaxySeriesNftInfoBo
)
obj
;
}
else
{
GalaxySeriesNftInfoVo
seriesNftInfoVo
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"skuId"
).
is
(
skuId
)),
GalaxySeriesNftInfoVo
.
class
,
GalaxySeriesNftInfoVo
.
class
.
getSimpleName
());
if
(
seriesNftInfoVo
==
null
)
{
return
null
;
}
GalaxySeriesNftInfoBo
seriesNftInfoBo
=
GalaxySeriesNftInfoBo
.
getNew
();
BeanUtil
.
copy
(
seriesNftInfoVo
,
seriesNftInfoBo
);
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_SERIES_NFT
.
concat
(
routerType
).
concat
(
":"
)
+
skuId
,
seriesNftInfoBo
);
return
seriesNftInfoBo
;
}
}
public
void
updateNftOrderBuyTaskId
(
String
routerType
,
String
nftOrderPayId
,
GalaxyNftOrderBo
nftOrderBo
)
{
redisUtil
.
set
(
GalaxyConstant
.
REDIS_KEY_GALAXY_TRADE
.
concat
(
routerType
).
concat
(
":"
)
+
nftOrderPayId
,
nftOrderBo
,
keyExpireTime
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"nftOrderPayId"
).
is
(
nftOrderPayId
));
Update
update
=
Update
.
fromDocument
(
Document
.
parse
(
JsonUtils
.
toJson
(
nftOrderBo
)));
update
.
set
(
"nftBuyTaskId"
,
nftOrderBo
.
getNftBuyTaskId
());
String
nowTimeStr
=
DateUtil
.
Formatter
.
yyyyMMddHHmmss
.
format
(
LocalDateTime
.
now
());
update
.
set
(
"updatedAt"
,
nowTimeStr
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
query
,
update
,
GalaxyNftOrderVo
.
class
,
GalaxyNftOrderVo
.
class
.
getSimpleName
());
log
.
info
(
"updateNftOrderInfo result:{}"
,
result
.
toString
());
try
{
queueUtil
.
sendMySqlRedis
(
SqlMapping
.
get
(
"galaxy_nft_order_info.updateNftBuyTaskId"
),
new
Object
[]{
nftOrderBo
.
getNftBuyTaskId
(),
LocalDateTime
.
now
(),
nftOrderBo
.
getNftOrderPayId
()}
,
MQConst
.
GalaxyQueue
.
SQL_NFT_TRADE_INFO
.
getKey
()
);
}
catch
(
Exception
e
){
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
"#setNftTradeInfo error ==> MESSAGE:{}"
,
e
.
getMessage
());
}
}
}
liquidnet-bus-service/liquidnet-service-consumer-all/liquidnet-service-consumer-galaxy/src/main/java/com/liquidnet/service/consumer/galaxy/utils/QueueUtil.java
0 → 100644
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
consumer
.
galaxy
.
utils
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.galaxy.utils.ObjectUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: QueueUtil
* @Package com.liquidnet.service.galaxy.utils
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/25 15:35
*/
@Component
public
class
QueueUtil
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
/**
* 给 REDIS 队列发送消息 数据库相关
*
* @param sql sql语句
* @param data 需要操作的数据
* @return
*/
public
boolean
sendMySqlRedis
(
String
sql
,
Object
[]
data
,
String
redisKey
)
{
try
{
LinkedList
<
String
>
sqls
=
ObjectUtil
.
cloneLinkedListStr
();
sqls
.
add
(
sql
);
LinkedList
<
Object
[]>
sqlsData
=
ObjectUtil
.
cloneLinkedListObj
();
sqlsData
.
add
(
data
);
String
sqlData
=
SqlMapping
.
gets
(
sqls
,
sqlsData
);
HashMap
<
String
,
String
>
map
=
ObjectUtil
.
cloneHashMapStringAndString
();
map
.
put
(
"message"
,
sqlData
);
MapRecord
<
String
,
String
,
String
>
record
=
StreamRecords
.
mapBacked
(
map
).
withStreamKey
(
redisKey
);
stringRedisTemplate
.
opsForStream
().
add
(
record
);
return
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
}
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/controller/GalaxyTradeController.java
View file @
d9b88b7f
...
...
@@ -51,13 +51,21 @@ public class GalaxyTradeController {
return
galaxyTradeService
.
nftBuyResultQuery
(
reqDto
);
}
// @ControllerLog(description = "NFT购买(发行+购买)")
// @ApiOperationSupport(order = 1)
// @ApiOperation(value = "NFT购买(发行+购买)")
// @PostMapping(value = {"nftPublishAndBuy"})
// public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(@Valid @RequestBody GalaxyNftPublishAndBuyReqDto reqDto){
// return galaxyTradeService.nftPublishAndBuy(reqDto);
// }
@ControllerLog
(
description
=
"NFT购买(发行+购买)"
)
@ApiOperationSupport
(
order
=
1
)
@ApiOperation
(
value
=
"NFT购买(发行+购买)"
)
@PostMapping
(
value
=
{
"nftPublishAndBuy"
})
public
ResponseDto
<
GalaxyNftPublishAndBuyRespDto
>
nftPublishAndBuy
(
@Valid
@RequestBody
GalaxyNftPublishAndBuyReqDto
reqDto
){
return
galaxyTradeService
.
nftPublishAndBuy
(
reqDto
);
}
@ControllerLog
(
description
=
"NFT发行购买结果查询"
)
@ApiOperationSupport
(
order
=
1
)
@ApiOperation
(
value
=
"NFT发行购买结果查询"
)
@PostMapping
(
value
=
{
"nftPublishAndBuyResultQuery"
})
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
@Valid
@RequestBody
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
){
return
galaxyTradeService
.
nftPublishAndBuyResultQuery
(
reqDto
);
}
// @ControllerLog(description = "NFT购买支付结果查询")
// @ApiOperationSupport(order = 1)
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/biz/ZxinTradeBiz.java
View file @
d9b88b7f
...
...
@@ -273,6 +273,35 @@ public class ZxinTradeBiz {
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 查询订单相关信息
*/
//3.2.5查询NFT购买支付结果
// Nft045BuyPayResultReqDto nft045ReqDto = Nft045BuyPayResultReqDto.getNew();
// nft045ReqDto.setTaskId(nftOrderBo.getNftBuyPayTaskId());
// ZxlnftResponseDto<Nft045BuyPayResultRespDto> nft045RespDto = zxlnftSdkUtil.nft045BuyPayResult(nft045ReqDto);
GalaxyNftPublishAndBuyResultQueryRespDto
resultQueryRespDto
=
GalaxyNftPublishAndBuyResultQueryRespDto
.
getNew
();
// BeanUtil.copy(nft045RespDto.getData(),resultQueryRespDto);
// String nowTimeStr = DateUtil.format(new Date(nft045RespDto.getData().getChainTimestamp().longValue()*1000),DateUtil.Formatter.yyyyMMddHHmmss);
//转换任务状态
// Integer taskStatus = Integer.valueOf(GalaxyEnumBiz.getTaskStatusEnum(reqDto.getRouterType(),nft045RespDto.getData().getTaskStatus().toString()).getCode());
return
ResponseDto
.
success
(
resultQueryRespDto
);
}
private
GalaxyNftBuyRespDto
nftBuyBusiness
(
String
routerType
,
String
nftId
,
GalaxyUserInfoBo
userInfoBo
,
GalaxySeriesNftInfoBo
seriesNftInfoBo
,
GalaxyNftOrderBo
nftOrderBo
){
// 3.2.2调用购买NFT接口
Nft043BuyReqDto
nft043BuyReqDto
=
Nft043BuyReqDto
.
getNew
();
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/router/zxin/service/GalaxyRouterStrategyZxlTradeImpl.java
View file @
d9b88b7f
...
...
@@ -41,6 +41,11 @@ public class GalaxyRouterStrategyZxlTradeImpl implements IGalaxyRouterStrategyTr
return
zxinTradeBiz
.
nftBuyPayResultQuery
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
)
{
return
zxinTradeBiz
.
nftPublishAndBuyResultQuery
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftBuyRespDto
>
nftBuy
(
GalaxyNftBuyReqDto
reqDto
)
{
return
zxinTradeBiz
.
nftBuy
(
reqDto
);
...
...
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/service/impl/GalaxyTradeServiceImpl.java
View file @
d9b88b7f
...
...
@@ -42,4 +42,9 @@ public class GalaxyTradeServiceImpl implements IGalaxyTradeService {
public
ResponseDto
<
GalaxyNftBuyPayResultQueryRespDto
>
nftBuyPayResultQuery
(
GalaxyNftBuyPayResultQueryReqDto
reqDto
)
{
return
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftBuyPayResultQuery
(
reqDto
);
}
@Override
public
ResponseDto
<
GalaxyNftPublishAndBuyResultQueryRespDto
>
nftPublishAndBuyResultQuery
(
GalaxyNftPublishAndBuyResultQueryReqDto
reqDto
)
{
return
galaxyRouterStrategyContext
.
getTradeStrategy
(
reqDto
.
getRouterType
()).
nftPublishAndBuyResultQuery
(
reqDto
);
}
}
liquidnet-bus-service/liquidnet-service-galaxy/liquidnet-service-galaxy-impl/src/main/java/com/liquidnet/service/galaxy/utils/ObjectUtil.java
View file @
d9b88b7f
package
com
.
liquidnet
.
service
.
galaxy
.
utils
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ObjectUtil
* @Package com.liquidnet.service.dragon.utils
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 16:00
*/
@Component
public
class
ObjectUtil
{
private
static
final
LinkedList
<
Object
[]>
linkedListObj
=
new
LinkedList
<
Object
[]>();
private
static
final
LinkedList
<
String
>
linkedListStr
=
new
LinkedList
<
String
>();
private
static
final
HashMap
<
String
,
String
>
hashMapStringAndString
=
new
HashMap
<>();
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
LinkedMultiValueMap
<
String
,
String
>
linkedMultiValueMapStringAndString
=
new
LinkedMultiValueMap
<
String
,
String
>();
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
}
public
static
LinkedList
<
String
>
cloneLinkedListStr
()
{
return
(
LinkedList
<
String
>)
linkedListStr
.
clone
();
}
public
static
HashMap
<
String
,
String
>
cloneHashMapStringAndString
()
{
return
(
HashMap
<
String
,
String
>)
hashMapStringAndString
.
clone
();
}
public
static
HashMap
<
String
,
Object
>
cloneHashMapStringAndObj
()
{
return
(
HashMap
<
String
,
Object
>)
hashMapStringAndObj
.
clone
();
}
public
static
JSONObject
cloneJsonObjectObj
()
{
return
(
JSONObject
)
jsonObjectObj
.
clone
();
}
public
static
LinkedMultiValueMap
<
String
,
String
>
cloneLinkedMultiValueMapStringAndString
()
{
return
linkedMultiValueMapStringAndString
.
clone
();
}
}
//
package com.liquidnet.service.galaxy.utils;
//
//
import com.alibaba.fastjson.JSONObject;
//
import org.springframework.stereotype.Component;
//
import org.springframework.util.LinkedMultiValueMap;
//
//
import java.util.HashMap;
//
import java.util.LinkedList;
//
/
//
**
//
* @author AnJiabin <anjiabin@zhengzai.tv>
//
* @version V1.0
//
* @Description: TODO
//
* @class: ObjectUtil
//
* @Package com.liquidnet.service.dragon.utils
//
* @Copyright: LightNet @ Copyright (c) 2021
//
* @date 2022/3/15 16:00
//
*/
//
@Component
//
public class ObjectUtil {
//
private static final LinkedList<Object[]> linkedListObj = new LinkedList<Object[]>();
//
private static final LinkedList<String> linkedListStr = new LinkedList<String>();
//
private static final HashMap<String, String> hashMapStringAndString = new HashMap<>();
//
private static final HashMap<String, Object> hashMapStringAndObj = new HashMap<>();
//
private static final JSONObject jsonObjectObj = new JSONObject();
//
private static final LinkedMultiValueMap<String, String> linkedMultiValueMapStringAndString = new LinkedMultiValueMap<String, String>();
//
//
public static LinkedList<Object[]> cloneLinkedListObj() {
//
return (LinkedList<Object[]>) linkedListObj.clone();
//
}
//
//
public static LinkedList<String> cloneLinkedListStr() {
//
return (LinkedList<String>) linkedListStr.clone();
//
}
//
//
public static HashMap<String, String> cloneHashMapStringAndString() {
//
return (HashMap<String, String>) hashMapStringAndString.clone();
//
}
//
//
public static HashMap<String, Object> cloneHashMapStringAndObj() {
//
return (HashMap<String, Object>) hashMapStringAndObj.clone();
//
}
//
//
public static JSONObject cloneJsonObjectObj() {
//
return (JSONObject) jsonObjectObj.clone();
//
}
//
//
public static LinkedMultiValueMap<String, String> cloneLinkedMultiValueMapStringAndString() {
//
return linkedMultiValueMapStringAndString.clone();
//
}
//
}
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