xiongzhu 4 anni fa
parent
commit
1cc5702c1e

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

@@ -49,17 +49,17 @@ import java.util.Map;
 @AllArgsConstructor
 public class GiftOrderService {
 
-    private AssetRepo          assetRepo;
-    private UserRepo           userRepo;
-    private SysConfigService   sysConfigService;
-    private GiftOrderRepo      giftOrderRepo;
-    private AlipayProperties   alipayProperties;
-    private AlipayClient       alipayClient;
-    private WxPayProperties    wxPayProperties;
-    private WxPayService       wxPayService;
-    private Environment        env;
-    private AssetService       assetService;
-    private AdapayProperties   adapayProperties;
+    private AssetRepo        assetRepo;
+    private UserRepo         userRepo;
+    private SysConfigService sysConfigService;
+    private GiftOrderRepo    giftOrderRepo;
+    private AlipayProperties alipayProperties;
+    private AlipayClient     alipayClient;
+    private WxPayProperties  wxPayProperties;
+    private WxPayService     wxPayService;
+    private Environment      env;
+    private AssetService     assetService;
+    private AdapayProperties adapayProperties;
 
     @Transactional
     public GiftOrder gift(Long userId, Long assetId, Long toUserId) {

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

@@ -10,6 +10,7 @@ import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.PostConstruct;
 import java.math.BigDecimal;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
@@ -25,11 +26,6 @@ public class SysConfigService {
 
     @Cacheable("SysConfigServiceGetBigDecimal")
     public BigDecimal getBigDecimal(String name) {
-        try {
-            Thread.sleep(3000);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
         return sysConfigRepo.findByName(name).map(sysConfig -> new BigDecimal(sysConfig.getValue()))
                 .orElse(BigDecimal.ZERO);
     }
@@ -55,4 +51,16 @@ public class SysConfigService {
                 .orElseThrow(new BusinessException("配置不存在"));
         return Integer.parseInt(str);
     }
+
+    @PostConstruct
+    public void init() {
+        if (!sysConfigRepo.findByName("gift_gas_fee").isPresent()) {
+            sysConfigRepo.save(SysConfig.builder()
+                    .name("gift_gas_fee")
+                    .desc("转赠gas费")
+                    .type(SysConfig.ValueType.NUMBER)
+                    .value("1")
+                    .build());
+        }
+    }
 }