Просмотр исходного кода

mq

(cherry picked from commit 5ae8f10840565280bb9fc4c671bf2357f8a69eba)
xiongzhu 3 лет назад
Родитель
Сommit
9cd70148dd

+ 19 - 1
pom.xml

@@ -404,7 +404,25 @@
         <dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <groupId>com.alibaba</groupId>
             <artifactId>druid-spring-boot-starter</artifactId>
             <artifactId>druid-spring-boot-starter</artifactId>
-            <version>1.1.21</version>
+            <version>1.2.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-spring-boot-starter</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-validator</groupId>
+            <artifactId>commons-validator</artifactId>
+            <version>1.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-core</artifactId>
+            <version>5.7.21</version>
         </dependency>
         </dependency>
     </dependencies>
     </dependencies>
 
 

+ 18 - 5
src/main/java/com/izouma/nineth/config/GeneralProperties.java

@@ -6,9 +6,22 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 @ConfigurationProperties(prefix = "general")
 @ConfigurationProperties(prefix = "general")
 @Data
 @Data
 public class GeneralProperties {
 public class GeneralProperties {
-    private String host;
-    private String contractName;
-    private String name;
-    private String org;
-    private String shortName;
+    private String  host;
+    private String  contractName;
+    private String  name;
+    private String  org;
+    private String  shortName;
+    private String  createOrderGroup;
+    private String  createOrderTopic;
+    private String  updateStockGroup;
+    private String  updateStockTopic;
+    private String  updateSaleGroup;
+    private String  updateSaleTopic;
+    private String  orderNotifyGroup;
+    private String  orderNotifyTopic;
+    private String  mintGroup;
+    private String  mintTopic;
+    private boolean notifyServer;
+    private String  updateActivityStockGroup;
+    private String  updateActivityStockTopic;
 }
 }

+ 13 - 0
src/main/java/com/izouma/nineth/config/SnowflakeIdWorkerConfig.java

@@ -0,0 +1,13 @@
+package com.izouma.nineth.config;
+
+import com.izouma.nineth.utils.SnowflakeIdWorker;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SnowflakeIdWorkerConfig {
+    @Bean
+    public SnowflakeIdWorker snowflakeIdWorker() {
+        return new SnowflakeIdWorker(0, 0);
+    }
+}

+ 20 - 0
src/main/java/com/izouma/nineth/config/WebMvcConfig.java

@@ -1,9 +1,14 @@
 package com.izouma.nineth.config;
 package com.izouma.nineth.config;
 
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -13,6 +18,8 @@ import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spring.web.plugins.Docket;
 import springfox.documentation.spring.web.plugins.Docket;
 
 
+import java.util.List;
+
 @Configuration
 @Configuration
 @EnableConfigurationProperties(GeneralProperties.class)
 @EnableConfigurationProperties(GeneralProperties.class)
 public class WebMvcConfig implements WebMvcConfigurer {
 public class WebMvcConfig implements WebMvcConfigurer {
@@ -44,6 +51,19 @@ public class WebMvcConfig implements WebMvcConfigurer {
                 .build();
                 .build();
     }
     }
 
 
+    @Override
+    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+        converters.stream().filter(converter -> converter instanceof MappingJackson2HttpMessageConverter)
+                .forEach(converter -> {
+                    ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converter).getObjectMapper();
+                    SimpleModule simpleModule = new SimpleModule();
+                    simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
+                    simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
+                    objectMapper.registerModule(simpleModule);
+                    ((MappingJackson2HttpMessageConverter) converter).setObjectMapper(objectMapper);
+                });
+        System.out.println(converters);
+    }
     // @Bean
     // @Bean
     // public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
     // public MappingJackson2HttpMessageConverter getMappingJackson2HttpMessageConverter() {
     //     MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
     //     MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();

+ 31 - 0
src/main/java/com/izouma/nineth/event/AccountCreatedEvent.java

