where('official_account_bills.distribution_channel_id', $distribution_channel_id) ->join('official_accounts', 'official_account_bills.appid', '=', 'official_accounts.appid') ->leftjoin('send_order_breakeven_stats', function ($join) { $join->on('official_accounts.id', '=', 'send_order_breakeven_stats.official_account_id')->on('official_account_bills.date', '=', 'send_order_breakeven_stats.date'); }); $search_object->select('official_account_bills.distribution_channel_id', 'official_account_bills.appid', 'official_account_bills.date', 'official_account_bills.nickname', 'official_account_bills.recharge_amount', 'official_account_bills.channel_recharge_amount', 'send_order_breakeven_stats.recharge_amount_in_one_month as recharge_amount_in_30_days', 'send_order_breakeven_stats.recharge_amount_in_two_months as recharge_amount_in_60_days', 'send_order_breakeven_stats.recharge_amount_in_three_months as recharge_amount_in_90_days', 'send_order_breakeven_stats.force_user_num as new_fans_num'); if ($start_time) { $search_object->where('official_account_bills.date', '>=', $start_time); } if ($end_time) { $search_object->where('official_account_bills.date', '<=', $end_time); } if ($isAll) { return $search_object->get(); } else { return $search_object->paginate(); } } }