...
|
...
|
@@ -190,18 +190,50 @@ class Common |
|
|
* 商品列表
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function goodsList($where='',$page,$limit='',$order='id desc'){
|
|
|
public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc'){
|
|
|
$arr = [];
|
|
|
//默认未登录
|
|
|
$is_news = 2;
|
|
|
if(!empty($uid)){
|
|
|
//已登录
|
|
|
$res1 = self::findSoftWhereData('order',['uid'=>$uid,'status'=>config('verify.status')[3]],'id');
|
|
|
if($res1){
|
|
|
$is_news = 1;//旧人
|
|
|
}else{
|
|
|
$is_news = 0;//新人
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(empty($where)){
|
|
|
$res = Common::selectSoftPageData('goods','id,image,name,tag,style,new_price,sale_price,expense_price',$page,$limit,$order);
|
|
|
if($is_news == 1){
|
|
|
//去除含有新人标签的数据
|
|
|
$res = Common::selectSoftWherePageData('goods',['is_new'=>0],'id,image,name,tag,style,sale_price,expense_price,is_new',$page,$limit,$order);
|
|
|
}else{
|
|
|
$res = Common::selectSoftPageData('goods','id,image,name,tag,style,sale_price,expense_price,is_new',$page,$limit,$order);
|
|
|
}
|
|
|
}else{
|
|
|
$res = Common::selectSoftWherePageData('goods',$where,'id,image,name,tag,style,new_price,sale_price,expense_price',$page,$limit,$order);
|
|
|
if($is_news == 1){
|
|
|
$where['is_new'] = 0;
|
|
|
}
|
|
|
$res = Common::selectSoftWherePageData('goods',$where,'id,image,name,tag,style,sale_price,expense_price,is_new',$page,$limit,$order);
|
|
|
}
|
|
|
|
|
|
foreach ($res as &$value){
|
|
|
if($is_news == 2 || $is_news == 0){//未登录或者新人
|
|
|
if($value['is_new'] == 0){
|
|
|
//非新人优惠标签
|
|
|
$value['is_new_tag'] = 0;//不用显示新人价标签
|
|
|
}else{
|
|
|
//新人优惠标签
|
|
|
$value['is_new_tag'] = 1;//显示新人价标签
|
|
|
}
|
|
|
}else{
|
|
|
$value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来)
|
|
|
}
|
|
|
$value['image'] = self::absolutionUrlOne($value['image']);
|
|
|
$value['style'] = explode('|',$value['style']);
|
|
|
$value['tag'] = explode('|',$value['tag']);
|
|
|
unset($value['is_new']);
|
|
|
}
|
|
|
$arr['data'] = $res;
|
|
|
//总页数
|
...
|
...
|
@@ -213,19 +245,46 @@ class Common |
|
|
* 检索商品列表
|
|
|
* @ApiInternal
|
|
|
*/
|
|
|
public static function searchGoodsList($keyword,$where,$page){
|
|
|
public static function searchGoodsList($keyword,$where,$page,$uid){
|
|
|
$arr = [];
|
|
|
//默认未登录
|
|
|
$is_news = 2;
|
|
|
if(!empty($uid)){
|
|
|
//已登录
|
|
|
$res1 = self::findSoftWhereData('order',['uid'=>$uid,'status'=>config('verify.status')[3]],'id');
|
|
|
if($res1){
|
|
|
$is_news = 1;//旧人
|
|
|
}else{
|
|
|
$is_news = 0;//新人
|
|
|
}
|
|
|
}
|
|
|
if($is_news == 1){
|
|
|
$where['is_new'] = 0;
|
|
|
}
|
|
|
$limit = config('verify.limit');
|
|
|
$res = Db::name('goods')
|
|
|
->field('LOCATE("'.$keyword.'",name) as nameIndex,id,image,name,tag,new_price,sale_price,expense_price')//获取关键字的位置:LOCATE(关键字,字段) 返回索引位置
|
|
|
->field('LOCATE("'.$keyword.'",name) as nameIndex,id,image,name,tag,is_new,style,sale_price,expense_price')//获取关键字的位置:LOCATE(关键字,字段) 返回索引位置
|
|
|
->where($where)//多字段条件查询
|
|
|
->page($page,$limit)
|
|
|
->order('nameIndex')//按tIndex 值排序
|
|
|
->select();
|
|
|
foreach ($res as &$value){
|
|
|
if($is_news == 2 || $is_news == 0){//未登录或者新人
|
|
|
if($value['is_new'] == 0){
|
|
|
//非新人优惠标签
|
|
|
$value['is_new_tag'] = 0;//不用显示新人价标签
|
|
|
}else{
|
|
|
//新人优惠标签
|
|
|
$value['is_new_tag'] = 1;//显示新人价标签
|
|
|
}
|
|
|
}else{
|
|
|
$value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来)
|
|
|
}
|
|
|
$value['name'] = str_replace($keyword,'<a href="javascript:void(0);" style="color:red;">'.$keyword.'</a>',$value['name']);
|
|
|
$value['image'] = self::absolutionUrlOne($value['image']);
|
|
|
$value['tag'] = explode('|',$value['tag']);
|
|
|
$value['style'] = explode('|',$value['style']);
|
|
|
unset($value['is_new']);
|
|
|
}
|
|
|
$arr['data'] = $res;
|
|
|
//总页数
|
...
|
...
|
|