xiongzhu il y a 4 ans
Parent
commit
1f893a7f3c
29 fichiers modifiés avec 353 ajouts et 121 suppressions
  1. 6 0
      src/main/java/com/izouma/nineth/config/GeneralProperties.java
  2. 13 0
      src/main/java/com/izouma/nineth/config/SnowflakeIdWorkerConfig.java
  3. 2 3
      src/main/java/com/izouma/nineth/domain/Order.java
  4. 15 0
      src/main/java/com/izouma/nineth/dto/CollectionStockAndSale.java
  5. 1 0
      src/main/java/com/izouma/nineth/event/CreateOrderEvent.java
  6. 25 5
      src/main/java/com/izouma/nineth/listener/CreateOrderListener.java
  7. 26 0
      src/main/java/com/izouma/nineth/listener/UpdateSaleListener.java
  8. 26 0
      src/main/java/com/izouma/nineth/listener/UpdateStockListener.java
  9. 20 0
      src/main/java/com/izouma/nineth/repo/CollectionRepo.java
  10. 3 0
      src/main/java/com/izouma/nineth/repo/UserRepo.java
  11. 8 0
      src/main/java/com/izouma/nineth/service/CacheService.java
  12. 41 2
      src/main/java/com/izouma/nineth/service/CollectionService.java
  13. 3 2
      src/main/java/com/izouma/nineth/service/GiftOrderService.java
  14. 6 5
      src/main/java/com/izouma/nineth/service/NFTService.java
  15. 46 37
      src/main/java/com/izouma/nineth/service/OrderService.java
  16. 7 2
      src/main/java/com/izouma/nineth/service/UserService.java
  17. 8 3
      src/main/java/com/izouma/nineth/web/CollectionController.java
  18. 14 7
      src/main/java/com/izouma/nineth/web/OrderController.java
  19. 7 6
      src/main/java/com/izouma/nineth/web/OrderNotifyController.java
  20. 14 0
      src/main/resources/application.yaml
  21. 31 11
      src/main/resources/logback-spring.xml
  22. 4 0
      src/main/vue/src/styles/app.less
  23. 2 2
      src/main/vue/src/views/BlindBoxList.vue
  24. 2 2
      src/main/vue/src/views/CollectionList.vue
  25. 4 4
      src/main/vue/src/views/OrderList.vue
  26. 2 2
      src/main/vue/src/views/UserList.vue
  27. 7 4
      src/test/java/com/izouma/nineth/RedisTest.java
  28. 5 21
      src/test/java/com/izouma/nineth/service/AdapayServiceTest.java
  29. 5 3
      src/test/java/com/izouma/nineth/service/NFTServiceTest.java

+ 6 - 0
src/main/java/com/izouma/nineth/config/GeneralProperties.java

@@ -11,4 +11,10 @@ public class GeneralProperties {
     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;
 }

+ 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);
+    }
+}

+ 2 - 3
src/main/java/com/izouma/nineth/domain/Order.java

@@ -18,7 +18,6 @@ import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import org.hibernate.annotations.GenericGenerator;
 import org.hibernate.envers.Audited;
 import org.springframework.data.annotation.CreatedBy;
 import org.springframework.data.annotation.CreatedDate;
@@ -46,8 +45,8 @@ import java.util.List;
 public class Order {
 
     @Id
-    @GenericGenerator(name = "custom-id", strategy = "com.izouma.nineth.utils.SnowflakeIdGenerator")
-    @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom-id")
+//    @GenericGenerator(name = "custom-id", strategy = "com.izouma.nineth.utils.SnowflakeIdGenerator")
+//    @GeneratedValue(strategy = GenerationType.AUTO, generator = "custom-id")
     private Long id;
 
     @JsonIgnore

+ 15 - 0
src/main/java/com/izouma/nineth/dto/CollectionStockAndSale.java

@@ -0,0 +1,15 @@
+package com.izouma.nineth.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class CollectionStockAndSale {
+    private Long id;
+    private int  stock;
+    private int  sale;
+
+}

+ 1 - 0
src/main/java/com/izouma/nineth/event/CreateOrderEvent.java

@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @NoArgsConstructor
 public class CreateOrderEvent {
+    private Long id;
     private Long userId;
     private Long collectionId;
     private int  qty;

+ 25 - 5
src/main/java/com/izouma/nineth/listener/CreateOrderListener.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.listener;
 
+import com.izouma.nineth.domain.Order;
 import com.izouma.nineth.event.CreateOrderEvent;
 import com.izouma.nineth.service.OrderService;
 import lombok.AllArgsConstructor;
@@ -7,19 +8,38 @@ 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.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 @Service
 @Slf4j
 @AllArgsConstructor
 @RocketMQMessageListener(
-        consumerGroup = "${general.create-order-group}", topic = "${general.create-order-topic}", consumeMode = ConsumeMode.CONCURRENTLY)
+        consumerGroup = "${general.create-order-group}",
+        topic = "${general.create-order-topic}",
+        consumeMode = ConsumeMode.CONCURRENTLY)
 public class CreateOrderListener implements RocketMQListener<CreateOrderEvent> {
-    private OrderService orderService;
+    private OrderService                  orderService;
+    private RedisTemplate<String, Object> redisTemplate;
 
     @Override
-    public void onMessage(CreateOrderEvent createOrderEvent) {
-        orderService.create(createOrderEvent.getUserId(), createOrderEvent.getCollectionId(), createOrderEvent.getQty(),
-                createOrderEvent.getAddressId(), createOrderEvent.getUserCouponId(), createOrderEvent.getInvitor());
+    public void onMessage(CreateOrderEvent event) {
+        log.info("收到订单创建消息: {}", event.getId());
+        Map<String, Object> map = new HashMap<>();
+        try {
+            Order order = orderService.create(event.getUserId(), event.getCollectionId(), event.getQty(),
+                    event.getAddressId(), event.getUserCouponId(), event.getInvitor(), event.getId());
+            map.put("success", true);
+            map.put("data", order);
+        } catch (Exception e) {
+            log.error("订单创建失败", e);
+            map.put("success", false);
+            map.put("data", e.getMessage());
+        }
+        redisTemplate.opsForValue().set("createOrder::" + event.getId(), map);
+
     }
 }

+ 26 - 0
src/main/java/com/izouma/nineth/listener/UpdateSaleListener.java

@@ -0,0 +1,26 @@
+package com.izouma.nineth.listener;
+
+import com.izouma.nineth.service.CollectionService;
+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.update-sale-group}",
+        topic = "${general.update-sale-topic}",
+        consumeMode = ConsumeMode.ORDERLY)
+public class UpdateSaleListener implements RocketMQListener<Long> {
+
+    private CollectionService collectionService;
+
+    @Override
+    public void onMessage(Long id) {
+        collectionService.syncSale(id);
+    }
+}

