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

Commit 05685b45 authored by anjiabin's avatar anjiabin

nft修改购买逻辑

parent 6c2c48ae
...@@ -257,6 +257,42 @@ public class GalaxyEnum { ...@@ -257,6 +257,42 @@ public class GalaxyEnum {
} }
} }
/**
* 订单处理状态
*/
public enum OrderDealWithStatusEnum{
DATA_INIT("0","数据初始化"),
SUCCESS("1","已处理成功"),
FAIL("2","处理失败"),
NOT_DEAL_WITH("3","不做处理");
private String code;
private String message;
OrderDealWithStatusEnum(String code, String message) {
this.code = code;
this.message = message;
}
public OrderDealWithStatusEnum getEnumByCode(String code){
OrderDealWithStatusEnum[] arry = OrderDealWithStatusEnum.values();
for (int i = 0; i < arry.length; i++) {
if (arry[i].getCode().equals(code)) {
return arry[i];
}
}
return null;
}
public String getCode() {
return code;
}
public String getMessage(){
return message;
}
}
public static void main(String[] args) { public static void main(String[] args) {
Integer aaa = 1; Integer aaa = 1;
......
...@@ -24,7 +24,12 @@ public enum GalaxyErrorEnum { ...@@ -24,7 +24,12 @@ public enum GalaxyErrorEnum {
PUBLISH_ORDER_NOT_EXIST("NFT0010011","NFT购买订单不存在!"), PUBLISH_ORDER_NOT_EXIST("NFT0010011","NFT购买订单不存在!"),
NFT_BUY_TASK_NOT_EXIST("NFT0010012","NFT购买执行任务不存在"), NFT_BUY_TASK_NOT_EXIST("NFT0010012","NFT购买执行任务不存在"),
NFT_BUY_TASK_HAVE_EXIST("NFT0010013","NFT购买执行任务已存在,不可以重复购买!"), NFT_BUY_TASK_HAVE_EXIST("NFT0010013","NFT购买执行任务已存在,不可以重复购买!"),
NFT_BUY_FAIL("NFT0010014","NFT购买失败,nftId不存在!"); NFT_BUY_FAIL("NFT0010014","NFT购买失败,nftId不存在!"),
NFT_BUY_FAIL_USER_NOT_EXIST("NFT0010015","NFT购买失败,用户信息不存在!"),
NFT_BUY_FAIL_SERIES_NFT_NOT_EXIST("NFT0010016","NFT购买失败,系列NFT信息不存在!"),
NFT_PUBLISH_ERROR("NFT0010017","NFT发行异常!"),
NFT_BUY_ERROR("NFT0010018","NFT购买异常!");
private String code; private String code;
private String message; private String message;
......
package com.liquidnet.service.galaxy.exception;
import lombok.Data;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 自定义异常类
* @class: ZxlNftException
* @Package com.liquidnet.common.third.zxlnft.exception
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 13:44
*/
@Data
public class GalaxyNftBuyException extends RuntimeException{
private static final long serialVersionUID = -3916918823313768482L;
private String code;
private String message;
public GalaxyNftBuyException(String code, String message) {
super(message);
this.code = code;
this.message = message;
}
public GalaxyNftBuyException(String code, String message, Throwable t) {
super(message, t);
this.code = code;
this.message = message;
}
}
...@@ -15,18 +15,18 @@ import lombok.Data; ...@@ -15,18 +15,18 @@ import lombok.Data;
public class GalaxyNftException extends RuntimeException{ public class GalaxyNftException extends RuntimeException{
private static final long serialVersionUID = -3916918823313768482L; private static final long serialVersionUID = -3916918823313768482L;
private String code; private String code;
private String msg; private String message;
public GalaxyNftException(String code, String msg) { public GalaxyNftException(String code, String message) {
super(msg); super(message);
this.code = code; this.code = code;
this.msg = msg; this.message = message;
} }
public GalaxyNftException(String code, String msg, Throwable t) { public GalaxyNftException(String code, String message, Throwable t) {
super(msg, t); super(message, t);
this.code = code; this.code = code;
this.msg = msg; this.message = message;
} }
} }
package com.liquidnet.service.galaxy.exception;
import lombok.Data;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 自定义异常类
* @class: ZxlNftException
* @Package com.liquidnet.common.third.zxlnft.exception
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/2/21 13:44
*/
@Data
public class GalaxyNftPublishException extends RuntimeException{
private static final long serialVersionUID = -3916918823313768482L;
private String code;
private String message;
public GalaxyNftPublishException(String code, String message) {
super(message);
this.code = code;
this.message = message;
}
public GalaxyNftPublishException(String code, String message, Throwable t) {
super(message, t);
this.code = code;
this.message = message;
}
}
package com.liquidnet.service.consumer.kylin.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.galaxy.utils.AbstractDataUtils;
import com.liquidnet.service.galaxy.utils.QueueUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DataUtils extends AbstractDataUtils {
@Autowired
private RedisUtil redisUtil;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private QueueUtil queueUtil;
private long keyExpireTime = 3600*24*30;
@Override
public RedisUtil getRedisUtil() {
return redisUtil;
}
@Override
public MongoTemplate getMongoTemplate() {
return mongoTemplate;
}
@Override
public com.liquidnet.service.galaxy.utils.QueueUtil getQueueUtil() {
return queueUtil;
}
}
package com.liquidnet.service.galaxy.biz; package com.liquidnet.service.galaxy.biz;
import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig; import com.liquidnet.common.third.zxlnft.config.ZxlnftConfig;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.galaxy.constant.GalaxyEnum; import com.liquidnet.service.galaxy.constant.GalaxyEnum;
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.GalaxySeriesNftInfoBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo; import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo;
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;
...@@ -54,4 +57,42 @@ public class GalaxyBeanTransferBiz { ...@@ -54,4 +57,42 @@ public class GalaxyBeanTransferBiz {
nftOrderBo.setUpdatedAt(null); nftOrderBo.setUpdatedAt(null);
return nftOrderBo; return nftOrderBo;
} }
/**
*
* @param reqDto
* @param userInfoBo
* @param seriesNftInfoBo
* @return
*/
public GalaxyNftOrderFailLogVo buildNftOrderFailLogVo(GalaxyEnum.TradeTypeEnum tradeTypeEnum,GalaxyNftPublishAndBuyReqDto reqDto
,GalaxyEnum.OrderDealWithStatusEnum orderDealWithStatus,String failDesc,String failDescSecond,GalaxyUserInfoBo userInfoBo, GalaxySeriesNftInfoBo seriesNftInfoBo, GalaxyNftOrderBo nftOrderBo){
GalaxyNftOrderFailLogVo nftOrderFailLogVo = GalaxyNftOrderFailLogVo.getNew();
nftOrderFailLogVo.setNftOrderPayId(reqDto.getNftOrderPayId());
if(StringUtil.isNotNull(seriesNftInfoBo)){
nftOrderFailLogVo.setUserId(seriesNftInfoBo.getSkuId());
nftOrderFailLogVo.setNftName(seriesNftInfoBo.getNftName());
nftOrderFailLogVo.setSeriesName(seriesNftInfoBo.getSeriesName());
nftOrderFailLogVo.setSeriesId(seriesNftInfoBo.getSeriesId());
nftOrderFailLogVo.setSeriesCode(seriesNftInfoBo.getSeriesCode());
}
if(StringUtil.isNotNull(nftOrderBo)){
nftOrderFailLogVo.setNftId(nftOrderBo.getNftId());
if(tradeTypeEnum.getCode().equalsIgnoreCase(GalaxyEnum.TradeTypeEnum.TRADE_PUBLISH.getCode())){
nftOrderFailLogVo.setTaskId(nftOrderBo.getNftPublishTaskId());
}else if(tradeTypeEnum.getCode().equalsIgnoreCase(GalaxyEnum.TradeTypeEnum.TRADE_BUY.getCode())){
nftOrderFailLogVo.setTaskId(nftOrderBo.getNftBuyTaskId());
}
}
nftOrderFailLogVo.setFailReasonDesc(failDesc);
nftOrderFailLogVo.setFailReasonDescSecond(failDescSecond);
nftOrderFailLogVo.setDealWithStatus(orderDealWithStatus.getCode());
nftOrderFailLogVo.setTradeType(tradeTypeEnum.getCode());
nftOrderFailLogVo.setRouterType(reqDto.getRouterType());
nftOrderFailLogVo.setCreatedAt(LocalDateTime.now());
nftOrderFailLogVo.setUpdatedAt(null);
return nftOrderFailLogVo;
}
} }
...@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component; ...@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
@Slf4j @Slf4j
@Component @Component
public class DataUtils extends AbstractDataUtils{ public class GalaxyDataUtils extends AbstractDataUtils{
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
......
...@@ -6,6 +6,7 @@ db.createCollection("GalaxySeriesNftInfoVo"); ...@@ -6,6 +6,7 @@ db.createCollection("GalaxySeriesNftInfoVo");
db.createCollection("GalaxySeriesNftUploadVo"); db.createCollection("GalaxySeriesNftUploadVo");
db.createCollection("GalaxyNftOrderVo"); db.createCollection("GalaxyNftOrderVo");
db.createCollection("GalaxyNftOrderBindVo"); db.createCollection("GalaxyNftOrderBindVo");
db.createCollection("GalaxyNftOrderFailLogVo");
db.createCollection("GalaxyNftTradeVo"); db.createCollection("GalaxyNftTradeVo");
...@@ -16,6 +17,7 @@ db.GalaxySeriesNftInfoVo.createIndex({skuId:"hashed"}); ...@@ -16,6 +17,7 @@ db.GalaxySeriesNftInfoVo.createIndex({skuId:"hashed"});
db.GalaxySeriesNftUploadVo.createIndex({skuId:"hashed"}); db.GalaxySeriesNftUploadVo.createIndex({skuId:"hashed"});
db.GalaxyNftOrderVo.createIndex({nftOrderPayId:"hashed"}); db.GalaxyNftOrderVo.createIndex({nftOrderPayId:"hashed"});
db.GalaxyNftOrderBindVo.createIndex({nftOrderPayId:"hashed"}); db.GalaxyNftOrderBindVo.createIndex({nftOrderPayId:"hashed"});
db.GalaxyNftOrderFailLogVo.createIndex({nftOrderPayId:"hashed"});
db.GalaxyNftTradeVo.createIndex({nftId:"hashed"}); db.GalaxyNftTradeVo.createIndex({nftId:"hashed"});
#创建分片 #创建分片
......
...@@ -139,7 +139,7 @@ create table galaxy_nft_order_fail_log ...@@ -139,7 +139,7 @@ create table galaxy_nft_order_fail_log
fail_reason_desc_second varchar(20) COMMENT '失败原因2', fail_reason_desc_second varchar(20) COMMENT '失败原因2',
trade_type varchar(3) COMMENT '交易类别 1发行 2购买 3转移 4设置价格 5设置状态', trade_type varchar(3) COMMENT '交易类别 1发行 2购买 3转移 4设置价格 5设置状态',
router_type varchar(20) NOT NULL COMMENT '路由类型(zxinchain、eth、antchain)', router_type varchar(20) NOT NULL COMMENT '路由类型(zxinchain、eth、antchain)',
deal_with_status varchar(3) COMMENT '处理状态 1未处理 2已处理 3再次失败 4不做处理', deal_with_status varchar(3) COMMENT '处理状态 0数据初始化 1已处理成功 2处理失败 3不做处理',
created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', updated_at timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`mid`) PRIMARY KEY (`mid`)
......
...@@ -24,7 +24,7 @@ import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo; ...@@ -24,7 +24,7 @@ import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesInfoBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo; import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftUploadBo; import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftUploadBo;
import com.liquidnet.service.galaxy.dto.param.*; import com.liquidnet.service.galaxy.dto.param.*;
import com.liquidnet.service.galaxy.utils.DataUtils; 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;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -59,7 +59,7 @@ public class ZxinArtworkBiz { ...@@ -59,7 +59,7 @@ public class ZxinArtworkBiz {
private ZxlnftConfig zxlnftConfig; private ZxlnftConfig zxlnftConfig;
@Autowired @Autowired
private DataUtils dataUtils; private GalaxyDataUtils dataUtils;
@Autowired @Autowired
private GalaxyCommonBiz galaxyCommonBiz; private GalaxyCommonBiz galaxyCommonBiz;
......
...@@ -20,7 +20,7 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto; ...@@ -20,7 +20,7 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto; import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryReqDto; import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryRespDto; import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishResultQueryRespDto;
import com.liquidnet.service.galaxy.utils.DataUtils; 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;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -45,7 +45,7 @@ public class ZxinPublishBiz { ...@@ -45,7 +45,7 @@ public class ZxinPublishBiz {
private ZxlnftSdkUtil zxlnftSdkUtil; private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired @Autowired
private DataUtils dataUtils; private GalaxyDataUtils dataUtils;
@Autowired @Autowired
private GalaxyBeanTransferBiz galaxyBeanTransferBiz; private GalaxyBeanTransferBiz galaxyBeanTransferBiz;
......
...@@ -21,7 +21,7 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto; ...@@ -21,7 +21,7 @@ import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto; import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto;
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.utils.DataUtils; 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;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -51,7 +51,7 @@ public class ZxinUserBiz { ...@@ -51,7 +51,7 @@ public class ZxinUserBiz {
private ZxlnftBiz zxlnftBiz; private ZxlnftBiz zxlnftBiz;
@Autowired @Autowired
private DataUtils dataUtils; private GalaxyDataUtils dataUtils;
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) { public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
String userId = reqDto.getUserId(); String userId = reqDto.getUserId();
......
package com.liquidnet.service.galaxy.router.zxin.service; package com.liquidnet.service.galaxy.router.zxin.service;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.constant.GalaxyEnum; import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.param.*; import com.liquidnet.service.galaxy.dto.param.*;
import com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyTrade; import com.liquidnet.service.galaxy.router.strategy.IGalaxyRouterStrategyTrade;
...@@ -34,9 +32,10 @@ public class GalaxyRouterStrategyZxlTradeImpl implements IGalaxyRouterStrategyTr ...@@ -34,9 +32,10 @@ public class GalaxyRouterStrategyZxlTradeImpl implements IGalaxyRouterStrategyTr
@Override @Override
public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) { public ResponseDto<GalaxyNftPublishAndBuyRespDto> nftPublishAndBuy(GalaxyNftPublishAndBuyReqDto reqDto) {
queueUtil.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey(), JsonUtils.toJson(reqDto)); //测试发送队列
return ResponseDto.success(); // queueUtil.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey(), JsonUtils.toJson(reqDto));
// return zxinTradeBiz.nftPublishAndBuy(reqDto); // return ResponseDto.success();
return zxinTradeBiz.nftPublishAndBuy(reqDto);
} }
@Override @Override
......
...@@ -6,7 +6,8 @@ liquidnet: ...@@ -6,7 +6,8 @@ liquidnet:
username: user username: user
password: user123 password: user123
eureka: eureka:
host: 39.107.71.112:7001 # host: 39.107.71.112:7001
host: 127.0.0.1:7001
# end-dev-这里是配置信息基本值 # end-dev-这里是配置信息基本值
spring: spring:
......
...@@ -4,7 +4,7 @@ import com.liquidnet.common.cache.redis.util.RedisUtil; ...@@ -4,7 +4,7 @@ import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.galaxy.constant.GalaxyConstant; import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.constant.GalaxyEnum; import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo; import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.utils.DataUtils; import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -34,7 +34,7 @@ public class TestRedisUtil { ...@@ -34,7 +34,7 @@ public class TestRedisUtil {
private long keyExpireTime = 3600*24*30; private long keyExpireTime = 3600*24*30;
@Autowired @Autowired
private DataUtils dataUtils; private GalaxyDataUtils dataUtils;
@Test @Test
......
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