<?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.TOrderCallMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TOrderCall">
|
<id column="id" property="id" />
|
<result column="userId" property="userId" />
|
<result column="serverCarModelId" property="serverCarModelId" />
|
<result column="driverId" property="driverId" />
|
<result column="carId" property="carId" />
|
<result column="orderNum" property="orderNum" />
|
<result column="placementLon" property="placementLon" />
|
<result column="placementLat" property="placementLat" />
|
<result column="placementAddress" property="placementAddress" />
|
<result column="startLon" property="startLon" />
|
<result column="startLat" property="startLat" />
|
<result column="endLon" property="endLon" />
|
<result column="startAddress" property="startAddress" />
|
<result column="endLat" property="endLat" />
|
<result column="endAddress" property="endAddress" />
|
<result column="boardingLon" property="boardingLon" />
|
<result column="boardingLat" property="boardingLat" />
|
<result column="boardingAddress" property="boardingAddress" />
|
<result column="boardingTime" property="boardingTime" />
|
<result column="getoffLon" property="getoffLon" />
|
<result column="getoffLat" property="getoffLat" />
|
<result column="getoffAddress" property="getoffAddress" />
|
<result column="getoffTime" property="getoffTime" />
|
<result column="mileage" property="mileage" />
|
<result column="payManner" property="payManner" />
|
<result column="payType" property="payType" />
|
<result column="orderMoney" property="orderMoney" />
|
<result column="startMileage" property="startMileage" />
|
<result column="startMoney" property="startMoney" />
|
<result column="mileageKilometers" property="mileageKilometers" />
|
<result column="mileageMoney" property="mileageMoney" />
|
<result column="duration" property="duration" />
|
<result column="durationMoney" property="durationMoney" />
|
<result column="wait" property="wait" />
|
<result column="waitMoney" property="waitMoney" />
|
<result column="longDistance" property="longDistance" />
|
<result column="longDistanceMoney" property="longDistanceMoney" />
|
<result column="parkMoney" property="parkMoney" />
|
<result column="roadTollMoney" property="roadTollMoney" />
|
<result column="holidayFee" property="holidayFee" />
|
<result column="redPacketMoney" property="redPacketMoney" />
|
<result column="couponMoney" property="couponMoney" />
|
<result column="redPacketId" property="redPacketId" />
|
<result column="couponId" property="couponId" />
|
<result column="discount" property="discount" />
|
<result column="discountMoney" property="discountMoney" />
|
<result column="activityId" property="activityId" />
|
<result column="taxiCardId" property="taxiCardId" />
|
<result column="userTaxiCardId" property="userTaxiCardId" />
|
<result column="discountAmount" property="discountAmount" />
|
<result column="companyId" property="companyId" />
|
<result column="payMoney" property="payMoney" />
|
<result column="thankYouFee" property="thankYouFee" />
|
<result column="remark" property="remark" />
|
<result column="substitute" property="substitute" />
|
<result column="passengers" property="passengers" />
|
<result column="passengersPhone" property="passengersPhone" />
|
<result column="state" property="state" />
|
<result column="insertTime" property="insertTime" />
|
<result column="travelTime" property="travelTime" />
|
<result column="snatchOrderTime" property="snatchOrderTime" />
|
<result column="setOutTime" property="setOutTime" />
|
<result column="arriveTime" property="arriveTime" />
|
<result column="startServiceTime" property="startServiceTime" />
|
<result column="endServiceTime" property="endServiceTime" />
|
<result column="orderType" property="orderType" />
|
<result column="orderSource" property="orderSource" />
|
<result column="invoiceId" property="invoiceId" />
|
<result column="isReassign" property="isReassign" />
|
<result column="reassignNotice" property="reassignNotice" />
|
<result column="trackId" property="trackId" />
|
<result column="isDelete" property="isDelete" />
|
<result column="oldState" property="oldState" />
|
<result column="telX" property="telX" />
|
<result column="bindId" property="bindId" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, userId, serverCarModelId, driverId, carId, orderNum, placementLon, placementLat, placementAddress, startLon, startLat, endLon, startAddress, endLat, endAddress, boardingLon, boardingLat, boardingAddress, boardingTime, getoffLon, getoffLat, getoffAddress, getoffTime, mileage, payManner, payType, orderMoney, startMileage, startMoney, mileageKilometers, mileageMoney, duration, durationMoney, wait, waitMoney, longDistance, longDistanceMoney, parkMoney, roadTollMoney, holidayFee, redPacketMoney, couponMoney, redPacketId, couponId, discount, discountMoney, activityId, taxiCardId, userTaxiCardId, discountAmount, companyId, payMoney, thankYouFee, remark, substitute, passengers, passengersPhone, state, insertTime, travelTime, snatchOrderTime, setOutTime, arriveTime, startServiceTime, endServiceTime, orderType, orderSource, invoiceId, isReassign, reassignNotice, trackId, isDelete, oldState, telX, bindId
|
</sql>
|
|
|
<select id="orderNoCollect" resultType="double">
|
|
|
SELECT IFNULL(SUM(orderMoney),0) allmoney FROM (
|
SELECT IFNULL(SUM(orderMoney),0) orderMoney FROM t_order_private_car opc WHERE opc.driverId=#{driverId} AND opc.state = 7
|
UNION
|
SELECT IFNULL(SUM(orderMoney),0) orderMoney FROM t_order_call oc WHERE oc.driverId=#{driverId} AND oc.state = 7
|
UNION
|
SELECT IFNULL(SUM(orderMoney),0) orderMoney FROM t_order_taxi ot WHERE ot.driverId=#{driverId} AND ot.state = 7
|
) tt
|
</select>
|
|
|
|
<select id="hasWithdrawalTotal" resultType="double">
|
select IFNULL(sum(money),0) amountTotal from t_pub_withdrawal
|
where userType = 2
|
and userId = #{driverId}
|
and state = 2
|
and type = #{type}
|
and handleTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</select>
|
|
|
|
<select id="excel" resultType="map">
|
select
|
d.id,
|
IFNULL(d.name,'') driverName,
|
IFNULL(d.phone,'') driverPhone,
|
IFNULL(activityMSG.activityIncome,0) allReward,
|
IFNULL(businessMSG.businessIncome,0) allOrderEarning,
|
IFNULL((IFNULL(activityMSG.activityIncome,0) + IFNULL(businessMSG.businessIncome,0)),0) allEarning,
|
IFNULL(hasActMSG.amountTotal,0) hasWithdrawalReward,
|
IFNULL((IFNULL(activityMSG.activityIncome,0) - IFNULL(hasActMSG.amountTotal,0)),0) noWithdrawalReward,
|
IFNULL(hasBusMSG.amountTotal,0) hasWithdrawalOrder,
|
IFNULL((IFNULL(businessMSG.businessIncome,0) - IFNULL(hasBusMSG.amountTotal,0)),0) noWithdrawalOrder,
|
IFNULL(needCollectMSG.allMoney,0) needCollectOrder
|
|
from t_driver d
|
|
left join (select IFNULL(sum(i.money),0) activityIncome,d.id from t_driver d left join t_income i on i.objectId = d.id where i.userType = 2
|
and i.type = 1
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and i.insertTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
group by d.id
|
) activityMSG
|
on activityMSG.id = d.id
|
|
left join (select IFNULL(sum(i.money),0) businessIncome,d.id from t_driver d left join t_income i on i.objectId = d.id where i.userType = 2
|
and i.type = 2
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and i.insertTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
group by d.id
|
) businessMSG
|
on businessMSG.id = d.id
|
|
left join (select IFNULL(sum(pw.money),0) amountTotal,d.id from t_driver d left join t_pub_withdrawal pw on d.id = pw.userId where pw.userType = 2
|
and pw.state = 2 and pw.type = 1
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and pw.handleTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
group by d.id
|
) hasActMSG
|
on hasActMSG.id = d.id
|
|
left join (select IFNULL(sum(pw.money),0) amountTotal,d.id from t_driver d left join t_pub_withdrawal pw on d.id = pw.userId where pw.userType = 2
|
and pw.state = 2 and pw.type = 2
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and pw.handleTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
group by d.id
|
) hasBusMSG
|
on hasBusMSG.id = d.id
|
|
left join (select (IFNULL(sum(opc.orderMoney),0) + IFNULL(sum(oc.orderMoney),0) + IFNULL(sum(ot.orderMoney),0)) allmoney,d.id from t_driver d
|
left join t_order_private_car opc on d.id = opc.driverId and opc.state = 7
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and opc.endServiceTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
left join t_order_call oc on oc.driverId = d.id and oc.state = 7
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and oc.endServiceTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
left join t_order_taxi ot on ot.driverId = d.id and ot.state = 7
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
and ot.endServiceTime between CONCAT(#{startTime},' 00:00:00') and CONCAT(#{endTime},' 23:59:59')
|
</if>
|
group by d.id) needCollectMSG
|
on d.id = needCollectMSG.id
|
|
where 1=1
|
<if test="list!=null and list.size>0">
|
AND d.id IN
|
<foreach collection="list" item="item" index="index" open="(" close=")"
|
separator=",">
|
#{item}
|
</foreach>
|
</if>
|
order by d.id desc
|
</select>
|
|
<!-- <select id="" resultType="map">-->
|
<!-- select-->
|
<!-- d.id,d.name,d.phone,-->
|
<!-- logisticsMSG.logisticsAllOrderMoney,logisticsMSG.type,logisticsMSG.isSameLogisticsFixedOrProportional,logisticsMSG.sameLogisticsMoney,logisticsMSG.zafeiLog,-->
|
<!-- callMSG.callAllOrderMoney,callMSG.isOncallFixedOrProportional,callMSG.OncallMoney,callMSG.zafeiCall,-->
|
<!-- privateMSG.privateAllOrderMoney,privateMSG.isSpe,privateMSG.speMoney,privateMSG.zafeiPre,-->
|
<!-- taxiMSG.taxiAllOrderMoney,taxiMSG.isTaxi,taxiMSG.taxiMoney,taxiMSG.zafeiTaxi-->
|
|
<!-- from t_driver d-->
|
<!-- left join (select oc.driverId,oc.type,(sum(oc.holidayFee) + sum(oc.thankYouFee) + sum(oc.redPacketMoney) + sum(feeMoney)) zafeiLog,-->
|
<!-- sum(oc.orderMoney) logisticsAllOrderMoney,c.isSameLogisticsFixedOrProportional,c.sameLogisticsMoney,c.isCrossLogisticsFixedOrProportional,c.crossLogisticsMoney-->
|
<!-- from t_order_logistics oc left join t_company c on oc.companyId = c.id left join (select sum(amount) feeMoney,orderId from t_order_additional_fee group by orderId) fee on fee.orderId = oc.id where oc.driverId is not null-->
|
<!-- group by oc.driverId) logisticsMSG on d.id = logisticsMSG.driverId-->
|
|
<!-- left join (select oc.driverId,(sum(oc.holidayFee) + sum(oc.thankYouFee) + sum(oc.redPacketMoney) + sum(feeMoney)) zafeiCall,-->
|
<!-- sum(oc.orderMoney) callAllOrderMoney,c.isOncallFixedOrProportional,c.OncallMoney-->
|
<!-- from t_order_call oc left join t_company c on oc.companyId = c.id left join (select sum(amount) feeMoney,orderId from t_order_additional_fee group by orderId) fee on fee.orderId = oc.id where oc.driverId is not null-->
|
<!-- group by oc.driverId) callMSG on d.id = callMSG.driverId-->
|
|
<!-- left join (select oc.driverId,(sum(oc.holidayFee) + sum(oc.thankYouFee) + sum(oc.redPacketMoney) + sum(feeMoney)) zafeiPre,-->
|
<!-- sum(oc.orderMoney) privateAllOrderMoney,c.isSpe,c.speMoney-->
|
<!-- from t_order_private_car oc left join t_company c on oc.companyId = c.id left join (select sum(amount) feeMoney,orderId from t_order_additional_fee group by orderId) fee on fee.orderId = oc.id where oc.driverId is not null-->
|
<!-- group by oc.driverId) privateMSG on d.id = privateMSG.driverId-->
|
|
<!-- left join (select oc.driverId,(sum(oc.holidayFee) + sum(oc.thankYouFee) + sum(oc.redPacketMoney) + sum(feeMoney)) zafeiTaxi,sum(oc.orderMoney) taxiAllOrderMoney,c.isTaxi,c.taxiMoney-->
|
<!-- from t_order_taxi oc left join t_company c on oc.companyId = c.id left join (select sum(amount) feeMoney,orderId from t_order_additional_fee group by orderId) fee on fee.orderId = oc.id where oc.driverId is not null-->
|
<!-- group by oc.driverId) taxiMSG on d.id = taxiMSG.driverId-->
|
<!-- </select>-->
|
</mapper>
|