From 5ff8fb8bd9d298def47437b24e77c8879cdc37d2 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期四, 14 十一月 2024 09:36:39 +0800
Subject: [PATCH] 1.定时任务-待付款-15分钟 2.领券中心:根据领取次数判断是否已领取 3.付款:优惠券自动领取最大优惠券

---
 src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml b/src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml
index cf3918e..485f9b1 100644
--- a/src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml
+++ b/src/main/resources/mapper/coupon/CouponTemplateMapperCustom.xml
@@ -141,6 +141,54 @@
         ORDER BY t.create_time DESC
         limit 1
     </select>
+    <select id="getActivityEffectListWithMine"
+            resultType="com.mzl.flower.dto.response.coupon.CouponTemplateVO">
+        select t2.*,t2.get_limit,IFNULL(t2.get_limit- t2.getNum,0) as left_num  from (
+            SELECT
+                t.*,
+                (
+                    SELECT count( 1 )
+                    FROM t_coupon_record cr
+                    WHERE  cr.coupon_id = t.id AND cr.deleted = 0
+                    <if test="param.userId != null and param.userId != ''">
+                        AND cr.user_id = #{param.userId}
+                    </if>
+
+                ) AS getNum,
+                (
+                    SELECT min( cr.create_time )
+                    FROM t_coupon_record cr
+                    WHERE cr.coupon_id = t.id AND cr.deleted = 0
+                    <if test="param.userId != null and param.userId != ''">
+                        AND cr.user_id = #{param.userId}
+                    </if>
+                ) AS record_create_time
+            FROM
+            t_coupon_template t
+            WHERE
+            t.deleted = FALSE
+            <if test="param.category != null and param.category != '' and param.category == 'activity' ">
+                AND t.get_start_date &lt;= NOW()
+                AND NOW() &lt;= t.get_end_date
+            </if>
+
+            <if test="param.category != null and param.category != ''">
+                AND category =  #{param.category}
+            </if>
+            <if test="param.status != null and param.status != ''">
+                AND status =  #{param.status}
+            </if>
+            <if test="param.getType != null and param.getType != ''">
+                AND t.get_type =  #{param.getType}
+            </if>
+
+        ) t2
+
+        ORDER BY
+        left_num desc,
+        create_time DESC,
+        record_create_time ASC
+    </select>
 
     <sql id="QueryPointSql">
         select *

--
Gitblit v1.9.3