作者 jinglong
1 个管道 的构建 通过 耗费 7 秒

修改所有商品列表的价格标签

... ... @@ -144,9 +144,9 @@ class Brand extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -157,7 +157,6 @@ class Brand extends Api
"ABX级",
"ABN级"
],
"new_price": 2499,
"sale_price": 2599
},
],
... ... @@ -176,7 +175,7 @@ class Brand extends Api
}
$where = ['type'=>1,'t_id'=>$b_id];
$arr = Common::goodsList($where,$page);
$arr = Common::goodsList($where,$page,$this->uid);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -203,9 +203,9 @@ class Cars extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -233,7 +233,7 @@ class Cars extends Api
$this->error($validate->getError());
}
$arr = Common::goodsList('',$page,'','hots desc,id desc');
$arr = Common::goodsList('',$page,$this->uid,'hots desc,id desc');
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -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;
//总页数
... ...
... ... @@ -146,9 +146,9 @@ class Goods extends Api
"隐秘乡奢",
"家庭情侣"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -183,11 +183,8 @@ class Goods extends Api
$where['t_id'] = $result['t_id'];
$where['id'] = ['<>',$result['id']];
}
$res = Common::selectSoftWhereLimitData('goods',$where,'id,image,name,tag,new_price,sale_price,expense_price');
foreach ($res as &$value){
$value['image'] = $this->auth->absolutionUrlOne($value['image']);
$value['tag'] = explode('|',$value['tag']);
}
$limit = config('verify.limit');
$res = Common::goodsList($where,1,$this->uid,$limit);
$this->success('成功',$res);
}else{
$this->error('请求方式错误');
... ... @@ -227,9 +224,9 @@ class Goods extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -276,11 +273,15 @@ class Goods extends Api
$order = 'sales asc';
}
}else if($price){
if($price == 1){
$order = 'sale_price desc,id desc';
}else if($price == 2){
$order = 'sale_price asc';
}
}
$where = ['type'=>0,'t_id'=>$s_id];
$limit = config('verify.goods_limit');
$arr = Common::goodsList($where,$page,$limit,$order);
$arr = Common::goodsList($where,$page,$this->uid,$limit,$order);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -110,7 +110,7 @@ class Index extends Api
$arr['res_advert'] = $res_advert;
//设计师作品
$res_design = Common::selectSoftWhereLimitData('goods',['flag'=>$this->flag[2]],'id,name,introduce,sale_price,file','sort desc');
$res_design = Common::selectSoftWhereLimitData('goods',['is_design'=>$this->flag[1]],'id,name,introduce,sale_price,file','sort desc');
foreach ($res_design as &$d_value){
//获取视频帧
$d_value['image'] = $this->auth->absolutionUrlOneFrame($d_value['file'],2);
... ... @@ -183,7 +183,7 @@ class Index extends Api
{
"id": 7,//商品id
"image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片路径
"name": "MONENT 动感系列",//商品名称
"name": "MONENT 动感系列",//商品名称(含有标记红色标签)
"tag": [//商品标签
"日式简约",
"隐秘乡奢",
... ... @@ -193,9 +193,9 @@ class Index extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -206,7 +206,6 @@ class Index extends Api
"ABX级",
"ABN级"
],
"new_price": 2499,
"sale_price": 2599
},
],
... ... @@ -223,8 +222,8 @@ class Index extends Api
$this->error($validate->getError());
}
$where = ['flag'=>$this->flag[1]];
$arr = Common::goodsList($where,$page);
$where = ['is_recommend'=>$this->flag[1]];
$arr = Common::goodsList($where,$page,$this->uid);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -16,6 +16,7 @@ class News extends Api
public function _initialize()
{
parent::_initialize();
$this->uid = $this->auth->getUserId();
}
/**
... ... @@ -46,9 +47,9 @@ class News extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -77,9 +78,9 @@ class News extends Api
}
$flag = config('verify.flag');
$where = ['flag'=>$flag[3]];
$where = ['is_new'=>$flag[1]];
$limit = config('verify.goods_limit');
$arr = Common::goodsList($where,$page,$limit);
$arr = Common::goodsList($where,$page,$this->uid,$limit);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -48,9 +48,9 @@ class Search extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -81,7 +81,7 @@ class Search extends Api
$where = ['type_name|name'=>['like','%'.$keyword.'%']];
//暂时
$arr = Common::searchGoodsList($keyword,$where,$page);
$arr = Common::searchGoodsList($keyword,$where,$page,$this->uid);
//写入检索记录
// $record = Common::findWhereData('record',['uid'=>$this->uid,'keyword'=>$keyword],'id,keyword');
// if(!$record){
... ...
... ... @@ -279,9 +279,9 @@ class User extends Api
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -311,7 +311,7 @@ class User extends Api
$res = Common::selectWhereData('collection',['uid'=>$this->uid],'id,g_id');
$goods_ids = array_column($res,'g_id');
$res1 = Common::goodsList(['id'=>['in',$goods_ids]],$page);
$res1 = Common::goodsList(['id'=>['in',$goods_ids]],$page,$this->uid);
$this->success('成功',$res1);
}else{
$this->error('请求方式错误');
... ...
... ... @@ -22,8 +22,8 @@ return [
//非凡谷域名
'ffg_host' => 'http://feifangu.w.brotop.cn',
//商品标识
'flag' => [0,1,2,3],//0:普通,1:推荐,2:设计师作品,3:新人特惠
//订单状态
// 'flag' => [0,1,2,3],//0:普通,1:推荐,2:设计师作品,3:新人特惠
'flag' => [0,1],//0:否,1:是
'status' => [0,1,2,3],//0:待付款,1:待发货,2:待收货,3:已完成
//分页数
'limit' => 10,
... ...
... ... @@ -568,9 +568,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -581,7 +581,6 @@
"ABX级",
"ABN级"
],
"new_price": 2499,
"sale_price": 2599
},
],
... ... @@ -1181,9 +1180,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -1678,9 +1677,9 @@
"隐秘乡奢",
"家庭情侣"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -1866,9 +1865,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -2262,7 +2261,7 @@
{
"id": 7,//商品id
"image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片路径
"name": "MONENT 动感系列",//商品名称
"name": "MONENT 动感系列",//商品名称(含有标记红色标签)
"tag": [//商品标签
"日式简约",
"隐秘乡奢",
... ... @@ -2272,9 +2271,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -2285,7 +2284,6 @@
"ABX级",
"ABN级"
],
"new_price": 2499,
"sale_price": 2599
},
],
... ... @@ -2582,9 +2580,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -2772,9 +2770,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -3731,9 +3729,9 @@
"主餐匙,茶匙各1件",
"古堡灰"
],
"new_price": 2199,//新人价格(未登录,未购买记录(个人中心返是否有购买记录),显示该字段,另加“新人价”标签)
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
... ... @@ -3765,7 +3763,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2019-12-02 10:54:24 </div>
Generated on 2019-12-02 16:48:33 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...