start_date = $start_date; $this->end_date = $end_date; } public function collection() { $start_date = $this->start_date; $end_date = $this->end_date; Log::info($start_date.'---'.$end_date); $users = MerchantUser::with("mpUser.profileCourtship","mUserProfile")->whereBetween('authorize_at', [$start_date, $end_date])->get(); $rows = [ ["ID", "姓名", "联系电话", "是否有过消费", "常住地"] ]; foreach ($users as $user) { $has_order = $user->orders()->where("merchant_id", 491)->where("pay_status", "<>", 0)->where("price", ">", 0)->count()?"有":"无"; $mp_user = $user->mpUser; $mp_profile = $user->mpUser?$user->mpUser->profileCourtship:null; $merchant_profile = $user->mUserProfile; $profile = $merchant_profile?:$mp_profile; $province = $profile?$profile->province:""; $city = $profile?$profile->city:""; $nickname = $mp_user?$mp_user->nickname:$user->nickname; $mobile = $mp_user?$mp_user->mobile:$user->mobile; $rows[] = [$user->id, $nickname, $mobile, $has_order, $province."-".$city]; } return collect($rows); } /** * @return string */ public function title(): string { return 'saas用户'; } }