Ver Fonte

gas费配置

xiongzhu há 4 anos atrás
pai
commit
a94f720ddd

+ 0 - 5
pom.xml

@@ -75,11 +75,6 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-cache</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-aop</artifactId>

+ 4 - 2
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -63,6 +63,7 @@ public class OrderService {
     private WxPayService     wxPayService;
     private WxPayProperties  wxPayProperties;
     private AssetService     assetService;
+    private SysConfigService sysConfigService;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
@@ -92,6 +93,7 @@ public class OrderService {
 
         minter.setSales(minter.getSales() + 1);
 
+        BigDecimal gasFee = sysConfigService.getBigDecimal("gas_fee");
         Order order = Order.builder()
                 .userId(userId)
                 .collectionId(collectionId)
@@ -103,8 +105,8 @@ public class OrderService {
                 .minterAvatar(minter.getAvatar())
                 .qty(qty)
                 .price(collection.getPrice())
-                .gasPrice(BigDecimal.valueOf(1))
-                .totalPrice(collection.getPrice().multiply(BigDecimal.valueOf(qty)).add(BigDecimal.valueOf(1)))
+                .gasPrice(gasFee)
+                .totalPrice(collection.getPrice().multiply(BigDecimal.valueOf(qty)).add(gasFee))
                 .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
                 .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
                 .address(Optional.ofNullable(userAddress).map(u ->

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

@@ -23,13 +23,13 @@ public class SysConfigService {
         return sysConfigRepo.findAll(JpaUtils.toSpecification(pageQuery, SysConfig.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    @Cacheable("SysConfigServiceGetBigDecimal")
+//    @Cacheable("SysConfigServiceGetBigDecimal")
     public BigDecimal getBigDecimal(String name) {
         return sysConfigRepo.findByName(name).map(sysConfig -> new BigDecimal(sysConfig.getValue()))
                 .orElse(BigDecimal.ZERO);
     }
 
-    @Cacheable("SysConfigServiceGetTime")
+//    @Cacheable("SysConfigServiceGetTime")
     public LocalTime getTime(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));
@@ -37,14 +37,14 @@ public class SysConfigService {
         return LocalTime.from(dateTimeFormatter.parse(str));
     }
 
-    @Cacheable("SysConfigServiceGetBoolean")
+//    @Cacheable("SysConfigServiceGetBoolean")
     public boolean getBoolean(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));
         return str.equals("1");
     }
 
-    @Cacheable("SysConfigServiceGetInt")
+//    @Cacheable("SysConfigServiceGetInt")
     public int getInt(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));

+ 1 - 1
src/main/java/com/izouma/nineth/web/SysConfigController.java

@@ -25,7 +25,7 @@ public class SysConfigController extends BaseController {
 
     @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
-    @CacheEvict(value = {"SysConfigServiceGetBigDecimal", "SysConfigServiceGetTime", "SysConfigServiceGetBoolean", "SysConfigServiceGetInt"}, allEntries = true)
+//    @CacheEvict(value = {"SysConfigServiceGetBigDecimal", "SysConfigServiceGetTime", "SysConfigServiceGetBoolean", "SysConfigServiceGetInt"}, allEntries = true)
     public SysConfig save(@RequestBody SysConfig record) {
         return sysConfigRepo.save(record);
     }

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

@@ -18,6 +18,10 @@ public class NFTServiceTest extends ApplicationTests {
 
     @Test
     public void createToken() throws Exception {
-        nftService.createToken("9th_test");
+        nftService.createToken("9th_BHlKkGWw");
+    }
+
+    @Test
+    public void testCreateToken() {
     }
 }