getUserInfo($this->userId); $adminInfo = $this->adminUserModel->getAdminInfoByBindUserId($this->userId); return [ 'id' => $this->userId, 'nickname' => $userInfo->nickname, 'avatar' => $this->getOssObjectById($userInfo->avatar_id) ?? '', 'mobile' => StringUtil::maskMiddleStrByNum($userInfo->mobile,4), 'point' => 0, 'coupon_num' => $this->getCouponNum(), 'invite_num' => 0, 'role_id' => (!empty($adminInfo) && $adminInfo->role_id > 0) ? $adminInfo->role_id : 0, ]; } /** * @return int */ private function getCouponNum(): int { return $this->userCouponModel ->where('user_id',$this->userId) ->where('status',CouponCode::COUPON_STATUS_UNUSED) ->where('validity_end_time','<',date('Y-m-d H:i:s')) ->count() ?? 0; } /** * @var UserCoupon */ #[Inject] private UserCoupon $userCouponModel; }