/** * 指定用户关注的人 * * @param integer $uid */ public function actionUidConcern($uid) { $login_uid = ZCommonSessionFun::get_user_id(); $this->layout = false; $uid = intval($uid); $this->view->title = User::getUidShowName($uid) . '关注的人'; $model = new UsersFriends(); $condition['uid'] = $uid; $data = $model->getList($condition, null, $this->pageSize); if (isset($_GET['ajax'])) { $status = 0; $html = ''; if (isset($_GET[$data['pagination']->pageParam]) && $data['pagination']->pageCount < $_GET[$data['pagination']->pageParam]) { $data['models'] = []; } $my_fans_uids = ZCommonFun::listData($data['models'], 'fuid', 'fuid'); $concer_data = []; if (count($my_fans_uids) > 0) { $my_fans_uids_str = implode(',', $my_fans_uids); $sql = <<<str select uf.uid uf_uid,uf.fuid fans /*我关注的人*/,( select count(id) from users_friends where uid=uf_uid and fuid={$login_uid} ) fans_is_concern_ta /*uf.uid关注了他 */ ,( select count(id) from users_friends where uid={$login_uid} and fuid=uf_uid )ta_is_concern_fans /* 他关注了uf.uid */ ,up.* from users_friends uf left join user_profile up on up.uid=uf.uid where uf.uid in({$my_fans_uids_str} ) group by uf.uid str; $query = new Query(); $concer_data = $query->createCommand()->setSql($sql)->queryAll(); } // ZCommonFun::print_r_debug($concer_data); // exit; // ZCommonFun::print_r_debug($data); foreach ($data['models'] as $key => $row) { $ta_url = Yii::$app->urlManager->createUrl(['my/personal-page', 'uid' => $row->fuid]); $ta_nickname = User::getDefaultTaNickname(); $ta_image = User::getDefaultHead_image(); $ta_intro = User::getDefaultTaIntro(); $concer_text = '关注'; $is_find = false; foreach ($concer_data as $key2 => $row2) { if ($row->fuid == $row2['uf_uid']) { !empty($row2['nickname']) ? $ta_nickname = $row2['nickname'] : null; !empty($row2['head_image']) ? $ta_image = $row2['head_image'] : null; !empty($row2['intro']) ? $ta_intro = $row2['intro'] : null; if ($row2['fans_is_concern_ta'] && $row2['ta_is_concern_fans']) { $url = ''; $concer_text = '相互关注'; } else { if ($row2['ta_is_concern_fans']) { $url = ''; $concer_text = '已关注'; } else { $url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $row->fuid]); } } $is_find = true; break; } } if (!$is_find) { $url = Yii::$app->urlManager->createUrl(['my/concern', 'fuid' => $row->fuid]); } $html .= <<<str <ul class="list" id="answer-view" style="margin:0;"> <li class="diy-item"><a \t\t\t\t\thref="{$ta_url}" \t\t\t\t\ttarget="_blank"> \t\t\t\t\t\t<figure class="cover"> \t\t\t\t\t\t\t<img src="{$ta_image}" \t\t\t\t\t\t\t\tclass="tuijian-img"> \t\t\t\t\t\t</figure> \t\t\t\t\t\t<div class="diy-meta"> \t\t\t\t<div class="title mui-ellipsis">{$ta_nickname}</div> \t\t\t\t<span class="iconfont icon-start-filled5"></span> \t\t\t\t<div class="desc mui-ellipsis">{$ta_intro}</div> \t\t\t</div> \t\t\t\t</a> \t<a url="{$url}" class="play concern" onclick="concern(this)" data-ui="danger small icon-right">{$concer_text}<i class="iconfont icon-right"></i> \t</a> \t\t\t\t </li> </ul> str; } echo $html; exit; } return $this->render('fans', ['uid' => $uid, 'ajax_url' => Yii::$app->urlManager->createUrl(['my/uid-concern', 'uid' => $uid, 'page' => '#page#', 'ajax' => '1'])]); }
/** * 分数型测试结果保存 * @param unknown $post * @param unknown $condition * @param unknown $id */ public function step4_2SaveResulteCondition2($post, $condition, $id) { $post_data = []; $url = $error = ''; if (isset($post['name'][0])) { foreach ($post['name'] as $key => $name) { $value = isset($post['value'][$key]) ? $post['value'][$key] : ''; $intro = isset($post['intro'][$key]) ? $post['intro'][$key] : ''; $min = isset($post['score-min'][$key]) ? $post['score-min'][$key] : 1; $max = isset($post['score-max'][$key]) ? $post['score-max'][$key] : 1; $temp = $min > $max ? $min : $max; if ($min > $max) { $temp = $min; $min = $max; $max = $temp; } if ($max > 0 && $min > 0 && !empty($value) && isset($name[0])) { $post_data[$key]['name'] = $value; $post_data[$key]['value'] = $value; $post_data[$key]['intro'] = $intro; $post_data[$key]['sr-id'] = isset($post['sr-id'][$key]) ? $post['sr-id'][$key] : null; $post_data[$key]['min'] = $min; $post_data[$key]['max'] = $max; } } // ZCommonFun::print_r_debug($post_data); // ZCommonFun::print_r_debug($post); // exit(); //有结果 if ($post_data) { //保存结果 $transaction = Yii::$app->db->beginTransaction(); //删除结果 $deleteSurveyResulte = new SurveyResulte(); $deleteAll = $deleteSurveyResulte->getAll($id); isset($deleteAll[0]) ? null : ($deleteAll = []); $sr_ids = ZCommonFun::listData($deleteAll, 'sr_id', 'sr_id'); $save = 0; try { foreach ($post_data as $key => $row) { if (isset($row['sr-id']) && $row['sr-id'] > 0) { $row_SurveyResulte = SurveyResulte::findOne($row['sr-id']); if ($row_SurveyResulte) { //结果存在,就不删除 unset($sr_ids[$row['sr-id']]); if ($row_SurveyResulte->s_id != $id) { continue; } $save++; } else { $row_SurveyResulte = new SurveyResulte(); } } else { $row_SurveyResulte = new SurveyResulte(); } $row_SurveyResulte->score_max = $row['max']; $row_SurveyResulte->score_min = $row['min']; $row_SurveyResulte->name = $row['name']; $row_SurveyResulte->value = $row['value']; $row_SurveyResulte->intro = $row['intro']; $row_SurveyResulte->value = $row['value']; $row_SurveyResulte->value = $row['value']; $row_SurveyResulte->uid = ZCommonSessionFun::get_user_id(); $row_SurveyResulte->s_id = $id; $row_SurveyResulte->save() ? $save++ : null; } if ($save > 0) { $condition = null; if (count($sr_ids) > 0) { $condition['sr_id'] = $sr_ids; $condition['s_id'] = $id; //删除所有结果 SurveyResulte::deleteAll($condition); } $transaction->commit(); $url = ['my']; } // ZCommonFun::print_r_debug($sr_ids); // ZCommonFun::print_r_debug($post_data); // exit; $url = ['my']; } catch (\Exception $e) { // ZCommonFun::print_r_debug($e); $transaction->rollBack(); } } } return $url; }