Files
crm-server/app/service/UserService.php
T

63 lines
1.4 KiB
PHP
Raw Normal View History

2025-03-26 09:57:25 +08:00
<?php
namespace app\service;
use app\model\User;
use app\model\UserSn;
2025-04-02 15:17:13 +08:00
use app\util\HttpClient;
2025-03-26 09:57:25 +08:00
class UserService
{
2025-04-02 15:17:13 +08:00
protected $domain;
public function __construct(){
$this->domain = config('const.rpc_domain');
}
2025-03-26 09:57:25 +08:00
/**
* 更新用户sn
* @param $sn
* @param $email
*/
public static function updateSn($sn, $email)
{
$user = User::first()
2025-04-02 15:17:13 +08:00
->where('email', $email)
2025-03-26 09:57:25 +08:00
->first();
2025-04-02 15:17:13 +08:00
if (!$user) {
2025-03-26 09:57:25 +08:00
return false;
}
2025-04-02 15:17:13 +08:00
if ($user->sn != $sn) {
2025-03-26 09:57:25 +08:00
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;
}
2025-04-02 15:17:13 +08:00
/**
* 创建或查询用户
* @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;
}
2025-03-26 09:57:25 +08:00
}