select bo.*,omd.memberLevel,IFNULL(orvd.start_company_id,otd.start_company_id) AS `companyId` from (select `id`,`type`,`status`,`order_amount` AS `orderAmount`, `real_amount`AS
select bo.*,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),`parent_user_company_id`) AS `companyId`,orvd.deposit,orvd.cost_detail_extend AS `costDetailExtend` from (select `id`,`type`,`status`,`order_amount` AS `orderAmount`, `real_amount`AS
`realAmount`,`order_origin` AS `orderOrigin`, `has_pay` AS `hasPay`,
`realAmount`,`order_origin` AS `orderOrigin`, `has_pay` AS `hasPay`,
`pay_way` AS `payWay`
`pay_way` AS `payWay`
from `base_order` where (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreachcollection="types"
from `base_order` where (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreachcollection="types"
...
@@ -363,7 +363,7 @@
...
@@ -363,7 +363,7 @@
separator=",">
separator=",">
#{type}
#{type}
</foreach> ) AS `bo`
</foreach> ) AS `bo`
LEFT JOIN (select `order_id`,`start_company_id` from `order_rent_vehicle_detail`) AS `orvd` ON
LEFT JOIN (select `order_id`,`start_company_id`,`deposit`,`cost_detail_extend` from `order_rent_vehicle_detail`) AS `orvd` ON
orvd.order_id=bo.id
orvd.order_id=bo.id
LEFT JOIN (select `order_id`,`start_company_id` from `order_tour_detail`) AS `otd` ON otd.order_id=bo.id
LEFT JOIN (select `order_id`,`start_company_id` from `order_tour_detail`) AS `otd` ON otd.order_id=bo.id
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
LEFT JOIN (select `order_id`,`member_level` AS `memberLevel` from `order_member_detail`) AS `omd` ON
SELECT tmp1.countYear,tmp1.countMonth,tmp1.countDay, tmp1.companyId, tmp1.countWeek, tmp1.countNum as departureNum, tmp2.countNum as arrivalNum from (
SELECT YEAR(FROM_UNIXTIME(o.crt_time/1000)) as countYear, MONTH(FROM_UNIXTIME(o.crt_time/1000)) AS countMonth, DAY(FROM_UNIXTIME(o.crt_time/1000)) AS countDay, WEEK(FROM_UNIXTIME(o.crt_time/1000))as countWeek, o1.start_company_id as companyId, count(*) as countNum from order_vehicle_crosstown o
LEFT JOIN order_rent_vehicle_detail o1 on o.order_id = o1.order_id
where o.type = 1
<iftest="startTime != null">
and o.crt_time >= #{startTime} and o.crt_time <= #{endTime}
</if>
GROUP BY companyId, countYear,countMonth,countDay,countWeek
) tmp1
LEFT JOIN
(SELECT YEAR(FROM_UNIXTIME(o.crt_time/1000)) as countYear, MONTH(FROM_UNIXTIME(o.crt_time/1000)) AS countMonth, DAY(FROM_UNIXTIME(o.crt_time/1000)) AS countDay, WEEK(FROM_UNIXTIME(o.crt_time/1000))as countWeek, o1.end_company_id as companyId, count(*) as countNum from order_vehicle_crosstown o
LEFT JOIN order_rent_vehicle_detail o1 on o.order_id = o1.order_id
where (o.type = 2 or o.type = 3)
<iftest="startTime != null">
and o.crt_time >= #{startTime} and o.crt_time <= #{endTime}
</if>
GROUP BY companyId, countYear,countMonth,countDay,countWeek