@@ -21,6 +21,7 @@ class Question_model extends CI_Model {
$this->index=$xs->index;
}
}
//设为已解决
functionchange_to_solve($qids){
...
...
@@ -80,10 +81,10 @@ class Question_model extends CI_Model {
$adoptmoeny=$question['shangjin'];
//回答者获得赏金
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine+'$cash_fee' WHERE `uid`=$touid");
//$this->db->query ( "UPDATE " . $this->db->dbprefix . "user SET `jine`=jine+'$cash_fee' WHERE `uid`=$touid" );
//被采纳获得赏金记录
if($adoptmoeny>0)
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='adoptqid',typeid=$qid,money=$adoptmoeny,openid='',fromuid=$quid,touid=$touid,`time`=$time");//增加被采纳记录
//if ($adoptmoeny > 0)
// $this->db->query ( "INSERT INTO " . $this->db->dbprefix . "paylog SET type='adoptqid',typeid=$qid,money=$adoptmoeny,openid='',fromuid=$quid,touid=$touid,`time`=$time" ); //增加被采纳记录
return1;
...
...
@@ -116,7 +117,7 @@ class Question_model extends CI_Model {
@@ -371,28 +372,46 @@ class Question_model extends CI_Model {
foreach($query->result_array()as$question){
$qid=$question['id'];
$authorid=$question['authorid'];
//是否有提问悬赏现金托管
$model=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='qid' and typeid=$qid and fromuid=$authorid and state=0")->row_array();
$model=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='qid' and typeid=$qid and fromuid=$authorid ")->row_array();
if($model){
$fromuid=$model['fromuid'];
$money=$model['needpay']*100;
$qtitle="删除问题:".$question['title'];
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine+'$money' WHERE `uid`=$fromuid");
$time=time();
$needpay=$model['needpay'];
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='thqid',typeid=$qid,money=$needpay,openid='',fromuid=0,touid=$fromuid,`time`=$time");
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='thqid',typeid=$qid,money=$needpay,beizhu='$qtitle',openid='',fromuid=0,touid=$fromuid,`time`=$time");
$this->db->query("DELETE FROM `".$this->db->dbprefix."user_depositmoney` WHERE fromuid=$fromuid and type='qid' and typeid=$qid");
$adoptmodel=$this->db->query("SELECT * FROM ".$this->db->dbprefix."paylog WHERE type='adoptqid' and typeid=$qid and fromuid=$authorid")->row_array();
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine-'$adoptpay' WHERE `uid`=$adoptuid");
$needpay=$adoptmodel['money'];
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='thadoptqid',typeid=$qid,money=$needpay,beizhu='$qadoptcontent',openid='',fromuid=0,touid=$adoptuid,`time`=$time");
}
}
//是否有对专家付费提问
$model1=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='eqid' and typeid=$qid and fromuid=$authoridand state=0")->row_array();
$model1=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='eqid' and typeid=$qid and fromuid=$authorid ")->row_array();
if($model1){
$fromuid=$model1['fromuid'];
$money=$model1['needpay']*100;
$qtitle="付费咨询问题:".$question['title'];
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine+'$money' WHERE `uid`=$fromuid");
$time=time();
$needpay=$model1['needpay'];
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='theqid',typeid=$qid,money=$needpay,openid='',fromuid=0,touid=$fromuid,`time`=$time");
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='theqid',typeid=$qid,money=$needpay,beizhu='$qtitle',openid='',fromuid=0,touid=$fromuid,`time`=$time");
$this->db->query("DELETE FROM `".$this->db->dbprefix."user_depositmoney` WHERE fromuid=$fromuid and type='eqid' and typeid=$qid");
}
...
...
@@ -493,8 +512,10 @@ class Question_model extends CI_Model {
//$this->db->query ( "INSERT INTO " . $this->db->dbprefix . "question SET cid='$cid',cid1='$cid1',cid2='$cid2',cid3='$cid3',askuid='$askfromuid',authorid='$uid',shangjin='$shangjin',author='$username',title='$title',description='$description',price='$price',time='$creattime',endtime='$endtime',hidden='$hidanswer',status='$status',ip='{$this->base->ip}'" );
$qid=$this->db->insert_id();
...
...
@@ -874,12 +896,35 @@ class Question_model extends CI_Model {
$quid=$question['authorid'];
$adoptmoeny=$question['shangjin'];
$cash_fee=intval($question['shangjin'])*100;
$qtitle="关闭问题:".$question['title'];
//如果没有回答,删除托管记录,零钱回到用户钱包,设置问题关闭
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine+'$cash_fee' WHERE `uid`=$quid");
//删除托管记录
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='closeqid',typeid=$qid,money=$adoptmoeny,openid='',fromuid=0,touid=$quid,`time`=$time");//增加关闭问题记录
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='closeqid',typeid=$qid,money=$adoptmoeny,beizhu='$qtitle',openid='',fromuid=0,touid=$quid,`time`=$time");//增加关闭问题记录
$authorid=$question['authorid'];
//是否有提问悬赏现金托管
$model=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='qid' and typeid=$qid and fromuid=$authorid and state=0")->row_array();
if($model){
$fromuid=$model['fromuid'];
$this->db->query("DELETE FROM `".$this->db->dbprefix."user_depositmoney` WHERE fromuid=$fromuid and type='qid' and typeid=$qid");
}
//是否有对专家付费提问
$model1=$this->db->query("SELECT * FROM ".$this->db->dbprefix."user_depositmoney WHERE type='eqid' and typeid=$qid and fromuid=$authorid and state=0")->row_array();
if($model1){
$fromuid=$model1['fromuid'];
$money=$model1['needpay']*100;
$qtitle="付费咨询问题:".$question['title'];
$this->db->query("UPDATE ".$this->db->dbprefix."user SET `jine`=jine+'$money' WHERE `uid`=$fromuid");
$time=time();
$needpay=$model1['needpay'];
$this->db->query("INSERT INTO ".$this->db->dbprefix."paylog SET type='theqid',typeid=$qid,money=$needpay,beizhu='$qtitle',openid='',fromuid=0,touid=$fromuid,`time`=$time");
$this->db->query("DELETE FROM `".$this->db->dbprefix."user_depositmoney` WHERE fromuid=$fromuid and type='eqid' and typeid=$qid");
}
}
}
...
...
@@ -910,7 +955,7 @@ class Question_model extends CI_Model {
@@ -1250,12 +1294,10 @@ class Question_model extends CI_Model {
functionmakeindex($startindex,$pagesize){
if($this->base->setting['xunsearch_open']){
if($startindex==0){
$this->index->clean();
}
$this->index->openBuffer();
$query=$this->db->query("SELECT * FROM ".$this->db->dbprefix."question LIMIT $startindex,$pagesize");
$query=$this->db->query("SELECT * FROM ".$this->db->dbprefix."question where status!=0 and isupdatexunsearch=0 order by time desc LIMIT $startindex,$pagesize");
foreach($query->result_array()as$question){
$data=array();
$data['id']=$question['id'];
...
...
@@ -1278,6 +1320,7 @@ class Question_model extends CI_Model {
@@ -716,9 +716,9 @@ class Topic_model extends CI_Model {
$desrc=addslashes($desrc);
$filepath=addslashes($filepath);
if($filepath)
$this->db->query("UPDATE `".$this->db->dbprefix."topic` SET `title`='$title' ,`describtion`='$desrc' , `image`='$filepath' WHERE `id`=$id");
$this->db->query("UPDATE `".$this->db->dbprefix."topic` SET `isupdatexunsearch`=0 ,`title`='$title' ,`describtion`='$desrc' , `image`='$filepath' WHERE `id`=$id");
else
$this->db->query("UPDATE `".$this->db->dbprefix."topic` SET `title`='$title' ,`describtion`='$desrc' WHERE `id`=$id");
$this->db->query("UPDATE `".$this->db->dbprefix."topic` SET `isupdatexunsearch`=0 , `title`='$title' ,`describtion`='$desrc' WHERE `id`=$id");
if($this->base->setting['xunsearch_open']){
$topic=array();
$topic['id']=$id;
...
...
@@ -751,6 +751,7 @@ class Topic_model extends CI_Model {
'describtion'=>$desrc,
'image'=>$filepath,
'isphone'=>$isphone,
'isupdatexunsearch'=>0,
'ispc'=>$ispc,
'views'=>$views,
'articleclassid'=>$cid
...
...
@@ -765,6 +766,7 @@ class Topic_model extends CI_Model {
'price'=>$price,
'describtion'=>$desrc,
'isphone'=>$isphone,
'isupdatexunsearch'=>0,
'ispc'=>$ispc,
'views'=>$views,
'articleclassid'=>$cid
...
...
@@ -773,7 +775,7 @@ class Topic_model extends CI_Model {
'id'=>$id
))->update('topic',$data);
}
if($this->base->setting['xunsearch_open']){
$topic=array();
$topic['id']=$id;
...
...
@@ -953,7 +955,7 @@ class Topic_model extends CI_Model {
functionmakeindex($startindex,$pagesize){
if($this->base->setting['xunsearch_open']){
$this->index->openBuffer();
$query=$this->db->query("SELECT * FROM ".$this->db->dbprefix."topic limit $startindex, $pagesize");
$query=$this->db->query("SELECT * FROM ".$this->db->dbprefix."topic where state!=0 and isupdatexunsearch=0 order by viewtime desc limit $startindex, $pagesize");
foreach($query->result_array()as$topic){
$data=array();
...
...
@@ -976,6 +978,7 @@ class Topic_model extends CI_Model {