select `orders`.`number`, `orders`.`startup_mode`, `orders`.`paid_type`, `agents`.`nickname` as `agent_name`, `users`.`mobile` as `user_mobile`, `users`.`nickname` as `user_name`, `orders`.`ic_card_number`, `orders`.`started_at`, `orders`.`stopped_at`, `orders`.`charging_time`, `orders`.`charging_electricity`, `orders`.`start_soc`, `orders`.`soc`, `stations`.`name` as `station_name`, `orders`.`station_city_name`, `orders`.`station_id`, `orders`.`pile_sn`, `orders`.`gun_sn`, `orders`.`gun_port`, `orders`.`pile_type`, `orders`.`pile_total_power`, `orders`.`plate_number`, `orders`.`vin`, `orders`.`stop_reason_detail`, `orders`.`paid_amount`, `orders`.`service_amount`, `orders`.`original_service_amount`, `orders`.`service_discount_amount`, IFNULL(divided.platform_divideds, 0) as platform_divideds, IFNULL(divided.agent_divideds, 0) as agent_divideds, IFNULL(divided.person_divideds, 0) as person_divideds, `tip_electricity`, `peak_electricity`, `flat_electricity`, `valley_electricity`, `tip_amount`, `peak_amount`, `flat_amount`, `valley_amount`, `tip_elec_amount`, `peak_elec_amount`, `flat_elec_amount`, `valley_elec_amount`, `tip_service_amount`, `peak_service_amount`, `flat_service_amount`, `valley_service_amount`, `tip_charging_time`, `peak_charging_time`, `flat_charging_time`, `valley_charging_time`, `invoice_status`, invoices.amount as invoice_amount, invoices.number as invoice_number, invoices.created_at as open_date from `orders` left join `agents` on `agents`.`id` = `orders`.`agent_id` left join `users` on `users`.`id` = `orders`.`user_id` left join `stations` on `stations`.`id` = `orders`.`station_id` left join `invoices` on FIND_IN_SET(orders.id,invoices.order_ids) > 0 left join (select order_id, SUM(CASE WHEN type = 1 THEN amount ELSE 0 END) AS platform_divideds, SUM(CASE WHEN type = 2 THEN amount ELSE 0 END) AS agent_divideds, SUM(CASE WHEN type = 3 THEN amount ELSE 0 END) AS person_divideds from `agent_divideds` group by `order_id`) as `divided` on `divided`.`order_id` = `orders`.`id` where `orders`.`paid_status` != ?