记得上下班打卡 | git大法好,push需谨慎

Commit d9b88b7f authored by anjiabin's avatar anjiabin

合并发行与购买

parent 9f4e12d2
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();
}
}
}
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();
}
}
}
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();
}
}
}
......@@ -21,4 +21,6 @@ public interface IGalaxyTradeService {
ResponseDto<GalaxyNftBuyResultQueryRespDto> nftBuyResultQuery(GalaxyNftBuyResultQueryReqDto reqDto);
ResponseDto<GalaxyNftBuyPayResultQueryRespDto> nftBuyPayResultQuery(GalaxyNftBuyPayResultQueryReqDto reqDto);
ResponseDto<GalaxyNftPublishAndBuyResultQueryRespDto> nftPublishAndBuyResultQuery(GalaxyNftPublishAndBuyResultQueryReqDto reqDto);
}
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();
}
}
......@@ -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;
......
......@@ -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>
......
......@@ -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.SqlRedisSqlSeriesInfoReceiver;
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 SqlRedisSqlSeriesInfoReceiver sqlSeriesInfoReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
......
......@@ -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.SqlRedisSqlSeriesInfoReceiver;
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 SqlRedisSqlSeriesInfoReceiver sqlSeriesInfoReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
......
......@@ -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.SqlRedisSqlSeriesInfoReceiver;
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 SqlRedisSqlSeriesInfoReceiver sqlSeriesInfoReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
......
......@@ -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.SqlRedisSqlUserInfoReceiver;
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 SqlRedisSqlUserInfoReceiver sqlUserInfoReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
......
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();
}
......@@ -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 AbstractSqlRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
@Autowired
private IBaseDao baseDao;
@Autowired
......
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();
}
}
......@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisSqlNftOrderInfoReceiver extends AbstractRedisReceiver {
public class SqlRedisSqlNftOrderInfoReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
......
......@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisSqlNftTradeInfoReceiver extends AbstractRedisReceiver {
public class SqlRedisSqlNftTradeInfoReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
......
......@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisSqlSeriesInfoReceiver extends AbstractRedisReceiver {
public class SqlRedisSqlSeriesInfoReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
......
......@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class RedisSqlUserInfoReceiver extends AbstractRedisReceiver {
public class SqlRedisSqlUserInfoReceiver extends AbstractSqlRedisReceiver {
@Override
protected String getRedisStreamKey() {
......
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());
}
}
}
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;
}
}
}
......@@ -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)
......
......@@ -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();
......
......@@ -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);
......
......@@ -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);
}
}
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();
// }
//}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment