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

Commit ef5a6c77 authored by anjiabin's avatar anjiabin

nft订单增加字段

parent c8483e87
......@@ -15,6 +15,9 @@ public class GalaxyConstant {
public static final String REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD="galaxy:series:nft:upload:";
public static final String REDIS_KEY_GALAXY_SERIES_NFT="galaxy:series:nft:";
public static final String REDIS_KEY_GALAXY_TRADE="galaxy:trade:order:";
public static final String REDIS_KEY_GALAXY_PUBLISH_NFT="galaxy:publish:nft:";
public static final String REDIS_KEY_GALAXY_PUBLISH_ORDER="galaxy:publish:order:";
public static final String SERIES_NAME_PREFIX="NOW_ZXL_";// 系列存储目录名称和系列声明
}
package com.liquidnet.service.galaxy.dto.bo;
import com.liquidnet.commons.lang.util.JsonUtils;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyNftOrderBindBo
* @Package com.liquidnet.service.galaxy.dto.bo
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/31 13:36
*/
@Data
public class GalaxyNftOrderBindBo implements Serializable,Cloneable{
/**
* 接入方买入唯一标识
*/
private String nftOrderPayId;
/**
* 系列唯一编码
*/
private String seriesCode;
/**
* 系列的唯一Id
*/
private String seriesId;
/**
* nftId索引
*/
private Integer nftIdIndex;
/**
* 路由类型
*/
private String routerType;
/**
* 创建时间
*/
private String createdAt;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftOrderBindBo obj = new GalaxyNftOrderBindBo();
public static GalaxyNftOrderBindBo getNew() {
try {
return (GalaxyNftOrderBindBo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftOrderBindBo();
}
}
}
......@@ -54,6 +54,14 @@ public class GalaxySeriesNftInfoBo implements Serializable,Cloneable {
* 系列nft发行开始索引
*/
private String nftIdBegin;
/**
* 系列nft发行开始索引
*/
private Integer nftIdBeginIndex;
/**
* nft系列发行序号
*/
private Integer nftPublishNumber;
/**
* nft素材原始地址
*/
......
package com.liquidnet.service.galaxy.dto.vo.mongo;
import com.liquidnet.commons.lang.util.JsonUtils;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyNftOrderBindBo
* @Package com.liquidnet.service.galaxy.dto.bo
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/31 13:36
*/
@Data
public class GalaxyNftOrderBindVo implements Serializable,Cloneable{
/**
* 接入方买入唯一标识
*/
private String nftOrderPayId;
/**
* 系列唯一编码
*/
private String seriesCode;
/**
* 系列的唯一Id
*/
private String seriesId;
/**
* nftId索引
*/
private Integer nftIdIndex;
/**
* 路由类型
*/
private String routerType;
/**
* 创建时间
*/
private String createdAt;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftOrderBindVo obj = new GalaxyNftOrderBindVo();
public static GalaxyNftOrderBindVo getNew() {
try {
return (GalaxyNftOrderBindVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftOrderBindVo();
}
}
}
......@@ -54,6 +54,14 @@ public class GalaxySeriesNftInfoVo implements Serializable,Cloneable {
* 系列nft发行开始索引
*/
private String nftIdBegin;
/**
* 系列nft发行开始索引
*/
private Integer nftIdBeginIndex;
/**
* nft系列发行序号
*/
private Integer nftPublishNumber;
/**
* nft素材原始地址
*/
......
......@@ -5,6 +5,7 @@ db.createCollection("GalaxySeriesInfoVo");
db.createCollection("GalaxySeriesNftInfoVo");
db.createCollection("GalaxySeriesNftUploadVo");
db.createCollection("GalaxyNftOrderVo");
db.createCollection("GalaxyNftOrderBindVo");
db.createCollection("GalaxyNftTradeVo");
......@@ -14,6 +15,7 @@ db.GalaxySeriesInfoVo.createIndex({seriesCode:"hashed"});
db.GalaxySeriesNftInfoVo.createIndex({skuId:"hashed"});
db.GalaxySeriesNftUploadVo.createIndex({skuId:"hashed"});
db.GalaxyNftOrderVo.createIndex({nftOrderPayId:"hashed"});
db.GalaxyNftOrderBindVo.createIndex({nftOrderPayId:"hashed"});
db.GalaxyNftTradeVo.createIndex({nftId:"hashed"});
#创建分片
......
......@@ -53,6 +53,8 @@ create table galaxy_series_nft_info
nft_total_count varchar(50) COMMENT '系列nft发行总量',
nft_crt_count varchar(200) COMMENT '系列nft已发行个数',
nft_id_begin varchar(200) COMMENT '系列nft发行开始id',
nft_id_begin_index int default 0 COMMENT 'nftId开始索引',
nft_publish_number int default 1 COMMENT 'nft系列发行序号',
original_nft_url varchar(1000) COMMENT 'nft素材原始地址',
original_display_url varchar(1000) COMMENT 'nft显示素材原始地址',
author varchar(200) COMMENT '作者名',
......@@ -68,6 +70,8 @@ create table galaxy_series_nft_info
updated_at timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`mid`)
) ENGINE = InnoDB comment '数字藏品系列nft信息';
alter table galaxy_series_nft_info add nft_id_begin_index int default 0 comment 'nftId开始索引' after nft_id_begin;
alter table galaxy_series_nft_info add nft_publish_number int default 1 comment 'nft系列发行序号' after nft_id_begin_index;
create table galaxy_nft_order_info
(
......
......@@ -448,6 +448,8 @@ public class ZxinArtworkBiz {
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());
......@@ -456,10 +458,13 @@ public class ZxinArtworkBiz {
seriesNftInfoBo.setSeriesName(seriesInfoBo.getSeriesName());
seriesNftInfoBo.setSeriesCode(seriesInfoBo.getSeriesCode());
seriesNftInfoBo.setSeriesId(seriesInfoBo.getSeriesId());
seriesNftInfoBo.setNftTotalCount(0L);
//目前要求发行总数必须能整除
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());
seriesNftInfoBo.setNftPublishNumber(nftPublishNumber);
seriesNftInfoBo.setOriginalNftUrl(seriesNftUploadBo.getOriginalNftUrl());
seriesNftInfoBo.setOriginalDisplayUrl(seriesNftUploadBo.getOriginalDisplayUrl());
//以下为购买信息
......
......@@ -9,6 +9,7 @@ import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.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;
......@@ -59,11 +60,29 @@ public class ZxinPublishBiz {
return ResponseDto.failure(GalaxyErrorEnum.PUBLISH_FAIL_ALREADY_EXIST.getCode(), GalaxyErrorEnum.PUBLISH_FAIL_ALREADY_EXIST.getMessage());
}
//获取用户信息
GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId());
//获取sku信息
GalaxySeriesNftInfoBo seriesNftInfoBo = dataUtils.getSeriesNftInfoBo(reqDto.getRouterType(),reqDto.getSkuId());
/**
* 获取订单和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();
......@@ -75,7 +94,7 @@ public class ZxinPublishBiz {
//发行个数
Long publishCount = 1L;
//开始索引
Integer seriesBeginIndex = 0;
Integer seriesBeginIndex = nftOrderBindBo.getNftIdIndex();;
Long sellCount = seriesNftInfoBo.getSellCount().longValue(); //积分
/**
* 根据sku获取系列Id
......@@ -85,19 +104,18 @@ public class ZxinPublishBiz {
String nftId = null;
String taskId = null;
//查询系列信息
Nft032SeriesReqDto nft032ReqDto = Nft032SeriesReqDto.getNew();
nft032ReqDto.setSeriesId(seriesId);
ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(nft032ReqDto);
if(resp.isSuccess()){
//该系列已经发行多少个nft
Long crtCount = resp.getData().getSeriesInfo().getCrtCount();
log.info("系列:{} 已发行 :{}", seriesId, crtCount);
//设置开始索引
seriesBeginIndex = Integer.parseInt(String.valueOf(crtCount.longValue() + 1));
}
//查询系列信息 暂时不通过系列信息控制发行索引
// Nft032SeriesReqDto nft032ReqDto = Nft032SeriesReqDto.getNew();
// nft032ReqDto.setSeriesId(seriesId);
// ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(nft032ReqDto);
//
// if(resp.isSuccess()){
// //该系列已经发行多少个nft
// Long crtCount = resp.getData().getSeriesInfo().getCrtCount();
// log.info("系列:{} 已发行 :{}", seriesId, crtCount);
// //设置开始索引
// seriesBeginIndex = Integer.parseInt(String.valueOf(crtCount.longValue() + 1));
// }
//3.1.2调用NFT发行接口
/**
......
......@@ -164,6 +164,9 @@ public class DataUtils {
public void setSeriesNftInfoBo(String routerType, String skuId, GalaxySeriesInfoBo seriesInfoBo, GalaxySeriesNftInfoBo seriesNftInfoBo) {
redisUtil.set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo,keyExpireTime);
//初始化nft发行开始索引
redisUtil.set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId),seriesNftInfoBo.getNftIdBeginIndex());
//mongo入库
GalaxySeriesNftInfoVo seriesNftInfoVo = GalaxySeriesNftInfoVo.getNew();
BeanUtil.copy(seriesNftInfoBo,seriesNftInfoVo);
......@@ -172,14 +175,14 @@ public class DataUtils {
try{
// insert into galaxy_series_nft_info (mid, series_nft_info_id, series_info_id, sku_id, series_name, series_code
// ,series_id, nft_total_count, nft_crt_count,nft_id_begin,original_nft_url
// ,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)
queueUtil.sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.insert"),
new Object[]{seriesNftInfoBo.getSeriesNftInfoId(),seriesInfoBo.getSeriesInfoId(),skuId,seriesInfoBo.getSeriesName(),seriesInfoBo.getSeriesCode()
,seriesInfoBo.getSeriesId(),seriesInfoBo.getTotalCount(),seriesInfoBo.getCrtCount(),seriesNftInfoBo.getNftIdBegin(),seriesNftInfoBo.getOriginalNftUrl()
,seriesInfoBo.getSeriesId(),seriesNftInfoBo.getNftTotalCount(),seriesNftInfoBo.getNftCrtCount(),seriesNftInfoBo.getNftIdBegin(),seriesNftInfoBo.getNftIdBeginIndex(),seriesNftInfoBo.getNftPublishNumber(),seriesNftInfoBo.getOriginalNftUrl()
,seriesNftInfoBo.getOriginalDisplayUrl(),seriesNftInfoBo.getAuthor(),seriesNftInfoBo.getNftName(),seriesNftInfoBo.getNftUrl(),seriesNftInfoBo.getDisplayUrl()
,seriesNftInfoBo.getNftDesc(),seriesNftInfoBo.getNftFlag(),seriesNftInfoBo.getSellCount(),seriesNftInfoBo.getNftHash(),seriesInfoBo.getRouterType()
,LocalDateTime.now(),null
......@@ -384,6 +387,32 @@ public class DataUtils {
}
}
public void setGalaxyNftOrderBindBo(String routerType,String nftOrderPayId, GalaxyNftOrderBindBo nftOrderBindBo) {
redisUtil.set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBindBo,keyExpireTime);
//入库mongo
GalaxyNftOrderBindVo nftOrderBindVo = GalaxyNftOrderBindVo.getNew();
BeanUtil.copy(nftOrderBindBo,nftOrderBindVo);
mongoTemplate.save(nftOrderBindVo,GalaxyNftOrderBindVo.class.getSimpleName());
}
public GalaxyNftOrderBindBo getGalaxyNftOrderBindBo(String routerType,String nftOrderPayId) {
String redisKey = GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_ORDER.concat(routerType).concat(":") + nftOrderPayId;
Object obj = redisUtil.get(redisKey);
if(obj!=null){
return (GalaxyNftOrderBindBo) obj;
}else {
GalaxyNftOrderBindVo nftOrderBindVo = mongoTemplate.findOne(Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId)), GalaxyNftOrderBindVo.class, GalaxyNftOrderBindVo.class.getSimpleName());
if (nftOrderBindVo == null) {
return null;
}
GalaxyNftOrderBindBo nftOrderBindBo = GalaxyNftOrderBindBo.getNew();
BeanUtil.copy(nftOrderBindVo,nftOrderBindBo);
redisUtil.set(redisKey, nftOrderBindBo,keyExpireTime);
return nftOrderBindBo;
}
}
public void setNftTradeInfo(String routerType, GalaxyNftTradeVo nftTradeVo) {
/**
* 入库mongo
......@@ -406,4 +435,12 @@ public class DataUtils {
}
}
public long incrNftIdNo(String routerType,String skuId) {
return redisUtil.incr(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId), 1);
}
public long getNftIdNo(String routerType,String skuId) {
Object o = redisUtil.get(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId));
return o==null?-1:(int)o;
}
}
......@@ -6,8 +6,8 @@ liquidnet:
username: user
password: user123
eureka:
host: 172.17.192.42:7001
# host: 127.0.0.1:7001
# host: 172.17.192.42:7001
host: 127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring:
......
......@@ -3,7 +3,7 @@ galaxy_user_info.insert=insert into galaxy_user_info (user_id, user_name, user_t
# ------------------------数字藏品系列信息----------------------------
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_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 ,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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------数字藏品订单信息----------------------------
galaxy_nft_order_info.insert=insert into galaxy_nft_order_info (nft_order_pay_id, user_id, sku_id, series_name, series_id, nft_id, nft_price,from_address, to_address, nft_publish_task_id, nft_buy_task_id, nft_buy_pay_task_id,router_type, created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------数字藏品交易信息----------------------------
......
package com.liquidnet.service.galaxy;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.utils.DataUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -24,11 +25,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class TestRedisUtil {
// @Autowired
// private RedisDataSourceUtil redisUtil;
@Autowired
private RedisDataSourceUtil redisUtil;
private RedisUtil redisUtil;
private long keyExpireTime = 3600*24*30;
@Autowired
private DataUtils dataUtils;
@Test
public void testSet(){
......@@ -37,6 +44,18 @@ public class TestRedisUtil {
userInfoBo.setUserId(userId);
String key = GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode()).concat(":") + userId;
redisUtil.getRedisGalaxyUtil().set(key,userInfoBo,keyExpireTime);
// redisUtil.getRedisGalaxyUtil().set(key,userInfoBo,keyExpireTime);
}
@Test
public void testGetNftIdNo(){
String routerType = "zxinchain";
String skuId = "1234567890-sku-010";
// redisUtil.set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId),2000);
long nftIdNo = dataUtils.incrNftIdNo(routerType,skuId);
// long nftIdNo = dataUtils.getNftIdNo(routerType,skuId);
System.out.println("skuId:"+skuId+" no:"+nftIdNo+" ");
}
}
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