<?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.DriverMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Driver">
|
<id column="id" property="id" />
|
<result column="account" property="account" />
|
<result column="jobNumber" property="jobNumber" />
|
<result column="phone" property="phone" />
|
<result column="phoneOperator" property="phoneOperator"/>
|
<result column="password" property="password" />
|
<result column="withdrawPassword" property="withdrawPassword"/>
|
<result column="lastName" property="lastName" />
|
<result column="firstName" property="firstName"/>
|
<result column="sex" property="sex" />
|
<result column="idCard" property="idCard" />
|
<result column="companyId" property="companyId" />
|
<result column="franchiseeId" property="franchiseeId"/>
|
<result column="headImgUrl" property="headImgUrl" />
|
<result column="faceImgUrl" property="faceImgUrl" />
|
<result column="idCardImgUrl1" property="idCardImgUrl1" />
|
<result column="idCardImgUrl2" property="idCardImgUrl2" />
|
<result column="placeOfEmployment" property="placeOfEmployment" />
|
<result column="birthday" property="birthday" />
|
<result column="bankCardNumber" property="bankCardNumber" />
|
<result column="driverNationality" property="driverNationality" />
|
<result column="driverNation" property="driverNation" />
|
<result column="driverMaritalStatus" property="driverMaritalStatus" />
|
<result column="driverLanguageLevel" property="driverLanguageLevel" />
|
<result column="driverEducation" property="driverEducation" />
|
<result column="driverCensus" property="driverCensus" />
|
<result column="driverAddress" property="driverAddress" />
|
<result column="driverContactAddress" property="driverContactAddress" />
|
<result column="driverContactAddress_" property="driverContactAddress_" />
|
<result column="driverAge" property="driverAge" />
|
<result column="driveCard" property="driveCard" />
|
<result column="driveCardImgUrl1" property="driveCardImgUrl1" />
|
<result column="driveCardImgUrl2" property="driveCardImgUrl2" />
|
<result column="email" property="email"/>
|
<result column="driverType" property="driverType" />
|
<result column="getDriverLicenseDate" property="getDriverLicenseDate" />
|
<result column="driverLicenseOn" property="driverLicenseOn" />
|
<result column="driverLicenseOff" property="driverLicenseOff" />
|
<result column="taxiDriver" property="taxiDriver" />
|
<result column="taxiAptitudeCard" property="taxiAptitudeCard" />
|
<result column="networkCarlssueImg" property="networkCarlssueImg"/>
|
<result column="networkCarlssueOrganization" property="networkCarlssueOrganization" />
|
<result column="networkCarlssueDate" property="networkCarlssueDate" />
|
<result column="getNetworkCarProofDate" property="getNetworkCarProofDate" />
|
<result column="networkCarProofOn" property="networkCarProofOn" />
|
<result column="networkCarProofOff" property="networkCarProofOff" />
|
<result column="registerDate" property="registerDate" />
|
<result column="fullTimeDriver" property="fullTimeDriver" />
|
<result column="inDriverBlacklist" property="inDriverBlacklist" />
|
<result column="commercialType" property="commercialType" />
|
<result column="contractCompany" property="contractCompany" />
|
<result column="contractOn" property="contractOn" />
|
<result column="contractOff" property="contractOff" />
|
<result column="emergencyContact" property="emergencyContact" />
|
<result column="emergencyContactPhone" property="emergencyContactPhone" />
|
<result column="emergencyContactAddress" property="emergencyContactAddress" />
|
<result column="remark" property="remark" />
|
<result column="isPlatCar" property="isPlatCar" />
|
<result column="carId" property="carId" />
|
<result column="authState" property="authState" />
|
<result column="state" property="state" />
|
<result column="addType" property="addType" />
|
<result column="balance" property="balance" />
|
<result column="activityMoney" property="activityMoney" />
|
<result column="laveActivityMoney" property="laveActivityMoney" />
|
<result column="businessMoney" property="businessMoney" />
|
<result column="laveBusinessMoney" property="laveBusinessMoney" />
|
<result column="placeOfPractice" property="placeOfPractice"/>
|
<result column="appletsOpenId" property="appletsOpenId"/>
|
<result column="language" property="language"/>
|
|
<result column="flag" property="flag"/>
|
<result column="insertTime" property="insertTime"/>
|
<result column="insertUser" property="insertUser"/>
|
<result column="updateTime" property="updateTime"/>
|
<result column="updateUser" property="updateUser"/>
|
<result column="uid" property="uid"/>
|
<result column="uType" property="uType"/>
|
</resultMap>
|
|
|
|
<select id="queryByPhone" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and authState != 4 and phone = #{phone}
|
</select>
|
|
|
<select id="queryAccount" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and authState != 4 and account = #{account}
|
</select>
|
|
|
|
|
<select id="queryByPhone_" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and authState = #{authState} and phone = #{phone}
|
</select>
|
|
|
|
<select id="getCount" resultType="int">
|
select count(id) from t_driver where flag != 3 and authState != 4
|
</select>
|
|
|
<select id="queryHomeData" resultType="map">
|
select
|
b.carLicensePlate as licensePlate,
|
CONCAT(d.`name`, ' ', c.`name`, ' . ', b.carColor) as brand,
|
(
|
(select count(id) from t_order_private_car where driverId = a.id and state in (7, 8, 9) and to_days(insertTime) = to_days(now())) +
|
(select count(id) from t_order_taxi where driverId = a.id and state in (7, 8, 9) and to_days(insertTime) = to_days(now())) +
|
(select count(id) from t_order_cross_city where driverId = a.id and state in (6, 8, 9) and to_days(insertTime) = to_days(now())) +
|
(select count(id) from t_order_logistics where driverId = a.id and state in (7, 8, 9) and to_days(insertTime) = to_days(now()))
|
) as dayNum,
|
(
|
(select count(id) from t_order_private_car where driverId = a.id and state in (7, 8, 9) and DATE_FORMAT(insertTime, '%Y%m') = DATE_FORMAT(now(), '%Y%m')) +
|
(select count(id) from t_order_taxi where driverId = a.id and state in (7, 8, 9) and DATE_FORMAT(insertTime, '%Y%m') = DATE_FORMAT(now(), '%Y%m')) +
|
(select count(id) from t_order_cross_city where driverId = a.id and state in (6, 8, 9) and DATE_FORMAT(insertTime, '%Y%m') = DATE_FORMAT(now(), '%Y%m')) +
|
(select count(id) from t_order_logistics where driverId = a.id and state in (7, 8, 9) and DATE_FORMAT(insertTime, '%Y%m') = DATE_FORMAT(now(), '%Y%m'))
|
) as mouthNum,
|
((select sum(fraction) from t_order_evaluate where driverId = a.id) / (select count(fraction) from t_order_evaluate where driverId = a.id)) as score,
|
if((select count(id) from t_driver_work where driverId = a.id and state = 1) != 0, 1, 2) as `work`
|
from t_driver a
|
left join t_car b on (a.carId = b.id)
|
left join t_car_model c on (b.carModelId = c.id)
|
left join t_car_brand d on (c.brandId = d.id)
|
where a.id = #{uid}
|
</select>
|
|
|
<select id="queryInfo" resultType="map">
|
select
|
a.id as id,
|
a.headImgUrl as avatar,
|
a.sex as sex,
|
a.lastName as lastName,
|
a.firstName as firstName,
|
a.phoneOperator as phoneOperator,
|
a.phone as phone,
|
DATE_FORMAT(a.birthday, '%Y-%m-%d') as birthday,
|
a.email,
|
a.driverAddress,
|
a.qrCode,
|
a.language,
|
a.laveActivityMoney as balance,
|
a.laveActivityMoney as laveActivityMoney,
|
a.activityMoney as activityMoney,
|
a.businessMoney as businessMoney,
|
a.laveBusinessMoney as laveBusinessMoney,
|
a.taxiAptitudeCard as taxiAptitudeCard,
|
DATE_FORMAT(a.networkCarlssueDate, '%Y-%m-%d') as networkCarlssueDate,
|
a.driverContactAddress_ as driverContactAddress_,
|
a.idCard as idCard,
|
a.authState as authState,
|
a.idCardImgUrl1 as idCardImgUrl1,
|
a.idCardImgUrl2 as idCardImgUrl2,
|
DATE_FORMAT(a.getDriverLicenseDate, '%Y-%m-%d') as getDriverLicenseDate,
|
(select GROUP_CONCAT(type Separator ',') from t_driver_service where driverId = a.id) as `type`,
|
a.placeOfPractice as placeOfPractice,
|
a.driveCardImgUrl1 as driveCardImgUrl,
|
a.driveCardImgUrl2 as driveCardImgUrl2,
|
b.drivingLicensePhoto,b.carModelId,b.carBrandId,a.carId,
|
a.networkCarlssueImg as networkCarlssueImg,
|
a.placeOfEmployment as placeOfEmployment,
|
(select id from t_city where chineseName = a.placeOfPractice or englishName = a.placeOfPractice or frenchName = a.placeOfPractice)placeOfPracticeId,
|
(select `name` from t_company where 1 = 1 and if(a.companyId is null or a.companyId = 0, id = 1, if(a.franchiseeId is null or a.franchiseeId = 0, id = a.companyId, id = a.franchiseeId))) as company,
|
b.carLicensePlate as licensePlate,
|
b.carColor as carColor,
|
b.vehicleId,
|
CONCAT(d.`name`, ' ', c.`name`) as brand,
|
(
|
(select count(id) from t_order_private_car where driverId = a.id and state in (6, 7, 8, 9)) +
|
(select count(id) from t_order_logistics where driverId = a.id and state in (6, 7, 8, 9))
|
) as orderNum,
|
((select sum(fraction) from t_order_evaluate where driverId = a.id) / (select count(fraction) from t_order_evaluate where driverId = a.id)) as score
|
from t_driver a
|
left join t_car b on (a.carId = b.id)
|
left join t_car_model c on (b.carModelId = c.id)
|
left join t_car_brand d on (c.brandId = d.id)
|
where a.id = #{uid}
|
</select>
|
|
|
|
<select id="queryByJobNum" resultType="Driver">
|
select * from t_driver where flag != 3 and jobNumber = #{jobNum}
|
</select>
|
|
|
|
<select id="queryWorkDriver" resultType="Driver">
|
select
|
a.*
|
from t_driver a
|
left join t_driver_work b on (a.id = b.driverId)
|
where flag != 3 and b.state = 1
|
</select>
|
|
|
<select id="queryNeedCertificate" resultType="int">
|
select isQualifications from t_open_city where flag != 3 and code = #{code}
|
</select>
|
|
|
|
<select id="queryByCompanyId" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and authState = 2
|
<choose>
|
<when test="companyId == 1">
|
and (companyId = 1 or companyId is null or companyId = 0) and (franchiseeId = 0 or franchiseeId is null)
|
</when>
|
<otherwise>
|
and companyId = #{companyId} or franchiseeId = #{companyId}
|
</otherwise>
|
</choose>
|
</select>
|
|
|
|
<select id="queryByIdentification" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and idCard = #{identification}
|
</select>
|
|
|
|
|
<select id="queryByTaxiAptitudeCard" resultType="Driver">
|
select *
|
from t_driver where flag != 3 and taxiAptitudeCard = #{taxiAptitudeCard}
|
</select>
|
|
<select id="queryMyInviteDriverList" resultType="map">
|
select
|
id as id,
|
phoneOperator as phoneOperator,
|
phone as phone,
|
CONCAT(firstName, " ", lastName) as name,
|
headImgUrl as avatar,
|
DATE_FORMAT(insertTime,'%Y-%m-%d %H:%i') as insertTime
|
from
|
t_driver
|
where uid=#{uid}
|
and uType=#{uType}
|
order by insertTime desc
|
limit #{pageNum}, #{size}
|
</select>
|
<select id="getAppOpenInfo" resultType="Integer">
|
select isOpen from app_open_info where type=#{type}
|
</select>
|
<select id="getWithdrawalRule" resultType="Integer">
|
SELECT weeks FROM app_withdrawal_rule LIMIT 1
|
</select>
|
<select id="getDriverOnlineTime" resultType="Integer">
|
SELECT
|
IFNULL(SUM(o.timeNumber),0)
|
FROM
|
(
|
SELECT
|
TIMESTAMPDIFF(
|
MINUTE,
|
startTime,
|
CASE
|
WHEN endTime IS NULL THEN
|
NOW()
|
ELSE
|
endTime
|
END
|
)timeNumber
|
FROM
|
t_driver_work
|
WHERE
|
driverId = #{driverId}
|
<if test="type == 1">
|
and to_days(startTime) = to_days(now())
|
</if>
|
<if test="type == 2">
|
and YEARWEEK(date_format(startTime,'%Y-%m-%d')) = YEARWEEK(now())
|
</if>
|
<if test="type == 3">
|
and DATE_FORMAT( startTime, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
|
</if>
|
) o
|
</select>
|
<select id="getThisWeekMoney" resultType="Double">
|
SELECT
|
SUM(money)
|
FROM
|
t_income
|
WHERE
|
userType = 2
|
AND type != 1
|
AND orderType = 1
|
AND objectId=#{driverId}
|
AND YEARWEEK(
|
date_format(insertTime, '%Y-%m-%d')
|
) = YEARWEEK(now())
|
</select>
|
|
|
<select id="queryIdleDriver_" resultType="Driver">
|
select * from (
|
select
|
*
|
from t_driver
|
where flag != 3 and state = 2 and authState = 2
|
<if test="null != companyId">
|
<choose>
|
<when test="companyId != 1">
|
and companyId = #{companyId} or franchiseeId = #{companyId}
|
</when>
|
<otherwise>
|
and companyId is null or companyId = 0 or companyId = 1 or franchiseeId is null or franchiseeId = 0
|
</otherwise>
|
</choose>
|
|
</if>
|
and id in
|
(
|
select driverId from t_driver_work where startTime < now() and state = 1 and `type` like CONCAT('%', #{type}, '%')
|
)
|
and id in (select driverId from t_driver_orders where `type` = #{type})
|
and carId in (select carId from t_car_service where `type` = #{type}
|
|
<if test="null != serverCarModelId">
|
and serverCarModelId = #{serverCarModelId}
|
</if>
|
)
|
) as aa <!--where aa.id not in (
|
select driverId from t_order_private_car where isDelete = 1 and driverPay = 1 and state in (7, 8, 9)
|
union all
|
select driverId from t_order_logistics where isDelete = 1 and driverPay = 1 and state != 10
|
)-->
|
</select>
|
</mapper>
|