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

Commit 2d6b4c23 authored by 胡佳晨's avatar 胡佳晨

Merge branch 'dev_notice_0708' into dev_bd_rm_consumer_od

# Conflicts:
#	liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/src/main/java/com/liquidnet/service/kylin/controller/InnerController.java
parents f6769c31 19e66f15
......@@ -7,6 +7,7 @@ public class AdamEnum {
public enum BizAcct {
IMHX("imhx", "即时通讯-环信"),
NFT_ZX("nft_zx", "NFT-至信链"),
NFT_XUPER("nft_xuper", "NFT-百度超级链"),
;
private final String code;
private final String desc;
......
......@@ -23,6 +23,7 @@ public class GalaxyConstant {
public static final String REDIS_KEY_GALAXY_PUBLISH_NFT="galaxy:publish:nft:"; //nft索引递增记录
public static final String SERIES_NAME_PREFIX="NOW_ZXL_";// 系列存储目录名称和系列声明
public static final String SERIES_NAME_XUPER_PREFIX="NOW_XUPER_";// 系列存储目录名称和系列声明
public static final String ADAM_USER_SYNC_URL="/adam/rsc/syn/certmeta";// adam用户开通数字账户信息同步url
......
......@@ -148,6 +148,42 @@ public class GalaxyEnum {
}
}
/**
* 标记任务状态
*/
public enum AssetPublishStatusEnum{
INIT("-1","数据初始化"),
PROCESSING("0","发行中"),
SUCCESS("1","发行成功"),
FAIL("2","发行失败");
private String code;
private String message;
AssetPublishStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public AssetPublishStatusEnum getEnumByCode(String code){
AssetPublishStatusEnum[] arry = AssetPublishStatusEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
public String getMessage(){
return message;
}
}
/**
* 标记任务状态
*/
......
......@@ -71,6 +71,16 @@ public class GalaxySeriesNftInfoBo implements Serializable,Cloneable {
*/
private String originalDisplayUrl;
/**
* nft发行状态
*/
private String nftPublishStatus;
/**
* nft发行交易hash
*/
private String nftPublishTradeHash;
//======================================
//=============以下都为购买信息=============
//======================================
......
......@@ -39,6 +39,11 @@ public class GalaxySeriesNftUploadBo implements Serializable,Cloneable {
*/
private String displayUrl;
/**
* nft介质hash值
*/
private String nftHashStr;
/**
* 创建时间
*/
......
......@@ -69,6 +69,45 @@ public class GalaxyQuerySeriesInfoRespDto implements Serializable,Cloneable {
return JsonUtils.toJson(this);
}
/**
* 以下为百度链新增字段****开始***********
*/
/**
* nft介质访问url
*/
@ApiModelProperty(position = 1, required = true, value = "nft介质访问url")
private String nftUrl;
/**
* nft缩略图icon
*/
@ApiModelProperty(position = 1, required = true, value = "nft缩略图icon")
private String nftThumbIcon;
/**
* nft缩略图url1
*/
@ApiModelProperty(position = 1, required = true, value = "nft缩略图url1")
private String nftThumbUrl1;
/**
* nft缩略图url2
*/
@ApiModelProperty(position = 1, required = true, value = "nft缩略图url2")
private String nftThumbUrl2;
/**
* nft缩略图url3
*/
@ApiModelProperty(position = 1, required = true, value = "nft缩略图url3")
private String nftThumbUrl3;
/**
* 以下为百度链新增字段****结束***********
*/
private static final GalaxyQuerySeriesInfoRespDto obj = new GalaxyQuerySeriesInfoRespDto();
public static GalaxyQuerySeriesInfoRespDto getNew() {
......
......@@ -22,12 +22,20 @@ import java.io.Serializable;
@Data
public class GalaxyUserBindStatusQueryReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
/**
* nftOrderPayId
* 用户id
*/
@ApiModelProperty(position = 1, required = true, value = "用户区块链地址")
@NotBlank(message = "用户区块链地址不能为空!")
@Size(min = 2, max = 100, message = "用户区块链地址不能超过100个字符")
private String blockChainAddress;
@ApiModelProperty(position = 1, required = true, value = "用户ID[30]")
@NotBlank(message = "用户ID不能为空!")
@Size(min = 1, max = 30, message = "用户ID限制2-30位且不能包含特殊字符")
private String userId;
// /**
// * nftOrderPayId
// */
// @ApiModelProperty(position = 1, required = true, value = "用户区块链地址")
// @NotBlank(message = "用户区块链地址不能为空!")
// @Size(min = 2, max = 100, message = "用户区块链地址不能超过100个字符")
// private String blockChainAddress;
@Override
public String toString(){
......
......@@ -19,6 +19,9 @@ import java.io.Serializable;
@ApiModel(value = "GalaxyUserBindStatusQueryRespDto", description = "用户绑定状态查询")
@Data
public class GalaxyUserBindStatusQueryRespDto implements Serializable,Cloneable {
@ApiModelProperty(position = 1, required = true, value = "用户ID[30]")
private String userId;
@ApiModelProperty(position = 3, required = true, value = "用户区块链地址")
private String blockChainAddress;
......
......@@ -27,8 +27,8 @@ public class GoblinStoreMgtDigitalGoodsAddSkuParam implements Serializable {
@ApiModelProperty(position = 12, required = false, value = "单品ID,编辑时必传")
private String skuId;
@ApiModelProperty(position = 12, required = false, value = "NFT区块链[zxinchain-至信链]", allowableValues = "zxinchain", example = "zxinchain")
@Pattern(regexp = "\\b(zxinchain)\\b", message = "NFT区块链参数无效")
@ApiModelProperty(position = 12, required = false, value = "NFT区块链[zxinchain-至信链|xuper-百度链]", allowableValues = "zxinchain,xuper", example = "zxinchain")
@Pattern(regexp = "\\b(zxinchain|xuper)\\b", message = "NFT区块链参数无效")
private String routeType;
@ApiModelProperty(position = 13, required = true, value = "藏品名称[36]", example = "藏品名称...")
......
package com.liquidnet.service.goblin.dto.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinGoodsAnticipateValueVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author TT
*/
@ApiModel(value = "NoticeGoblinGoodsSkuInfoVo", description = "票务")
@Data
public class NoticeGoblinGoodsSkuInfoVo implements Serializable, Cloneable {
@ApiModelProperty(value = "商品单品ID")
private String skuId;
@ApiModelProperty(value = "商品ID[64]")
private String spuId;
@ApiModelProperty(value = "单品的编号[45]")
private String skuNo;
@ApiModelProperty(value = "商品类型[0-常规|1-数字藏品]")
private int skuType;
@ApiModelProperty(value = "单品的名称[100]")
private String name;
@ApiModelProperty(value = "单品的副标题[128]")
private String subtitle;
@ApiModelProperty(value = "单品默认图片的URL[256]")
private String skuPic;
@ApiModelProperty(value = "单品详情展示文件URL[256]")
private String skuWatch;
@ApiModelProperty(value = "展示文件类型[1-图片|2-视频|3-模型]")
private String watchType;
@ApiModelProperty(value = "展示预览图片URL[256]")
private String skuWatchPic;
@ApiModelProperty(value = "素材原始文件类型[1-图片|2-视频|3-模型]")
private String materialType;
@ApiModelProperty(value = "素材原始文件URL")
private String materialUrl;
@ApiModelProperty(value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice;
@ApiModelProperty(value = "单品现价[20,2]")
private BigDecimal price;
@ApiModelProperty(value = "IOS商品价格[20,2]")
private BigDecimal priceV;
@ApiModelProperty(value = "IOS商品价格ID")
private String productId;
@ApiModelProperty(value = "单品会员价格[20,2]")
private BigDecimal priceMember;
@ApiModelProperty(value = "NFT路由")
private String routeType;
@ApiModelProperty(value = "NFT上传声明状态[0-待上传|1-已声明|2-声明失败|9-声明中]")
private Integer upchain;
@ApiModelProperty(value = "NFT预览图访问URL")
private String displayUrl;
@ApiModelProperty(value = "NFT素材访问URL")
private String nftUrl;
@ApiModelProperty(value = "NFT系列ID")
private String seriesId;
@ApiModelProperty(value = "NFT系列HASH")
private String seriesHash;
@ApiModelProperty(value = "NFT藏品HASH")
private String nftHash;
@ApiModelProperty(value = "NFT系列声明时间")
private String declareAt;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(value = "开售时间")
private LocalDateTime saleStartTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(value = "停售时间")
private LocalDateTime saleStopTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(value = "预约开始时间")
private LocalDateTime aboutStartTime;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
@ApiModelProperty(value = "预约停止时间")
private LocalDateTime aboutStopTime;
@ApiModelProperty(value = "上架处理方式[1-等待手动上架|2-直接上架售卖|3-预约定时上架]")
private String shelvesHandle;
@ApiModelProperty(value = "预约上架时间[上架处理方式为3-预约定时上架时需要指定]")
private String shelvesTime;
@ApiModelProperty(position = 62, value = "标签[0-提前购买|1-分段购买|2-预约|3-普通数字藏品]")
private Integer tagType;
@ApiModelProperty(position = 70, value = "分批购活动id")
private String listId;
@ApiModelProperty(position = 12, value = "创作者")
private String author;
@ApiModelProperty(position = 13, value = "发行方")
private String publisher;
private static final NoticeGoblinGoodsSkuInfoVo obj = new NoticeGoblinGoodsSkuInfoVo();
public static NoticeGoblinGoodsSkuInfoVo getNew() {
try {
return (NoticeGoblinGoodsSkuInfoVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new NoticeGoblinGoodsSkuInfoVo();
}
}
public NoticeGoblinGoodsSkuInfoVo copy(GoblinGoodsSkuInfoVo goblinGoodsSkuInfoVo) {
if (null == goblinGoodsSkuInfoVo) return getNew();
this.declareAt = goblinGoodsSkuInfoVo.getDeclareAt();
this.displayUrl = goblinGoodsSkuInfoVo.getDisplayUrl();
this.price = goblinGoodsSkuInfoVo.getPrice();
this.materialType = goblinGoodsSkuInfoVo.getMaterialType();
this.materialUrl = goblinGoodsSkuInfoVo.getMaterialUrl();
this.name = goblinGoodsSkuInfoVo.getName();
this.nftHash = goblinGoodsSkuInfoVo.getNftHash();
this.nftUrl = goblinGoodsSkuInfoVo.getNftUrl();
this.priceV = goblinGoodsSkuInfoVo.getPriceV();
this.priceMember = goblinGoodsSkuInfoVo.getPriceMember();
this.productId = goblinGoodsSkuInfoVo.getProductId();
this.routeType = goblinGoodsSkuInfoVo.getRouteType();
this.saleStartTime = goblinGoodsSkuInfoVo.getSaleStartTime();
this.saleStopTime = goblinGoodsSkuInfoVo.getSaleStopTime();
this.sellPrice = goblinGoodsSkuInfoVo.getSellPrice();
this.seriesHash = goblinGoodsSkuInfoVo.getSeriesHash();
this.seriesId = goblinGoodsSkuInfoVo.getSeriesId();
this.skuId = goblinGoodsSkuInfoVo.getSkuId();
this.skuNo = goblinGoodsSkuInfoVo.getSkuNo();
this.skuPic = goblinGoodsSkuInfoVo.getSkuPic();
this.skuType = goblinGoodsSkuInfoVo.getSkuType();
this.spuId = goblinGoodsSkuInfoVo.getSpuId();
this.skuWatch = goblinGoodsSkuInfoVo.getSkuWatch();
this.skuWatchPic = goblinGoodsSkuInfoVo.getSkuWatchPic();
this.subtitle = goblinGoodsSkuInfoVo.getSubtitle();
this.upchain = goblinGoodsSkuInfoVo.getUpchain();
this.watchType = goblinGoodsSkuInfoVo.getWatchType();
this.shelvesHandle = goblinGoodsSkuInfoVo.getShelvesHandle();
this.shelvesTime = goblinGoodsSkuInfoVo.getShelvesTime();
return this;
}
public NoticeGoblinGoodsSkuInfoVo valueCopy(GoblinGoodsAnticipateValueVo valueVo) {
if (null == valueVo) return getNew();
this.aboutStartTime = valueVo.getAboutStartDate();
this.aboutStopTime = valueVo.getAboutEndDate();
return this;
}
}
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author TT
*/
@ApiModel(value = "NoticeGoblinMixDetailsItemVo", description = "票务")
@Data
public class NoticeGoblinMixDetailsItemVo implements Serializable, Cloneable {
@ApiModelProperty(value = "spuId")
private String spuId;
@ApiModelProperty(value = "skuId")
private String skuId;
@ApiModelProperty(value = "skuId")
private String skuPic;
@ApiModelProperty(value = "sku名称")
private String skuName;
@ApiModelProperty(value = "spu名称")
private String spuName;
@ApiModelProperty(value = "商品类型[1-商城|2-数字藏品]")
private String position;
@ApiModelProperty(value = "sku原价")
private BigDecimal skuPrice;
@ApiModelProperty(value = "组合价格")
private BigDecimal price;
@ApiModelProperty(value = "苹果价格")
private BigDecimal priceV;
@ApiModelProperty(value = "苹果价格id")
private String productId;
@ApiModelProperty(value = "组合件数[数字藏品不能大于1]")
private Integer count;
private static final NoticeGoblinMixDetailsItemVo obj = new NoticeGoblinMixDetailsItemVo();
public static NoticeGoblinMixDetailsItemVo getNew() {
try {
return (NoticeGoblinMixDetailsItemVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new NoticeGoblinMixDetailsItemVo();
}
}
public NoticeGoblinMixDetailsItemVo copy(GoblinMixDetailsItemVo goblinMixDetailsItemVo){
if (null==goblinMixDetailsItemVo) return getNew();
this.count = goblinMixDetailsItemVo.getCount();
this.position = goblinMixDetailsItemVo.getPosition();
this.priceV = goblinMixDetailsItemVo.getPriceV();
this.price = goblinMixDetailsItemVo.getPrice();
this.productId = goblinMixDetailsItemVo.getProductId();
this.skuId = goblinMixDetailsItemVo.getSkuId();
this.skuName = goblinMixDetailsItemVo.getSkuName();
this.skuPic = goblinMixDetailsItemVo.getSkuPic();
this.skuPrice = goblinMixDetailsItemVo.getSkuPrice();
this.spuId = goblinMixDetailsItemVo.getSpuId();
this.spuName = goblinMixDetailsItemVo.getSpuName();
return this;
}
}
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author TT
*/
@ApiModel(value = "NoticeGoblinMixDetailsVo", description = "票务")
@Data
public class NoticeGoblinMixDetailsVo implements Serializable, Cloneable {
@ApiModelProperty(value = "活动id")
private String mixId;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "活动名称")
private String name;
@ApiModelProperty(value = "开始时间")
private String timeStart;
@ApiModelProperty(value = "结束时间")
private String timeEnd;
@ApiModelProperty(value = "展示位置[1-商城|2-数字藏品]")
private Integer showPosition;
@ApiModelProperty(value = "组合名称")
private String sellName;
@ApiModelProperty(value = "封面图片地址")
private String coverPic;
@ApiModelProperty(value = "展示文件类型[1-图片|2-视频]")
private Integer watchType;
@ApiModelProperty(value = "销售价格")
private BigDecimal sellPrice;
@ApiModelProperty(value = "原价")
private BigDecimal price;
@ApiModelProperty(value = "配置详情")
private List<NoticeGoblinMixDetailsItemVo> item;
private static final NoticeGoblinMixDetailsVo obj = new NoticeGoblinMixDetailsVo();
public static NoticeGoblinMixDetailsVo getNew() {
try {
return (NoticeGoblinMixDetailsVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new NoticeGoblinMixDetailsVo();
}
}
public NoticeGoblinMixDetailsVo copy(GoblinMixDetailsVo goblinMixDetailsVo) {
if (null == goblinMixDetailsVo) return getNew();
this.coverPic = goblinMixDetailsVo.getCoverPic();
this.item = goblinMixDetailsVo.getItem().stream().map(goblinMixDetailsItemVo -> {
return NoticeGoblinMixDetailsItemVo.getNew().copy(goblinMixDetailsItemVo);
}).collect(Collectors.toList());
this.price = goblinMixDetailsVo.getPrice();
this.mixId = goblinMixDetailsVo.getMixId();
this.timeEnd = goblinMixDetailsVo.getTimeEnd();
this.name = goblinMixDetailsVo.getName();
this.sellName = goblinMixDetailsVo.getSellName();
this.sellPrice = goblinMixDetailsVo.getSellPrice();
this.showPosition = goblinMixDetailsVo.getShowPosition();
this.timeStart = goblinMixDetailsVo.getTimeStart();
this.userId = goblinMixDetailsVo.getUserId();
this.watchType = goblinMixDetailsVo.getWatchType();
return this;
}
}
......@@ -7,6 +7,7 @@ public class KylinRedisConst {
public static final String PERFORMANCES_LIST_CITY = "kylin:performances:city:";
public static final String PERFORMANCES_LIST_SYSTEM_RECOMMEND = "kylin:performances:systemRecommend";
public static final String PERFORMANCES_LIST_NOTICE = "kylin:performances:notice";
public static final String PERFORMANCES_LIST_NOTICE_IDS = "kylin:performances:notice:ids";
public static final String PERFORMANCES_LIST_RECOMMEND = "kylin:performances:recommend";
public static final String PERFORMANCES_LIST_EXCLUSIVE = "kylin:performances:exclusive";
public static final String PERFORMANCES_ROADLIST = "kylin:performances:roadShowId:";
......
package com.liquidnet.service.kylin.dto.vo.returns;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinPerformanceVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author TT
*/
@ApiModel(value = "NoticeKylinPerformanceVo", description = "票务")
@Data
public class NoticeKylinPerformanceVo implements Serializable, Cloneable {
private Integer mid;
@ApiModelProperty(value = "主键")
private String performancesId;
@ApiModelProperty(value = "演出名称")
private String title;
@ApiModelProperty(value = "演出图片")
private String imgPoster;
@ApiModelProperty(value = "演出开始时间")
private String timeStart;
@ApiModelProperty(value = "演出结束时间")
private String timeEnd;
@ApiModelProperty(value = "停售时间")
private String stopSellTime;
@ApiModelProperty(value = "价格")
private String price;
@ApiModelProperty(value = "开售时间")
private String sellTime;
@ApiModelProperty(value = "城市id")
private Integer cityId;
@ApiModelProperty(value = "城市名称")
private String cityName;
@ApiModelProperty(value = "场地id")
private String fieldId;
@ApiModelProperty(value = "场地名称")
private String fieldName;
@ApiModelProperty(value = "搭售id")
private String projectId;
@ApiModelProperty(value = "巡演id")
private String roadShowId;
private static final NoticeKylinPerformanceVo obj = new NoticeKylinPerformanceVo();
public static NoticeKylinPerformanceVo getNew() {
try {
return (NoticeKylinPerformanceVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new NoticeKylinPerformanceVo();
}
}
public NoticeKylinPerformanceVo copy(KylinPerformanceVo kylinPerformanceVo){
if (null == kylinPerformanceVo) return getNew();
this.mid = kylinPerformanceVo.getMid();
this.cityId = kylinPerformanceVo.getCityId();
this.cityName = kylinPerformanceVo.getCityName();
this.performancesId = kylinPerformanceVo.getPerformancesId();
this.fieldId = kylinPerformanceVo.getFieldId();
this.fieldName = kylinPerformanceVo.getFieldName();
this.imgPoster = kylinPerformanceVo.getImgPoster();
this.price = kylinPerformanceVo.getPrice();
this.projectId = kylinPerformanceVo.getProjectId();
this.roadShowId = kylinPerformanceVo.getRoadShowId();
this.sellTime = kylinPerformanceVo.getSellTime();
this.stopSellTime = kylinPerformanceVo.getStopSellTime();
this.timeEnd = kylinPerformanceVo.getTimeEnd();
this.timeStart = kylinPerformanceVo.getTimeStart();
this.title = kylinPerformanceVo.getTitle();
return this;
}
}
......@@ -24,4 +24,5 @@ public interface IKylinPerformancesService {
ResponseDto<String> subscribe(String performancesId, Integer sourceType);
ResponseDto<Integer> isSubscribe(String performancesId);
}
......@@ -117,6 +117,10 @@ public class IDGenerator {
return "ZXLNFTIMAGE" + nextTimeId();
}
public static String getXuperNftImageCosCode() {
return "XUPERNFTIMAGE" + nextTimeId();
}
public static String refundCode() {
return "RED" + nextTimeId();
}
......
<?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.liquidnet</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.liquidnet</groupId>
<artifactId>liquidnet-common-base</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</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
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;
}
}
package com.liquidnet.common.third.xuper.config;
import com.baidu.xasset.client.xasset.Asset;
import com.baidu.xasset.common.config.Config;
import com.liquidnet.commons.lang.util.MD5Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
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
*/
@Slf4j
@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;
@Value("${liquidnet.service.galaxy.xuper.nftPlatformMnemonic}")
private String nftPlatformMnemonic;
@Value("${liquidnet.service.galaxy.xuper.nftPlatformAddress}")
private String nftPlatformAddress;
private Asset asset = null;
private static Asset staticAsset = null;
private static Logger logger = Logger.getLogger(XuperConfig.class.getCanonicalName());
@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);
// 初始化接口类
// Logger logger = Logger.getGlobal();
// logger.getParent().setLevel(Level.INFO);
log.info("logger.getParent().getLevel() === {}",logger.getParent().getLevel());
// logger.setLevel(Level.INFO);
log.info("logger.getLevel() === {}",logger.getLevel());
asset = new Asset(cfg, logger);
}
//
// 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;
}
public String getNftPlatformMnemonic() {
return nftPlatformMnemonic;
}
public String getNftPlatformAddress() {
return nftPlatformAddress;
}
}
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 {
}
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;
}
}
/**
* 资产发行状态 1:初始 3:发行中 4:发行成功 5:冻结中 6:已冻结 7:封禁中 8:已封禁
*/
public enum AssetPublishStatusEnum{
INIT("1","初始"),
PUBLISHING("3","发行中"),
PUBLISH_SUCCESS("4","发行成功"),
FREEZING("5","冻结中"),
BANNEDING("6","封禁中"),
BANNEDED("7","已封禁");
private String code;
private String message;
AssetPublishStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public AssetPublishStatusEnum getEnumByCode(String code){
AssetPublishStatusEnum[] arry = AssetPublishStatusEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
public String getMessage(){
return message;
}
}
/**
* 资产授予状态 0:已上链 1:授予中 4:转移中 5: 核销中 6: 已核销 10:异常详情参考错误码和状态码
*/
public enum AssetGrantStatusEnum{
GRANT_SUCCESS("0","已上链"),
GRANTING("1","授予中"),
TRANSFERING("4","转移中"),
CANCELING("5","核销中"),
CANCELED("6","已核销"),
OTHER_ERROR("10","异常详情参考错误码和状态码");
private String code;
private String message;
AssetGrantStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public AssetGrantStatusEnum getEnumByCode(String code){
AssetGrantStatusEnum[] arry = AssetGrantStatusEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
public String getMessage(){
return message;
}
}
}
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();
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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 Xuper004PublishAssetRespDto {
public long requestId;
public int errNo;
public String errMsg;
private static final Xuper004PublishAssetRespDto obj = new Xuper004PublishAssetRespDto();
public static Xuper004PublishAssetRespDto getNew() {
try {
return (Xuper004PublishAssetRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper004PublishAssetRespDto();
}
}
}
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();
}
}
}
package com.liquidnet.common.third.xuper.dto;
import com.alibaba.fastjson.JSONArray;
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;//60
private String url1;//140
private String url2;//360
private String url3;//850
}
private static final Xuper005QueryAssetRespDto obj = new Xuper005QueryAssetRespDto();
public static Xuper005QueryAssetRespDto getNew() {
try {
return (Xuper005QueryAssetRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper005QueryAssetRespDto();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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;
public long assetId;
public long shardId;
private static final Xuper007GrantShardRespDto obj = new Xuper007GrantShardRespDto();
public static Xuper007GrantShardRespDto getNew() {
try {
return (Xuper007GrantShardRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper007GrantShardRespDto();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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 Xuper010QuerySdsRespDto {
public long requestId;
public int errNo;
public String errMsg;
public ShardMeta meta;
@Data
public static class ShardMeta {
public long assetId;
public long shardId;
public String ownerAddr;
public long uid;
public long price;
public int status;
public String txId;
public ShardAssetInfo assetInfo;
public long ctime;
}
@Data
public static class ShardAssetInfo {
public String title;
public int assetCate;
public Thumb[] thumb;
public String shortDesc;
public String createAddr;
public long groupId;
}
@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 Xuper010QuerySdsRespDto obj = new Xuper010QuerySdsRespDto();
public static Xuper010QuerySdsRespDto getNew() {
try {
return (Xuper010QuerySdsRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper010QuerySdsRespDto();
}
}
}
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 Xuper011ListSdsByAddrReqDto {
//要拉取的区块链账户地址
private String addr = "";
//要拉取页数,第一页为1
private int page = 1;
//每页拉取数量,默认20,最大50(可选)
private int limit = 50;
private static final Xuper011ListSdsByAddrReqDto obj = new Xuper011ListSdsByAddrReqDto();
public static Xuper011ListSdsByAddrReqDto getNew() {
try {
return (Xuper011ListSdsByAddrReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper011ListSdsByAddrReqDto();
}
}
}
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 Xuper011ListSdsByAddrRespDto {
public long requestId;
public int errNo;
public String errMsg;
public ArrayList<ShardMeta> list;
public int totalCnt;
@Data
public static class ShardMeta {
public long assetId;
public long shardId;
public String ownerAddr;
public long uid;
public long price;
public int status;
public String txId;
public ShardAssetInfo assetInfo;
public long ctime;
}
@Data
public static class ShardAssetInfo {
public String title;
public int assetCate;
public Thumb[] thumb;
public String shortDesc;
public String createAddr;
public long groupId;
}
@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 Xuper011ListSdsByAddrRespDto obj = new Xuper011ListSdsByAddrRespDto();
public static Xuper011ListSdsByAddrRespDto getNew() {
try {
return (Xuper011ListSdsByAddrRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper011ListSdsByAddrRespDto();
}
}
}
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 Xuper012ListSdsByAstReqDto {
//资产id
private long assetId;
//分页游标,首页设置空字符串,后面的用上页返回的cursor值
private String cursor = "";
//每页拉取数量,默认20,最多50(可选)
private int limit = 20;
private static final Xuper012ListSdsByAstReqDto obj = new Xuper012ListSdsByAstReqDto();
public static Xuper012ListSdsByAstReqDto getNew() {
try {
return (Xuper012ListSdsByAstReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper012ListSdsByAstReqDto();
}
}
}
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 Xuper012ListSdsByAstRespDto {
public long requestId;
public int errNo;
public String errMsg;
public ArrayList<ShardAssetInfo> list;
public int hasMore;
public String cursor;
@Data
public static class ShardAssetInfo {
public long shardId;
public String ownerAddr;
public long price;
public String txId;
public String groupId;
public long ctime;
}
private static final Xuper012ListSdsByAstRespDto obj = new Xuper012ListSdsByAstRespDto();
public static Xuper012ListSdsByAstRespDto getNew() {
try {
return (Xuper012ListSdsByAstRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper012ListSdsByAstRespDto();
}
}
}
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 Xuper013HistoryReqDto {
//资产id
private long assetId;
//要拉取页数,第一页为1
private int page = 1;
//每页拉取数量,默认20,最大50(可选)
private int limit = 20;
private static final Xuper013HistoryReqDto obj = new Xuper013HistoryReqDto();
public static Xuper013HistoryReqDto getNew() {
try {
return (Xuper013HistoryReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper013HistoryReqDto();
}
}
}
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 Xuper013HistoryRespDto {
public long requestId;
public int errNo;
public String errMsg;
public ArrayList<AssetInfo> list;
public int totalCnt;
@Data
public static class AssetInfo {
public long assetId;
public long type;
public long shardId;
public long price;
public String txId;
public String from;
public String to;
public long ctime;
}
private static final Xuper013HistoryRespDto obj = new Xuper013HistoryRespDto();
public static Xuper013HistoryRespDto getNew() {
try {
return (Xuper013HistoryRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper013HistoryRespDto();
}
}
}
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 Xuper014FreezeAssetReqDto {
/**
* 资产id
*/
private Long assetId;
/**
* 助记词
*/
private String mnemonic;
private static final Xuper014FreezeAssetReqDto obj = new Xuper014FreezeAssetReqDto();
public static Xuper014FreezeAssetReqDto getNew() {
try {
return (Xuper014FreezeAssetReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper014FreezeAssetReqDto();
}
}
}
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 Xuper014FreezeAssetRespDto {
public long requestId;
public int errNo;
public String errMsg;
private static final Xuper014FreezeAssetRespDto obj = new Xuper014FreezeAssetRespDto();
public static Xuper014FreezeAssetRespDto getNew() {
try {
return (Xuper014FreezeAssetRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new Xuper014FreezeAssetRespDto();
}
}
}
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();
}
}
}
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();
}
}
}
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);
}
}
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();
}
}
}
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 {
public String link;
public GetStokenResp resp;
public RequestRes res;
@Data
public static class GetStokenResp {
public long requestId;
public int errNo;
public String errMsg;
public AccessInfo accessInfo;
}
@Data
public static class AccessInfo {
public String bucket;
public String endPoint;
public String objectPath;
public String accessKeyId;
public String secreteAccessKey;
public String sessionToken;
public String createTime;
public String expiration;
}
@Data
public static class RequestRes {
public int httpCode;
public String reqUrl;
public String traceId;
public String body;
}
private static final XuperUploadFileRespDto obj = new XuperUploadFileRespDto();
public static XuperUploadFileRespDto getNew() {
try {
return (XuperUploadFileRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new XuperUploadFileRespDto();
}
}
}
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;
}
}
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);
}
}
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);
BaseDef.RequestRes requestRes = uploadFile.res;
if(requestRes.httpCode==200){
log.debug("xuperUploadFile resp : "+ JsonUtils.toJson(uploadFile));
respDto = JsonUtils.fromJson(JsonUtils.toJson(uploadFile),new TypeReference<XuperUploadFileRespDto>(){});
}
log.debug("xuperUploadFile resp : "+ JsonUtils.toJson(respDto));
}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.debug("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.debug("pubKeyStr ===> {}",acc.getKeyPair().getJSONPublicKey());
log.debug("priKeyStr ===> {}",acc.getKeyPair().getJSONPrivateKey());
log.debug("address ===> {}",acc.getAddress());
log.debug("address ===> {}",acc.getMnemonic());
BaseDef.RequestRes requestRes = getStokenResp.res;
if(requestRes.httpCode==200){
log.debug("xuper001GetStoken resp : "+ JsonUtils.toJson(getStokenResp));
log.debug("xuper001GetStoken apiResp : "+ JsonUtils.toJson(getStokenResp.apiResp));
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.debug("xuper002CreateAsset resp : "+ JsonUtils.toJson(createAssetResp));
log.debug("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.debug("xuper003AlterAsset resp : "+ JsonUtils.toJson(alterAssetResp));
log.debug("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.debug("xuper004PublishAsset resp : "+ JsonUtils.toJson(publishAssetResp));
BaseDef.RequestRes requestRes = publishAssetResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper005QueryAsset resp : "+ JsonUtils.toJson(queryAssetResp));
BaseDef.RequestRes requestRes = queryAssetResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper006ListAssetByAddr resp : "+ JsonUtils.toJson(listPageResp));
BaseDef.RequestRes requestRes = listPageResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper007GrantShard resp : "+ JsonUtils.toJson(grantShardResp));
BaseDef.RequestRes requestRes = grantShardResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper008TransferShard resp : "+ JsonUtils.toJson(transferShardResp));
BaseDef.RequestRes requestRes = transferShardResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper009Consume resp : "+ JsonUtils.toJson(consumeShardResp));
BaseDef.RequestRes requestRes = consumeShardResp.res;
if(requestRes.httpCode==200){
log.debug("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.debug("xuper010QuerySds resp : "+ JsonUtils.toJson(queryShardsResp));
BaseDef.RequestRes requestRes = queryShardsResp.res;
if(requestRes.httpCode==200){
log.debug("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 = reqDto.getAddr();
//要拉取页数,第一页为1
int page = reqDto.getPage();
//每页拉取数量,默认20,最大50(可选)
int limit = reqDto.getLimit();
BaseDef.Resp<BaseDef.ListPageResp> listPageResp = getAsset().listShardsAddr(addr, page, limit);
log.debug("xuper011ListSdsByAddr resp : "+ JsonUtils.toJson(listPageResp));
BaseDef.RequestRes requestRes = listPageResp.res;
if(requestRes.httpCode==200){
log.debug("xuper011ListSdsByAddr apiResp : "+ JsonUtils.toJson(listPageResp.apiResp));
respDto = JsonUtils.fromJson(JsonUtils.toJson(listPageResp.apiResp),new TypeReference<Xuper011ListSdsByAddrRespDto>(){});
}
}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 = reqDto.getAssetId();
//分页游标,首页设置空字符串,后面的用上页返回的cursor值
String cursor = reqDto.getCursor();
//每页拉取数量,默认20,最多50(可选)
int limit = reqDto.getLimit();
BaseDef.Resp<BaseDef.ListCursorResp> listCursorResp = getAsset().listShardsByAsset(assetId, cursor, limit);
log.info("xuper012ListSdsByAst resp : "+ JsonUtils.toJson(listCursorResp));
BaseDef.RequestRes requestRes = listCursorResp.res;
if(requestRes.httpCode==200){
log.info("xuper012ListSdsByAst apiResp : "+ JsonUtils.toJson(listCursorResp.apiResp));
respDto = JsonUtils.fromJson(JsonUtils.toJson(listCursorResp.apiResp),new TypeReference<Xuper012ListSdsByAstRespDto>(){});
}
}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 = reqDto.getAssetId();
//要拉取页数,第一页为1
int page = reqDto.getPage();
//每页拉取数量,默认20,最大50(可选)
int limit = reqDto.getLimit();
BaseDef.Resp<BaseDef.ListPageResp> listPageResp = getAsset().history(assetId, page, limit);
log.info("xuper013History resp : "+ JsonUtils.toJson(listPageResp));
BaseDef.RequestRes requestRes = listPageResp.res;
if(requestRes.httpCode==200){
log.info("xuper013History apiResp : "+ JsonUtils.toJson(listPageResp.apiResp));
respDto = JsonUtils.fromJson(JsonUtils.toJson(listPageResp.apiResp),new TypeReference<Xuper013HistoryRespDto>(){});
}
}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 = this.getAccount(reqDto.getMnemonic());;
//资产id
long assetId = reqDto.getAssetId();
BaseDef.Resp<BaseDef.BaseResp> baseResp = getAsset().freezeAsset(assetId, account);
log.info("xuper014FreezeAsset resp : "+ JsonUtils.toJson(baseResp));
BaseDef.RequestRes requestRes = baseResp.res;
if(requestRes.httpCode==200){
log.info("xuper014FreezeAsset apiResp : "+ JsonUtils.toJson(baseResp.apiResp));
respDto = JsonUtils.fromJson(JsonUtils.toJson(baseResp.apiResp),new TypeReference<Xuper014FreezeAssetRespDto>(){});
}
}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> baseResp = getAsset().getEvidenceInfo(assetId);
log.info("xuper015GetEvidenceInfo resp : "+ JsonUtils.toJson(baseResp));
BaseDef.RequestRes requestRes = baseResp.res;
if(requestRes.httpCode==200){
log.info("xuper015GetEvidenceInfo apiResp : "+ JsonUtils.toJson(baseResp.apiResp));
respDto = JsonUtils.fromJson(JsonUtils.toJson(baseResp.apiResp),new TypeReference<Xuper015GetEvidenceInfoRespDto>(){});
}
}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);
}
}
# 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
# 新增转发请求接口路由
xl.al.manager.request.fun = /api/v1/spider/sdk/req/forward
# 新增文件转发接口路由
xl.al.manager.file.request.fun = /api/v1/spider/sdk/req/file/forward
......@@ -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>
......@@ -131,8 +131,9 @@ liquidnet:
url: http://devchime.zhengzai.tv
galaxy:
url: http://devgalaxy.zhengzai.tv
temp-file-path: /data/galaxy/tempFilePath
router: zxinchain,eth
# temp-file-path: /data/galaxy/tempFilePath
temp-file-path: /Users/anjiabin/data/galaxy/tempFilePath
router: zxinchain,xuper
zxlnft:
walletSdkUrl: http://127.0.0.1:30505
nftApiUrl: https://nfttest2.zxinchain.com
......@@ -142,6 +143,13 @@ liquidnet:
nftPlatformPubKey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb0VjejFVQmdpMERRZ0FFbFNTQk00MHJIZlJFa0NjWUxlRm1RZzE0SHlIcAp5Rk9uSktzblFqbDBCL2JXOStFWnZPblArNW0vMEdkUCtXM29yeG5Kd3p5OHNoYS9OYkQ4QVBmNXlBPT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
nftPlatformPriKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR1RBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUJITTlWQVlJdEJIa3dkd0lCQVFRZ1VhbTVWM2V6ZFZJTmNoZ28KVDRKL28zMHArMGJCd3hQWUZFL01FdEU3MTZhZ0NnWUlLb0VjejFVQmdpMmhSQU5DQUFTVkpJRXpqU3NkOUVTUQpKeGd0NFdaQ0RYZ2ZJZW5JVTZja3F5ZENPWFFIOXRiMzRSbTg2Yy83bWIvUVowLzViZWl2R2NuRFBMeXlGcjgxCnNQd0E5L25JCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
platformIdentification: 4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef
xuper:
nftApiUrl: http://120.48.16.137:8360
appId: 110353
accessKeyID: 44b69914377ed77613824781da9e8653
secretAccessKey: 99b946f9dba244e7a3d5bc7a1862ef39
nftPlatformMnemonic: person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe
nftPlatformAddress: YqsYxgBSP74piDhNQHTjWMH9wXnXxZbt8
other:
ticketSystemUrl: http://dev-report.capapiao.com
appId: 11920532
......
......@@ -132,7 +132,7 @@ liquidnet:
galaxy:
# url: http://testgalaxy.zhengzai.tv
temp-file-path: /data/galaxy/tempFilePath
router: zxinchain,eth
router: zxinchain,xuper
zxlnft:
walletSdkUrl: http://127.0.0.1:30505
nftApiUrl: https://nfttest2.zxinchain.com
......@@ -142,6 +142,13 @@ liquidnet:
nftPlatformPubKey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZrd0V3WUhLb1pJemowQ0FRWUlLb0VjejFVQmdpMERRZ0FFbFNTQk00MHJIZlJFa0NjWUxlRm1RZzE0SHlIcAp5Rk9uSktzblFqbDBCL2JXOStFWnZPblArNW0vMEdkUCtXM29yeG5Kd3p5OHNoYS9OYkQ4QVBmNXlBPT0KLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==
nftPlatformPriKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR1RBZ0VBTUJNR0J5cUdTTTQ5QWdFR0NDcUJITTlWQVlJdEJIa3dkd0lCQVFRZ1VhbTVWM2V6ZFZJTmNoZ28KVDRKL28zMHArMGJCd3hQWUZFL01FdEU3MTZhZ0NnWUlLb0VjejFVQmdpMmhSQU5DQUFTVkpJRXpqU3NkOUVTUQpKeGd0NFdaQ0RYZ2ZJZW5JVTZja3F5ZENPWFFIOXRiMzRSbTg2Yy83bWIvUVowLzViZWl2R2NuRFBMeXlGcjgxCnNQd0E5L25JCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
platformIdentification: 4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef
xuper:
nftApiUrl: http://120.48.16.137:8360
appId: 110353
accessKeyID: 44b69914377ed77613824781da9e8653
secretAccessKey: 99b946f9dba244e7a3d5bc7a1862ef39
nftPlatformMnemonic: person lucky trophy wall kangaroo body bounce coach unable sister second goat guitar virus tree security acoustic ankle kiss deputy sunny message weapon believe
nftPlatformAddress: YqsYxgBSP74piDhNQHTjWMH9wXnXxZbt8
other:
ticketSystemUrl: http://dev-report.capapiao.com/
appId: 11920532
......
......@@ -10,7 +10,7 @@ liquidnet:
path: /data/logs
name: service-goblin
max-history: 7
level: debug
level: info
mysql:
database-name: dev_ln_scene
mongodb:
......
......@@ -52,4 +52,8 @@ public interface FeignKylinForChimeClient {
ResponseDto<KylinPerformanceVo> getDetail(
@RequestParam("performancesId") String performancesId
);
@GetMapping("inner/setNoticeIds")
ResponseDto<HashMap<String,Object>> setNoticeIds();
}
package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
import com.liquidnet.service.galaxy.router.xuper.biz.XuperTradeCommonBiz;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinTradeCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,12 +25,21 @@ public class ConsumerGalaxyJsonNftPublishAndBuyProcessor {
@Autowired
private ZxinTradeCommonBiz zxinTradeCommonBiz;
@Autowired
private XuperTradeCommonBiz xuperTradeCommonBiz;
/**
* 执行购买处理
* @param reqDto
* @return
*/
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
return zxinTradeCommonBiz.nftPublishAndBuy(reqDto);
if(reqDto.getRouterType().equalsIgnoreCase(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode())){
return zxinTradeCommonBiz.nftPublishAndBuy(reqDto);
}else if(reqDto.getRouterType().equalsIgnoreCase(GalaxyEnum.RouterTypeEnum.XUPER.getCode())){
return xuperTradeCommonBiz.nftPublishAndBuy(reqDto);
}else{
log.error("nftPublishAndBuy 区块链路由类型不存在 routerType : {}",reqDto.getRouterType());
return ResponseDto.failure();
}
}
}
package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.router.xuper.biz.XuperUserCommonBiz;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,12 +25,22 @@ public class ConsumerGalaxyJsonNftUserRegisterProcessor {
@Autowired
private ZxinUserCommonBiz zxinUserCommonBiz;
@Autowired
private XuperUserCommonBiz xuperUserCommonBiz;
/**
* 执行用户注册
* @param reqDto
* @return
*/
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserCommonBiz.userRegister(reqDto);
if(reqDto.getRouterType().equalsIgnoreCase(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode())){
return zxinUserCommonBiz.userRegister(reqDto);
}else if(reqDto.getRouterType().equalsIgnoreCase(GalaxyEnum.RouterTypeEnum.XUPER.getCode())){
return xuperUserCommonBiz.userRegister(reqDto);
}else{
log.error("userRegister 区块链路由类型不存在 routerType : {}",reqDto.getRouterType());
return ResponseDto.failure();
}
}
}
package com.liquidnet.service.executor.main.handler;
import com.liquidnet.service.feign.kylin.api.FeignKylinForChimeClient;
import com.liquidnet.service.feign.kylin.task.FeignPlatformTaskClient;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
......@@ -19,6 +20,9 @@ public class KylinTaskHandler {
@Autowired
private FeignPlatformTaskClient feignPlatformTaskClient;
@Autowired
private FeignKylinForChimeClient feignKylinForChimeClient;
@XxlJob(value = "sev-platform:checkOrderTimeHandler")
public void checkOrderTimeHandler() {
try {
......@@ -68,4 +72,14 @@ public class KylinTaskHandler {
XxlJobHelper.handleFail();
}
}
@XxlJob(value = "sev-platform:setNoticeIds")
public void setNoticeIds() {
try {
XxlJobHelper.handleSuccess("结果:" + feignKylinForChimeClient.setNoticeIds().getData());
} catch (Exception e) {
XxlJobHelper.log(e);
XxlJobHelper.handleFail();
}
}
}
......@@ -41,5 +41,17 @@
<artifactId>liquidnet-service-adam-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</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>
package com.liquidnet.service.galaxy.biz;
import com.liquidnet.common.third.antchain.constant.AntchainEnum;
import com.liquidnet.common.third.xuper.constant.XuperEnum;
import com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
......@@ -16,7 +17,7 @@ import com.liquidnet.service.galaxy.constant.GalaxyEnum;
public class GalaxyEnumBiz {
/**
* 任务状态转换
* 任务状态转换(至信链通用状态 百度链为系列声明状态转换)
* @param routerType
* @param code
* @return
......@@ -46,6 +47,45 @@ public class GalaxyEnumBiz {
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_FAIL;
break;
}
case "xuper":
if(code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.INIT.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_SUCCESS;
break;
}{
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_FAIL;
break;
}
}
return taskStatusEnum;
}
/**
* 任务状态转换
* @param routerType
* @param code
* @return
*/
public static GalaxyEnum.AssetPublishStatusEnum getAssetPublishStatusEnum(String routerType, String code){
GalaxyEnum.AssetPublishStatusEnum taskStatusEnum = null;
switch (routerType){
case "xuper":
if(code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.INIT.getCode())){
taskStatusEnum = GalaxyEnum.AssetPublishStatusEnum.INIT;
break;
}else if(code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.PUBLISHING.getCode())){
taskStatusEnum = GalaxyEnum.AssetPublishStatusEnum.PROCESSING;
break;
}else if(code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.PUBLISH_SUCCESS.getCode())){
taskStatusEnum = GalaxyEnum.AssetPublishStatusEnum.SUCCESS;
break;
}else if(code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.FREEZING.getCode())
||code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.BANNEDING.getCode())
||code.equalsIgnoreCase(XuperEnum.AssetPublishStatusEnum.BANNEDED.getCode())
){
taskStatusEnum = GalaxyEnum.AssetPublishStatusEnum.FAIL;
break;
}
}
return taskStatusEnum;
}
......@@ -90,4 +130,53 @@ public class GalaxyEnumBiz {
}
return userBindStatusEnum;
}
}
/**
* 资产授予状态转换
* @param routerType
* @param code
* @return
*/
public static GalaxyEnum.TaskStatusEnum getGrantStatusEnum(String routerType, String code){
GalaxyEnum.TaskStatusEnum taskStatusEnum = null;
switch (routerType){
case "zxinchain":
if(code.equalsIgnoreCase(ZxlnftEnum.TaskStatusEnum.PROCESSING.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.PROCESSING;
break;
}else if(code.equalsIgnoreCase(ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_SUCCESS;
break;
}else if(code.equalsIgnoreCase(ZxlnftEnum.TaskStatusEnum.TASK_FAIL.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_FAIL;
break;
}
case "antchain":
if(code.equalsIgnoreCase(AntchainEnum.TaskStatusEnum.PROCESSING.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.PROCESSING;
break;
}else if(code.equalsIgnoreCase(AntchainEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_SUCCESS;
break;
}else if(code.equalsIgnoreCase(AntchainEnum.TaskStatusEnum.TASK_FAIL.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_FAIL;
break;
}
case "xuper":
if(code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.GRANTING.getCode())||code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.TRANSFERING.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.PROCESSING;
break;
}else if(code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.GRANT_SUCCESS.getCode())){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_SUCCESS;
break;
}else if(code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.CANCELING.getCode())
||code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.CANCELED.getCode())
||code.equalsIgnoreCase(XuperEnum.AssetGrantStatusEnum.OTHER_ERROR.getCode())
){
taskStatusEnum = GalaxyEnum.TaskStatusEnum.TASK_FAIL;
break;
}
}
return taskStatusEnum;
}
}
\ No newline at end of file
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.common.third.xuper.config.XuperConfig;
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.common.third.zxlnft.dto.Nft035PublishResultReqDto;
import com.liquidnet.common.third.zxlnft.dto.Nft044BuyResultReqDto;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.biz.GalaxyEnumBiz;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBindBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.*;
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.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 XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@Autowired
private GalaxyDataUtils dataUtils;
@Autowired
private GalaxyBeanTransferBiz galaxyBeanTransferBiz;
/**
* 发行和购买
* @param reqDto
* @return
*/
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);
nftOrderBo.setNftPublishTaskId(seriesNftInfoBo.getSeriesId());
nftOrderBo.setNftPublishFromAddress(xuperConfig.getNftPlatformAddress());
nftOrderBo.setNftBuyFromAddress(xuperConfig.getNftPlatformAddress());
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());
}
}
}
//开始索引
Integer seriesBeginIndex = null;
/**
* 根据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();
/**
* 如果已经发行成功
*/
if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());;
nftPublishChainTimestamp = DateUtil.getNowSeconds();
nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode());
nftPublishTradeHash = publishTaskId;
//设置购买标志
nftOrderBo.setNftId(nftId);
}else if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){
if(StringUtil.isNotEmpty(nftOrderBo.getNftPublishTaskId())){
publishTaskId = nftOrderBo.getNftPublishTaskId();
}
}else if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.INIT.getCode())){
//发行
Xuper004PublishAssetReqDto xuper004PublishAssetReqDto = Xuper004PublishAssetReqDto.getNew();
// 定义返回结果对象
Xuper004PublishAssetRespDto xuper004PublishAssetRespDto = null;
long assetId = Long.parseLong(seriesNftInfoBo.getSeriesId());
try {
xuper004PublishAssetReqDto.setMnemonic(xuperConfig.getNftPlatformMnemonic());
xuper004PublishAssetReqDto.setAssetId(assetId);
XuperResponseDto<Xuper004PublishAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper004PublishAsset(xuper004PublishAssetReqDto);
if(xuperResponseDto.isSuccess()){
xuper004PublishAssetRespDto = 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("xuper004PublishAsset resp : "+ JsonUtils.toJson(xuper004PublishAssetRespDto));
if (Integer.parseInt(ErrorCode.SUCCESS.getCode()) == xuper004PublishAssetRespDto.errNo){
publishTaskId = String.valueOf(assetId);
nftOrderBo.setNftPublishTaskId(publishTaskId);
}
}
if (StringUtil.isNotEmpty(publishTaskId)){
try{
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto nft035ReqDto = Nft035PublishResultReqDto.getNew();
nft035ReqDto.setTaskId(publishTaskId);
int count = 0;
long timeStart = System.currentTimeMillis();
while (StringUtil.isEmpty(nftId)) {
Thread.sleep(500l);
count++;
log.info("=======执行nft发行第{}次查询,taskId:{}", count, nft035ReqDto.getTaskId());
//执行nft发行结果查询
GalaxyNftPublishResultQueryReqDto nftPublishResultQueryReqDto = GalaxyNftPublishResultQueryReqDto.getNew();
nftPublishResultQueryReqDto.setNftOrderPayId(reqDto.getNftOrderPayId());
nftPublishResultQueryReqDto.setRouterType(reqDto.getRouterType());
ResponseDto<GalaxyNftPublishResultQueryRespDto> publishResultQueryRespDto = this.nftPublishResultQuery(nftPublishResultQueryReqDto);
if(publishResultQueryRespDto.isSuccess()){
GalaxyNftPublishResultQueryRespDto nftPublishResultQueryRespDto = publishResultQueryRespDto.getData();
if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())) {
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());;
nftPublishChainTimestamp = DateUtil.getNowSeconds();
nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode());
nftPublishTradeHash = nftPublishResultQueryRespDto.getTxHash();
//首次查询nft发行状态,如果成功更新nft系列发行状态
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode());
seriesNftInfoBo.setNftPublishTradeHash(nftPublishTradeHash);
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
} else if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode())) {
log.info("任务执行失败!taskId:{}", nft035ReqDto.getTaskId());
nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus();
//发行失败
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode());
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
//直接进行异常处理
throw new GalaxyNftPublishException(GalaxyErrorEnum.PUBLISH_FAIL.getCode(), "nft035PublishResult_resp:"+GalaxyErrorEnum.PUBLISH_FAIL.getMessage());
}else if(nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){
log.info("任务执行中!taskId:{}", nft035ReqDto.getTaskId());
nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus();
//发行中
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode());
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
}
}
if (count == 20) {
log.info("=======查询共20次,跳出循环!taskId:{}", nft035ReqDto.getTaskId());
break;
}
}
//赋值返回参数
nftOrderBo.setNftId(nftId);
log.info("发行NFT后返回给前端nftID:{}", nftId);
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{
if(!seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){
//发行失败
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)){
//转换任务状态
nftOrderBo.setNftPublishStatus(nftPublishStatus.toString());
}
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());
}
public 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;
String nftBuyChainTimestamp = null;
Integer nftBuyStatus = null;
String nftBuyTradeHash = null;
String nftBuyPayTaskId = null;
/**
* 获取订单和nft绑定信息
*/
Long shardId = -1l;
GalaxyNftOrderBindBo nftOrderBindBo = dataUtils.getGalaxyNftOrderBindBo(routerType,nftOrderBo.getNftOrderPayId());
if(StringUtil.isNotNull(nftOrderBindBo)){
shardId = nftOrderBindBo.getNftIdIndex().longValue();
}
//如果购买任务不为空,则直接进行购买任务查询
if(StringUtil.isNotEmpty(nftOrderBo.getNftBuyTaskId())){
nftBuyTaskId = nftOrderBo.getNftBuyTaskId();
}
if(StringUtil.isEmpty(nftBuyTaskId)){
//购买
Xuper007GrantShardReqDto xuper007GrantShardReqDto = Xuper007GrantShardReqDto.getNew();
// 定义返回结果对象
Xuper007GrantShardRespDto xuper007GrantShardRespDto = null;
long assetId = Long.parseLong(seriesNftInfoBo.getSeriesId());
try {
xuper007GrantShardReqDto.setMnemonic(xuperConfig.getNftPlatformMnemonic());
xuper007GrantShardReqDto.setAssetId(assetId);
xuper007GrantShardReqDto.setShardId(shardId);
xuper007GrantShardReqDto.setToAddr(xuperSdkUtil.getAccount(userInfoBo.getMnemonic()).getAddress());
xuper007GrantShardReqDto.setToUserId(100000l);
xuper007GrantShardReqDto.setPrice(seriesNftInfoBo.getSellCount().longValue());
XuperResponseDto<Xuper007GrantShardRespDto> xuperResponseDto = xuperSdkUtil.xuper007GrantShard(xuper007GrantShardReqDto);
if(xuperResponseDto.isSuccess()){
xuper007GrantShardRespDto = 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(xuper007GrantShardRespDto));
if(StringUtil.isNotNull(xuper007GrantShardRespDto)&&xuper007GrantShardRespDto.getErrNo()==0){
nftBuyTaskId = String.valueOf(assetId);
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(500l);
count++;
log.info("=======执行nft购买第{}次查询,taskId:{}",count,nft044ReqDto.getTaskId());
//执行nft购买结果查询
GalaxyNftBuyResultQueryReqDto nftBuyResultQueryReqDto = GalaxyNftBuyResultQueryReqDto.getNew();
nftBuyResultQueryReqDto.setNftOrderPayId(nftOrderBo.getNftOrderPayId());
nftBuyResultQueryReqDto.setRouterType(routerType);
ResponseDto<GalaxyNftBuyResultQueryRespDto> buyResultQueryRespDto= this.nftBuyResultQuery(nftBuyResultQueryReqDto,nftOrderBo);
if(buyResultQueryRespDto.isSuccess()){
if(buyResultQueryRespDto.getData().getTaskStatus().toString().equals(GalaxyEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
nftBuyPayTaskId = buyResultQueryRespDto.getData().getPayTaskId();
nftBuyChainTimestamp = buyResultQueryRespDto.getData().getChainTimestamp();
nftBuyStatus = buyResultQueryRespDto.getData().getTaskStatus();
nftBuyTradeHash = buyResultQueryRespDto.getData().getTxHash();
}else if(buyResultQueryRespDto.getData().getTaskStatus().toString().equals(GalaxyEnum.TaskStatusEnum.TASK_FAIL.getCode())){
log.info("任务执行失败!taskId:{}",nft044ReqDto.getTaskId());
nftBuyStatus = buyResultQueryRespDto.getData().getTaskStatus();
//购买失败
throw new GalaxyNftBuyException(GalaxyErrorEnum.NFT_BUY_FAIL.getCode(), "nftBuyResultQuery:"+GalaxyErrorEnum.NFT_BUY_FAIL.getMessage());
}else if(buyResultQueryRespDto.getData().getTaskStatus().toString().equals(GalaxyEnum.TaskStatusEnum.PROCESSING.getCode())){
log.info("任务执行中!taskId:{}",nft044ReqDto.getTaskId());
nftBuyStatus = buyResultQueryRespDto.getData().getTaskStatus();
}
}
if(count==20){
//查询超过20次,则把nftId设置为空,为后续重新入队
nftId = null;
log.info("=======查询共20次,跳出循环!taskId:{}",nft044ReqDto.getTaskId());
break;
}
}
log.info("总共执行了多少次查询:{} 总耗时:{}",count,System.currentTimeMillis() - timeStart);
}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(),"nftBuyResultQuery_exception:"+e.getMessage());
}
//更新订单缓存数据状态
if(StringUtil.isNotNull(nftBuyChainTimestamp)){
//设置时间
String nftBuyChainTimestampStr = DateUtil.format(new Date(),DateUtil.Formatter.yyyyMMddHHmmss);
nftOrderBo.setNftBuyChainTimestamp(nftBuyChainTimestampStr);
}
if(StringUtil.isNotNull(nftBuyStatus)){
nftOrderBo.setNftBuyStatus(nftBuyStatus.toString());
}
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(),"nftBuyResultQuery: nftBuyTaskId:"+nftBuyTaskId);
}
GalaxyNftBuyRespDto nftBuyRespDto = GalaxyNftBuyRespDto.getNew();
nftBuyRespDto.setUserId(userInfoBo.getUserId());
nftBuyRespDto.setNftId(nftId);
return nftBuyRespDto;
}
public ResponseDto<GalaxyNftBuyResultQueryRespDto> nftBuyResultQuery(GalaxyNftBuyResultQueryReqDto reqDto,GalaxyNftOrderBo nftOrderBo) {
//获取订单信息
// 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());
}
//执行资产碎片授予查询
Xuper010QuerySdsReqDto xuper010QuerySdsReqDto = Xuper010QuerySdsReqDto.getNew();
// 定义返回结果对象
Xuper010QuerySdsRespDto xuper010QuerySdsRespDto = null;
long shardId = 1l;
try {
xuper010QuerySdsReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId()));
xuper010QuerySdsReqDto.setShardId(shardId);
XuperResponseDto<Xuper010QuerySdsRespDto> xuperResponseDto = xuperSdkUtil.xuper010QuerySds(xuper010QuerySdsReqDto);
if(xuperResponseDto.isSuccess()){
xuper010QuerySdsRespDto = 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("xuper010QuerySds resp : "+ JsonUtils.toJson(xuper010QuerySdsRespDto));
if(String.valueOf(xuper010QuerySdsRespDto.getErrNo()).equalsIgnoreCase(ErrorCode.SUCCESS.getCode())){
GalaxyNftBuyResultQueryRespDto resultQueryRespDto = GalaxyNftBuyResultQueryRespDto.getNew();
String nowTimeStr = DateUtil.getNowTime();
//转换任务状态
Integer taskStatus = Integer.valueOf(GalaxyEnumBiz.getGrantStatusEnum(reqDto.getRouterType(),String.valueOf(xuper010QuerySdsRespDto.getMeta().getStatus())).getCode());
resultQueryRespDto.setTaskStatus(taskStatus);
resultQueryRespDto.setChainTimestamp(nowTimeStr);
resultQueryRespDto.setPayTaskId(xuper010QuerySdsRespDto.getMeta().getTxId());
resultQueryRespDto.setTxHash(xuper010QuerySdsRespDto.getMeta().getTxId());
return ResponseDto.success(resultQueryRespDto);
}else{
return ResponseDto.failure(GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getCode(),GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getMessage());
}
}
/**
* nft发行结果查询
* @param reqDto
* @return
*/
private 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());
}
//NFT发行结果查询
Xuper005QueryAssetReqDto xuper005QueryAssetReqDto = Xuper005QueryAssetReqDto.getNew();
xuper005QueryAssetReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId()));
// 定义返回结果对象
Xuper005QueryAssetRespDto xuper005QueryAssetRespDto = null;
try {
XuperResponseDto<Xuper005QueryAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper005QueryAsset(xuper005QueryAssetReqDto);
if(xuperResponseDto.isSuccess()){
xuper005QueryAssetRespDto = 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("xuper005QueryAsset resp : "+ JsonUtils.toJson(xuper005QueryAssetRespDto));
if (Integer.parseInt(ErrorCode.SUCCESS.getCode()) == xuper005QueryAssetRespDto.getErrNo()){
//获取资产信息
Xuper005QueryAssetRespDto.AssetMeta assetMeta = xuper005QueryAssetRespDto.getMeta();
//设置时间
String nftPublishChainTimestampStr = DateUtil.getNowTime();
//转换任务状态
String nftPublishStatusStr = GalaxyEnumBiz.getAssetPublishStatusEnum(reqDto.getRouterType(),String.valueOf(assetMeta.getStatus())).getCode();
//更新缓存数据状态
nftOrderBo.setNftId(nftOrderBo.getNftId());
nftOrderBo.setNftPublishChainTimestamp(nftPublishChainTimestampStr);
nftOrderBo.setNftPublishStatus(nftPublishStatusStr);
nftOrderBo.setNftPublishTradeHash(assetMeta.getTxId());
nftOrderBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateNftOrderPublishInfo(reqDto.getRouterType(),reqDto.getNftOrderPayId(),nftOrderBo);
//构造返回结果
GalaxyNftPublishResultQueryRespDto nftPublishResultQueryRespDto = GalaxyNftPublishResultQueryRespDto.getNew();
nftPublishResultQueryRespDto.setNftIdBegin(nftOrderBo.getNftId());
nftPublishResultQueryRespDto.setTaskMsg(nftOrderBo.getNftId());
nftPublishResultQueryRespDto.setTxHash(nftOrderBo.getNftPublishTradeHash());
nftPublishResultQueryRespDto.setChainTimestamp(nftPublishChainTimestampStr);
nftPublishResultQueryRespDto.setTaskStatus(Integer.valueOf(nftPublishStatusStr));
return ResponseDto.success(nftPublishResultQueryRespDto);
}else{
return ResponseDto.failure(GalaxyErrorEnum.PUBLISH_FAIL.getCode(), GalaxyErrorEnum.PUBLISH_FAIL.getMessage());
}
}
}
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.commons.lang.util.BASE64Util;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @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();
}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(reqDto.getRouterType());
userInfoBo.setBlockChainAddress(address);
dataUtils.setGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId(),userInfoBo);
}catch(Exception e){
log.error("xuper设置用户信息异常 msg:{}",e.getMessage(),e);
throw new XupterException(ZxlErrorEnum.FAILURE.getCode(),"xuper设置用户信息异常");
}
}
}catch (GalaxyNftUserException e) {
bizFailDesc = e.getMessage();
log.info(e.getMessage());
}catch(XupterException 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)&&StringUtil.isNotEmpty(userInfoBo.getBlockChainAddress())){
//构造返回参数
respDto.setUserId(userId);
respDto.setBlockChainType(GalaxyEnum.RouterTypeEnum.XUPER.getCode());
respDto.setBlockChainAddress(userInfoBo.getBlockChainAddress());
}
}
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);
}
}
......@@ -23,6 +23,7 @@ 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.router.xuper.biz.XuperUserCommonBiz;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
......@@ -34,6 +35,7 @@ import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -63,6 +65,9 @@ public class ZxinUserCommonBiz {
@Value("${liquidnet.service.adam.url}")
private String adamUrl;
@Autowired
private XuperUserCommonBiz xuperUserCommonBiz;
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
long startTime = System.currentTimeMillis();
String userId = reqDto.getUserId();
......@@ -277,6 +282,7 @@ public class ZxinUserCommonBiz {
return ResponseDto.success(respDto);
}
/**
* 同步用户数字账户开通信息
* @param reqDto
......@@ -298,8 +304,18 @@ public class ZxinUserCommonBiz {
String resultCode = NftAccStatusEnum.StatusAcc.ING.getCode();
String resultMessage = NftAccStatusEnum.StatusAcc.ING.getMsg();
//实名成功+绑定区块链地址成功
//百度链开通数字账户
boolean isOpenXuperUserSuccess = false;
ResponseDto<GalaxyUserRegisterRespDto> xuperUserRegisterRespDto = null;
if(isRealNameAuthSuccess && isBindBlockAddressSuccess){
xuperUserRegisterRespDto = this.isOpenXuperUserSuccess(reqDto);;
if(xuperUserRegisterRespDto.isSuccess()){
isOpenXuperUserSuccess = true;
}
}
//实名成功+绑定区块链地址成功
if(isRealNameAuthSuccess && isBindBlockAddressSuccess && isOpenXuperUserSuccess){
isOpenAccount = true;
resultCode = NftAccStatusEnum.StatusAcc.SUCCESS.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.SUCCESS.getMsg();
......@@ -326,6 +342,9 @@ public class ZxinUserCommonBiz {
resultCode = NftAccStatusEnum.StatusAcc.FAILURE2.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE2.getMsg();
}
}else if(!isOpenXuperUserSuccess){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE2.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE2.getMsg();
}
}
}
......@@ -345,8 +364,15 @@ public class ZxinUserCommonBiz {
syncUserAccountInfoToAdam(reqDto);
//同步业务账号关联关系到adam
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqlsDataA.add(new Object[]{
reqDto.getUserId(), AdamEnum.BizAcct.NFT_ZX.name(), blockChainAddress, null, null, 1, LocalDateTime.now()
});
sqlsDataA.add(new Object[]{
reqDto.getUserId(), AdamEnum.BizAcct.NFT_XUPER.name(), xuperUserRegisterRespDto.getData().getBlockChainAddress(), null, null, 1, LocalDateTime.now()
});
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())
SqlMapping.get("adam_user_busi_acct.add",sqlsDataA)
);
//开户成功记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
......@@ -377,9 +403,9 @@ public class ZxinUserCommonBiz {
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());
.concat(reqDto.getMobile()).concat(",")
.concat(reqDto.getIdCardType().concat(reqDto.getIdCard())).concat(",")
.concat(reqDto.getUserName());
//加密用户信息
DESUtils desUtils = DESUtils.DES();
// MultiValueMap<String, String> params = new LinkedMultiValueMap();
......@@ -388,139 +414,20 @@ public class ZxinUserCommonBiz {
// 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);
log.error("同步用户信息到adam异常:{}", JsonUtils.toJson(reqDto), e);
return false;
}
return true;
}
// public ResponseDto<GalaxyUserRegisterRespDto> userRegister2(GalaxyUserRegisterReqDto reqDto) {
// 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;
//
// GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(reqDto.getRouterType(),userId);
// if(userInfoBo!=null){
// mnemonic = userInfoBo.getMnemonic();
// }else{
// try{
// //生成助记词
// CreateMnemonicReq req = CreateMnemonicReq.getNew();
// CreateMnemonicResp createMnemonicResp = zxlWalletSdkUtil.createMnemonic(req);
// mnemonic = createMnemonicResp.getMnemonic();
// }catch(Exception e){
// throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"生成助记词失败!");
// }
// }
//
//
// /**
// * todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
// */
//
// if(StringUtil.isNotEmpty(mnemonic)){
// //生成公私钥
// DeriveKeyPairReq deriveKeyPairReq = DeriveKeyPairReq.getNew();
// deriveKeyPairReq.setMnemonic(mnemonic);
//// deriveKeyPairReq.setMnemonic(createMnemonicResp.getMnemonic());
// deriveKeyPairReq.setIndex(index);
// try{
// DeriveKeyPairResp deriveKeyPairResp = zxlWalletSdkUtil.deriveKeyPair(deriveKeyPairReq);
// if(!deriveKeyPairResp.getErr().equals("")) throw new Exception("生成公私钥失败!");
// userPubKey = BASE64Util.encoded(deriveKeyPairResp.getPubKey());
// userPriKey = BASE64Util.encoded(deriveKeyPairResp.getPriKey());
// }catch(Exception e){
// throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),e.getMessage());
// }
// }
//
// //1.2.1调用自然人注册实名(使用NFT平台签名)接口
// Nft003RegisterPersonPlatformReqDto nft003ReqDto = Nft003RegisterPersonPlatformReqDto.getNew();
// nft003ReqDto.setPersonName(userName);
//// reqDto.setEmail("");
// nft003ReqDto.setMobile(mobile);
// nft003ReqDto.setIdCard(idCard);
//
// nft003ReqDto.setCardType(Integer.valueOf(idCardType));
// ZxlnftResponseDto<Nft003RegisterPersonPlatformRespDto> nft003Resp = zxlnftSdkUtil.nft003RegisterPersonPlatform(nft003ReqDto);
//
// if(nft003Resp.isSuccess()){
// userIdentification = nft003Resp.getData().getUserIdentification();
// }else{
// return ResponseDto.failure(nft003Resp.getCode(),nft003Resp.getMessage());
// }
//
// GalaxyUserRegisterRespDto respDto = GalaxyUserRegisterRespDto.getNew();
//
// if(StringUtil.isNotEmpty(userPubKey)&&StringUtil.isNotEmpty(userPriKey)&&StringUtil.isNotEmpty(userIdentification)){
// //1.2.2调用授信平台NFT地址绑定接口
// Nft014IdentityBindSubmitByTrustedReqDto nft014ReqDto = Nft014IdentityBindSubmitByTrustedReqDto.getNew();
//
// try {
// nft014ReqDto.setUserPubKey(BASE64Util.decode(userPubKey));
// nft014ReqDto.setUserIdentification(nft003Resp.getData().getUserIdentification());
//
// String signature = zxlnftBiz.createSign(BASE64Util.decode(userPriKey),nft014ReqDto.getUserIdentification());
// nft014ReqDto.setUserSignData(signature);
// } catch (UnsupportedEncodingException e) {
// log.error("公私钥解密错误!");
// }
//
// ZxlnftResponseDto<Nft014IdentityBindSubmitByTrustedRespDto> nft014Resp = zxlnftSdkUtil.nft014IdentityBindSubmitByTrusted(nft014ReqDto);
//
// ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> nft016Resp = null;
// if(nft014Resp.isSuccess()){
// //1.2.3调用绑定状态批量查询
// Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew();
// nft016ReqDto.setAddressList(nft014Resp.getData().getAddress());
// nft016Resp = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
// }else{
// log.info("nft014Resp 返回结果:{}",nft014Resp.toJson());
// return ResponseDto.failure(nft014Resp.getCode(),nft014Resp.getMessage());
// }
//
// if(StringUtil.isNotNull(nft016Resp)&&nft016Resp.isSuccess()){
// List<Nft016QueryRsData> queryRsDataList = nft016Resp.getData().getList();
// Nft016QueryRsData queryRsData = queryRsDataList.get(0);
// address = queryRsData.getAddress();
// log.info("nft016Resp 返回结果:{}",nft016Resp.toJson());
// //构造返回参数
// respDto.setUserId(userId);
// respDto.setBlockChainType(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
// respDto.setBlockChainAddress(address);
// }else{
// return ResponseDto.failure(nft016Resp.getMessage());
// }
//
//
// //构造缓存数据
// if(userInfoBo==null){
// 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);
// }else{
//
// }
// }
// return ResponseDto.success(respDto);
// }
/**
* 是否开通xuper数字账户
* @param reqDto
* @return
*/
private ResponseDto<GalaxyUserRegisterRespDto> isOpenXuperUserSuccess(GalaxyUserRegisterReqDto reqDto){
reqDto.setRouterType(GalaxyEnum.RouterTypeEnum.XUPER.getCode());
return xuperUserCommonBiz.userRegister(reqDto);
}
}
......@@ -3,6 +3,7 @@ package com.liquidnet.service.galaxy.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
......@@ -117,9 +118,9 @@ public abstract class AbstractDataUtils {
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.insert"),
new Object[]{seriesInfoBo.getSeriesInfoId(),seriesInfoBo.getSeriesName(),seriesCode,null,seriesInfoBo.getTotalCount()
new Object[]{seriesInfoBo.getSeriesInfoId(),seriesInfoBo.getSeriesName(),seriesCode,seriesInfoBo.getSeriesId(),seriesInfoBo.getTotalCount()
,seriesInfoBo.getCrtCount(),seriesInfoBo.getSeriesClaimTaskId(),seriesInfoBo.getSeriesClaimStatus(),seriesInfoBo.getCoverUrl(),seriesInfoBo.getSeriesDesc()
,nftCount,seriesInfoBo.getRouterType(),LocalDateTime.now(),null
,nftCount,seriesInfoBo.getTradeHash(),seriesInfoBo.getRouterType(),LocalDateTime.now(),null
}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
......@@ -238,6 +239,33 @@ public abstract class AbstractDataUtils {
}
}
/**
* 更新系列nft发行状态
* @param routerType
* @param skuId
* @param seriesNftInfoBo
*/
public void updateSeriesNftPublishStatus(String routerType,String skuId, GalaxySeriesNftInfoBo seriesNftInfoBo) {
//更新系列nft状态
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(seriesNftInfoBo.getUpdatedAt());
if(StringUtil.isEmpty(seriesNftInfoBo.getNftPublishStatus())){
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.INIT.getCode());
}
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.updateSeriesNftPublishStatus"),
new Object[]{seriesNftInfoBo.getNftPublishStatus(),seriesNftInfoBo.getNftPublishTradeHash(),nowTimeStr,seriesNftInfoBo.getSkuId()}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#updateSeriesNftStatus error ==> MESSAGE:{}",e.getMessage());
}
}
//根据系列Id获取 一个系列对应多个skuId
// public List<String> getSkuIdListBySeriesCode(String seriesCode){
// //根据演出id获取用户信息 只查询5条
......
# ------------------------用户注册信息----------------------------
galaxy_user_info.insert=insert into galaxy_user_info (user_id, user_name, user_type, mobile, id_card_type, id_card, mnemonic, mnemonic_index,user_identification, user_pub_key, user_pri_key, block_chain_address, router_type,created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------数字藏品系列信息----------------------------
galaxy_series_info.insert=insert into galaxy_series_info (series_info_id, series_name, series_code, series_id, total_count, crt_count,series_claim_task_id, series_claim_status, cover_url, series_desc, nft_count,router_type, created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)
galaxy_series_info.insert=insert into galaxy_series_info (series_info_id, series_name, series_code, series_id, total_count, crt_count,series_claim_task_id, series_claim_status, cover_url, series_desc, nft_count,trade_hash,router_type, created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------数字藏品系列NFT信息----------------------------
galaxy_series_nft_info.insert=insert into galaxy_series_nft_info (series_nft_info_id, series_info_id, sku_id, series_name, series_code,series_id, nft_total_count, nft_crt_count, nft_id_begin ,nft_id_begin_index ,nft_publish_number,original_nft_url, original_display_url,author, nft_name, nft_url, display_url, nft_desc, nft_flag, sell_count, nft_hash,router_type, created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------数字藏品订单信息----------------------------
......@@ -27,6 +27,7 @@ galaxy_series_info.updateSeriesCrtCount=update galaxy_series_info t set t.crt_co
galaxy_series_nft_info.updateSeriesNftCrtCount=update galaxy_series_nft_info t set t.nft_crt_count = ?,t.updated_at =? where t.sku_id = ?
# ------------------------更新发行购买处理结果----------------------------
galaxy_nft_order_fail_log.updateDealWithStatus=update galaxy_nft_order_fail_log t set t.deal_with_status = ?,t.updated_at =? where t.nft_order_pay_id = ? and t.router_type = ?
# ------------------------更新系列NFT发行状态信息----------------------------
galaxy_series_nft_info.updateSeriesNftPublishStatus=update galaxy_series_nft_info t set t.publish_status = ?,t.publish_trade_hash = ?,t.updated_at =? where t.sku_id = ?
# ------------------------同步用户数字账户信息到adam---------------------------
adam_user_busi_acct.add=INSERT INTO adam_user_busi_acct (`uid`, busi, uuid, `work`, ppwd, `state`, created_at) VALUES (?,?,?,?,?,?,?)
alter table galaxy_series_nft_info
add publish_status varchar(10) null comment 'nft发行状态(-1初始化 0发行中 1发行成功 2发行失败)' after router_type;
alter table galaxy_series_nft_info
add publish_trade_hash varchar(200) null comment 'nft发行交易hash' after publish_status;
alter table galaxy_series_info modify series_name varchar(30) not null comment '本地系列唯一名称(前缀+skuid)';
alter table galaxy_series_nft_info modify series_name varchar(30) not null comment '本地系列唯一名称(前缀+skuid)';
\ No newline at end of file
package com.liquidnet.service.galaxy;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.ArrayList;
import java.util.List;
public class MybatisPlusCodeGenerator {
/**
* @param moduleRootPath 项目模块根路径 到 /src 之前 ex:E:\projects\trlabs-bus-v1\trlabs-bus-service\trlabs-common\trlabs-mybatis
* @param dsc 数据源
* @param parentName 相当于业务模块名 com.liquidnet.service.adam 全限定类名
* @param tableNames 表名
*/
public static void doGenerator(String moduleRootPath,
DataSourceConfig dsc,
String parentName,
String[] tableNames) {
AutoGenerator mpg = new AutoGenerator();
// 全局配置BankMybatisPlusCodeGenerator
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(moduleRootPath + "/src/main/java");
gc.setAuthor("liquidnet");
gc.setOpen(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
// 数据源配置
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent(parentName);
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
// 如果模板引擎是 freemarker
String templatePath = "/templates/mapper.xml.ftl";
// 自定义输出配置
List<FileOutConfig> focList = new ArrayList<>();
// 自定义配置会被优先输出
focList.add(new FileOutConfig(templatePath) {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return moduleRootPath + "/src/main/resources/com/liquidnet/service/galaxy/mapper/" + pc.getModuleName()
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
// 配置模板
TemplateConfig templateConfig = new TemplateConfig();
templateConfig.setXml(null);
mpg.setTemplate(templateConfig);
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
strategy.setInclude(tableNames);
strategy.setControllerMappingHyphenStyle(true);
strategy.setTablePrefix(pc.getModuleName() + "_");
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
public static void main(String[] args) {
DataSourceConfig dsc = new DataSourceConfig();
// dsc.setSchemaName("public");
dsc.setDriverName("com.mysql.cj.jdbc.Driver");
dsc.setUrl("jdbc:mysql://39.107.71.112:3308/dev_ln_scene?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=CST");
dsc.setUsername("root");
dsc.setPassword("Zhengzai@rd2U#");
String resourcePath = "/Users/anjiabin/Downloads/tmp";
String directory = "com.liquidnet.service.galaxy";
String[] dbTableArray = new String[]{"galaxy_user_info", "galaxy_series_info", "galaxy_series_nft_info","galaxy_nft_order_info", "galaxy_nft_trade_info","galaxy_nft_order_fail_log"};
doGenerator(resourcePath, dsc, directory, dbTableArray);
}
}
package com.liquidnet.service.galaxy.biz;
import com.liquidnet.commons.lang.util.CollectionUtil;
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 javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -66,4 +68,74 @@ 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();
}
}
public static HashMap<String,Integer> getImageWidthAndHeight(String imgLocalFilePath){
HashMap rsHashMap = CollectionUtil.mapStringInteger();
// String imgLocalFilePath = "/Users/anjiabin/Downloads/zxl_image_test_001.jpg";
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new FileInputStream(imgLocalFilePath));
} catch (IOException e) {
e.printStackTrace();
log.error("xuper getImageWidthAndHeight error:"+e.getMessage(),e);
}
int height = bufferedImage.getHeight();
int width = bufferedImage.getWidth();
rsHashMap.put("width",width);
rsHashMap.put("height",height);
log.info("getImageWidthAndHeight width=={} height=={}",width,height);
return rsHashMap;
}
public static boolean isImageType(String imageUrl){
// ”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”
String[] imageArray = {"jpg","jpeg","png","bmp","webp","hejc"};
String imageType = null;
if(imageUrl.lastIndexOf("?")!=-1){
String tempUrl = imageUrl.substring(0,imageUrl.lastIndexOf("?"));
imageType = tempUrl.substring(tempUrl.lastIndexOf(".")+1,tempUrl.length());
}else{
imageType = imageUrl.substring(imageUrl.lastIndexOf(".")+1,imageUrl.length());
}
System.out.println("imageType====="+imageType);
if(Arrays.asList(imageArray).contains(imageType.toLowerCase())){
return true;
}
return false;
}
}
package com.liquidnet.service.galaxy.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.aop.annotation.ControllerLog;
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.service.IGalaxyPublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyPublishController
* @Package com.liquidnet.service.galaxy.controller
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 12:11
*/
@Api(tags = "NFT发行相关")
@RestController
@RequestMapping("nftPublish")
@Validated
@Slf4j
public class GalaxyPublishController {
@Resource(name = "galaxyPublishServiceImpl")
private IGalaxyPublishService galaxyPublishService;
@ControllerLog(description = "NFT发行")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT发行")
@PostMapping(value = {"nftPublish"})
public ResponseDto<GalaxyNftPublishRespDto> nftPublish(@Valid @RequestBody GalaxyNftPublishReqDto reqDto){
return galaxyPublishService.nftPublish(reqDto);
}
@ControllerLog(description = "NFT发行结果查询")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "NFT发行结果查询")
@PostMapping(value = {"nftPublishResultQuery"})
public ResponseDto<GalaxyNftPublishResultQueryRespDto> nftPublishResultQuery(@Valid @RequestBody GalaxyNftPublishResultQueryReqDto reqDto) {
return galaxyPublishService.nftPublishResultQuery(reqDto);
}
}
//package com.liquidnet.service.galaxy.controller;
//
//import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
//import com.liquidnet.service.base.ResponseDto;
//import com.liquidnet.service.galaxy.aop.annotation.ControllerLog;
//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.service.IGalaxyPublishService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.validation.Valid;
//
///**
// * @author AnJiabin <anjiabin@zhengzai.tv>
// * @version V1.0
// * @Description: TODO
// * @class: GalaxyPublishController
// * @Package com.liquidnet.service.galaxy.controller
// * @Copyright: LightNet @ Copyright (c) 2021
// * @date 2022/3/15 12:11
// */
//@Api(tags = "NFT发行相关")
//@RestController
//@RequestMapping("nftPublish")
//@Validated
//@Slf4j
//public class GalaxyPublishController {
// @Resource(name = "galaxyPublishServiceImpl")
// private IGalaxyPublishService galaxyPublishService;
//
// @ControllerLog(description = "NFT发行")
// @ApiOperationSupport(order = 1)
// @ApiOperation(value = "NFT发行")
// @PostMapping(value = {"nftPublish"})
// public ResponseDto<GalaxyNftPublishRespDto> nftPublish(@Valid @RequestBody GalaxyNftPublishReqDto reqDto){
// return galaxyPublishService.nftPublish(reqDto);
// }
//
// @ControllerLog(description = "NFT发行结果查询")
// @ApiOperationSupport(order = 3)
// @ApiOperation(value = "NFT发行结果查询")
// @PostMapping(value = {"nftPublishResultQuery"})
// public ResponseDto<GalaxyNftPublishResultQueryRespDto> nftPublishResultQuery(@Valid @RequestBody GalaxyNftPublishResultQueryReqDto reqDto) {
// return galaxyPublishService.nftPublishResultQuery(reqDto);
// }
//}
package com.liquidnet.service.galaxy.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.aop.annotation.ControllerLog;
import com.liquidnet.service.galaxy.dto.param.*;
......@@ -17,8 +16,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -38,21 +35,21 @@ public class GalaxyTradeController {
@Resource(name = "galaxyTradeServiceImpl")
private IGalaxyTradeService galaxyTradeService;
@ControllerLog(description = "NFT购买")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT购买")
@PostMapping(value = {"nftBuy"})
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(@Valid @RequestBody GalaxyNftBuyReqDto reqDto){
return galaxyTradeService.nftBuy(reqDto);
}
@ControllerLog(description = "NFT购买结果查询")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT购买结果查询")
@PostMapping(value = {"nftBuyResultQuery"})
public ResponseDto<GalaxyNftBuyResultQueryRespDto> nftBuyResultQuery(@Valid @RequestBody GalaxyNftBuyResultQueryReqDto reqDto){
return galaxyTradeService.nftBuyResultQuery(reqDto);
}
// @ControllerLog(description = "NFT购买")
// @ApiOperationSupport(order = 1)
// @ApiOperation(value = "NFT购买")
// @PostMapping(value = {"nftBuy"})
// public ResponseDto<GalaxyNftBuyRespDto> nftBuy(@Valid @RequestBody GalaxyNftBuyReqDto reqDto){
// return galaxyTradeService.nftBuy(reqDto);
// }
//
// @ControllerLog(description = "NFT购买结果查询")
// @ApiOperationSupport(order = 1)
// @ApiOperation(value = "NFT购买结果查询")
// @PostMapping(value = {"nftBuyResultQuery"})
// public ResponseDto<GalaxyNftBuyResultQueryRespDto> nftBuyResultQuery(@Valid @RequestBody GalaxyNftBuyResultQueryReqDto reqDto){
// return galaxyTradeService.nftBuyResultQuery(reqDto);
// }
@ControllerLog(description = "NFT购买(发行+购买)")
@ApiOperationSupport(order = 1)
......@@ -75,30 +72,30 @@ public class GalaxyTradeController {
return galaxyTradeService.nftPublishAndBuyResultQuery(reqDto);
}
@ControllerLog(description = "NFT发行购买结果批量查询")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT发行购买结果批量查询")
@PostMapping(value = {"nftPublishAndBuyResultBatchQuery"})
public ResponseDto<GalaxyNftPublishAndBuyResultBatchQueryRespDto> nftPublishAndBuyResultBatchQuery(@Valid @RequestBody GalaxyNftPublishAndBuyResultBatchQueryReqDto reqDto){
//定义返回结果
List<GalaxyNftPublishAndBuyResultQueryRespDto> routerBuyInfoList = new ArrayList<>();
//获取请求信息
List<GalaxyNftPublishAndBuyResultBatchQueryReqDto.RouterOrderInfo> routerOrderInfoList = reqDto.getRouterOrderInfoList();
routerOrderInfoList.forEach(routerOrderInfo -> {
GalaxyNftPublishAndBuyRouterBatchQueryReqDto batchQueryReqDto = GalaxyNftPublishAndBuyRouterBatchQueryReqDto.getNew();
batchQueryReqDto.setUserId(routerOrderInfo.getUserId());
batchQueryReqDto.setRouterType(routerOrderInfo.getRouterType());
batchQueryReqDto.setNftOrderPayIdList(routerOrderInfo.getNftOrderPayIdList());
//进行批量查询
ResponseDto<GalaxyNftPublishAndBuyRouterBatchQueryRespDto> responseDtoTemp = galaxyTradeService.nftPublishAndBuyResultBatchQuery(batchQueryReqDto);
if(StringUtil.isNotNull(responseDtoTemp)&&responseDtoTemp.isSuccess()){
routerBuyInfoList.addAll(responseDtoTemp.getData().getBuyInfoList());
}
});
GalaxyNftPublishAndBuyResultBatchQueryRespDto respDto = GalaxyNftPublishAndBuyResultBatchQueryRespDto.getNew();
respDto.setRouterBuyInfoList(routerBuyInfoList);
return ResponseDto.success(respDto);
}
// @ControllerLog(description = "NFT发行购买结果批量查询")
// @ApiOperationSupport(order = 1)
// @ApiOperation(value = "NFT发行购买结果批量查询")
// @PostMapping(value = {"nftPublishAndBuyResultBatchQuery"})
// public ResponseDto<GalaxyNftPublishAndBuyResultBatchQueryRespDto> nftPublishAndBuyResultBatchQuery(@Valid @RequestBody GalaxyNftPublishAndBuyResultBatchQueryReqDto reqDto){
// //定义返回结果
// List<GalaxyNftPublishAndBuyResultQueryRespDto> routerBuyInfoList = new ArrayList<>();
// //获取请求信息
// List<GalaxyNftPublishAndBuyResultBatchQueryReqDto.RouterOrderInfo> routerOrderInfoList = reqDto.getRouterOrderInfoList();
// routerOrderInfoList.forEach(routerOrderInfo -> {
// GalaxyNftPublishAndBuyRouterBatchQueryReqDto batchQueryReqDto = GalaxyNftPublishAndBuyRouterBatchQueryReqDto.getNew();
// batchQueryReqDto.setUserId(routerOrderInfo.getUserId());
// batchQueryReqDto.setRouterType(routerOrderInfo.getRouterType());
// batchQueryReqDto.setNftOrderPayIdList(routerOrderInfo.getNftOrderPayIdList());
// //进行批量查询
// ResponseDto<GalaxyNftPublishAndBuyRouterBatchQueryRespDto> responseDtoTemp = galaxyTradeService.nftPublishAndBuyResultBatchQuery(batchQueryReqDto);
// if(StringUtil.isNotNull(responseDtoTemp)&&responseDtoTemp.isSuccess()){
// routerBuyInfoList.addAll(responseDtoTemp.getData().getBuyInfoList());
// }
// });
// GalaxyNftPublishAndBuyResultBatchQueryRespDto respDto = GalaxyNftPublishAndBuyResultBatchQueryRespDto.getNew();
// respDto.setRouterBuyInfoList(routerBuyInfoList);
// return ResponseDto.success(respDto);
// }
// @ControllerLog(description = "NFT购买支付结果查询")
// @ApiOperationSupport(order = 1)
......
package com.liquidnet.service.galaxy.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
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.aop.annotation.ControllerLog;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
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.xuper.biz.XuperUserCommonBiz;
import com.liquidnet.service.galaxy.service.IGalaxyUserService;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -19,6 +30,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.LinkedList;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -38,6 +51,12 @@ public class GalaxyUserController {
@Resource(name = "galaxyUserServiceImpl")
private IGalaxyUserService galaxyUserService;
@Autowired
private XuperUserCommonBiz xuperUserCommonBiz;
@Autowired
private GalaxyDataUtils dataUtils;
@ControllerLog(description = "NFT用户注册")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT用户注册")
......@@ -53,4 +72,36 @@ public class GalaxyUserController {
public ResponseDto<GalaxyUserBindStatusQueryRespDto> userBindStatusQuery(@Valid @RequestBody GalaxyUserBindStatusQueryReqDto reqDto) {
return galaxyUserService.userBindStatusQuery(reqDto);
}
@ControllerLog(description = "NFT百度用户同步")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "NFT百度用户同步")
@PostMapping(value = {"xuperUserSync"})
public ResponseDto<String> xuperUserSync(@Valid @RequestBody GalaxyUserRegisterReqDto reqDto) {
//判断百度链用户是否已经存在
GalaxyUserInfoBo xuperUserInfoBo = dataUtils.getGalaxyUserInfo(GalaxyEnum.RouterTypeEnum.XUPER.getCode(), reqDto.getUserId());
if(StringUtil.isNotNull(xuperUserInfoBo)&&StringUtil.isNotEmpty(xuperUserInfoBo.getBlockChainAddress())){
log.error("NFT百度用户同步 error 该用户百度链用户已经开通成功无需再次开通 reqParam:{}", JsonUtils.toJson(reqDto));
return ResponseDto.success("已开通成功");
}
//获取至信链用户开通信息
GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode(), reqDto.getUserId());
if(StringUtil.isNotNull(userInfoBo)&&StringUtil.isNotEmpty(userInfoBo.getBlockChainAddress())){
reqDto.setRouterType(GalaxyEnum.RouterTypeEnum.XUPER.getCode());
ResponseDto<GalaxyUserRegisterRespDto> responseDto = xuperUserCommonBiz.userRegister(reqDto);
if(responseDto.isSuccess()){
//同步业务账号关联关系到adam
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqlsDataA.add(new Object[]{
reqDto.getUserId(), AdamEnum.BizAcct.NFT_XUPER.name(), responseDto.getData().getBlockChainAddress(), null, null, 1, LocalDateTime.now()
});
dataUtils.getQueueUtil().sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("adam_user_busi_acct.add",sqlsDataA)
);
return ResponseDto.success("开通成功");
};
}
log.error("NFT百度用户同步 error 该用户至信链数字账户未开通 reqParam:{}", JsonUtils.toJson(reqDto));
return ResponseDto.failure("开通失败");
}
}
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.baidu.xasset.auth.Crypto;
import com.baidu.xasset.client.base.Base;
import com.baidu.xuper.api.Account;
import com.liquidnet.common.exception.constant.ErrorCode;
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.*;
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.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.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 百度超级链艺术品上传
* @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 XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@Autowired
private GalaxyDataUtils dataUtils;
@Autowired
private GalaxyCommonBiz galaxyCommonBiz;
public ResponseDto<GalaxyNftImageRespDto> nftImageCheck(GalaxyNftImageReqDto reqDto) {
GalaxyNftImageRespDto nftImageRespDto = GalaxyNftImageRespDto.getNew();
nftImageRespDto.setSuggestion("Pass");
nftImageRespDto.setLabel("Normal");
nftImageRespDto.setScore(100);
return ResponseDto.success(nftImageRespDto);
}
public ResponseDto<GalaxyNftUploadRespDto> nftUpload(GalaxyNftUploadReqDto reqDto) {
/**
* 系列缓存初始化
*/
//获取任务ID
GalaxySeriesNftUploadBo seriesNftUploadBo = dataUtils.getSeriesNftUploadBo(reqDto.getRouterType(),reqDto.getSkuId());
if(StringUtil.isNotNull(seriesNftUploadBo)&&StringUtil.isNotEmpty(seriesNftUploadBo.getNftUrl())){
return ResponseDto.failure("素材已经上传过!");
}
String originalNftUrl = reqDto.getOriginalNftUrl();
String originalDisplayUrl = reqDto.getOriginalDisplayUrl();
//上传系列名只用来目录区分
String seriesName = GalaxyConstant.SERIES_NAME_XUPER_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(XupterException 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());
seriesNftUploadBo.setCreatedAt(LocalDateTime.now());
dataUtils.setSeriesNftUploadBo(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftUploadBo);
return ResponseDto.success(galaxyNftUploadRespDto);
}
public ResponseDto<GalaxyArtSeriesClaimRespDto> seriesClaim(GalaxyArtSeriesClaimReqDto reqDto) {
//系列声明用到参数
String skuId = reqDto.getSkuId();
//以下系列名称可以用spu名称代替
String seriesName = GalaxyConstant.SERIES_NAME_XUPER_PREFIX.concat(skuId);
String seriesCode = GalaxyConstant.SERIES_NAME_XUPER_PREFIX.concat(skuId);
Long totalCount = reqDto.getTotalCount();
String coverUrl = reqDto.getCoverUrl();//暂时用nftUrl
String seriesDesc = reqDto.getSeriesDesc();
//根据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;
// 创建区块链数字资产
Xuper002CreateAssetRespDto xuper002CreateAssetRespDto = null;
try {
Xuper002CreateAssetReqDto xuper002CreateAssetReqDto = Xuper002CreateAssetReqDto.getNew();
// String nftUrl = "bos_v1://xasset-offline/110381/ZXLNFTIMAGE202206231042217867523750.jpg/";
String nftUrl = reqDto.getNftUrl();
//该文件只为了生成hash值
String originalNftUrl = seriesNftUploadBo.getOriginalNftUrl();
String nftHashStr = this.getNftHashByNftUrl(originalNftUrl);
//设置nft的hash值
seriesNftUploadBo.setNftHashStr(nftHashStr);
String displlayUrl = reqDto.getDisplayUrl();
try {
//原始显示图片地址,该地址是为了获取图片宽高
String originalDisplayUrl = seriesNftUploadBo.getOriginalDisplayUrl();
HashMap<String,Integer> displayWidthAndHeight = CollectionUtil.mapStringInteger();
//判断类型是否为图片
boolean displayIsImageType = GalaxyCommonBiz.isImageType(originalDisplayUrl);
if(displayIsImageType){//如果是图片则获取原始宽高
File nftUrlFile= galaxyCommonBiz.inputStreamToFile(originalDisplayUrl,IDGenerator.getXuperNftImageCosCode());
displayWidthAndHeight = GalaxyCommonBiz.getImageWidthAndHeight(nftUrlFile.getAbsolutePath());
}else{
displayWidthAndHeight.put("width",290);
displayWidthAndHeight.put("height",290);
}
xuper002CreateAssetReqDto.setMnemonic(xuperConfig.getNftPlatformMnemonic());
//资产碎片数量,小于1和大于200000代表不做库存限制
xuper002CreateAssetReqDto.setAmount(totalCount.intValue());
//藏品显示售卖价格,单位为分
xuper002CreateAssetReqDto.setPrice(new BigDecimal(reqDto.getSellCount()).multiply(BigDecimal.valueOf(100l)).longValue());
//资产分类。1:艺术品 2:收藏品 3:门票 4:酒店
xuper002CreateAssetReqDto.setAssetCate(Integer.valueOf(XuperEnum.assetTypeEnum.COLLECTION.getCode()));
//资产名称,小于30个字节
xuper002CreateAssetReqDto.setTitle(reqDto.getNftName());
//资产缩略图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
xuper002CreateAssetReqDto.setThumb(displlayUrl.concat(displayWidthAndHeight.get("width").intValue()+"_"+displayWidthAndHeight.get("height").intValue()));
//短文字描述,小于300个字节
xuper002CreateAssetReqDto.setShortDesc(reqDto.getNftDesc());
//(可选)资产详情介绍长图。bos上传的图片,格式支持:”jpg”, “jpeg”, “png”, “bmp”, “webp”, “heic”。参数格式bos_v1://{bucket}/{object}/{width}_{height}
xuper002CreateAssetReqDto.setImgDesc(displlayUrl.concat(displayWidthAndHeight.get("width").intValue()+"_"+displayWidthAndHeight.get("height").intValue()));
//资产原始文件。比如图片,图片本身就是资产。格式bos_v1://{bucket}/{object} ,文件大小<10M。文件名采用文件md5值,为了正常展现,需要正确携带文件后缀
//判断类型是否为图片
boolean isImageType = GalaxyCommonBiz.isImageType(originalNftUrl);
if(isImageType){//如果是图片则获取原始宽高
File nftUrlFile= galaxyCommonBiz.inputStreamToFile(originalNftUrl,IDGenerator.getXuperNftImageCosCode());
HashMap<String,Integer> widthAndHeight = GalaxyCommonBiz.getImageWidthAndHeight(nftUrlFile.getAbsolutePath());
int width = widthAndHeight.get("width").intValue();
int height = widthAndHeight.get("height").intValue();
xuper002CreateAssetReqDto.setAssetUrl(nftUrl.concat(width+"_"+height));
}else{
xuper002CreateAssetReqDto.setAssetUrl(nftUrl);
}
//(可选)长文字描述,小于1200个字节
xuper002CreateAssetReqDto.setLongDesc(reqDto.getNftDesc());
//(可选)资产额外描述信息json字符串。比如标签
// xuper002CreateAssetReqDto.setAssetExt("{\"tags\":[\"艺术品\",\"古董\"]} ");
//(可选)资产组id。用于关联业务层酒店/店铺id
xuper002CreateAssetReqDto.setGroupId(0l);
//(可选)业务侧用户标记,必要时请安全处理后设置
xuper002CreateAssetReqDto.setUserId(0l);
//(可选)要存证的资产文件sm3散列值,如有多个文件逐个计算hash值后合并计算最终hash值
xuper002CreateAssetReqDto.setFileHash(nftHashStr);
//执行数字资产创建
XuperResponseDto<Xuper002CreateAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper002CreateAsset(xuper002CreateAssetReqDto);
if(xuperResponseDto.isSuccess()){
xuper002CreateAssetRespDto = 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(xuper002CreateAssetRespDto));
//返回参数
String seriesId = null;
String taskId = null;
String tradeHash = null; //系列声明hash,这里暂时用返回参数request_id
seriesClaimRespDto = GalaxyArtSeriesClaimRespDto.getNew();
if(StringUtil.isNotNull(xuper002CreateAssetRespDto)&&xuper002CreateAssetRespDto.errNo==0){
//第零个系列 无限制系列
taskId = String.valueOf(xuper002CreateAssetRespDto.getAssetId());
seriesId = String.valueOf(xuper002CreateAssetRespDto.getAssetId());
tradeHash = String.valueOf(xuper002CreateAssetRespDto.getRequestId());
//构造缓存数据
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);
seriesInfoBo.setSeriesId(seriesId);
seriesInfoBo.setSeriesClaimTaskId(taskId);
seriesInfoBo.setTradeHash(tradeHash);
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 XupterException(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(XupterException 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);
}
/**
* 系列声明结果查询
* @param reqDto
* @return
*/
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())){
//根据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());
}
String originalNftUrl = seriesNftUploadBo.getOriginalNftUrl();
seriesNftInfoBo.setNftHash(this.getNftHashByNftUrl(originalNftUrl));
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, XuperEnum.AssetPublishStatusEnum.INIT.getCode());
return ResponseDto.success(resultQueryRespDto);
}
Xuper005QueryAssetReqDto xuper005QueryAssetReqDto = Xuper005QueryAssetReqDto.getNew();
// 定义返回结果对象
Xuper005QueryAssetRespDto respDto = null;
//百度超级链使用的是资产id作为任务id
long assetId = Long.parseLong(seriesInfoBo.getSeriesClaimTaskId());
try {
xuper005QueryAssetReqDto.setAssetId(assetId);
XuperResponseDto<Xuper005QueryAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper005QueryAsset(xuper005QueryAssetReqDto);
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("seriesClaimResultQuery resp : "+ JsonUtils.toJson(respDto));
if(respDto.getErrNo() == Integer.parseInt(ErrorCode.SUCCESS.getCode())){
if(respDto.getMeta().getStatus() == Integer.parseInt(XuperEnum.AssetPublishStatusEnum.INIT.getCode())){
//设置系列声明状态
seriesInfoBo.setSeriesClaimStatus(GalaxyEnum.SeriesClaimStatusEnum.SUCCESS.getCode());
String nowTimeStr = DateUtil.getNowTime();
seriesInfoBo.setChainTimestamp(nowTimeStr);
seriesInfoBo.setSeriesId(String.valueOf(respDto.getMeta().getAssetId()));
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,XuperEnum.AssetPublishStatusEnum.INIT.getCode());
return ResponseDto.success(resultQueryRespDto);
}else{
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){
//完整全路径 https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/NOW_ZXL_NFT_PIC001_test_skuId001/2022-03-04/ZXLNFTIMAGE202203041707466694345291.jpg
String fullFilePath = null; //需要保存,返回给调用者
// 创建区块链账户
XuperUploadFileRespDto xuperUploadFileRespDto = null;
try {
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.getXuperNftImageCosCode() + imageType;
//通过图片url地址上传
File cosFile = galaxyCommonBiz.inputStreamToFile(originalUrl,fileName);
filePath = cosFile.getPath();
log.info("cosFile.getPath() :{}",cosFile.getPath());//Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
log.info("cosFile.getAbsoluteFile() :{}",cosFile.getAbsoluteFile());///Users/anjiabin/mdsky_gitlab/liquidnet-bus-v1/Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
XuperUploadFileReqDto reqDto = XuperUploadFileReqDto.getNew();
reqDto.setMnemonic(xuperConfig.getNftPlatformMnemonic());
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()){
xuperUploadFileRespDto = uploadFileResp.getParseData(XuperUploadFileRespDto.class);
fullFilePath = xuperUploadFileRespDto.getLink();
}
}catch (XupterException e) {
log.error("biz error msg "+e.getMessage(),e);
}catch (Exception e) {
log.error("sys error msg "+e.getMessage(),e);
}
log.info("xuper getFullFilePath xuperUploadFile resp : "+ JsonUtils.toJson(xuperUploadFileRespDto));
log.info("完整的素材访问fullFilePath url:{}",fullFilePath);
return fullFilePath;
}
private String getNftHashByNftUrl(String originalUrl){
//原始介质文件hash值
String nftHashStr = null;
try {
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.getXuperNftImageCosCode() + imageType;
//通过图片url地址上传
File cosFile = galaxyCommonBiz.inputStreamToFile(originalUrl,fileName);
filePath = cosFile.getPath();
log.info("cosFile.getPath() :{}",cosFile.getPath());//Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
log.info("cosFile.getAbsoluteFile() :{}",cosFile.getAbsoluteFile());///Users/anjiabin/mdsky_gitlab/liquidnet-bus-v1/Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
byte[] fileByte = new byte[0];
try {
fileByte = galaxyCommonBiz.toByteArray(new File(filePath));
} catch (IOException e) {
e.printStackTrace();
}
try {
Account account = xuperSdkUtil.getAccount(xuperConfig.getNftPlatformMnemonic());
nftHashStr = Crypto.xassetSignECDSA(account,fileByte);
} catch (Exception var25) {
Base.logger.warning("account esdsa sign failed" + var25);
throw new XupterException(GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getCode(),GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getMessage());
}
}catch (XupterException e) {
log.error("biz error msg "+e.getMessage(),e);
}catch (Exception e) {
log.error("sys error msg "+e.getMessage(),e);
}
log.info("getNftHashByNftUrl url:{} ,hashStr:{}",originalUrl,nftHashStr);
return nftHashStr;
}
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());
//针对百度超级链增加nft整体发行状态
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.INIT.getCode());
//以下为购买信息
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(100l)); //积分
seriesNftInfoBo.setSellCount(sellCount);
seriesNftInfoBo.setNftHash(seriesNftUploadBo.getNftHashStr());
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;
}
}
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.common.third.xuper.config.XuperConfig;
import com.liquidnet.common.third.xuper.dto.*;
import com.liquidnet.common.third.xuper.exception.XupterException;
import com.liquidnet.common.third.xuper.util.XuperSdkUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.biz.GalaxyEnumBiz;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBindBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo;
import com.liquidnet.service.galaxy.dto.bo.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.time.LocalDateTime;
/**
* @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 XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@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;
//发行
Xuper004PublishAssetReqDto xuper004PublishAssetReqDto = Xuper004PublishAssetReqDto.getNew();
// 定义返回结果对象
Xuper004PublishAssetRespDto xuper004PublishAssetRespDto = null;
long assetId = Long.parseLong(seriesNftInfoBo.getSeriesId());
try {
xuper004PublishAssetReqDto.setMnemonic(xuperConfig.getNftPlatformMnemonic());
xuper004PublishAssetReqDto.setAssetId(assetId);
XuperResponseDto<Xuper004PublishAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper004PublishAsset(xuper004PublishAssetReqDto);
if(xuperResponseDto.isSuccess()){
xuper004PublishAssetRespDto = 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("xuper004PublishAsset resp : "+ JsonUtils.toJson(xuper004PublishAssetRespDto));
if (Integer.parseInt(ErrorCode.SUCCESS.getCode()) == xuper004PublishAssetRespDto.errNo){
//赋值返回参数
taskId = String.valueOf(assetId);
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());
nftOrderBo.setNftId(nftId);
nftOrderBo.setNftPublishTaskId(taskId);
}
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());
}
//NFT发行结果查询
Xuper005QueryAssetReqDto xuper005QueryAssetReqDto = Xuper005QueryAssetReqDto.getNew();
xuper005QueryAssetReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId()));
// 定义返回结果对象
Xuper005QueryAssetRespDto xuper005QueryAssetRespDto = null;
try {
XuperResponseDto<Xuper005QueryAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper005QueryAsset(xuper005QueryAssetReqDto);
if(xuperResponseDto.isSuccess()){
xuper005QueryAssetRespDto = 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("xuper005QueryAsset resp : "+ JsonUtils.toJson(xuper005QueryAssetRespDto));
if (Integer.parseInt(ErrorCode.SUCCESS.getCode()) == xuper005QueryAssetRespDto.getErrNo()){
//获取资产信息
Xuper005QueryAssetRespDto.AssetMeta assetMeta = xuper005QueryAssetRespDto.getMeta();
//设置时间
String nftPublishChainTimestampStr = DateUtil.getNowTime();
//转换任务状态
String nftPublishStatusStr = GalaxyEnumBiz.getAssetPublishStatusEnum(reqDto.getRouterType(),String.valueOf(assetMeta.getStatus())).getCode();
//更新缓存数据状态
nftOrderBo.setNftId(nftOrderBo.getNftId());
nftOrderBo.setNftPublishChainTimestamp(nftPublishChainTimestampStr);
nftOrderBo.setNftPublishStatus(nftPublishStatusStr);
nftOrderBo.setNftPublishTradeHash(assetMeta.getTxId());
nftOrderBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateNftOrderPublishInfo(reqDto.getRouterType(),reqDto.getNftOrderPayId(),nftOrderBo);
//构造返回结果
GalaxyNftPublishResultQueryRespDto nftPublishResultQueryRespDto = GalaxyNftPublishResultQueryRespDto.getNew();
nftPublishResultQueryRespDto.setNftIdBegin(nftOrderBo.getNftId());
nftPublishResultQueryRespDto.setTaskMsg(nftOrderBo.getNftId());
nftPublishResultQueryRespDto.setTxHash(nftOrderBo.getNftPublishTradeHash());
nftPublishResultQueryRespDto.setChainTimestamp(nftPublishChainTimestampStr);
nftPublishResultQueryRespDto.setTaskStatus(Integer.valueOf(nftPublishStatusStr));
return ResponseDto.success(nftPublishResultQueryRespDto);
}else{
return ResponseDto.failure(GalaxyErrorEnum.PUBLISH_FAIL.getCode(), GalaxyErrorEnum.PUBLISH_FAIL.getMessage());
}
}
}
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.liquidnet.common.third.xuper.config.XuperConfig;
import com.liquidnet.common.third.xuper.util.XuperSdkUtil;
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.biz.GalaxyBeanTransferBiz;
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.param.*;
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;
/**
* @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 XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@Autowired
private GalaxyDataUtils dataUtils;
@Autowired
private GalaxyBeanTransferBiz galaxyBeanTransferBiz;
@Autowired
private XuperTradeCommonBiz xuperTradeCommonBiz;
@Autowired
private QueueUtil queueUtil;
@Autowired
private XuperPublishBiz xuperPublishBiz;
/**
* 发行和购买
* @param reqDto
* @return
*/
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
return xuperTradeCommonBiz.nftPublishAndBuy(reqDto);
}
/**
* 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 = xuperPublishBiz.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= xuperTradeCommonBiz.nftBuyResultQuery(nftBuyResultQueryReqDto,nftOrderBo);
if(buyResultQueryRespDto.isSuccess()){
GalaxyNftBuyResultQueryRespDto nftBuyResultQueryRespDtoTemp = buyResultQueryRespDto.getData();
BeanUtil.copy(nftBuyResultQueryRespDtoTemp,nftOrderBo);
}
}
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);
}
}
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.common.third.xuper.config.XuperConfig;
import com.liquidnet.common.third.xuper.dto.*;
import com.liquidnet.common.third.xuper.exception.XupterException;
import com.liquidnet.common.third.xuper.util.XuperSdkUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
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.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 XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@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());
}
//获取sku信息
GalaxySeriesNftInfoBo seriesNftInfoBo = dataUtils.getSeriesNftInfoBo(reqDto.getRouterType(),nftOrderBo.getSkuId());
if(StringUtil.isNull(seriesNftInfoBo)){
return ResponseDto.failure(GalaxyErrorEnum.SERIES_NFT_INFO_NOT_EXIST.getCode(), GalaxyErrorEnum.SERIES_NFT_INFO_NOT_EXIST.getMessage());
}
//执行资产碎片授予查询
Xuper010QuerySdsReqDto xuper010QuerySdsReqDto = Xuper010QuerySdsReqDto.getNew();
// 定义返回结果对象
Xuper010QuerySdsRespDto xuper010QuerySdsRespDto = null;
long shardId = 1l;
try {
xuper010QuerySdsReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId()));
xuper010QuerySdsReqDto.setShardId(shardId);
XuperResponseDto<Xuper010QuerySdsRespDto> xuperResponseDto = xuperSdkUtil.xuper010QuerySds(xuper010QuerySdsReqDto);
if(xuperResponseDto.isSuccess()){
xuper010QuerySdsRespDto = 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("xuper010QuerySds resp : "+ JsonUtils.toJson(xuper010QuerySdsRespDto));
if(String.valueOf(xuper010QuerySdsRespDto.getErrNo()).equalsIgnoreCase(ErrorCode.SUCCESS.getCode())){
Xuper010QuerySdsRespDto.ShardMeta shardMeta = xuper010QuerySdsRespDto.getMeta();
Xuper010QuerySdsRespDto.ShardAssetInfo assetInfo = shardMeta.getAssetInfo();
//返回结果
GalaxyQueryNftInfoRespDto respDto = GalaxyQueryNftInfoRespDto.getNew();
respDto.setNftId(String.valueOf(shardMeta.getAssetId()));
respDto.setOwnerAddr(shardMeta.getOwnerAddr());
respDto.setAuthor(assetInfo.getCreateAddr());
respDto.setName(assetInfo.getTitle());
respDto.setUrl(seriesNftInfoBo.getNftUrl());
respDto.setDisplayUrl(seriesNftInfoBo.getDisplayUrl());
respDto.setHash(seriesNftInfoBo.getNftHash());
respDto.setOwnerGainedTime(shardMeta.getCtime());
respDto.setDesc(assetInfo.getShortDesc());
respDto.setFlag("");
respDto.setSeriesName(seriesNftInfoBo.getSeriesName());
respDto.setSeriesId(String.valueOf(shardMeta.getAssetId()));
respDto.setSeriesTotalNum(seriesNftInfoBo.getNftTotalCount());
respDto.setMetaData("");
respDto.setPublisherAddr(assetInfo.getCreateAddr());
respDto.setPublishPlatformAddr(assetInfo.getCreateAddr());
respDto.setSeriesIndexId(Long.valueOf(shardMeta.getShardId()).intValue());
respDto.setPublishTxHash(shardMeta.getTxId());
respDto.setSellStatus(1);
respDto.setSellCount(shardMeta.getPrice());
// GalaxyNftBuyResultQueryRespDto resultQueryRespDto = GalaxyNftBuyResultQueryRespDto.getNew();
// String nowTimeStr = DateUtil.getNowTime();
// //转换任务状态
// Integer taskStatus = Integer.valueOf(GalaxyEnumBiz.getGrantStatusEnum(reqDto.getRouterType(),String.valueOf(xuper010QuerySdsRespDto.getMeta().getStatus())).getCode());
// resultQueryRespDto.setTaskStatus(taskStatus);
// resultQueryRespDto.setChainTimestamp(nowTimeStr);
// resultQueryRespDto.setPayTaskId(xuper010QuerySdsRespDto.getMeta().getTxId());
// resultQueryRespDto.setTxHash(xuper010QuerySdsRespDto.getMeta().getTxId());
return ResponseDto.success(respDto);
}else{
return ResponseDto.failure(GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getCode(),GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getMessage());
}
}
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(1000l);
// 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());
}
Xuper005QueryAssetReqDto xuper005QueryAssetReqDto = Xuper005QueryAssetReqDto.getNew();
// 定义返回结果对象
Xuper005QueryAssetRespDto respDto = null;
//百度超级链使用的是资产id作为任务id
long assetId = Long.parseLong(seriesNftInfoBo.getSeriesId());
try {
xuper005QueryAssetReqDto.setAssetId(assetId);
XuperResponseDto<Xuper005QueryAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper005QueryAsset(xuper005QueryAssetReqDto);
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("seriesClaimResultQuery resp : "+ JsonUtils.toJson(respDto));
if(respDto.getErrNo() == Integer.parseInt(ErrorCode.SUCCESS.getCode())){
Xuper005QueryAssetRespDto.AssetMeta meta = respDto.getMeta();
//查询结果
GalaxyQuerySeriesInfoRespDto querySeriesInfoRespDto = GalaxyQuerySeriesInfoRespDto.getNew();
querySeriesInfoRespDto.setName(meta.getTitle());
querySeriesInfoRespDto.setSeriesId(String.valueOf(meta.getAssetId()));
querySeriesInfoRespDto.setCreatorAddr(meta.getCreateAddr());
querySeriesInfoRespDto.setCoverUrl(meta.getImgDesc().get(0).toString());
querySeriesInfoRespDto.setNftUrl(meta.getAssetUrl().get(0).toString());
querySeriesInfoRespDto.setNftThumbIcon(meta.getThumb()[0].getUrls().getIcon());
querySeriesInfoRespDto.setNftThumbUrl1(meta.getThumb()[0].getUrls().getUrl1());
querySeriesInfoRespDto.setNftThumbUrl2(meta.getThumb()[0].getUrls().getUrl2());
querySeriesInfoRespDto.setNftThumbUrl3(meta.getThumb()[0].getUrls().getUrl3());
querySeriesInfoRespDto.setDesc(meta.getShortDesc());
querySeriesInfoRespDto.setTotalCount(String.valueOf(meta.getAmount()));
querySeriesInfoRespDto.setSeriesBeginFromZero(Boolean.FALSE.toString());
querySeriesInfoRespDto.setCrtCount("-");
querySeriesInfoRespDto.setCreateTimeStamp(DateUtil.format(seriesNftInfoBo.getCreatedAt(), DateUtil.Formatter.yyyyMMddHHmmss));
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(1000l);
// 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);
return ResponseDto.failure();
}
public ResponseDto<GalaxyQueryUserTradeAllListRespDto> queryUserTradeAllList(GalaxyQueryUserTradeAllListReqDto reqDto) {
// Nft042TradeAllListReqDto nft042TradeAllListReqDto = Nft042TradeAllListReqDto.getNew();
// nft042TradeAllListReqDto.setAddr(reqDto.getBlockChainAddress());
// nft042TradeAllListReqDto.setLimit(1000l);
// 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);
return ResponseDto.failure();
}
public ResponseDto<GalaxyQueryUserTradeInListRespDto> queryUserTradeInList(GalaxyQueryUserTradeInListReqDto reqDto) {
// Nft040TradeInListReqDto nft040TradeInListReqDto = Nft040TradeInListReqDto.getNew();
// nft040TradeInListReqDto.setAddr(reqDto.getBlockChainAddress());
// nft040TradeInListReqDto.setLimit(1000l);
// 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);
return ResponseDto.failure();
}
public ResponseDto<GalaxyQueryUserTradeOutListRespDto> queryUserTradeOutList(GalaxyQueryUserTradeOutListReqDto reqDto) {
// Nft041TradeOutListReqDto nft041TradeOutListReqDto = Nft041TradeOutListReqDto.getNew();
// nft041TradeOutListReqDto.setAddr(reqDto.getBlockChainAddress());
// nft041TradeOutListReqDto.setLimit(1000l);
// 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);
return ResponseDto.failure();
}
}
package com.liquidnet.service.galaxy.router.xuper.biz;
import com.liquidnet.common.third.xuper.util.XuperSdkUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
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.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: 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;
@Autowired
private GalaxyDataUtils dataUtils;
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return xuperUserCommonBiz.userRegister(reqDto);
}
public ResponseDto<GalaxyUserBindStatusQueryRespDto> userBindStatusQuery(GalaxyUserBindStatusQueryReqDto reqDto){
//获取用户信息
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());
}
GalaxyUserBindStatusQueryRespDto userBindStatusQueryRespDto = GalaxyUserBindStatusQueryRespDto.getNew();
userBindStatusQueryRespDto.setBlockChainAddress(userInfoBo.getBlockChainAddress());
Integer userBindStatus = Integer.valueOf(GalaxyEnum.UserBindStatusEnum.BIND_SUCCESS.getCode());
userBindStatusQueryRespDto.setUserBindStatus(userBindStatus);
return ResponseDto.success(userBindStatusQueryRespDto);
}
}
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
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);
}
}
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 null;
}
@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 null;
}
}
\ No newline at end of file
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);
}
}
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) {
//暂时屏蔽xuper开户,直接通过至信链实名开户
// return xuperUserBiz.userRegister(reqDto);
return null;
}
@Override
public ResponseDto<GalaxyUserBindStatusQueryRespDto> userBindStatusQuery(GalaxyUserBindStatusQueryReqDto reqDto) {
return xuperUserBiz.userBindStatusQuery(reqDto);
}
}
......@@ -25,7 +25,6 @@ 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.exception.GalaxyNftUserException;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -248,102 +247,6 @@ public class ZxinArtworkBiz {
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());
......@@ -450,7 +353,7 @@ public class ZxinArtworkBiz {
return fullFilePath;
}
public GalaxySeriesNftUploadTempSecretBo getSeriesNftUploadTempSecret(String seriesName){
private GalaxySeriesNftUploadTempSecretBo getSeriesNftUploadTempSecret(String seriesName){
//获取临时密钥
GalaxySeriesNftUploadTempSecretBo seriesNftUploadTempSecretBo = dataUtils.getSeriesNftUploadTempSecretBo(seriesName);
if(StringUtil.isNull(seriesNftUploadTempSecretBo)){
......
......@@ -7,8 +7,11 @@ import com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto;
import com.liquidnet.common.third.zxlnft.dto.nft.Nft016QueryRsData;
import com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil;
import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.biz.GalaxyEnumBiz;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
......@@ -50,8 +53,15 @@ public class ZxinUserBiz {
}
public ResponseDto<GalaxyUserBindStatusQueryRespDto> userBindStatusQuery(GalaxyUserBindStatusQueryReqDto reqDto){
//获取用户信息
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());
}
Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew();
nft016ReqDto.setAddressList(reqDto.getBlockChainAddress());
nft016ReqDto.setAddressList(userInfoBo.getBlockChainAddress());
ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> zxlnftResponseDto = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
GalaxyUserBindStatusQueryRespDto userBindStatusQueryRespDto = GalaxyUserBindStatusQueryRespDto.getNew();
......
......@@ -9,6 +9,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 +30,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);
}
......
......@@ -9,7 +9,7 @@ eureka:
spring:
cloud:
config:
# uri: http://182.92.70.253:7002/support-config
# uri: http://127.0.0.1:7002/support-config
# uri: http://39.107.71.112:7002/support-config
profile: ${liquidnet.cloudConfig.profile}
name: ${spring.application.name} #默认为spring.application.name
......
package com.liquidnet.service.goblin.test.xuper;
import com.baidu.xasset.auth.Crypto;
import com.baidu.xasset.client.base.Base;
import com.baidu.xuper.api.Account;
import com.liquidnet.common.third.xuper.config.XuperConfig;
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.service.galaxy.biz.GalaxyCommonBiz;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
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 java.io.File;
import java.io.IOException;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: TestUrlHash
* @Package com.liquidnet.service.goblin.test.xuper
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/6/29 16:10
*/
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class TestUrlHash {
@Autowired
private GalaxyCommonBiz galaxyCommonBiz;
@Autowired
private XuperSdkUtil xuperSdkUtil;
@Autowired
private XuperConfig xuperConfig;
@Test
public void getAccount(){
Account account = null;
try {
account = xuperSdkUtil.getAccount(xuperConfig.getNftPlatformMnemonic());
log.info("accountgetAddress : {}",account.getAddress());
} catch (Exception var25) {
Base.logger.warning("account esdsa sign failed" + var25);
throw new XupterException(GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getCode(),GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getMessage());
}
}
@Test
public void testGetNftHashByNftUrl(){
String url = "https://zhixinliantest-1302317679.cos.ap-guangzhou.myqcloud.com/nft/4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef/ZXLNFTIMAGE202202241512003609141721.jpg";
log.info("hash === {} ",this.getNftHashByNftUrl(url));
}
private String getNftHashByNftUrl(String originalUrl){
//原始介质文件hash值
String nftHashStr = null;
try {
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.getXuperNftImageCosCode() + imageType;
//通过图片url地址上传
File cosFile = galaxyCommonBiz.inputStreamToFile(originalUrl,fileName);
filePath = cosFile.getPath();
log.info("cosFile.getPath() :{}",cosFile.getPath());//Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
log.info("cosFile.getAbsoluteFile() :{}",cosFile.getAbsoluteFile());///Users/anjiabin/mdsky_gitlab/liquidnet-bus-v1/Users/anjiabin/data/galaxy/tempFilePath/XUPERNFTIMAGE202206291056041871343690.jpg
byte[] fileByte = new byte[0];
try {
fileByte = galaxyCommonBiz.toByteArray(new File(filePath));
} catch (IOException e) {
e.printStackTrace();
}
try {
Account account = xuperSdkUtil.getAccount(xuperConfig.getNftPlatformMnemonic());
nftHashStr = Crypto.xassetSignECDSA(account,fileByte);
} catch (Exception var25) {
Base.logger.warning("account esdsa sign failed" + var25);
throw new XupterException(GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getCode(),GalaxyErrorEnum.SERIES_NFT_HASH_CREATE_FAIL.getMessage());
}
// nftHashStr = new String(Hash.doubleSha256(fileByte));
}catch (XupterException e) {
log.error("biz error msg "+e.getMessage(),e);
}catch (Exception e) {
log.error("sys error msg "+e.getMessage(),e);
}
log.info("getNftHashByNftUrl url:{} ,hashStr:{}",originalUrl,nftHashStr);
return nftHashStr;
}
}
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.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.galaxy.biz.GalaxyCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
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;
import java.util.Date;
/**
* @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));
Integer time = 1656644857;
String nowTimeStr = DateUtil.format(new Date(time),DateUtil.Formatter.yyyyMMddHHmmss);
System.out.println("nowTimeStr==="+nowTimeStr);
}
@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("testXuperUploadFile 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(1000l);
//资产分类。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(123123l);
//(可选)业务侧用户标记,必要时请安全处理后设置
reqDto.setUserId(123123l);
//(可选)要存证的资产文件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(1710956158450194370l);
//设置助记词
reqDto.setMnemonic(creatorMnemonic);
//资产碎片数量,小于1和大于200000代表不做库存限制
reqDto.setAmount(100);
//藏品显示售卖价格,单位为分
reqDto.setPrice(1000l);
//资产分类。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(123123l);
//(可选)业务侧用户标记,必要时请安全处理后设置
reqDto.setUserId(123123l);
//(可选)要存证的资产文件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 = 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));
}
/**
* 005查询数字商品详情
*/
@Test
public void testXuper005QueryAsset(){
Xuper005QueryAssetReqDto reqDto = Xuper005QueryAssetReqDto.getNew();
// 定义返回结果对象
Xuper005QueryAssetRespDto respDto = null;
long assetId = 166759372822785837l; //第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 = 4;
//要拉取的区块链账户地址
String addr = xuperSdkUtil.getAccount(creatorMnemonic).getAddress();
//要拉取页数,第一页为1
int page = 1;
//每页拉取数量,默认20,最大50(可选)
int limit = 50;
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 = 171095615845019437l;
// long assetId = 1532351545249738541l;
try {
reqDto.setMnemonic(creatorMnemonic);
reqDto.setAssetId(assetId);
reqDto.setShardId(1l);
reqDto.setToAddr(xuperSdkUtil.getAccount(customerMnemonic).getAddress());
reqDto.setToUserId(100000l);
reqDto.setPrice(1234l);
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 = 171095615845019437l;
// long assetId = 1532351545249738541l;
try {
reqDto.setMnemonic(customerMnemonic);
reqDto.setAssetId(assetId);
reqDto.setShardId(1l);
reqDto.setToAddr(xuperSdkUtil.getAccount(customerMnemonic2).getAddress());
reqDto.setToUserId(100000l);
reqDto.setPrice(1234l);
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 = 171095615845019437l;
// 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 = 171095615845019437l;
// assetId = 477060752401870637l;
assetId = 2203931451566698285l;
long shardId = 1l;
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(){
//要查询的区块链账户地址
String addr = xuperConfig.getNftPlatformAddress();
//xuper-userid-002
addr = "acsuf4Mrz9r38KERQGabsoDsa4MPEcF85";
Xuper011ListSdsByAddrReqDto reqDto = Xuper011ListSdsByAddrReqDto.getNew();
// 定义返回结果对象
Xuper011ListSdsByAddrRespDto respDto = null;
try {
reqDto.setAddr(addr);
reqDto.setPage(1);
reqDto.setLimit(50);
XuperResponseDto<Xuper011ListSdsByAddrRespDto> xuperResponseDto = xuperSdkUtil.xuper011ListSdsByAddr(reqDto);
if(xuperResponseDto.isSuccess()){
respDto = xuperResponseDto.getParseData(Xuper011ListSdsByAddrRespDto.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("testXuper011ListSdsByAddr resp : "+ JsonUtils.toJson(respDto));
}
@Test
public void testXuper012ListSdsByAst(){
Xuper012ListSdsByAstReqDto reqDto = Xuper012ListSdsByAstReqDto.getNew();
// 定义返回结果对象
Xuper012ListSdsByAstRespDto respDto = null;
//xuper-skuid-003
long assetId = 477060752401870637l;
//xuper-skuid-004
assetId = 2203931451566698285l;
//xuper-skuid-008
assetId = 139521326019882797l;
try {
reqDto.setAssetId(assetId);
reqDto.setCursor("");
reqDto.setLimit(20);
XuperResponseDto<Xuper012ListSdsByAstRespDto> xuperResponseDto = xuperSdkUtil.xuper012ListSdsByAst(reqDto);
if(xuperResponseDto.isSuccess()){
respDto = xuperResponseDto.getParseData(Xuper012ListSdsByAstRespDto.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("testXuper012ListSdsByAst resp : "+ JsonUtils.toJson(respDto));
}
@Test
public void testXuper013History(){
Xuper013HistoryReqDto reqDto = Xuper013HistoryReqDto.getNew();
// 定义返回结果对象
Xuper013HistoryRespDto respDto = null;
//xuper-skuid-003
long assetId = 477060752401870637l;
//xuper-skuid-004
assetId = 2203931451566698285l;
//xuper-skuid-008
assetId = 139521326019882797l;
try {
reqDto.setAssetId(assetId);
reqDto.setPage(1);
reqDto.setLimit(20);
XuperResponseDto<Xuper013HistoryRespDto> xuperResponseDto = xuperSdkUtil.xuper013History(reqDto);
if(xuperResponseDto.isSuccess()){
respDto = xuperResponseDto.getParseData(Xuper013HistoryRespDto.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("testXuper013History resp : "+ JsonUtils.toJson(respDto));
}
/**
* 资产冻结操作-谨慎使用
*/
@Test
public void testXuper014FreezeAsset(){
// Xuper014FreezeAssetReqDto reqDto = Xuper014FreezeAssetReqDto.getNew();
// // 定义返回结果对象
// Xuper014FreezeAssetRespDto respDto = null;
// long assetId = 171095615845019437l;
//// long assetId = 1532351545249738541l;
// try {
// reqDto.setMnemonic(creatorMnemonic);
// reqDto.setAssetId(assetId);
// XuperResponseDto<Xuper014FreezeAssetRespDto> xuperResponseDto = xuperSdkUtil.xuper014FreezeAsset(reqDto);
// if(xuperResponseDto.isSuccess()){
// respDto = xuperResponseDto.getParseData(Xuper014FreezeAssetRespDto.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("testXuper014FreezeAsset resp : "+ JsonUtils.toJson(respDto));
}
@Test
public void testXuper015GetEvidenceInfo(){
Xuper015GetEvidenceInfoReqDto reqDto = Xuper015GetEvidenceInfoReqDto.getNew();
// 定义返回结果对象
Xuper015GetEvidenceInfoRespDto respDto = null;
long assetId = 171095615845019437l;
// long assetId = 1532351545249738541l;
try {
reqDto.setAssetId(assetId);
XuperResponseDto<Xuper015GetEvidenceInfoRespDto> xuperResponseDto = xuperSdkUtil.xuper015GetEvidenceInfo(reqDto);
if(xuperResponseDto.isSuccess()){
respDto = xuperResponseDto.getParseData(Xuper015GetEvidenceInfoRespDto.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("testXuper015GetEvidenceInfo resp : "+ JsonUtils.toJson(respDto));
}
}
......@@ -38,6 +38,12 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-goblin-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
......@@ -7,6 +7,8 @@ import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.adam.dto.vo.AdamUserMemberVo;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.service.IKylinConsmerService;
import com.liquidnet.service.kylin.service.IKylinPerformancesService;
import com.liquidnet.service.kylin.service.impl.KylinPerformancesServiceImpl;
import com.liquidnet.service.kylin.utils.DataUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
@Api(tags = "内部接口")
@RestController
......@@ -33,6 +36,9 @@ public class InnerController {
@Autowired
IKylinConsmerService kylinConsmerService;
@Autowired
private KylinPerformancesServiceImpl kylinPerformancesService;
@GetMapping("cache/member/{uid}")
@ApiOperation("获取会员相关数据")
public void cacheMember(@NotBlank @PathVariable(value = "uid") String uid) {
......@@ -68,4 +74,11 @@ public class InnerController {
public ResponseDto<Boolean> orderTransferOverTime(String orderId) {
return kylinConsmerService.orderTransferOverTime(orderId);
}
@GetMapping("/setNoticeIds")
@ApiOperation("演出预告列表定时任务")
public ResponseDto<HashMap<String,Object>> setNoticeIds(){
HashMap<String, Object> map = kylinPerformancesService.setNoticeIds();
return ResponseDto.success(map);
}
}
......@@ -9,6 +9,7 @@ import com.liquidnet.service.kylin.dto.vo.returns.PayDetailVo;
import com.liquidnet.service.kylin.service.IKylinLackRegistersService;
import com.liquidnet.service.kylin.service.IKylinPerformancesService;
import com.liquidnet.service.kylin.service.impl.KylinPerformancesServiceImpl;
import com.liquidnet.service.kylin.utils.DataUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......
......@@ -7,6 +7,7 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.SmileUserVO;
import com.liquidnet.service.kylin.constant.KylinPerformanceStatusEnum;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
......@@ -152,6 +153,14 @@ public class KylinPerformancesServiceImpl implements IKylinPerformancesService {
HashMap<String, Object> performancesListNotice = dataUtils.getPerformancesListNotice();
List<KylinPerformanceVo> toDayList = (List<KylinPerformanceVo>) performancesListNotice.get("toDayList");
List<KylinPerformanceVo> threeDaysList = (List<KylinPerformanceVo>) performancesListNotice.get("threeDaysList");
List<GoblinGoodsSkuInfoVo> toDaysNftList = (List<GoblinGoodsSkuInfoVo>) performancesListNotice.get("toDaysNftList");
List<GoblinGoodsSkuInfoVo> threeDayNftList = (List<GoblinGoodsSkuInfoVo>) performancesListNotice.get("threeDayNftList");
List<GoblinGoodsSkuInfoVo> toDayCombinationList = (List<GoblinGoodsSkuInfoVo>) performancesListNotice.get("toDayCombinationList");
List<GoblinGoodsSkuInfoVo> threeDayCombinationList = (List<GoblinGoodsSkuInfoVo>) performancesListNotice.get("threeDayCombinationList");
/*List<NoticeGoblinGoodsSkuInfoVo> toDaysNftList = (List<NoticeGoblinGoodsSkuInfoVo>) performancesListNotice.get("toDaysNftList");
List<NoticeGoblinGoodsSkuInfoVo> threeNftList = (List<NoticeGoblinGoodsSkuInfoVo>) performancesListNotice.get("threeNftList");
List<NoticeGoblinMixDetailsVo> toDayCombinationList = (List<NoticeGoblinMixDetailsVo>) performancesListNotice.get("toDayCombinationList");
List<NoticeGoblinMixDetailsVo> threeDayCombinationList = (List<NoticeGoblinMixDetailsVo>) performancesListNotice.get("threeDayCombinationList");*/
toDayList = checkAppStatus(toDayList);
threeDaysList = checkAppStatus(threeDaysList);
......@@ -163,9 +172,17 @@ public class KylinPerformancesServiceImpl implements IKylinPerformancesService {
HashMap<String, Object> newList = CollectionUtil.mapStringObject();
newList.put("toDayList", toDayList);
newList.put("threeDaysList", threeDaysList);
newList.put("toDaysNftList",toDaysNftList);
newList.put("threeDayNftList",threeDayNftList);
newList.put("toDayCombinationList",toDayCombinationList);
newList.put("threeDayCombinationList",threeDayCombinationList);
return newList;
}
public HashMap<String,Object> setNoticeIds() {
return dataUtils.setNoticeIds();
}
private List<KylinPerformanceVo> mergeRoadList(List<KylinPerformanceVo> performanceList) {
List<String> roadIdList = new ArrayList<>();
List<KylinPerformanceVo> newList = ObjectUtil.getKylinPerformanceVoArrayList();
......
......@@ -3,6 +3,9 @@ package com.liquidnet.service.kylin.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinGoodsAnticipateValueVo;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.constant.KylinTableStatusConst;
import com.liquidnet.service.kylin.dao.KylinTicketActive;
......@@ -17,6 +20,7 @@ import com.liquidnet.service.kylin.dto.vo.mongo.*;
import com.liquidnet.service.kylin.dto.vo.partner.KylinTicketExpressModuleVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderListVo;
import com.liquidnet.service.kylin.dto.vo.returns.KylinOrderRefundsVo;
import com.liquidnet.service.kylin.dto.vo.returns.NoticeKylinPerformanceVo;
import com.liquidnet.service.kylin.entity.KylinOrderCoupons;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -43,6 +47,9 @@ public class DataUtils {
@Autowired
private RedisUtil redisUtil;
@Autowired
GoblinRedisUtils goblinRedisUtils;
/**
* 转赠订单
......@@ -354,56 +361,385 @@ public class DataUtils {
* 获取演出预告列表redis
*/
public HashMap<String, Object> getPerformancesListNotice() {
String redisKey = KylinRedisConst.PERFORMANCES_LIST_NOTICE;
Object obj = redisUtil.get(redisKey);
if (obj == null) {
// 固定条件
Query query = getCommonWhere();
// 排序
Sort sortName = Sort.by(Sort.Direction.ASC, "sellTime");
query.with(sortName);
String redisKeyIds = KylinRedisConst.PERFORMANCES_LIST_NOTICE_IDS;
Object obj = redisUtil.get(redisKeyIds);
if (obj != null) {
//获取ids
HashMap<String, Object> map = (HashMap<String, Object>) obj;
List<String> toDayIds = (List<String>) map.get("toDayIds");
List<String> threeDayIds = (List<String>) map.get("threeDayIds");
List<String> toDayNftIds = (List<String>) map.get("toDayNftIds");
List<String> threeNftIds = (List<String>) map.get("threeNftIds");
List<String> toDayCombinationIds = (List<String>) map.get("toDayCombinationIds");
List<String> threeDayCombinationIds = (List<String>) map.get("threeDayCombinationIds");
// 今天的
HashMap toDayTime = DateUtil.oneDayStartEnd();
String nowTimeTStr = (String) toDayTime.get("startStr");
String toDayEndTimeStr = (String) toDayTime.get("endStr");
query.addCriteria(Criteria.where("sellTime").gte(nowTimeTStr).lt(toDayEndTimeStr));
query.fields().exclude("details");
query.fields().exclude("noticeImage");
query.fields().exclude("ticketTimeList");
query.fields().exclude("describeElectronic");
List<KylinPerformanceVo> toDayList = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
List<String> roadShowId = toDayList.stream().filter(r -> !r.getRoadShowId().equals("0")).map(KylinPerformanceVo -> KylinPerformanceVo.getRoadShowId()).collect(Collectors.toList());
// 固定条件
List<KylinPerformanceVo> toDayList = getKylinPerformanceVos(toDayIds);
toDayList.forEach(kylinPerformanceVo -> {
kylinPerformanceVo.setNoticeImage(null);
kylinPerformanceVo.setTicketTimeList(null);
kylinPerformanceVo.setDetails(null);
});
/*List<NoticeKylinPerformanceVo> toDayVoList = toDayList.stream().map(kylinPerformanceVo -> {
return NoticeKylinPerformanceVo.getNew().copy(kylinPerformanceVo);
}).collect(Collectors.toList());*/
// 固定条件
Query queryT = getCommonWhere();
// 排序
Sort sortNameT = Sort.by(Sort.Direction.ASC, "sellTime");
queryT.with(sortNameT);
// 三天的
Calendar cal = Calendar.getInstance();
cal.setTime((Date) toDayTime.get("end"));
Date beforeDayEnd = DateUtil.getBeforeDayEnd(cal, 2);
String threeDaysLaterStr = DateUtil.SDF_YMD_HMS.format(beforeDayEnd);
queryT.addCriteria(Criteria.where("sellTime").gte(toDayEndTimeStr).lt(threeDaysLaterStr));
queryT.fields().exclude("details");
queryT.fields().exclude("noticeImage");
queryT.fields().exclude("ticketTimeList");
queryT.fields().exclude("describeElectronic");
queryT.addCriteria(Criteria.where("roadShowId").nin(roadShowId));
List<KylinPerformanceVo> threeDaysList = mongoTemplate.find(queryT, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
List<KylinPerformanceVo> threeDaysList = getKylinPerformanceVos(threeDayIds);
threeDaysList.forEach(kylinPerformanceVo -> {
kylinPerformanceVo.setNoticeImage(null);
kylinPerformanceVo.setTicketTimeList(null);
kylinPerformanceVo.setDetails(null);
});
/*List<NoticeKylinPerformanceVo> threeDayVoList = threeDaysList.stream().map(kylinPerformanceVo -> {
return NoticeKylinPerformanceVo.getNew().copy(kylinPerformanceVo);
}).collect(Collectors.toList());*/
//数字藏品
List<NoticeGoblinGoodsSkuInfoVo> toDayNftVoList = null;
List<NoticeGoblinGoodsSkuInfoVo> threeDayNftVoList = null;
try {
//当天
List<GoblinGoodsSkuInfoVo> toDaysNftList = getGoblinGoodsSkuInfoVos(toDayNftIds);
toDayNftVoList = aboutDayNftVoList(toDaysNftList);
//三天的
List<GoblinGoodsSkuInfoVo> threeNftList = getGoblinGoodsSkuInfoVos(threeNftIds);
threeDayNftVoList = aboutDayNftVoList(threeNftList);
} catch (Exception e) {
log.error("return NftVoList error!");
}
//组合购
List<NoticeGoblinMixDetailsVo> toDayCombinationVoList = null;
List<NoticeGoblinMixDetailsVo> threeDayCombinationVoList = null;
try {
//当天
List<GoblinMixDetailsVo> toDayCombinationList = getGoblinMixDetailsVos(toDayCombinationIds);
toDayCombinationVoList = toDayCombinationList.stream().map(goblinMixDetailsVo -> NoticeGoblinMixDetailsVo.getNew().copy(goblinMixDetailsVo)).collect(Collectors.toList());
//三天
List<GoblinMixDetailsVo> threeDayCombinationList = getGoblinMixDetailsVos(threeDayCombinationIds);
threeDayCombinationVoList = threeDayCombinationList.stream().map(goblinMixDetailsVo -> NoticeGoblinMixDetailsVo.getNew().copy(goblinMixDetailsVo)).collect(Collectors.toList());
} catch (Exception e) {
log.error("return CombinationVoList error!");
}
HashMap<String, Object> info = CollectionUtil.mapStringObject();
info.put("toDayList", toDayList);
info.put("threeDaysList", threeDaysList);
redisUtil.set(redisKey, info);
//过滤数据
info.put("toDaysNftList", toDayNftVoList);
info.put("threeDayNftList", threeDayNftVoList);
info.put("toDayCombinationList", toDayCombinationVoList);
info.put("threeDayCombinationList", threeDayCombinationVoList);
//原始数据
// info.put("toDaysNftList", toDaysNftList);
// info.put("threeNftList", threeNftList);
// info.put("toDayCombinationList", toDayCombinationList);
// info.put("threeDayCombinationList", threeDayCombinationList);
return info;
}
return (HashMap<String, Object>) obj;
}
private List<NoticeGoblinGoodsSkuInfoVo> aboutDayNftVoList(List<GoblinGoodsSkuInfoVo> toDaysNftList) {
LocalDateTime now = LocalDateTime.now();
String anticipateKey = GoblinRedisConst.ANTICIPATE_VALUE_SKUID;
List<NoticeGoblinGoodsSkuInfoVo> toDayNftVoList = toDaysNftList.stream().map(goblinGoodsSkuInfoVo -> {
NoticeGoblinGoodsSkuInfoVo noticeGoblinGoodsSkuInfoVo = NoticeGoblinGoodsSkuInfoVo.getNew().copy(goblinGoodsSkuInfoVo);
//获取预约开始结束时间
/*Object valueVo = redisUtil.get(anticipateKey.concat(goblinGoodsSkuInfoVo.getSkuId()));
if (valueVo != null) {
noticeGoblinGoodsSkuInfoVo = noticeGoblinGoodsSkuInfoVo.valueCopy((GoblinGoodsAnticipateValueVo) valueVo);
noticeGoblinGoodsSkuInfoVo.setTagType(2);
} else {
//非预约sku 查询优先购分批购
HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(now, goblinGoodsSkuInfoVo.getSkuId());
if (map != null) {
Integer tagType = (Integer) map.get("tagType");
String listId = (String) map.get("listId");
noticeGoblinGoodsSkuInfoVo.setTagType(tagType);
noticeGoblinGoodsSkuInfoVo.setListId(listId);
}
}*/
//非预约sku 查询优先购分批购
HashMap<String, Object> map = goblinRedisUtils.getGoodsSkuInfoVo(now, goblinGoodsSkuInfoVo.getSkuId());
if (map != null) {
Integer tagType = (Integer) map.get("tagType");
String listId = (String) map.get("listId");
noticeGoblinGoodsSkuInfoVo.setTagType(tagType);
noticeGoblinGoodsSkuInfoVo.setListId(listId);
}
//根据spuId获取创作者 发行方
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getGoodsInfoVo(goblinGoodsSkuInfoVo.getSpuId());
noticeGoblinGoodsSkuInfoVo.setPublisher(goodsInfoVo.getPublisher());
noticeGoblinGoodsSkuInfoVo.setAuthor(goodsInfoVo.getAuthor());
//普通数字藏品
if (noticeGoblinGoodsSkuInfoVo.getTagType() == null) {
noticeGoblinGoodsSkuInfoVo.setTagType(3);
}
return noticeGoblinGoodsSkuInfoVo;
}).collect(Collectors.toList());
return toDayNftVoList;
}
private List<GoblinMixDetailsVo> getGoblinMixDetailsVos(List<String> toDayCombinationIds) {
List<GoblinMixDetailsVo> toDayCombinationList = new ArrayList<>();
//redis key
String rdk = GoblinRedisConst.GOBLIN_MIX_DETAILS;
String rk = GoblinRedisConst.BASIC_GOODS_SKU;
if (toDayCombinationIds != null && toDayCombinationIds.size() > 0) {
//查询redis
toDayCombinationIds.forEach(id -> {
Object obj = redisUtil.get(rdk.concat(id));
if (obj != null) {
GoblinMixDetailsVo goblinMixDetailsVo = (GoblinMixDetailsVo) obj;
goblinMixDetailsVo.getItem().forEach(goblinMixDetailsItemVo -> {
Object objRk = redisUtil.get(rk.concat(goblinMixDetailsItemVo.getSkuId()));
if (objRk != null) {
goblinMixDetailsItemVo.setSkuName(((GoblinGoodsSkuInfoVo) objRk).getName());
}
});
toDayCombinationList.add(goblinMixDetailsVo);
}
});
/*Query queryToDayCombination = new Query();
Sort sortToDayCombination = Sort.by(Sort.Direction.ASC, "saleStartTime");
queryToDayCombination.with(sortToDayCombination);
queryToDayCombination.fields().exclude("details");
queryToDayCombination.addCriteria(Criteria.where("mixId").in(toDayCombinationIds));
toDayCombinationList = mongoTemplate.find(queryToDayCombination, GoblinMixDetailsVo.class, GoblinMixDetailsVo.class.getSimpleName());
toDayCombinationList.forEach(goblinMixDetailsVo -> {
List<GoblinMixDetailsItemVo> item = goblinMixDetailsVo.getItem();
item.forEach(goblinMixDetailsItemVo -> {
Query query = new Query();
query.addCriteria(Criteria.where("skuId").is(goblinMixDetailsItemVo.getSkuId()));
//skuName查询redis
Object objRk = redisUtil.get(rk.concat(goblinMixDetailsItemVo.getSkuId()));
if (objRk != null) {
goblinMixDetailsItemVo.setSkuName(((GoblinGoodsSkuInfoVo) objRk).getName());
}
//skuName查询mongodb
*//*GoblinGoodsSkuInfoVo one = mongoTemplate.findOne(query, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
if (one != null) {
goblinMixDetailsItemVo.setSkuName(one.getName());
}*//*
});
});*/
}
return toDayCombinationList;
}
private List<GoblinGoodsSkuInfoVo> getGoblinGoodsSkuInfoVos(List<String> toDayNftIds) {
List<GoblinGoodsSkuInfoVo> toDaysNftList = new ArrayList<>();
//redis key
String rk = GoblinRedisConst.BASIC_GOODS_SKU;
if (toDayNftIds != null && toDayNftIds.size() > 0) {
//查询redis
toDayNftIds.forEach(id -> {
Object obj = redisUtil.get(rk.concat(id));
if (obj != null) {
toDaysNftList.add((GoblinGoodsSkuInfoVo) obj);
}
});
//查询mongodb
/*Query queryToDayNft = new Query();
queryToDayNft.fields().exclude("extagVoList");
queryToDayNft.addCriteria(Criteria.where("skuId").in(toDayNftIds));
toDaysNftList = mongoTemplate.find(queryToDayNft, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());*/
}
return toDaysNftList;
}
private List<KylinPerformanceVo> getKylinPerformanceVos(List<String> toDayIds) {
List<KylinPerformanceVo> toDayList = new ArrayList<>();
//redis key
String key = KylinRedisConst.PERFORMANCES;
if (toDayIds != null && toDayIds.size() > 0) {
//查询redis
toDayIds.forEach(id -> {
Object obj = redisUtil.get(key + id);
if (obj != null) {
toDayList.add((KylinPerformanceVo) obj);
} else {
Query query = new Query();
query.fields().exclude("details");
query.fields().exclude("noticeImage");
query.fields().exclude("ticketTimeList");
query.fields().exclude("describeElectronic");
query.addCriteria(Criteria.where("performancesId").is(id));
KylinPerformanceVo one = mongoTemplate.findOne(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
if (one != null) {
//增加redis缓存
redisUtil.set(key + id, one);
toDayList.add(one);
}
}
});
}
return toDayList;
}
//执行脚本
public HashMap<String, Object> setNoticeIds() {
// 固定条件
Query query = getCommonWhere();
// 排序
Sort sortName = Sort.by(Sort.Direction.ASC, "sellTime");
query.with(sortName);
// 今天的
HashMap toDayTime = DateUtil.oneDayStartEnd();
String nowTimeTStr = (String) toDayTime.get("startStr");
String toDayEndTimeStr = (String) toDayTime.get("endStr");
query.addCriteria(Criteria.where("sellTime").gte(nowTimeTStr).lt(toDayEndTimeStr));
query.fields().exclude("details");
query.fields().exclude("noticeImage");
query.fields().exclude("ticketTimeList");
query.fields().exclude("describeElectronic");
List<KylinPerformanceVo> toDayList = mongoTemplate.find(query, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
List<String> roadShowId = toDayList.stream().filter(r -> !r.getRoadShowId().equals("0")).map(KylinPerformanceVo -> KylinPerformanceVo.getRoadShowId()).collect(Collectors.toList());
List<String> toDayIds = toDayList.stream().map(KylinPerformanceVo::getPerformancesId).collect(Collectors.toList());
// 固定条件
Query queryT = getCommonWhere();
// 排序
Sort sortNameT = Sort.by(Sort.Direction.ASC, "sellTime");
queryT.with(sortNameT);
// 三天的
Calendar cal = Calendar.getInstance();
cal.setTime((Date) toDayTime.get("end"));
Date beforeDayEnd = DateUtil.getBeforeDayEnd(cal, 2);
String threeDaysLaterStr = DateUtil.SDF_YMD_HMS.format(beforeDayEnd);
queryT.addCriteria(Criteria.where("sellTime").gte(toDayEndTimeStr).lt(threeDaysLaterStr));
queryT.fields().exclude("details");
queryT.fields().exclude("noticeImage");
queryT.fields().exclude("ticketTimeList");
queryT.fields().exclude("describeElectronic");
queryT.addCriteria(Criteria.where("roadShowId").nin(roadShowId));
List<KylinPerformanceVo> threeDaysList = mongoTemplate.find(queryT, KylinPerformanceVo.class, KylinPerformanceVo.class.getSimpleName());
List<String> threeDayIds = threeDaysList.stream().map(KylinPerformanceVo::getPerformancesId).collect(Collectors.toList());
//数字藏品
LocalDateTime nowTimeTime = null;
List<String> toDayNftIds = null;
List<String> threeNftIds = null;
try {
nowTimeTime = DateUtil.asLocalDateTime((Date) toDayTime.get("start"));
LocalDateTime toDayEndTime = DateUtil.asLocalDateTime((Date) toDayTime.get("end"));
LocalDateTime threeEndTime = DateUtil.asLocalDateTime(beforeDayEnd);
//查询预约(当天)
// List<GoblinGoodsSkuInfoVo> toDayAboutNft = getAboutNftByStartAndEndTime(nowTimeTime, toDayEndTime,0);
// List<String> toDayAboutNftSkuIds = toDayAboutNft.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
/*List<String> toDayAboutNft = getAboutNftByStartAndEndTime(nowTimeTime, toDayEndTime, 0);*/
//查询预约(三天)
// List<GoblinGoodsSkuInfoVo> threeDayAboutNft = getAboutNftByStartAndEndTime(toDayEndTime, threeEndTime,1);
// List<String> threeDayAboutNftSkuIds = threeDayAboutNft.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
// toDayAboutNftSkuIds.addAll(threeDayAboutNftSkuIds);
/*List<String> threeDayAboutNft = getAboutNftByStartAndEndTime(toDayEndTime, threeEndTime, 1);*/
/*ArrayList<String> allListSkuIds = new ArrayList<>();
allListSkuIds.addAll(toDayAboutNft);
allListSkuIds.addAll(threeDayAboutNft);*/
//当天
Query queryToDayNft = new Query();
queryToDayNft.addCriteria(Criteria.where("skuType").is(1));
queryToDayNft.addCriteria(Criteria.where("delFlg").is("0"));
queryToDayNft.addCriteria(Criteria.where("saleStartTime").gte(nowTimeTime).lt(toDayEndTime));
// queryToDayNft.addCriteria(Criteria.where("skuId").nin(toDayAboutNftSkuIds));
/* queryToDayNft.addCriteria(Criteria.where("skuId").nin(allListSkuIds));*/
queryToDayNft.addCriteria(Criteria.where("shelvesHandle").ne("3"));
Sort sortNameToDayNft = Sort.by(Sort.Direction.ASC, "saleStartTime");
queryToDayNft.with(sortNameToDayNft);
List<GoblinGoodsSkuInfoVo> toDaysNftList = mongoTemplate.find(queryToDayNft, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
// toDaysNftList.addAll(toDayAboutNft);
toDayNftIds = toDaysNftList.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
/*toDayNftIds.addAll(toDayAboutNft);*/
//三天的
Query queryThreeNft = new Query();
queryThreeNft.addCriteria(Criteria.where("skuType").is(1));
queryThreeNft.addCriteria(Criteria.where("delFlg").is("0"));
queryThreeNft.addCriteria(Criteria.where("saleStartTime").gte(toDayEndTime).lt(threeEndTime));
/*queryThreeNft.addCriteria(Criteria.where("skuId").nin(allListSkuIds));*/
queryThreeNft.addCriteria(Criteria.where("shelvesHandle").ne("3"));
Sort sortThreeNft = Sort.by(Sort.Direction.ASC, "saleStartTime");
queryThreeNft.with(sortThreeNft);
List<GoblinGoodsSkuInfoVo> threeNftList = mongoTemplate.find(queryThreeNft, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
// threeNftList.addAll(threeDayAboutNft);
threeNftIds = threeNftList.stream().map(GoblinGoodsSkuInfoVo::getSkuId).collect(Collectors.toList());
/*threeNftIds.addAll(threeDayAboutNft);*/
} catch (Exception e) {
log.error("get NftIds error!");
}
//组合购
List<String> toDayCombinationIds = null;
List<String> threeDayCombinationIds = null;
try {
//当天
Query queryToDayCombination = new Query();
Sort sortToDayCombination = Sort.by(Sort.Direction.ASC, "saleStartTime");
queryToDayCombination.addCriteria(Criteria.where("timeStart").gte(nowTimeTStr).lt(toDayEndTimeStr));
queryToDayCombination.addCriteria(Criteria.where("status").ne(7));
queryToDayCombination.with(sortToDayCombination);
List<GoblinMixDetailsVo> toDayCombinationList = mongoTemplate.find(queryToDayCombination, GoblinMixDetailsVo.class, GoblinMixDetailsVo.class.getSimpleName());
toDayCombinationIds = toDayCombinationList.stream().map(GoblinMixDetailsVo::getMixId).collect(Collectors.toList());
//三天
Query queryThreeDayCombination = new Query();
Sort sortThreeDayCombination = Sort.by(Sort.Direction.ASC, "saleStartTime");
queryThreeDayCombination.addCriteria(Criteria.where("timeStart").gte(toDayEndTimeStr).lt(threeDaysLaterStr));
queryThreeDayCombination.addCriteria(Criteria.where("status").ne(7));
queryThreeDayCombination.with(sortThreeDayCombination);
List<GoblinMixDetailsVo> threeDayCombinationList = mongoTemplate.find(queryThreeDayCombination, GoblinMixDetailsVo.class, GoblinMixDetailsVo.class.getSimpleName());
threeDayCombinationIds = threeDayCombinationList.stream().map(GoblinMixDetailsVo::getMixId).collect(Collectors.toList());
} catch (Exception e) {
log.error("get CombinationIds error!");
}
//缓存ids
HashMap<String, Object> idsList = CollectionUtil.mapStringObject();
idsList.put("toDayIds", toDayIds);
idsList.put("threeDayIds", threeDayIds);
idsList.put("toDayNftIds", toDayNftIds);
idsList.put("threeNftIds", threeNftIds);
idsList.put("toDayCombinationIds", toDayCombinationIds);
idsList.put("threeDayCombinationIds", threeDayCombinationIds);
idsList.put("now", nowTimeTime);
String redisKeyIds = KylinRedisConst.PERFORMANCES_LIST_NOTICE_IDS;
redisUtil.set(redisKeyIds, idsList);
return idsList;
}
// private List<GoblinGoodsSkuInfoVo> getAboutNftByStartAndEndTime(LocalDateTime nowTime, LocalDateTime EndTime,Integer tag) {
private List<String> getAboutNftByStartAndEndTime(LocalDateTime nowTime, LocalDateTime EndTime, Integer tag) {
Query aboutQuery = new Query();
if (tag.equals(0)) {
//当天 查询当天可预约的nft 预约结束时间>当前时间>预约开始
aboutQuery.addCriteria(Criteria.where("aboutStartDate").lt(nowTime));
aboutQuery.addCriteria(Criteria.where("aboutEndDate").gte(EndTime));
} else {
//三天 预约开始时间 范围在三天以内
aboutQuery.addCriteria(Criteria.where("aboutStartDate").gte(nowTime).lt(EndTime));
}
aboutQuery.addCriteria(Criteria.where("delTag").is(0));
List<GoblinGoodsAnticipateValueVo> aboutQueryList = mongoTemplate.find(aboutQuery, GoblinGoodsAnticipateValueVo.class, GoblinGoodsAnticipateValueVo.class.getSimpleName());
List<String> aboutIds = aboutQueryList.stream().map(GoblinGoodsAnticipateValueVo::getSkuId).collect(Collectors.toList());
if (aboutIds.size() > 0) {
/* Query queryAbout = new Query();
queryAbout.addCriteria(Criteria.where("skuId").in(aboutIds));
return mongoTemplate.find(queryAbout, GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());*/
return aboutIds;
}
return new ArrayList<>();
}
/**
* 获取推荐演出列表redis
*/
......@@ -906,41 +1242,43 @@ public class DataUtils {
}
//万青补偿id 获取
public Integer getWqOrderId(String orderId){
public Integer getWqOrderId(String orderId) {
String rdk = KylinRedisConst.REDIS_WQ_ORDER_FIX.concat(orderId);
Object obj = redisUtil.get(rdk);
if(obj==null){
if (obj == null) {
return 0;
}else{
} else {
return 1;
}
}
//万青补偿id 添加
public void setWqOrderId(String orderId){
public void setWqOrderId(String orderId) {
String rdk = KylinRedisConst.REDIS_WQ_ORDER_FIX.concat(orderId);
redisUtil.set(rdk,orderId);
redisUtil.set(rdk, orderId);
}
//万青补偿id 删除
public void delWqOrderId(String orderId){
public void delWqOrderId(String orderId) {
String rdk = KylinRedisConst.REDIS_WQ_ORDER_FIX.concat(orderId);
redisUtil.del(rdk,orderId);
redisUtil.del(rdk, orderId);
}
// 万青补偿vo覆盖
public void setWqOrderVo(WqTempVo vo){
public void setWqOrderVo(WqTempVo vo) {
String rdk = KylinRedisConst.REDIS_WQ_ORDER_EXPRESS.concat(vo.getOrderId());
redisUtil.set(rdk,vo);
redisUtil.set(rdk, vo);
}
// 万青补偿vo获取
public WqTempVo getWqOrderVo(String orderId){
public WqTempVo getWqOrderVo(String orderId) {
String rdk = KylinRedisConst.REDIS_WQ_ORDER_EXPRESS.concat(orderId);
Object obj = redisUtil.get(rdk);
if(obj==null){
if (obj == null) {
WqTempVo vo = WqTempVo.getNew();
vo.setIsTemp(getWqOrderId(orderId));
return vo;
}else{
} else {
WqTempVo vo = (WqTempVo) obj;
vo.setIsTemp(getWqOrderId(orderId));
return vo;
......@@ -949,19 +1287,22 @@ public class DataUtils {
// 获取用户状态
public String getUserStatus(String userId) {
return (String) redisUtil.get(KylinRedisConst.ACTIVE_TICKET_AR_USER+ userId);
return (String) redisUtil.get(KylinRedisConst.ACTIVE_TICKET_AR_USER + userId);
}
//获得 ar券
public KylinTicketActive getArTicket(String code){
return (KylinTicketActive) redisUtil.get(KylinRedisConst.ACTIVE_TICKET_AR_TICKET+code);
public KylinTicketActive getArTicket(String code) {
return (KylinTicketActive) redisUtil.get(KylinRedisConst.ACTIVE_TICKET_AR_TICKET + code);
}
//设置 tikcet
public void setArTicket(KylinTicketActive kylinTicketActive){
redisUtil.set(KylinRedisConst.ACTIVE_TICKET_AR_TICKET+kylinTicketActive.getCode(),kylinTicketActive);
public void setArTicket(KylinTicketActive kylinTicketActive) {
redisUtil.set(KylinRedisConst.ACTIVE_TICKET_AR_TICKET + kylinTicketActive.getCode(), kylinTicketActive);
}
//设置用户状态。
public void setUser(String userId,String value){
redisUtil.set(KylinRedisConst.ACTIVE_TICKET_AR_USER+userId,value);
public void setUser(String userId, String value) {
redisUtil.set(KylinRedisConst.ACTIVE_TICKET_AR_USER + userId, value);
}
......
package com.liquidnet.service.kylin.utils;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
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.stereotype.Component;
@Component
public class GoblinMongodbUtils {
@Autowired
MongoTemplate mongoTemplate;
// SKU信息
public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) {
// return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
// return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId).and("delFlg").is("0")),
return mongoTemplate.findOne(Query.query(Criteria.where("skuId").is(skuId)),
GoblinGoodsSkuInfoVo.class, GoblinGoodsSkuInfoVo.class.getSimpleName());
}
// SPU信息
public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) {
// return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
// return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0")),
return mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId)),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
}
}
package com.liquidnet.service.kylin.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinListCollectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class GoblinRedisUtils {
@Autowired
RedisUtil redisUtil;
@Autowired
GoblinMongodbUtils goblinMongoUtils;
/**
* 获取 包含分段购的sku详情 HASHMAP
*
* @param now 当前时间
* @param skuId skuId
* @return
*/
public HashMap<String, Object> getGoodsSkuInfoVo(LocalDateTime now, String skuId) {
GoblinGoodsSkuInfoVo vo = getGoodsSkuInfoVo(skuId);
if (null == vo) {
return null;
}
HashMap<String, Object> map = CollectionUtil.mapStringObject();
LocalDateTime nextSaleStartTime = null;
if (null == vo.getSaleStartTime() || now.isAfter(vo.getSaleStartTime())) {//普通商品已开售
map.put("vo", vo);
map.put("tagType", null);
map.put("listId", null);
map.put("whiteType", null);
map.put("baseSaleStartTime", vo.getSaleStartTime());
map.put("nextSaleStartTime", null);
} else {//未开售
GoblinListCollectVo collectVo = getCollectByNow(now, skuId);
Integer tagType = null;
Integer whiteType = null;
String listId = null;
LocalDateTime baseSaleStartTime = vo.getSaleStartTime();
if (collectVo != null) {
vo.setPrice(collectVo.getPrice());
vo.setPriceV(collectVo.getPriceV());
vo.setProductId(collectVo.getProductId());
vo.setSaleStartTime(collectVo.getTimeStart());
vo.setSaleStopTime(collectVo.getTimeEnd());
listId = collectVo.getListId();
whiteType = collectVo.getWhiteType();
tagType = collectVo.getTagType();
}
GoblinListCollectVo collectNext = getCollectByNowNext(now, skuId);
if (collectNext != null) {
if (tagType == null) {
tagType = collectNext.getTagType();
}
//todo 逻辑修改 开售时间
if (collectVo == null) {
vo.setSaleStartTime(collectNext.getTimeStart());
vo.setSaleStopTime(collectNext.getTimeEnd());
}
nextSaleStartTime = collectNext.getTimeStart();
}
map.put("vo", vo);
map.put("tagType", tagType);
map.put("listId", listId);
map.put("whiteType", whiteType);
map.put("baseSaleStartTime", baseSaleStartTime);
map.put("nextSaleStartTime", nextSaleStartTime);
}
return map;
}
/**
* 单品信息
*
* @param skuId 单品ID
* @return GoblinGoodsSkuInfoVo
*/
public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId);
if (pre != null && pre.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId.split(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())[0]);
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) {
redisUtil.set(rk, vo);
}
if (vo == null) {
return vo;
}
String marketrk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId);
GoblinGoodsSkuInfoVo marketVo = (GoblinGoodsSkuInfoVo) redisUtil.get(marketrk);
if (null == marketVo && null != (marketVo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) {
redisUtil.set(marketrk, marketVo);
}
if (marketVo == null) {
return marketVo;
}
vo.setSpuId(marketVo.getSpuId());
vo.setSkuId(marketVo.getSkuId());
vo.setPrice(marketVo.getPrice());
vo.setPriceMember(marketVo.getPriceMember());
vo.setSkuStock(marketVo.getSkuStock());
vo.setBuyLimit(marketVo.getBuyLimit());
vo.setBuyRoster(marketVo.getBuyRoster());
vo.setBuyFactor(marketVo.getBuyFactor());
// vo.setDelFlg("0");
vo.setDelFlg(marketVo.getDelFlg().equals("1") ? marketVo.getDelFlg() : vo.getDelFlg());
vo.setMarketId(marketVo.getMarketId());
vo.setCreatedAt(LocalDateTime.now());
return vo;
} else {
String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId);
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) {
redisUtil.set(rk, vo);
}
return vo;
}
}
/**
* 根据时间获取当前分段购vo 如果当前没有返回下一个
*
* @param now
* @param skuId
* @return
*/
public GoblinListCollectVo getCollectByNowNext(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
GoblinListCollectVo collectNext = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem;
}
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem;
} else if (now.isBefore(collectVoItem.getTimeStart())) {
if (collectNext == null || collectNext.getTimeStart().isAfter(collectNext.getTimeStart())) {
collectNext = collectVoItem;
}
} else if (collectVoItem.getTimeEnd() != null && now.isAfter(collectVoItem.getTimeEnd())) {
collectTemp = null;
}
}
// if (collectVo == null && collectTemp != null) {
// collectVo = collectTemp;
// } else
// if (collectVo == null) {
// collectVo = collectNext;
// }
// return collectVo;
return collectNext;
}
public List<GoblinListCollectVo> getGoblinListCollect(String skuId) {
Object obj = redisUtil.get(GoblinRedisConst.LIST_COLLECT.concat(skuId));
if (obj == null) {
return ObjectUtil.getGoblinListCollectVo();
} else {
List<GoblinListCollectVo> list = (List<GoblinListCollectVo>) obj;
list = list.stream().sorted(Comparator.comparing(GoblinListCollectVo::getTimeStart)).collect(Collectors.toList());
return list;
}
}
/**
* 根据时间获取当前分段购vo
*
* @param now
* @param skuId
* @return
*/
public GoblinListCollectVo getCollectByNow(LocalDateTime now, String skuId) {
GoblinListCollectVo collectVo = null;
GoblinListCollectVo collectTemp = null;
List<GoblinListCollectVo> collectVos = getGoblinListCollect(skuId);
for (int i = 0; i < collectVos.size(); i++) {
GoblinListCollectVo collectVoItem = collectVos.get(i);
if (now.isAfter(collectVoItem.getTimeStart()) && collectVoItem.getTimeEnd() == null) {
if (collectTemp == null || collectTemp.getTimeStart().isBefore(collectVoItem.getTimeStart())) {
collectTemp = collectVoItem;
}
} else if (now.isAfter(collectVoItem.getTimeStart()) && now.isBefore(collectVoItem.getTimeEnd())) {
collectVo = collectVoItem;
break;
} else if (collectVoItem.getTimeEnd() != null && now.isAfter(collectVoItem.getTimeEnd())) {
collectTemp = null;
}
}
if (collectVo == null) {
collectVo = collectTemp;
}
return collectVo;
}
/**
* 商品基础信息
*
* @param spuId 商品ID
* @return GoblinGoodsInfoVo
*/
public GoblinGoodsInfoVo getGoodsInfoVo(String spuId) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(spuId);
if (pre != null && pre.equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
String[] spuSplitArr = spuId.split(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue());
String rk = GoblinRedisConst.BASIC_GOODS.concat(spuSplitArr[0]);
GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsInfoVo(spuId))) {
redisUtil.set(rk, vo);
}
if (vo == null) {
return vo;
}
String marketrk = GoblinRedisConst.BASIC_GOODS.concat(spuId);
GoblinGoodsInfoVo marketVo = (GoblinGoodsInfoVo) redisUtil.get(marketrk);
if (null == marketVo && null != (marketVo = goblinMongoUtils.getGoodsInfoVo(spuId))) {
redisUtil.set(marketrk, marketVo);
}
if (marketVo == null) {
return marketVo;
}
vo.setSpuId(marketVo.getSpuId());
List<String> skuIdList = CollectionUtil.linkedListString();
for (String skuIds : vo.getSkuIdList()) {
skuIdList.add(skuIds.concat(pre).concat(spuSplitArr[1]));
}
vo.setSkuIdList(skuIdList);
vo.setPriceGe(marketVo.getPriceGe());
vo.setPriceLe(marketVo.getPriceLe());
vo.setMarketId(marketVo.getMarketId());
vo.setDelFlg(marketVo.getDelFlg().equals("1") ? marketVo.getDelFlg() : vo.getDelFlg());
return vo;
} else {
String rk = GoblinRedisConst.BASIC_GOODS.concat(spuId);
GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsInfoVo(spuId))) {
redisUtil.set(rk, vo);
}
return vo;
}
}
}
......@@ -2,6 +2,7 @@ package com.liquidnet.service.kylin.utils;
import com.liquidnet.service.adam.dto.vo.AdamEntersVo;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.vo.GoblinListCollectVo;
import com.liquidnet.service.kylin.dto.vo.KylinApiCameraDevicesVo;
import com.liquidnet.service.kylin.dto.vo.admin.OrderRefundPoundage;
import com.liquidnet.service.kylin.dto.vo.middle.KylinTicketTimesVo;
......@@ -33,6 +34,9 @@ public class ObjectUtil {
private static final ArrayList<KylinOrderCoupons> kylinOrderCouponsArrayList = new ArrayList<>();
private static final ArrayList<KylinApiCameraDevicesVo> kylinApiCameraDevicesVoArrayList = new ArrayList<>();
/*正在热卖*/
private static final ArrayList<GoblinListCollectVo> goblinListCollectVo = new ArrayList<>();
public static ArrayList<KylinStationPerformanceVo> getKylinStationPerformanceVoArrayList() {
return (ArrayList<KylinStationPerformanceVo>) kylinStationPerformanceVoArrayList.clone();
......@@ -97,4 +101,10 @@ public class ObjectUtil {
public static ArrayList<KylinApiCameraDevicesVo> getKylinApiCameraDevicesVoArrayList() {
return (ArrayList<KylinApiCameraDevicesVo>) kylinApiCameraDevicesVoArrayList.clone();
}
/*正在热卖*/
public static ArrayList<GoblinListCollectVo> getGoblinListCollectVo() {
return (ArrayList<GoblinListCollectVo>) goblinListCollectVo.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