/*
评论列表
*/
public function commentListW(){
$base = new Base();
$info = $base->getUserByToken();
$shop_id = $info['shop_id'];
$page = $this->data['page']?:1;
$pagesize = $this->data['pagesize']?:C('ROLLPAGE');
$search = $this->data['search'];
$and = "";
if($search){
$and .= " and (c.c_name like '%{$search}%' or cu.customer_name like '%{$search}%')";
}
$sql0 = "select count(c.c_id) as itemcount from `comment` as c left join `customer` as cu on c.customer_id=cu.customer_id where c.shop_id='{$shop_id}' and c.com_status='0'{$and}";
$itemcount = M()->query($sql0)[0]['itemcount'];
$pagecount = ceil($itemcount/$pagesize);
$limit = ($page-1)*$pagesize;
$offset = " limit {$limit},{$pagesize}";
$sql1 = "select c.c_id,c.c_name,c.c_pic,c.c_type,cu.customer_name,cu.headimgurl,c.com_content,c.com_time,c.reply_time,c.thumb_num,c.pic_num,c.com_reply,c.is_reply,c.com_status,c.com_status from `comment` as c left join `customer` as cu on c.customer_id=cu.customer_id where c.shop_id='{$shop_id}' and c.com_status='0'{$and} order by c.com_time desc {$offset}";
$data = M()->query($sql1);
$ret = array();
$ret['data'] = $data;
$ret['page'] = array(
'pagecount'=>(int)$pagecount,
'itemcount'=>(int)$itemcount,
);
return $ret;
}
/*
点赞/取消点赞
*/
public function doThumb(){
$art_id = $this->data['art_id'];
$customer_id = $this->data['customer_id'];
$brand_id = $this->data['brand_id'];
$time = time();
$data = $this->getThumb();
if($data){
$thumb_id = $data['thumb_id'];
$thumb_status = $data['thumb_status'];
if($thumb_status==0){
$sql = "update `brand_article_thumb` set thumb_status='1' where thumb_id='{$thumb_id}'";
}else{
$sql = "update `brand_article_thumb` set thumb_status='0' where thumb_id='{$thumb_id}'";
}
}else{
$sql = "insert into `brand_article_thumb` (art_id,customer_id,thumb_time,brand_id) values ('{$art_id}','{$customer_id}','{$time}','{$brand_id}')";
}
$ret = M()->execute($sql);
if($ret<0){
return false;
}else{
return true;
}
}
分享文章:php写接口的日常
转载来源:
http://njwzjz.com/article/ihhcpd.html