liujie
昨天 ee7208a3bb7770e24fa135916fa5f7165b25fee6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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.TDriverPromotionActivityMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TDriverPromotionActivity">
        <id column="id" property="id" />
        <result column="bizType" property="bizType" />
        <result column="activityTitle" property="activityTitle" />
        <result column="province" property="province" />
        <result column="provinceCode" property="provinceCode" />
        <result column="city" property="city" />
        <result column="cityCode" property="cityCode" />
        <result column="district" property="district" />
        <result column="districtCode" property="districtCode" />
        <result column="startTime" property="startTime" />
        <result column="endTime" property="endTime" />
        <result column="commissionRatio" property="commissionRatio" />
        <result column="bindingDays" property="bindingDays" />
        <result column="activityDesc" property="activityDesc" />
        <result column="status" property="status" />
        <result column="creator" property="creator" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, bizType, activityTitle, province, provinceCode, city, cityCode, district, districtCode, startTime, endTime, commissionRatio, bindingDays, activityDesc,  creator, createTime, updateTime,
    </sql>
 
    <select id="list" resultType="java.util.Map">
select  * from (
        select <include refid="Base_Column_List"/>
            case
                when now()>endTime then 4
                when startTime>now()  then 3
                when now()>startTime and endTime >now() and state =1 then 1
                when now()>startTime and endTime >now() and state =2 then 2
                else 0
            end as status
            from t_driver_promotion_activity
        where remove=0
        <if test="beginTime != null and endTime != null">
            and createTime between #{beginTime} and #{endTime}
        </if>
 
        <if test="name != null">
            and activityTitle like concat('%',#{name},'%')
        </if>
        ) t1 where 1=1
        <if test="status!= null">
            and t1.status =#{status}
        </if>
        order by t1.createTime desc
 
 
    </select>
 
</mapper>