getUserByToken(); $shop_i..."/>
溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

php寫接口的日常

發(fā)布時(shí)間:2020-04-11 12:08:02 來源:網(wǎng)絡(luò) 閱讀:633 作者:Lee_吉 欄目:web開發(fā)
    /*
      評(píng)論列表
     */
    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;
    }
    /*
     點(diǎn)贊/取消點(diǎn)贊
     */
    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問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI