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

Commit b6a90a1e authored by zhanggb's avatar zhanggb

Merge remote-tracking branch 'origin/jxl_0512_nft_acc' into pre

# Conflicts:
#	liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
parents e0ebe06e ebbdb186
......@@ -15,4 +15,6 @@ public interface IAdamRealNameService {
void add(AdamRealName realName);
void upsert(AdamRealName realName, boolean updateFlg);
void update(AdamRealName realName, String mobile);
}
......@@ -70,4 +70,6 @@ public interface IAdamUserService {
AdamRealInfoVo identity(String uid, String name, String idCard, String mobile);
AdamRealInfoVo identityForUpsert(String uid, String name, String idCard, String mobile, boolean updateFlg);
AdamRealInfoVo identityForUpdate(String uid, String mobile, int idType, int node, String idCard, String idName);
}
......@@ -11,6 +11,7 @@ package com.liquidnet.service.galaxy.constant;
*/
public class GalaxyConstant {
//可删除key
public static final String REDIS_KEY_GALAXY_USER_ID_CARD="galaxy:user_id_card:";
public static final String REDIS_KEY_GALAXY_USER="galaxy:user:";
public static final String REDIS_KEY_GALAXY_SERIES="galaxy:series:";
public static final String REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD="galaxy:series:nft:upload:";
......@@ -21,7 +22,8 @@ public class GalaxyConstant {
//以下禁止删除
public static final String REDIS_KEY_GALAXY_PUBLISH_NFT="galaxy:publish:nft:"; //nft索引递增记录
public static final String SERIES_NAME_PREFIX="NOW_ZXL_";// 系列存储目录名称和系列声明
public static final String ADAM_USER_SYNC_URL="/adam/rsc/syn/certmeta";// adam用户开通数字账户信息同步url
public static final String SERIES_NAME_PREFIX="NOW_ZXL_";// 系列存储目录名称和系列声明
}
......@@ -32,7 +32,8 @@ public enum GalaxyErrorEnum {
NFT_PUBLISH_AND_BUY_QUERY_FAIL("NFT0010019","NFT发行和购买结果查询失败!"),
NFT_QUERY_FAIL_ORDER_NOT_EXIST("NFT0010020","NFT订单不存在!"),
NFT_QUERY_FAIL_NFT_NOT_EXIST("NFT0010021","NFT信息查询不存在!"),
NFT_QUERY_FAIL_SERIES_NOT_EXIST("NFT0010022","系列信息查询不存在!");
NFT_QUERY_FAIL_SERIES_NOT_EXIST("NFT0010022","系列信息查询不存在!"),
NFT_USER_HAS_OPEN_ACCOUNT("NFT0010023","用户已经开通过数字账户!");
private String code;
......
package com.liquidnet.service.galaxy.exception;
import lombok.Data;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 自定义异常类
* @class: GalaxyNftUserException
* @Package com.liquidnet.service.galaxy.exception
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/5/12 13:44
*/
@Data
public class GalaxyNftUserException extends RuntimeException{
private static final long serialVersionUID = -3916918823313768482L;
private String code;
private String message;
public GalaxyNftUserException(String code, String message) {
super(message);
this.code = code;
this.message = message;
}
public GalaxyNftUserException(String code, String message, Throwable t) {
super(message, t);
this.code = code;
this.message = message;
}
}
......@@ -133,6 +133,12 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_NFT_GOODS_LIST = PREFIX.concat("nft:goodsList");// nft商品列表
public static final String REDIS_GOBLIN_NFT_GOODS_LIST_INFO = PREFIX.concat("nft:goodsList:info:");// nft商品列表单藏品详情 skuId
public static final String REDIS_GOBLIN_NFT_NUM_ACCOUNT = PREFIX.concat("nft:account:");// nft用户数字账户是否开通 userId
public static final String REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO = PREFIX.concat("nft:account:info:");// nft用户数字账户开通信息 userId
/**
* {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
*/
public static final String REDIS_GOBLIN_NFT_CERTMETA = PREFIX.concat("nft:certmeta:");
public static final String REDIS_GOBLIN_NFT_CERTMETA_JUNK = PREFIX.concat("nft:certmeta_junk:");
......
package com.liquidnet.service.goblin.constant;
public class NftAccStatusEnum {
/**
* 数字账户开通状态
*/
public enum StatusAcc {
ING("1000", "开通中"),
SUCCESS("2000", "开通成功"),
FAILURE1("3000", "实名失败"),
FAILURE2("3001", "开通失败可重试"),
FAILURE3("3002", "该身份证已开通数字账号 不可重复操作"),
;
private final String code;
private final String msg;
StatusAcc(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
}
package com.liquidnet.service.goblin.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@ApiModel(value = "GoblinUserNftAccInfoVo", description = "数字账户开通信息")
@Data
public class GoblinUserNftAccInfoVo implements Serializable, Cloneable {
private static final long serialVersionUID = 9036417838200526658L;
@ApiModelProperty(position = 11, value = "状态码 1000开通中 2000开通成功 3000实名失败 3001开通失败可重试 3002该身份证已开通数字账号 不可重复操作")
private String code;
@ApiModelProperty(position = 12, value = "提示信息")
private String msg;
@ApiModelProperty(position = 13, value = "最后操作的时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DateUtil.DATE_FULL_STR)
private LocalDateTime time;
private static final GoblinUserNftAccInfoVo obj = new GoblinUserNftAccInfoVo();
public static GoblinUserNftAccInfoVo getNew() {
try {
return (GoblinUserNftAccInfoVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinUserNftAccInfoVo();
}
}
}
package com.liquidnet.service.goblin.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
public interface IGoblinNftUserService {
......@@ -12,7 +13,7 @@ public interface IGoblinNftUserService {
* @param name 证件名
* @param idCard 证件号
* @param mobile 手机号
* @return Integer[1-成功]
* @return ResponseDto<GoblinUserNftAccInfoVo>
*/
ResponseDto<Integer> openNftAccount(String uid, String bizCode, String name, String idCard, String mobile);
ResponseDto<GoblinUserNftAccInfoVo> openNftAccount(String uid, String bizCode, String name, String idCard, String mobile);
}
......@@ -328,8 +328,8 @@ public class MQConst {
SQL_NFT_ORDER_INFO("galaxy:stream:rk.sql.nftOrderInfo", "group.sql.nftOrderInfo", "订单信息"),
SQL_NFT_TRADE_INFO("galaxy:stream:rk.sql.nftTradeInfo", "group.sql.nftTradeInfo", "交易信息"),
SQL_NFT_ORDER_FAIL_LOG("galaxy:stream:rk.sql.nftOrderFailLog", "group.sql.nftOrderFailLog", "交易发行购买失败记录"),
JSON_NFT_PUBLISH_AND_BUY("galaxy:stream:rk.json.nftPublishAndBuy", "group.sql.nftPublishAndBuy", "NFT发行和购买"),
;
JSON_NFT_PUBLISH_AND_BUY("galaxy:stream:rk.json.nftPublishAndBuy", "group.json.nftPublishAndBuy", "NFT发行和购买"),
JSON_NFT_USER_REGISTER("galaxy:stream:rk.json.userRegister", "group.json.userRegister", "NFT用户注册");
private final String key;
private final String group;
private final String desc;
......
......@@ -2,6 +2,8 @@ package com.liquidnet.service.adam.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.DESUtils;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.adam.dto.rsc.AdamChimeUinfoDto;
import com.liquidnet.service.adam.dto.rsc.AdamChimeUinfoReq;
import com.liquidnet.service.adam.dto.vo.*;
......@@ -172,4 +174,31 @@ public class AdamRscController {
}
return ResponseDto.success(true);
}
@ApiOperationSupport(order = 50)
@ApiOperation(value = "@API:NFT三要素", notes = "用于NFT认证成功的用户同步更新用户账号实名信息")
@PostMapping(value = {"syn/certmeta"})
public void syncUpdateReal(@NotBlank @RequestBody String certmeta) {
try {
String certmetaPlain = DESUtils.DES().decrypt(certmeta);// {uid},{mobile},{证件类型}{证件号},{姓名}
log.info("NFT三要素同步实名信息:加解密信息[{} => {}]", certmeta, certmetaPlain);
String[] certmetaPlainArr = certmetaPlain.split(",");
String uid = certmetaPlainArr[0], mobile = certmetaPlainArr[1], idTypeCardNo = certmetaPlainArr[2];
String uidByMobile = adamRdmService.getUidByMobile(mobile);
if (org.apache.commons.lang3.StringUtils.isEmpty(uidByMobile) || !org.apache.commons.lang3.StringUtils.equals(uidByMobile, uid)) {
log.warn("NFT三要素同步实名信息:手机号未注册/不匹配[{}]", certmetaPlain);
return;
}
AdamRealInfoVo realInfoVoByUidPlain = adamRdmService.getRealInfoVoByUidPlain(uid);
if (null == realInfoVoByUidPlain || realInfoVoByUidPlain.getNode() == 2) {
int idType = Integer.parseInt(idTypeCardNo.substring(0, 1));
adamUserService.identityForUpdate(uid, mobile, idType, 3, idTypeCardNo.substring(1), certmetaPlainArr[3]);
} else {
log.warn("NFT三要素同步实名信息:三要素信息已存在[certmetaPlain={},realInfoVoByUidPlain={}]", certmetaPlain, JsonUtils.toJson(realInfoVoByUidPlain));
}
} catch (Exception e) {
log.warn("NFT三要素同步实名信息:参数解析失败[certmeta={}]", certmeta, e);
}
}
}
......@@ -119,4 +119,43 @@ public class AdamRealNameServiceImpl implements IAdamRealNameService {
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
public void update(AdamRealName realName, String mobile) {
List<Object> paramList = Arrays.asList(
realName.getRealNameId(),
realName.getUid(),
realName.getType(),
realName.getNode(),
realName.getName(),
realName.getIdCard(),
realName.getState(),
realName.getCreatedAt()
);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserRealInfoObjs = CollectionUtil.linkedListObjectArr(),
delUserRealInfoObjs = CollectionUtil.linkedListObjectArr(),
updateUserMobileLocateObjs = CollectionUtil.linkedListObjectArr();
toMqSqls.add(SqlMapping.get("adam_real_name.del_by_nft"));
delUserRealInfoObjs.add(new Object[]{realName.getCreatedAt(), realName.getUid()});
toMqSqls.add(SqlMapping.get("adam_real_name.add"));
initUserRealInfoObjs.add(paramList.toArray());
String[] mobileLocateArr = adamRdmService.getMobileLocateArr(mobile);
toMqSqls.add(SqlMapping.get("adam_user_mobile_locate.real_name"));
if (null != mobileLocateArr && mobileLocateArr.length > 0) {
updateUserMobileLocateObjs.add(new Object[]{
realName.getName(), realName.getIdCard(), realName.getCreatedAt(), realName.getUid()
});
}
long s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(
MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.gets(toMqSqls, delUserRealInfoObjs, initUserRealInfoObjs, updateUserMobileLocateObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
}
......@@ -476,4 +476,25 @@ public class AdamUserServiceImpl implements IAdamUserService {
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
return vo;
}
@Override
public AdamRealInfoVo identityForUpdate(String uid, String mobile, int idType, int node, String idCard, String idName) {
AdamRealName realName = new AdamRealName();
realName.setRealNameId(IDGenerator.nextSnowId() + "");
realName.setUid(uid);
realName.setType(idType);
realName.setNode(node);
realName.setName(idName);
realName.setIdCard(idCard);
realName.setState(1);
realName.setCreatedAt(LocalDateTime.now());
adamRealNameService.update(realName, mobile);
AdamRealInfoVo vo = AdamRealInfoVo.getNew().copy(realName);
long s = System.currentTimeMillis();
adamRdmService.setRealInfoVoByUid(uid, vo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
return vo;
}
}
......@@ -12,7 +12,8 @@ adam_user_info.update_qr_code=UPDATE adam_user_info SET qr_code=? WHERE uid=?
# ----------------------------------------------------
adam_real_name.add=INSERT INTO adam_real_name (real_name_id,`uid`,`type`,`node`,`name`,id_card,`state`,created_at) VALUES (?,?,?,?,?,?,?,?)
adam_real_name.del=UPDATE adam_real_name SET `state`=2, updated_at=?, comment='三要素认证覆盖' WHERE `uid`=? and `state`=1 and node=2
adam_real_name.del=UPDATE adam_real_name SET `state`=2, updated_at=?, comment='\u4E09\u8981\u7D20\u8BA4\u8BC1\u8986\u76D6' WHERE `uid`=? and `state`=1 and node=2
adam_real_name.del_by_nft=UPDATE adam_real_name SET `state`=2, updated_at=?, comment='\u4E09\u8981\u7D20\u8BA4\u8BC1\u8986\u76D6NFT' WHERE `uid`=? and `state`=1
adam_real_name.close=UPDATE adam_real_name SET `state`=2, updated_at=?, comment='close' WHERE `uid`=?
# ----------------------------------------------------
......
package com.liquidnet.service.consumer.kylin.receiver;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.kylin.service.processor.ConsumerGalaxyJsonNftUserRegisterProcessor;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterReceiver extends AbstractBizRedisReceiver {
@Autowired
private ConsumerGalaxyJsonNftUserRegisterProcessor jsonNftUserRegisterProcessor;
@Override
protected boolean consumerMessageHandler(String msg) {
boolean aBoolean = false;
try {
GalaxyUserRegisterReqDto textMessage = JsonUtils.fromJson(msg, GalaxyUserRegisterReqDto.class);
if (textMessage == null) {
aBoolean = true;
} else {
//执行计数
ResponseDto<GalaxyUserRegisterRespDto> responseDto = jsonNftUserRegisterProcessor.userRegister(textMessage);
// if(responseDto.isSuccess()){
aBoolean = true;
// }
}
} catch (Exception e) {
log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
} finally {
if (!aBoolean) {
HashMap<String, String> map = CollectionUtil.mapStringString();
map.put("message", msg);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
}
}
return aBoolean;
}
@Override
protected String getRedisStreamKey() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getGroup();
}
}
package com.liquidnet.service.consumer.kylin.service.processor;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerJsonNftPublishAndBuyProcessor
* @Package com.liquidnet.service.consumer.kylin.service.processor
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/29 17:04
*/
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterProcessor {
@Autowired
private ZxinUserCommonBiz zxinUserCommonBiz;
/**
* 执行用户注册
* @param reqDto
* @return
*/
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserCommonBiz.userRegister(reqDto);
}
}
package com.liquidnet.service.consumer.nft.config;
import com.liquidnet.common.cache.redis.config.RedisStreamConfig;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.nft.receiver.ConsumerGalaxyJsonNftUserRegisterReceiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.stream.Consumer;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.stream.StreamMessageListenerContainer;
import org.springframework.data.redis.stream.Subscription;
import java.util.ArrayList;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: 区块链nft订单相关
* @class: ConsumerSqlNftOrderInfoConfig
* @Package com.liquidnet.service.consumer.galaxy.config
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/25 14:45
*/
@Configuration
public class ConsumerGalaxyJsonNftUserRegisterConfig extends RedisStreamConfig {
@Autowired
private ConsumerGalaxyJsonNftUserRegisterReceiver jsonNftUserRegisterReceiver;
@Autowired
StringRedisTemplate stringRedisTemplate;
@Bean
public List<Subscription> subscriptionJsonNftUserRegister(RedisConnectionFactory factory) {
List<Subscription> subscriptionList = new ArrayList<>();
MQConst.GalaxyQueue stream = MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER;
this.initStream(stringRedisTemplate, stream.getKey(), stream.getGroup());
for (int i = 0; i < 10; i++) {
StreamMessageListenerContainer<String, MapRecord<String, String, String>> listenerContainer = this.buildStreamMessageListenerContainer(factory);
subscriptionList.add(listenerContainer.receiveAutoAck(
Consumer.from(stream.getGroup(), getConsumerName(stream.name() + i)),
StreamOffset.create(stream.getKey(), ReadOffset.lastConsumed()), jsonNftUserRegisterReceiver
));
listenerContainer.start();
}
return subscriptionList;
}
}
package com.liquidnet.service.consumer.nft.receiver;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.consumer.nft.service.processor.ConsumerGalaxyJsonNftUserRegisterProcessor;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterReceiver extends AbstractBizRedisReceiver {
@Autowired
private ConsumerGalaxyJsonNftUserRegisterProcessor jsonNftUserRegisterProcessor;
@Override
protected boolean consumerMessageHandler(String msg) {
boolean aBoolean = false;
try {
GalaxyUserRegisterReqDto textMessage = JsonUtils.fromJson(msg, GalaxyUserRegisterReqDto.class);
if (textMessage == null) {
aBoolean = true;
} else {
//执行计数
ResponseDto<GalaxyUserRegisterRespDto> responseDto = jsonNftUserRegisterProcessor.userRegister(textMessage);
// if(responseDto.isSuccess()){
aBoolean = true;
// }
}
} catch (Exception e) {
log.error("CONSUMER MSG EX_HANDLE ==> [{}]:{}", this.getRedisStreamKey(), msg, e);
} finally {
if (!aBoolean) {
HashMap<String, String> map = CollectionUtil.mapStringString();
map.put("message", msg);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(this.getRedisStreamKey()));
}
}
return aBoolean;
}
@Override
protected String getRedisStreamKey() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getKey();
}
@Override
protected String getRedisStreamGroup() {
return MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getGroup();
}
}
package com.liquidnet.service.consumer.nft.service.processor;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinUserCommonBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ConsumerJsonNftPublishAndBuyProcessor
* @Package com.liquidnet.service.consumer.kylin.service.processor
* @Copyright: LightNet @ Copyright (c) 2022
* @date 2022/3/29 17:04
*/
@Slf4j
@Component
public class ConsumerGalaxyJsonNftUserRegisterProcessor {
@Autowired
private ZxinUserCommonBiz zxinUserCommonBiz;
/**
* 执行用户注册
* @param reqDto
* @return
*/
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserCommonBiz.userRegister(reqDto);
}
}
......@@ -31,5 +31,15 @@
<artifactId>liquidnet-service-galaxy-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-goblin-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-service-adam-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package com.liquidnet.service.galaxy.router.zxin.biz;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
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.*;
import com.liquidnet.service.adam.constant.AdamEnum;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.exception.GalaxyNftUserException;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @version V1.0
* @Description: TODO
* @class: ZxinUserCommonBiz
* @Package com.liquidnet.service.galaxy.router.zxin.biz
* @Copyright: LightNet @ Copyright (c) 2021
* @date 2022/5/12 13:08
*/
@Slf4j
@Component
public class ZxinUserCommonBiz {
@Autowired
private ZxlnftSdkUtil zxlnftSdkUtil;
@Autowired
private ZxlnftBiz zxlnftBiz;
@Autowired
private GalaxyDataUtils dataUtils;
@Autowired
private ZxlWalletSdkUtil zxlWalletSdkUtil;
@Value("${liquidnet.service.adam.url}")
private String adamUrl;
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
long startTime = System.currentTimeMillis();
String userId = reqDto.getUserId();
String userName = reqDto.getUserName();
String mobile = reqDto.getMobile();
String idCardType = reqDto.getIdCardType();
String idCard = reqDto.getIdCard();
String mnemonic = null;
Long index = 0L;
String userIdentification = null;
String address = null;
String userPubKey = null;
String userPriKey = null;
//业务失败信息
String bizFailDesc = null;
//系统失败信息
String sysFailDesc = null;
//是否实名认证成功
boolean isRealNameAuthSuccess = false;
//是否绑定区块链地址
boolean isBindBlockAddressSuccess = false;
GalaxyUserRegisterRespDto respDto = GalaxyUserRegisterRespDto.getNew();
//用户信息
GalaxyUserInfoBo userInfoBo = null;
try{
/**
* todo 把助记词进行redis存储 key=userID mnemonic/index/userIdentification/address
*/
userInfoBo = dataUtils.getGalaxyUserInfo(reqDto.getRouterType(),userId);
if(userInfoBo!=null){
mnemonic = userInfoBo.getMnemonic();
if(StringUtil.isNotEmpty(userInfoBo.getBlockChainAddress())){
try{
//同步用户数字账户开通信息
boolean isOpenAccount = syncOpenAccount(reqDto,respDto.getBlockChainAddress(),bizFailDesc,sysFailDesc,true,true);
log.info("用户 {} 数字账户开通结果:{}",reqDto.getUserId(),isOpenAccount);
}catch(Exception e){
log.error("同步用户数字账户开通信息异常:"+e.getMessage(),e);
}
return ResponseDto.failure("已经开通过数字账户");
}
}else{
try{
//生成助记词
CreateMnemonicReq req = CreateMnemonicReq.getNew();
CreateMnemonicResp createMnemonicResp = zxlWalletSdkUtil.createMnemonic(req);
mnemonic = createMnemonicResp.getMnemonic();
}catch(Exception e){
log.error("生成助记词失败 msg:{}",e.getMessage(),e);
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"生成助记词失败!");
}
}
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){
log.error("生成公私钥失败 msg:{}",e.getMessage(),e);
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),e.getMessage());
}
}
if(StringUtil.isNull(userInfoBo)){
//初始化用户信息
try{
//构造缓存数据
userInfoBo = GalaxyUserInfoBo.getNew();
userInfoBo.setUserId(userId);
userInfoBo.setUserName(userName);
userInfoBo.setMobile(mobile);
userInfoBo.setIdCardType(idCardType);
userInfoBo.setIdCard(idCard);
userInfoBo.setMnemonic(mnemonic);
userInfoBo.setIndex(index.toString());
userInfoBo.setUserIdentification(userIdentification);
userInfoBo.setUserPubKey(userPubKey);
userInfoBo.setUserPriKey(userPriKey);
userInfoBo.setRouterType(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
userInfoBo.setBlockChainAddress(address);
dataUtils.setGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId(),userInfoBo);
}catch(Exception e){
log.error("设置用户信息异常 msg:{}",e.getMessage(),e);
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),"设置用户信息异常");
}
}
//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();
isRealNameAuthSuccess = true;
}else{
throw new GalaxyNftUserException(nft003Resp.getCode(),nft003Resp.getMessage());
}
//如果实名认证成功,并且该身份证已经开通过数字账户
if(isRealNameAuthSuccess){
String blockAddress = dataUtils.getGalaxyUserInfoByIdCardNo(reqDto.getRouterType(),idCard);
if(StringUtil.isNotEmpty(blockAddress)){
throw new GalaxyNftUserException(GalaxyErrorEnum.NFT_USER_HAS_OPEN_ACCOUNT.getCode(),GalaxyErrorEnum.NFT_USER_HAS_OPEN_ACCOUNT.getMessage());
}
}
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("公私钥解密错误!");
throw new ZxlNftException(ZxlErrorEnum.FAILURE.getCode(),e.getMessage());
}
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());
throw new GalaxyNftUserException(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(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
respDto.setBlockChainAddress(address);
isBindBlockAddressSuccess = true;
userInfoBo.setBlockChainAddress(address);
//设置
dataUtils.setGalaxyUserInfoByIdCardNo(reqDto.getRouterType(),idCard,address);
}else{
throw new GalaxyNftUserException(nft016Resp.getCode(),nft016Resp.getMessage());
}
}
}catch (GalaxyNftUserException e) {
bizFailDesc = e.getMessage();
log.info(e.getMessage());
}catch(ZxlNftException e){
sysFailDesc = e.getMessage();
log.error(e.getMessage(),e);
}catch(Exception e){
sysFailDesc = e.getMessage();
log.error(e.getMessage(),e);
}
//如果实名认证成功-更新数据库
if(isRealNameAuthSuccess){
if(StringUtil.isNotNull(userInfoBo)){
userInfoBo.setUserName(userName);
userInfoBo.setMobile(mobile);
userInfoBo.setIdCardType(idCardType);
userInfoBo.setIdCard(idCard);
userInfoBo.setUserIdentification(userIdentification);
dataUtils.updateGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId(),userInfoBo);
}
}
try{
//同步用户数字账户开通信息
boolean isOpenAccount = syncOpenAccount(reqDto,respDto.getBlockChainAddress(),bizFailDesc,sysFailDesc,isRealNameAuthSuccess,isBindBlockAddressSuccess);
log.info("用户 {} 数字账户开通结果:{}",reqDto.getUserId(),isOpenAccount);
}catch(Exception e){
log.error("同步用户数字账户开通信息异常:"+e.getMessage(),e);
}
long endTime = System.currentTimeMillis();
log.error("开通数字账户userRegister总耗时:{} ",endTime-startTime);
if(StringUtil.isNotEmpty(sysFailDesc)){
return ResponseDto.failure(sysFailDesc);
}
if(StringUtil.isNotEmpty(bizFailDesc)){
return ResponseDto.failure(bizFailDesc);
}
return ResponseDto.success(respDto);
}
/**
* 同步用户数字账户开通信息
* @param reqDto
* @param bizFailDesc
* @param sysFailDesc
* @param isRealNameAuthSuccess
* @param isBindBlockAddressSuccess
* @return
*/
public boolean syncOpenAccount(GalaxyUserRegisterReqDto reqDto,String blockChainAddress,String bizFailDesc,String sysFailDesc,
boolean isRealNameAuthSuccess,boolean isBindBlockAddressSuccess){
long startTime = System.currentTimeMillis();
long openAccSuccessKeyExpireTime = 3600*24*30*3;
long openAccFailKeyExpireTime = 60*5;
//是否开通数字账户
boolean isOpenAccount = false;
//开通失败错误信息
String resultCode = null;
String resultMessage = null;
//实名成功+绑定区块链地址成功
if(isRealNameAuthSuccess && isBindBlockAddressSuccess){
isOpenAccount = true;
resultCode = NftAccStatusEnum.StatusAcc.SUCCESS.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.SUCCESS.getMsg();
}
//开通数字账户失败
if(!isOpenAccount){
//实名失败
if(!isRealNameAuthSuccess){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE1.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE1.getMsg();
}else{
//地址绑定失败
if(!isBindBlockAddressSuccess){
if(StringUtil.isNotEmpty(bizFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE3.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE3.getMsg();
}else if(StringUtil.isNotEmpty(sysFailDesc)){
resultCode = NftAccStatusEnum.StatusAcc.FAILURE2.getCode();
resultMessage = NftAccStatusEnum.StatusAcc.FAILURE2.getMsg();
}
}
}
}
//更新至信链开户状态
GoblinUserNftAccInfoVo goblinUserNftAccInfoVo = GoblinUserNftAccInfoVo.getNew();
goblinUserNftAccInfoVo.setCode(resultCode);
goblinUserNftAccInfoVo.setMsg(resultMessage);
goblinUserNftAccInfoVo.setTime(LocalDateTime.now());
if(isOpenAccount){
//更新开户状态
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId())
,goblinUserNftAccInfoVo);
//同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
syncUserAccountInfoToAdam(reqDto);
//同步业务账号关联关系到adam
dataUtils.getQueueUtil().sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("adam_user_busi_acct.add", reqDto.getUserId(), AdamEnum.BizAcct.NFT_ZX.name(), blockChainAddress, null, null, 1, LocalDateTime.now())
);
//开户成功记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA.concat(reqDto.getIdCardType().concat(reqDto.getIdCard()))
,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccSuccessKeyExpireTime);
}else{
//更新开户状态
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(reqDto.getUserId())
,goblinUserNftAccInfoVo);
}
//设置错误信息到redis
if(StringUtil.isNotEmpty(resultCode)&&!resultCode.equalsIgnoreCase(NftAccStatusEnum.StatusAcc.SUCCESS.getCode())){
//开户失败记录缓存 {goblin:nft:certmeta:{idType+idNo},{idname,mobile}}
dataUtils.getRedisUtil().set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK.concat(reqDto.getIdCardType().concat(reqDto.getIdCard()))
,reqDto.getUserName().concat(",").concat(reqDto.getMobile()),openAccFailKeyExpireTime);
}
long endTime = System.currentTimeMillis();
log.error("同步数字账户syncOpenAccount总耗时:{} ",endTime-startTime);
return isOpenAccount;
}
/**
* 同步用户信息到adam 格式:{uid},{mobile},{证件类型}{证件号},{姓名}
* @param reqDto
* @return
*/
private boolean syncUserAccountInfoToAdam(GalaxyUserRegisterReqDto reqDto) {
try {
String certmetaInfo = reqDto.getUserId().concat(",")
.concat(reqDto.getMobile()).concat(",")
.concat(reqDto.getIdCardType().concat(reqDto.getIdCard())).concat(",")
.concat(reqDto.getUserName());
//加密用户信息
DESUtils desUtils = DESUtils.DES();
// MultiValueMap<String, String> params = new LinkedMultiValueMap();
// params.add("certmeta",desUtils.encrypt(certmetaInfo));
//
// HttpUtil.post(adamUrl + GalaxyConstant.ADAM_USER_SYNC_URL, params);
HttpUtil.postJson(adamUrl + GalaxyConstant.ADAM_USER_SYNC_URL, desUtils.encrypt(certmetaInfo));
} catch (Exception e) {
log.error("同步用户信息到adam异常:{}",JsonUtils.toJson(reqDto), e);
return false;
}
return true;
}
// public ResponseDto<GalaxyUserRegisterRespDto> userRegister2(GalaxyUserRegisterReqDto reqDto) {
// String userId = reqDto.getUserId();
// String userName = reqDto.getUserName();
// String mobile = reqDto.getMobile();
// String idCardType = reqDto.getIdCardType();
// String idCard = reqDto.getIdCard();
// String mnemonic = null;
// Long index = 0L;
// String userIdentification = null;
// String address = null;
// String userPubKey = null;
// String userPriKey = null;
//
// GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(reqDto.getRouterType(),userId);
// if(userInfoBo!=null){
// mnemonic = userInfoBo.getMnemonic();
// }else{
// 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(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
// respDto.setBlockChainAddress(address);
// }else{
// return ResponseDto.failure(nft016Resp.getMessage());
// }
//
//
// //构造缓存数据
// if(userInfoBo==null){
// userInfoBo = GalaxyUserInfoBo.getNew();
// userInfoBo.setUserId(userId);
// userInfoBo.setUserName(userName);
// userInfoBo.setMobile(mobile);
// userInfoBo.setIdCardType(idCardType);
// userInfoBo.setIdCard(idCard);
// userInfoBo.setMnemonic(mnemonic);
// userInfoBo.setIndex(index.toString());
// userInfoBo.setUserIdentification(userIdentification);
// userInfoBo.setUserPubKey(userPubKey);
// userInfoBo.setUserPriKey(userPriKey);
// userInfoBo.setRouterType(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
// userInfoBo.setBlockChainAddress(address);
// dataUtils.setGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId(),userInfoBo);
// }else{
//
// }
// }
// return ResponseDto.success(respDto);
// }
}
package com.liquidnet.service.galaxy.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.*;
import com.liquidnet.service.galaxy.dto.vo.mongo.*;
import com.mongodb.client.result.UpdateResult;
import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftOrderFailLogVo;
import com.liquidnet.service.galaxy.dto.vo.mongo.GalaxyNftTradeVo;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 该类为redis+mysql
*/
@Slf4j
public abstract class AbstractDataUtils {
public abstract RedisUtil getRedisUtil();
......@@ -33,15 +29,22 @@ public abstract class AbstractDataUtils {
// private long keyExpireTime = 3600*24*30;
public void setGalaxyUserInfoByIdCardNo(String routerType,String idCardNo, String address) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER_ID_CARD.concat(routerType).concat(":") + idCardNo,address);
}
public String getGalaxyUserInfoByIdCardNo(String routerType,String idCardNo) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_USER_ID_CARD.concat(routerType).concat(":") + idCardNo);
if(obj!=null){
return (String) obj;
}
return null;
}
public void setGalaxyUserInfo(String routerType,String userId, GalaxyUserInfoBo userInfoBo) {
String userType = GalaxyEnum.RegisterTypeEnum.PERSON.getCode();
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId,userInfoBo);
//入库mongo
GalaxyUserInfoVo userInfoVo = GalaxyUserInfoVo.getNew();
BeanUtil.copy(userInfoBo,userInfoVo);
userInfoVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(userInfoVo,GalaxyUserInfoVo.class.getSimpleName());
// insert into galaxy_user_info (mid, user_id, user_name, user_type, mobile, id_card_type
// , id_card, mnemonic, index,user_identification, user_pub_key
// , user_pri_key, block_chain_address, router_type,created_at, updated_at)
......@@ -60,56 +63,44 @@ public abstract class AbstractDataUtils {
}
}
public void updateGalaxyUserInfo(String routerType,String userId, GalaxyUserInfoBo userInfoBo) {
String userType = GalaxyEnum.RegisterTypeEnum.PERSON.getCode();
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId,userInfoBo);
// update galaxy_user_info set user_name = ?,id_card_type = ?,id_card = ?,mobile = ?,block_chain_address = ? where router_type = ? and user_id = ?
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_user_info.update"),
new Object[]{userInfoBo.getUserName(),userInfoBo.getIdCardType(),userInfoBo.getIdCard(),userInfoBo.getMobile()
,userInfoBo.getBlockChainAddress(),new Date(),userInfoBo.getRouterType(),userInfoBo.getUserId()
}
, MQConst.GalaxyQueue.SQL_USER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setGalaxyUserInfo error ==> MESSAGE:{}",e.getMessage());
}
}
public GalaxyUserInfoBo getGalaxyUserInfo(String routerType,String userId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId);
if(obj!=null){
return (GalaxyUserInfoBo) obj;
}else {
GalaxyUserInfoVo userInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("userId").is(userId)), GalaxyUserInfoVo.class, GalaxyUserInfoVo.class.getSimpleName());
if (userInfoVo == null) {
return null;
}
GalaxyUserInfoBo userInfoBo = GalaxyUserInfoBo.getNew();
BeanUtil.copy(userInfoVo,userInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId, userInfoBo);
return userInfoBo;
}
return null;
}
public void setSeriesNftUploadBo(String routerType,String skuId, GalaxySeriesNftUploadBo seriesNftUploadBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId,seriesNftUploadBo);
//mongo入库
GalaxySeriesNftUploadVo seriesNftUploadVo = GalaxySeriesNftUploadVo.getNew();
BeanUtil.copy(seriesNftUploadBo,seriesNftUploadVo);
seriesNftUploadVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(seriesNftUploadVo,GalaxySeriesNftUploadVo.class.getSimpleName());
}
public GalaxySeriesNftUploadBo getSeriesNftUploadBo(String routerType,String skuId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId);
if(obj!=null){
return (GalaxySeriesNftUploadBo) obj;
}else {
//设置查询参数
Criteria criteria = Criteria.where("routerType").is(routerType);
String userId = CurrentUtil.getCurrentUid();
if(StringUtil.isNotEmpty(skuId)){
criteria = criteria.and("skuId").is(skuId);
}
GalaxySeriesNftUploadVo seriesNftUploadVo = this.getMongoTemplate().findOne(Query.query(criteria), GalaxySeriesNftUploadVo.class, GalaxySeriesNftUploadVo.class.getSimpleName());
if (seriesNftUploadVo == null) {
return null;
}
GalaxySeriesNftUploadBo seriesNftUploadBo = GalaxySeriesNftUploadBo.getNew();
BeanUtil.copy(seriesNftUploadVo,seriesNftUploadBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId, seriesNftUploadBo);
return seriesNftUploadBo;
}
}
public void setSeriesInfoBo(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
......@@ -119,12 +110,6 @@ public abstract class AbstractDataUtils {
// , nft_count,router_type, created_at, updated_at)
Integer nftCount = seriesInfoBo.getNftCount();//默认为一个系列包含一个NFT
//mongo入库
GalaxySeriesInfoVo seriesInfoVo = GalaxySeriesInfoVo.getNew();
BeanUtil.copy(seriesInfoBo,seriesInfoVo);
seriesInfoVo.setCreatedAt(DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMddHHmmss));
this.getMongoTemplate().save(seriesInfoVo,GalaxySeriesInfoVo.class.getSimpleName());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.insert"),
......@@ -144,16 +129,8 @@ public abstract class AbstractDataUtils {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode);
if(obj!=null){
return (GalaxySeriesInfoBo) obj;
}else {
GalaxySeriesInfoVo seriesInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("seriesCode").is(seriesCode)), GalaxySeriesInfoVo.class, GalaxySeriesInfoVo.class.getSimpleName());
if (seriesInfoVo == null) {
return null;
}
GalaxySeriesInfoBo seriesInfoBo = GalaxySeriesInfoBo.getNew();
BeanUtil.copy(seriesInfoVo,seriesInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode, seriesInfoBo);
return seriesInfoBo;
}
return null;
}
public void setSeriesNftInfoBo(String routerType, String skuId, GalaxySeriesInfoBo seriesInfoBo, GalaxySeriesNftInfoBo seriesNftInfoBo) {
......@@ -162,12 +139,6 @@ public abstract class AbstractDataUtils {
//初始化nft发行绑定索引,未发行则初始化为0,
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId),seriesNftInfoBo.getNftIdBeginIndex()-1);
//mongo入库
GalaxySeriesNftInfoVo seriesNftInfoVo = GalaxySeriesNftInfoVo.getNew();
BeanUtil.copy(seriesNftInfoBo,seriesNftInfoVo);
seriesNftInfoVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(seriesNftInfoVo,GalaxySeriesNftInfoVo.class.getSimpleName());
try{
// insert into galaxy_series_nft_info (mid, series_nft_info_id, series_info_id, sku_id, series_name, series_code
// ,series_id, nft_total_count, nft_crt_count,nft_id_begin,nft_id_begin_index,nft_publish_number,original_nft_url
......@@ -194,28 +165,14 @@ public abstract class AbstractDataUtils {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId);
if(obj!=null){
return (GalaxySeriesNftInfoBo) obj;
}else {
GalaxySeriesNftInfoVo seriesNftInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("skuId").is(skuId)), GalaxySeriesNftInfoVo.class, GalaxySeriesNftInfoVo.class.getSimpleName());
if (seriesNftInfoVo == null) {
return null;
}
GalaxySeriesNftInfoBo seriesNftInfoBo = GalaxySeriesNftInfoBo.getNew();
BeanUtil.copy(seriesNftInfoVo,seriesNftInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId, seriesNftInfoBo);
return seriesNftInfoBo;
}
return null;
}
public void updateSeriesClaimStatus(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo) {
public void updateSeriesClaimStatus(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo,String skuId) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
Query query = Query.query(Criteria.where("seriesCode").is(seriesInfoBo.getSeriesCode()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesInfoVo.class,GalaxySeriesInfoVo.class.getSimpleName());
log.info("updateSeriesClaimStatus result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.updateSeriesIdAndStatus"),
......@@ -226,27 +183,44 @@ public abstract class AbstractDataUtils {
log.error(e.getMessage(),e);
log.error("#updateSeriesClaimStatus error ==> MESSAGE:{}",e.getMessage());
}
//更新系列对应的系列nft状态
List<String> skuIdList = this.getSkuIdListBySeriesCode(seriesCode);
skuIdList.stream().forEach(skuId -> {
GalaxySeriesNftInfoBo seriesNftInfoBo = this.getSeriesNftInfoBo(routerType,skuId);
seriesNftInfoBo.setSeriesId(seriesInfoBo.getSeriesId());
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
this.updateSeriesNftStatus(routerType,skuId,seriesNftInfoBo);
});
}
public void updateSeriesClaimStatus(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo) {
// this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
//
// String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
// try{
// this.getQueueUtil().sendMySqlRedis(
// SqlMapping.get("galaxy_series_info.updateSeriesIdAndStatus"),
// new Object[]{seriesInfoBo.getSeriesId(),seriesInfoBo.getChainTimestamp(),seriesInfoBo.getTradeHash(),seriesInfoBo.getSeriesClaimStatus(),nowTimeStr,seriesInfoBo.getSeriesCode()}
// , MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
// );
// }catch(Exception e){
// log.error(e.getMessage(),e);
// log.error("#updateSeriesClaimStatus error ==> MESSAGE:{}",e.getMessage());
// }
//
// //更新系列对应的系列nft状态
// List<String> skuIdList = this.getSkuIdListBySeriesCode(seriesCode);
// skuIdList.stream().forEach(skuId -> {
// GalaxySeriesNftInfoBo seriesNftInfoBo = this.getSeriesNftInfoBo(routerType,skuId);
// seriesNftInfoBo.setSeriesId(seriesInfoBo.getSeriesId());
// seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
// this.updateSeriesNftStatus(routerType,skuId,seriesNftInfoBo);
// });
}
public void updateSeriesNftStatus(String routerType,String skuId, GalaxySeriesNftInfoBo seriesNftInfoBo) {
//更新系列nft状态
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
Query query = Query.query(Criteria.where("skuId").is(skuId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesNftInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(seriesNftInfoBo.getUpdatedAt());
update.set("routerType",routerType);
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesNftInfoVo.class,GalaxySeriesNftInfoVo.class.getSimpleName());
log.info("updateSeriesNftStatus result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
......@@ -260,36 +234,30 @@ public abstract class AbstractDataUtils {
}
}
//根据系列Id获取
public List<String> getSkuIdListBySeriesCode(String seriesCode){
//根据演出id获取用户信息 只查询5条
List<String> skuIdList = new ArrayList<>();
//获取总数
Criteria criteria = Criteria.where("seriesCode").is(seriesCode);
Query query = Query.query(criteria);
long startTime = System.currentTimeMillis();
List<GalaxySeriesNftInfoVo> seriesNftInfoVoList = this.getMongoTemplate().find(query, GalaxySeriesNftInfoVo.class, GalaxySeriesNftInfoVo.class.getSimpleName());
long endTime = System.currentTimeMillis();
log.info("getSkuIdListBySeriesCode 根据系列code获取skuId 耗时:{}ms",endTime-startTime);
//根据用户id获取头像信息
if(StringUtil.isNotNull(seriesNftInfoVoList)){
skuIdList = seriesNftInfoVoList.stream().map(GalaxySeriesNftInfoVo::getSkuId).collect(Collectors.toList());
}
return skuIdList;
}
//根据系列Id获取 一个系列对应多个skuId
// public List<String> getSkuIdListBySeriesCode(String seriesCode){
// //根据演出id获取用户信息 只查询5条
// List<String> skuIdList = new ArrayList<>();
// //获取总数
// Criteria criteria = Criteria.where("seriesCode").is(seriesCode);
//
// Query query = Query.query(criteria);
//
// long startTime = System.currentTimeMillis();
// List<GalaxySeriesNftInfoVo> seriesNftInfoVoList = this.getMongoTemplate().find(query, GalaxySeriesNftInfoVo.class, GalaxySeriesNftInfoVo.class.getSimpleName());
// long endTime = System.currentTimeMillis();
// log.info("getSkuIdListBySeriesCode 根据系列code获取skuId 耗时:{}ms",endTime-startTime);
//
// //根据用户id获取头像信息
// if(StringUtil.isNotNull(seriesNftInfoVoList)){
// skuIdList = seriesNftInfoVoList.stream().map(GalaxySeriesNftInfoVo::getSkuId).collect(Collectors.toList());
// }
// return skuIdList;
// }
public void setNftOrderBo(String routerType,String nftOrderPayId, GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
/**
* 入库mongo
*/
GalaxyNftOrderVo nftOrderVo = GalaxyNftOrderVo.getNew();
BeanUtil.copy(nftOrderBo,nftOrderVo);
this.getMongoTemplate().save(nftOrderVo,GalaxyNftOrderVo.class.getSimpleName());
// insert into galaxy_nft_order_info (nft_order_pay_id, user_id, sku_id, series_name, series_id,
// series_code, nft_id,nft_price, nft_publish_task_id, nft_publish_from_address,
......@@ -331,16 +299,8 @@ public abstract class AbstractDataUtils {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId);
if(obj!=null){
return (GalaxyNftOrderBo) obj;
}else {
GalaxyNftOrderVo nftOrderVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId)), GalaxyNftOrderVo.class, GalaxyNftOrderVo.class.getSimpleName());
if (nftOrderVo == null) {
return null;
}
GalaxyNftOrderBo nftOrderBo = GalaxyNftOrderBo.getNew();
BeanUtil.copy(nftOrderVo,nftOrderBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId, nftOrderBo);
return nftOrderBo;
}
return null;
}
/**
......@@ -352,13 +312,6 @@ public abstract class AbstractDataUtils {
public void updateNftOrderPublishInfo(String routerType,String nftOrderPayId,GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
Query query = Query.query(Criteria.where("nftOrderPayId").is(nftOrderBo.getNftOrderPayId()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(nftOrderBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nftOrderBo.getUpdatedAt());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxyNftOrderVo.class,GalaxyNftOrderVo.class.getSimpleName());
log.info("updateNftOrderPublishInfo result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_info.updateNftPublishInfo"),
......@@ -387,13 +340,6 @@ public abstract class AbstractDataUtils {
public void updateNftOrderBuyInfo(String routerType,String nftOrderPayId,GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
Query query = Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(nftOrderBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nftOrderBo.getUpdatedAt());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxyNftOrderVo.class,GalaxyNftOrderVo.class.getSimpleName());
log.info("updateNftOrderBuyInfo result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_info.updateNftBuyInfo"),
......@@ -415,10 +361,6 @@ public abstract class AbstractDataUtils {
public void setGalaxyNftOrderBindBo(String routerType,String nftOrderPayId, GalaxyNftOrderBindBo nftOrderBindBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBindBo);
//入库mongo
GalaxyNftOrderBindVo nftOrderBindVo = GalaxyNftOrderBindVo.getNew();
BeanUtil.copy(nftOrderBindBo,nftOrderBindVo);
this.getMongoTemplate().save(nftOrderBindVo,GalaxyNftOrderBindVo.class.getSimpleName());
}
public GalaxyNftOrderBindBo getGalaxyNftOrderBindBo(String routerType,String nftOrderPayId) {
......@@ -426,26 +368,12 @@ public abstract class AbstractDataUtils {
Object obj = this.getRedisUtil().get(redisKey);
if(obj!=null){
return (GalaxyNftOrderBindBo) obj;
}else {
GalaxyNftOrderBindVo nftOrderBindVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId)), GalaxyNftOrderBindVo.class, GalaxyNftOrderBindVo.class.getSimpleName());
if (nftOrderBindVo == null) {
return null;
}
GalaxyNftOrderBindBo nftOrderBindBo = GalaxyNftOrderBindBo.getNew();
BeanUtil.copy(nftOrderBindVo,nftOrderBindBo);
this.getRedisUtil().set(redisKey, nftOrderBindBo);
return nftOrderBindBo;
}
return null;
}
public void setNftTradeInfo(String routerType, GalaxyNftTradeVo nftTradeVo) {
try{
/**
* 发行成功记录入库mongo
*/
this.getMongoTemplate().save(nftTradeVo,GalaxyNftTradeVo.class.getSimpleName());
// insert into galaxy_nft_trade_info (user_id, nft_id, nft_name, series_name, series_id,
// series_code, trade_hash,chain_timestamp, from_address, to_address,
// trade_price, trade_type, router_type,created_at, updated_at)
......@@ -466,12 +394,6 @@ public abstract class AbstractDataUtils {
}
public void setNftOrderFailLogVo(String routerType, GalaxyNftOrderFailLogVo nftOrderFailLogVo) {
/**
* 入库mongo
*/
nftOrderFailLogVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(nftOrderFailLogVo,GalaxyNftOrderFailLogVo.class.getSimpleName());
// insert into galaxy_nft_order_fail_log (nft_order_pay_id, user_id, nft_id, nft_name, series_name,
// series_id,series_code, taskId, fail_reason_desc, fail_reason_desc_second,
// deal_with_status,trade_type, router_type, created_at, updated_at)
......@@ -509,13 +431,6 @@ public abstract class AbstractDataUtils {
seriesInfoBo.setCrtCount(seriesInfoBo.getCrtCount()+1);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
Query query = Query.query(Criteria.where("seriesCode").is(seriesInfoBo.getSeriesCode()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesInfoVo.class,GalaxySeriesInfoVo.class.getSimpleName());
log.info("updateSeriesCrtCount result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.updateSeriesCrtCount"),
......@@ -538,13 +453,6 @@ public abstract class AbstractDataUtils {
seriesNftInfoBo.setNftCrtCount(seriesNftInfoBo.getNftCrtCount()+1);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
Query query = Query.query(Criteria.where("skuId").is(skuId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesNftInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesNftInfoVo.class,GalaxySeriesNftInfoVo.class.getSimpleName());
log.info("updateSeriesNftCrtCount result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.updateSeriesNftCrtCount"),
......
package com.liquidnet.service.galaxy.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.constant.GalaxyConstant;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.*;
import com.liquidnet.service.galaxy.dto.vo.mongo.*;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 该类为redis+mongodb+mysql
*/
@Slf4j
public abstract class AbstractDataUtilsBackup {
public abstract RedisUtil getRedisUtil();
public abstract MongoTemplate getMongoTemplate();
public abstract QueueUtil getQueueUtil();
// private long keyExpireTime = 3600*24*30;
public void setGalaxyUserInfo(String routerType,String userId, GalaxyUserInfoBo userInfoBo) {
String userType = GalaxyEnum.RegisterTypeEnum.PERSON.getCode();
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId,userInfoBo);
//入库mongo
GalaxyUserInfoVo userInfoVo = GalaxyUserInfoVo.getNew();
BeanUtil.copy(userInfoBo,userInfoVo);
userInfoVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(userInfoVo,GalaxyUserInfoVo.class.getSimpleName());
// insert into galaxy_user_info (mid, user_id, user_name, user_type, mobile, id_card_type
// , id_card, mnemonic, index,user_identification, user_pub_key
// , user_pri_key, block_chain_address, router_type,created_at, updated_at)
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_user_info.insert"),
new Object[]{userId,userInfoBo.getUserName(),userType,userInfoBo.getMobile(),userInfoBo.getIdCardType()
,userInfoBo.getIdCard(),userInfoBo.getMnemonic(),userInfoBo.getIndex(),userInfoBo.getUserIdentification(),userInfoBo.getUserPubKey()
,userInfoBo.getUserPriKey(),userInfoBo.getBlockChainAddress(),userInfoBo.getRouterType(),new Date(),null
}
, MQConst.GalaxyQueue.SQL_USER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setGalaxyUserInfo error ==> MESSAGE:{}",e.getMessage());
}
}
public void updateGalaxyUserInfo(String routerType,String userId, GalaxyUserInfoBo userInfoBo) {
String userType = GalaxyEnum.RegisterTypeEnum.PERSON.getCode();
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId,userInfoBo);
//入库mongo
GalaxyUserInfoVo userInfoVo = GalaxyUserInfoVo.getNew();
BeanUtil.copy(userInfoBo,userInfoVo);
userInfoVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(userInfoVo,GalaxyUserInfoVo.class.getSimpleName());
// insert into galaxy_user_info (mid, user_id, user_name, user_type, mobile, id_card_type
// , id_card, mnemonic, index,user_identification, user_pub_key
// , user_pri_key, block_chain_address, router_type,created_at, updated_at)
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_user_info.insert"),
new Object[]{userId,userInfoBo.getUserName(),userType,userInfoBo.getMobile(),userInfoBo.getIdCardType()
,userInfoBo.getIdCard(),userInfoBo.getMnemonic(),userInfoBo.getIndex(),userInfoBo.getUserIdentification(),userInfoBo.getUserPubKey()
,userInfoBo.getUserPriKey(),userInfoBo.getBlockChainAddress(),userInfoBo.getRouterType(),new Date(),null
}
, MQConst.GalaxyQueue.SQL_USER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setGalaxyUserInfo error ==> MESSAGE:{}",e.getMessage());
}
}
public GalaxyUserInfoBo getGalaxyUserInfo(String routerType,String userId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId);
if(obj!=null){
return (GalaxyUserInfoBo) obj;
}else {
GalaxyUserInfoVo userInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("userId").is(userId)), GalaxyUserInfoVo.class, GalaxyUserInfoVo.class.getSimpleName());
if (userInfoVo == null) {
return null;
}
GalaxyUserInfoBo userInfoBo = GalaxyUserInfoBo.getNew();
BeanUtil.copy(userInfoVo,userInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_USER.concat(routerType).concat(":") + userId, userInfoBo);
return userInfoBo;
}
}
public void setSeriesNftUploadBo(String routerType,String skuId, GalaxySeriesNftUploadBo seriesNftUploadBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId,seriesNftUploadBo);
//mongo入库
GalaxySeriesNftUploadVo seriesNftUploadVo = GalaxySeriesNftUploadVo.getNew();
BeanUtil.copy(seriesNftUploadBo,seriesNftUploadVo);
seriesNftUploadVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(seriesNftUploadVo,GalaxySeriesNftUploadVo.class.getSimpleName());
}
public GalaxySeriesNftUploadBo getSeriesNftUploadBo(String routerType,String skuId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId);
if(obj!=null){
return (GalaxySeriesNftUploadBo) obj;
}else {
//设置查询参数
Criteria criteria = Criteria.where("routerType").is(routerType);
String userId = CurrentUtil.getCurrentUid();
if(StringUtil.isNotEmpty(skuId)){
criteria = criteria.and("skuId").is(skuId);
}
GalaxySeriesNftUploadVo seriesNftUploadVo = this.getMongoTemplate().findOne(Query.query(criteria), GalaxySeriesNftUploadVo.class, GalaxySeriesNftUploadVo.class.getSimpleName());
if (seriesNftUploadVo == null) {
return null;
}
GalaxySeriesNftUploadBo seriesNftUploadBo = GalaxySeriesNftUploadBo.getNew();
BeanUtil.copy(seriesNftUploadVo,seriesNftUploadBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD.concat(routerType).concat(":") + skuId, seriesNftUploadBo);
return seriesNftUploadBo;
}
}
public void setSeriesInfoBo(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
// insert into galaxy_series_info (mid, series_info_id, series_name, series_code, series_id, total_count
// , crt_count,series_claim_task_id, series_claim_status, cover_url, series_desc
// , nft_count,router_type, created_at, updated_at)
Integer nftCount = seriesInfoBo.getNftCount();//默认为一个系列包含一个NFT
//mongo入库
GalaxySeriesInfoVo seriesInfoVo = GalaxySeriesInfoVo.getNew();
BeanUtil.copy(seriesInfoBo,seriesInfoVo);
seriesInfoVo.setCreatedAt(DateUtil.format(LocalDateTime.now(), DateUtil.Formatter.yyyyMMddHHmmss));
this.getMongoTemplate().save(seriesInfoVo,GalaxySeriesInfoVo.class.getSimpleName());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.insert"),
new Object[]{seriesInfoBo.getSeriesInfoId(),seriesInfoBo.getSeriesName(),seriesCode,null,seriesInfoBo.getTotalCount()
,seriesInfoBo.getCrtCount(),seriesInfoBo.getSeriesClaimTaskId(),seriesInfoBo.getSeriesClaimStatus(),seriesInfoBo.getCoverUrl(),seriesInfoBo.getSeriesDesc()
,nftCount,seriesInfoBo.getRouterType(),LocalDateTime.now(),null
}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setSeriesInfoBo error ==> MESSAGE:{}",e.getMessage());
}
}
public GalaxySeriesInfoBo getSeriesInfoBo(String routerType, String seriesCode) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode);
if(obj!=null){
return (GalaxySeriesInfoBo) obj;
}else {
GalaxySeriesInfoVo seriesInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("seriesCode").is(seriesCode)), GalaxySeriesInfoVo.class, GalaxySeriesInfoVo.class.getSimpleName());
if (seriesInfoVo == null) {
return null;
}
GalaxySeriesInfoBo seriesInfoBo = GalaxySeriesInfoBo.getNew();
BeanUtil.copy(seriesInfoVo,seriesInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode, seriesInfoBo);
return seriesInfoBo;
}
}
public void setSeriesNftInfoBo(String routerType, String skuId, GalaxySeriesInfoBo seriesInfoBo, GalaxySeriesNftInfoBo seriesNftInfoBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
//初始化nft发行绑定索引,未发行则初始化为0,
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId),seriesNftInfoBo.getNftIdBeginIndex()-1);
//mongo入库
GalaxySeriesNftInfoVo seriesNftInfoVo = GalaxySeriesNftInfoVo.getNew();
BeanUtil.copy(seriesNftInfoBo,seriesNftInfoVo);
seriesNftInfoVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(seriesNftInfoVo,GalaxySeriesNftInfoVo.class.getSimpleName());
try{
// insert into galaxy_series_nft_info (mid, series_nft_info_id, series_info_id, sku_id, series_name, series_code
// ,series_id, nft_total_count, nft_crt_count,nft_id_begin,nft_id_begin_index,nft_publish_number,original_nft_url
// , original_display_url,author, nft_name, nft_url, display_url
// , nft_desc, nft_flag, sell_count, nft_hash,router_type
// , created_at, updated_at)
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.insert"),
new Object[]{seriesNftInfoBo.getSeriesNftInfoId(),seriesInfoBo.getSeriesInfoId(),skuId,seriesInfoBo.getSeriesName(),seriesInfoBo.getSeriesCode()
,seriesInfoBo.getSeriesId(),seriesNftInfoBo.getNftTotalCount(),seriesNftInfoBo.getNftCrtCount(),seriesNftInfoBo.getNftIdBegin(),seriesNftInfoBo.getNftIdBeginIndex(),seriesNftInfoBo.getNftPublishNumber(),seriesNftInfoBo.getOriginalNftUrl()
,seriesNftInfoBo.getOriginalDisplayUrl(),seriesNftInfoBo.getAuthor(),seriesNftInfoBo.getNftName(),seriesNftInfoBo.getNftUrl(),seriesNftInfoBo.getDisplayUrl()
,seriesNftInfoBo.getNftDesc(),seriesNftInfoBo.getNftFlag(),seriesNftInfoBo.getSellCount(),seriesNftInfoBo.getNftHash(),seriesInfoBo.getRouterType()
,LocalDateTime.now(),null
}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey());
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setSeriesInfoBo error ==> MESSAGE:{}",e.getMessage());
}
}
public GalaxySeriesNftInfoBo getSeriesNftInfoBo(String routerType, String skuId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId);
if(obj!=null){
return (GalaxySeriesNftInfoBo) obj;
}else {
GalaxySeriesNftInfoVo seriesNftInfoVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("skuId").is(skuId)), GalaxySeriesNftInfoVo.class, GalaxySeriesNftInfoVo.class.getSimpleName());
if (seriesNftInfoVo == null) {
return null;
}
GalaxySeriesNftInfoBo seriesNftInfoBo = GalaxySeriesNftInfoBo.getNew();
BeanUtil.copy(seriesNftInfoVo,seriesNftInfoBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId, seriesNftInfoBo);
return seriesNftInfoBo;
}
}
public void updateSeriesClaimStatus(String routerType,String seriesCode, GalaxySeriesInfoBo seriesInfoBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
Query query = Query.query(Criteria.where("seriesCode").is(seriesInfoBo.getSeriesCode()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesInfoVo.class,GalaxySeriesInfoVo.class.getSimpleName());
log.info("updateSeriesClaimStatus result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.updateSeriesIdAndStatus"),
new Object[]{seriesInfoBo.getSeriesId(),seriesInfoBo.getChainTimestamp(),seriesInfoBo.getTradeHash(),seriesInfoBo.getSeriesClaimStatus(),nowTimeStr,seriesInfoBo.getSeriesCode()}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#updateSeriesClaimStatus error ==> MESSAGE:{}",e.getMessage());
}
//更新系列对应的系列nft状态
List<String> skuIdList = this.getSkuIdListBySeriesCode(seriesCode);
skuIdList.stream().forEach(skuId -> {
GalaxySeriesNftInfoBo seriesNftInfoBo = this.getSeriesNftInfoBo(routerType,skuId);
seriesNftInfoBo.setSeriesId(seriesInfoBo.getSeriesId());
seriesNftInfoBo.setUpdatedAt(LocalDateTime.now());
this.updateSeriesNftStatus(routerType,skuId,seriesNftInfoBo);
});
}
public void updateSeriesNftStatus(String routerType,String skuId, GalaxySeriesNftInfoBo seriesNftInfoBo) {
//更新系列nft状态
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
Query query = Query.query(Criteria.where("skuId").is(skuId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesNftInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(seriesNftInfoBo.getUpdatedAt());
update.set("routerType",routerType);
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesNftInfoVo.class,GalaxySeriesNftInfoVo.class.getSimpleName());
log.info("updateSeriesNftStatus result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.updateSeriesIdAndStatus"),
new Object[]{seriesNftInfoBo.getSeriesId(),nowTimeStr,seriesNftInfoBo.getSkuId()}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#updateSeriesNftStatus error ==> MESSAGE:{}",e.getMessage());
}
}
//根据系列Id获取
public List<String> getSkuIdListBySeriesCode(String seriesCode){
//根据演出id获取用户信息 只查询5条
List<String> skuIdList = new ArrayList<>();
//获取总数
Criteria criteria = Criteria.where("seriesCode").is(seriesCode);
Query query = Query.query(criteria);
long startTime = System.currentTimeMillis();
List<GalaxySeriesNftInfoVo> seriesNftInfoVoList = this.getMongoTemplate().find(query, GalaxySeriesNftInfoVo.class, GalaxySeriesNftInfoVo.class.getSimpleName());
long endTime = System.currentTimeMillis();
log.info("getSkuIdListBySeriesCode 根据系列code获取skuId 耗时:{}ms",endTime-startTime);
//根据用户id获取头像信息
if(StringUtil.isNotNull(seriesNftInfoVoList)){
skuIdList = seriesNftInfoVoList.stream().map(GalaxySeriesNftInfoVo::getSkuId).collect(Collectors.toList());
}
return skuIdList;
}
public void setNftOrderBo(String routerType,String nftOrderPayId, GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
/**
* 入库mongo
*/
GalaxyNftOrderVo nftOrderVo = GalaxyNftOrderVo.getNew();
BeanUtil.copy(nftOrderBo,nftOrderVo);
this.getMongoTemplate().save(nftOrderVo,GalaxyNftOrderVo.class.getSimpleName());
// insert into galaxy_nft_order_info (nft_order_pay_id, user_id, sku_id, series_name, series_id,
// series_code, nft_id,nft_price, nft_publish_task_id, nft_publish_from_address,
// nft_publish_to_address,nft_publish_chain_timestamp, nft_publish_status, nft_publish_trade_hash,nft_buy_task_id,
// nft_buy_from_address, nft_buy_to_address, nft_buy_chain_timestamp,nft_buy_status, nft_buy_trade_hash,
// nft_buy_pay_task_id, router_type, created_at,updated_at)
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_info.insert"),
new Object[]{nftOrderPayId,nftOrderBo.getUserId(),nftOrderBo.getSkuId(),nftOrderBo.getSeriesName(),nftOrderBo.getSeriesId()
,nftOrderBo.getSeriesCode(),nftOrderBo.getNftId(),nftOrderBo.getNftName(),nftOrderBo.getNftPrice(),nftOrderBo.getNftPublishTaskId(),nftOrderBo.getNftPublishFromAddress()
,nftOrderBo.getNftPublishToAddress(),nftOrderBo.getNftPublishChainTimestamp(),nftOrderBo.getNftPublishStatus(),nftOrderBo.getNftPublishTradeHash(),nftOrderBo.getNftBuyTaskId()
,nftOrderBo.getNftBuyFromAddress(),nftOrderBo.getNftBuyToAddress(),nftOrderBo.getNftBuyChainTimestamp(),nftOrderBo.getNftBuyStatus(),nftOrderBo.getNftBuyTradeHash(),
nftOrderBo.getNftBuyPayTaskId(),nftOrderBo.getRouterType(),LocalDateTime.now(),null
}
, MQConst.GalaxyQueue.SQL_NFT_ORDER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setNftOrderBo error ==> MESSAGE:{}",e.getMessage());
}
//更新系列已发行信息
try {
this.updateSeriesCrtCount(routerType,nftOrderBo.getSeriesCode());
} catch (Exception e) {
log.error(e.getMessage(),e);
}
//更新系列nft已发行信息
try {
this.updateSeriesNftCrtCount(routerType,nftOrderBo.getSkuId());
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
public GalaxyNftOrderBo getNftOrderBo(String routerType, String nftOrderPayId) {
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId);
if(obj!=null){
return (GalaxyNftOrderBo) obj;
}else {
GalaxyNftOrderVo nftOrderVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId)), GalaxyNftOrderVo.class, GalaxyNftOrderVo.class.getSimpleName());
if (nftOrderVo == null) {
return null;
}
GalaxyNftOrderBo nftOrderBo = GalaxyNftOrderBo.getNew();
BeanUtil.copy(nftOrderVo,nftOrderBo);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId, nftOrderBo);
return nftOrderBo;
}
}
/**
* 更新nft订单发行数据
* @param routerType
* @param nftOrderPayId
* @param nftOrderBo
*/
public void updateNftOrderPublishInfo(String routerType,String nftOrderPayId,GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
Query query = Query.query(Criteria.where("nftOrderPayId").is(nftOrderBo.getNftOrderPayId()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(nftOrderBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nftOrderBo.getUpdatedAt());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxyNftOrderVo.class,GalaxyNftOrderVo.class.getSimpleName());
log.info("updateNftOrderPublishInfo result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_info.updateNftPublishInfo"),
new Object[]{nftOrderBo.getNftId(),nftOrderBo.getNftPublishTaskId(),nftOrderBo.getNftPublishChainTimestamp()
,nftOrderBo.getNftPublishStatus(),nftOrderBo.getNftPublishTradeHash()
,LocalDateTime.now(),nftOrderBo.getNftOrderPayId()}
, MQConst.GalaxyQueue.SQL_NFT_ORDER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#updateNftOrderPublishInfo error ==> MESSAGE:{}",e.getMessage());
}
if(nftOrderBo.getNftPublishStatus().equalsIgnoreCase(GalaxyEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
GalaxyNftTradeVo nftTradeVo = GalaxyBeanTransferBiz.buildNftTradeVo(GalaxyEnum.TradeTypeEnum.TRADE_PUBLISH,nftOrderBo);
this.setNftTradeInfo(routerType,nftTradeVo);
}
}
/**
* 更新nft订单购买数据
* @param routerType
* @param nftOrderPayId
* @param nftOrderBo
*/
public void updateNftOrderBuyInfo(String routerType,String nftOrderPayId,GalaxyNftOrderBo nftOrderBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_TRADE_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBo);
Query query = Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(nftOrderBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(nftOrderBo.getUpdatedAt());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxyNftOrderVo.class,GalaxyNftOrderVo.class.getSimpleName());
log.info("updateNftOrderBuyInfo result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_info.updateNftBuyInfo"),
new Object[]{nftOrderBo.getNftBuyTaskId(),nftOrderBo.getNftBuyChainTimestamp(),nftOrderBo.getNftBuyStatus()
,nftOrderBo.getNftBuyTradeHash(),nftOrderBo.getNftBuyPayTaskId()
,LocalDateTime.now(),nftOrderBo.getNftOrderPayId()}
, MQConst.GalaxyQueue.SQL_NFT_ORDER_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setNftTradeInfo error ==> MESSAGE:{}",e.getMessage());
}
if(nftOrderBo.getNftBuyStatus().equalsIgnoreCase(GalaxyEnum.TaskStatusEnum.TASK_SUCCESS.getCode())){
GalaxyNftTradeVo nftTradeVo = GalaxyBeanTransferBiz.buildNftTradeVo(GalaxyEnum.TradeTypeEnum.TRADE_BUY,nftOrderBo);
this.setNftTradeInfo(routerType,nftTradeVo);
}
}
public void setGalaxyNftOrderBindBo(String routerType,String nftOrderPayId, GalaxyNftOrderBindBo nftOrderBindBo) {
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_ORDER.concat(routerType).concat(":") + nftOrderPayId,nftOrderBindBo);
//入库mongo
GalaxyNftOrderBindVo nftOrderBindVo = GalaxyNftOrderBindVo.getNew();
BeanUtil.copy(nftOrderBindBo,nftOrderBindVo);
this.getMongoTemplate().save(nftOrderBindVo,GalaxyNftOrderBindVo.class.getSimpleName());
}
public GalaxyNftOrderBindBo getGalaxyNftOrderBindBo(String routerType,String nftOrderPayId) {
String redisKey = GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_ORDER.concat(routerType).concat(":") + nftOrderPayId;
Object obj = this.getRedisUtil().get(redisKey);
if(obj!=null){
return (GalaxyNftOrderBindBo) obj;
}else {
GalaxyNftOrderBindVo nftOrderBindVo = this.getMongoTemplate().findOne(Query.query(Criteria.where("nftOrderPayId").is(nftOrderPayId)), GalaxyNftOrderBindVo.class, GalaxyNftOrderBindVo.class.getSimpleName());
if (nftOrderBindVo == null) {
return null;
}
GalaxyNftOrderBindBo nftOrderBindBo = GalaxyNftOrderBindBo.getNew();
BeanUtil.copy(nftOrderBindVo,nftOrderBindBo);
this.getRedisUtil().set(redisKey, nftOrderBindBo);
return nftOrderBindBo;
}
}
public void setNftTradeInfo(String routerType, GalaxyNftTradeVo nftTradeVo) {
try{
/**
* 发行成功记录入库mongo
*/
this.getMongoTemplate().save(nftTradeVo,GalaxyNftTradeVo.class.getSimpleName());
// insert into galaxy_nft_trade_info (user_id, nft_id, nft_name, series_name, series_id,
// series_code, trade_hash,chain_timestamp, from_address, to_address,
// trade_price, trade_type, router_type,created_at, updated_at)
/**
* 发行成功记录入库mysql
*/
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_trade_info.insert"),
new Object[]{nftTradeVo.getUserId(),nftTradeVo.getNftId(),nftTradeVo.getNftName(),nftTradeVo.getSeriesName(),nftTradeVo.getSeriesId(),
nftTradeVo.getSeriesCode(),nftTradeVo.getTradeHash(),nftTradeVo.getChainTimestamp(),nftTradeVo.getFromAddress(),nftTradeVo.getToAddress(),
nftTradeVo.getTradePrice(),nftTradeVo.getTradeType(),nftTradeVo.getRouterType(),LocalDateTime.now(),nftTradeVo.getUpdatedAt()}
, MQConst.GalaxyQueue.SQL_NFT_TRADE_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setNftTradeInfo error ==> MESSAGE:{}",e.getMessage());
}
}
public void setNftOrderFailLogVo(String routerType, GalaxyNftOrderFailLogVo nftOrderFailLogVo) {
/**
* 入库mongo
*/
nftOrderFailLogVo.setCreatedAt(LocalDateTime.now());
this.getMongoTemplate().save(nftOrderFailLogVo,GalaxyNftOrderFailLogVo.class.getSimpleName());
// insert into galaxy_nft_order_fail_log (nft_order_pay_id, user_id, nft_id, nft_name, series_name,
// series_id,series_code, taskId, fail_reason_desc, fail_reason_desc_second,
// deal_with_status,trade_type, router_type, created_at, updated_at)
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_nft_order_fail_log.insert"),
new Object[]{nftOrderFailLogVo.getNftOrderPayId(),nftOrderFailLogVo.getUserId(),nftOrderFailLogVo.getNftId(),nftOrderFailLogVo.getNftName(),nftOrderFailLogVo.getSeriesName(),
nftOrderFailLogVo.getSeriesId(),nftOrderFailLogVo.getSeriesCode(),nftOrderFailLogVo.getTaskId(),nftOrderFailLogVo.getFailReasonDesc(),nftOrderFailLogVo.getFailReasonDescSecond(),
nftOrderFailLogVo.getDealWithStatus(),nftOrderFailLogVo.getTradeType(),nftOrderFailLogVo.getRouterType(),LocalDateTime.now(),null
}
, MQConst.GalaxyQueue.SQL_NFT_ORDER_FAIL_LOG.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#setNftOrderFailLogVo error ==> MESSAGE:{}",e.getMessage());
}
}
public long incrNftIdNo(String routerType,String skuId) {
return this.getRedisUtil().incr(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId), 1);
}
public long getNftIdNo(String routerType,String skuId) {
Object o = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId));
return o==null?-1:(int)o;
}
/**
* 更新系列已购买信息
* @param routerType
* @param seriesCode
*/
public void updateSeriesCrtCount(String routerType,String seriesCode) {
GalaxySeriesInfoBo seriesInfoBo = this.getSeriesInfoBo(routerType,seriesCode);
seriesInfoBo.setCrtCount(seriesInfoBo.getCrtCount()+1);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES.concat(routerType).concat(":") + seriesCode,seriesInfoBo);
Query query = Query.query(Criteria.where("seriesCode").is(seriesInfoBo.getSeriesCode()));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesInfoVo.class,GalaxySeriesInfoVo.class.getSimpleName());
log.info("updateSeriesCrtCount result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_info.updateSeriesCrtCount"),
new Object[]{seriesInfoBo.getCrtCount(),LocalDateTime.now(),seriesCode}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#updateSeriesCrtCount error ==> MESSAGE:{}",e.getMessage());
}
}
/**
* 更新系列nft已购买信息
* @param routerType
* @param skuId
*/
public void updateSeriesNftCrtCount(String routerType,String skuId) {
GalaxySeriesNftInfoBo seriesNftInfoBo = this.getSeriesNftInfoBo(routerType,skuId);
seriesNftInfoBo.setNftCrtCount(seriesNftInfoBo.getNftCrtCount()+1);
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT.concat(routerType).concat(":") + skuId,seriesNftInfoBo);
Query query = Query.query(Criteria.where("skuId").is(skuId));
Update update = Update.fromDocument(Document.parse(JsonUtils.toJson(seriesNftInfoBo)));
String nowTimeStr = DateUtil.Formatter.yyyyMMddHHmmss.format(LocalDateTime.now());
update.set("updatedAt",nowTimeStr);
UpdateResult result = this.getMongoTemplate().updateFirst(query,update, GalaxySeriesNftInfoVo.class,GalaxySeriesNftInfoVo.class.getSimpleName());
log.info("updateSeriesNftCrtCount result:{}",result.toString());
try{
this.getQueueUtil().sendMySqlRedis(
SqlMapping.get("galaxy_series_nft_info.updateSeriesNftCrtCount"),
new Object[]{seriesNftInfoBo.getNftCrtCount(),LocalDateTime.now(),skuId}
, MQConst.GalaxyQueue.SQL_SERIES_INFO.getKey()
);
}catch(Exception e){
log.error(e.getMessage(),e);
log.error("#GalaxySeriesNftInfoBo error ==> MESSAGE:{}",e.getMessage());
}
}
public void setSeriesNftUploadTempSecretBo(String uploadSeriesName,GalaxySeriesNftUploadTempSecretBo seriesNftUploadTempSecretBo){
long keyExpireTime = 320;
this.getRedisUtil().set(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD_TEMP_SECRET.concat(":") + uploadSeriesName,seriesNftUploadTempSecretBo,keyExpireTime);
}
public GalaxySeriesNftUploadTempSecretBo getSeriesNftUploadTempSecretBo(String uploadSeriesName){
Object obj = this.getRedisUtil().get(GalaxyConstant.REDIS_KEY_GALAXY_SERIES_NFT_UPLOAD_TEMP_SECRET.concat(":") + uploadSeriesName);
if(obj!=null){
return (GalaxySeriesNftUploadTempSecretBo) obj;
}else{
return null;
}
}
}
......@@ -11,6 +11,8 @@ galaxy_nft_trade_info.insert=insert into galaxy_nft_trade_info (user_id, nft_id,
# ------------------------数字藏品发行购买失败记录----------------------------
galaxy_nft_order_fail_log.insert=insert into galaxy_nft_order_fail_log (nft_order_pay_id, user_id, nft_id, nft_name, series_name, series_id,series_code, taskId, fail_reason_desc, fail_reason_desc_second, deal_with_status, trade_type,router_type, created_at, updated_at)values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
# ------------------------更新用户注册信息----------------------------
galaxy_user_info.update=update galaxy_user_info set user_name = ?,id_card_type = ?,id_card = ?,mobile = ?,block_chain_address = ?,updated_at =? where router_type = ? and user_id = ?
# ------------------------更新系列声明信息----------------------------
galaxy_series_info.updateSeriesIdAndStatus=update galaxy_series_info t set t.series_id = ?,t.chain_timestamp = ?,t.trade_hash = ?,t.series_claim_status = ? ,t.updated_at =? where t.series_code = ?
# ------------------------更新系列NFT信息----------------------------
......@@ -26,3 +28,5 @@ galaxy_series_nft_info.updateSeriesNftCrtCount=update galaxy_series_nft_info t s
# ------------------------更新发行购买处理结果----------------------------
galaxy_nft_order_fail_log.updateDealWithStatus=update galaxy_nft_order_fail_log t set t.deal_with_status = ?,t.updated_at =? where t.nft_order_pay_id = ? and t.router_type = ?
# ------------------------同步用户数字账户信息到adam---------------------------
adam_user_busi_acct.add=INSERT INTO adam_user_busi_acct (`uid`, busi, uuid, `work`, ppwd, `state`, created_at) VALUES (?,?,?,?,?,?,?)
......@@ -67,6 +67,11 @@ public class GalaxyTradeController {
@ApiOperation(value = "NFT发行购买结果查询")
@PostMapping(value = {"nftPublishAndBuyResultQuery"})
public ResponseDto<GalaxyNftPublishAndBuyResultQueryRespDto> nftPublishAndBuyResultQuery(@Valid @RequestBody GalaxyNftPublishAndBuyResultQueryReqDto reqDto){
try {
Thread.sleep(2000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
return galaxyTradeService.nftPublishAndBuyResultQuery(reqDto);
}
......
......@@ -353,7 +353,12 @@ public class ZxinArtworkBiz {
seriesInfoBo.setTradeHash(resp.getData().getTxHash());
seriesInfoBo.setSeriesId(resp.getData().getSeriesId());
seriesInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据系列编号更新系列声明状态 1对多skuId
// dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据skuId更新系列声明状态 1对1
dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo,reqDto.getSkuId());
//设置成功返回参数
GalaxyArtSeriesClaimResultQueryRespDto resultQueryRespDto = this.buildGalaxyArtSeriesClaimResultQueryRespDto(reqDto,seriesInfoBo,ZxlnftEnum.TaskStatusEnum.TASK_SUCCESS.getCode());
......@@ -362,7 +367,14 @@ public class ZxinArtworkBiz {
}else if(resp.getData().getTaskStatus().toString().equals(ZxlnftEnum.TaskStatusEnum.TASK_FAIL.getCode())){
seriesInfoBo.setSeriesClaimStatus(GalaxyEnum.SeriesClaimStatusEnum.FAIL.getCode());
seriesInfoBo.setUpdatedAt(LocalDateTime.now());
dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据系列编号更新系列声明状态 1对多skuId
// dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo);
//根据skuId更新系列声明状态 1对1
dataUtils.updateSeriesClaimStatus(reqDto.getRouterType(),seriesCode,seriesInfoBo,reqDto.getSkuId());
return ResponseDto.failure(GalaxyErrorEnum.SERIES_CLAIM_ERROR.getCode(), GalaxyErrorEnum.SERIES_CLAIM_ERROR.getMessage());
}
}
......
package com.liquidnet.service.galaxy.router.zxin.biz;
import com.liquidnet.common.third.zxlnft.biz.ZxlnftBiz;
import com.liquidnet.common.third.zxlnft.constant.ZxlErrorEnum;
import com.liquidnet.common.third.zxlnft.dto.*;
import com.liquidnet.common.third.zxlnft.dto.Nft016IdentityBindQueryReqDto;
import com.liquidnet.common.third.zxlnft.dto.Nft016IdentityBindQueryRespDto;
import com.liquidnet.common.third.zxlnft.dto.ZxlnftResponseDto;
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.biz.GalaxyEnumBiz;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyUserInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserBindStatusQueryRespDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
......@@ -26,9 +18,6 @@ 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
......@@ -53,132 +42,11 @@ public class ZxinUserBiz {
@Autowired
private GalaxyDataUtils dataUtils;
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 = null;
Long index = 0L;
String userIdentification = null;
String address = null;
String userPubKey = null;
String userPriKey = null;
GalaxyUserInfoBo userInfoBo = dataUtils.getGalaxyUserInfo(reqDto.getRouterType(),userId);
if(userInfoBo!=null){
mnemonic = userInfoBo.getMnemonic();
}else{
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(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
respDto.setBlockChainAddress(address);
}else{
return ResponseDto.failure(nft016Resp.getMessage());
}
@Autowired
private ZxinUserCommonBiz zxinUserCommonBiz;
//构造缓存数据
if(userInfoBo==null){
userInfoBo = GalaxyUserInfoBo.getNew();
userInfoBo.setUserId(userId);
userInfoBo.setUserName(userName);
userInfoBo.setMobile(mobile);
userInfoBo.setIdCardType(idCardType);
userInfoBo.setIdCard(idCard);
userInfoBo.setMnemonic(mnemonic);
userInfoBo.setIndex(index.toString());
userInfoBo.setUserIdentification(userIdentification);
userInfoBo.setUserPubKey(userPubKey);
userInfoBo.setUserPriKey(userPriKey);
userInfoBo.setRouterType(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
userInfoBo.setBlockChainAddress(address);
dataUtils.setGalaxyUserInfo(reqDto.getRouterType(),reqDto.getUserId(),userInfoBo);
}
}
return ResponseDto.success(respDto);
public ResponseDto<GalaxyUserRegisterRespDto> userRegister(GalaxyUserRegisterReqDto reqDto) {
return zxinUserCommonBiz.userRegister(reqDto);
}
public ResponseDto<GalaxyUserBindStatusQueryRespDto> userBindStatusQuery(GalaxyUserBindStatusQueryReqDto reqDto){
......
......@@ -7,6 +7,8 @@ import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.IDCardUtil;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.service.IGoblinNftUserService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api;
......@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;
@Api(tags = "NFT:账号相关")
@Slf4j
......@@ -38,10 +41,10 @@ public class GoblinNFTUserController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "idCard", value = "身份证号"),
})
@PostMapping(value = "open/account")
public ResponseDto<Integer> openAccount(@Pattern(regexp = "\\b(NFT_ZX)\\b", message = "业务码无效")
public ResponseDto<GoblinUserNftAccInfoVo> openAccount(@Pattern(regexp = "\\b(NFT_ZX)\\b", message = "业务码无效")
@RequestParam String bizCode,
@RequestParam(required = true) String name,
@RequestParam(required = true) String idCard) {
@RequestParam String name,
@RequestParam String idCard) {
if (!java.util.regex.Pattern.matches(LnsRegex.Valid.CN_HANZI, name)) {
return ResponseDto.failure(ErrorMapping.get("140013"));
}
......@@ -51,10 +54,21 @@ public class GoblinNFTUserController {
if (IDCardUtil.getAge(idCard) < 18) {
return ResponseDto.failure(ErrorMapping.get("140010"));
}
try {
String currentUid = CurrentUtil.getCurrentUid();
String mobile = (String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE);
try {
if (goblinRedisUtils.isCertmetaJunk(1, idCard, name, mobile)) {// 实名认证失败缓存命中
return ResponseDto.failure(ErrorMapping.get("140016"));
}
GoblinUserNftAccInfoVo openAccountInfo = goblinRedisUtils.getOpenAccountInfo(currentUid);
if (null != openAccountInfo) {// 已申请开通或开通处理中
String code = openAccountInfo.getCode();
if (!"3000".equals(code) && !"3001".equals(code)) { // 不可重试
return ResponseDto.success(openAccountInfo);
}
}
return goblinNftUserService.openNftAccount(currentUid, bizCode, name, idCard, mobile);
} catch (Exception e) {
if (e instanceof LiquidnetServiceException) {
......@@ -66,9 +80,21 @@ public class GoblinNFTUserController {
}
@ApiOperationSupport(order = 11)
@ApiOperation(value = "业务账号是否开通")
@ApiOperation(value = "业务账号是否开通 废弃")
@GetMapping(value = "open/account")
public ResponseDto<Boolean> openAccount() {
return ResponseDto.success(goblinRedisUtils.getNftNumAccount(CurrentUtil.getCurrentUid()));
}
@ApiOperationSupport(order = 11)
@ApiOperation(value = "业务账号开通信息")
@GetMapping(value = "open/account/info")
public ResponseDto<GoblinUserNftAccInfoVo> openAccountInfo() {
/*GoblinUserNftAccInfoVo nftAccInfoVo = GoblinUserNftAccInfoVo.getNew();
nftAccInfoVo.setCode(NftAccStatusEnum.StatusAcc.ING.getCode());
nftAccInfoVo.setMsg(NftAccStatusEnum.StatusAcc.ING.getMsg());
nftAccInfoVo.setTime(LocalDateTime.now());
goblinRedisUtils.setOpenAccountInfo(CurrentUtil.getCurrentUid(), nftAccInfoVo);*/
return ResponseDto.success(goblinRedisUtils.getOpenAccountInfo(CurrentUtil.getCurrentUid()));
}
}
package com.liquidnet.service.goblin.service.impl;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.adam.constant.AdamEnum;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
......@@ -9,6 +10,8 @@ import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyUserRegisterRespDto;
import com.liquidnet.service.galaxy.service.IGalaxyUserService;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.service.IGoblinNftUserService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.QueueUtils;
......@@ -30,8 +33,8 @@ public class GoblinNftUserServiceImpl implements IGoblinNftUserService {
private IGalaxyUserService galaxyUserService;
@Override
public ResponseDto<Integer> openNftAccount(String uid, String bizCode, String name, String idCard, String mobile) {
if (goblinRedisUtils.getNftNumAccount(uid)) return ResponseDto.success(1);
public ResponseDto<GoblinUserNftAccInfoVo> openNftAccount(String uid, String bizCode, String name, String idCard, String mobile) {
GoblinUserNftAccInfoVo openAccountInfo;
switch (bizCode) {
case "NFT_ZX":
GalaxyUserRegisterReqDto userRegisterReqDto = GalaxyUserRegisterReqDto.getNew();
......@@ -39,25 +42,23 @@ public class GoblinNftUserServiceImpl implements IGoblinNftUserService {
userRegisterReqDto.setUserName(name);
userRegisterReqDto.setIdCard(idCard);
userRegisterReqDto.setMobile(mobile);
userRegisterReqDto.setIdCardType("1");
userRegisterReqDto.setIdCardType("1");// 同步com.liquidnet.service.galaxy.constant.GalaxyEnum.CardTypeEnum
userRegisterReqDto.setRouterType(GalaxyEnum.RouterTypeEnum.ZXINCHAIN.getCode());
ResponseDto<GalaxyUserRegisterRespDto> userRegisterRespDto = galaxyUserService.userRegister(userRegisterReqDto);
if (userRegisterRespDto.isSuccess()) {
goblinRedisUtils.setNftNumAccount(uid);
// galaxyUserService.userRegister(userRegisterReqDto);
queueUtils.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_USER_REGISTER.getKey(), JsonUtils.toJson(userRegisterReqDto));
GalaxyUserRegisterRespDto userRegisterRespDtoData = userRegisterRespDto.getData();
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("adam_user_busi_acct.add", uid, AdamEnum.BizAcct.NFT_ZX.name(), userRegisterRespDtoData.getBlockChainAddress(), null, null, 1, LocalDateTime.now())
);
return ResponseDto.success(1);
}
openAccountInfo = GoblinUserNftAccInfoVo.getNew();
openAccountInfo.setCode(NftAccStatusEnum.StatusAcc.ING.getCode());
openAccountInfo.setMsg(NftAccStatusEnum.StatusAcc.ING.getMsg());
break;
default:
log.warn("#开通业务账号:无效的业务码[UID={},bizCode={}]", bizCode, uid);
break;
}
log.warn("#开通业务账号:无效的业务码[UID={},bizCode={},name={},idCard={},mobile={}]", uid, bizCode, name, idCard, mobile);
return ResponseDto.failure(ErrorMapping.get("140015"));
}
openAccountInfo.setTime(LocalDateTime.now());
goblinRedisUtils.setOpenAccountInfo(uid, openAccountInfo);
return ResponseDto.success(openAccountInfo);
}
}
package com.liquidnet.service.goblin.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.RandomUtil;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinGoodsAnticipateValueVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.vo.*;
......@@ -2018,12 +2017,6 @@ public class GoblinRedisUtils {
redisUtil.set(redisKey, spuList);
}
// 记录用户开通数字账户
public void setNftNumAccount(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT.concat(userId);
redisUtil.set(redisKey, 1);
}
public boolean getNftNumAccount(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT.concat(userId);
Object obj = redisUtil.get(redisKey);
......@@ -2034,6 +2027,20 @@ public class GoblinRedisUtils {
}
}
public GoblinUserNftAccInfoVo getOpenAccountInfo(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(userId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return null;
} else {
return (GoblinUserNftAccInfoVo) obj;
}
}
public void setOpenAccountInfo(String userId, GoblinUserNftAccInfoVo nftAccInfoVo) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(userId);
redisUtil.set(redisKey, nftAccInfoVo);
}
public int getIsExchange(String skuId) {
String redisKey = GoblinRedisConst.ACTIVITY_SKU_TIME.concat(skuId);
Object obj = redisUtil.get(redisKey);
......@@ -2232,6 +2239,29 @@ public class GoblinRedisUtils {
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | NFT三要素认证缓存的<ID_TYPE+ID_NO, "ID_NAME,MOBILE"> */
public boolean setCertmetaJunk(int idType, String idNo, String idName, String mobile) {
return redisUtil.set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK + idType + idNo, idName.concat(",").concat(mobile), 604800);
}
public boolean isCertmetaJunk(int idType, String idNo, String idName, String mobile) {
String val = (String) redisUtil.get(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA_JUNK + idType + idNo);
return !StringUtils.isEmpty(val) && val.equals(idName.concat(",").concat(mobile));
}
public boolean setCertmeta(int idType, String idNo, String idName, String mobile) {
return redisUtil.set(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA + idType + idNo, idName.concat(",").concat(mobile));
}
public int isCertmeta(int idType, String idNo, String idName, String mobile) {
String o = (String) redisUtil.get(GoblinRedisConst.REDIS_GOBLIN_NFT_CERTMETA + idType + idNo);
if (StringUtils.isEmpty(o)) {
return -1;
}
return o.equals(idName.concat(",").concat(mobile)) ? 1 : 0;
}
/* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */
}
......@@ -16,6 +16,7 @@
140013=\u8EAB\u4EFD\u8BC1\u59D3\u540D\u4E0D\u5408\u89C4
140014=\u8EAB\u4EFD\u8BC1\u53F7\u7801\u4E0D\u5408\u89C4
140015=\u8D26\u53F7\u5F00\u901A\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u5BA2\u670D
140016=\u8BC1\u4EF6\u4FE1\u606F\u6216\u624B\u673A\u53F7\u4E0D\u4E00\u81F4
......
......@@ -3,12 +3,15 @@ package com.liquidnet.service.order.service.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.UserPathDto;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinNftOrder;
import com.liquidnet.service.goblin.param.GoblinNftOrderPayAgainParam;
......@@ -23,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import java.math.BigDecimal;
import java.math.RoundingMode;
......@@ -65,8 +69,8 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
} else {
try {
// 认证验证
boolean numAccount = goblinRedisUtils.getNftNumAccount(uid);
if (!numAccount) {
GoblinUserNftAccInfoVo openAccountInfo = goblinRedisUtils.getOpenAccountInfo(uid);
if (null == openAccountInfo || !NftAccStatusEnum.StatusAcc.SUCCESS.getCode().equals(openAccountInfo.getCode())) {
return ResponseDto.failure("您还未开通数字账户~");
}
......@@ -530,75 +534,73 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
return ResponseDto.failure("暂不支持此接口");
/*String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now();
//检查订单时间 是否关闭
GoblinStoreOrderVo storeOrderVo = goblinRedisUtils.getGoblinOrder(param.getOrderId());
if (storeOrderVo == null) {
GoblinNftOrderVo nftOrder = nftOrderUtils.getNftOrder(param.getOrderId());
// 检查订单时间
if (nftOrder == null) {
return ResponseDto.failure("订单不存在");
}
if (!storeOrderVo.getUserId().equals(uid)) {
if (!nftOrder.getUserId().equals(uid)) {
return ResponseDto.failure(ErrorMapping.get("20003"));
}
if (storeOrderVo.getStatus() != GoblinStatusConst.Status.ORDER_STATUS_0.getValue()) {
return ResponseDto.failure("订单无法支付");//订单
if (nftOrder.getStatus() != GoblinStatusConst.Status.ORDER_STATUS_0.getValue()) {
return ResponseDto.failure("当前订单状态不支持支付");
}
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
String returnCheckData = HttpUtil.get(checkUrl + "?code=" + storeOrderVo.getPayCode(), null, header);
String returnCheckData = HttpUtil.get(checkUrl + "?code=" + nftOrder.getPayCode(), null, header);
ResponseDto<GoblinPayInnerResultVo> checkVo = JsonUtils.fromJson(returnCheckData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() {
});
if (checkVo.getData().getStatus() == 1) {
return ResponseDto.failure("订单已支付");
}
BigDecimal price = BigDecimal.ZERO;
String[] orderIds = goblinRedisUtils.getMasterCode(storeOrderVo.getMasterOrderCode());
for (String orderId : orderIds) {
GoblinStoreOrderVo orderVo = goblinRedisUtils.getGoblinOrder(orderId);
price = price.add(orderVo.getPriceActual());
}
// 获取支付参数
GoblinNftPayResultVo NftPayResultVo = GoblinNftPayResultVo.getNew();
if (!storeOrderVo.getPayType().equals("FREE")) {
if (!nftOrder.getPayType().equals("FREE")) {
// 调用支付
LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString();
httpData.add("type", "PRODUCT");
httpData.add("price", price.toString());
httpData.add("name", goblinRedisUtils.getStoreInfoVo(storeOrderVo.getStoreId()).getStoreName());
httpData.add("detail", "查找最初订单");
httpData.add("orderCode", storeOrderVo.getMasterOrderCode());
httpData.add("clientIp", storeOrderVo.getIpAddress());
httpData.add("type", "NFT");
httpData.add("price", nftOrder.getPriceActual().toString());
httpData.add("name", nftOrder.getStoreName());
httpData.add("detail", nftOrder.getSkuTitle());
httpData.add("orderCode", nftOrder.getOrderCode());
httpData.add("clientIp", nftOrder.getIpAddress());
httpData.add("notifyUrl", synUrl);
httpData.add("createDate", storeOrderVo.getCreatedAt());
httpData.add("expireTime", storeOrderVo.getPayCountdownMinute().toString());
httpData.add("createDate", nftOrder.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
httpData.add("expireTime", nftOrder.getPayCountdownMinute().toString());
httpData.add("payType", param.getPayType());
httpData.add("deviceFrom", param.getDeviceFrom());
if (param.getDeviceFrom().equals("js") || param.getDeviceFrom().equals("applet")) {
httpData.add("openId", param.getOpenId());
}
httpData.add("showUrl", param.getShowUrl() + storeOrderVo.getMasterOrderCode());
httpData.add("returnUrl", param.getReturnUrl() + storeOrderVo.getMasterOrderCode());
String showUrl = param.getShowUrl().concat(nftOrder.getOrderCode());
String returnUrl = param.getReturnUrl().concat(nftOrder.getOrderCode());
httpData.add("showUrl", showUrl);
httpData.add("returnUrl", returnUrl);
String returnData = HttpUtil.post(payUrl, httpData);
log.debug("调用 DRAGON 结果 = " + returnData);
log.info("调用 DRAGON 结果 = " + returnData);
ResponseDto<GoblinPayInnerResultVo> dto = JsonUtils.fromJson(returnData, new TypeReference<ResponseDto<GoblinPayInnerResultVo>>() {
});
NftPayResultVo.setCode(dto.getData().getCode());
NftPayResultVo.setOrderCode(storeOrderVo.getMasterOrderCode());
GoblinPayInnerResultVo dtoData = dto.getData();
String payCode = dtoData.getCode();
NftPayResultVo.setCode(payCode);
NftPayResultVo.setOrderCode(nftOrder.getOrderCode());
NftPayResultVo.setPayData(dto.getData().getPayData());
NftPayResultVo.setOrderId(storeOrderVo.getMasterOrderCode());
NftPayResultVo.setPayType(param.getPayType());
NftPayResultVo.setPrice(price);
NftPayResultVo.setShowUrl(param.getShowUrl() + storeOrderVo.getMasterOrderCode());
NftPayResultVo.setReturnUrl(param.getReturnUrl() + storeOrderVo.getMasterOrderCode());
//redis
storeOrderVo.setPayType(param.getPayType());
storeOrderVo.setDeviceFrom(param.getDeviceFrom());
storeOrderVo.setPayCode(NftPayResultVo.getCode());
goblinRedisUtils.setGoblinOrder(storeOrderVo.getOrderId(), storeOrderVo);
//mongo
goblinMongoUtils.updateGoblinStoreOrderVo(storeOrderVo.getOrderId(), storeOrderVo);
//mysql
NftPayResultVo.setOrderId(nftOrder.getOrderId());
NftPayResultVo.setPayData(dtoData.getPayData());
NftPayResultVo.setPayType(nftOrder.getPayType());
NftPayResultVo.setPrice(nftOrder.getPriceActual());
NftPayResultVo.setShowUrl(showUrl);
NftPayResultVo.setReturnUrl(returnUrl);
// redis
nftOrder.setPayType(param.getPayType());
nftOrder.setDeviceFrom(param.getDeviceFrom());
nftOrder.setPayCode(NftPayResultVo.getCode());
nftOrderUtils.setNftOrder(nftOrder);
// mongo
goblinOrderUtils.setMongoList(GoblinNftOrderVo.class.getSimpleName(), "orderId", nftOrder.getOrderId(), GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_INFO, 2);
// mysql
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_AGAIN.getKey(),
SqlMapping.get("goblin_order.pay.again", param.getPayType(), param.getDeviceFrom(), NftPayResultVo.getCode(), param.getOrderId(), now, now));
log.info(UserPathDto.setData("再次支付[新支付方式]", param, NftPayResultVo));
......
......@@ -6,6 +6,7 @@ import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -623,13 +624,13 @@ public class GoblinRedisUtils {
}
}
public boolean getNftNumAccount(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT.concat(userId);
public GoblinUserNftAccInfoVo getOpenAccountInfo(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_NUM_ACCOUNT_INFO.concat(userId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return false;
return null;
} else {
return true;
return (GoblinUserNftAccInfoVo) obj;
}
}
......
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