Sfoglia il codice sorgente

设置天数、开启/关闭白名单分享、用户风险提示

licailing 3 anni fa
parent
commit
1e074b5ddf

+ 5 - 0
src/main/java/com/izouma/nineth/domain/Asset.java

@@ -161,6 +161,9 @@ public class Asset extends BaseEntity {
     @Enumerated(EnumType.STRING)
     private CollectionType type;
 
+    @ApiModelProperty("持有几天")
+    private Integer holdDays;
+
     @Transient
     private boolean opened = true;
 
@@ -187,6 +190,7 @@ public class Asset extends BaseEntity {
                 .ownerId(user.getId())
                 .ownerAvatar(user.getAvatar())
                 .type(CollectionType.DEFAULT)
+                .holdDays(collection.getHoldDays())
                 .build();
     }
 
@@ -213,6 +217,7 @@ public class Asset extends BaseEntity {
                 .ownerId(user.getId())
                 .ownerAvatar(user.getAvatar())
                 .type(CollectionType.BLIND_BOX)
+                .holdDays(item.getHoldDays())
                 .build();
     }
 }

+ 3 - 0
src/main/java/com/izouma/nineth/domain/BlindBoxItem.java

@@ -95,4 +95,7 @@ public class BlindBoxItem extends BaseEntity {
 
     @ApiModelProperty("稀有")
     private boolean rare;
+
+    @ApiModelProperty("持有几天")
+    private Integer holdDays;
 }

+ 6 - 0
src/main/java/com/izouma/nineth/domain/Collection.java

@@ -182,4 +182,10 @@ public class Collection extends BaseEntity {
 
     @ApiModelProperty("销售时间")
     private LocalDateTime saleTime;
+
+    @ApiModelProperty("持有几天")
+    private Integer holdDays;
+
+    @ApiModelProperty("开启抢白名单")
+    private Boolean openQuota;
 }

+ 3 - 0
src/main/java/com/izouma/nineth/domain/User.java

@@ -151,4 +151,7 @@ public class User extends BaseEntity implements Serializable {
     @Column(columnDefinition = "int(11) default 0")
     @ApiModelProperty("白名单积分")
     private int vipPoint = 0;
+
+    @ApiModelProperty(value = "风险提示")
+    private Boolean riskWarning;
 }

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

@@ -30,14 +30,14 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
             "c.schedule_sale = ?5, c.sort = ?6, c.detail = ?7, c.privileges = ?8, " +
             "c.properties = ?9, c.model3d = ?10, c.max_count = ?11, c.count_id = ?12, c.scan_code = ?13, " +
             "c.no_sold_out = ?14, c.assignment = ?15, c.coupon_payment = ?16, c.share_bg = ?17," +
-            "c.register_bg = ?18, c.vip_quota = ?19, c.time_delay = ?20, c.sale_time = ?21 " +
-            "where c.id = ?1", nativeQuery = true)
+            "c.register_bg = ?18, c.vip_quota = ?19, c.time_delay = ?20, c.sale_time = ?21, c.hold_days = ?22, " +
+            "c.open_quota = ?23 where c.id = ?1", nativeQuery = true)
     @CacheEvict(value = {"collection", "recommend"}, allEntries = true)
     void update(@Nonnull Long id, boolean onShelf, boolean salable, LocalDateTime startTime,
                 boolean schedule, int sort, String detail, String privileges,
                 String properties, String model3d, int maxCount, String countId, boolean scanCode,
                 boolean noSoldOut, int assignment, boolean couponPayment, String shareBg, String registerBg,
-                Integer vipQuota, Boolean timeDelay, LocalDateTime saleTime);
+                Integer vipQuota, Boolean timeDelay, LocalDateTime saleTime, Integer holdDays, Boolean openQuota);
 
     @Cacheable("collection")
     Optional<Collection> findById(@Nonnull Long id);

+ 8 - 1
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -163,7 +163,14 @@ public class AssetService {
         if (!asset.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
             throw new BusinessException("此藏品不属于你");
         }
-        int holdDays = sysConfigService.getInt("hold_days");
+
+        int holdDays;
+        if (ObjectUtils.isEmpty(asset.getHoldDays())) {
+            holdDays = sysConfigService.getInt("hold_days");
+        } else {
+            holdDays = asset.getHoldDays();
+        }
+
         if (ChronoUnit.DAYS.between(asset.getCreatedAt(), LocalDateTime.now()) < holdDays) {
             throw new BusinessException("需持有满" + holdDays + "天才能寄售上架");
         }

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

@@ -152,7 +152,8 @@ public class CollectionService {
                 JSON.toJSONString(record.getProperties()), JSON.toJSONString(record.getModel3d()),
                 record.getMaxCount(), record.getCountId(), record.isScanCode(), record.isNoSoldOut(),
                 record.getAssignment(), record.isCouponPayment(), record.getShareBg(), record.getRegisterBg(),
-                record.getVipQuota(), record.getTimeDelay(), record.getSaleTime());
+                record.getVipQuota(), record.getTimeDelay(), record.getSaleTime(), record.getHoldDays(),
+                record.getOpenQuota());
 
         record = collectionRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
         onShelfTask(record);

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

