<?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.CarRentalMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.CarRental">
|
<id column="id" property="id"/>
|
<result column="userType" property="userType"/>
|
<result column="userId" property="userId"/>
|
<result column="title" property="title"/>
|
<result column="brandId" property="brandId"/>
|
<result column="brandName" property="brandName"/>
|
<result column="category" property="category"/>
|
<result column="seat" property="seat"/>
|
<result column="displacement" property="displacement"/>
|
<result column="gear" property="gear"/>
|
<result column="pickUpCarCarCertificates" property="pickUpCarCarCertificates"/>
|
<result column="rentMoney" property="rentMoney"/>
|
<result column="deposit" property="deposit"/>
|
<result column="describe" property="describe"/>
|
<result column="describeImgUrl" property="describeImgUrl"/>
|
<result column="contactsPhone" property="contactsPhone"/>
|
<result column="contactsName" property="contactsName"/>
|
<result column="provinceCode" property="provinceCode"/>
|
<result column="cityCode" property="cityCode"/>
|
<result column="provinceName" property="provinceName"/>
|
<result column="cityName" property="cityName"/>
|
<result column="createTime" property="createTime"/>
|
<result column="status" property="status"/>
|
<result column="addres" property="addres"/>
|
<result column="authRemark" property="authRemark"/>
|
<result column="imgUrl" property="imgUrl"/>
|
<result column="videoUrl" property="videoUrl"/>
|
<result column="firstPageShow" property="firstPageShow"/>
|
<result column="insertUser" property="insertUser"/>
|
</resultMap>
|
|
|
<select id="list" resultType="map">
|
select
|
a.id,
|
DATE_FORMAT(a.createTime, '%Y/%m/%d %H:%i') as createTime,
|
a.userType,
|
if(a.userType = 1, c.`name`, if(a.userType = 2, d.`name`, b.`name`)) as pushUser,
|
if(a.userType = 1, c.`phone`, if(a.userType = 2, d.`phone`, b.`principalPhone`)) as pushPhone,
|
a.title,
|
a.imgUrl,
|
a.brandName,
|
a.seat,
|
a.pickUpCarCarCertificates,
|
a.rentMoney,
|
a.firstPageShow,
|
a.contactsPhone,
|
a.`status`
|
from tb_car_rental a
|
left join t_company b on (a.userType = 3 and a.userId = b.id)
|
left join t_user c on (a.userType = 1 and a.userId = c.id)
|
left join t_driver d on (a.userType = 2 and a.userId = d.id)
|
where a.`status` != 6
|
<if test="null != companyId">
|
and a.userType = 3 and a.userId = #{companyId}
|
</if>
|
<if test="null != start and '' != start and null != end and '' != end">
|
and DATE_FORMAT(a.createTime, '%Y-%m-%d') BETWEEN #{start} and #{end}
|
</if>
|
<if test="null != title and '' != title">
|
and a.title like CONCAT('%', #{title}, '%')
|
</if>
|
<if test="null != brandId">
|
and a.brandId = #{brandId}
|
</if>
|
<if test="null != insertUser and '' != insertUser">
|
and (b.`name` like CONCAT('%', #{insertUser}, '%') or c.`name` like CONCAT('%', #{insertUser}, '%') or d.`name` like CONCAT('%', #{insertUser}, '%'))
|
</if>
|
<if test="null != status">
|
and a.status in
|
<foreach collection="status" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != userType">
|
and a.userType = #{userType}
|
</if>
|
order by a.createTime desc
|
<if test="null != offset and null != limit">
|
limit #{offset}, #{limit}
|
</if>
|
</select>
|
|
|
<select id="listCount" resultType="int">
|
select
|
count(1)
|
from tb_car_rental a
|
left join t_company b on (a.userType = 3 and a.userId = b.id)
|
left join t_user c on (a.userType = 1 and a.userId = c.id)
|
left join t_driver d on (a.userType = 2 and a.userId = d.id)
|
where a.`status` != 6
|
<if test="null != companyId">
|
and a.userType = 3 and a.userId = #{companyId}
|
</if>
|
<if test="null != start and '' != start and null != end and '' != end">
|
and DATE_FORMAT(a.createTime, '%Y-%m-%d') BETWEEN #{start} and #{end}
|
</if>
|
<if test="null != title and '' != title">
|
and a.title like CONCAT('%', #{title}, '%')
|
</if>
|
<if test="null != brandId">
|
and a.brandId = #{brandId}
|
</if>
|
<if test="null != insertUser and '' != insertUser">
|
and (b.`name` like CONCAT('%', #{insertUser}, '%') or c.`name` like CONCAT('%', #{insertUser}, '%') or d.`name` like CONCAT('%', #{insertUser}, '%'))
|
</if>
|
<if test="null != status">
|
and a.status in
|
<foreach collection="status" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != userType">
|
and a.userType = #{userType}
|
</if>
|
</select>
|
</mapper>
|