master
cody 3 months ago
parent 932f386805
commit cbe5dc577a

@ -16,7 +16,7 @@ class UpdateCompany extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'update_company {--user_id=} {--address=0} {--market=0}'; protected $signature = 'update_company {--user_id=} {--course_id=} {--address=0} {--market=0}';
/** /**
* The console command description. * The console command description.
@ -43,10 +43,11 @@ class UpdateCompany extends Command
public function handle() public function handle()
{ {
$user_id = $this->option('user_id'); $user_id = $this->option('user_id');
$course_id = $this->option('course_id');
$updateLocal = (int)$this->option('address'); $updateLocal = (int)$this->option('address');
$updateMarket = (int)$this->option('market'); $updateMarket = (int)$this->option('market');
// 更新公司信息 // 更新公司信息
$this->compnay($user_id); $this->compnay($user_id, $course_id);
// 更新经纬度信息(可选) // 更新经纬度信息(可选)
if ($updateLocal) { if ($updateLocal) {
$this->local($user_id); $this->local($user_id);
@ -61,7 +62,7 @@ class UpdateCompany extends Command
/** /**
* 更新公司信息 * 更新公司信息
*/ */
public function compnay($user_id = null) public function compnay($user_id = null, $course_id = null)
{ {
if ($user_id) { if ($user_id) {
// 强制单个更新 // 强制单个更新
@ -70,10 +71,14 @@ class UpdateCompany extends Command
})->where('id', $user_id)->get(); })->where('id', $user_id)->get();
} else { } else {
// 批量更新(只更新有报名审核通过的用户) // 批量更新(只更新有报名审核通过的用户)
$users = User::whereHas('courseSigns', function ($query) { $users = User::whereHas('courseSigns', function ($query) use ($course_id) {
$query->where('status', 1); $query->where('status', 1);
if ($course_id) {
$query->where('course_id', $course_id);
}
})->whereNotNull('company_name') })->whereNotNull('company_name')
->whereNull('company_id') ->whereNull('company_id')
->orderBy('id', 'desc')
->get(); ->get();
} }

Loading…
Cancel
Save