From c13ff1312ec52e7417911e61dc58f3ec74473db7 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 3 Sep 2019 11:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=84=E8=AE=BA=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/store/StoreProductReply.php | 15 ++++----------- .../admin/model/store/StoreProductReply.php | 12 +++++++----- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/application/admin/controller/store/StoreProductReply.php b/application/admin/controller/store/StoreProductReply.php index f5daaa6b..ce14c592 100644 --- a/application/admin/controller/store/StoreProductReply.php +++ b/application/admin/controller/store/StoreProductReply.php @@ -29,19 +29,10 @@ class StoreProductReply extends AuthController */ public function index() { - $where = Util::getMore([ - ['is_reply',''], - ['comment',''], - ],$this->request); - $product_id = 0; $product_id = input('product_id'); - if($product_id) - $where['product_id'] = $product_id; - else - $where['product_id'] = 0; - $this->assign('where',$where); + if(!$product_id) $product_id = 0; $this->assign('is_layui',true); - $this->assign(ProductReplyModel::systemPage($where)); + $this->assign('product_id',(int)$product_id); return $this->fetch(); } @@ -52,6 +43,8 @@ class StoreProductReply extends AuthController ['limit',10], ['title',''], ['is_reply',''], + ['product_name',''], + ['product_id',0], ]); return JsonService::successful(ProductReplyModel::getProductImaesList($where)); } diff --git a/application/admin/model/store/StoreProductReply.php b/application/admin/model/store/StoreProductReply.php index 012e9324..d083696c 100644 --- a/application/admin/model/store/StoreProductReply.php +++ b/application/admin/model/store/StoreProductReply.php @@ -29,22 +29,24 @@ class StoreProductReply extends ModelBasic * @param string $alias * @param object $model * */ - public static function valiWhere($where,$alias='',$model=null) + public static function valiWhere($where,$alias='',$joinAlias='',$model=null) { $model=is_null($model) ? new self() : $model; if($alias){ $model=$model->alias($alias); $alias.='.'; } + $joinAlias=$joinAlias ? $joinAlias.'.' : ''; if(isset($where['title']) && $where['title']!='') $model=$model->where("{$alias}comment",'LIKE',"%$where[title]%"); if(isset($where['is_reply']) && $where['is_reply']!='') $model= $where['is_reply'] >= 0 ? $model->where("{$alias}is_reply",$where['is_reply']) : $model->where("{$alias}is_reply",'GT',0); - if(isset($where['producr_id']) && $where['producr_id']!=0) $model=$model->where('product_id',$where['producr_id']); + if(isset($where['producr_id']) && $where['producr_id']!=0) $model=$model->where($alias.'product_id',$where['producr_id']); + if(isset($where['product_name']) && $where['product_name']) $model=$model->where("{$joinAlias}store_name",'LIKE',"%$where[product_name]%"); return $model->where("{$alias}is_del",0); } public static function getProductImaesList($where) { - $list=self::valiWhere($where,'a')->group('p.id')->join('__WECHAT_USER__ u','u.uid=a.uid')->join("__STORE_PRODUCT__ p",'a.product_id=p.id')->field(['p.id','p.image','p.store_name','p.price'])->page($where['page'],$where['limit'])->select(); + $list=self::valiWhere($where,'a','p')->group('p.id')->join('__WECHAT_USER__ u','u.uid=a.uid')->join("__STORE_PRODUCT__ p",'a.product_id=p.id')->field(['p.id','p.image','p.store_name','p.price'])->page($where['page'],$where['limit'])->select(); $list=count($list) ? $list->toArray() : []; foreach ($list as &$item){ $item['store_name']=self::getSubstrUTf8($item['store_name'],10,'UTF-8',''); @@ -55,7 +57,7 @@ class StoreProductReply extends ModelBasic public static function getProductReplyList($where) { - $data=self::valiWhere($where,'a')->join("__STORE_PRODUCT__ p",'a.product_id=p.id') + $data=self::valiWhere($where,'a','p')->join("__STORE_PRODUCT__ p",'a.product_id=p.id') ->join('__WECHAT_USER__ u','u.uid=a.uid') ->order('a.add_time desc,a.is_reply asc') ->field('a.*,u.nickname,u.headimgurl as avatar') @@ -65,7 +67,7 @@ class StoreProductReply extends ModelBasic foreach ($data as &$item){ $item['time']=\service\UtilService::timeTran($item['add_time']); } - $count=self::valiWhere($where,'a')->join('__WECHAT_USER__ u','u.uid=a.uid')->join("__STORE_PRODUCT__ p",'a.product_id=p.id')->count(); + $count=self::valiWhere($where,'a','p')->join('__WECHAT_USER__ u','u.uid=a.uid')->join("__STORE_PRODUCT__ p",'a.product_id=p.id')->count(); return ['list'=>$data,'count'=>$count]; } /**