| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301 | 
							- <?php
 
- /**
 
-  * 问答显示逻辑
 
-  * @author cp
 
-  */
 
- class AskLogic extends BaseLogic {
 
- 	
 
- 	private $categorydao;
 
- 	private $questiondao;
 
- 	private $creditdao;
 
- 	private $answerdao;
 
- 	private $messagedao;
 
- 	private $authissuedao;
 
- 	private $vipquestiondao;
 
- 	private $vipanswerdao;
 
- 	private $userdao;
 
- 	private $credit3logdao;
 
- 	private $funddao;
 
- 	
 
- 	
 
- 	function __construct() {
 
- 		
 
- 		Doo::loadModel ( 'CategoryDao' );
 
- 		Doo::loadModel ( 'QuestionDao' );
 
- 		Doo::loadModel ( 'CreditDao' );
 
- 		Doo::loadModel ( 'AnswerDao' );
 
- 		Doo::loadModel ( 'MessageDao' );
 
- 		Doo::loadModel ( 'AuthissueDao' );
 
- 		Doo::loadModel ( 'VipquestionDao' );
 
- 		Doo::loadModel ( 'VipanswerDao' );
 
- 		Doo::loadModel ( 'UserDao' );
 
- 		Doo::loadModel ( 'Credit3logDao' );
 
- 		Doo::loadModel ( 'FundDao' );
 
- 		
 
- 		$this->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 .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
 
- 				else
 
- 					$page .= '<a href="' . $action . $i . '" class="paginate">' . $i . '</a>';
 
- 				
 
- 				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 .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
 
- 				else
 
- 					$page_c .= ' <span class="current">' . $i . '</span> ';
 
- 			} else if ($other == "page")
 
- 				$page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
 
- 			else
 
- 				$page_c .= ' <a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a> ';
 
- 			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;
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 格式化回答 // '#<a.+?href="(.+?)".*?>(.+?)</a>#'
 
- 	 * @param unknown_type $data
 
- 	 */
 
- 	function _format_message_data($data = array()) {
 
- 		foreach ( $data as $key => $value ) {
 
- 			
 
- 			preg_match ( '#<a.*?>(.+?)</a>#', $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 .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
 
- 			else
 
- 				$page .= '<a href="javascript:void(0);" id="get_msg_' . $i . '" data="' . $muid . '_' . $i . '"  class="paginate">' . $i . '</a>';
 
- 			
 
- 			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' => '<span class="colGreen">充值完成</span>', 'failed' => '充值失败', 'error' => '充值错误', 'progress' => '<span class="colOrange">等待付款</span>', 'timeout' => '超时', 'cancel' => '关闭', 'waitting' => '<span class="colOrange">等待付款</span>', '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;
 
- 	}
 
- 	
 
- }
 
- ?>
 
 
  |