Browse Source

Merge branch 'dev' of http://git.izouma.com/xiongzhu/raex_back into dev

licailing 4 years ago
parent
commit
91df1ec1d8

+ 8 - 0
src/main/java/com/izouma/nineth/service/NFTService.java

@@ -20,6 +20,7 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Hex;
 import org.springframework.context.ApplicationContext;
+import org.springframework.core.env.Environment;
 import org.springframework.retry.annotation.Backoff;
 import org.springframework.retry.annotation.Retryable;
 import org.springframework.scheduling.annotation.Async;
@@ -27,6 +28,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 @Service
@@ -38,6 +40,7 @@ public class NFTService {
     private final GeneralProperties    generalProperties;
     private final SnowflakeIdWorker    snowflakeIdWorker;
     private final ApplicationContext   context;
+    private final Environment          env;
 
     @Async
     public void createAccount(Long userId) {
@@ -85,6 +88,11 @@ public class NFTService {
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     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.add(Utils.getIdentityByName(toAccount));
         jsonArray.add(new BigInteger(tokenId, 16));

+ 7 - 0
src/main/java/com/izouma/nineth/web/OrderNotifyController.java

@@ -193,6 +193,13 @@ public class OrderNotifyController {
         }
     }
 
+    @PostMapping("/adapay/ordertest/{orderId}")
+    @ResponseBody
+    public void adapayNotifyTest(@PathVariable Long orderId, @RequestParam String transactionId) throws Exception {
+        rocketMQTemplate.syncSend(generalProperties.getOrderNotifyTopic(),
+                new OrderNotifyEvent(orderId, PayMethod.ALIPAY, transactionId, System.currentTimeMillis()));
+    }
+
     @PostMapping("/adapay/giftOrder/{orderId}")
     @ResponseBody
     public void adapayGiftNotify(@PathVariable Long orderId, HttpServletRequest request) {