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

Commit 038dd0e9 authored by anjiabin's avatar anjiabin

实现zxtnft购买功能

parent 77d2ae8d
...@@ -12,14 +12,14 @@ package com.liquidnet.service.galaxy.constant; ...@@ -12,14 +12,14 @@ package com.liquidnet.service.galaxy.constant;
public class GalaxyConstant { public class GalaxyConstant {
public static final String SERIES_STORE_NAME="NOW_ZXL_NFT_PIC";// 系列存储目录名称 public static final String SERIES_STORE_NAME="NOW_ZXL_NFT_PIC";// 系列存储目录名称
public enum RouterEnum{ public enum RouterTypeEnum{
ZXINCHAIN("zxinchain","至信链"), ZXINCHAIN("zxinchain","至信链"),
ETH ("eth","以太坊"), ETH ("eth","以太坊"),
ANTCHAIN ("antchain","蚂蚁链"), ANTCHAIN ("antchain","蚂蚁链"),
XUPER("xuper","百度超级链"); XUPER("xuper","百度超级链");
private String code; private String code;
private String message; private String message;
RouterEnum(String code, String message) { RouterTypeEnum(String code, String message) {
this.code = code; this.code = code;
this.message = message; this.message = message;
} }
...@@ -68,7 +68,7 @@ public class GalaxyConstant { ...@@ -68,7 +68,7 @@ public class GalaxyConstant {
public static void main(String[] args) { public static void main(String[] args) {
Integer aaa = 1; Integer aaa = 1;
if(aaa.toString().equals(RouterEnum.ZXINCHAIN.getCode())){ if(aaa.toString().equals(RouterTypeEnum.ZXINCHAIN.getCode())){
System.out.println("支付成功"); System.out.println("支付成功");
} }
} }
......
...@@ -17,7 +17,7 @@ import java.io.Serializable; ...@@ -17,7 +17,7 @@ import java.io.Serializable;
*/ */
@ApiModel(value = "GalaxyArtSeriesClaimReqDto", description = "NFT系列声明") @ApiModel(value = "GalaxyArtSeriesClaimReqDto", description = "NFT系列声明")
@Data @Data
public class GalaxyArtSeriesClaimReqDto implements Serializable,Cloneable { public class GalaxyArtSeriesClaimReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
/** /**
* skuId * skuId
*/ */
......
package com.liquidnet.service.galaxy.dto;
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: GalaxyBaseReqDto
* @Package com.liquidnet.service.galaxy.dto
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 12:21
*/
@Data
public class GalaxyBaseReqDto implements Serializable,Cloneable{
private String routeType;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyBaseReqDto obj = new GalaxyBaseReqDto();
public static GalaxyBaseReqDto getNew() {
try {
return (GalaxyBaseReqDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyBaseReqDto();
}
}
}
...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel; ...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
...@@ -20,7 +21,7 @@ import java.io.Serializable; ...@@ -20,7 +21,7 @@ import java.io.Serializable;
*/ */
@ApiModel(value = "GalaxyNftBuyReqDto", description = "NFT购买") @ApiModel(value = "GalaxyNftBuyReqDto", description = "NFT购买")
@Data @Data
public class GalaxyNftBuyReqDto implements Serializable,Cloneable { public class GalaxyNftBuyReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
/** /**
* 以下为发行参数*********************************** * 以下为发行参数***********************************
*/ */
...@@ -31,36 +32,52 @@ public class GalaxyNftBuyReqDto implements Serializable,Cloneable { ...@@ -31,36 +32,52 @@ public class GalaxyNftBuyReqDto implements Serializable,Cloneable {
/** /**
* skuId * skuId
*/ */
@ApiModelProperty(position = 1, required = true, value = "系列唯一id标识,不超过20个字符")
@Size(min = 2, max = 20, message = "skuId限制2-20位且不能包含特殊字符")
private String skuId; private String skuId;
/**
* 作者名,中文+英文(数字或符号为非法输入) 不超过30个字符
*/
@ApiModelProperty(position = 1, required = true, value = "作者名,中文+英文(数字或符号为非法输入) 不超过20个字符")
@Size(max = 20, message = "中文+英文(数字或符号为非法输入) 不超过20个字符")
private String author;
/** /**
* nft名字(sku名称),中英文数字均可,不超过256个字符 * nft名字(sku名称),中英文数字均可,不超过256个字符
*/ */
@ApiModelProperty(position = 1, required = true, value = "nft名字(sku名称),中英文数字均可,不超过100个字符")
@Size(max = 100, message = "nft名字不能超过100个字符")
private String name; private String name;
/** /**
* nftUrl,不超过1024个字符 * nftUrl,不超过1024个字符
*/ */
@ApiModelProperty(position = 1, required = true, value = "nftUrl,不超过500个字符")
@Size(max = 500, message = "nftUrl,不超过500个字符")
private String url; private String url;
/** /**
* 预览图url,不超过1024个字符。(至信链浏览器展示预览图尺寸为290*290,请上传比例为1:1的图片) * 预览图url,不超过1024个字符。(至信链浏览器展示预览图尺寸为290*290,请上传比例为1:1的图片)
*/ */
@ApiModelProperty(position = 1, required = true, value = "预览图url,不超过500个字符")
@Size(max = 500, message = "预览图url,不超过500个字符")
private String displayUrl; private String displayUrl;
/** /**
* nft简介,500个字符以内 * nft简介,500个字符以内
*/ */
@ApiModelProperty(position = 1, required = true, value = "nft简介,300个字符以内")
@Size(max = 300, message = "nft简介,300个字符以内")
private String desc; private String desc;
/** /**
* 标签,【文创】,游戏,动漫,30个字符以内 * 标签,【文创】,游戏,动漫,30个字符以内
* 非必填 * 非必填
*/ */
@ApiModelProperty(position = 1, required = false, value = "标签,文创,游戏,动漫,30个字符以内")
@Size(max = 20, message = "标签,文创,游戏,动漫,20个字符以内")
private String flag; private String flag;
/**
* 发行量,如果没有系列,就只能为1,如果有系列从1开始,比如如有100个,系列id范围则为[1-100],单次发行个数不超过1000,
* 同系列下同介质个数总共不能超过3000
*/
private String publishCount;
/** /**
* 可售状态下有意义,表示售卖多少积分 * 可售状态下有意义,表示售卖多少积分
*/ */
@ApiModelProperty(position = 1, required = true, value = "sku价格,金额必须是数字格式,例:211.23 后续不可修改")
@Digits(integer = 10,fraction = 2,message = "金额必须是数字格式")
private String sellCount; private String sellCount;
@Override @Override
......
package com.liquidnet.service.galaxy.dto; package com.liquidnet.service.galaxy.dto;
import com.liquidnet.commons.lang.util.JsonUtils;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -9,5 +15,25 @@ package com.liquidnet.service.galaxy.dto; ...@@ -9,5 +15,25 @@ package com.liquidnet.service.galaxy.dto;
* @Copyright: LightNet @ Copyright (c) 2021 * @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/14 18:13 * @date 2022/3/14 18:13
*/ */
public class GalaxyNftBuyRespDto { @ApiModel(value = "GalaxyNftBuyRespDto", description = "NFT购买")
@Data
public class GalaxyNftBuyRespDto implements Serializable,Cloneable {
private String userId;
private String nftId;
@Override
public String toString(){
return JsonUtils.toJson(this);
}
private static final GalaxyNftBuyRespDto obj = new GalaxyNftBuyRespDto();
public static GalaxyNftBuyRespDto getNew() {
try {
return (GalaxyNftBuyRespDto) obj.clone();
} catch (CloneNotSupportedException e) {
return new GalaxyNftBuyRespDto();
}
}
} }
...@@ -18,7 +18,7 @@ import java.io.Serializable; ...@@ -18,7 +18,7 @@ import java.io.Serializable;
*/ */
@ApiModel(value = "GalaxyNftUploadReqDto", description = "NFT素材上传") @ApiModel(value = "GalaxyNftUploadReqDto", description = "NFT素材上传")
@Data @Data
public class GalaxyNftUploadReqDto implements Serializable,Cloneable { public class GalaxyNftUploadReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
@ApiModelProperty(position = 1, required = true, value = "上传原始图片url") @ApiModelProperty(position = 1, required = true, value = "上传原始图片url")
private String imageUrl; private String imageUrl;
......
...@@ -21,7 +21,7 @@ import java.io.Serializable; ...@@ -21,7 +21,7 @@ import java.io.Serializable;
*/ */
@ApiModel(value = "GalaxyUserRegisterReqDto", description = "用户实名注册") @ApiModel(value = "GalaxyUserRegisterReqDto", description = "用户实名注册")
@Data @Data
public class GalaxyUserRegisterReqDto implements Serializable,Cloneable { public class GalaxyUserRegisterReqDto extends GalaxyBaseReqDto implements Serializable,Cloneable {
@ApiModelProperty(position = 1, required = true, value = "用户ID[30]") @ApiModelProperty(position = 1, required = true, value = "用户ID[30]")
@NotBlank(message = "用户ID不能为空!") @NotBlank(message = "用户ID不能为空!")
@Size(min = 1, max = 30, message = "用户ID限制2-30位且不能包含特殊字符") @Size(min = 1, max = 30, message = "用户ID限制2-30位且不能包含特殊字符")
......
package com.liquidnet.service.galaxy.service; package com.liquidnet.service.galaxy.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.GalaxyNftBuyRespDto;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -11,4 +15,5 @@ package com.liquidnet.service.galaxy.service; ...@@ -11,4 +15,5 @@ package com.liquidnet.service.galaxy.service;
* @date 2022/3/8 11:45 * @date 2022/3/8 11:45
*/ */
public interface IGalaxyPublishService { public interface IGalaxyPublishService {
ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
} }
package com.liquidnet.service.galaxy.router.eth.biz;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: EthArtworkBiz
* @Package com.liquidnet.service.galaxy.router.eth.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:07
*/
public class EthArtworkBiz {
}
package com.liquidnet.service.galaxy.router.eth.biz;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: EthPublishBiz
* @Package com.liquidnet.service.galaxy.router.eth.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:07
*/
public class EthPublishBiz {
}
package com.liquidnet.service.galaxy.router.eth.biz;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: EthUserBiz
* @Package com.liquidnet.service.galaxy.router.eth.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:08
*/
public class EthUserBiz {
}
package com.liquidnet.service.galaxy.router.strategy; package com.liquidnet.service.galaxy.router.strategy;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.*;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -10,9 +13,11 @@ package com.liquidnet.service.galaxy.router.strategy; ...@@ -10,9 +13,11 @@ package com.liquidnet.service.galaxy.router.strategy;
* @date 2022/3/8 10:27 * @date 2022/3/8 10:27
*/ */
public interface IGalaxyRouterStrategy { public interface IGalaxyRouterStrategy {
// ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto); ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto);
//
// String dragonNotify(HttpServletRequest request, String payType, String deviceFrom); ResponseDto<GalaxyNftUploadRespDto> nftUpload(GalaxyNftUploadReqDto reqDto);
//
// DragonPayOrderQueryRespDto checkOrderStatus(String code); ResponseDto<GalaxyArtSeriesClaimRespDto> seriesClaim(GalaxyArtSeriesClaimReqDto reqDto);
ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
} }
...@@ -18,5 +18,5 @@ import java.lang.annotation.*; ...@@ -18,5 +18,5 @@ import java.lang.annotation.*;
@Target(ElementType.TYPE) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface StrategyGalaxyRouterHandler { public @interface StrategyGalaxyRouterHandler {
GalaxyConstant.RouterEnum value(); GalaxyConstant.RouterTypeEnum value();
} }
package com.liquidnet.service.galaxy.router.strategy.impl; package com.liquidnet.service.galaxy.router.strategy.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.*;
import com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategy; import com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategy;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -14,60 +16,9 @@ import lombok.extern.slf4j.Slf4j; ...@@ -14,60 +16,9 @@ import lombok.extern.slf4j.Slf4j;
*/ */
@Slf4j @Slf4j
public abstract class AbstractGalaxyRouterStrategyImpl implements IGalaxyRouterStrategy { public abstract class AbstractGalaxyRouterStrategyImpl implements IGalaxyRouterStrategy {
// @Autowired public abstract ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto);
// private DragonPayBiz dragonPayBiz;
// @Autowired
// private DataUtils dataUtils;
//
// @Autowired
// private DragonServiceCommonBiz dragonServiceCommonBiz;
//
// @Override
// public abstract ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto);
//
// @Override
// public abstract String dragonNotify(HttpServletRequest request, String payType, String deviceFrom);
//
// @Override
// public abstract DragonPayOrderQueryRespDto checkOrderStatus(String code);
//
// /**
// * 支付成功方法
// * @param dragonOrdersDto
// * @param bankTrxNo
// * @param timeEnd
// * @param bankReturnMsg
// */
// @Transactional(rollbackFor = Exception.class)
// protected boolean completeSuccessOrder(DragonOrdersDto dragonOrdersDto, String bankTrxNo, LocalDateTime timeEnd, String bankReturnMsg) {
// log.info("订单支付成功!");
// dragonOrdersDto.setPaymentAt(timeEnd);
// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
// dragonOrdersDto.setStatus(Integer.parseInt(DragonConstant.PayStatusEnum.STATUS_PAID.getCode()));
// //更新缓存
// dataUtils.updateOrderStatus(dragonOrdersDto.getCode(),dragonOrdersDto);
// //修改订单状态
// dragonServiceCommonBiz.updateOrderStatus(dragonOrdersDto.getCode(),dragonOrdersDto.getStatus(),bankTrxNo);
// //通知商户
// return dragonPayBiz.sendNotify(dragonPayBiz.buildPayNotifyReqBo(dragonOrdersDto));
// }
//
// /**
// * 支付失败方法
// * @param dragonOrdersDto
// * @param bankReturnMsg
// */
// protected boolean completeFailOrder(DragonOrdersDto dragonOrdersDto, String bankReturnMsg) {
// log.info("订单支付失败!");
//// dragonOrdersDto.setPaymentAt(timeEnd);
//// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
// dragonOrdersDto.setStatus(Integer.parseInt(DragonConstant.PayStatusEnum.STATUS_PAY_FAIL.getCode()));
// //更新缓存
// dataUtils.updateOrderStatus(dragonOrdersDto.getCode(),dragonOrdersDto);
// //修改订单状态
// dragonServiceCommonBiz.updateOrderStatus(dragonOrdersDto.getCode(),dragonOrdersDto.getStatus(),null);
// //通知商户
// return dragonPayBiz.sendNotify(dragonPayBiz.buildPayNotifyReqBo(dragonOrdersDto));
// }
public abstract ResponseDto<GalaxyNftUploadRespDto> nftUpload(GalaxyNftUploadReqDto reqDto);
public abstract ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto);
} }
package com.liquidnet.service.galaxy.router.strategy.impl; package com.liquidnet.service.galaxy.router.strategy.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyConstant; import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.dto.*;
import com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterHandler; import com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterHandler;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -16,21 +18,26 @@ import org.springframework.stereotype.Component; ...@@ -16,21 +18,26 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
@StrategyGalaxyRouterHandler(GalaxyConstant.RouterEnum.ETH) @StrategyGalaxyRouterHandler(GalaxyConstant.RouterTypeEnum.ETH)
public class GalaxyRouterStrategyEthImpl extends AbstractGalaxyRouterStrategyImpl { public class GalaxyRouterStrategyEthImpl extends AbstractGalaxyRouterStrategyImpl {
// @Override @Override
// public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) { public ResponseDto<GalaxyArtSeriesClaimRespDto> seriesClaim(GalaxyArtSeriesClaimReqDto reqDto) {
// return null; return null;
// } }
//
// @Override @Override
// public String dragonNotify(HttpServletRequest request,String payType,String deviceFrom) { public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
// return null; return null;
// } }
//
// @Override @Override
// public DragonPayOrderQueryRespDto checkOrderStatus(String code) { public ResponseDto<GalaxyNftUploadRespDto> nftUpload(GalaxyNftUploadReqDto reqDto) {
// return null; return null;
// } }
@Override
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
return null;
}
} }
package com.liquidnet.service.galaxy.router.strategy.impl; package com.liquidnet.service.galaxy.router.strategy.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyConstant; import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.dto.*;
import com.liquidnet.service.galaxy.router.strategy.annotation.StrategyGalaxyRouterHandler; 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.ZxinUserBiz;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -16,127 +22,34 @@ import org.springframework.stereotype.Component; ...@@ -16,127 +22,34 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
@StrategyGalaxyRouterHandler(GalaxyConstant.RouterEnum.ZXINCHAIN) @StrategyGalaxyRouterHandler(GalaxyConstant.RouterTypeEnum.ZXINCHAIN)
public class GalaxyRouterStrategyZxlImpl extends AbstractGalaxyRouterStrategyImpl { public class GalaxyRouterStrategyZxlImpl extends AbstractGalaxyRouterStrategyImpl {
// @Autowired @Autowired
// private AlipayStrategyContext alipayStrategyContext; private ZxinUserBiz zxinUserBiz;
//
// @Autowired @Autowired
// private DataUtils dataUtils; private ZxinArtworkBiz zxinArtworkBiz;
//
// @Autowired @Autowired
// private AlipayBiz alipayBiz; private ZxinPublishBiz zxinPublishBiz;
//
// @Autowired @Override
// private DragonPayBiz dragonPayBiz; public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
// return zxinUserBiz.userRegister(reqDto);
// @Autowired }
// private DragonServiceCommonBiz dragonServiceCommonBiz;
// @Override
// @Autowired public ResponseDto<GalaxyNftUploadRespDto> nftUpload(GalaxyNftUploadReqDto reqDto) {
// private DragonOrderRefundsServiceImpl dragonOrderRefundsService; return zxinArtworkBiz.nftUpload(reqDto);
// }
// @Value("${liquidnet.dragon.alipay.appId}")
// private String appId; @Override
// @Value("${liquidnet.dragon.alipay.merchantPubKey}") public ResponseDto<GalaxyArtSeriesClaimRespDto> seriesClaim(GalaxyArtSeriesClaimReqDto reqDto) {
// private String merchantPubKey; return zxinArtworkBiz.seriesClaim(reqDto);
// @Value("${liquidnet.dragon.alipay.merchantPrivateKey}") }
// private String merchantPrivateKey;
// @Value("${liquidnet.dragon.alipay.signtType}") @Override
// private String signtType; public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
// @Value("${liquidnet.dragon.alipay.charset}") return zxinPublishBiz.nftBuy(reqDto);
// private String charset; }
//
// @Override
// public ResponseDto<DragonPayBaseRespDto> dragonPay(DragonPayBaseReqDto dragonPayBaseReqDto) {
// return alipayStrategyContext.getStrategy(dragonPayBaseReqDto.getDeviceFrom()).dragonPay(dragonPayBaseReqDto);
// }
//
// @Override
// public String dragonNotify(HttpServletRequest request,String payType,String deviceFrom) {
// log.info("alipay-->notify-->begin payType:{} deviceFrom:{}",payType,deviceFrom);
// Map<String, String[]> requestParams = request.getParameterMap();
// Map<String, String> notifyMap = new HashMap<String, String>();
// notifyMap = alipayBiz.parseNotifyMsg(requestParams);
// log.info("dragonNotify-->alipay json : {}", JSON.toJSONString(notifyMap));
// log.info("接收到{}支付结果{}", payType, notifyMap);
//
//
// String returnStr = "fail";
// String code = notifyMap.get("out_trade_no");
//
// //持久化通知记录
// dragonServiceCommonBiz.createDragonOrderLogs(code,dragonPayBiz.getPaymentType(payType,deviceFrom),JSON.toJSONString(notifyMap));
//
// //退款
// if(notifyMap.containsKey("refund_fee") || notifyMap.containsKey("gmt_refund") || notifyMap.containsKey("out_biz_no")) {
// returnStr = dragonOrderRefundsService.aliPayRefundCallBack(JSON.toJSONString(notifyMap));
// return returnStr;
// }
//
// // 根据银行订单号获取支付信息
// DragonOrdersDto dragonOrdersDto = dataUtils.getPayOrderByCode(code);
// if (dragonOrdersDto == null) {
// throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getCode(),DragonErrorCodeEnum.TRADE_ERROR_NOT_EXISTS.getMessage());
// }
//
// if (DragonConstant.PayStatusEnum.STATUS_PAID.getCode().equals(dragonOrdersDto.getStatus())) {
// throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ERROR_HAS_PAID.getCode(),DragonErrorCodeEnum.TRADE_ERROR_HAS_PAID.getMessage());
// }
//
// try {
// if (AlipaySignature.rsaCheckV1(notifyMap, merchantPubKey, "UTF-8", "RSA2")){
// String tradeStatus = notifyMap.get("trade_status");
// boolean notifyResult = false;
//
// if (AlipayConstant.AlipayTradeStateEnum.TRADE_SUCCESS.name().equals(tradeStatus)
// ||AlipayConstant.AlipayTradeStateEnum.TRADE_FINISHED.name().equals(tradeStatus)) {
//
// String gmtPaymentStr = notifyMap.get("gmt_payment");// 付款时间
// LocalDateTime timeEnd = null;
// if (!StringUtil.isEmpty(gmtPaymentStr)) {
// timeEnd = DateUtil.Formatter.yyyyMMddHHmmss.parse(gmtPaymentStr);
// }
// notifyResult = this.completeSuccessOrder(dragonOrdersDto, notifyMap.get("trade_no"), timeEnd, notifyMap.toString());
// } else {
// notifyResult = this.completeFailOrder(dragonOrdersDto, notifyMap.toString());
// }
// if(notifyResult){
// returnStr = "success";
// }
// } else {// 验证失败
// log.error("alipay notify fail code:{} msg:{} ",DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getMessage());
// return returnStr;
// }
// } catch (AlipayApiException e) {
// log.error("alipay notify fail 验签失败:e:{}" , e);
// log.error("alipay notify fail 验签失败:code:{} msg:{}" ,DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_SIGN_ERROR.getMessage());
// }
//
// log.info("返回支付通道{}信息{}", payType, returnStr);
// log.info("alipay-->notify-->end payType:{} deviceFrom:{}",payType,deviceFrom);
// return returnStr;
// }
//
// @Override
// public DragonPayOrderQueryRespDto checkOrderStatus(String code) {
// DragonOrdersDto ordersDto = dataUtils.getPayOrderByCode(code);
// Map<String, Object> resultMap = alipayBiz.tradeQuery(code);
// DragonPayOrderQueryRespDto respDto = dragonPayBiz.buildPayOrderQueryRespDto(ordersDto);
// if ("10000".equals(resultMap.get("code"))) {
// // 当返回状态为“TRADE_FINISHED”交易成功结束和“TRADE_SUCCESS”支付成功时更新交易状态
// if (AlipayConstant.AlipayTradeStateEnum.TRADE_SUCCESS.getCode().equals(resultMap.get("tradeStatus"))
// || AlipayConstant.AlipayTradeStateEnum.TRADE_FINISHED.getCode().equals(resultMap.get("tradeStatus"))) {
// respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_PAID.getCode()));
// }else{
// respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_PAY_FAIL.getCode()));
// }
//// throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getMessage());
// }else if("40004".equals(resultMap.get("code"))&&"ACQ.TRADE_NOT_EXIST".equalsIgnoreCase(resultMap.get("subCode").toString())){
// respDto.setStatus(Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_UNPAID.getCode()));
// }else{
// throw new LiquidnetServiceException(DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getCode(),DragonErrorCodeEnum.TRADE_ALIPAY_QUERY_ERROR.getMessage());
// }
// return respDto;
// }
} }
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.dto.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.GalaxyNftBuyRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinPublishBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:05
*/
@Slf4j
@Component
public class ZxinPublishBiz {
@Autowired
private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlWalletSdkUtil zxlWalletSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
@Autowired
private ZxlnftConfig zxlnftConfig;
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
String author = reqDto.getAuthor();
String name = reqDto.getName();
String url = reqDto.getUrl();
String displayUrl = reqDto.getDisplayUrl();
String desc = reqDto.getDesc();
String flag = reqDto.getFlag();
//发行个数
Long publishCount = 1L;
//开始索引
Integer seriesBeginIndex = 0;
Long sellCount = Long.valueOf(new BigDecimal(reqDto.getSellCount()).longValue()); //积分
/**
* 根据sku获取系列Id
*/
String seriesId = reqDto.getSkuId();
//查询系列信息
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发行接口
/**
* 发行无限制系列
*/
Nft034PublishReqDto nft034ReqDto = Nft034PublishReqDto.getNew();
nft034ReqDto.setAuthor(author);
nft034ReqDto.setName(name);
nft034ReqDto.setUrl(url);
nft034ReqDto.setDisplayUrl(displayUrl);
nft034ReqDto.setDesc(desc);
nft034ReqDto.setFlag(flag);
nft034ReqDto.setPublishCount(publishCount);
//无限制零系列
nft034ReqDto.setSeriesId(seriesId);
nft034ReqDto.setSeriesBeginIndex(seriesBeginIndex);
nft034ReqDto.setSellStatus(Integer.parseInt(ZxlnftEnum.SellStatusEnum.CAN_SELL.getCode()));
nft034ReqDto.setSellCount(sellCount);
nft034ReqDto.setOperateId(IDGenerator.get32UUID());
nft034ReqDto.setMetaData("");
ZxlnftResponseDto<Nft034PublishRespDto> nft034RespDto = zxlnftSdkUtil.nft034Publish(nft034ReqDto);
if (nft034RespDto.isSuccess()) {
//3.1.4查询 NFT发行结果
Nft035PublishResultReqDto nft035ReqDto = Nft035PublishResultReqDto.getNew();
nft035ReqDto.setTaskId(nft034RespDto.getData().getTaskId());
//休眠1秒钟,等待执行结果
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
long timeStart = System.currentTimeMillis();
log.info("=======执行第{}次查询,taskId:{}", 1, nft035ReqDto.getTaskId());
ZxlnftResponseDto<Nft035PublishResultRespDto> nft035RespDto = zxlnftSdkUtil.nft035PublishResult(nft035ReqDto);
if (nft035RespDto.isSuccess()) {
if (nft035RespDto.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_FAIL.getCode())) {
log.info("任务执行失败!taskId:{} taskMsg:{}", nft035ReqDto.getTaskId(), nft035RespDto.getData().getTaskMsg());
return null;
}
int count = 1;
String nftIdBegin = nft035RespDto.getData().getNftIdBegin();
if (nft035RespDto.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.PROCESSING.getCode())) {
log.info(ZxlnftEnum.TaskStatusEnum.PROCESSING.getMessage());
while (StringUtil.isEmpty(nftIdBegin)) {
//休眠1秒钟,等待执行结果
try {
Thread.sleep(1000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
count++;
ZxlnftResponseDto<Nft035PublishResultRespDto> nft035RespDtoTemp = zxlnftSdkUtil.nft035PublishResult(nft035ReqDto);
log.info("=======执行第{}次查询,taskId:{}", count, nft035ReqDto.getTaskId());
if (nft035RespDtoTemp.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getCode())) {
nftIdBegin = nft035RespDtoTemp.getData().getNftIdBegin();
} else if (nft035RespDtoTemp.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_FAIL.getCode())) {
log.info("任务执行失败!taskId:{}", nft035ReqDto.getTaskId());
return null;
}
if (count == 6) {
log.info("=======查询共6次,跳出循环!taskId:{}", nft035ReqDto.getTaskId());
break;
}
}
} else if (nft035RespDto.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getCode())) {
log.info(ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getMessage());
}
log.info("发行NFT后返回给前端nftID:{}", nftIdBegin);
log.info("总共执行了{}次查询 总耗时:{} MS", count, (System.currentTimeMillis() - timeStart));
if (StringUtil.isNotEmpty(nftIdBegin)) {
//3.1.3调用NFT查询接口
Nft036InfoReqDto nft036ReqDto = Nft036InfoReqDto.getNew();
nft036ReqDto.setNftId(nftIdBegin);
ZxlnftResponseDto<Nft036InfoRespDto> nft036RespDto = zxlnftSdkUtil.nft036Info(nft036ReqDto);
log.info("调用NFT查询接口 : {}", nft036RespDto.toJson());
}
}
}
return null;
}
}
package com.liquidnet.service.galaxy.router.zxin.biz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinTradeBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:08
*/
@Slf4j
@Component
public class ZxinTradeBiz {
}
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.ZxlErrorEnum;
import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.dto.nft.Nft016QueryRsData;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairResp;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
import com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil;
import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil;
import com.liquidnet.commons.lang.util.BASE64Util;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinUserBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 13:05
*/
@Slf4j
@Component
public class ZxinUserBiz {
@Autowired
private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlWalletSdkUtil zxlWalletSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
@Autowired
private ZxlnftConfig zxlnftConfig;
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
String userId = reqDto.getUserId();
String userName = reqDto.getUserName();
String mobile = reqDto.getMobile();
String idCardType = reqDto.getIdCardType();
String idCard = reqDto.getIdCard();
String mnemonic = "stuff name goat health siren dumb gorilla antique board tenant buffalo present"; //安家宾
// String mnemonic = "economy cost balance weapon flight also nut biology very sun slight about"; //周焕
Long index = 0L;
String userIdentification = null;
String address = null;
String userPubKey = null;
String userPriKey = null;
try{
//生成助记词
CreateMnemonicReq req = CreateMnemonicReq.getNew();
CreateMnemonicResp createMnemonicResp = zxlWalletSdkUtil.createMnemonic(req);
mnemonic = createMnemonicResp.getMnemonic();
}catch(Exception e){
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"生成助记词失败!");
}
/**
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
if(StringUtil.isNotEmpty(mnemonic)){
//生成公私钥
DeriveKeyPairReq deriveKeyPairReq = DeriveKeyPairReq.getNew();
deriveKeyPairReq.setMnemonic(mnemonic);
// deriveKeyPairReq.setMnemonic(createMnemonicResp.getMnemonic());
deriveKeyPairReq.setIndex(index);
try{
DeriveKeyPairResp deriveKeyPairResp = zxlWalletSdkUtil.deriveKeyPair(deriveKeyPairReq);
if(!deriveKeyPairResp.getErr().equals("")) throw new Exception("生成公私钥失败!");
userPubKey = BASE64Util.encoded(deriveKeyPairResp.getPubKey());
userPriKey = BASE64Util.encoded(deriveKeyPairResp.getPriKey());
}catch(Exception e){
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),e.getMessage());
}
}
//1.2.1调用自然人注册实名(使用NFT平台签名)接口
Nft003RegisterPersonPlatformReqDto nft003ReqDto = Nft003RegisterPersonPlatformReqDto.getNew();
nft003ReqDto.setPersonName(userName);
// reqDto.setEmail("");
nft003ReqDto.setMobile(mobile);
nft003ReqDto.setIdCard(idCard);
nft003ReqDto.setCardType(Integer.valueOf(idCardType));
ZxlnftResponseDto<Nft003RegisterPersonPlatformRespDto> nft003Resp = zxlnftSdkUtil.nft003RegisterPersonPlatform(nft003ReqDto);
if(nft003Resp.isSuccess()){
userIdentification = nft003Resp.getData().getUserIdentification();
}else{
return ResponseDto.failure(nft003Resp.getCode(),nft003Resp.getMessage());
}
GalaxyUserRegisterRespDto respDto = GalaxyUserRegisterRespDto.getNew();
if(StringUtil.isNotEmpty(userPubKey)&&StringUtil.isNotEmpty(userPriKey)&&StringUtil.isNotEmpty(userIdentification)){
//1.2.2调用授信平台NFT地址绑定接口
Nft014IdentityBindSubmitByTrustedReqDto nft014ReqDto = Nft014IdentityBindSubmitByTrustedReqDto.getNew();
try {
nft014ReqDto.setUserPubKey(BASE64Util.decode(userPubKey));
nft014ReqDto.setUserIdentification(nft003Resp.getData().getUserIdentification());
String signature = zxlnftBiz.createSign(BASE64Util.decode(userPriKey),nft014ReqDto.getUserIdentification());
nft014ReqDto.setUserSignData(signature);
} catch (UnsupportedEncodingException e) {
log.error("公私钥解密错误!");
}
ZxlnftResponseDto<Nft014IdentityBindSubmitByTrustedRespDto> nft014Resp = zxlnftSdkUtil.nft014IdentityBindSubmitByTrusted(nft014ReqDto);
ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> nft016Resp = null;
if(nft014Resp.isSuccess()){
//1.2.3调用绑定状态批量查询
Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew();
nft016ReqDto.setAddressList(nft014Resp.getData().getAddress());
nft016Resp = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
}else{
log.info("nft014Resp 返回结果:{}",nft014Resp.toJson());
return ResponseDto.failure(nft014Resp.getCode(),nft014Resp.getMessage());
}
if(StringUtil.isNotNull(nft016Resp)&&nft016Resp.isSuccess()){
List<Nft016QueryRsData> queryRsDataList = nft016Resp.getData().getList();
Nft016QueryRsData queryRsData = queryRsDataList.get(0);
address = queryRsData.getAddress();
log.info("nft016Resp 返回结果:{}",nft016Resp.toJson());
//构造返回参数
respDto.setUserId(userId);
respDto.setBlockChainType(GalaxyConstant.RouterTypeEnum.ZXINCHAIN.getCode());
respDto.setBlockChainAddress(address);
}else{
return ResponseDto.failure(nft016Resp.getMessage());
}
}
return ResponseDto.success(respDto);
}
}
package com.liquidnet.service.galaxy.service.impl;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.GalaxyNftBuyReqDto;
import com.liquidnet.service.galaxy.dto.GalaxyNftBuyRespDto;
import com.liquidnet.service.galaxy.router.strategy.GalaxyRouterStrategyContext;
import com.liquidnet.service.galaxy.service.IGalaxyPublishService;
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: GalaxyPublishServiceImpl
* @Package com.liquidnet.service.galaxy.service.impl
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/3/15 11:28
*/
@Slf4j
@Service
public class GalaxyPublishServiceImpl implements IGalaxyPublishService {
@Autowired
private GalaxyRouterStrategyContext galaxyRouterStrategyContext;
@Override
public ResponseDto<GalaxyNftBuyRespDto> nftBuy(GalaxyNftBuyReqDto reqDto) {
return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).nftBuy(reqDto);
}
}
package com.liquidnet.service.galaxy.service.impl; package com.liquidnet.service.galaxy.service.impl;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum;
import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.dto.nft.Nft016QueryRsData;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.CreateMnemonicResp;
import com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairReq;
import com.liquidnet.common.third.zxlnft.dto.wallet.DeriveKeyPairResp;
import com.liquidnet.common.third.zxlnft.exception.ZxlNftException;
import com.liquidnet.common.third.zxlnft.util.ZxlWalletSdkUtil;
import com.liquidnet.common.third.zxlnft.util.ZxlnftSdkUtil;
import com.liquidnet.commons.lang.util.BASE64Util;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterReqDto; import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterRespDto; import com.liquidnet.service.galaxy.dto.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.router.strategy.GalaxyRouterStrategyContext;
import com.liquidnet.service.galaxy.service.IGalaxyUserService; import com.liquidnet.service.galaxy.service.IGalaxyUserService;
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.Service; import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.util.List;
/** /**
* @author AnJiabin <anjiabin@zhengzai.tv> * @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0 * @version V1.0
...@@ -39,119 +22,10 @@ import java.util.List; ...@@ -39,119 +22,10 @@ import java.util.List;
@Service @Service
public class GalaxyUserServiceImpl implements IGalaxyUserService { public class GalaxyUserServiceImpl implements IGalaxyUserService {
@Autowired @Autowired
private ZxlnftSdkUtil zxlnftSdkUtil; private GalaxyRouterStrategyContext galaxyRouterStrategyContext;
@Autowired
private ZxlWalletSdkUtil zxlWalletSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
@Autowired
private ZxlnftConfig zxlnftConfig;
@Override @Override
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) { public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
String userId = reqDto.getUserId(); return galaxyRouterStrategyContext.getStrategy(reqDto.getRouteType()).userRegister(reqDto);
String userName = reqDto.getUserName();
String mobile = reqDto.getMobile();
String idCardType = reqDto.getIdCardType();
String idCard = reqDto.getIdCard();
String mnemonic = "stuff name goat health siren dumb gorilla antique board tenant buffalo present"; //安家宾
// String mnemonic = "economy cost balance weapon flight also nut biology very sun slight about"; //周焕
Long index = 0L;
String userIdentification = null;
String address = null;
String userPubKey = null;
String userPriKey = null;
try{
//生成助记词
CreateMnemonicReq req = CreateMnemonicReq.getNew();
CreateMnemonicResp createMnemonicResp = zxlWalletSdkUtil.createMnemonic(req);
mnemonic = createMnemonicResp.getMnemonic();
}catch(Exception e){
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"生成助记词失败!");
}
/**
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
if(StringUtil.isNotEmpty(mnemonic)){
//生成公私钥
DeriveKeyPairReq deriveKeyPairReq = DeriveKeyPairReq.getNew();
deriveKeyPairReq.setMnemonic(mnemonic);
// deriveKeyPairReq.setMnemonic(createMnemonicResp.getMnemonic());
deriveKeyPairReq.setIndex(index);
try{
DeriveKeyPairResp deriveKeyPairResp = zxlWalletSdkUtil.deriveKeyPair(deriveKeyPairReq);
if(!deriveKeyPairResp.getErr().equals("")) throw new Exception("生成公私钥失败!");
userPubKey = BASE64Util.encoded(deriveKeyPairResp.getPubKey());
userPriKey = BASE64Util.encoded(deriveKeyPairResp.getPriKey());
}catch(Exception e){
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),e.getMessage());
}
}
//1.2.1调用自然人注册实名(使用NFT平台签名)接口
Nft003RegisterPersonPlatformReqDto nft003ReqDto = Nft003RegisterPersonPlatformReqDto.getNew();
nft003ReqDto.setPersonName(userName);
// reqDto.setEmail("");
nft003ReqDto.setMobile(mobile);
nft003ReqDto.setIdCard(idCard);
nft003ReqDto.setCardType(Integer.valueOf(idCardType));
ZxlnftResponseDto<Nft003RegisterPersonPlatformRespDto> nft003Resp = zxlnftSdkUtil.nft003RegisterPersonPlatform(nft003ReqDto);
if(nft003Resp.isSuccess()){
userIdentification = nft003Resp.getData().getUserIdentification();
}else{
return ResponseDto.failure(nft003Resp.getCode(),nft003Resp.getMessage());
}
GalaxyUserRegisterRespDto respDto = GalaxyUserRegisterRespDto.getNew();
if(StringUtil.isNotEmpty(userPubKey)&&StringUtil.isNotEmpty(userPriKey)&&StringUtil.isNotEmpty(userIdentification)){
//1.2.2调用授信平台NFT地址绑定接口
Nft014IdentityBindSubmitByTrustedReqDto nft014ReqDto = Nft014IdentityBindSubmitByTrustedReqDto.getNew();
try {
nft014ReqDto.setUserPubKey(BASE64Util.decode(userPubKey));
nft014ReqDto.setUserIdentification(nft003Resp.getData().getUserIdentification());
String signature = zxlnftBiz.createSign(BASE64Util.decode(userPriKey),nft014ReqDto.getUserIdentification());
nft014ReqDto.setUserSignData(signature);
} catch (UnsupportedEncodingException e) {
log.error("公私钥解密错误!");
}
ZxlnftResponseDto<Nft014IdentityBindSubmitByTrustedRespDto> nft014Resp = zxlnftSdkUtil.nft014IdentityBindSubmitByTrusted(nft014ReqDto);
ZxlnftResponseDto<Nft016IdentityBindQueryRespDto> nft016Resp = null;
if(nft014Resp.isSuccess()){
//1.2.3调用绑定状态批量查询
Nft016IdentityBindQueryReqDto nft016ReqDto = Nft016IdentityBindQueryReqDto.getNew();
nft016ReqDto.setAddressList(nft014Resp.getData().getAddress());
nft016Resp = zxlnftSdkUtil.nft016IdentityBindQuery(nft016ReqDto);
}else{
log.info("nft014Resp 返回结果:{}",nft014Resp.toJson());
return ResponseDto.failure(nft014Resp.getCode(),nft014Resp.getMessage());
}
if(StringUtil.isNotNull(nft016Resp)&&nft016Resp.isSuccess()){
List<Nft016QueryRsData> queryRsDataList = nft016Resp.getData().getList();
Nft016QueryRsData queryRsData = queryRsDataList.get(0);
address = queryRsData.getAddress();
log.info("nft016Resp 返回结果:{}",nft016Resp.toJson());
//构造返回参数
respDto.setUserId(userId);
respDto.setBlockChainType(GalaxyConstant.RouterEnum.ZXINCHAIN.getCode());
respDto.setBlockChainAddress(address);
}else{
return ResponseDto.failure(nft016Resp.getMessage());
}
}
return ResponseDto.success(respDto);
} }
} }
...@@ -441,7 +441,8 @@ public class TestZxlnftSdkUtil { ...@@ -441,7 +441,8 @@ public class TestZxlnftSdkUtil {
//无限制系列 NOW_ZXL_NFT_PIC_skuId002 //无限制系列 NOW_ZXL_NFT_PIC_skuId002
// reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_b9b105d186742e44691c540bbacddd1c3a883a49d899b81c5b1a5cf10b4ad4e6"); // reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_b9b105d186742e44691c540bbacddd1c3a883a49d899b81c5b1a5cf10b4ad4e6");
//第一个系列 //第一个系列
reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_ca49b5ebadd5f73ab057fe869bf897cbcc0f31e0b89db71cc3ec78bca2d16ed6"); // reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_ca49b5ebadd5f73ab057fe869bf897cbcc0f31e0b89db71cc3ec78bca2d16ed6");
reqDto.setSeriesId("111111");
//第二个系列 //第二个系列
// reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_31ff9f7d4c33c98518e095fec6cecdab8d337751602cf6e651eb7d131cff5b61"); // reqDto.setSeriesId("4e40d5f6f65aa8ec9bc33ab424e0167e68783bbe95d4d265086314d749808eef_31ff9f7d4c33c98518e095fec6cecdab8d337751602cf6e651eb7d131cff5b61");
ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(reqDto); ZxlnftResponseDto<Nft032SeriesRespDto> resp = zxlnftSdkUtil.nft032Series(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