+ 26 - 0
src/main/java/com/izouma/nineth/listener/UpdateStockListener.java

@@ -0,0 +1,26 @@
+package com.izouma.nineth.listener;
+
+import com.izouma.nineth.service.CollectionService;
+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.update-stock-group}",
+        topic = "${general.update-stock-topic}",
+        consumeMode = ConsumeMode.ORDERLY)
+public class UpdateStockListener implements RocketMQListener<Long> {
+
+    private CollectionService collectionService;
+
+    @Override
+    public void onMessage(Long id) {
+        collectionService.syncStock(id);
+    }
+}

+ 20 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -1,6 +1,7 @@
 package com.izouma.nineth.repo;
 
 import com.izouma.nineth.domain.Collection;
+import com.izouma.nineth.dto.CollectionStockAndSale;
 import com.izouma.nineth.dto.RecommendCollection;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
@@ -91,4 +92,23 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     List<Collection> findByNameLike(String name);
 
     List<Collection> findByStockGreaterThan(int stock);
+
+    @Query("update Collection c set c.stock = ?2 where c.id = ?1")
+    @Transactional
+    @Modifying
+    int updateStock(Long id, int stock);
+
+    @Query("update Collection c set c.sale = ?2 where c.id = ?1")
+    @Transactional
+    @Modifying
+    int updateSale(Long id, int sale);
+
+    @Query("select c.stock from Collection c where c.id = ?1")
+    Integer getStock(Long id);
+
+    @Query("select c.sale from Collection c where c.id = ?1")
+    Integer getSale(Long id);
+
+    @Query("select new com.izouma.nineth.dto.CollectionStockAndSale(c.id, c.stock, c.sale) from Collection c where c.stock > 0")
+    List<CollectionStockAndSale> getStockAndSale();
 }

+ 3 - 0
src/main/java/com/izouma/nineth/repo/UserRepo.java

@@ -24,6 +24,9 @@ public interface UserRepo extends JpaRepository<User, Long>, JpaSpecificationExe
     @NonNull
     User save(@NonNull User user);
 
+    @Cacheable("userInfo")
+    Optional<User> findById(@NonNull Long id);
+
     @Cacheable("user")
     User findByUsernameAndDelFalse(String username);
 

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

@@ -20,4 +20,12 @@ public class CacheService {
     @CacheEvict(value = "user", key = "#username")
     public void clearUser(String username) {
     }
+
+    @CacheEvict(value = "userInfo", key = "#id")
+    public void clearUserInfo(Long id) {
+    }
+
+    @CacheEvict(value = "recommend", allEntries = true)
+    public void clearRecommend() {
+    }
 }

+ 41 - 2
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -1,9 +1,11 @@
 package com.izouma.nineth.service;
 
 import com.alibaba.fastjson.JSON;
+import com.izouma.nineth.config.GeneralProperties;
 import com.izouma.nineth.domain.Collection;
 import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.CollectionDTO;
+import com.izouma.nineth.dto.CollectionStockAndSale;
 import com.izouma.nineth.dto.CreateBlindBox;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.enums.CollectionSource;
