select bo.*,omd.memberLevel,IFNULL(IFNULL(orvd.start_company_id,otd.start_company_id),bo.`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`,
`pay_way` AS `payWay`,`parent_user_company_id`
from `base_order` where (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreachcollection="types"
select bo.id,bo.type,bo.status,bo.order_amount,bo.real_amount,bo.order_origin,bo.parent_user_id as `userId`,bo.parent_position_id as `postionId`,
bo.has_pay,bo.pay_way,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 * from `base_order` where 1=1
<iftest="hasPay!=null">
and `has_pay`=#{hasPay}
</if>
and (`crt_time` between #{startDate} and #{endDate} or `pay_time` between #{startDate} and #{endDate} ) and `type` IN <foreachcollection="types"