接入公共服务
This commit is contained in:
@@ -4,9 +4,17 @@ 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
|
||||
@@ -15,12 +23,12 @@ class UserService
|
||||
public static function updateSn($sn, $email)
|
||||
{
|
||||
$user = User::first()
|
||||
->where('email',$email)
|
||||
->where('email', $email)
|
||||
->first();
|
||||
if(!$user){
|
||||
if (!$user) {
|
||||
return false;
|
||||
}
|
||||
if($user->sn != $sn){
|
||||
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;
|
||||
@@ -28,4 +36,28 @@ class UserService
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user