101captain
2022-03-09 9c5b811fb700bc66e66dbf38ed8733e57a4edac6
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
<?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.panzhihua.service_community.dao.ComFmsServiceDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.ComFmsService" id="ComFmsServiceMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="INTEGER"/>
        <result property="phone" column="phone" jdbcType="VARCHAR"/>
        <result property="serviceContent" column="service_content" jdbcType="VARCHAR"/>
        <result property="serviceImage" column="service_image" jdbcType="VARCHAR"/>
        <result property="approvalContent" column="approval_content" jdbcType="VARCHAR"/>
        <result property="approvalAt" column="approval_at" jdbcType="TIMESTAMP"/>
        <result property="memberId" column="member_id" jdbcType="INTEGER"/>
        <result property="serviceStatus" column="service_status" jdbcType="INTEGER"/>
        <result property="serviceAt" column="service_at" jdbcType="TIMESTAMP"/>
        <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
        <result property="createdBy" column="created_by" jdbcType="INTEGER"/>
        <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
        <result property="updatedBy" column="updated_by" jdbcType="INTEGER"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_fms_service(user_name, user_id, phone, service_content, service_image, approval_content, approval_at, member_id, service_status, service_at, created_at, created_by, updated_at, updated_by, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
        (#{entity.userName}, #{entity.userId}, #{entity.phone}, #{entity.serviceContent}, #{entity.serviceImage}, #{entity.approvalContent}, #{entity.approvalAt}, #{entity.memberId}, #{entity.serviceStatus}, #{entity.serviceAt}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.com_fms_service(user_name, user_id, phone, service_content, service_image, approval_content, approval_at, member_id, service_status, service_at, created_at, created_by, updated_at, updated_by, community_id)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.userName}, #{entity.userId}, #{entity.phone}, #{entity.serviceContent}, #{entity.serviceImage}, #{entity.approvalContent}, #{entity.approvalAt}, #{entity.memberId}, #{entity.serviceStatus}, #{entity.serviceAt}, #{entity.createdAt}, #{entity.createdBy}, #{entity.updatedAt}, #{entity.updatedBy}, #{entity.communityId})
        </foreach>
        on duplicate key update
         user_name = values(user_name) , user_id = values(user_id) , phone = values(phone) , service_content = values(service_content) , service_image = values(service_image) , approval_content = values(approval_content) , approval_at = values(approval_at) , member_id = values(member_id) , service_status = values(service_status) , service_at = values(service_at) , created_at = values(created_at) , created_by = values(created_by) , updated_at = values(updated_at) , updated_by = values(updated_by) , community_id = values(community_id)     </insert>
    <select id="pageFmsServiceAdmin" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT t1.id, t1.user_name, t1.phone, t1.created_at, t1.service_content, t2.`name` AS serviceMember, t3.star_level, t1.service_status
        FROM com_fms_service t1
        LEFT JOIN com_fms_team_member t2 ON t1.member_id = t2.id
        LEFT JOIN com_fms_service_evaluations t3 ON t1.id = t3.service_id
        WHERE t1.community_id = #{adminDTO.communityId}
        <if test="adminDTO.keyword != null and adminDTO.keyword != &quot;&quot;">
            AND(t1.user_name LIKE CONCAT('%',#{adminDTO.keyword},'%')
            OR t2.`name` LIKE CONCAT('%',#{adminDTO.keyword},'%')
            OR t1.service_content LIKE CONCAT('%',#{adminDTO.keyword},'%'))
        </if>
        <if test="adminDTO.serviceStatus != null">
            AND t1.service_status = #{adminDTO.serviceStatus}
        </if>
        ORDER BY t1.created_at DESC
    </select>
    <select id="detailFmsServiceAdmin"
            resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT t1.id, t1.user_name, t2.`name` AS realName, t1.phone, t1.service_content, t1.service_image,
        t1.service_status
        FROM com_fms_service t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.id = #{serviceId}
    </select>
    <select id="statisticsFmsService"
            resultType="com.panzhihua.common.model.vos.community.fms.FmsServiceTopStatisticsVO">
        SELECT
        (SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 4) AS completedCount,
        (SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 1) AS unVerifiedCount,
        (SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 2) AS inProgressCount,
        (SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 3) AS unEvaluateCount,
        (SELECT COUNT(id) FROM com_fms_service WHERE community_id = #{communityId} AND service_status = 5) AS unPassCount
    </select>
    <select id="pageFmsServiceAdminApplets"
            resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT t1.id, t1.service_content, t1.service_image, IF(t2.nick_name IS NULL,'匿名用户',t2.nick_name) AS nickName, t2.image_url
        FROM com_fms_service t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.community_id = #{adminDTO.communityId}
        <if test="adminDTO.status != null and adminDTO.status == 1">
            AND t1.service_status IN (3,4)
        </if>
        <if test="adminDTO.status != null and adminDTO.status == 2">
            AND t1.service_status = 2
        </if>
        ORDER BY t1.created_at DESC
    </select>
    <select id="detailFmsServiceApplets"
            resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT t1.id, t1.service_content, t1.service_image, t1.phone, t1.service_status,
        t1.created_at, IF(t2.nick_name IS NULL,'匿名用户',t2.nick_name) AS nickName, t2.image_url
        FROM com_fms_service t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.id = #{serviceId}
    </select>
    <select id="pageMyFmsService" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT id, service_content, service_image, service_status, created_at
        FROM com_fms_service WHERE user_id = #{adminDTO.userId} AND community_id = #{adminDTO.communityId}
        ORDER BY created_at DESC
    </select>
    <select id="pageDealFmsService" resultType="com.panzhihua.common.model.vos.community.fms.ComFmsServiceVO">
        SELECT t1.id, t1.service_content, t1.service_image, t1.service_status, t1.created_at, IF(t2.nick_name IS NULL,'匿名用户',t2.nick_name) AS nickName, t2.image_url
        FROM com_fms_service t1
        LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
        WHERE t1.community_id = #{adminDTO.communityId}
        <if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 1">
            AND t1.member_id = #{adminDTO.memberId}
        </if>
        <if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 2">
            AND t1.service_status = 1
        </if>
        <if test="adminDTO.dealStatus != null and adminDTO.dealStatus == 3">
            AND t1.service_status = 4
        </if>
        ORDER BY t1.created_at DESC
    </select>
 
</mapper>