正在显示
1 个修改的文件
包含
52 行增加
和
4 行删除
@@ -326,10 +326,58 @@ class User extends Api | @@ -326,10 +326,58 @@ class User extends Api | ||
326 | $this->error($validate->getError()); | 326 | $this->error($validate->getError()); |
327 | } | 327 | } |
328 | 328 | ||
329 | - $res = Common::selectWhereData('collection',['uid'=>$this->uid],'id,g_id'); | ||
330 | - $goods_ids = array_column($res,'g_id'); | ||
331 | - $res1 = Common::goodsList(['id'=>['in',$goods_ids]],$page,$this->uid); | ||
332 | - $this->success('成功',$res1); | 329 | + $is_news = Common::is_new($this->uid); |
330 | + $limit = config('verify.limit'); | ||
331 | + $where = ['uid'=>$this->uid]; | ||
332 | + if($is_news == 1){ | ||
333 | + //旧人 | ||
334 | + $where['is_new'] = 0; | ||
335 | + } | ||
336 | + $res = Db::name('collection') | ||
337 | + ->alias('c') | ||
338 | + ->join('goods g','c.g_id = g.id') | ||
339 | + ->where($where) | ||
340 | + ->field('g.id,g.image,g.name,g.tag,g.style,g.sale_price1 sale_price,g.expense_price,g.is_new') | ||
341 | + ->page($page,$limit) | ||
342 | + ->order('c.id desc') | ||
343 | + ->useSoftDelete('g.deletetime') | ||
344 | + ->select(); | ||
345 | + | ||
346 | + foreach ($res as &$value){ | ||
347 | + if($is_news == 2 || $is_news == 0){//未登录或者新人 | ||
348 | + if($value['is_new'] == 0){ | ||
349 | + //非新人优惠标签 | ||
350 | + $value['is_new_tag'] = 0;//不用显示新人价标签 | ||
351 | + }else{ | ||
352 | + //新人优惠标签 | ||
353 | + $value['is_new_tag'] = 1;//显示新人价标签 | ||
354 | + } | ||
355 | + }else{ | ||
356 | + $value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来) | ||
357 | + } | ||
358 | + $value['image'] = Common::absolutionUrlOne($value['image']); | ||
359 | + $value['style'] = explode('|',$value['style']); | ||
360 | + $value['tag'] = explode('|',$value['tag']); | ||
361 | + $sale_price = Common::salePrice($value['sale_price']); | ||
362 | + if($sale_price){ | ||
363 | + $value['sale_price'] = $sale_price[0]; | ||
364 | + }else{ | ||
365 | + $value['sale_price'] = ''; | ||
366 | + } | ||
367 | + unset($value['is_new']); | ||
368 | + } | ||
369 | + $arr['data'] = $res; | ||
370 | + //总页数 | ||
371 | + | ||
372 | + $count= Db::name('collection') | ||
373 | + ->alias('c') | ||
374 | + ->join('goods g','c.g_id = g.id') | ||
375 | + ->where($where) | ||
376 | + ->order('c.id desc') | ||
377 | + ->useSoftDelete('g.deletetime') | ||
378 | + ->count(); | ||
379 | + $arr['total_page'] = ceil($count/$limit); | ||
380 | + $this->success('成功',$arr); | ||
333 | }else{ | 381 | }else{ |
334 | $this->error('请求方式错误'); | 382 | $this->error('请求方式错误'); |
335 | } | 383 | } |
-
请 注册 或 登录 后发表评论