funddao = new FundDao (); $this->messagedao = new MessageDao (); $this->categorydao = new CategoryDao (); $this->questiondao = new QuestionDao (); $this->creditdao = new CreditDao (); $this->answerdao = new AnswerDao (); $this->authissuedao = new AuthissueDao (); $this->vipquestiondao = new VipquestionDao (); $this->vipanswerdao = new VipanswerDao (); $this->userdao = new UserDao (); $this->credit3logdao = new Credit3logDao (); } /** * 获取今日发布数 */ function get_today_question($condition = "") { $result = $this->questiondao->get_today_question ( $condition ); if ($result ['times'] > 20) $result ['times'] = 20; return $result ['times']; } /** * 获取基金金额数 */ function get_fund() { $result = $this->funddao->get_fund (); if (empty ( $result ['allmoney'] )) $result ['allmoney'] = 0; return $result; } /** * 获取已付款,为填写 * @param unknown_type $uid */ function get_vip_question_by_paid($uid = 0) { $rs = $this->vipquestiondao->get_vip_question_by_paid ( $uid ); return $rs; } /** * * 认证问题发布 * @param unknown_type $uid * @return int 1:可以发布 ; 2:今天发布数**条已用完 ; 3:在*小时内只可以发布*条 */ function auth_question_issue($uid = 0, $groupid = 7, $auth = array()) { $rs = $this->authissuedao->get_auth_issue ( $uid ); //获取今天结束时间 $day = get_today (); //获取几个小时后的时间 $time = get_seconds ( $auth ['TIME_INTERVAL'] ); $nowtime = time (); $opt ['where'] = " uid=" . $uid . " "; //当天未记录 if (empty ( $rs )) { $this->authissuedao->uid = $uid; $this->authissuedao->day_time = $day ['end']; $this->authissuedao->time_interval = $time; $this->db ()->insert ( $this->authissuedao ); return 1; } else { //判断今天发布总数 if ($rs ['day_time'] > $nowtime) { //今天发布总算在容许范围内 if ($rs ['day_totals'] < $auth ['DAY_TOTALS']) { //*小时后时间大于现在时间 if ($rs ['time_interval'] > $nowtime) { //发布数量小于限制数 if ($rs ['time_totals'] < $auth ['TIME_TOTALS']) return 1; else return 3; } else { //设置数量为0,时间设置为新当前结束时间 $this->authissuedao->uid = $uid; $this->authissuedao->time_totals = 0; $this->authissuedao->time_interval = $time; $this->db ()->update ( $this->authissuedao, $opt ); return 1; } } else //今天发布总算超过限制 return 2; } else { //不是当天时间更新,总算清0 $this->authissuedao->uid = $uid; $this->authissuedao->day_totals = 0; $this->authissuedao->time_totals = 0; $this->authissuedao->day_time = $day ['end']; $this->authissuedao->time_interval = $time; $this->db ()->update ( $this->authissuedao, $opt ); return 1; } } } /** * 根据问题ID,用户ID获取回答 * @param unknown_type $qid * @param unknown_type $uid */ function get_answer_by_quid($qid = 0, $uid = 0) { $result = $this->answerdao->get_answer_by_quid ( $qid, $uid ); return $result; } /** * 搜索问答 * @param unknown_type $keywork * @param unknown_type $on_page * @param unknown_type $page_size */ function search($keywork = "", $status = 0, $on_page = 1, $page_size = 20) { $result = array (); $ask_info = array (); $result ['on_page'] = $on_page; $result ['status'] = $status; $result ['search_info'] = array (); $page = ""; $status1 = null; $status2 = null; try { $result ['previous'] = $on_page != 0 ? $on_page - 1 : $on_page; $pa = $on_page; $limit_lower = (-- $pa) * $page_size; $D=""; if ($status == 1) { $D=" and status =1"; $status1 = 1; } elseif ($status == 2) { $D=" and status =2"; $status2 = 2; } $docs=$this->questiondao->find(array('where' => "title like '%".$keywork."%' ".$D,'limit'=>$limit_lower.','.$page_size)); $counts=$this->questiondao->count(array('where' => "title like '%".$keywork."%' ".$D ,'asArray' => TRUE)); //$docs =$xs->search->setQuery('12')->setLimit($page_size, $limit_lower)->search(); //$docs = $xs->search->addDb ( SEARCH_WD_DB )->setQuery ( $keywork )->addRange ( 'status', $status2, $status1 )->setLimit ( $page_size, $limit_lower )->setSort ( 'time' )->search (); //$docs = $xs->search->setQuery ( $keywork )->search (); //总记录数 $result ['total_data'] = $counts; $total = intval ( $result ['total_data'] / $page_size ); //总页数 $result ['total_page'] = ($result ['total_data'] % $page_size) == 0 ? $total : $total + 1; $result ['next'] = $on_page == $result ['total_page'] ? $result ['total_page'] : $on_page + 1; $i = 0; $page_max = 1; if ($on_page > 10) { $page_max = intval ( $on_page / 10 ) + 1; $i = intval ( $on_page / 10 ) * 10; } foreach ( $docs as $doc ) { //结果集 $ask_info ['qid'] = $doc->id; $ask_info ['cid'] = $doc->cid; $ask_info ['cid1'] = $doc->cid1; $ask_info ['cid2'] = $doc->cid2; $ask_info ['price'] = $doc->price; $ask_info ['author'] = $doc->author; $ask_info ['authorid'] = $doc->authorid; $ask_info ['title'] = $doc->title ; $ask_info ['description'] = cutstr(strip_tags( $doc->description ),300,"..."); $ask_info ['time'] = my_date_format2 ( $doc->time, "Y-m-d" ); $ask_info ['status'] = format_question_status ( $doc->status, 'other' ); $ask_info ['answers'] = $doc->answers; //$ask_info ['answer'] = $doc->answer; $result ['search_info'] [$i] = $ask_info; $i ++; } $action = '/question/search/?keywork=' . $keywork . '&status=' . $status . '&on_page='; $i = 1; for(; $i <= $result ['total_page']; $i ++) { if ($i == $on_page) $page .= '' . $i . ''; else $page .= '' . $i . ''; if ($i == (10 * $page_max)) break; } $result ['page'] = $page; return $result; } catch ( XSException $e ) { //print $e->getMessage(); die; return array (); } } /** * 搜索名师答疑问答 * @param unknown_type $keywork * @param unknown_type $on_page * @param unknown_type $page_size */ function search_advisory($keywork = "", $type = "new", $on_page = 1, $page_size = 10) { $result = array (); $vip_questions = array (); $result ['vip_questions'] = array (); try { $xs = new XS ( SEARCH_VIP_INI ); $limit_lower = ($on_page - 1) * $page_size; $search = " NOT status:1 "; if ($type == "answer") $search .= " NOT answers:0 "; if ($type == "hot") $search .= " NOT hot:0 "; $docs = $xs->search->addDb ( SEARCH_WD_DB )->setLimit ( $page_size, $limit_lower )->setSort ( 'time' )->search ( $keywork . $search ); $action = '/search_advisory?type=' . $type . '&keywork_advisory=' . $keywork . '&on_page='; $page = $this->_get_page_search ( $on_page, $page_size, $xs->search->lastCount, $action ); $i = 0; foreach ( $docs as $doc ) { //结果集 $vip_questions ['id'] = $doc->id; $vip_questions ['price'] = $doc->price; $vip_questions ['author'] = $doc->author; $vip_questions ['authorid'] = $doc->authorid; $vip_questions ['title'] = $xs->search->highlight ( $doc->title ); $vip_questions ['description'] = $xs->search->highlight ( $doc->description ); $vip_questions ['time'] = my_date_format2 ( $doc->time, "Y-m-d H:i:s" ); $vip_questions ['status'] = format_question_status ( $doc->status, 'other' ); $vip_questions ['answers'] = $doc->answers; $vip_questions ['hot'] = $doc->hot; $vip_questions ['answer'] = $xs->search->highlight ( $doc->answer ); //获取用户信息 $rs = $this->userdao->get_userinfo_by_uid ( $doc->authorid ); // if (empty ( $rs ['avatar'] )) // $rs ['avatar'] = DEF_AVATAR; $rs ['avatar'] = $this->get_user_avatar_by_username ( $doc->author ); $vip_questions ['user'] = $rs; $result ['vip_questions'] [$i] = $vip_questions; $i ++; } $result ['page'] = $page; return $result; } catch ( XSException $e ) { return array (); } } function _get_page_search($on_page = 1, $page_size = 20, $total_count = 0, $action = "", $get = "", $other = "page") { $page_c = ""; $page ['previous'] = get_previous ( $on_page ); $page ['on_page'] = $on_page; $total = intval ( $total_count / $page_size ); $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1; $page ['total_data'] = $total_count; $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1; $i = 1; $page_max = 1; if ($on_page > 10) { $page_max = intval ( $on_page / 10 ) + 1; $i = intval ( $on_page / 10 ) * 10 - 1; } for(; $i <= $page ['total_page']; $i ++) { if ($i == $on_page) { if ($other == "page") $page_c .= '' . $i . ''; else $page_c .= ' ' . $i . ' '; } else if ($other == "page") $page_c .= '' . $i . ''; else $page_c .= ' ' . $i . ' '; if ($i == (10 * $page_max)) break; } $page ['page'] = $page_c; $page ['lower'] = (-- $on_page) * $page_size; return $page; } /** * 获取相关问答动态 * @param unknown_type $uid */ function get_related_que_ans($uid = 0) { if ($uid == 0) return array (); $param ['authorid'] = $uid; $limit ['lower'] = 0; $limit ['size'] = 3; $result ['question'] = $this->questiondao->get_questions_list ( $param, $limit ); $result ['answer'] = $this->answerdao->get_answer_list ( $uid, $limit ); $data = $this->_format_related_data ( $result ['question'], $result ['answer'] ); return $data; } /** * 格式化相关问答动态 * @param unknown_type $question * @param unknown_type $answer */ function _format_related_data($question, $answer) { $data = array (); foreach ( $question as $key => $value ) { $value ['description'] = strip_tags ( $value ['description'] ); $data [$value ['time']] = $value; $data [$value ['time']] ['adopttime'] = 0; $data [$value ['time']] ['type'] = "问题"; } foreach ( $answer as $key => $value ) { $value ['title'] = strip_tags ( $value ['title'] ); $data [$value ['time']] = $value; $data [$value ['time']] ['title'] = $value ['title']; $data [$value ['time']] ['type'] = "回答"; } krsort ( $data ); foreach ( $data as $key => $value ) { $data [$key] ['time'] = my_date_format2 ( $value ['time'] ); } return $data; } /** * 获取擅长分析信息 * @param unknown_type $cids */ function get_expert_category_list($cids = "") { if (empty ( $cids )) return array (); $result = $this->categorydao->get_expert_category_list ( $cids ); return $result; } /** * 获取相关问题--看具体需求 * @param unknown_type $id */ function get_like_questions_list($id = 0, $cid = 0, $status = "") { $result = $this->questiondao->get_like_questions_list ( $id, $cid, $status ); return $result; } /** * 获取问题分类内容 * @return $result array; */ function get_category_list() { $result = $this->db ()->find ( $this->categorydao ); $data ['top'] = array (); $data ['second'] = array (); foreach ( $result as $key => $value ) { if ($value->grade == 1) array_push ( $data ['top'], $value ); if ($value->grade == 2) array_push ( $data ['second'], $value ); } return $data; } /** * 获取分类 根据ID * @param unknown_type $id */ function get_category_by_id($id = 0) { $result = $this->categorydao->get_category_by_id ( $id ); return $result; } /** * 获取采纳率(效率问题--可以优化地方) */ function get_adopt_percentage($uid = 0) { if ($uid != 0) $param ['authorid'] = $uid; $total = $this->questiondao->get_questions_count ( array () ); $param ['auto'] = " and status in (1) and hidden =0 "; $w = $this->questiondao->get_questions_count ( $param ); $param ['auto'] = " and status in (2) "; $y = $this->questiondao->get_questions_count ( $param ); $data ['adopt'] = 0; if ($total ['count'] != 0) $data ['adopt'] = round ( ($y ['count'] / $total ['count'] * 100), 2 ); $data ['unresolved'] = $w ['count']; $data ['resolved'] = $y ['count']; return $data; } /** * 获取问题列表 * @param unknown_type $data * @param unknown_type $condition * @param unknown_type $limit */ function get_questions_list_tem($data = array(), $condition = "", $limit = "", $type = "index", $time_type = "Y-m-d H:i:s") { $result = $this->get_list ( $data, $condition, $limit, t_question ); //加入15天自动关闭问题--发送系统信息 foreach ( $result as $key => $value ) { $this->auto_set_status_question ( $value ); } $result = $this->_format_question_data ( $result, $type, $time_type ); return $result; } function get_QA(){ $field=" a.id,a.title,b.content "; $condition=" a.status =2 limit 5"; $rs=$this->questiondao->get_QA($field,$condition); return $rs; } /** * 获取文章列表 * @param unknown_type $data * @param unknown_type $condition * @param unknown_type $limit * @param unknown_type $type */ function get_article_list($data = array(), $condition = "", $limit = "", $format = "Y-m-d H:i:s", $type = "index") { $result = $this->get_list ( $data, $condition, $limit, t_article ); foreach ( $result as $key => $value ) { $result [$key] ['time'] = format_date ( $value ['time'], $format ); } return $result; } /** * 格式化问题数据 * @param unknown_type $data */ function _format_question_data($data = array(), $type = "index", $time_type = "Y-m-d H:i:s") { foreach ( $data as $key => $value ) { $data [$key] ['time'] = my_date_format2 ( $value ['time'], $time_type ); $data [$key] ['status'] = format_question_status ( $value ['status'], $type ); } return $data; } /** * 格式化名师答疑问题数据 * @param unknown_type $data */ function _format_vip_question_data($data = array()) { foreach ( $data as $key => $value ) { $data [$key] ['time'] = my_date_format2 ( $value ['time'], "Y-m-d H:i:s" ); $data [$key] ['status_num'] = $data [$key] ['status']; $data [$key] ['status'] = format_question_status ( $value ['status'], "vip" ); } return $data; } /** * 获取积分详细 */ function get_credit_details($uid){ $result = $this->creditdao->get_credit_info_by_uid ( $uid ); foreach ($result as $key=>$value){ $result[$key]['time']=format_date($value['time']); } return $result; } /** * 获取积分,财富日常操作信息 * @param unknown_type $uid */ function get_credit_info($uid) { $result = $this->creditdao->get_credit_info_by_uid ( $uid ); $data ['usually_point'] = 0; $data ['add_point'] = 0; $data ['reply_point'] = 0; $data ['punish_point'] = 0; $data ['rich_adopt'] = 0; $data ['rich_refunds'] = 0; //财富 $data ['rich_offer'] = 0; foreach ( $result as $key => $value ) { if ($value ['operation'] == CREDIT_ACTION_LOGIN || $value ['operation'] == ACTION_REGISTER) //日常操作积分 $data ['usually_point'] += $value ['credit1']; elseif ($value ['operation'] == CREDIT_ACTION_ADD) //添加问题积分 $data ['add_point'] += $value ['credit1']; //回答获得 elseif ($value ['operation'] == CREDIT_ACTION_ANSWER || $value ['operation'] == ACTION_ADOPT || $value ['operation'] == ACTION_SUPPORT) $data ['reply_point'] += $value ['credit1']; //处罚积分 elseif ($value ['operation'] == ACTION_DELETE_QUESTION || $value ['operation'] == ACTION_DELETE_ANSWER) $data ['punish_point'] += $value ['credit1']; //财富付出 if ($value ['operation'] == RICH_ACTION_OFFER) $data ['rich_offer'] += $value ['credit3']; //财富获得 if ($value ['operation'] == RICH_ACTION_ADOPT || $value ['operation'] == RICH_ACTION_REFUNDS) $data ['rich_adopt'] += $value ['credit3']; //财富退款 if ($value ['operation'] == RICH_ACTION_REFUNDS) $data ['rich_refunds'] += $value ['credit3']; } return $data; } /** * 问题和用户信息 * @param unknown_type $id */ function get_question_user_info($id = 0) { $result = $this->questiondao->get_question_user_info_by_id ( $id ); if (empty ( $result )) return false; $lv = get_lv ( $result ['credit1'] ); $result ['lv'] = $lv [0]; $result ['status_num'] = $result ['status']; $result ['last_close_day'] = get_last_close_day ( $result ['time'] ); $su = unserialize ( $result ['supply'] ); $result ['supply'] = $su [0] ['content']; //获取头像 $result ['avatar'] = json_decode($result ['avatar'],true);//$this->get_user_avatar_by_username ( $result ['author'] ); $result ['supply_time'] = my_date_format2 ( $su [0] ['time'] ); //条件满足-关闭问题 $this->auto_set_status_question ( $result ); $result ['status'] = format_question_status ( $result ['status'], 'page' ); if (defined ( "CREDIT3" )) $result ['credit3'] = CREDIT3; else $result ['credit3'] = 0; return $result; } /** * 关闭问题 * @param unknown_type $id */ function close_question($id) { $this->questiondao->close_question_by_id ( $id ); } /** * 获取回答列表 * @param unknown_type $data * @param unknown_type $condition * @param unknown_type $limit */ function get_answers_list_tem($data = array(), $condition = "", $limit = "") { $result = $this->get_list ( $data, $condition, $limit, t_answer ); $result = $this->_format_answer_data ( $result ); return $result; } /** * 格式化回答 // '#(.+?)#' * @param unknown_type $data */ function _format_message_data($data = array()) { foreach ( $data as $key => $value ) { preg_match ( '#(.+?)#', $value ['content'], $match ); $msg = cutstr ( $match [0], 90, '...' ); $data [$key] ['content'] = str_replace ( $match [1], $msg, $value ['content'] ); $data [$key] ['time'] = my_date_format2 ( $value ['time'], "Y-m-d" ); } return $data; } /** * 格式化回答 * @param unknown_type $data */ function _format_answer_data($data = array()) { foreach ( $data as $key => $value ) { $data [$key] ['time'] = my_date_format2 ( $value ['time'], "Y-m-d" ); } return $data; } /** * 回答和用户信息 * @param unknown_type $id 问题id */ function get_answer_user_info($id = 0) { $result = $this->answerdao->get_answer_user_info_by_id ( $id ); foreach ( $result as $key => $value ) { $lv = get_lv ( $value ['credit1'] ); $result [$key] ['lv'] = $lv [0]; $result [$key] ['time'] = format_date ( intval ( $value ['time'] ) ); if (defined ( "CREDIT3" )) $result [$key] ['credit3'] = CREDIT3; else $result [$key] ['credit3'] = 0; //追问和回答 $tag_array = unserialize ( $value ['tag'] ); // if (empty ( $value ['avatar'] )) // $result [$key] ['avatar'] = "/global/img/avatarNormal.png"; //获取头像 $result [$key] ['avatar'] = json_decode($value ['avatar'],true);//$this->get_user_avatar_by_username ( $value ['author'] ); $result [$key] ['to_ask'] = $tag_array [0]; if (isset ( $tag_array [1] )) $result [$key] ['answer_again'] = $tag_array [1]; $result [$key] ['to_ask_time'] = my_date_format2 ( $value ['tagtime'] ); $result [$key] ['answer_again_time'] = 0; if (isset ( $tag_array [2] )) $result [$key] ['answer_again_time'] = my_date_format2 ( $tag_array [2] ); } return $result; } /** * 获取系统信息 * @param unknown_type $uid * @param unknown_type $fromuid * @param unknown_type $time * @param unknown_type $on_page * @param unknown_type $page_size */ function get_messages_list($uid = 0, $fromuid = 1, $time = 7, $on_page = 1, $page_size = 10) { $page = ""; $muid = $fromuid; $fromuid = " type=" . $fromuid . " and "; $total_count = $this->messagedao->get_message_count ( $uid, $fromuid, $time ); //可否抽象出分页类 $data ['total_page'] = intval ( $total_count ['count'] / $page_size ) + 1; $data ['total_data'] = $total_count ['count']; $data ['on_page'] = $on_page; $data ['previous'] = $on_page != 0 ? $on_page - 1 : $on_page; $data ['next'] = $on_page == $data ['total_page'] ? $data ['total_page'] : $on_page + 1; $i = 1; $page_max = 1; if ($on_page > 10) { $page_max = intval ( $on_page / 10 ) + 1; $i = intval ( $on_page / 10 ) * 10 - 1; } for(; $i <= $data ['total_page']; $i ++) { if ($i == $on_page) $page .= '' . $i . ''; else $page .= '' . $i . ''; if ($i == (10 * $page_max)) break; } $data ['page'] = $page; $limit ['lower'] = (-- $on_page) * $page_size; $limit ['size'] = $page_size; $data ['messages'] = $this->messagedao->get_message_list ( $uid, $fromuid, $time, $limit ); $data ['messages'] = $this->_format_message_data ( $data ['messages'] ); $this->messagedao->update_message_new ( $uid ); return $data; } /** * 根据问题ID,用户ID * @param unknown_type $qid * @param unknown_type $uid */ function get_question_by_uqid($qid = 0, $uid = 0) { $rs = $this->questiondao->get_question_by_uqid ( $qid, $uid ); return $rs; } /** * 根据回答ID,问题ID * @param unknown_type $aid * @param unknown_type $qid */ function get_answer_by_aqid($aid = 0, $qid = 0) { $rs = $this->answerdao->get_answer_by_aqid ( $aid, $qid ); return $rs; } /** * 获取名师答疑问题 */ function get_vip_questions_list($data = array (), $condition = "", $limit = "", $type = "vip") { $result = $this->get_list ( $data, $condition, $limit, t_vipquestion ); foreach ( $result as $key => $value ) { $rs = $this->userdao->get_userinfo_by_uid ( $value ['authorid'] ); $rs ['avatar'] = $this->get_user_avatar_by_username ( $value ['author'] ); $result [$key] ['description'] = strip_tags ( $value ['description'] ); $result [$key] ['user'] = $rs; } $result = $this->_format_vip_question_data ( $result ); return $result; } /** * 根据ID获取名师答疑问题 * @param unknown_type $id */ function get_vip_questions_by_id($id = 0) { $rs = $this->vipquestiondao->get_vip_question_by_id ( $id ); $rs ['time_stamp'] = $rs ['time']; $rs ['time_10'] = $rs ['time_stamp'] + 10 * 60; $rs ['time'] = my_date_format2 ( $rs ['time'], "Y-m-d H:i:s" ); return $rs; } /** * 根据ID获取名师回答 * @param unknown_type $id */ function get_vip_answer_by_id($id = 0) { $rs = $this->vipanswerdao->get_vip_answer_by_qid ( $id ); if (empty ( $rs )) return array (); $rs ['answer_again'] = ""; //追问和回答 $tag_array = unserialize ( $rs ['tag'] ); $rs ['to_ask'] = $tag_array [0]; if (isset ( $tag_array [1] )) $rs ['to_ask_time'] = my_date_format2 ( $tag_array [1] ); if (isset ( $tag_array [2] )) $rs ['answer_again'] = $tag_array [2]; return $rs; } /** * 获取该用户指定的名师问题 * @param unknown_type $qid * @param unknown_type $uid */ function get_vip_question_by_quid($qid = 0, $uid = 0) { $rs = $this->vipquestiondao->get_vip_question_by_quid ( $qid, $uid ); if (! empty ( $rs )) { $rs ['time_stamp'] = $rs ['time']; $rs ['time_10'] = $rs ['time_stamp'] + 10 * 60; $rs ['time'] = my_date_format2 ( $rs ['time'], "Y-m-d H:i:s" ); } return $rs; } /** * 更新名师答疑问题详情 * @param unknown_type $qid * @param unknown_type $description */ function update_vip_question_description($qid = 0, $description = "") { $this->vipquestiondao->update_vip_question_description ( $qid, $description ); } /** * 获取某个用户的名师答疑 * @param unknown_type $uid */ function get_vip_questions_by_uid($uid) { $rs = $this->vipquestiondao->get_vip_question_by_uid ( $uid ); foreach ( $rs as $key => $value ) { $rs [$key] ['time'] = format_date ( $value ['time'] ); } return $rs; } /** * 后台获取名师答疑问题 */ function get_vip_questions_list_admin($data = array (), $condition = "", $limit = "", $type = "vip") { $result = $this->get_list ( $data, $condition, $limit, t_vipquestion ); $nowtime = get_date (); foreach ( $result as $key => $value ) { $result [$key] ['do_answer_time'] = $value ['time']; if ($value ['price'] == 100) { $do_answer_time = $value ['time'] + 432000 - $nowtime; $result [$key] ['do_answer_time'] = do_vip_answer_time ( $do_answer_time ); } elseif ($value ['price'] == 200) { $do_answer_time = $value ['time'] + 259200 - $nowtime; $result [$key] ['do_answer_time'] = do_vip_answer_time ( $do_answer_time ); } elseif ($value ['price'] == 500) { $do_answer_time = $value ['time'] + 172800 - $nowtime; $result [$key] ['do_answer_time'] = do_vip_answer_time ( $do_answer_time ); } $rs = $this->vipanswerdao->get_vip_answer_by_qid ( $value ['id'] ); $result [$key] ['aid'] = $rs ['id']; //追问和回答 $tag_array = unserialize ( $rs ['tag'] ); $result [$key] ['to_ask'] = $tag_array [0]; if (isset ( $tag_array [1] )) $result [$key] ['to_ask_time'] = my_date_format2 ( $tag_array [1] ); if (isset ( $tag_array [2] )) $result [$key] ['answer_again'] = $tag_array [2]; } $result = $this->_format_vip_question_data ( $result ); return $result; } /** * 获取用户财富明细列表 * @param unknown_type $uid */ function get_credit3_list($data = array(), $condition = "", $limit = "") { $rs = $this->get_list ( $data, $condition, $limit, t_credit3log ); foreach ( $rs as $key => $value ) { if ($value ['is_vip'] == 0) $rs [$key] ['question'] = $this->questiondao->get_question_by_id ( $value ['qid'] ); else $rs [$key] ['question'] = $this->vipquestiondao->get_vip_question_by_id ( $value ['qid'] ); $rs [$key] ['date'] = format_date ( $value ['time'] ); } return $rs; } /** * 获取其他相关公告 * @param unknown_type $id */ function get_article_other($id = 0) { Doo::loadModel ( 'ArticleDao' ); $articledao = new ArticleDao (); $rs = $articledao->get_article_other ( $id ); foreach ( $rs as $key => $value ) { $rs [$key] ['time'] = format_date ( $value ['time'] ); } return $rs; } /** * 获取名师讨论 * @param unknown_type $id */ function get_discuss_by_qid($id) { Doo::loadModel ( 'DiscussDao' ); $discussdao = new DiscussDao (); $rs ['discuss_list'] = $discussdao->get_discuss_by_qid ( $id ); $uid = array (); foreach ( $rs ['discuss_list'] as $key => $value ) { $user = $this->userdao->get_userinfo_by_uid ( $value ['uid'] ); array_push ( $uid, $user ['uid'] ); $rs ['discuss_list'] [$key] ['user'] = $user; $rs ['discuss_list'] [$key] ['user'] ['avatar'] = $this->get_user_avatar_by_username ( $user ['username'] ); $rs ['discuss_list'] [$key] ['time'] = format_date ( $value ['time'] ); $chir_discuss = $discussdao->get_discuss_by_cid ( $value ['id'] ); foreach ( $chir_discuss as $keys => $values ) { $user = $this->userdao->get_userinfo_by_uid ( $values ['uid'] ); $chir_discuss [$keys] ['user'] = $user; $chir_discuss [$keys] ['user'] ['avatar'] = $this->get_user_avatar_by_username ( $user ['username'] ); } $rs ['discuss_list'] [$key] ['chir_discuss'] = $chir_discuss; } $uid = array_unique ( $uid ); $rs ['user_num'] = count ( $uid ); return $rs; } /** * 获取充值日志 * @param unknown_type $uid */ function get_bank_jorunal_list($data = array(), $condition = "", $limit = "") { $rs = $this->get_list ( $data, $condition, $limit, t_bankjorunal ); foreach ( $rs as $key => $value ) { $rs [$key] ['time'] = format_date ( $value ['time'] ); } return $rs; } /** * 获取金额 * @param unknown_type $username */ function get_bank_by_username($username = "") { $bank = 0; require_once (SITE_PATH . '/protected/plugin/client.php'); $client = new client ( ZHSSO ); $userinfo = $client->zhsso_getUserbyName ( $username ); $userinfo = explode ( "\r", $userinfo ); $ts = json_decode ( $userinfo ['0'], true ); $bank = $ts [0] ['bank']; return $bank; } /** * 获取通行证用户头像-- * @param unknown_type $username */ function get_user_avatar_by_username($username = "") { require_once (SITE_PATH . '/protected/plugin/client.php'); $client = new client ( ZHSSO ); $avatar = array ('180' => DEF_AVATAR, '30' => DEF_AVATAR, '90' => DEF_AVATAR, '45' => DEF_AVATAR ); $userinfo = $client->zhsso_getUserbyName ( $username ); $userinfo = explode ( "\r", $userinfo ); $ts = json_decode ( $userinfo ['0'], true ); if (isset ( $ts ) && ! empty ( $ts )) { $avatar = $client->ps_getavatar ( $ts [0] ['id'] ); } return $avatar; } /** * 获取充值信息 * @param unknown_type $uid */ function get_recharge($username = "") { $statusArray = array ('succ' => '充值完成', 'failed' => '充值失败', 'error' => '充值错误', 'progress' => '等待付款', 'timeout' => '超时', 'cancel' => '关闭', 'waitting' => '等待付款', 'unpay' => '交易未支付' ); require_once (SITE_PATH . '/protected/plugin/client.php'); $client = new client ( ZHSSO ); $userinfo = $client->zhsso_getUserbyName ( $username ); $userinfo = explode ( "\r", $userinfo ); $ts = json_decode ( $userinfo ['0'], true ); $recharge_info = explode ( "\r", $client->getPayOrder ( $ts [0] ['id'] ) ); $PayOrderArray = json_decode ( $recharge_info ['1'], true ); $this->data ['v_mid'] = '22544863'; // 商户号,这里为测试商户号1001,替换为自己的商户号(老版商户号为4位或5位,新版为8位)即可 $this->data ['v_url'] = Doo::conf ()->APP_URL . 'Receive'; // 请填写返回url,地址应为绝对路径,带有http协议 $this->data ['key'] = 'smartcost@)!@onlinepaychinabank'; // 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/ $this->data ['v_moneytype'] = "CNY"; if (! empty ( $PayOrderArray )) { foreach ( $PayOrderArray as $value ) { $tmpArray [] = ( array ) $value; } foreach ( $tmpArray as $key => $value ) { if ($value ['status'] == 'unpay') $tmpArray [$key] ['md5info'] = strtoupper ( md5 ( $value ['money'] . $this->data ['v_moneytype'] . $value ['trade_sn'] . $this->data ['v_mid'] . $this->data ['v_url'] . $this->data ['key'] ) ); $tmpArray [$key] ['statusname'] = $statusArray [$value ['status']]; $tmpArray [$key] ['addtime'] = format_date ( $value ['addtime'] ); } } else { $tmpArray = null; } sort ( $tmpArray ); return $tmpArray; } public function payOrder() { // // $this->data['v_mid'] = '22544863'; // 商户号,这里为测试商户号1001,替换为自己的商户号(老版商户号为4位或5位,新版为8位)即可 // $this->data['v_url'] = Doo::conf()->APP_URL . 'Receive'; // 请填写返回url,地址应为绝对路径,带有http协议 // $this->data['key'] = 'smartcost@)!@onlinepaychinabank'; // 如果您还没有设置MD5密钥请登陆我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/ // $this->data['v_moneytype'] = "CNY"; // if (!empty($PayOrderArray)) { // foreach ($PayOrderArray as $value) { // $tmpArray[] = (array) $value; // } // foreach ($tmpArray as $key => $value) { // if ($value['status'] == 'unpay') // $tmpArray[$key]['md5info'] = strtoupper(md5($value['money'] . $this->data['v_moneytype'] . $value['trade_sn'] . $this->data['v_mid'] . $this->data['v_url'] . $this->data['key'])); // $tmpArray[$key]['statusname'] = $statusArray[$value['status']]; // } // } else { // $tmpArray = null; // } // $this->data['PayOrderArray'] = $tmpArray; // $this->data['leftmenu'] = 'payOrder'; // $this->data['extmenu'] = 0; // $this->data['curlink'] = __FUNCTION__; // $this->render('myHome - rechargeOrder', $this->data, TRUE); } /** * * Enter description here ... * @param unknown_type $qid */ function get_question_by_qid($qid) { $result = $this->questiondao->get_question_by_id ( $qid ); return $result; } /** * 实现接口 * (non-PHPdoc) * @see BaseLogic::format_email_content() */ protected function format_email_content($html_templete, $templete_name, $qid, $aid) { } function get_credit_log(){ $result = $this->credit3logdao->get_all_list(); return $result; } } ?>