|
@@ -8,6 +8,7 @@ use app\common\controller\Api; |
|
@@ -8,6 +8,7 @@ use app\common\controller\Api; |
8
|
use fast\Http;
|
8
|
use fast\Http;
|
9
|
use think\Validate;
|
9
|
use think\Validate;
|
10
|
use think\Db;
|
10
|
use think\Db;
|
|
|
11
|
+use think\db\Expression;
|
11
|
|
12
|
|
12
|
/**
|
13
|
/**
|
13
|
* 个人中心接口
|
14
|
* 个人中心接口
|
|
@@ -326,57 +327,15 @@ class User extends Api |
|
@@ -326,57 +327,15 @@ class User extends Api |
326
|
$this->error($validate->getError());
|
327
|
$this->error($validate->getError());
|
327
|
}
|
328
|
}
|
328
|
|
329
|
|
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();
|
330
|
+ $collection = Common::selectWhereData('collection',['uid'=>$this->uid],'id,g_id');
|
|
|
331
|
+ $g_ids = array_column($collection,'g_id');
|
345
|
|
332
|
|
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
|
- //总页数
|
333
|
+ //按照指定的顺序排序
|
|
|
334
|
+ $g_id_str = implode(',',$g_ids);
|
|
|
335
|
+ $exp = new Expression('field(id,'.$g_id_str.')');
|
371
|
|
336
|
|
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);
|
337
|
+ $limit = config('verify.limit');
|
|
|
338
|
+ $arr = Common::goodsList(['id'=>['in',$g_ids]],$page,$this->uid,$limit,$exp);
|
380
|
$this->success('成功',$arr);
|
339
|
$this->success('成功',$arr);
|
381
|
}else{
|
340
|
}else{
|
382
|
$this->error('请求方式错误');
|
341
|
$this->error('请求方式错误');
|