@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.net.URLCodec;
 import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.core.env.Environment;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -76,7 +77,14 @@ public class GiftOrderService {
         if (!asset.getUserId().equals(userId)) {
             throw new BusinessException("无权限");
         }
-        int holdDays = sysConfigService.getInt("hold_days");
+
+        int holdDays;
+        if (ObjectUtils.isEmpty(asset.getHoldDays())) {
+            holdDays = sysConfigService.getInt("hold_days");
+        } else {
+            holdDays = asset.getHoldDays();
+        }
+
         if (ChronoUnit.DAYS.between(asset.getCreatedAt(), LocalDateTime.now()) < holdDays) {
             throw new BusinessException("需持有满" + holdDays + "天才能转赠");
         }

+ 6 - 3
src/main/java/com/izouma/nineth/service/UserService.java

@@ -29,6 +29,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.mp.api.WxMpService;
 import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
 import me.chanjar.weixin.mp.bean.result.WxMpUser;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -191,8 +192,8 @@ public class UserService {
 
         // 加积分
         if (collectionId != null && invitor != null) {
-            // 额度
-            if (collection.getVipQuota() > 0) {
+            // 额度或者额度为空
+            if (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota())) {
                 int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
                 // 邀请人数
                 if (countUser >= collection.getAssignment()) {
@@ -209,7 +210,9 @@ public class UserService {
                                     .point(1)
                                     .build());
                             // 扣除藏品额度
-                            collectionService.decreaseQuota(collectionId, 1);
+                            if(ObjectUtils.isNotEmpty(collection.getVipQuota())){
+                                collectionService.decreaseQuota(collectionId, 1);
+                            }
                         }
                     }
                 }

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

@@ -23,7 +23,7 @@ public class MintActivityController extends BaseController {
     private MintActivityService mintActivityService;
     private MintActivityRepo    mintActivityRepo;
 
-    //@PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MintActivity save(@RequestBody MintActivity record) {
         if (record.getId() != null) {

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

@@ -189,6 +189,11 @@
                         <el-input v-model="formData.countId"></el-input>
                         <div class="tip">相同识别码的藏品共享限购数量</div>
                     </el-form-item>
+
+                    <el-form-item prop="holdDays" label="持有天数">
+                        <el-input-number type="number" :min="0" :step="1" :max="2147483647" v-model="formData.holdDays" style="width: 180px"></el-input-number>
+                        <div class="tip">持有多少天可转赠/转让。为空时,按系统设置天数</div>
+                    </el-form-item>
                     <el-form-item prop="noSoldOut" label="售罄">
                         <el-radio v-model="formData.noSoldOut" :label="false">是</el-radio>
                         <el-radio v-model="formData.noSoldOut" :label="true">否</el-radio>
@@ -221,6 +226,10 @@
                             <div class="tip">多少人拉新可获得积分</div>
                         </el-form-item>
                     </div>
+                    <el-form-item prop="openQuota" label="白名单分享" v-if="formData.assignment > 0">
+                        <el-radio v-model="formData.openQuota" :label="true">开启</el-radio>
+                        <el-radio v-model="formData.openQuota" :label="false">关闭</el-radio>
+                    </el-form-item>
                     <div class="inline-wrapper">
                         <el-form-item prop="timeDelay" label="延迟销售" v-if="formData.assignment > 0">
                             <el-radio v-model="formData.timeDelay" :label="true">是</el-radio>
@@ -680,7 +689,7 @@ export default {
             });
         },
         submit() {
-              if (this.editQuota && this.formData.totalQuota) {
+            if (this.editQuota && this.formData.totalQuota) {
                 this.formData.vipQuota = this.formData.totalQuota;
             }
             if (this.formData.id) {

+ 23 - 0
src/main/vue/src/views/CollectionEdit.vue

@@ -226,6 +226,11 @@
                             <div class="tip">相同识别码的藏品共享限购数量</div>
                         </el-form-item>
                     </div>
+
+                    <el-form-item prop="holdDays" label="持有天数">
+                        <el-input-number type="number" :min="0" :step="1" :max="2147483647" v-model="formData.holdDays" style="width: 180px"></el-input-number>
+                        <div class="tip">持有多少天可转赠/转让。为空时,按系统设置天数。</div>
+                    </el-form-item>
                     <el-form-item prop="noSoldOut" label="售罄">
                         <el-radio v-model="formData.noSoldOut" :label="false">是</el-radio>
                         <el-radio v-model="formData.noSoldOut" :label="true">否</el-radio>
@@ -258,6 +263,10 @@
                             <div class="tip">多少人拉新可获得积分</div>
                         </el-form-item>
                     </div>
+                    <el-form-item prop="openQuota" label="白名单分享" v-if="formData.assignment > 0">
+                        <el-radio v-model="formData.openQuota" :label="true">开启</el-radio>
+                        <el-radio v-model="formData.openQuota" :label="false">关闭</el-radio>
+                    </el-form-item>
                     <div class="inline-wrapper">
                         <el-form-item prop="timeDelay" label="延迟销售" v-if="formData.assignment > 0">
                             <el-radio v-model="formData.timeDelay" :label="true">是</el-radio>
@@ -600,6 +609,20 @@ export default {
                         },
                         trigger: 'blur'
                     }
+                ],
+                openQuota: [
+                    {
+                        validator: (rule, value, callback) => {
+                            if (this.formData.assignment > 0) {
+                                if (value === '' || value === undefined) {
+                                    callback(new Error('请选择开启/关闭白名单分享'));
+                                    return;
+                                }
+                            }
+                            callback();
+                        },
+                        trigger: 'blur'
+                    }
                 ]
             },
             typeOptions: [