puzhibing
2023-02-15 2811bab657aab4145b65a45a824fb63e93b58e30
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
<?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.DriverActivityHistoryMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.DriverActivityHistory">
        <id column="id" property="id"/>
        <result column="day" property="day"/>
        <result column="driverId" property="driverId"/>
        <result column="type" property="type"/>
        <result column="activityId" property="activityId"/>
        <result column="carryOut" property="carryOut"/>
        <result column="money" property="money"/>
        <result column="collectionTime" property="collectionTime"/>
        <result column="insertTime" property="insertTime"/>
 
    </resultMap>
 
 
 
    <select id="query" resultType="map">
        select * from
        (
            select
            DATE_FORMAT(`day`, '%Y.%m.%d') as time,
            if((select count(id) from t_driver_activity_history where driverId = #{driverId}) > (select count(id) from t_driver_activity_history where driverId = #{driverId} and carryOut = 2), 1, 2) as carryOut
            from t_driver_activity_history where driverId = #{driverId} group by `day`
        ) as a order by a.time desc limit #{pageNum}, #{size}
    </select>
 
    <select id="queryList" resultType="DriverActivityHistory">
        select
        id as id,
        `day` as `day`,
        driverId as driverId,
        `type` as `type`,
        activityId as activityId,
        carryOut as carryOut,
        money as money,
        collectionTime as collectionTime,
        insertTime as insertTime
        from t_driver_activity_history where `day` between #{start} and #{end}
        <if test="null != type">
            and `type` = #{type}
        </if>
        <if test="null != carryOut">
            and carryOut = #{carryOut}
        </if>
        <if test="null != driverId">
            and driverId = #{driverId}
        </if>
    </select>
</mapper>