@@ -53,6 +55,7 @@ public class CollectionService {
     private CacheService                  cacheService;
     private RedisTemplate<String, Object> redisTemplate;
     private RocketMQTemplate              rocketMQTemplate;
+    private GeneralProperties             generalProperties;
 
     private final Map<Long, ScheduledFuture<?>> tasks = new HashMap<>();
 
@@ -62,9 +65,9 @@ public class CollectionService {
         for (Collection collection : collections) {
             onShelfTask(collection);
         }
-        for (Collection collection : collectionRepo.findByStockGreaterThan(0)) {
+        for (CollectionStockAndSale collection : collectionRepo.getStockAndSale()) {
             redisTemplate.opsForValue().set("collectionStock::" + collection.getId(), collection.getStock());
-            redisTemplate.opsForValue().set("collectionSale::" + collection.getId(), collection.getStock());
+            redisTemplate.opsForValue().set("collectionSale::" + collection.getId(), collection.getSale());
         }
     }
 
@@ -123,6 +126,8 @@ public class CollectionService {
         }
         record = collectionRepo.save(record);
         onShelfTask(record);
+        redisTemplate.opsForValue().set("collectionStock::" + record.getId(), record.getStock());
+        redisTemplate.opsForValue().set("collectionSale::" + record.getId(), record.getSale());
         return record;
     }
 
@@ -132,6 +137,7 @@ public class CollectionService {
                 record.getDetail(), JSON.toJSONString(record.getPrivileges()),
                 JSON.toJSONString(record.getProperties()), JSON.toJSONString(record.getModel3d()),
                 record.getMaxCount(), record.getCountId(), record.isScanCode());
+
         record = collectionRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
         onShelfTask(record);
         return record;
@@ -338,22 +344,55 @@ public class CollectionService {
     }
 
     public Long increaseStock(Long id, int number) {
+        if (redisTemplate.opsForValue().get("collectionStock::" + id) == null) {
+            redisTemplate.opsForValue().set("collectionStock::" + id, collectionRepo.getStock(id));
+        }
         Long stock = redisTemplate.opsForValue().increment("collectionStock::" + id, number);
         return stock;
     }
 
     public Long decreaseStock(Long id, int number) {
+        if (redisTemplate.opsForValue().get("collectionStock::" + id) == null) {
+            redisTemplate.opsForValue().set("collectionStock::" + id, collectionRepo.getStock(id));
+        }
         Long stock = redisTemplate.opsForValue().decrement("collectionStock::" + id, number);
+        rocketMQTemplate.convertAndSend(generalProperties.getUpdateStockTopic(), id);
         return stock;
     }
 
     public Long increaseSale(Long id, int number) {
+        if (redisTemplate.opsForValue().get("collectionSale::" + id) == null) {
+            redisTemplate.opsForValue().set("collectionSale::" + id, collectionRepo.getSale(id));
+        }
         Long sale = redisTemplate.opsForValue().increment("collectionSale::" + id, number);
+        rocketMQTemplate.convertAndSend(generalProperties.getUpdateSaleGroup(), id);
         return sale;
     }
 
     public Long decreaseSale(Long id, int number) {
+        if (redisTemplate.opsForValue().get("collectionSale::" + id) == null) {
+            redisTemplate.opsForValue().set("collectionSale::" + id, collectionRepo.getSale(id));
+        }
         Long sale = redisTemplate.opsForValue().decrement("collectionSale::" + id, number);
+        rocketMQTemplate.convertAndSend(generalProperties.getUpdateSaleGroup(), id);
         return sale;
     }
+
+    public void syncStock(Long id) {
+        Integer stock = (Integer) redisTemplate.opsForValue().get("collectionStock::" + id);
+        if (stock != null) {
+            log.info("同步库存信息{}", id);
+            collectionRepo.updateStock(id, stock);
+            cacheService.clearCollection(id);
+        }
+    }
+
+    public void syncSale(Long id) {
+        Integer sale = (Integer) redisTemplate.opsForValue().get("collectionSale::" + id);
+        if (sale != null) {
+            log.info("同步销量信息{}", id);
+            collectionRepo.updateSale(id, sale);
+            cacheService.clearCollection(id);
+        }
+    }
 }

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

