bug
jiangqs
2023-08-21 c93e76c57a98e35abbf62d2f514d9ba51efd3243
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?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.ruoyi.shop.mapper.task.ShopTaskMapper">
 
    <resultMap type="ShopTask" id="ShopTaskResult">
        <result property="taskId"    column="task_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="shopId"    column="shop_id"    />
        <result property="followType"    column="follow_type"    />
        <result property="followContent"    column="follow_content"    />
        <result property="nextFollowDate"    column="next_follow_date"    />
        <result property="taskTitle"    column="task_title"    />
        <result property="emergencyState"    column="emergency_state"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
 
    <sql id="selectShopTaskVo">
        select task_id, del_flag, shop_id, follow_type, follow_content, next_follow_date, task_title, emergency_state, create_time from t_shop_task
    </sql>
 
    <select id="selectShopTaskList" parameterType="ShopTask" resultMap="ShopTaskResult">
        <include refid="selectShopTaskVo"/>
        <where>
            <if test="shopId != null "> and shop_id = #{shopId}</if>
            <if test="followType != null "> and follow_type = #{followType}</if>
            <if test="followContent != null  and followContent != ''"> and follow_content = #{followContent}</if>
            <if test="nextFollowDate != null "> and next_follow_date = #{nextFollowDate}</if>
            <if test="taskTitle != null  and taskTitle != ''"> and task_title = #{taskTitle}</if>
            <if test="emergencyState != null "> and emergency_state = #{emergencyState}</if>
        </where>
    </select>
 
    <select id="selectShopTaskByTaskId" parameterType="String" resultMap="ShopTaskResult">
        <include refid="selectShopTaskVo"/>
        where task_id = #{taskId}
    </select>
 
    <insert id="insertShopTask" parameterType="ShopTask">
        insert into t_shop_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="shopId != null">shop_id,</if>
            <if test="followType != null">follow_type,</if>
            <if test="followContent != null">follow_content,</if>
            <if test="nextFollowDate != null">next_follow_date,</if>
            <if test="taskTitle != null">task_title,</if>
            <if test="emergencyState != null">emergency_state,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="shopId != null">#{shopId},</if>
            <if test="followType != null">#{followType},</if>
            <if test="followContent != null">#{followContent},</if>
            <if test="nextFollowDate != null">#{nextFollowDate},</if>
            <if test="taskTitle != null">#{taskTitle},</if>
            <if test="emergencyState != null">#{emergencyState},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>
 
    <update id="updateShopTask" parameterType="ShopTask">
        update t_shop_task
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="shopId != null">shop_id = #{shopId},</if>
            <if test="followType != null">follow_type = #{followType},</if>
            <if test="followContent != null">follow_content = #{followContent},</if>
            <if test="nextFollowDate != null">next_follow_date = #{nextFollowDate},</if>
            <if test="taskTitle != null">task_title = #{taskTitle},</if>
            <if test="emergencyState != null">emergency_state = #{emergencyState},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where task_id = #{taskId}
    </update>
 
    <delete id="deleteShopTaskByTaskId" parameterType="String">
        delete from t_shop_task where task_id = #{taskId}
    </delete>
 
    <delete id="deleteShopTaskByTaskIds" parameterType="String">
        delete from t_shop_task where task_id in
        <foreach item="taskId" collection="array" open="(" separator="," close=")">
            #{taskId}
        </foreach>
    </delete>
 
 
    <select id="getShopIngTotal" resultType="java.lang.Integer">
        SELECT COUNT(task_id)
        FROM t_shop_task
        WHERE del_flag = 0 AND task_status = 1
        <if test="shopIds!=null and shopIds!=''">
            AND  shop_id IN
            <foreach collection="shopIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        AND task_date = DATE(NOW())
    </select>
 
    <select id="pageStaffShopTask" resultType="com.ruoyi.shop.domain.vo.StaffShopTaskPageVo">
        SELECT
        tst.task_id taskId,
        tst.task_date taskDate,
        tst.follow_content taskContent,
        tst.task_title taskTitle,
        tst.emergency_state emergencyState,
        CASE WHEN tst.task_date = DATE(now()) THEN 1 ELSE 0 END todayFlag,
        tstr.user_id userId,
        tstr.create_time followTime
        FROM t_shop_task tst
        LEFT JOIN t_shop_task_record tstr ON tstr.task_id = tst.task_id AND tstr.id = (SELECT MAX(id) FROM t_shop_task_record WHERE task_id = tst.task_id)
        WHERE tst.del_flag = 0 AND tst.shop_id = #{param.shopId}
        <if test="param.taskStatus!=null and param.taskStatus != ''">
            AND tst.task_status = #{param.taskStatus}
        </if>
        ORDER BY tst.task_status ASC
    </select>
 
    <update id="checkShopTaskStatus">
        UPDATE t_shop_task
        SET task_status = CASE
        WHEN task_date = CURDATE() THEN 1
        WHEN task_date &lt; CURDATE() AND task_status &lt; 2 THEN 3
        ELSE task_status
        END
    </update>
 
    <update id="checkMemberTaskStatus">
        UPDATE t_member_task
        SET task_status = CASE
        WHEN task_date = CURDATE() THEN 1
        WHEN task_date &lt; CURDATE() AND task_status &lt; 2 THEN 3
        ELSE task_status
        END
    </update>
 
    <update id="checkAgencyTaskStatus">
        UPDATE t_agency_task
        SET task_status = CASE
        WHEN task_date = CURDATE() THEN 1
        WHEN task_date &lt; CURDATE() AND task_status &lt; 2 THEN 3
        ELSE task_status
        END
    </update>
 
</mapper>