63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\service;
|
|
|
|
use app\model\User;
|
|
use app\model\UserSn;
|
|
use app\util\HttpClient;
|
|
|
|
class UserService
|
|
{
|
|
protected $domain;
|
|
|
|
|
|
public function __construct(){
|
|
$this->domain = config('const.rpc_domain');
|
|
}
|
|
|
|
/**
|
|
* 更新用户sn
|
|
* @param $sn
|
|
* @param $email
|
|
*/
|
|
public static function updateSn($sn, $email)
|
|
{
|
|
$user = User::first()
|
|
->where('email', $email)
|
|
->first();
|
|
if (!$user) {
|
|
return false;
|
|
}
|
|
if ($user->sn != $sn) {
|
|
UserSn::where(['sn' => $user->sn])->update(['user_id' => 0]);
|
|
UserSn::where(['sn' => $sn])->update(['user_id' => $user->id]);
|
|
$user->sn = $sn;
|
|
$user->save();
|
|
}
|
|
return $user;
|
|
}
|
|
|
|
/**
|
|
* 创建或查询用户
|
|
* @param array $data ['email'=>'','phone'=>'','company_tag'=>'','name'=>''];
|
|
* @return array
|
|
*/
|
|
public function createOrquery(array $data)
|
|
{
|
|
|
|
$result = HttpClient::post($this->domain . '/user/create/query', $data);
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* 创建或查询用户
|
|
* @param array $data ['email'=>'','phone'=>'','company_tag'=>'','name'=>''];
|
|
* @return array
|
|
*/
|
|
public function update(array $data)
|
|
{
|
|
|
|
$result = HttpClient::post($this->domain . '/user/update', $data);
|
|
return $result;
|
|
}
|
|
} |