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

Commit 128cf2bd authored by anjiabin's avatar anjiabin

增加系列声明异常处理逻辑

parent 568d09bb
......@@ -20,7 +20,6 @@ public enum GalaxyErrorEnum {
SERIES_CLAIM_PROCESSING("NFT0010008","系列声明正在处理中,不允许重复声明!"),
SERIES_CLAIM_SUCCESSED("NFT0010009","系列已声明成功,不允许重复声明!"),
SERIES_CLAIM_NOT_EXIST("NFT0010010","系列声明初始化信息不存在,请检查是否已上传对应素材!"),
SERIES_NFT_INFO_NOT_EXIST("NFT0010015","系列NFT信息查询不存在!"),
PUBLISH_ORDER_NOT_EXIST("NFT0010011","NFT购买订单不存在!"),
NFT_BUY_TASK_NOT_EXIST("NFT0010012","NFT购买执行任务不存在"),
NFT_BUY_TASK_HAVE_EXIST("NFT0010013","NFT购买执行任务已存在,不可以重复购买!"),
......@@ -33,7 +32,9 @@ public enum GalaxyErrorEnum {
NFT_QUERY_FAIL_ORDER_NOT_EXIST("NFT0010020","NFT订单不存在!"),
NFT_QUERY_FAIL_NFT_NOT_EXIST("NFT0010021","NFT信息查询不存在!"),
NFT_QUERY_FAIL_SERIES_NOT_EXIST("NFT0010022","系列信息查询不存在!"),
NFT_USER_HAS_OPEN_ACCOUNT("NFT0010023","用户已经开通过数字账户!");
NFT_USER_HAS_OPEN_ACCOUNT("NFT0010023","用户已经开通过数字账户!"),
SERIES_NFT_INFO_NOT_EXIST("NFT0010024","系列NFT信息查询不存在!"),
SERIES_NFT_HASH_CREATE_FAIL("NFT0010025","系列NFT的介质hash生成失败!");
private String code;
......
......@@ -135,11 +135,18 @@ public class ZxlnftBiz {
* @return
*/
public String getHashString(String data){
SM3HashEncodeReq req = SM3HashEncodeReq.getNew();
byte[] fileByteArray = this.getNftFileByteArray(data);
req.setData(fileByteArray);
SM3HashEncodeResp sm3HashEncodeResp = walletSdkService.sM3HashEncode(req);
return sm3HashEncodeResp.getDigest();
SM3HashEncodeResp sm3HashEncodeResp = null;
try {
SM3HashEncodeReq req = SM3HashEncodeReq.getNew();
byte[] fileByteArray = this.getNftFileByteArray(data);
req.setData(fileByteArray);
sm3HashEncodeResp = walletSdkService.sM3HashEncode(req);
return sm3HashEncodeResp.getDigest();
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(),e);
}
return null;
}
/**
......
......@@ -25,6 +25,7 @@ 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;
......@@ -168,59 +169,82 @@ public class ZxinArtworkBiz {
}
}
/**
* 进行系列声明
*/
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);
//返回参数
String seriesId = null;
String taskId = null;
GalaxyArtSeriesClaimRespDto seriesClaimRespDto = GalaxyArtSeriesClaimRespDto.getNew();
if(nft30RespDto.isSuccess()){
//第零个系列 无限制系列
taskId = nft30RespDto.getData().getTaskId();
//构造缓存数据
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);
dataUtils.setSeriesInfoBo(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//构造系列nft信息
GalaxySeriesNftInfoBo seriesNftInfoBo = this.buildSeriesNftInfoBo(reqDto,seriesInfoBo,seriesNftUploadBo);
dataUtils.setSeriesNftInfoBo(reqDto.getRouterType(),reqDto.getSkuId(),seriesInfoBo,seriesNftInfoBo);
//业务失败信息
String bizFailDesc = null;
//系统失败信息
String sysFailDesc = null;
GalaxyArtSeriesClaimRespDto seriesClaimRespDto = null;
try {
/**
* 进行系列声明
*/
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);
//返回参数
String seriesId = null;
String taskId = null;
seriesClaimRespDto = GalaxyArtSeriesClaimRespDto.getNew();
if(nft30RespDto.isSuccess()){
//第零个系列 无限制系列
taskId = nft30RespDto.getData().getTaskId();
//构造缓存数据
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);
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 ZxlNftException(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());
}
}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);
seriesClaimRespDto.setSkuId(skuId);
seriesClaimRespDto.setNftUrl(seriesNftUploadBo.getNftUrl());
seriesClaimRespDto.setDisplayUrl(seriesNftUploadBo.getDisplayUrl());
seriesClaimRespDto.setSeriesId(seriesId);
seriesClaimRespDto.setSeriesName(seriesName);
}catch(ZxlNftException 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);
}
......@@ -329,6 +353,13 @@ public class ZxinArtworkBiz {
}
String seriesCode = seriesNftInfoBo.getSeriesCode();
//如果nftUrl介质hash为空,则重新生成
if(StringUtil.isEmpty(seriesNftInfoBo.getNftHash())){
//更新系列对应的系列nft状态
seriesNftInfoBo.setNftHash(zxlnftBiz.getHashString(seriesNftInfoBo.getNftUrl()));
dataUtils.updateSeriesNftStatus(reqDto.getRouterType(),reqDto.getSkuId(),seriesNftInfoBo);
}
//获取任务ID
GalaxySeriesInfoBo seriesInfoBo = dataUtils.getSeriesInfoBo(reqDto.getRouterType(),seriesCode);
if(StringUtil.isNull(seriesInfoBo)||StringUtil.isEmpty(seriesInfoBo.getSeriesClaimTaskId())){
......
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