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

Commit 7ba98dfc authored by anjiabin's avatar anjiabin

增加xuper用户同步接口

parent 00474748
package com.liquidnet.service.consumer.nft.service.processor; package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto; 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.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto; 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 com.liquidnet.service.galaxy.router.zxin.biz.ZxinTradeCommonBiz;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,12 +25,21 @@ public class ConsumerGalaxyJsonNftPublishAndBuyProcessor { ...@@ -23,12 +25,21 @@ public class ConsumerGalaxyJsonNftPublishAndBuyProcessor {
@Autowired @Autowired
private ZxinTradeCommonBiz zxinTradeCommonBiz; private ZxinTradeCommonBiz zxinTradeCommonBiz;
@Autowired
private XuperTradeCommonBiz xuperTradeCommonBiz;
/** /**
* 执行购买处理 * 执行购买处理
* @param reqDto * @param reqDto
* @return * @return
*/ */
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) { 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; package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto; 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.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto; 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 com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserCommonBiz;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,12 +25,22 @@ public class ConsumerGalaxyJsonNftUserRegisterProcessor { ...@@ -23,12 +25,22 @@ public class ConsumerGalaxyJsonNftUserRegisterProcessor {
@Autowired @Autowired
private ZxinUserCommonBiz zxinUserCommonBiz; private ZxinUserCommonBiz zxinUserCommonBiz;
@Autowired
private XuperUserCommonBiz xuperUserCommonBiz;
/** /**
* 执行用户注册 * 执行用户注册
* @param reqDto * @param reqDto
* @return * @return
*/ */
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) { 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();
}
} }
} }
...@@ -5,6 +5,7 @@ import com.liquidnet.common.third.xuper.config.XuperConfig; ...@@ -5,6 +5,7 @@ import com.liquidnet.common.third.xuper.config.XuperConfig;
import com.liquidnet.common.third.xuper.dto.*; import com.liquidnet.common.third.xuper.dto.*;
import com.liquidnet.common.third.xuper.exception.XupterException; import com.liquidnet.common.third.xuper.exception.XupterException;
import com.liquidnet.common.third.xuper.util.XuperSdkUtil; 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.common.third.zxlnft.dto.Nft044BuyResultReqDto;
import com.liquidnet.commons.lang.util.BeanUtil; import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.DateUtil; import com.liquidnet.commons.lang.util.DateUtil;
...@@ -22,6 +23,7 @@ import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo; ...@@ -22,6 +23,7 @@ import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.*; import com.liquidnet.service.galaxy.dto.param.*;
import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo; import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo;
import com.liquidnet.service.galaxy.exception.GalaxyNftBuyException; import com.liquidnet.service.galaxy.exception.GalaxyNftBuyException;
import com.liquidnet.service.galaxy.exception.GalaxyNftPublishException;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils; import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -54,6 +56,272 @@ public class XuperTradeCommonBiz { ...@@ -54,6 +56,272 @@ public class XuperTradeCommonBiz {
@Autowired @Autowired
private GalaxyBeanTransferBiz galaxyBeanTransferBiz; 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){ public GalaxyNftPublishAndBuyRespDto executeBuyBusiness(GalaxyNftPublishAndBuyReqDto reqDto,GalaxyUserInfoBo userInfoBo, GalaxySeriesNftInfoBo seriesNftInfoBo,GalaxyNftOrderBo nftOrderBo){
String buyFailDesc = null; String buyFailDesc = null;
//执行购买逻辑 //执行购买逻辑
...@@ -260,4 +528,63 @@ public class XuperTradeCommonBiz { ...@@ -260,4 +528,63 @@ public class XuperTradeCommonBiz {
return ResponseDto.failure(GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getCode(),GalaxyErrorEnum.NFT_PUBLISH_AND_BUY_QUERY_FAIL.getMessage()); 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; 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.config.XuperConfig;
import com.liquidnet.common.third.xuper.dto.Xuper004PublishAssetReqDto;
import com.liquidnet.common.third.xuper.dto.Xuper004PublishAssetRespDto;
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.xuper.util.XuperSdkUtil;
import com.liquidnet.common.third.zxlnft.dto.Nft035PublishResultReqDto;
import com.liquidnet.commons.lang.util.BeanUtil; 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.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz; import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.constant.GalaxyEnum; import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum; 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.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.param.*;
import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo;
import com.liquidnet.service.galaxy.exception.GalaxyNftPublishException;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils; import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import com.liquidnet.service.galaxy.utils.QueueUtil; import com.liquidnet.service.galaxy.utils.QueueUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Date;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -64,272 +48,15 @@ public class XuperTradeBiz { ...@@ -64,272 +48,15 @@ public class XuperTradeBiz {
@Autowired @Autowired
private XuperPublishBiz xuperPublishBiz; private XuperPublishBiz xuperPublishBiz;
/** /**
* 发行和购买 * 发行和购买
* @param reqDto * @param reqDto
* @return * @return
*/ */
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) { public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
log.info("开始执行nftPublishAndBuy 请求参数:{}",reqDto.toString()); return xuperTradeCommonBiz.nftPublishAndBuy(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());
}
//获取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 = xuperTradeCommonBiz.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 = xuperPublishBiz.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 = xuperTradeCommonBiz.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());
} }
/** /**
* NFT发行和购买 * NFT发行和购买
* @param reqDto * @param reqDto
......
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