|
|
@@ -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];
|
|
|
}
|
|
|
/**
|