@@ -68,6 +68,7 @@ public class GiftOrderService {
     private AssetService      assetService;
     private AdapayProperties  adapayProperties;
     private GeneralProperties generalProperties;
+    private SnowflakeIdWorker snowflakeIdWorker;
 
     @Transactional
     public GiftOrder gift(Long userId, Long assetId, Long toUserId) {
@@ -132,7 +133,7 @@ public class GiftOrderService {
             JSONObject bizContent = new JSONObject();
             bizContent.put("notifyUrl", alipayProperties.getNotifyUrl());
             bizContent.put("returnUrl", alipayProperties.getReturnUrl());
-            bizContent.put("out_trade_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
+            bizContent.put("out_trade_no", String.valueOf(snowflakeIdWorker.nextId()));
             bizContent.put("total_amount", order.getGasPrice().stripTrailingZeros().toPlainString());
             bizContent.put("disable_pay_channels", "pcredit,creditCard");
             if (Arrays.stream(env.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
@@ -208,7 +209,7 @@ public class GiftOrderService {
         }
 
         Map<String, Object> paymentParams = new HashMap<>();
-        paymentParams.put("order_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
+        paymentParams.put("order_no", String.valueOf(snowflakeIdWorker.nextId()));
         paymentParams.put("pay_amt", order.getGasPrice().setScale(2, RoundingMode.HALF_UP).toPlainString());
         paymentParams.put("app_id", adapayProperties.getAppId());
         paymentParams.put("pay_channel", payChannel);

+ 6 - 5
src/main/java/com/izouma/nineth/service/NFTService.java

@@ -33,11 +33,12 @@ public class NFTService {
     private final RestClient           restClient;
     private final RestClientProperties restClientProperties;
     private final GeneralProperties    generalProperties;
+    private final SnowflakeIdWorker    snowflakeIdWorker;
 
     @Retryable(maxAttempts = 10, backoff = @Backoff(delay = 5000), value = BusinessException.class)
     public NFTAccount createAccount(String username) {
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(Constants.bizId)
                 .account(restClientProperties.getAccount())
                 .mykmsKeyId(restClientProperties.getKmsId())
@@ -68,7 +69,7 @@ public class NFTService {
         jsonArray.add(Utils.getIdentityByName(toAccount));
         jsonArray.add(new BigInteger(tokenId, 16));
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName(generalProperties.getContractName())
@@ -125,7 +126,7 @@ public class NFTService {
 
     public String ownerOf(String tokenId) throws Exception {
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName(generalProperties.getContractName())
@@ -164,7 +165,7 @@ public class NFTService {
         jsonArray.add(Utils.getIdentityByName("9th_HCWWflAZ_"));
         jsonArray.add("95057808871064671354760012409081314299");
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName("raex12")
@@ -201,7 +202,7 @@ public class NFTService {
         jsonArray.add(true);
 
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName(generalProperties.getContractName())

+ 46 - 37
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -42,6 +42,7 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.context.event.EventListener;
 import org.springframework.core.env.Environment;
 import org.springframework.data.domain.Page;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.Model;
@@ -58,37 +59,43 @@ import java.util.*;
 @Slf4j
 public class OrderService {
 
-    private OrderRepo            orderRepo;
-    private CollectionRepo       collectionRepo;
-    private UserAddressRepo      userAddressRepo;
-    private UserRepo             userRepo;
-    private Environment          env;
-    private AlipayClient         alipayClient;
-    private AlipayProperties     alipayProperties;
-    private WxPayService         wxPayService;
-    private WxPayProperties      wxPayProperties;
-    private AssetService         assetService;
-    private SysConfigService     sysConfigService;
-    private BlindBoxItemRepo     blindBoxItemRepo;
-    private AssetRepo            assetRepo;
-    private UserCouponRepo       userCouponRepo;
-    private CollectionService    collectionService;
-    private CommissionRecordRepo commissionRecordRepo;
-    private AdapayProperties     adapayProperties;
-    private GeneralProperties    generalProperties;
-    private RocketMQTemplate     rocketMQTemplate;
+    private OrderRepo                     orderRepo;
+    private CollectionRepo                collectionRepo;
+    private UserAddressRepo               userAddressRepo;
+    private UserRepo                      userRepo;
+    private Environment                   env;
+    private AlipayClient                  alipayClient;
+    private AlipayProperties              alipayProperties;
+    private WxPayService                  wxPayService;
+    private WxPayProperties               wxPayProperties;
+    private AssetService                  assetService;
+    private SysConfigService              sysConfigService;
+    private BlindBoxItemRepo              blindBoxItemRepo;
+    private AssetRepo                     assetRepo;
+    private UserCouponRepo                userCouponRepo;
+    private CollectionService             collectionService;
+    private CommissionRecordRepo          commissionRecordRepo;
+    private AdapayProperties              adapayProperties;
+    private GeneralProperties             generalProperties;
+    private RocketMQTemplate              rocketMQTemplate;
+    private RedisTemplate<String, Object> redisTemplate;
+    private SnowflakeIdWorker             snowflakeIdWorker;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    public Object mqCreate(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
-        SendResult result = rocketMQTemplate.syncSend("create-order", new CreateOrderEvent(userId, collectionId, qty, addressId, userCouponId, invitor));
-        return result.getMsgId();
+    public String mqCreate(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
+        Long id = snowflakeIdWorker.nextId();
+        SendResult result = rocketMQTemplate.syncSend(generalProperties.getCreateOrderTopic(),
+                new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor), 100000);
+        log.info("发送订单到队列: {}, result={}", id, result);
+        return String.valueOf(id);
     }
 
     @Transactional
-    public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
+    public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor, Long id) {
+        long t = System.currentTimeMillis();
         qty = 1;
         int stock = Optional.ofNullable(collectionService.decreaseStock(collectionId, qty))
                 .map(Math::toIntExact)
@@ -143,6 +150,7 @@ public class OrderService {
 
             BigDecimal gasFee = sysConfigService.getBigDecimal("gas_fee");
             Order order = Order.builder()
+                    .id(Optional.ofNullable(id).orElse(snowflakeIdWorker.nextId()))
                     .userId(userId)
                     .collectionId(collectionId)
                     .name(collection.getName())
@@ -193,6 +201,8 @@ public class OrderService {
             if (order.getTotalPrice().equals(BigDecimal.ZERO)) {
                 notifyOrder(order.getId(), PayMethod.WEIXIN, null);
             }
+            rocketMQTemplate.syncSend(generalProperties.getUpdateStockTopic(), collectionId, 10000);
+            log.info("订单创建完成, id={}, {}ms", order.getId(), System.currentTimeMillis() - t);
             return order;
         } catch (Exception e) {
             collectionService.increaseStock(collectionId, qty);
@@ -211,7 +221,7 @@ public class OrderService {
             JSONObject bizContent = new JSONObject();
             bizContent.put("notifyUrl", alipayProperties.getNotifyUrl());
             bizContent.put("returnUrl", alipayProperties.getReturnUrl());
-            bizContent.put("out_trade_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
+            bizContent.put("out_trade_no", String.valueOf(snowflakeIdWorker.nextId()));
             bizContent.put("total_amount", order.getTotalPrice().stripTrailingZeros().toPlainString());
             bizContent.put("disable_pay_channels", "pcredit,creditCard");
             if (Arrays.stream(env.getActiveProfiles()).noneMatch(s -> s.equals("prod"))) {
@@ -295,7 +305,7 @@ public class OrderService {
         }
 
         Map<String, Object> paymentParams = new HashMap<>();
-        paymentParams.put("order_no", String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
+        paymentParams.put("order_no", String.valueOf(snowflakeIdWorker.nextId()));
         paymentParams.put("pay_amt", order.getTotalPrice().setScale(2, RoundingMode.HALF_UP).toPlainString());
         paymentParams.put("app_id", adapayProperties.getAppId());
         paymentParams.put("pay_channel", payChannel);
@@ -417,7 +427,6 @@ public class OrderService {
                 orderRepo.save(order);
                 assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
                         winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null);
-                addSales(winItem.getMinterId(), order.getQty());
             } else {
                 if (collection.getSource() == CollectionSource.TRANSFER) {
                     Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
@@ -428,11 +437,12 @@ public class OrderService {
                     assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
                             collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
                 }
-                addSales(collection.getMinterId(), order.getQty());
             }
             commission(order);
+            collectionService.increaseSale(order.getCollectionId(), order.getQty());
         } else if (order.getStatus() == OrderStatus.CANCELLED) {
         }
+
     }
 
     @EventListener
@@ -486,8 +496,7 @@ public class OrderService {
             }
             collectionRepo.setOnShelf(order.getCollectionId(), true);
         }
-        collectionService.decreaseStock(order.getCollectionId(), order.getQty());
-        collectionService.increaseSale(order.getCollectionId(), order.getQty());
+        collectionService.increaseStock(order.getCollectionId(), order.getQty());
 
         order.setStatus(OrderStatus.CANCELLED);
         order.setCancelTime(LocalDateTime.now());
@@ -500,6 +509,8 @@ public class OrderService {
                 userCouponRepo.save(coupon);
             });
         }
+        rocketMQTemplate.syncSend(generalProperties.getUpdateStockTopic(), order.getCollectionId(), 10000);
+        log.info("取消订单{}", order.getId());
     }
 
     @Scheduled(fixedRate = 30000)
@@ -509,7 +520,7 @@ public class OrderService {
         }
         List<Order> orders = orderRepo.findByStatusAndCreatedAtBeforeAndDelFalse(OrderStatus.NOT_PAID,
                 LocalDateTime.now().minusSeconds(210));
-        orders.forEach(o -> {
+        orders.parallelStream().forEach(o -> {
             try {
                 cancel(o);
             } catch (Exception ignored) {
@@ -520,12 +531,6 @@ public class OrderService {
     public void refundCancelled(Order order) {
     }
 
-    public synchronized void addSales(Long userId, int num) {
-        if (userId != null) {
-            userRepo.increaseSales(userId, num);
-        }
-    }
-
     public void setNumber() {
         for (Collection collection : collectionRepo.findAll()) {
             if (collection.getSource() != CollectionSource.OFFICIAL) continue;
@@ -585,7 +590,11 @@ public class OrderService {
         request.setTransactionId(order.getTransactionId());
         request.setTotalFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
         request.setRefundFee(order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
-        request.setOutRefundNo(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()));
+        request.setOutRefundNo(String.valueOf(snowflakeIdWorker.nextId()));
         wxPayService.refund(request);
     }
+
+    public Object queryCreateOrder(String id) {
+        return redisTemplate.opsForValue().get("createOrder::" + id);
+    }
 }

+ 7 - 2
src/main/java/com/izouma/nineth/service/UserService.java

@@ -67,11 +67,10 @@ public class UserService {
     private NFTService        nftService;
     private CacheService      cacheService;
 
-    @CacheEvict(value = "user", key = "#user.username")
     public User update(User user) {
         User orig = userRepo.findById(user.getId()).orElseThrow(new BusinessException("无记录"));
         ObjUtils.merge(orig, user);
-        orig = userRepo.save(orig);
+        orig = save(orig);
         userRepo.updateAssetMinter(orig.getId());
         userRepo.updateAssetOwner(orig.getId());
         userRepo.updateCollectionMinter(orig.getId());
@@ -83,6 +82,12 @@ public class UserService {
         return orig;
     }
 
+    public User save(User user) {
+        cacheService.clearUserInfo(user.getId());
+        cacheService.clearUser(user.getUsername());
+        return userRepo.save(user);
+    }
+
     public Page<User> all(PageQuery pageQuery) {
         Specification<User> specification = JpaUtils.toSpecification(pageQuery, User.class);
 

+ 8 - 3
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -14,7 +14,9 @@ import com.izouma.nineth.utils.excel.ExcelUtils;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
 
@@ -97,14 +99,17 @@ public class CollectionController extends BaseController {
     }
 
     @GetMapping("/recommend")
+    @Cacheable("recommend")
     public List<CollectionDTO> recommend(@RequestParam String type) {
-        return collectionService.toDTO(collectionRepo.recommend(type).stream().map(rc -> {
+        return collectionRepo.recommend(type).stream().map(rc -> {
             if (StringUtils.isNotBlank(rc.getRecommend().getPic())) {
                 rc.getCollection().setPic(Collections.singletonList(new FileObject(null, rc.getRecommend()
                         .getPic(), null, null)));
             }
-            return rc.getCollection();
-        }).collect(Collectors.toList()));
+            CollectionDTO collectionDTO = new CollectionDTO();
+            BeanUtils.copyProperties(rc.getCollection(), collectionDTO);
+            return collectionDTO;
+        }).collect(Collectors.toList());
     }
 }
 

+ 14 - 7
src/main/java/com/izouma/nineth/web/OrderController.java

@@ -82,16 +82,18 @@ public class OrderController extends BaseController {
                         @RequestParam(required = false) Long couponId,
                         @RequestParam(required = false) Long invitor) {
         return orderService.create(SecurityUtils.getAuthenticatedUser().getId(),
-                collectionId, qty, addressId, couponId, invitor);
+                collectionId, qty, addressId, couponId, invitor, null);
     }
 
     @PostMapping("/mqCreate")
-    public Order mqCreate(@RequestParam Long collectionId, @RequestParam int qty,
-                        @RequestParam(required = false) Long addressId,
-                        @RequestParam(required = false) Long couponId,
-                        @RequestParam(required = false) Long invitor) {
-        return orderService.create(SecurityUtils.getAuthenticatedUser().getId(),
-                collectionId, qty, addressId, couponId, invitor);
+    public HashMap<String, String> mqCreate(@RequestParam Long collectionId, @RequestParam int qty,
+                                            @RequestParam(required = false) Long addressId,
+                                            @RequestParam(required = false) Long couponId,
+                                            @RequestParam(required = false) Long invitor) {
+        return new HashMap<>() {{
+            put("id", orderService.mqCreate(SecurityUtils.getAuthenticatedUser().getId(),
+                    collectionId, qty, addressId, couponId, invitor));
+        }};
     }
 
     @PostMapping("/hide")
@@ -133,5 +135,10 @@ public class OrderController extends BaseController {
     public void testNotify(@RequestParam Long id) {
         orderService.notifyOrder(id, PayMethod.ALIPAY, new SnowflakeIdWorker(0, 0).nextId() + "");
     }
+
+    @GetMapping("/createResult")
+    public Object createResult(@RequestParam String eventId) {
+        return orderService.queryCreateOrder(eventId);
+    }
 }
 

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

@@ -36,11 +36,12 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.PrettyFormat;
 @AllArgsConstructor
 public class OrderNotifyController {
 
-    private final AlipayProperties alipayProperties;
-    private final OrderService     orderService;
-    private final WxPayService     wxPayService;
-    private final AssetService     assetService;
-    private final GiftOrderService giftOrderService;
+    private final AlipayProperties  alipayProperties;
+    private final OrderService      orderService;
+    private final WxPayService      wxPayService;
+    private final AssetService      assetService;
+    private final GiftOrderService  giftOrderService;
+    private final SnowflakeIdWorker snowflakeIdWorker;
 
     @PostMapping("/order/alipay")
     @ResponseBody
@@ -127,7 +128,7 @@ public class OrderNotifyController {
             status = jsonObject.getInteger("status");
         }
         if (status == 0) {
-            orderService.notifyOrder(orderId, PayMethod.WEIXIN, new SnowflakeIdWorker(0, 0).nextId() + "");
+            orderService.notifyOrder(orderId, PayMethod.WEIXIN, snowflakeIdWorker.nextId() + "");
         }
         return "ok";
     }

+ 14 - 0
src/main/resources/application.yaml

@@ -142,6 +142,8 @@ general:
   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
 mychain:
   rest:
     bizid: a00e36c5
@@ -194,6 +196,18 @@ spring:
     password: jV%93RtjUx82Tp
 ---
 
+spring:
+  profiles: local
+  datasource:
+    url: jdbc:mysql://192.168.50.10/raex_test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2b8
+    username: root
+    password: 123456
+  redis:
+    host: 192.168.50.16
+    database: 0
+    password:
+---
+
 spring:
   profiles: prod
   datasource:

+ 31 - 11
src/main/resources/logback-spring.xml

@@ -26,8 +26,30 @@
             </encoder>
         </appender>
 
-        <!-- ding open sdk log -->
-        <appender name="DING_OPEN_CLIENT_SDK_LOGGER_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
+<!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
+<!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
+<!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
+<!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
+<!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
+<!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
+    </springProfile>
+
+    <springProfile name="local">
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+            <encoder>
+                <pattern>${CONSOLE_LOG_PATTERN}</pattern>
+            </encoder>
+        </appender>
+        <root level="INFO">
+            <appender-ref ref="CONSOLE"/>
+        </root>
+        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>
+        <!--swagger 类型转换异常日志去除-->
+        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>
+        <logger name="org.freemarker" level="DEBUG"/>
+
+        <!-- dingding log -->
+        <appender name="HTTP_INVOKE_LOGGER_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
             <param name="append" value="true"/>
             <param name="encoding" value="UTF-8"/>
             <param name="threshold" value="INFO"/>
@@ -35,15 +57,13 @@
                 <pattern>${CONSOLE_LOG_PATTERN}</pattern>
             </encoder>
         </appender>
-        <logger name="HTTP_INVOKE_LOGGER" additivity="false">
-            <level value="WARN"/>
-            <appender-ref ref="HTTP_INVOKE_LOGGER_APPENDER"/>
-        </logger>
-        <logger name="DING_OPEN_CLIENT_SDK_LOGGER" additivity="false">
-            <level value="WARN"/>
-            <appender-ref ref="DING_OPEN_CLIENT_SDK_LOGGER_APPENDER"/>
-        </logger>
-        <!-- end of dingding log -->
+
+        <!--        <logger name="org.hibernate.SQL" level="DEBUG"/>-->
+        <!--        <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.JdbcTemplate" level="DEBUG"/>-->
+        <!--        <logger name="org.springframework.jdbc.core.StatementCreatorUtils" level="TRACE"/>-->
+        <!--        <logger name="cn.binarywang.wx.miniapp" level="DEBUG"/>-->
+        <!--        <logger name="io.swagger.models.parameters.AbstractSerializableParameter" level="ERROR"/>-->
     </springProfile>
 
     <springProfile name="test">

+ 4 - 0
src/main/vue/src/styles/app.less

@@ -82,6 +82,10 @@ li {
         margin-bottom: 10px;
         margin-right: 10px;
         margin-left: 0;
+        &.el-date-editor {
+            position: relative;
+            top: 1px;
+        }
     }
 
     .filter-item.el-input {

+ 2 - 2
src/main/vue/src/views/BlindBoxList.vue

@@ -21,8 +21,8 @@
             </el-button> -->
         </page-title>
         <div class="filters-container">
-            <created-at-picker v-model="createdAt" @input="getData" style="margin-right: 10px"></created-at-picker>
-            <minter-filter v-model="minterId" @input="getData"></minter-filter>
+            <created-at-picker v-model="createdAt" @input="getData" class="filter-item"></created-at-picker>
+            <minter-filter v-model="minterId" @input="getData" class="filter-item"></minter-filter>
             <el-input
                 placeholder="搜索..."
                 v-model="search"

+ 2 - 2
src/main/vue/src/views/CollectionList.vue

@@ -21,8 +21,8 @@
             </el-button> -->
         </page-title>
         <div class="filters-container">
-            <created-at-picker v-model="createdAt" @input="getData" style="margin-right:10px"></created-at-picker>
-            <minter-filter v-model="minterId" @input="getData"></minter-filter>
+            <created-at-picker v-model="createdAt" @input="getData" class="filter-item"></created-at-picker>
+            <minter-filter v-model="minterId" @input="getData" class="filter-item"></minter-filter>
             <el-input
                 placeholder="搜索..."
                 v-model="search"

+ 4 - 4
src/main/vue/src/views/OrderList.vue

@@ -21,7 +21,7 @@
             </el-button>
         </page-title>
         <div class="filters-container">
-            <el-select v-model="status" placeholder="筛选状态" clearable @change="getData" style="margin-right: 10px">
+            <el-select v-model="status" placeholder="筛选状态" clearable @change="getData" class="filter-item">
                 <el-option
                     v-for="item in statusOptions"
                     :key="item.value"
@@ -29,7 +29,7 @@
                     :label="item.label"
                 ></el-option>
             </el-select>
-            <created-at-picker v-model="createdAt" name="下单" @input="getData"></created-at-picker>
+            <created-at-picker v-model="createdAt" @input="getData" name="下单" class="filter-item"></created-at-picker>
             <el-input
                 placeholder="搜索..."
                 v-model="search"
@@ -52,10 +52,10 @@
             v-loading="fetchingData"
         >
             <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
-            <el-table-column prop="id" label="ID" width="100"> </el-table-column>
+            <el-table-column prop="id" label="ID" width="155"> </el-table-column>
             <el-table-column prop="userId" label="用户ID"> </el-table-column>
             <el-table-column prop="collectionId" label="藏品ID"> </el-table-column>
-            <el-table-column prop="name" label="名称" show-overflow-tooltip> </el-table-column>
+            <el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip> </el-table-column>
             <el-table-column prop="pic" label="图片" width="80">
                 <template slot-scope="{ row }">
                     <el-image

+ 2 - 2
src/main/vue/src/views/UserList.vue

@@ -9,7 +9,7 @@
             </el-button>
         </page-title>
         <div class="filters-container" @keyup.enter="getData">
-            <created-at-picker v-model="createdAt" name="注册" @input="getData"></created-at-picker>
+            <created-at-picker v-model="createdAt" @input="getData" name="注册" class="filter-item"></created-at-picker>
             <el-input placeholder="搜索..." v-model="search" clearable class="filter-item search">
                 <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
             </el-input>
@@ -173,7 +173,7 @@ export default {
                     .then(res => {
                         let el = document.createElement('div');
                         new ClipboardJS(el, {
-                            text: function (trigger) {
+                            text: function(trigger) {
                                 return res;
                             }
                         });

+ 7 - 4
src/test/java/com/izouma/nineth/RedisTest.java

@@ -2,7 +2,6 @@ package com.izouma.nineth;
 
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.BoundValueOperations;
 import org.springframework.data.redis.core.RedisTemplate;
 
 public class RedisTest extends ApplicationTests {
@@ -10,8 +9,12 @@ public class RedisTest extends ApplicationTests {
     private RedisTemplate<String, Object> redisTemplate;
 
     @Test
-    public void testINC() {
-        redisTemplate.opsForValue().increment("collectionNumber::2");
-        System.out.println(redisTemplate.opsForValue().get("collectionNumber::2"));
+    public void testOrder() {
+        System.out.println(redisTemplate.opsForValue().get("createOrder::931502789098471424"));
+    }
+
+    @Test
+    public void testasdf() {
+        System.out.println(redisTemplate.opsForValue().get("collectionStock::sdfasdf"));
     }
 }

+ 5 - 21
src/test/java/com/izouma/nineth/service/AdapayServiceTest.java

@@ -1,36 +1,18 @@
 package com.izouma.nineth.service;
 
 import com.alibaba.excel.EasyExcel;
-import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.huifu.adapay.Adapay;
 import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.model.AdapayCommon;
-import com.huifu.adapay.model.MerConfig;
-import com.huifu.adapay.model.Payment;
 import com.huifu.adapay.model.Refund;
 import com.izouma.nineth.ApplicationTests;
 import com.izouma.nineth.domain.AdaTrade;
 import com.izouma.nineth.repo.GiftOrderRepo;
 import com.izouma.nineth.repo.OrderRepo;
 import com.izouma.nineth.utils.SnowflakeIdWorker;
-import com.izouma.nineth.utils.excel.BigIntegerConverter;
-import com.izouma.nineth.utils.excel.LocalDateConverter;
-import com.izouma.nineth.utils.excel.LocalDateTimeConverter;
-import lombok.Data;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.math.BigDecimal;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,9 +22,11 @@ import java.util.stream.Collectors;
 
 public class AdapayServiceTest extends ApplicationTests {
     @Autowired
-    private OrderRepo     orderRepo;
+    private OrderRepo         orderRepo;
     @Autowired
-    private GiftOrderRepo giftOrderRepo;
+    private GiftOrderRepo     giftOrderRepo;
+    @Autowired
+    private SnowflakeIdWorker snowflakeIdWorker;
 
     private final String appId = "app_0e8d3acb-3d95-4ebb-8445-e470c378a787";
 
@@ -75,7 +59,7 @@ public class AdapayServiceTest extends ApplicationTests {
         for (AdaTrade adaTrade : list) {
             Map<String, Object> refundParams = new HashMap<>();
             refundParams.put("refund_amt", adaTrade.get交易金额());
-            refundParams.put("refund_order_no", new SnowflakeIdWorker(0, 0).nextId() + "");
+            refundParams.put("refund_order_no", snowflakeIdWorker.nextId() + "");
             try {
                 Map<String, Object> response = Refund.create(adaTrade.get订单号(), refundParams);
             } catch (BaseAdaPayException e) {

+ 5 - 3
src/test/java/com/izouma/nineth/service/NFTServiceTest.java

@@ -36,6 +36,8 @@ public class NFTServiceTest extends ApplicationTests {
     private RestClientProperties restClientProperties;
     @Autowired
     private GeneralProperties    generalProperties;
+    @Autowired
+    private SnowflakeIdWorker    snowflakeIdWorker;
 
     @Test
     public void createAccount() {
@@ -52,7 +54,7 @@ public class NFTServiceTest extends ApplicationTests {
         jsonArray.add(new BigInteger(s, 16).toString());
         log.info("data {}", jsonArray.toJSONString());
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName(generalProperties.getContractName())
@@ -139,7 +141,7 @@ public class NFTServiceTest extends ApplicationTests {
     @Test
     public void ownerof() throws Exception {
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName("raex12")
@@ -184,7 +186,7 @@ public class NFTServiceTest extends ApplicationTests {
         jsonArray.add(Utils.getIdentityByName("9th_HCWWflAZ_"));
         jsonArray.add("95057808871064671354760012409081314299");
         CallRestBizParam callRestBizParam = CallRestBizParam.builder()
-                .orderId(String.valueOf(new SnowflakeIdWorker(0, 0).nextId()))
+                .orderId(String.valueOf(snowflakeIdWorker.nextId()))
                 .bizid(restClientProperties.getBizid())
                 .account(restClientProperties.getAccount())
                 .contractName("raex12")