zoujiajian 3 gadi atpakaļ
vecāks
revīzija
65c8a7d6c3

+ 2 - 1
netflix-dao/src/main/resources/mapper/CouponRecommendMapper.xml

@@ -23,6 +23,7 @@
         when cu.id is null then 'collecting'
         when cu.id is not null and cu.status != 'unused' then 'used'
         when cu.id is not null and cu.valid_end_time < now() then 'expired'
+        when cu.id is not null and cu.valid_start_time > now() then 'noEffective'
         when cu.id is not null and cu.status = 'unused' then 'received'
         end) as couponStatus,
         (case
@@ -35,7 +36,7 @@
         where cr.deleted is true and c.deleted is true and cr.status = 1
         <if test='!isNewUser'>
             and c.scope !='newUser'
-        </if>)s where couponStatus not in ('used','expired') and flag is true order by `order`
+        </if>)s where couponStatus not in ('used','expired','noEffective') and flag is true order by `order`
     </select>
 
     <select id="getRecommendCouponList" resultType="com.cyksj.model.views.CouponAvailableRecommendView">

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1048,6 +1048,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 					throw BusinessRuntimeException.getInstance("该优惠码只适用于新用户");
 				}
 			}
+			if (exists.getIsValidTime() && exists.getValidEndTime().before(DateTime.now())) {
+				throw BusinessRuntimeException.getInstance("该优惠码已失效");
+			}
 		} else if (couponId != null) {
 			CouponUserView couponUserView = beanSearcher.searchFirst(CouponUserView.class, MapUtils.builder()
 					.field(CouponUserView::getCouponId, couponId).op(Operator.Equal)

+ 3 - 0
netflix-web/src/main/java/com/cyksj/web/controller/coupon/CouponFrontController.java

@@ -214,6 +214,9 @@ public class CouponFrontController {
 				throw BusinessRuntimeException.getInstance("该优惠码只适用于新用户");
 			}
 		}
+		if (dto.getIsValidTime() && dto.getValidEndTime().before(DateTime.now())) {
+			throw BusinessRuntimeException.getInstance("该优惠码已失效");
+		}
 		List<Coupon.CouponGoodsSku> skuIds = Jsons.parseList(dto.getGoodsSkuIds(), Coupon.CouponGoodsSku.class);
 		Set<Long> collect = skuIds.stream().map(Coupon.CouponGoodsSku::getSkuId).collect(Collectors.toSet());
 		if (!collect.contains(skuId)) {