php写接口的日常
admin
2023-06-14 10:22:53
0
    /*
      评论列表
     */
    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;
            }
    }

相关内容

热门资讯

女婿深夜持刀重伤岳父母背后:1... 澎湃新闻记者 史凭5月7日凌晨,云南镇雄县44岁男子陈某潜入岳父家中持刀行凶,将两位熟睡中的老人刺成...
尴尬!美国急于安抚,“但QUA... 【文/观察者网 熊超然】“当印度、日本和澳大利亚三国最高外交官于5月26日在新德里与美国国务卿鲁比奥...
丈夫家暴后以为妻子死了,将她抛... 2024年12月24日,在离婚诉讼被驳回的第13天,陕西咸阳女子苗苗遭到丈夫张某毒打。张某误以为失去...
民众党内乱狂烧,柯文哲被爆遭架... 柯文哲表示,很多人认为他对很多资讯不了解、被控制不能讲话,他直言“我没有失智啦”。民众党近来因提名争...
山西沁源矿难背后:沦为空文的1... 5月22日晚7时29分,山西省沁源县留神峪煤矿发生瓦斯爆炸事故。截至目前,事故已致82人遇难,2人失...
微软Copilot Cowor... IT之家 5 月 26 日消息,PromptArmor 昨日(5 月 25 日)发布博文,报道称微软...
瑞达精工取得数显天气气象钟专利... 国家知识产权局信息显示,福建瑞达精工股份有限公司取得一项名为“一种数显天气气象钟”的专利,授权公告号...
苹果之后,三星也加速去高通化! 5月26日消息,据产业链最新消息,苹果计划将完全自主研发的5G基带芯片应用到iPhone 18全系机...
300万以下的京沪“老破小”卖... 作者 | 孙梦凡今年楼市的“小阳春”行情,持续期比往年更长。以往,楼市“小阳春”大多集中在3月~4月...
原创 2... 来源:网络消息 当自然指数最新一期数据揭晓,中国科学技术大学以1021.18分的总论文分数,稳居中...