liujie
2023-10-26 e030255c23c7ba3e2cbad1036a810d6d72fa864f
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
<?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.dsh.other.mapper.SiteMapper">
    <update id="changeState">
        update t_site set
        state = #{type}
        <where>
            <if test="siteIds != null and siteIds.size()>0">
                AND t_site.id IN
                <foreach collection="siteIds" separator="," item="id" open="(" close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </update>
 
    <select id="querySiteList" resultType="com.dsh.other.model.QuerySiteListVo">
        select
        a.id,
        a.`name`,
        c.`name` as siteTypeName,
        b.`name` as storeName,
        b.address as storeAddress,
        b.lon as storeLon,
        b.lat as storeLat,
        CONCAT(a.appointmentStartTime, '-', a.appointmentEndTime) as times,
        a.cashPrice as price
        from t_site a
        left join t_store b on (a.storeId = b.id)
        left join t_site_type c on (a.siteTypeId = c.id)
        where a.state = 1
        <if test="null != item.startTime and '' != item.startTime and null != item.endTime and '' != item.endTime">
            and CONCAT(DATE_FORMAT(now(), '%Y-%m-%d'), ' ', a.appointmentStartTime) &lt;=  CONCAT(DATE_FORMAT(now(), '%Y-%m-%d'), ' ', #{item.startTime}) and CONCAT(DATE_FORMAT(now(), '%Y-%m-%d'), ' ', a.appointmentEndTime) &gt;=  CONCAT(DATE_FORMAT(now(), '%Y-%m-%d'), ' ', #{item.endTime})
        </if>
        <if test="null != item.siteTypeId">
            and a.siteTypeId = #{item.siteTypeId}
        </if>
        <if test="null != item.cityCode">
            and b.cityCode = #{item.cityCode}
        </if>
        <if test="null != item.storeId">
            and a.storeId = #{item.storeId}
        </if>
        <if test="null != item.search and '' != item.search">
            and (a.name like CONCAT('%', #{item.search}, '%') or b.name like CONCAT('%', #{item.search}, '%'))
        </if>
        order by a.insertTime desc limit #{item.pageNum}, #{item.pageSize}
    </select>
 
 
 
    <select id="queryMySite" resultType="com.dsh.other.model.QueryMySiteVo">
        select
        a.id,
        b.`name` as `name`,
        d.`name` as siteTypeName,
        c.`name` as storeName,
        c.address as storeAddress,
        c.lon as storeLon,
        c.lat as storeLat,
        a.payMoney as payMoney,
        CONCAT(DATE_FORMAT(a.startTime, '%Y-%m-%d %H:%i'), '-', DATE_FORMAT(a.endTime, '%H:%i')) as appointment,
        a.`status`,
        UNIX_TIMESTAMP(a.insertTime) * 1000 as insertTime
        from t_site_booking a
        left join t_site b on (a.siteId = b.id)
        left join t_store c on (b.storeId = c.id)
        left join t_site_type d on (b.siteTypeId = d.id)
        where a.state = 1 and a.appUserId = #{uid}
        <if test="null != status">
            and a.status = #{status}
        </if>
        order by a.insertTime desc limit #{pageNo}, #{pageSize}
    </select>
    <select id="listAll" resultType="com.dsh.other.model.dto.siteDto.TSiteDTO">
        select t1.*,t2.name storeName,t3.name siteTypeName from t_site t1
        inner join t_store t2 on t1.storeId = t2.id
        left join t_site_type t3 on t1.siteTypeId = t3.id
        where
        t1.sign=0
        <if test="query.objectType == 2">
        and t1.cityManagerId = #{query.objectId}
        </if>
        <if test="query.objectType == 3">
        and t2.storeStaffId = #{query.objectId}
        </if>
            <if test="query.city!=null and query.city!= ''">
                and t1.city = #{query.city}
            </if>
        <if test="query.province!=null and query.province!= ''">
            and t1.province = #{query.province}
        </if>
        <if test="query.siteTypeId!=null and query.siteTypeId!= ''">
            and t1.siteTypeId = #{query.siteTypeId}
        </if>
        <if test="query.storeName!=null and query.storeName!= ''">
            and t2.name like concat('%',#{query.storeName},'%')
        </if>
        <if test="query.name!=null and query.name!= ''">
            and t1.name like concat('%',#{query.name},'%')
        </if>
        and t1.state != 3
 
    </select>
    <select id="listExipre" resultType="com.dsh.other.model.dto.siteDto.TSiteDTO">
        select t1.*,t2.name storeName,t3.name siteTypeName ,t4.name operator from t_site t1
        inner join t_store t2 on t1.storeId = t2.id
        left join t_site_type t3 on t1.siteTypeId = t3.id
        left join t_operator t4 on t1.operatorId = t4.id
        <where>
            <if test="query.objectType == 2">
                and t1.operatorId = #{query.objectId}
            </if>
            <if test="query.objectType == 3">
                and t2.id = #{query.objectId}
            </if>
            <if test="query.city!=null and query.city!= ''">
                and t1.cityCode = #{query.city}
            </if>
            <if test="query.province!=null and query.province!= ''">
                and t1.provinceCode = #{query.province}
            </if>
            <if test="query.siteTypeId!=null and query.siteTypeId!= ''">
                and t1.siteTypeId = #{query.siteTypeId}
            </if>
            <if test="query.storeName!=null and query.storeName!= ''">
                and t2.name like concat('%',#{query.storeName},'%')
            </if>
            <if test="query.name!=null and query.name!= ''">
                and t1.name like concat('%',#{query.name},'%')
            </if>
 
            <if test="query.opId!=null ">
                and t1.operatorId =#{query.opId}
            </if>
            and t1.state != 3
        </where>
 
        ORDER BY insertTime desc
    </select>
</mapper>