'array', 'task_sing_data' => 'array', 'updated_at' => 'int', 'be_vip_at' => 'int', 'supvip_endat' => 'int' ]; public static function boot() { parent::boot(); self::saving(function (/** @var UserModel $model */ $model) { // 头像上传oss if ( 'local' != config('app.env') && !empty($model->headimgurl) && 0 == substr_count( $model->headimgurl, "oss.pocketuniversity.cn" ) ) { $response = Curl::to($model->headimgurl)->withResponseHeaders()->returnResponseObject()->get(); $new_avatar = sprintf("avatar/%s/%s.png", date('Y-m-d'), \Ramsey\Uuid\Uuid::uuid4()->toString()); Storage::disk('oss')->put($new_avatar, $response->content); $avatar = Storage::disk('oss')->url($new_avatar); $model->headimgurl = $avatar; } // 黑名单处理 if ( ( $model->isDirty('weixin') && BlackListModel::where('account_type', 'weixin') ->where('account', $model->weixin) ->first() ) || ( $model->isDirty('qq') && BlackListModel::where('account_type', 'qq') ->where('account', $model->qq) ->first() ) ) { RiskListModel::create([ 'uid' => $model->uid, 'phone' => $model->phone, 'weixin' => $model->weixin, 'qq' => $model->qq, ]); BlackListModel::updateOrcreate( ['account_type' => 'uid', 'account' => $model->uid], ['type' => 'all', 'end_at' => 1893427200, 'state' => 3] ); BlackListModel::updateOrcreate( ['account_type' => 'phone', 'account' => $model->phone], ['type' => 'all', 'end_at' => 1893427200, 'state' => 3] ); } // 更新登录时间 if ($model->isDirty('login_at') && $model->partner_id > 0) { try { PartnerModel::findOrFail($model->partner_id)->update(['login_at' => $model->login_at]); } catch (ModelNotFoundException $exception) { } } }); self::updated(function (/** @var UserModel $model */ $model) { event(new UpdatedUserInfo($model)); }); } /** * 初始化fpdx用户 * @param int $uid * @return UserModel|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model */ public function initUser(int $uid) { $isnew = false; try { $user = $this->findOrFail($uid); if (0 == $user->login_at) { $isnew = true; } } catch (Exception $e) { $user = $this->fill(['uid' => $uid, 'phone' => null]); $user->save(); $isnew = true; } if ($isnew) { NoticeModel::create([ 'uid' => $uid, 'title' => '欢迎来到分配对象', 'content' => "hi,你好呀,终于等到你了~今后就让小象带你认识有趣的人,遇见属于你的心动!快先来完善你的交友信息吧,小象等不及要给你“分配对象”啦~", 'type' => 5, 'type_id' => 0, 'tab_content' => '编辑个人资料', 'tab_url' => '/pages/my-friend-card-editor/my-friend-card-editor', ]); } return $user; } public function getAuth() { $apps = [ '1109365561' => '1109365561', //分配对象QQ小程序 '1109284509' => '1109284509', //时遇记QQ小程序 'gh_b598cb7474d8' => 'wx7955aab955345d39',//分配对象公众号 'gh_c94c95866ca5' => 'wxa80cac3f6c2de130',//时遇记公众号 'gh_01c089b58dda' => 'wx4c1722a4055bd229',//分配对象小程序, 'qq_unionid' => 'qq_unionid', 'kdgx_unionid' => 'unionid', 'phone' => 'phone', ]; $unionid = AuthKey::where('uid', $this->uid)->where('auth_type', 'kdgx_unionid')->value('auth_key'); $qq_unionid = AuthKey::where('uid', $this->uid)->where('auth_type', 'qq_unionid')->value('auth_key'); $data = [ 'uid' => $this->uid, 'sex' => $this->sex, 'device' => $this->login_app_platform, 'phone' => AuthKey::where('uid', $this->uid) ->where('auth_type', 'phone') ->value('auth_key'), 'unionid' => $unionid, 'qq_unionid' => $qq_unionid, 'wxa80cac3f6c2de130' => $unionid ? Openid::where('unionid', $unionid) ->where('public_id', 'gh_c94c95866ca5') ->value('openid') : '', 'wx7955aab955345d39' => $unionid ? Openid::where('unionid', $unionid) ->where('public_id', 'gh_b598cb7474d8') ->value('openid') : '', 'wx4c1722a4055bd229' => AuthKey::where('uid', $this->uid) ->where('auth_type', 'gh_01c089b58dda') ->value('auth_key') ?: '', '1109365561' => AuthKey::where('uid', $this->uid) ->where('auth_type', '1109365561') ->value('auth_key') ?: '', '1109284509' => AuthKey::where('uid', $this->uid) ->where('auth_type', '1109284509') ->value('auth_key') ?: '', ]; return $data; } public function black() { $black = [ 'msy' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'msy']) ->orderBy('end_at', 'desc') ->first(), 'fpdx' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'fpdx']) ->orderBy('end_at', 'desc') ->first(), 'black' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'black']) ->orderBy('end_at', 'desc') ->first(), 'chat' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'chat']) ->orderBy('end_at', 'desc') ->first(), 'night' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'night']) ->orderBy('end_at', 'desc') ->first(), 'home' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'home']) ->orderBy('end_at', 'desc') ->first(), 'account' => BlackListModel::select(['created_at', 'end_at', 'state']) ->where('account_type', 'uid') ->where('account', $this->uid) ->where('end_at', '>', time()) ->whereIn('type', ['all', 'account']) ->orderBy('end_at', 'desc') ->first(), ]; return $black; } public function getNicknameAttribute($value) { return $value ? mb_substr($value, 0, 10) : ''; } public function getHeadimgurlAttribute($value) { return $value ?: ''; } public function getAvatarAttribute() { return $this->headimgurl ?: ''; } public function getBirthdayAttribute() { return $this->age ?: null; } public function getFullUrlPhotoAttribute() { $url = $this->photo_src; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getFullUrlPhotoSrcAttribute() { $url = $this->photo_src; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getFullUrlPhoto1Attribute() { $url = $this->photo_1; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getFullUrlPhoto2Attribute() { $url = $this->photo_2; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getFullUrlPhoto3Attribute() { $url = $this->photo_3; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getFullUrlPhoto4Attribute() { $url = $this->photo_4; if (!$url || str_contains($url, 'http')) { return $url; } return "https://oss.pocketuniversity.cn{$url}"; } public function getIsSuperVipAttribute() { return $this->supvip_endat > time(); } }