接入公共服务
This commit is contained in:
@@ -7,8 +7,11 @@ use app\model\FeishuUser;
|
||||
use app\model\User;
|
||||
use app\model\UserSn;
|
||||
use app\service\MailService;
|
||||
use app\service\UserService;
|
||||
use app\util\HttpClient;
|
||||
use app\util\JwtUtil;
|
||||
use app\util\Util;
|
||||
use support\Log;
|
||||
use support\Redis;
|
||||
use support\Request;
|
||||
|
||||
@@ -126,9 +129,9 @@ class UserController
|
||||
$res = User::select('id', 'email')
|
||||
->where('email', $email)
|
||||
->first();
|
||||
// if (!Util::isEmpty($res)) {
|
||||
// return Util::fail([], trans('email_repeat'));
|
||||
// }
|
||||
if (!empty($res)) {
|
||||
return Util::fail($res, trans('email_repeat'));
|
||||
}
|
||||
|
||||
if (Util::isEmpty($name)) {
|
||||
// return Util::fail([], trans('required_not_null'));
|
||||
@@ -159,15 +162,18 @@ class UserController
|
||||
|
||||
|
||||
if (Util::isEmpty($id)) {
|
||||
// 获取编号
|
||||
$userSnModel = new UserSn();
|
||||
$sn = $userSnModel->where('user_id', '=', 0)->inRandomOrder()->first();
|
||||
if (!$sn) {
|
||||
throw new BusinessException('未找到适用编号');
|
||||
$option = ['email' => $email];
|
||||
$userService = new UserService;
|
||||
$res = $userService->createOrquery($option);
|
||||
Log::info('register_rpc',$res);
|
||||
// return Util::fail($res, trans('register_fail'));
|
||||
if ($res['code'] != 200 && $res['data']['code'] != 0){
|
||||
return Util::fail($res, trans('register_fail'));
|
||||
}
|
||||
$data['sn'] = $sn['user_sn'];
|
||||
$res = User::create($data);
|
||||
UserSn::where(['user_sn'=>$data['sn']])->update(['user_id'=>$res['id']]);
|
||||
$data['sn'] = $res['data']['data']['sn'];
|
||||
$data['id'] = $res['data']['data']['uid'];
|
||||
$res = User::firstOrCreate(['sn' => $data['sn']],$data);
|
||||
$res['id'] = $data['id'];
|
||||
} else {
|
||||
$res = User::where('id', $id)
|
||||
->update($data);
|
||||
@@ -210,14 +216,28 @@ class UserController
|
||||
{
|
||||
$id = $request->user['id'];
|
||||
$avatar = Util::getParam($request, 'avatar_url');
|
||||
$socializePic = Util::getParam($request, 'socialize_pic_url');
|
||||
|
||||
$user = User::where('id', $id)->first();
|
||||
// 只填充前端传递的字段
|
||||
$user->fill($request->only(['name', 'sex', 'position', 'country_id', 'sign', 'mobile', 'address']));
|
||||
$user->fill($request->only(['name', 'sex', 'position', 'country_id', 'sign', 'mobile', 'address', 'socialize', 'socialize_pic']));
|
||||
|
||||
if(!Util::isEmpty($avatar)){
|
||||
$user->avatar = $avatar;
|
||||
}
|
||||
if(!Util::isEmpty($socializePic)){
|
||||
$user->socialize_pic = $socializePic;
|
||||
}
|
||||
|
||||
$mobile = $user->isDirty('mobile');
|
||||
$name = $user->isDirty('name');
|
||||
$sign = $user->isDirty('sign');
|
||||
if($mobile || $name || $sign){
|
||||
$userService = new UserService;
|
||||
$option = ['uid' => $user->id, 'phone' => $user->mobile, 'name' => $user->name, 'sign' => $user->sign, ];
|
||||
$res = $userService->update($option);
|
||||
Log::info('register_rpc',$res);
|
||||
}
|
||||
|
||||
$res = $user->save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user