Browse Source

列表sql修改

dev_shibei_match
zhangyongzhangyong 5 years ago
parent
commit
007abfd18e
  1. 15
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActInfoDao.xml

15
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 <![CDATA[ DATE_FORMAT(i.SIGN_UP_END_TIME,'%Y-%m-%d %H:%i:%s') >= ]]> 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
</select>
@ -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
</select>
@ -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'
-- 活动开始时间 > 当前时间 并且 报名截止时间 &lt; 当前时间 报名已结束,活动未开始 未开始
AND ( <![CDATA[ DATE_FORMAT(i.ACT_START_TIME,'%Y-%m-%d %H:%i:%s') > ]]> NOW() AND <![CDATA[ DATE_FORMAT(i.SIGN_UP_END_TIME,'%Y-%m-%d %H:%i:%s') < ]]> NOW() )
AND i.ACT_STATUS = 'published'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY i.ID
ORDER BY i.CREATED_TIME DESC
</select>
@ -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'
-- 活动开始时间 &lt;= 当前时间 进行中
AND <![CDATA[ DATE_FORMAT(i.ACT_START_TIME,'%Y-%m-%d %H:%i:%s') <= ]]> NOW()
AND i.ACT_STATUS = 'published'
AND i.CUSTOMER_ID = #{customerId}
GROUP BY i.ID
ORDER BY i.CREATED_TIME DESC
</select>
@ -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}
</select>

Loading…
Cancel
Save