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

Commit f0f5e1f9 authored by anjiabin's avatar anjiabin

修改百度链购买入库逻辑

parent d223438c
...@@ -5,7 +5,6 @@ import com.liquidnet.common.third.xuper.config.XuperConfig; ...@@ -5,7 +5,6 @@ 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;
...@@ -124,6 +123,8 @@ public class XuperTradeCommonBiz { ...@@ -124,6 +123,8 @@ public class XuperTradeCommonBiz {
//定义失败信息 //定义失败信息
String failDesc = null; String failDesc = null;
//是否发行成功
boolean isPublishSuccess = false;
try{ try{
/** /**
...@@ -150,16 +151,21 @@ public class XuperTradeCommonBiz { ...@@ -150,16 +151,21 @@ public class XuperTradeCommonBiz {
} }
seriesBeginIndex = nftOrderBindBo.getNftIdIndex(); seriesBeginIndex = nftOrderBindBo.getNftIdIndex();
//设置nftId
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());
//设置购买标志
nftOrderBo.setNftId(nftId);
/** /**
* 如果已经发行成功 * 如果已经发行成功
*/ */
if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){ if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());; publishTaskId = seriesNftInfoBo.getSeriesId();//跳过发行查询
nftPublishChainTimestamp = DateUtil.getNowSeconds(); nftPublishChainTimestamp = DateUtil.getNowSeconds();
nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode()); nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode());
nftPublishTradeHash = publishTaskId; nftPublishTradeHash = seriesNftInfoBo.getNftPublishTradeHash();
//设置购买标志 //发行成功
nftOrderBo.setNftId(nftId); isPublishSuccess = true;
}else if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){ }else if(seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){
if(StringUtil.isNotEmpty(nftOrderBo.getNftPublishTaskId())){ if(StringUtil.isNotEmpty(nftOrderBo.getNftPublishTaskId())){
publishTaskId = nftOrderBo.getNftPublishTaskId(); publishTaskId = nftOrderBo.getNftPublishTaskId();
...@@ -190,18 +196,15 @@ public class XuperTradeCommonBiz { ...@@ -190,18 +196,15 @@ public class XuperTradeCommonBiz {
} }
} }
if (StringUtil.isNotEmpty(publishTaskId)){ //发行结果查询
if (!isPublishSuccess){
try{ try{
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto nft035ReqDto = Nft035PublishResultReqDto.getNew();
nft035ReqDto.setTaskId(publishTaskId);
int count = 0; int count = 0;
long timeStart = System.currentTimeMillis(); long timeStart = System.currentTimeMillis();
while (StringUtil.isEmpty(nftId)) { while (!isPublishSuccess) {
Thread.sleep(500l); Thread.sleep(500l);
count++; count++;
log.info("=======执行nft发行第{}次查询,taskId:{}", count, nft035ReqDto.getTaskId()); log.info("=======执行nft发行第{}次查询,taskId:{}", count, publishTaskId);
//执行nft发行结果查询 //执行nft发行结果查询
GalaxyNftPublishResultQueryReqDto nftPublishResultQueryReqDto = GalaxyNftPublishResultQueryReqDto.getNew(); GalaxyNftPublishResultQueryReqDto nftPublishResultQueryReqDto = GalaxyNftPublishResultQueryReqDto.getNew();
nftPublishResultQueryReqDto.setNftOrderPayId(reqDto.getNftOrderPayId()); nftPublishResultQueryReqDto.setNftOrderPayId(reqDto.getNftOrderPayId());
...@@ -210,7 +213,6 @@ public class XuperTradeCommonBiz { ...@@ -210,7 +213,6 @@ public class XuperTradeCommonBiz {
if(publishResultQueryRespDto.isSuccess()){ if(publishResultQueryRespDto.isSuccess()){
GalaxyNftPublishResultQueryRespDto nftPublishResultQueryRespDto = publishResultQueryRespDto.getData(); GalaxyNftPublishResultQueryRespDto nftPublishResultQueryRespDto = publishResultQueryRespDto.getData();
if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())) { if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())) {
nftId = seriesId.concat("_").concat(seriesBeginIndex.toString());;
nftPublishChainTimestamp = DateUtil.getNowSeconds(); nftPublishChainTimestamp = DateUtil.getNowSeconds();
nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode()); nftPublishStatus = Integer.parseInt(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode());
nftPublishTradeHash = nftPublishResultQueryRespDto.getTxHash(); nftPublishTradeHash = nftPublishResultQueryRespDto.getTxHash();
...@@ -220,17 +222,19 @@ public class XuperTradeCommonBiz { ...@@ -220,17 +222,19 @@ public class XuperTradeCommonBiz {
seriesNftInfoBo.setNftPublishTradeHash(nftPublishTradeHash); seriesNftInfoBo.setNftPublishTradeHash(nftPublishTradeHash);
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now()); seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo); dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
isPublishSuccess = true;
} else if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode())) { } else if (nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode())) {
log.info("任务执行失败!taskId:{}", nft035ReqDto.getTaskId()); log.info("任务执行失败!taskId:{}", publishTaskId);
nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus(); nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus();
//发行失败 //发行失败
seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode()); seriesNftInfoBo.setNftPublishStatus(GalaxyEnum.AssetPublishStatusEnum.FAIL.getCode());
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now()); seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo); dataUtils.updateSeriesNftPublishStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
//直接进行异常处理 //直接进行异常处理
throw new GalaxyNftPublishException(GalaxyErrorEnum.PUBLISH_FAIL.getCode(), "nft035PublishResult_resp:"+GalaxyErrorEnum.PUBLISH_FAIL.getMessage()); throw new GalaxyNftPublishException(GalaxyErrorEnum.PUBLISH_FAIL.getCode(), "xuper004PublishAsset_resp:"+GalaxyErrorEnum.PUBLISH_FAIL.getMessage());
}else if(nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){ }else if(nftPublishResultQueryRespDto.getTaskStatus().toString().equals(GalaxyEnum.AssetPublishStatusEnum.PROCESSING.getCode())){
log.info("任务执行中!taskId:{}", nft035ReqDto.getTaskId()); log.info("任务执行中!taskId:{}", publishTaskId);
nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus(); nftPublishStatus = nftPublishResultQueryRespDto.getTaskStatus();
//发行中 //发行中
...@@ -241,13 +245,10 @@ public class XuperTradeCommonBiz { ...@@ -241,13 +245,10 @@ public class XuperTradeCommonBiz {
} }
if (count == 20) { if (count == 20) {
log.info("=======查询共20次,跳出循环!taskId:{}", nft035ReqDto.getTaskId()); log.info("=======查询共20次,跳出循环!taskId:{}",publishTaskId);
break; break;
} }
} }
//赋值返回参数
nftOrderBo.setNftId(nftId);
log.info("发行NFT后返回给前端nftID:{}", nftId); log.info("发行NFT后返回给前端nftID:{}", nftId);
log.info("总共执行了{}次查询 总耗时:{} MS", count, (System.currentTimeMillis() - timeStart)); log.info("总共执行了{}次查询 总耗时:{} MS", count, (System.currentTimeMillis() - timeStart));
}catch (GalaxyNftPublishException e){ }catch (GalaxyNftPublishException e){
...@@ -255,12 +256,12 @@ public class XuperTradeCommonBiz { ...@@ -255,12 +256,12 @@ public class XuperTradeCommonBiz {
}catch(Exception e){ }catch(Exception e){
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
//发行失败 //发行失败
throw new GalaxyNftPublishException(GalaxyErrorEnum.NFT_PUBLISH_ERROR.getCode(),"nft035PublishResult_exception:"+e.getMessage()); throw new GalaxyNftPublishException(GalaxyErrorEnum.NFT_PUBLISH_ERROR.getCode(),"xuper004PublishAsset_exception:"+e.getMessage());
} }
}else{ }else{
if(!seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){ if(!seriesNftInfoBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.AssetPublishStatusEnum.SUCCESS.getCode())){
//发行失败 //发行失败
throw new GalaxyNftPublishException(GalaxyErrorEnum.NFT_PUBLISH_ERROR.getCode(),"nft034Publish_resp:taskId : "+publishTaskId); throw new GalaxyNftPublishException(GalaxyErrorEnum.NFT_PUBLISH_ERROR.getCode(),"xuper004PublishAsset_resp:taskId : "+publishTaskId);
} }
} }
}catch (GalaxyNftPublishException e) { }catch (GalaxyNftPublishException e) {
...@@ -293,7 +294,7 @@ public class XuperTradeCommonBiz { ...@@ -293,7 +294,7 @@ public class XuperTradeCommonBiz {
} }
//更新订单缓存数据状态 //更新订单缓存数据状态
if(StringUtil.isNotEmpty(nftOrderBo.getNftId())){ if(isPublishSuccess){
if(StringUtil.isNotNull(nftPublishChainTimestamp)){ if(StringUtil.isNotNull(nftPublishChainTimestamp)){
//设置时间 //设置时间
String nftPublishChainTimestampStr = DateUtil.format(new Date(nftPublishChainTimestamp*1000),DateUtil.Formatter.yyyyMMddHHmmss); String nftPublishChainTimestampStr = DateUtil.format(new Date(nftPublishChainTimestamp*1000),DateUtil.Formatter.yyyyMMddHHmmss);
...@@ -307,10 +308,8 @@ public class XuperTradeCommonBiz { ...@@ -307,10 +308,8 @@ public class XuperTradeCommonBiz {
nftOrderBo.setUpdatedAt(LocalDateTime.now()); nftOrderBo.setUpdatedAt(LocalDateTime.now());
//先更新nft发行数据 //先更新nft发行数据
dataUtils.updateNftOrderPublishInfo(reqDto.getRouterType(),reqDto.getNftOrderPayId(),nftOrderBo); dataUtils.updateNftOrderPublishInfo(reqDto.getRouterType(),reqDto.getNftOrderPayId(),nftOrderBo);
}
//第二步:执行购买逻辑 //第二步:执行购买逻辑
if(StringUtil.isNotEmpty(nftOrderBo.getNftId())){
GalaxyNftPublishAndBuyRespDto nftPublishAndBuyRespDto = this.executeBuyBusiness(reqDto,userInfoBo,seriesNftInfoBo,nftOrderBo); GalaxyNftPublishAndBuyRespDto nftPublishAndBuyRespDto = this.executeBuyBusiness(reqDto,userInfoBo,seriesNftInfoBo,nftOrderBo);
if(StringUtil.isNotNull(nftPublishAndBuyRespDto)&&StringUtil.isNotEmpty(nftPublishAndBuyRespDto.getNftId())){ if(StringUtil.isNotNull(nftPublishAndBuyRespDto)&&StringUtil.isNotEmpty(nftPublishAndBuyRespDto.getNftId())){
return ResponseDto.success(nftPublishAndBuyRespDto); return ResponseDto.success(nftPublishAndBuyRespDto);
...@@ -499,7 +498,11 @@ public class XuperTradeCommonBiz { ...@@ -499,7 +498,11 @@ public class XuperTradeCommonBiz {
Xuper010QuerySdsReqDto xuper010QuerySdsReqDto = Xuper010QuerySdsReqDto.getNew(); Xuper010QuerySdsReqDto xuper010QuerySdsReqDto = Xuper010QuerySdsReqDto.getNew();
// 定义返回结果对象 // 定义返回结果对象
Xuper010QuerySdsRespDto xuper010QuerySdsRespDto = null; Xuper010QuerySdsRespDto xuper010QuerySdsRespDto = null;
long shardId = 1l; long shardId = -1l;
GalaxyNftOrderBindBo nftOrderBindBo = dataUtils.getGalaxyNftOrderBindBo(reqDto.getRouterType(),nftOrderBo.getNftOrderPayId());
if(StringUtil.isNotNull(nftOrderBindBo)){
shardId = nftOrderBindBo.getNftIdIndex().longValue();
}
try { try {
xuper010QuerySdsReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId())); xuper010QuerySdsReqDto.setAssetId(Long.parseLong(nftOrderBo.getSeriesId()));
xuper010QuerySdsReqDto.setShardId(shardId); xuper010QuerySdsReqDto.setShardId(shardId);
......
...@@ -360,9 +360,6 @@ public class ZxinUserCommonBiz { ...@@ -360,9 +360,6 @@ public class ZxinUserCommonBiz {
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId()) dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId())
,goblinUserNftAccInfoVo); ,goblinUserNftAccInfoVo);
//同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
syncUserAccountInfoToAdam(reqDto);
//同步业务账号关联关系到adam //同步业务账号关联关系到adam
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqlsDataA.add(new Object[]{ sqlsDataA.add(new Object[]{
...@@ -378,6 +375,9 @@ public class ZxinUserCommonBiz { ...@@ -378,6 +375,9 @@ public class ZxinUserCommonBiz {
//开户成功记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}} //开户成功记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA.concat(reqDto.getIdCardType().concat(reqDto.getIdCard())) dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA.concat(reqDto.getIdCardType().concat(reqDto.getIdCard()))
,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccSuccessKeyExpireTime); ,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccSuccessKeyExpireTime);
//同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
syncUserAccountInfoToAdam(reqDto);
}else{ }else{
//更新开户状态 //更新开户状态
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId()) dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId())
......
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