<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.stylefeng.guns.modular.system.dao.TActivityGeneralizationMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TActivityGeneralization">
|
<id column="id" property="id" />
|
<result column="activityName" property="activityName" />
|
<result column="participateCount" property="participateCount" />
|
<result column="startTime" property="startTime" />
|
<result column="endTime" property="endTime" />
|
<result column="couponId" property="couponId" />
|
<result column="userGrantCount" property="userGrantCount" />
|
<result column="monthUseCount" property="monthUseCount" />
|
<result column="useExplain" property="useExplain" />
|
<result column="isDelete" property="isDelete" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, activityName, participateCount, startTime, endTime, couponId, userGrantCount, monthUseCount, useExplain, isDelete
|
</sql>
|
<select id="getList" resultType="java.util.Map">
|
select a.id,a.insertTime,a.activityName,CONCAT(DATE_FORMAT(a.startTime, '%Y-%m-%d')," — ",DATE_FORMAT(a.endTime, '%Y-%m-%d')) as `time`,
|
a.qrCode,
|
a.participateCount,a.state,IFNULL(b.count, 0) AS `count`
|
from t_activity_generalization a
|
LEFT join (SELECT
|
couponActivityId,
|
activityType,
|
COUNT(DISTINCT userId) AS count
|
FROM
|
t_user_coupon_record
|
WHERE
|
activityType = 5
|
GROUP BY
|
couponActivityId ) b
|
ON a.id = b.couponActivityId
|
WHERE a.isDelete = 1
|
<if test="beginTime != null and beginTime !='' and endTime != null and endTime != ''">
|
and (a.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
|
</if>
|
<if test="activityName != null and activityName !=''">
|
and a.activityName like CONCAT('%',#{activityName},'%')
|
</if>
|
<if test="state != null">
|
and a.state=#{state}
|
</if>
|
order by a.insertTime desc
|
</select>
|
|
</mapper>
|