温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php写接口的日常

发布时间:2020-04-11 12:08:02 来源:网络 阅读:636 作者:Lee_吉 栏目:web开发
    /*
      评论列表
     */
    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;
            }
    }
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI