master
cody 3 months ago
parent d2f09f4ec8
commit f153a87e99

@ -2,6 +2,7 @@
namespace App\Console\Commands;
use App\Models\Company;
use App\Models\User;
use App\Repositories\MeetRepository;
use App\Repositories\YuanheRepository;
@ -15,7 +16,7 @@ class UpdateCompany extends Command
*
* @var string
*/
protected $signature = 'update_company';
protected $signature = 'update_company {--user_id=}';
/**
* The console command description.
@ -41,14 +42,54 @@ class UpdateCompany extends Command
*/
public function handle()
{
$users = User::get();
$user_id = $this->option('user_id');
$users = User::where(function ($query) use ($user_id) {
if ($user_id) {
$query->where('id', $user_id);
}
})->get();
$YuanheRepository = new YuanheRepository();
foreach ($users as $user) {
$result = $YuanheRepository->companyInfo(['enterpriseName' => $user->company_name]);
dd($result);
if (!$result) {
$this->info($user->company_name . '公司不存在');
continue;
}
$where = ['company_name' => $result['enterpriseName']];
$data = [
'company_address' => $result['address'],
'business_scope' => $result['businessScope'],
'company_city' => $result['city'],
'contact_mail' => $result['contactMail'],
'contact_phone' => $result['contactPhone'],
'company_area' => $result['country'],
'credit_code' => $result['creditCode'],
'enterprise_id' => $result['enterpriseId'],
'company_name' => $result['enterpriseName'],
'is_abroad' => $result['isAbroad'],
'company_market' => $result['isOnStock'],
'is_yh_invested' => $result['isYhInvested'],
'logo' => $result['logo'],
'company_legal_representative' => $result['operName'],
'company_province' => $result['province'],
'company_industry' => $result['qccIndustry'],
'regist_amount' => $result['registAmount'],
'regist_capi_type' => $result['registCapiType'],
'company_date' => $result['startDate'],
'status' => $result['status'],
'stock_date' => $result['stockDate'],
'currency_type' => $result['currencyType'],
'stock_number' => $result['stockNumber'],
'stock_type' => $result['stockType'],
'company_tag' => $result['tagList'],
];
$company = Company::updateOrCreate($where, $data);
// 更新用户关联
$user->company_id = $company->id;
$user->save();
$this->info($result['enterpriseName'] . '-更新成功');
}
return $this->info('更新完成');
return $this->info('全部更新完成');
}

@ -5,10 +5,13 @@
namespace App\Http\Controllers\Mobile;
use App\Helpers\ResponseCode;
use App\Models\AppointmentConfig;
use App\Models\AppointmentType;
use App\Models\Banner;
use App\Models\Config;
use App\Repositories\YuanheRepository;
use Illuminate\Support\Facades\Validator;
class OtherController extends CommonController
{
@ -62,5 +65,36 @@ class OtherController extends CommonController
return $this->success($config);
}
/**
* @OA\Get(
* path="/api/mobile/other/company",
* tags={"小程序-其他"},
* summary="公司搜索",
* @OA\Parameter(name="company_name", in="query", @OA\Schema(type="integer"), required=true, description="公司名字"),
* @OA\Response(
* response=200,
* description="操作成功"
* )
* )
*/
public function company()
{
$all = \request()->all();
$messages = [
'company_name.required' => '公司名称必填',
];
$validator = Validator::make($all, [
'company_name' => 'required',
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$YuanheRepository = new YuanheRepository();
$result = $YuanheRepository->companyInfo(['enterpriseName' => $all['company_name']]);
if (!$result) {
return $this->fail([ResponseCode::ERROR_PARAMETER, '获取失败']);
}
return $this->success($result);
}
}

@ -17,7 +17,9 @@ use App\Models\ScoreLog;
use App\Models\ThirdAppointmentLog;
use App\Models\User;
use App\Repositories\DoorRepository;
use App\Repositories\YuanheRepository;
use EasyWeChat\Factory;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
@ -176,6 +178,11 @@ class UserController extends CommonController
}
$model->fill($all);
$model->save();
// 如果有公司信息,就更新一下公司
if (isset($all['company_name']) && !empty($all['company_name'])) {
// 调用命令行更新
Artisan::call("update_company --user_id={$model->id}");
}
// 判断下,如果用户新加入车牌号,并且有未开始或者进行中的预约,则直接预约车牌号
$appointmentModel = Appointment::where('user_id', $this->getUserId())
->where('status', 1)

@ -25,11 +25,12 @@ class YuanheRepository
public function getHeader()
{
$timestamp = time();
$token = md5($this->customerId . time() . $this->authKey);
$timestamp = time() * 1000;
$token = $this->customerId . $timestamp . $this->authKey;
$token = md5($token);
$token = strtoupper($token);
$header[] = 'Content-Type: application/x-www-form-urlencoded,application/json';
$header[] = 'Content-Type: application/json';
$header[] = "customerId: {$this->customerId}";
$header[] = "timestamp: {$timestamp}";
$header[] = "token: {$token}";
@ -42,6 +43,7 @@ class YuanheRepository
*/
public function companyInfo($params)
{
$params = json_encode($params);
$url = $this->baseUrl . '/master-service/openapi/businessCollege/enterprise/info';
$header = $this->getHeader();
try {

@ -55,6 +55,37 @@ return new class extends Migration {
$table->string('sales_volume')->nullable()->comment('销售额');
$table->timestamps();
$table->softDeletes();
// 业务范围
$table->string('business_scope')->nullable()->comment('业务范围');
// 联系邮箱
$table->string('contact_mail')->nullable()->comment('联系邮箱');
// 联系手机
$table->string('contact_phone')->nullable()->comment('联系手机');
// 统一社会代码
$table->string('credit_code')->nullable()->comment('统一社会代码');
// 企业id
$table->string('enterprise_id')->nullable()->comment('企业id');
// 是否境外
$table->tinyInteger('is_abroad')->nullable()->comment('是否境外');
// 是否元禾已投
$table->tinyInteger('is_yh_invested')->nullable()->comment('是否元禾已投');
// 企业logo
$table->string('logo')->nullable()->comment('企业logo');
// 注册金额
$table->string('regist_amount')->nullable()->comment('注册金额');
// 注册资本币种
$table->string('regist_capi_type')->nullable()->comment('注册资本币种');
// 企业状态
$table->string('status')->nullable()->comment('企业状态');
// 上市日期
$table->string('stock_date')->nullable()->comment('上市日期');
// 股票代码
$table->string('stock_number')->nullable()->comment('股票代码');
// 上市类型
$table->string('stock_type')->nullable()->comment('上市类型');
// 注册资本币种
$table->string('currency_type')->nullable()->comment('注册资本币种');
});
}

@ -238,6 +238,8 @@ Route::group(["namespace" => "Mobile", "prefix" => "mobile"], function () {
Route::get('other/config', [\App\Http\Controllers\Mobile\OtherController::class, "config"]);
// 轮播图
Route::get('other/banner', [\App\Http\Controllers\Mobile\OtherController::class, "banner"]);
// 公司查询
Route::get('other/company', [\App\Http\Controllers\Mobile\OtherController::class, "company"]);
// 通知
Route::get('course/notices', [\App\Http\Controllers\Mobile\CourseController::class, "notices"]);
// 课程

Loading…
Cancel
Save