Selaa lähdekoodia

Merge branch 'dev'

xiongzhu 4 vuotta sitten
vanhempi
commit
d26b04472d

+ 9 - 0
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.Optional;
 import java.util.Optional;
@@ -46,6 +47,7 @@ public class AssetService {
     private OrderRepo          orderRepo;
     private OrderRepo          orderRepo;
     private TokenHistoryRepo   tokenHistoryRepo;
     private TokenHistoryRepo   tokenHistoryRepo;
     private AssetMintService   assetMintService;
     private AssetMintService   assetMintService;
+    private SysConfigService   sysConfigService;
 
 
     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));
@@ -147,6 +149,13 @@ public class AssetService {
         if (!asset.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
         if (!asset.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
             throw new BusinessException("此藏品不属于你");
             throw new BusinessException("此藏品不属于你");
         }
         }
+        if (!asset.isCanResale()) {
+            throw new BusinessException("此藏品不可转售");
+        }
+        int holdDays = sysConfigService.getInt("hold_days");
+        if (ChronoUnit.DAYS.between(asset.getCreatedAt(), LocalDateTime.now()) < holdDays) {
+            throw new BusinessException("需持有满" + holdDays + "天才能寄售上架");
+        }
         User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("用户不存在"));
         User owner = userRepo.findById(asset.getUserId()).orElseThrow(new BusinessException("用户不存在"));
         if (StringUtils.isBlank(owner.getSettleAccountId())) {
         if (StringUtils.isBlank(owner.getSettleAccountId())) {
             throw new BusinessException("请先绑定银行卡");
             throw new BusinessException("请先绑定银行卡");

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

@@ -78,5 +78,13 @@ public class SysConfigService {
                     .value("FALSE")
                     .value("FALSE")
                     .build());
                     .build());
         }
         }
+        if (!sysConfigRepo.findByName("hold_days").isPresent()) {
+            sysConfigRepo.save(SysConfig.builder()
+                    .name("hold_days")
+                    .desc("持有满几天可销售")
+                    .type(SysConfig.ValueType.NUMBER)
+                    .value("5")
+                    .build());
+        }
     }
     }
 }
 }

+ 1 - 1
src/main/vue/src/views/BlindBoxEdit.vue

@@ -17,7 +17,7 @@
                     style="max-width: 500px"
                     style="max-width: 500px"
                 >
                 >
                     <el-form-item prop="name" label="名称">
                     <el-form-item prop="name" label="名称">
-                        <el-input v-model="formData.name" :disabled="!canEdit" :maxlength="16"></el-input>
+                        <el-input v-model="formData.name" :disabled="!canEdit"></el-input>
                     </el-form-item>
                     </el-form-item>
                     <el-form-item prop="pic" label="图片">
                     <el-form-item prop="pic" label="图片">
                         <object-upload
                         <object-upload