$this->getChatTimesTotal($wechatId), 'dayTimes' => $this->getChatTimesPerDay($wechatId), ]; } /** * 获取限制记录 * * @param string $wechatId * @return array */ protected function getRestrict(string $wechatId): array { return WechatRestrictsModel::alias('r') ->field( [ 'r.id', 'r.restrictTime date', 'r.level', 'r.reason' ] ) ->where('r.wechatId', $wechatId)->select() ->toArray(); } /** * 获取账号权重 * * @param string $wechatId * @return array */ protected function getAccountWeight(string $wechatId): array { // 微信账号加友权重评估 $assessment = $this->classTable->getInstance(WeightAssessment::class); $assessment->settingFactor($wechatId); return [ 'ageWeight' => $assessment->calculAgeWeight()->getResult(), // 账号年龄权重 'activityWeigth' => $assessment->calculActivityWeigth()->getResult(), // 计算活跃度权重 'restrictWeight' => $assessment->calculRestrictWeigth()->getResult(), // 计算限制影响权重 'realNameWeight' => $assessment->calculRealNameWeigth()->getResult(), // 计算实名认证权重 'scope' => $assessment->getWeightScope(), // 计算总分 ]; } /** * 计算今日新增好友数量 * * @param string $ownerWechatId * @return int */ protected function getTodayNewFriendCount(string $ownerWechatId): int { return WechatFriendShipModel::where(compact('ownerWechatId')) ->whereBetween('createTime', [ strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59')) ] ) ->count('*'); } /** * 获取账号加友统计数据. * * @param string $wechatId * @return array */ protected function getStatistics(string $wechatId): array { return [ 'todayAdded' => $this->getTodayNewFriendCount($wechatId), 'addLimit' => (new LimitAssessment()) ->maxLimit( $this->classTable->getInstance(WeightAssessment::class) ), ]; } /** * 获取微信号详情 * * @return \think\response\Json */ public function index() { try { $wechatId = $this->request->param('id/s'); return ResponseHelper::success( [ 'accountAge' => $this->getRegisterDate($wechatId), 'activityLevel' => $this->getActivityLevel($wechatId), 'accountWeight' => $this->getAccountWeight($wechatId), 'statistics' => $this->getStatistics($wechatId), 'restrictions' => $this->getRestrict($wechatId), ] ); } catch (\Exception $e) { return ResponseHelper::error($e->getMessage(), $e->getCode()); } } }