From 007abfd18e32b28a8509e6d6a7a5990da73a7c14 Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Fri, 31 Jul 2020 17:34:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8sql=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ActInfoDao.xml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml index d362229eba..b3d4fb4fe0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml @@ -65,14 +65,13 @@ 'signing_up' AS actCurrentState, -- 活动状态:报名中,未报满 IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i - LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' + LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' AND u.USER_ID = #{userId} LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` != 'refused' AND re.`STATUS` != 'canceled' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.ACT_STATUS = 'published' AND = ]]> NOW() -- 报名截止时间 >= 当前时间 AND (i.ACT_QUOTA_CATEGORY = 0 OR i.ACT_QUOTA > IFNULL(c.signupNum, 0)) -- 不限名额或者报名人数未报满 AND i.CUSTOMER_ID = #{customerId} - GROUP BY i.ID ORDER BY i.ACT_QUOTA_CATEGORY DESC,i.CREATED_TIME DESC @@ -92,7 +91,7 @@ 'enough' AS actCurrentState, -- 活动状态:报名中,已报满 IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i - LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' + LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' AND u.USER_ID = #{userId} LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` != 'refused' AND re.`STATUS` != 'canceled' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.ACT_STATUS = 'published' @@ -100,7 +99,6 @@ AND i.ACT_QUOTA_CATEGORY = 1 -- 固定名额 AND i.ACT_QUOTA = IFNULL(c.signupNum, 0) -- 名额已满 AND i.CUSTOMER_ID = #{customerId} - GROUP BY i.ID ORDER BY i.CREATED_TIME DESC @@ -120,14 +118,13 @@ 'end_sign_up' AS actCurrentState, -- 活动状态:未开始 IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i - LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' + LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' AND u.USER_ID = #{userId} LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` != 'refused' AND re.`STATUS` != 'canceled' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' -- 活动开始时间 > 当前时间 并且 报名截止时间 < 当前时间 报名已结束,活动未开始 未开始 AND ( ]]> NOW() AND NOW() ) AND i.ACT_STATUS = 'published' AND i.CUSTOMER_ID = #{customerId} - GROUP BY i.ID ORDER BY i.CREATED_TIME DESC @@ -147,14 +144,13 @@ 'in_progress' AS actCurrentState, -- 活动状态:进行中 IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i - LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' + LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' AND u.USER_ID = #{userId} LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` = 'passed' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' -- 活动开始时间 <= 当前时间 进行中 AND NOW() AND i.ACT_STATUS = 'published' AND i.CUSTOMER_ID = #{customerId} - GROUP BY i.ID ORDER BY i.CREATED_TIME DESC @@ -174,12 +170,11 @@ 'finished' AS actCurrentState, -- 活动状态:已结束 IF(u.USER_ID = #{userId},'signed_up','no_signed_up') as signupFlag FROM act_info i - LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' + LEFT JOIN act_user_relation u ON i.ID = u.ACT_ID AND U.DEL_FLAG = '0' AND u.`STATUS` != 'refused' AND u.`STATUS` != 'canceled' AND u.USER_ID = #{userId} LEFT JOIN (SELECT count(1) signupNum, re.ACT_ID from act_user_relation re WHERE re.DEL_FLAG = '0' AND re.`STATUS` = 'passed' GROUP BY re.ACT_ID) c ON c.ACT_ID = i.ID WHERE i.DEL_FLAG = '0' AND i.ACT_STATUS = 'finished' AND i.CUSTOMER_ID = #{customerId} - GROUP BY i.ID ORDER BY i.CREATED_TIME DESC LIMIT #{pageNo}, #{pageSize}