licailing пре 3 година
родитељ
комит
13bdc29ea5

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

@@ -154,4 +154,7 @@ public class Collection extends BaseEntity {
 
     @ApiModelProperty("拉新任务指标")
     private int assignment;
+
+    @ApiModelProperty("优惠券支付")
+    private boolean couponPayment;
 }

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

@@ -29,12 +29,12 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     @Query(value = "update collection_info c set c.on_shelf = ?2, c.salable = ?3, c.start_time = ?4, " +
             "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 where c.id = ?1", nativeQuery = true)
+            "c.no_sold_out = ?14, c.assignment = ?15, c.coupon_payment = ?16 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 noSoldOut, int assignment, boolean couponPayment);
 
     @Cacheable("collection")
     Optional<Collection> findById(@Nonnull Long id);

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

@@ -142,7 +142,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.isNoSoldOut(),
-                record.getAssignment());
+                record.getAssignment(), record.isCouponPayment());
 
         record = collectionRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
         onShelfTask(record);

+ 5 - 1
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -119,7 +119,10 @@ public class OrderService {
             }
             User minter = userRepo.findById(collection.getMinterId()).orElseThrow(new BusinessException("铸造者不存在"));
             UserCoupon coupon = null;
-            if (userCouponId != null) {
+            if (collection.isCouponPayment()) {
+                if (userCouponId == null) {
+                    throw new BusinessException("必须使用优惠券支付");
+                }
                 coupon = userCouponRepo.findById(userCouponId).orElseThrow(new BusinessException("兑换券不存在"));
                 if (coupon.isUsed()) {
                     throw new BusinessException("该兑换券已使用");
@@ -128,6 +131,7 @@ public class OrderService {
                     throw new BusinessException("该兑换券不可用");
                 }
             }
+
             if (collection.isScheduleSale()) {
                 if (collection.getStartTime().isAfter(LocalDateTime.now())) {
                     throw new BusinessException("当前还未开售");

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

@@ -197,6 +197,12 @@
                         <el-input-number type="number" :min="0" :step="1" v-model="formData.assignment"></el-input-number>
                         <div class="tip">0表示无拉新任务限制</div>
                     </el-form-item>
+                    <el-form-item prop="couponPayment" label="支付方式">
+                        <el-radio-group v-model="formData.couponPayment">
+                            <el-radio :label="true">优惠券</el-radio>
+                            <el-radio :label="false">支付宝/微信</el-radio>
+                        </el-radio-group>
+                    </el-form-item>
                     <el-form-item class="form-submit">
                         <el-button @click="onSave" :loading="saving" type="primary" v-if="!formData.id">
                             保存
@@ -417,7 +423,8 @@ export default {
                 countId: null,
                 scanCode: false,
                 noSoldOut: true,
-                assignment: 0
+                assignment: 0,
+                coupoPayment: false
             },
             rules: {
                 name: [

+ 8 - 1
src/main/vue/src/views/CollectionEdit.vue

@@ -215,6 +215,12 @@
                         <el-input-number type="number" :min="0" :step="1" v-model="formData.assignment"></el-input-number>
                         <div class="tip">0表示无拉新任务限制</div>
                     </el-form-item>
+                    <el-form-item prop="couponPayment" label="支付方式">
+                        <el-radio-group v-model="formData.couponPayment">
+                            <el-radio :label="true">优惠券</el-radio>
+                            <el-radio :label="false">支付宝/微信</el-radio>
+                        </el-radio-group>
+                    </el-form-item>
                     <el-form-item class="form-submit">
                         <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
                         <!-- <el-button @click="onDelete" :disabled="saving" type="danger" v-if="formData.id">
@@ -325,7 +331,8 @@ export default {
                 canResale: true,
                 scanCode: false,
                 noSoldOut: true,
-                assignment: 0
+                assignment: 0,
+                coupoPayment: false
             },
             rules: {
                 name: [