UserModel.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. namespace App\Models\User;
  3. use App\Events\UpdatedUserInfo;
  4. use App\Models\BlackListModel;
  5. use App\Models\NoticeModel;
  6. use App\Models\Model;
  7. use App\Models\PartnerModel;
  8. use App\Models\RiskListModel;
  9. use Exception;
  10. use Illuminate\Database\Eloquent\ModelNotFoundException;
  11. use Illuminate\Support\Facades\Storage;
  12. use Ixudra\Curl\Facades\Curl;
  13. /**
  14. * App\Models\User\UserModel
  15. *
  16. * @property int $uid 用户ID
  17. * @property int $sex 性别
  18. * @property int $sxo 性取向
  19. * @property int $feed_sex 首页性别
  20. * @property string|null $headimgurl 头像
  21. * @property string|null $nickname 用户昵称
  22. * @property float $gold_flower 金fa数量
  23. * @property float $red_flower 红fa数量
  24. * @property int $ck_count 抽卡次数
  25. * @property string|null $task 任务[表白|上传语音|上架自己|卖室友|设置个人信息]0:未完成;1完成
  26. * @property int $height 身高
  27. * @property string|null $age 年-月-日
  28. * @property string $home 故乡:省-市
  29. * @property string $address 长居城市
  30. * @property int $partner_id partner卡片id
  31. * @property string|null $expect 期望
  32. * @property string|null $introduce 自我描述
  33. * @property string|null $phone 手机号
  34. * @property string $school 学校
  35. * @property string $subject 专业
  36. * @property string $limit 限制失效时间-次数
  37. * @property int $last_sign 上次签到时间(客户端调用)
  38. * @property \Illuminate\Support\Carbon $updated_at 更新时间
  39. * @property \Illuminate\Support\Carbon $created_at 创建时间
  40. * @property int $sign_con 连续签到次数
  41. * @property int $hiding 屏蔽
  42. * @property string $star 星座
  43. * @property string $tag_1 标签一
  44. * @property string $tag_2 标签二
  45. * @property string $tag_3 标签三
  46. * @property string $tag_4 标签四
  47. * @property int $subscribe_at 关注获取fa
  48. * @property string $fpdx_like 个人偏好
  49. * @property string $kf_account 分配对象客服
  50. * @property int $rollback 后悔滑动的机会
  51. * @property string $qq QQ
  52. * @property string $weixin 微信
  53. * @property string $education 学历
  54. * @property int $login_at 登录时间(接口级)
  55. * @property string|null $voice 语音地址
  56. * @property int $pair_min_age 匹配比我小的年龄
  57. * @property int $pair_max_age 匹配比我大的年龄
  58. * @property int $pair_province 允许同省调剂
  59. * @property int $pair_all 允许全国调剂
  60. * @property string|null $photo_src 主页图片
  61. * @property string|null $photo_1 相册1
  62. * @property string|null $photo_2 相册2
  63. * @property string|null $photo_3 相册3
  64. * @property string|null $photo_4 相册4
  65. * @property string|null $last_life 最近生活状态
  66. * @property string|null $why 为什么参加活动
  67. * @property string|null $pair_voice 匹配语音
  68. * @property int $jigsaw_amount 拼图数量
  69. * @property string|null $wxkf 微信客服
  70. * @property string|null $sign 签名
  71. * @property int $is_auto_expand 是否自动扩大
  72. * @property int $only_last 是否只看活跃的
  73. * @property float $lng 经度
  74. * @property float $lat 纬度
  75. * @property string $location 地理位置
  76. * @property int $feed_dis 首页筛选距离
  77. * @property string|null $identity_auth 通过身份认证的照片
  78. * @property int $wx_auth 是否通过微信认证
  79. * @property string $work_state 工作状态
  80. * @property string|null $claim_tag 需求标签
  81. * @property int $last_likeme_lock_at 上次喜欢我的解锁时间
  82. * @property int $be_vip_at 成为vip的时间
  83. * @property int $supvip_endat 超级会员到期时间
  84. * @property int $task_photo 爆照任务[-1不设置为任务|0不设置为任务(默认)|设置为任务]
  85. * @property int $task_question 心动考验任务[-1不设置为任务|0不设置为任务(默认)|设置为任务]
  86. * @property int|null $task_sing 心动接唱任务[-1不设置为任务|0不设置为任务(默认)|设置为任务]
  87. * @property array|null $task_question_data 心动考验问题[{问题:{问题形式,问题},模版id}]
  88. * @property int $logoff_at 注销时间
  89. * @property int $app_like_unlock_count app心动解锁次数
  90. * @property string|null $login_app_platform app登录平台
  91. * @property int|null $feed_cnt 滑动总次数
  92. * @property int|null $feed_like 滑动点赞数
  93. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel newModelQuery()
  94. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel newQuery()
  95. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel query()
  96. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereAddress($value)
  97. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereAge($value)
  98. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereAppLikeUnlockCount($value)
  99. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereBeVipAt($value)
  100. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereCkCount($value)
  101. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereClaimTag($value)
  102. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereCreatedAt($value)
  103. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereEducation($value)
  104. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereExpect($value)
  105. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereFeedCnt($value)
  106. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereFeedDis($value)
  107. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereFeedLike($value)
  108. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereFeedSex($value)
  109. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereFpdxLike($value)
  110. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereGoldFlower($value)
  111. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereHeadimgurl($value)
  112. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereHeight($value)
  113. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereHiding($value)
  114. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereHome($value)
  115. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereIdentityAuth($value)
  116. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereIntroduce($value)
  117. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereIsAutoExpand($value)
  118. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereJigsawAmount($value)
  119. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereKfAccount($value)
  120. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLastLife($value)
  121. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLastLikemeLockAt($value)
  122. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLastSign($value)
  123. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLat($value)
  124. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLimit($value)
  125. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLng($value)
  126. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLocation($value)
  127. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLoginAppPlatform($value)
  128. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLoginAt($value)
  129. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereLogoffAt($value)
  130. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereNickname($value)
  131. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereOnlyLast($value)
  132. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePairAll($value)
  133. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePairMaxAge($value)
  134. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePairMinAge($value)
  135. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePairProvince($value)
  136. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePairVoice($value)
  137. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePartnerId($value)
  138. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhone($value)
  139. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhoto1($value)
  140. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhoto2($value)
  141. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhoto3($value)
  142. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhoto4($value)
  143. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel wherePhotoSrc($value)
  144. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereQq($value)
  145. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereRedFlower($value)
  146. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereRollback($value)
  147. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSchool($value)
  148. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSex($value)
  149. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSign($value)
  150. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSignCon($value)
  151. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereStar($value)
  152. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSubject($value)
  153. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSubscribeAt($value)
  154. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSupvipEndat($value)
  155. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereSxo($value)
  156. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTag1($value)
  157. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTag2($value)
  158. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTag3($value)
  159. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTag4($value)
  160. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTask($value)
  161. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTaskPhoto($value)
  162. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTaskQuestion($value)
  163. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTaskQuestionData($value)
  164. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereTaskSing($value)
  165. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereUid($value)
  166. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereUpdatedAt($value)
  167. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereVoice($value)
  168. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereWeixin($value)
  169. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereWhy($value)
  170. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereWorkState($value)
  171. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereWxAuth($value)
  172. * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\User\UserModel whereWxkf($value)
  173. */
  174. class UserModel extends Model
  175. {
  176. protected $table = 'kdgx_partner_charge_user';
  177. protected $dateFormat = 'U';
  178. protected $primaryKey = 'uid';
  179. protected $fillable = [
  180. 'uid',
  181. 'gold_flower',
  182. 'red_flower',
  183. 'headimgurl',
  184. 'nickname',
  185. 'sex',
  186. 'sxo',
  187. 'height',
  188. 'age',
  189. 'star',
  190. 'home',
  191. 'education',
  192. 'address',
  193. 'qq',
  194. 'weixin',
  195. 'partner_id',
  196. 'task_photo',
  197. 'task_question',
  198. 'task_sing',
  199. 'expect',
  200. 'introduce',
  201. 'phone',
  202. 'school',
  203. 'subject',
  204. 'created_at',
  205. 'login_at',
  206. 'supvip_endat',
  207. 'sign_con',
  208. 'tag_1',
  209. 'tag_2',
  210. 'tag_3',
  211. 'tag_4',
  212. 'fpdx_like',
  213. 'last_life',
  214. 'why',
  215. 'kf_account',
  216. 'voice',
  217. 'pair_min_age',
  218. 'pair_max_age',
  219. 'pair_province',
  220. 'pair_all',
  221. 'pair_voice',
  222. 'photo_src',
  223. 'photo_1',
  224. 'photo_2',
  225. 'photo_3',
  226. 'photo_4',
  227. 'jigsaw_amount',
  228. 'wxkf',
  229. 'sign',
  230. 'feed_sex',
  231. 'is_auto_expand',
  232. 'feed_dis',
  233. 'only_last',
  234. 'lat',
  235. 'lng',
  236. 'location',
  237. 'identity_auth',
  238. 'wx_auth',
  239. 'work_state',
  240. 'claim_tag',
  241. 'last_likeme_lock_at',
  242. 'be_vip_at',
  243. 'login_app_platform',
  244. 'feed_cnt',
  245. 'feed_like',
  246. 'bgcolor',
  247. 'im_account',
  248. 'im_sig',
  249. 'pair_energy',
  250. ];
  251. protected $appends = [
  252. 'full_url_photo_src',
  253. 'full_url_photo',
  254. 'full_url_photo1',
  255. 'full_url_photo2',
  256. 'full_url_photo3',
  257. 'full_url_photo4',
  258. 'avatar',
  259. 'birthday',
  260. 'is_super_vip',
  261. ];
  262. protected $casts = [
  263. 'task_question_data' => 'array',
  264. 'task_sing_data' => 'array',
  265. 'updated_at' => 'int',
  266. 'be_vip_at' => 'int',
  267. 'supvip_endat' => 'int'
  268. ];
  269. public static function boot()
  270. {
  271. parent::boot();
  272. self::saving(function (/** @var UserModel $model */ $model) {
  273. // 头像上传oss
  274. if (
  275. 'local' != config('app.env') && !empty($model->headimgurl) && 0 == substr_count(
  276. $model->headimgurl,
  277. "oss.pocketuniversity.cn"
  278. )
  279. ) {
  280. $response = Curl::to($model->headimgurl)->withResponseHeaders()->returnResponseObject()->get();
  281. $new_avatar = sprintf("avatar/%s/%s.png", date('Y-m-d'), \Ramsey\Uuid\Uuid::uuid4()->toString());
  282. Storage::disk('oss')->put($new_avatar, $response->content);
  283. $avatar = Storage::disk('oss')->url($new_avatar);
  284. $model->headimgurl = $avatar;
  285. }
  286. // 黑名单处理
  287. if (
  288. (
  289. $model->isDirty('weixin') &&
  290. BlackListModel::where('account_type', 'weixin')
  291. ->where('account', $model->weixin)
  292. ->first()
  293. ) ||
  294. (
  295. $model->isDirty('qq') &&
  296. BlackListModel::where('account_type', 'qq')
  297. ->where('account', $model->qq)
  298. ->first()
  299. )
  300. ) {
  301. RiskListModel::create([
  302. 'uid' => $model->uid,
  303. 'phone' => $model->phone,
  304. 'weixin' => $model->weixin,
  305. 'qq' => $model->qq,
  306. ]);
  307. BlackListModel::updateOrcreate(
  308. ['account_type' => 'uid', 'account' => $model->uid],
  309. ['type' => 'all', 'end_at' => 1893427200, 'state' => 3]
  310. );
  311. BlackListModel::updateOrcreate(
  312. ['account_type' => 'phone', 'account' => $model->phone],
  313. ['type' => 'all', 'end_at' => 1893427200, 'state' => 3]
  314. );
  315. }
  316. // 更新登录时间
  317. if ($model->isDirty('login_at') && $model->partner_id > 0) {
  318. try {
  319. PartnerModel::findOrFail($model->partner_id)->update(['login_at' => $model->login_at]);
  320. } catch (ModelNotFoundException $exception) {
  321. }
  322. }
  323. });
  324. self::updated(function (/** @var UserModel $model */ $model) {
  325. event(new UpdatedUserInfo($model));
  326. });
  327. }
  328. /**
  329. * 初始化fpdx用户
  330. * @param int $uid
  331. * @return UserModel|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
  332. */
  333. public function initUser(int $uid)
  334. {
  335. $isnew = false;
  336. try {
  337. $user = $this->findOrFail($uid);
  338. if (0 == $user->login_at) {
  339. $isnew = true;
  340. }
  341. } catch (Exception $e) {
  342. $user = $this->fill(['uid' => $uid, 'phone' => null]);
  343. $user->save();
  344. $isnew = true;
  345. }
  346. if ($isnew) {
  347. NoticeModel::create([
  348. 'uid' => $uid,
  349. 'title' => '欢迎来到分配对象',
  350. 'content' => "hi,你好呀,终于等到你了~今后就让小象带你认识有趣的人,遇见属于你的心动!快先来完善你的交友信息吧,小象等不及要给你“分配对象”啦~",
  351. 'type' => 5,
  352. 'type_id' => 0,
  353. 'tab_content' => '编辑个人资料',
  354. 'tab_url' => '/pages/my-friend-card-editor/my-friend-card-editor',
  355. ]);
  356. }
  357. return $user;
  358. }
  359. public function getAuth()
  360. {
  361. $apps = [
  362. '1109365561' => '1109365561', //分配对象QQ小程序
  363. '1109284509' => '1109284509', //时遇记QQ小程序
  364. 'gh_b598cb7474d8' => 'wx7955aab955345d39',//分配对象公众号
  365. 'gh_c94c95866ca5' => 'wxa80cac3f6c2de130',//时遇记公众号
  366. 'gh_01c089b58dda' => 'wx4c1722a4055bd229',//分配对象小程序,
  367. 'qq_unionid' => 'qq_unionid',
  368. 'kdgx_unionid' => 'unionid',
  369. 'phone' => 'phone',
  370. ];
  371. $unionid = AuthKey::where('uid', $this->uid)->where('auth_type', 'kdgx_unionid')->value('auth_key');
  372. $qq_unionid = AuthKey::where('uid', $this->uid)->where('auth_type', 'qq_unionid')->value('auth_key');
  373. $data = [
  374. 'uid' => $this->uid,
  375. 'sex' => $this->sex,
  376. 'device' => $this->login_app_platform,
  377. 'phone' => AuthKey::where('uid', $this->uid)
  378. ->where('auth_type', 'phone')
  379. ->value('auth_key'),
  380. 'unionid' => $unionid,
  381. 'qq_unionid' => $qq_unionid,
  382. 'wxa80cac3f6c2de130' => $unionid ? Openid::where('unionid', $unionid)
  383. ->where('public_id', 'gh_c94c95866ca5')
  384. ->value('openid') : '',
  385. 'wx7955aab955345d39' => $unionid ? Openid::where('unionid', $unionid)
  386. ->where('public_id', 'gh_b598cb7474d8')
  387. ->value('openid') : '',
  388. 'wx4c1722a4055bd229' => AuthKey::where('uid', $this->uid)
  389. ->where('auth_type', 'gh_01c089b58dda')
  390. ->value('auth_key') ?: '',
  391. '1109365561' => AuthKey::where('uid', $this->uid)
  392. ->where('auth_type', '1109365561')
  393. ->value('auth_key') ?: '',
  394. '1109284509' => AuthKey::where('uid', $this->uid)
  395. ->where('auth_type', '1109284509')
  396. ->value('auth_key') ?: '',
  397. ];
  398. return $data;
  399. }
  400. public function black()
  401. {
  402. $black = [
  403. 'msy' => BlackListModel::select(['created_at', 'end_at', 'state'])
  404. ->where('account_type', 'uid')
  405. ->where('account', $this->uid)
  406. ->where('end_at', '>', time())
  407. ->whereIn('type', ['all', 'msy'])
  408. ->orderBy('end_at', 'desc')
  409. ->first(),
  410. 'fpdx' => BlackListModel::select(['created_at', 'end_at', 'state'])
  411. ->where('account_type', 'uid')
  412. ->where('account', $this->uid)
  413. ->where('end_at', '>', time())
  414. ->whereIn('type', ['all', 'fpdx'])
  415. ->orderBy('end_at', 'desc')
  416. ->first(),
  417. 'black' => BlackListModel::select(['created_at', 'end_at', 'state'])
  418. ->where('account_type', 'uid')
  419. ->where('account', $this->uid)
  420. ->where('end_at', '>', time())
  421. ->whereIn('type', ['all', 'black'])
  422. ->orderBy('end_at', 'desc')
  423. ->first(),
  424. 'chat' => BlackListModel::select(['created_at', 'end_at', 'state'])
  425. ->where('account_type', 'uid')
  426. ->where('account', $this->uid)
  427. ->where('end_at', '>', time())
  428. ->whereIn('type', ['all', 'chat'])
  429. ->orderBy('end_at', 'desc')
  430. ->first(),
  431. 'night' => BlackListModel::select(['created_at', 'end_at', 'state'])
  432. ->where('account_type', 'uid')
  433. ->where('account', $this->uid)
  434. ->where('end_at', '>', time())
  435. ->whereIn('type', ['all', 'night'])
  436. ->orderBy('end_at', 'desc')
  437. ->first(),
  438. 'home' => BlackListModel::select(['created_at', 'end_at', 'state'])
  439. ->where('account_type', 'uid')
  440. ->where('account', $this->uid)
  441. ->where('end_at', '>', time())
  442. ->whereIn('type', ['all', 'home'])
  443. ->orderBy('end_at', 'desc')
  444. ->first(),
  445. 'account' => BlackListModel::select(['created_at', 'end_at', 'state'])
  446. ->where('account_type', 'uid')
  447. ->where('account', $this->uid)
  448. ->where('end_at', '>', time())
  449. ->whereIn('type', ['all', 'account'])
  450. ->orderBy('end_at', 'desc')
  451. ->first(),
  452. ];
  453. return $black;
  454. }
  455. public function getNicknameAttribute($value)
  456. {
  457. return $value
  458. ? mb_substr($value, 0, 10)
  459. : '';
  460. }
  461. public function getHeadimgurlAttribute($value)
  462. {
  463. return $value ?: '';
  464. }
  465. public function getAvatarAttribute()
  466. {
  467. return $this->headimgurl ?: '';
  468. }
  469. public function getBirthdayAttribute()
  470. {
  471. return $this->age ?: null;
  472. }
  473. public function getFullUrlPhotoAttribute()
  474. {
  475. $url = $this->photo_src;
  476. if (!$url || str_contains($url, 'http')) {
  477. return $url;
  478. }
  479. return "https://oss.pocketuniversity.cn{$url}";
  480. }
  481. public function getFullUrlPhotoSrcAttribute()
  482. {
  483. $url = $this->photo_src;
  484. if (!$url || str_contains($url, 'http')) {
  485. return $url;
  486. }
  487. return "https://oss.pocketuniversity.cn{$url}";
  488. }
  489. public function getFullUrlPhoto1Attribute()
  490. {
  491. $url = $this->photo_1;
  492. if (!$url || str_contains($url, 'http')) {
  493. return $url;
  494. }
  495. return "https://oss.pocketuniversity.cn{$url}";
  496. }
  497. public function getFullUrlPhoto2Attribute()
  498. {
  499. $url = $this->photo_2;
  500. if (!$url || str_contains($url, 'http')) {
  501. return $url;
  502. }
  503. return "https://oss.pocketuniversity.cn{$url}";
  504. }
  505. public function getFullUrlPhoto3Attribute()
  506. {
  507. $url = $this->photo_3;
  508. if (!$url || str_contains($url, 'http')) {
  509. return $url;
  510. }
  511. return "https://oss.pocketuniversity.cn{$url}";
  512. }
  513. public function getFullUrlPhoto4Attribute()
  514. {
  515. $url = $this->photo_4;
  516. if (!$url || str_contains($url, 'http')) {
  517. return $url;
  518. }
  519. return "https://oss.pocketuniversity.cn{$url}";
  520. }
  521. public function getIsSuperVipAttribute()
  522. {
  523. return $this->supvip_endat > time();
  524. }
  525. }