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

Commit 459ae0d6 authored by anjiabin's avatar anjiabin

修改购买逻辑

parent 4eb7e81a
......@@ -11,7 +11,10 @@ package com.liquidnet.service.galaxy.constant;
*/
public enum GalaxyErrorCodeEnum {
SERIES_CLAIM_ERROR("NFT0010001","NFT系列声明失败"),
SERIES_CLAIM_ERROR_FIVE_TIMES("NFT0010002","NFT系列声明失败,任务查询超过5次");
SERIES_CLAIM_ERROR_FIVE_TIMES("NFT0010002","NFT系列声明失败,任务查询超过5次"),
PUBLISH_FAIL("NFT0010003","NFT发行失败,未获取nft"),
PUBLISH_BUY_FAIL("NFT0010004","NFT发行购买失败,未发起购买"),
PUBLISH_FAIL_ALREADY_EXIST("NFT0010005","NFT发行失败,该订单已经发行过指定nft!");
private String code;
private String message;
......
......@@ -32,7 +32,7 @@ public class GalaxyNftOrderBo implements Serializable,Cloneable {
/**
* 接入方买入唯一标识
*/
private String orderPayId;
private String nftOrderPayId;
/**
* nftId
*/
......
package com.liquidnet.service.galaxy.dto.param;
import com.liquidnet.commons.lang.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: NFT购买(涉及NFT发行、NFT购买)
* @class: GalaxyNftPublishAndBuyReqDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/17 13:51
*/
@ApiModel(value = "GalaxyNftPublishAndBuyReqDto", description = "NFT发行购买")
@Data
public class GalaxyNftPublishAndBuyReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
/**
* 以下为发行参数***********************************
*/
@ApiModelProperty(position = 1, required = true, value = "用户ID[30]")
@NotBlank(message = "用户ID不能为空!")
@Size(min = 1, max = 30, message = "用户ID限制2-30位且不能包含特殊字符")
private String userId;
/**
* skuId
*/
@ApiModelProperty(position = 1, required = true, value = "系列唯一id标识,不超过20个字符")
@NotBlank(message = "skuId不能为空!")
@Size(min = 2, max = 20, message = "skuId限制2-20位且不能包含特殊字符")
private String skuId;
/**
* nftOrderPayId
*/
@ApiModelProperty(position = 1, required = true, value = "nft订单支付id(保证唯一),不超过30个字符")
@NotBlank(message = "nft订单支付id不能为空")
@Size(min = 2, max = 30, message = "nft订单支付id限制2-30位且不能包含特殊字符")
private String nftOrderPayId;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftPublishAndBuyReqDto obj = new GalaxyNftPublishAndBuyReqDto();
public static GalaxyNftPublishAndBuyReqDto getNew() {
try {
return (GalaxyNftPublishAndBuyReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftPublishAndBuyReqDto();
}
}
}
package com.liquidnet.service.galaxy.dto.param;
import com.liquidnet.commons.lang.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyNftPublishAndBuyRespDto
* @Package com.liquidnet.service.galaxy.dto.param;
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/17 13:51
*/
@ApiModel(value = "GalaxyNftPublishAndBuyRespDto", description = "NFT购买")
@Data
public class GalaxyNftPublishAndBuyRespDto implements Serializable,Cloneable {
@ApiModelProperty(position = 1, required = true, value = "用户Id")
private String userId;
@ApiModelProperty(position = 1, required = true, value = "用户购买的nftId")
private String nftId;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftPublishAndBuyRespDto obj = new GalaxyNftPublishAndBuyRespDto();
public static GalaxyNftPublishAndBuyRespDto getNew() {
try {
return (GalaxyNftPublishAndBuyRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftPublishAndBuyRespDto();
}
}
}
package com.liquidnet.service.galaxy.dto.param;
import com.liquidnet.commons.lang.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: NFT购买(涉及NFT发行、NFT购买)
* @class: GalaxyNftPublishReqDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/17 13:51
*/
@ApiModel(value = "GalaxyNftPublishReqDto", description = "NFT发行")
@Data
public class GalaxyNftPublishReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
/**
* 以下为发行参数***********************************
*/
@ApiModelProperty(position = 1, required = true, value = "用户ID[30]")
@NotBlank(message = "用户ID不能为空!")
@Size(min = 1, max = 30, message = "用户ID限制2-30位且不能包含特殊字符")
private String userId;
/**
* skuId
*/
@ApiModelProperty(position = 1, required = true, value = "系列唯一id标识,不超过20个字符")
@NotBlank(message = "skuId不能为空!")
@Size(min = 2, max = 20, message = "skuId限制2-20位且不能包含特殊字符")
private String skuId;
/**
* nftOrderPayId
*/
@ApiModelProperty(position = 1, required = true, value = "nft订单支付id(保证唯一),不超过30个字符")
@NotBlank(message = "nft订单支付id不能为空")
@Size(min = 2, max = 30, message = "nft订单支付id限制2-30位且不能包含特殊字符")
private String nftOrderPayId;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftPublishReqDto obj = new GalaxyNftPublishReqDto();
public static GalaxyNftPublishReqDto getNew() {
try {
return (GalaxyNftPublishReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftPublishReqDto();
}
}
}
package com.liquidnet.service.galaxy.dto.param;
import com.liquidnet.commons.lang.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyNftPublishRespDto
* @Package com.liquidnet.service.galaxy.dto.param
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/17 13:51
*/
@ApiModel(value = "GalaxyNftPublishRespDto", description = "NFT发行")
@Data
public class GalaxyNftPublishRespDto implements Serializable,Cloneable {
@ApiModelProperty(position = 1, required = true, value = "用户Id")
private String userId;
@ApiModelProperty(position = 1, required = true, value = "用户购买的nftId")
private String nftId;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftPublishRespDto obj = new GalaxyNftPublishRespDto();
public static GalaxyNftPublishRespDto getNew() {
try {
return (GalaxyNftPublishRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftPublishRespDto();
}
}
}
......@@ -32,7 +32,7 @@ public class GalaxyNftOrderVo implements Serializable,Cloneable {
/**
* 接入方买入唯一标识
*/
private String orderPayId;
private String nftOrderPayId;
/**
* nftId
*/
......
......@@ -2,8 +2,8 @@ package com.liquidnet.service.galaxy.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -15,5 +15,5 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
* @date 2022/3/8 11:45
*/
public interface IGalaxyPublishService {
ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
ResponseDto<GalaxyNftPublishRespDto> nftPublish(GalaxyNftPublishReqDto reqDto);
}
package com.liquidnet.service.galaxy.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
......@@ -11,4 +17,7 @@ package com.liquidnet.service.galaxy.service;
* @date 2022/3/8 11:45
*/
public interface IGalaxyTradeService {
ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto);
}
package com.liquidnet.service.galaxy.controller;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: NFT购买
* @class: GalaxyNftTradeController
* @Package com.liquidnet.service.galaxy.controller
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/14 18:08
*/
@Api(tags = "NFT艺术品相关")
@RestController
@RequestMapping("nftTrade")
@Validated
@Slf4j
public class GalaxyNftTradeController {
}
......@@ -3,8 +3,8 @@ 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.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto;
import com.liquidnet.service.galaxy.service.IGalaxyPublishService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -27,7 +27,7 @@ import javax.validation.Valid;
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 12:11
*/
@Api(tags = "NFT-发行购买相关")
@Api(tags = "NFT-发行相关")
@RestController
@RequestMapping("nftPublish")
@Validated
......@@ -36,11 +36,11 @@ public class GalaxyPublishController {
@Autowired
private IGalaxyPublishService galaxyPublishService;
@ControllerLog(description = "NFT购买")
@ControllerLog(description = "NFT发行")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "NFT购买")
@PostMapping(value = {"nftBuy"})
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(@Valid @RequestBody GalaxyNftBuyReqDto reqDto){
return galaxyPublishService.nftBuy(reqDto);
@ApiOperation(value = "NFT发行")
@PostMapping(value = {"nftPublish"})
public ResponseDto<GalaxyNftPublishRespDto> nftPublish(@Valid @RequestBody GalaxyNftPublishReqDto reqDto){
return galaxyPublishService.nftPublish(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.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
import com.liquidnet.service.galaxy.service.IGalaxyTradeService;
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;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: NFT购买
* @class: GalaxyNftTradeController
* @Package com.liquidnet.service.galaxy.controller
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/14 18:08
*/
@Api(tags = "NFT交易相关")
@RestController
@RequestMapping("nftTrade")
@Validated
@Slf4j
public class GalaxyTradeController {
@Autowired
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 = {"nftPublishAndBuy"})
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(@Valid @RequestBody GalaxyNftPublishAndBuyReqDto reqDto){
return galaxyTradeService.nftPublishAndBuy(reqDto);
}
}
......@@ -21,5 +21,9 @@ public interface IGalaxyRouterStrategy {
ResponseDto<GalaxyArtSeriesClaimRespDto> seriesClaim(GalaxyArtSeriesClaimReqDto reqDto);
ResponseDto<GalaxyNftPublishRespDto> nftPublish(GalaxyNftPublishReqDto reqDto);
ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto);
ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
}
......@@ -26,6 +26,16 @@ public class GalaxyRouterStrategyEthImpl extends AbstractGalaxyRouterStrategyImp
return null;
}
@Override
public ResponseDto<GalaxyNftPublishRespDto> nftPublish(GalaxyNftPublishReqDto reqDto) {
return null;
}
@Override
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
return null;
}
@Override
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return null;
......
......@@ -6,6 +6,7 @@ import com.liquidnet.service.galaxy.dto.param.*;
import com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterHandler;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinArtworkBiz;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinPublishBiz;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinTradeBiz;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,6 +34,9 @@ public class GalaxyRouterStrategyZxlImpl extends AbstractGalaxyRouterStrategyImp
@Autowired
private ZxinPublishBiz zxinPublishBiz;
@Autowired
private ZxinTradeBiz zxinTradeBiz;
@Override
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserBiz.userRegister(reqDto);
......@@ -53,8 +57,18 @@ public class GalaxyRouterStrategyZxlImpl extends AbstractGalaxyRouterStrategyImp
return zxinArtworkBiz.seriesClaim(reqDto);
}
@Override
public ResponseDto<GalaxyNftPublishRespDto> nftPublish(GalaxyNftPublishReqDto reqDto) {
return zxinPublishBiz.nftPublish(reqDto);
}
@Override
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
return zxinPublishBiz.nftPublishAndBuy(reqDto);
}
@Override
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
return zxinPublishBiz.nftBuy(reqDto);
return zxinTradeBiz.nftBuy(reqDto);
}
}
package com.liquidnet.service.galaxy.router.zxin.biz;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlnftEnum;
import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil;
import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil;
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.GalaxyErrorCodeEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.utils.DataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
......@@ -15,4 +32,110 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class ZxinTradeBiz {
@Autowired
private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlWalletSdkUtil zxlWalletSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
@Autowired
private ZxlnftConfig zxlnftConfig;
@Autowired
private DataUtils dataUtils;
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto nftBuyReqDto){
//获取用户信息
GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(nftBuyReqDto.getRouteType(),nftBuyReqDto.getUserId());
//获取sku信息
GalaxySeriesInfoBo seriesInfoBo = dataUtils.getSeriesInfoBo(nftBuyReqDto.getRouteType(),nftBuyReqDto.getSkuId());
//获取nftOrder信息
GalaxyNftOrderBo nftOrderBo = dataUtils.getNftOrderBo(nftBuyReqDto.getRouteType(),nftBuyReqDto.getNftOrderPayId());
//返回参数nftId
String nftId = null;
if(StringUtil.isNotNull(nftOrderBo)){
nftId = nftOrderBo.getNftId();
}
if(StringUtil.isNotEmpty(nftId)){
//执行购买逻辑
GalaxyNftBuyRespDto nftBuyRespDto = this.nftBuyBusiness(nftId,userInfoBo,seriesInfoBo);
return ResponseDto.success(nftBuyRespDto);
}else{
return ResponseDto.failure(GalaxyErrorCodeEnum.PUBLISH_BUY_FAIL.getCode(),GalaxyErrorCodeEnum.PUBLISH_BUY_FAIL.getMessage());
}
}
public GalaxyNftBuyRespDto nftBuyBusiness(String nftId,GalaxyUserInfoBo userInfoBo, GalaxySeriesInfoBo seriesInfoBo){
// 3.2.2调用购买NFT接口
Nft043BuyReqDto nft043BuyReqDto = Nft043BuyReqDto.getNew();
nft043BuyReqDto.setNftId(nftId);
nft043BuyReqDto.setApplyScore(seriesInfoBo.getSellCount().intValue());
nft043BuyReqDto.setReceiverPubKey(userInfoBo.getUserPubKey());
nft043BuyReqDto.setPointReceiverAddr(userInfoBo.getBlockChainAddress());
nft043BuyReqDto.setOfferCount(seriesInfoBo.getSellCount().longValue());
nft043BuyReqDto.setOperateId(IDGenerator.get32UUID());
/**
* 接收人的私钥签名,签名对象是(platformPubKey_receiverPubKey_pointReceiverAddr_applyScore_接口名_nftId_offerCount_operateId)
* 接口名:buy_nft
*/
String signMetaData = zxlnftConfig.getNftPlatformPubKey()
.concat("_").concat(nft043BuyReqDto.getReceiverPubKey())
.concat("_").concat(nft043BuyReqDto.getPointReceiverAddr())
.concat("_").concat(nft043BuyReqDto.getApplyScore().toString())
.concat("_").concat("buy_nft")
.concat("_").concat(nft043BuyReqDto.getNftId())
.concat("_").concat(nft043BuyReqDto.getOfferCount().toString())
.concat("_").concat(nft043BuyReqDto.getOperateId());
String signature = zxlnftBiz.createSign(userInfoBo.getUserPriKey(),signMetaData);
nft043BuyReqDto.setSignature(signature);
ZxlnftResponseDto<Nft043BuyRespDto> nft043RespDto = zxlnftSdkUtil.nft043Buy(nft043BuyReqDto);
if(nft043RespDto.isSuccess()){
//3.2.4查询NFT购买结果
Nft044BuyResultReqDto nft044ReqDto = Nft044BuyResultReqDto.getNew();
nft044ReqDto.setTaskId(nft043RespDto.getData().getTaskId());
long timeStart = System.currentTimeMillis();
ZxlnftResponseDto<Nft044BuyResultRespDto> nft044RespDto = zxlnftSdkUtil.nft044BuyResult(nft044ReqDto);
if(nft044RespDto.isSuccess()){
int count = 1;
String payTaskId = null;
while(payTaskId == null){
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
count++;
log.info("=======执行第{}次查询,taskId:{}",1,nft044ReqDto.getTaskId());
ZxlnftResponseDto<Nft044BuyResultRespDto> nft044RespDtoTemp = zxlnftSdkUtil.nft044BuyResult(nft044ReqDto);
if(nft044RespDtoTemp.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
payTaskId = nft044RespDtoTemp.getData().getPayTaskId();
}else if(nft044RespDtoTemp.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_FAIL.getCode())){
log.info("任务执行失败!taskId:{}",nft044ReqDto.getTaskId());
return null;
}
if(count==6){
log.info("=======查询共6次,跳出循环!taskId:{}",nft044ReqDto.getTaskId());
break;
}
}
log.info("总共执行了多少次查询:{} 总耗时:{}",count,System.currentTimeMillis() - timeStart);
if(StringUtil.isNotEmpty(payTaskId)){
//3.2.5查询NFT购买支付结果
Nft045BuyPayResultReqDto nft045ReqDto = Nft045BuyPayResultReqDto.getNew();
nft045ReqDto.setTaskId(payTaskId);
ZxlnftResponseDto<Nft045BuyPayResultRespDto> nft045RespDto = zxlnftSdkUtil.nft045BuyPayResult(nft045ReqDto);
}
}
}
return null;
}
}
package com.liquidnet.service.galaxy.service.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.*;
import com.liquidnet.service.galaxy.router.strategy.GalaxyRouterStrategyContext;
import com.liquidnet.service.galaxy.service.IGalaxyPublishService;
import lombok.extern.slf4j.Slf4j;
......@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @Description: NFT发行相关
* @class: GalaxyPublishServiceImpl
* @Package com.liquidnet.service.galaxy.service.impl
* @Copyright: LightNet @ Copyright (c) 2021
......@@ -25,7 +24,7 @@ public class GalaxyPublishServiceImpl implements IGalaxyPublishService {
private GalaxyRouterStrategyContext galaxyRouterStrategyContext;
@Override
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).nftBuy(reqDto);
public ResponseDto<GalaxyNftPublishRespDto> nftPublish(GalaxyNftPublishReqDto reqDto) {
return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).nftPublish(reqDto);
}
}
package com.liquidnet.service.galaxy.service.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
import com.liquidnet.service.galaxy.router.strategy.GalaxyRouterStrategyContext;
import com.liquidnet.service.galaxy.service.IGalaxyTradeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: GalaxyTradeServiceImpl
* @Package com.liquidnet.service.galaxy.service.impl
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/17 14:19
*/
@Slf4j
@Service
public class GalaxyTradeServiceImpl implements IGalaxyTradeService {
@Autowired
private GalaxyRouterStrategyContext galaxyRouterStrategyContext;
@Override
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).nftBuy(reqDto);
}
@Override
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).nftPublishAndBuy(reqDto);
}
}
......@@ -61,9 +61,9 @@ public class DataUtils {
}
}
public void setNftOrderBo(String routeType,String skuId, GalaxyNftOrderBo nftOrderBo) {
public void setNftOrderBo(String routeType,String nftOrderPayId, GalaxyNftOrderBo nftOrderBo) {
redisUtil.set(GalaxyConstant.REDIS_KET_GALAXY_TRADE.concat(routeType).concat(":") + skuId,nftOrderBo,keyExpireTime);
redisUtil.set(GalaxyConstant.REDIS_KET_GALAXY_TRADE.concat(routeType).concat(":") + nftOrderPayId,nftOrderBo,keyExpireTime);
/**
* 入库mongo
*/
......@@ -77,7 +77,7 @@ public class DataUtils {
if(obj!=null){
return (GalaxyNftOrderBo) obj;
}else {
GalaxyNftOrderVo nftOrderVo = mongoTemplate.findOne(Query.query(Criteria.where("orderPayId").is(orderPayId)), GalaxyNftOrderVo.class, GalaxyNftOrderVo.class.getSimpleName());
GalaxyNftOrderVo nftOrderVo = mongoTemplate.findOne(Query.query(Criteria.where("nftOrderPayId").is(orderPayId)), GalaxyNftOrderVo.class, GalaxyNftOrderVo.class.getSimpleName());
if (nftOrderVo == null) {
return null;
}
......
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