luodangjia
2024-06-11 9d2babb8bb99d55d76eab0558fd9f510652b270c
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
<?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.TOrderCharteredCarMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TOrderCharteredCar">
        <id column="id" property="id" />
        <result column="userId" property="userId" />
        <result column="companyId" property="companyId" />
        <result column="orderNumber" property="orderNumber" />
        <result column="traveltime" property="traveltime" />
        <result column="carTime" property="carTime" />
        <result column="serverCarModelId" property="serverCarModelId" />
        <result column="modelUse" property="modelUse" />
        <result column="peopleNumber" property="peopleNumber" />
        <result column="contactPerson" property="contactPerson" />
        <result column="contactPhone" property="contactPhone" />
        <result column="state" property="state" />
        <result column="remark" property="remark" />
        <result column="isDelete" property="isDelete" />
        <result column="insertTime" property="insertTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userId, companyId, orderNumber, traveltime, carTime, serverCarModelId, modelUse, peopleNumber, contactPerson, contactPhone, state, remark, isDelete, insertTime
    </sql>
 
    <!--根据条件查询包车订单列表-->
    <select id="getCharterCarOrderList" resultType="map" parameterType="com.baomidou.mybatisplus.plugins.Page">
        SELECT * FROM (
        SELECT
        ui.nickName as userName,
        ui.phone as userPhone,
        oc.* ,
        sc.`name` as serverCarModel,
        cs.serviceMoney as price,
        cs.`serviceName` as serviceName
        FROM t_order_chartered_car as oc
        LEFT JOIN t_user as ui on ui.id = oc.userId
        LEFT JOIN t_server_carmodel as sc on (oc.serverCarModelId = sc.id)
        left join t_chartered_service as cs on (oc.serviceId = cs.id)
        ) as o
        <where>
            o.isDelete = 1
            <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
                AND (o.insertTime between CONCAT(#{beginTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59'))
            </if>
            <if test="userName != null and userName != ''">
                and o.userName  LIKE CONCAT('%',#{userName},'%')
            </if>
            <if test="contactPerson != null and contactPerson != ''">
                and o.contactPerson  LIKE CONCAT('%',#{contactPerson},'%')
            </if>
            <if test="contactPhone != null and contactPhone != ''">
                and o.contactPhone  LIKE CONCAT('%',#{contactPhone},'%')
            </if>
            <if test="modelUse != null and modelUse != ''">
                and o.modelUse  LIKE CONCAT('%',#{modelUse},'%')
            </if>
            <if test="state != null and state != ''">
                and o.state = #{state}
            </if>
            <if test="roleType != null and roleType != '' and roleType == 2">
                and (o.companyId = #{nowUserId} or FIND_IN_SET(o.companyId,(SELECT GROUP_CONCAT(id) as ids FROM t_company where superiorId = #{nowUserId} GROUP BY superiorId)))
            </if>
            <if test="roleType != null and roleType != '' and roleType == 3">
                and o.companyId = #{nowUserId}
            </if>
        </where>
        order by o.id desc
    </select>
 
</mapper>