<?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.ReassignMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Reassign">
|
<id column="id" property="id"/>
|
<result column="orderType" property="orderType"/>
|
<result column="orderId" property="orderId"/>
|
<result column="originalDriverId" property="originalDriverId"/>
|
<result column="originalCarId" property="originalCarId"/>
|
<result column="insertTime" property="insertTime"/>
|
<result column="nowDriverId" property="nowDriverId"/>
|
<result column="nowCarId" property="nowCarId"/>
|
<result column="money" property="money"/>
|
<result column="payType" property="payType"/>
|
<result column="payTime" property="payTime"/>
|
<result column="payOrder" property="payOrder"/>
|
<result column="state" property="state"/>
|
<result column="reason" property="reason"/>
|
<result column="remark" property="remark"/>
|
<result column="reviewer" property="reviewer"/>
|
<result column="reviewerType" property="reviewerType"/>
|
<result column="completeTime" property="completeTime"/>
|
</resultMap>
|
|
|
|
<select id="queryApplyReassignList" resultType="map">
|
select
|
a.id as id,
|
DATE_FORMAT(a.insertTime, '%Y年%m月%d日%H:%i') as applyTime,
|
if(a.orderType = 1, c.startAddress, b.startAddress) as startAddress,
|
if(a.orderType = 1, c.endAddress, b.endAddress) as endAddress,
|
CONCAT(d.`name`, '-', f.carLicensePlate) applyDriver,
|
CONCAT(e.`name`, '-', g.carLicensePlate) nowDriver,
|
a.state as state,
|
a.orderType as orderType
|
from t_reassign a
|
left join t_order_cross_city b on (a.orderId = b.id and a.orderType = 3)
|
left join t_order_private_car c on (a.orderId = c.id and a.orderType = 1)
|
left join t_driver d on (a.originalDriverId = d.id)
|
left join t_driver e on (a.nowDriverId = e.id)
|
left join t_car f on (d.carId = f.id)
|
left join t_car g on (e.carId = g.id)
|
where a.orderType in (1, 3)
|
<if test="null != companyId">
|
and if(d.franchiseeId is null or d.franchiseeId = 0, d.companyId = #{companyId}, d.franchiseeId = #{companyId})
|
</if>
|
<if test="state == 1">
|
and a.state in (2) and (b.state not in (10, 12) or c.state not in (10, 12))
|
</if>
|
<if test="state == 2">
|
and a.state in (3, 4, 5)
|
</if>
|
order by a.insertTime desc
|
<if test="null != pageNum and null != size">
|
limit #{pageNum}, #{size}
|
</if>
|
</select>
|
|
|
<select id="queryReassignInfo" resultType="map">
|
select
|
a.id as id,
|
DATE_FORMAT(a.insertTime, '%Y.%m.%d-%H:%i') as applyTime,
|
CONCAT(d.`name`, '-', e.carLicensePlate) as applyDriver,
|
a.reason as reason,
|
if(a.orderType = 1, f.nickName, g.nickName) as `user`,
|
if(a.orderType = 1, DATE_FORMAT(b.travelTime, '%Y.%m.%d-%H:%i'), DATE_FORMAT(c.travelTime, '%Y.%m.%d-%H:%i')) as travelTime,
|
if(a.orderType = 1, b.startAddress, c.startAddress) as startAddress,
|
if(a.orderType = 1, b.endAddress, c.endAddress) as endAddress,
|
if(a.orderType = 1, b.state, c.state) as state,
|
a.state as `status`,
|
if(a.reviewerType = 1, i.`name`, h.`name`) as reviewer,
|
CONCAT(j.`name`, '-', k.carLicensePlate) as nowDriver,
|
a.orderType as orderType
|
from t_reassign a
|
left join t_order_private_car b on (a.orderId = b.id and a.orderType = 1)
|
left join t_order_cross_city c on (a.orderId = c.id and a.orderType = 3)
|
left join t_driver d on (a.originalDriverId = d.id)
|
left join t_car e on (a.originalCarId = e.id)
|
left join t_user f on (b.userId = f.id)
|
left join t_user g on (c.userId = g.id)
|
left join sys_user h on (a.reviewer = h.id and a.reviewerType = 2)
|
left join t_dispatch i on (a.reviewer = i.id and a.reviewerType = 1)
|
left join t_driver j on (a.nowDriverId = j.id)
|
left join t_car k on (a.nowCarId = k.id)
|
where a.id = #{id}
|
</select>
|
</mapper>
|