@@ -0,0 +1,31 @@
+package com.izouma.nineth.event;
+
+import com.izouma.nineth.dto.NFTAccount;
+import org.springframework.context.ApplicationEvent;
+
+public class AccountCreatedEvent extends ApplicationEvent {
+    private final Long       userId;
+    private final NFTAccount account;
+
+    /**
+     * Create a new {@code ApplicationEvent}.
+     *
+     * @param source  the object on which the event initially occurred or with
+     *                which the event is associated (never {@code null})
+     * @param userId
+     * @param account
+     */
+    public AccountCreatedEvent(Object source, Long userId, NFTAccount account) {
+        super(source);
+        this.userId = userId;
+        this.account = account;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public NFTAccount getAccount() {
+        return account;
+    }
+}

+ 30 - 0
src/main/java/com/izouma/nineth/listener/MintListener.java

@@ -0,0 +1,30 @@
+package com.izouma.nineth.listener;
+
+import com.izouma.nineth.service.AssetMintService;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.rocketmq.spring.annotation.ConsumeMode;
+import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
+import org.apache.rocketmq.spring.core.RocketMQListener;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+@AllArgsConstructor
+@RocketMQMessageListener(
+        consumerGroup = "${general.mint-group}",
+        topic = "${general.mint-topic}",
+        consumeMode = ConsumeMode.ORDERLY)
+//@ConditionalOnProperty(value = "general.notify-server", havingValue = "true")
+public class MintListener implements RocketMQListener<Long> {
+    private AssetMintService assetMintService;
+
+    @Override
+    public void onMessage(Long assetId) {
+        try {
+            assetMintService.mint(assetId);
+        } catch (Exception e) {
+            log.error("铸造失败 " + assetId, e);
+        }
+    }
+}

+ 3 - 3
src/main/java/com/izouma/nineth/service/AssetMintService.java

@@ -32,8 +32,9 @@ public class AssetMintService {
     private ApplicationContext applicationContext;
     private ApplicationContext applicationContext;
 
 
     @Async
     @Async
-    public void mint(Long assetId, Long userId) {
-        User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
+    public void mint(Long assetId) {
+        Asset asset = assetRepo.findById(assetId).orElseThrow(new BusinessException("asset不存在"));
+        User user = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("用户不存在"));
         if (StringUtils.isEmpty(user.getPublicKey())) {
         if (StringUtils.isEmpty(user.getPublicKey())) {
             NFTAccount account = nftService.createAccount(user.getUsername() + "_");
             NFTAccount account = nftService.createAccount(user.getUsername() + "_");
             user.setNftAccount(account.getAccountId());
             user.setNftAccount(account.getAccountId());
@@ -42,7 +43,6 @@ public class AssetMintService {
             userRepo.save(user);
             userRepo.save(user);
         }
         }
         try {
         try {
-            Asset asset = assetRepo.findById(assetId).orElseThrow(new BusinessException("asset不存在"));
             NFT nft = nftService.createToken(user.getNftAccount(), asset.getTokenId());
             NFT nft = nftService.createToken(user.getNftAccount(), asset.getTokenId());
             if (nft != null) {
             if (nft != null) {
                 asset.setTokenId(nft.getTokenId());
                 asset.setTokenId(nft.getTokenId());

+ 7 - 4
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -1,6 +1,7 @@
 package com.izouma.nineth.service;
 package com.izouma.nineth.service;
 
 
 import com.izouma.nineth.TokenHistory;
 import com.izouma.nineth.TokenHistory;
+import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.dto.PageQuery;
@@ -19,6 +20,7 @@ import com.izouma.nineth.utils.TokenUtils;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContext;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
@@ -43,8 +45,9 @@ public class AssetService {
     private ApplicationContext applicationContext;
     private ApplicationContext applicationContext;
     private OrderRepo          orderRepo;
     private OrderRepo          orderRepo;
     private TokenHistoryRepo   tokenHistoryRepo;
     private TokenHistoryRepo   tokenHistoryRepo;
-    private AssetMintService   assetMintService;
     private SysConfigService   sysConfigService;
     private SysConfigService   sysConfigService;
+    private RocketMQTemplate   rocketMQTemplate;
+    private GeneralProperties  generalProperties;
 
 
     public Page<Asset> all(PageQuery pageQuery) {
     public Page<Asset> all(PageQuery pageQuery) {
         return assetRepo.findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
         return assetRepo.findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
@@ -56,7 +59,7 @@ public class AssetService {
         asset.setNumber(number);
         asset.setNumber(number);
         asset.setOrderId(orderId);
         asset.setOrderId(orderId);
         asset.setPrice(price);
         asset.setPrice(price);
-        assetRepo.save(asset);
+        assetRepo.saveAndFlush(asset);
 
 
         tokenHistoryRepo.save(TokenHistory.builder()
         tokenHistoryRepo.save(TokenHistory.builder()
                 .tokenId(asset.getTokenId())
                 .tokenId(asset.getTokenId())
@@ -70,7 +73,7 @@ public class AssetService {
                 .price(price)
                 .price(price)
                 .projectId(asset.getProjectId())
                 .projectId(asset.getProjectId())
                 .build());
                 .build());
-        assetMintService.mint(asset);
+        rocketMQTemplate.syncSend(generalProperties.getMintTopic(), asset.getId());
         return asset;
         return asset;
     }
     }
 
 
@@ -94,7 +97,7 @@ public class AssetService {
                 .price(price)
                 .price(price)
                 .projectId(asset.getProjectId())
                 .projectId(asset.getProjectId())
                 .build());
                 .build());
-        assetMintService.mint(asset.getId(), user.getId());
+        rocketMQTemplate.syncSend(generalProperties.getMintTopic(), asset.getId());
         return asset;
         return asset;
     }
     }
 
 

+ 37 - 7
src/main/java/com/izouma/nineth/service/NFTService.java

@@ -10,21 +10,26 @@ import com.antfinancial.mychain.baas.tool.restclient.model.CallRestBizParam;
 import com.antfinancial.mychain.baas.tool.restclient.model.Method;
 import com.antfinancial.mychain.baas.tool.restclient.model.Method;
 import com.antfinancial.mychain.baas.tool.restclient.model.ReceiptDecoration;
 import com.antfinancial.mychain.baas.tool.restclient.model.ReceiptDecoration;
 import com.antfinancial.mychain.baas.tool.restclient.response.BaseResp;
 import com.antfinancial.mychain.baas.tool.restclient.response.BaseResp;
-import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.config.Constants;
 import com.izouma.nineth.config.Constants;
+import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.dto.NFT;
 import com.izouma.nineth.dto.NFT;
 import com.izouma.nineth.dto.NFTAccount;
 import com.izouma.nineth.dto.NFTAccount;
+import com.izouma.nineth.event.AccountCreatedEvent;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.utils.HashUtils;
 import com.izouma.nineth.utils.HashUtils;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.env.Environment;
 import org.springframework.retry.annotation.Backoff;
 import org.springframework.retry.annotation.Backoff;
 import org.springframework.retry.annotation.Retryable;
 import org.springframework.retry.annotation.Retryable;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import java.math.BigInteger;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
 @Service
 @Service
@@ -34,11 +39,30 @@ public class NFTService {
     private final RestClient           restClient;
     private final RestClient           restClient;
     private final RestClientProperties restClientProperties;
     private final RestClientProperties restClientProperties;
     private final GeneralProperties    generalProperties;
     private final GeneralProperties    generalProperties;
+    private final SnowflakeIdWorker    snowflakeIdWorker;
+    private final ApplicationContext   context;
+    private final Environment          env;
+
+    @Async
+    public void createAccount(Long userId) {
+        NFTAccount account = null;
+        for (int i = 0; i < 10; i++) {
+            try {
+                Thread.sleep(5000);
+                account = createAccount("account_" + userId);
+                break;
+            } catch (Exception e) {
+            }
+        }
+        if (account != null) {
+            context.publishEvent(new AccountCreatedEvent(this, userId, account));
+        }
+    }
 
 
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     public NFTAccount createAccount(String username) {
     public NFTAccount createAccount(String username) {
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(Constants.bizId)
                 .bizid(Constants.bizId)
                 .account(restClientProperties.getAccount())
                 .account(restClientProperties.getAccount())
                 .mykmsKeyId(restClientProperties.getKmsId())
                 .mykmsKeyId(restClientProperties.getKmsId())
@@ -64,11 +88,17 @@ public class NFTService {
 
 
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     public synchronized NFT createToken(String toAccount, String tokenId) throws Exception {
     public synchronized NFT createToken(String toAccount, String tokenId) throws Exception {
+        log.info("开始执行EVM合约mint, toAccount: {}, tokenId: {}", toAccount, tokenId);
+        if (Arrays.asList(env.getActiveProfiles()).contains("test")) {
+            NFT nft = new NFT("1", tokenId, new BigInteger("1"), new BigInteger("1"));
+            log.info("测试服生成假token {}", tokenId);
+            return nft;
+        }
         JSONArray jsonArray = new JSONArray();
         JSONArray jsonArray = new JSONArray();
         jsonArray.add(Utils.getIdentityByName(toAccount));
         jsonArray.add(Utils.getIdentityByName(toAccount));
         jsonArray.add(new BigInteger(tokenId, 16));
         jsonArray.add(new BigInteger(tokenId, 16));
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .account(restClientProperties.getAccount())
                 .contractName(generalProperties.getContractName())
                 .contractName(generalProperties.getContractName())
@@ -82,7 +112,7 @@ public class NFTService {
                 .build();
                 .build();
         BaseResp resp = restClient.bizChainCallWithReceipt(callRestBizParam);
         BaseResp resp = restClient.bizChainCallWithReceipt(callRestBizParam);
         if (!resp.isSuccess()) {
         if (!resp.isSuccess()) {
-            log.info("EVM合约执行失败: " + resp.getCode() + ", " + resp.getData());
+            log.info("EVM合约执行失败: code: {}, data: {}, toAccount: {}, tokenId: {}", resp.getCode(), resp.getData(), toAccount, tokenId);
         }
         }
         if ("200".equals(resp.getCode())) {
         if ("200".equals(resp.getCode())) {
             log.info("EVM合约执行成功");
             log.info("EVM合约执行成功");
@@ -95,18 +125,18 @@ public class NFTService {
             log.info("NFT生成成功 {}", nft);
             log.info("NFT生成成功 {}", nft);
             return nft;
             return nft;
         } else if ("211".equals(resp.getCode())) {
         } else if ("211".equals(resp.getCode())) {
-
+            log.error("EVM合约执行限流");
         } else if ("10201".equals(resp.getCode())) {
         } else if ("10201".equals(resp.getCode())) {
             // 异步交易未成功需要根据状态码判断交易状态
             // 异步交易未成功需要根据状态码判断交易状态
             ReceiptDecoration txReceipt = JSON.parseObject(resp.getData(), ReceiptDecoration.class);
             ReceiptDecoration txReceipt = JSON.parseObject(resp.getData(), ReceiptDecoration.class);
             String out = new String(matchAndReplaceNonEnglishChar(txReceipt.getOutput()));
             String out = new String(matchAndReplaceNonEnglishChar(txReceipt.getOutput()));
             // 异步交易未成功需要根据状态码判断交易状态
             // 异步交易未成功需要根据状态码判断交易状态
-            log.error("EVM合约执行未成功: {}, {}", resp.getCode(), out);
+            log.error("EVM合约执行未成功: code: {}, out: {}, tokenId: {}", resp.getCode(), out, tokenId);
             if (out.endsWith("ERC721: token already minted")) {
             if (out.endsWith("ERC721: token already minted")) {
                 return new NFT(txReceipt.getHash(), tokenId, txReceipt.getBlockNumber(), txReceipt.getGasUsed());
                 return new NFT(txReceipt.getHash(), tokenId, txReceipt.getBlockNumber(), txReceipt.getGasUsed());
             }
             }
         }
         }
-        throw new BusinessException("创建nft失败");
+        throw new BusinessException("执行EVM合约mint失败");
     }
     }
 
 
     public static byte[] matchAndReplaceNonEnglishChar(byte[] data) {
     public static byte[] matchAndReplaceNonEnglishChar(byte[] data) {

+ 16 - 1
src/main/java/com/izouma/nineth/service/UserService.java

@@ -12,6 +12,7 @@ import com.izouma.nineth.domain.User;
 import com.izouma.nineth.dto.*;
 import com.izouma.nineth.dto.*;
 import com.izouma.nineth.enums.AuthStatus;
 import com.izouma.nineth.enums.AuthStatus;
 import com.izouma.nineth.enums.AuthorityName;
 import com.izouma.nineth.enums.AuthorityName;
+import com.izouma.nineth.event.AccountCreatedEvent;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.*;
 import com.izouma.nineth.repo.*;
 import com.izouma.nineth.security.Authority;
 import com.izouma.nineth.security.Authority;
@@ -33,6 +34,7 @@ import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.context.event.EventListener;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.domain.Specification;
@@ -65,6 +67,7 @@ public class UserService {
     private UserBankCardRepo  userBankCardRepo;
     private UserBankCardRepo  userBankCardRepo;
     private CacheService      cacheService;
     private CacheService      cacheService;
     private InviteRepo        inviteRepo;
     private InviteRepo        inviteRepo;
+    private NFTService        nftService;
 
 
     @CacheEvict(value = "user", key = "#user.username")
     @CacheEvict(value = "user", key = "#user.username")
     public User update(User user) {
     public User update(User user) {
@@ -117,7 +120,19 @@ public class UserService {
         if (StringUtils.isNotBlank(userRegister.getPassword())) {
         if (StringUtils.isNotBlank(userRegister.getPassword())) {
             user.setPassword(new BCryptPasswordEncoder().encode(userRegister.getPassword()));
             user.setPassword(new BCryptPasswordEncoder().encode(userRegister.getPassword()));
         }
         }
-        return userRepo.save(user);
+        user = userRepo.saveAndFlush(user);
+        nftService.createAccount(user.getId());
+        return user;
+    }
+
+    @EventListener
+    public void accountCreated(AccountCreatedEvent event) {
+        userRepo.findById(event.getUserId()).ifPresent(user -> {
+            user.setNftAccount(event.getAccount().getAccountId());
+            user.setKmsId(event.getAccount().getAccountKmsId());
+            user.setPublicKey(event.getAccount().getPublicKey());
+            userRepo.save(user);
+        });
     }
     }
 
 
     public User phoneRegister(String phone, String code, String password) {
     public User phoneRegister(String phone, String code, String password) {

+ 49 - 1
src/main/resources/application.yaml

@@ -135,6 +135,18 @@ general:
   name: 第九空间
   name: 第九空间
   org: 广州麦塔沃司信息技术有限公司
   org: 广州麦塔沃司信息技术有限公司
   short-name: 麦塔沃司
   short-name: 麦塔沃司
+  create-order-group: create-order-group-dev
+  create-order-topic: create-order-topic-dev
+  update-stock-group: update-stock-group-dev
+  update-stock-topic: update-stock-topic-dev
+  update-sale-group: update-sale-group-dev
+  update-sale-topic: update-sale-topic-dev
+  order-notify-group: order-notify-group-dev
+  order-notify-topic: order-notify-topic-dev
+  mint-group: mint-group-dev
+  mint-topic: mint-topic-dev
+  update-activity-stock-group: update-activity-stock-group-dev
+  update-activity-stock-topic: update-activity-stock-topic-dev
 mychain:
 mychain:
   rest:
   rest:
     bizid: a00e36c5
     bizid: a00e36c5
@@ -192,11 +204,30 @@ adapay:
   app-public-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB
   app-public-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwN6xgd6Ad8v2hIIsQVnbt8a3JituR8o4Tc3B5WlcFR55bz4OMqrG/356Ur3cPbc2Fe8ArNd/0gZbC9q56Eb16JTkVNA/fye4SXznWxdyBPR7+guuJZHc/VW2fKH2lfZ2P3Tt0QkKZZoawYOGSMdIvO+WqK44updyax0ikK6JlNQIDAQAB
   wx-app-id:
   wx-app-id:
   notify-url: https://nfttest.9space.vip/notify/adapay
   notify-url: https://nfttest.9space.vip/notify/adapay
+rocketmq:
+  name-server: 112.74.34.84:9876
+  producer:
+    group: my-producer-dev
+    send-message-timeout: 30000
 ---
 ---
 
 
 spring:
 spring:
   profiles: test
   profiles: test
-
+general:
+  host: https://nfttest.9space.vip
+  create-order-group: create-order-group-test
+  create-order-topic: create-order-topic-test
+  update-stock-group: update-stock-group-test
+  update-stock-topic: update-stock-topic-test
+  update-sale-group: update-sale-group-test
+  update-sale-topic: update-sale-topic-test
+  order-notify-group: order-notify-group-test
+  order-notify-topic: order-notify-topic-test
+  mint-group: mint-group-test
+  mint-topic: mint-topic-test
+  update-activity-stock-group: update-activity-stock-group-test
+  update-activity-stock-topic: update-activity-stock-topic-test
+  notify-server: true
 ---
 ---
 
 
 spring:
 spring:
@@ -208,6 +239,19 @@ spring:
     database: 1
     database: 1
 general:
 general:
   host: https://nft.9space.vip
   host: https://nft.9space.vip
+  create-order-group: create-order-group
+  create-order-topic: create-order-topic
+  update-stock-group: update-stock-group
+  update-stock-topic: update-stock-topic
+  update-sale-group: update-sale-group
+  update-sale-topic: update-sale-topic
+  order-notify-group: order-notify-group
+  order-notify-topic: order-notify-topic
+  mint-group: mint-group
+  mint-topic: mint-topic
+  update-activity-stock-group: update-activity-stock-group
+  update-activity-stock-topic: update-activity-stock-topic
+  notify-server: true
 wx:
 wx:
   pay:
   pay:
     notify-url: https://nft.9space.vip/notify/order/weixin
     notify-url: https://nft.9space.vip/notify/order/weixin
@@ -218,3 +262,7 @@ alipay:
   return-url: https://nft.9space.vip/9th/home
   return-url: https://nft.9space.vip/9th/home
 adapay:
 adapay:
   notify-url: https://nft.9space.vip/notify/adapay
   notify-url: https://nft.9space.vip/notify/adapay
+rocketmq:
+  name-server: 172.31.167.5:9876
+  producer:
+    group: my-producer