request->get('id', Yii::$app->params['mainUserId']); $deep = Yii::$app->request->get('deep', 2); $periodNum = Yii::$app->request->get('periodNum', null); if ($deep > 23) { return static::notice('Top 23 sub members of members can be viewed at most', 400);//最多查看会员的前23层子会员 } $allData = UserRelation::getChildrenWithDeepAndLayer($userId, $deep, 1, $periodNum); return static::notice(['allData' => $allData, 'periodNum' => $periodNum]); } /** * 主点位信息 * @return mixed * @throws \yii\base\Exception * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionMainUserInfo() { $userName = Yii::$app->request->get('userName', ''); $periodNum = Yii::$app->request->get('periodNum', null); $period = Period::instance(); $yearMonth = $period->getYearMonth($periodNum); if ($userName !== '') { //$oneUser = Info::getUserByUserNameFromUserInfoTable($userName); if (!$userId = Info::getUserIdByUserName($userName)) { return static::notice('会员不存在', 400); } } else { $userId = Yii::$app->params['mainUserId']; } $baseInfo = Info::baseInfo($userId, $periodNum); // print_r($baseInfo);exit; $decLevelConfig = Cache::getDecLevelConfig(); $empLevelConfig = Cache::getEmpLevelConfig(); $starLevelConfig = Cache::getStarCrownLevelConfig(); return static::notice([ [ 'TOP_RELATION_DEEP' => $baseInfo['RELATION_DEEP'], 'TOP_NETWORK_DEEP' => $baseInfo['NETWORK_DEEP'], 'USER_ID' => $userId, 'USER_NAME' => $baseInfo['USER_NAME'], 'REAL_NAME' => $baseInfo['REAL_NAME'], 'PERIOD_AT' => $baseInfo['PERIOD_AT'], 'DEC_LV_NAME' => $decLevelConfig[$baseInfo['DEC_LV']]['LEVEL_NAME'], 'EMP_LV_NAME' => isset($empLevelConfig[$baseInfo['EMP_LV']])?$empLevelConfig[$baseInfo['EMP_LV']]['LEVEL_NAME']:'', 'STAR_LV_NAME' => $starLevelConfig[$baseInfo['STAR_LV']]['LEVEL_NAME'], 'leaf' => false, 'icon' => 'el-icon-user-solid', 'children' => null, 'isExpanded' => false, 'displayNone' => 'display-none', 'className' => 'first-node', 'listPeriodNum' => $periodNum ], ]); } /** * 开拓网络列表 * @return mixed * @throws \yii\base\Exception * @throws \yii\web\HttpException */ public function actionRelationList() { $userName = Yii::$app->request->get('userName'); $deep = Yii::$app->request->get('deep', 2); $periodNum = Yii::$app->request->get('periodNum', null); if (!$userName) { $userId = Yii::$app->params['mainUserId']; } else { if (!$userId = Info::getUserIdByUserName($userName)) { return static::notice('Member does not exist', 400);//会员不存在 } } $listObj = new RelationList(); $data = $listObj->getList(['condition' => '', 'params' => [], 'others' => ['userId' => $userId, 'deep' => $deep, 'periodNum' => $periodNum]]); return static::notice($data); } /** * 开拓网络列表导出 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionRelationListExport() { $filter = $this->filterCondition([]); $userName = Yii::$app->request->get('userName'); $deep = Yii::$app->request->get('deep', 2); $periodNum = Yii::$app->request->get('periodNum', null); if (!$userName) { $userId = Yii::$app->params['mainUserId']; } else { if (!$userId = Info::getUserIdByUserName($userName)) { return static::notice('会员不存在', 400); } } $form = new AtlasExportForm(); $result = $form->run(array_merge($filter, ['others' => ['userId' => $userId, 'deep' => $deep, 'periodNum' => $periodNum]]), '开拓网络列表'); if (!$result) { return static::notice(Form::formatErrorsForApi($form->getErrors()), 400); } return static::notice('导出开始,请到文件管理-导出文件查看'); } /** * 安置网络图 * @return mixed * @throws \yii\web\HttpException */ public function actionNetwork() { $userId = Yii::$app->request->get('id', Yii::$app->params['mainUserId']); $periodNum = Yii::$app->request->get('periodNum', null); $deep = Yii::$app->request->get('deep', 2); if ($deep > 20) { return static::notice('View the top 20 sub members of the member at most', 400);//最多查看会员的前20层子会员 } $allData = UserNetwork::getChildrenWithDeepAndLayer($userId, $deep, 1, $periodNum); return static::notice(['allData' => $allData, 'periodNum' => $periodNum]); } /** * 安置网络列表 * @return mixed * @throws \yii\base\Exception * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionNetworkList() { $userName = Yii::$app->request->get('userName'); $deep = Yii::$app->request->get('deep', 2); $periodNum = Yii::$app->request->get('periodNum', null); if (!$userName) { $userId = Yii::$app->params['mainUserId']; } else { if (!$userId = Info::getUserIdByUserName($userName)) { return static::notice('Member does not exist', 400);//会员不存在 } } $listObj = new NetworkList(); $data = $listObj->getList(['condition' => '', 'params' => [], 'others' => ['userId' => $userId, 'deep' => $deep, 'periodNum' => $periodNum]]); return static::notice($data); } /** * 安置网络列表导出 * @return mixed * @throws \yii\db\Exception * @throws \yii\web\HttpException */ public function actionNetworkListExport() { $filter = $this->filterCondition([]); $userName = Yii::$app->request->get('userName'); $deep = Yii::$app->request->get('deep', 2); $periodNum = Yii::$app->request->get('periodNum', null); if (!$userName) { $userId = Yii::$app->params['mainUserId']; } else { if (!$userId = Info::getUserIdByUserName($userName)) { return static::notice('会员不存在', 400); } } $form = new AtlasExportForm(); $result = $form->run(array_merge($filter, ['others' => ['userId' => $userId, 'deep' => $deep, 'periodNum' => $periodNum]]), '安置网络列表'); if (!$result) { return static::notice(Form::formatErrorsForApi($form->getErrors()), 400); } return static::notice('导出开始,请到文件管理-导出文件查看'); } /** * 获取期数 * @return mixed * @throws \yii\web\HttpException */ public function getPeriod(){ $period = Period::instance(); $periodNum = $period->getNowPeriodNum(); return static::notice([ 'periodNum' => $periodNum, ]); } }