public function commentList(){ ???$info = $this->getUserByToken(); ???$shop_id = $info[‘shop_id‘]; ???$page = I(‘post.page‘)?:1; ???$pagesize = I(‘post.pagesize‘)?:C(‘ROLLPAGE‘); ???$c_type = I(‘post.c_type‘); ???$serach = I(‘post.serach‘); ???$and = ""; ???if($c_type == 1){ ?# ?商品 ???????if($c_type != 0){ ???????????$and .= " and co.c_type=‘{$c_type}‘"; ???????} ???????if($search){ ???????????$and .= " and (c.c_name like ‘%{$search}%‘)"; ???????} ???}else{ ???????$sql0 = "select count(s.s_id) as itemcount from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???} ???if($c_type == 1){ ?# ?商品 ???????$sql0 = "select count(c.c_id) as itemcount from `erp_commod_comment` as co left join `erp_commod` as c on co.c_id=c.c_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???}else{ ???????$sql0 = "select count(s.s_id) as itemcount from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and}"; ???} ???$itemcount = M()->query($sql0)[0][‘itemcount‘]; ???$pagecount = ceil($itemcount/$pagesize); ???$limit = ($page-1)*$pagesize; ???$offset = " limit {$limit},{$pagesize}"; ???if($c_type == 1){ ?# ?商品 ???????$sql1 = "select c.c_id,c.c_pic,c.c_name,cu.customer_id,cu.customer_name,cu.customer_type,cu.headimgurl,co.com_id,co.com_content,co.com_time,co.com_score,co.thumb_num,co.com_is_return,co.com_status from `erp_commod_comment` as co left join `erp_commod` as c on co.c_id=c.c_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and} order by co.com_status asc,co.com_time desc{$offset}"; ???}else{ ?# ?服务 ???????$sql1 = "select s.s_id,s.s_pic,s.s_name,cu.customer_id,cu.customer_name,cu.customer_type,cu.headimgurl,co.com_id,co.com_content,co.com_time,co.com_score,co.thumb_num,co.com_is_return,co.com_status from `erp_commod_comment` as co left join `erp_shopping_service` as s on co.c_id=s.s_id left join `erp_customer` as cu on co.customer_id=cu.customer_id where co.shop_id=‘{$shop_id}‘{$and} order by co.com_status asc,co.com_time desc{$offset}"; ???} ???$sql1 = ""; ???$data = M()->query($sql1); ???foreach ($data as $key => $value) { ???????$data[$key][‘shop_id‘] = M(‘commod‘,‘erp_‘)->where([‘c_id‘=>$value[‘c_id‘]])->getField(‘shop_id‘); ???} ???$ret = array(); ???$ret[‘data‘] = $data; ???$ret[‘page‘] = array( ???????????‘pagecount‘=>(int)$pagecount, ???????????‘itemcount‘=>(int)$itemcount, ???????); ???$this->ret(1,‘‘,$ret);}
PHP写接口的日常
原文地址:http://blog.51cto.com/12173069/2089125