46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Exports\Sheets;
|
|
|
|
use App\Models\AgentUser;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
use App\Models\ActivityOrder;
|
|
use App\Models\User;
|
|
|
|
class ActivityMember implements FromCollection,WithTitle
|
|
{
|
|
/**
|
|
* @return \Illuminate\Support\Collection
|
|
*/
|
|
public function collection()
|
|
{
|
|
//幸运奖 有余额的VIP + 有余额的批发商
|
|
$rows = [
|
|
["用户ID", "姓名", "手机号", "类型"]
|
|
];
|
|
$user_ids = ActivityOrder::whereHas("agentUser",function ($sql) {
|
|
$sql->where("level", AgentUser::AgentLevelBeing)->orWhere("level", AgentUser::AgentVIP);
|
|
})->with("user")->where('is_pay', 1)->whereIn('activity_id', [17,18])->where('residue_amount', ">", 0)->pluck("user_id")->toArray();
|
|
$users = User::with("agentUser")->whereIn("id", $user_ids)->get();
|
|
|
|
foreach($users as $user) {
|
|
$rows[] = [
|
|
$user->id,
|
|
$user->name,
|
|
$user->mobile,
|
|
($user->agentUser->level == AgentUser::AgentLevelBeing)?"有余额的批发商":"有余额的VIP"
|
|
];
|
|
}
|
|
return collect($rows);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function title(): string
|
|
{
|
|
return '幸运奖';
|
|
}
|
|
}
|