...
|
...
|
@@ -8,6 +8,7 @@ use app\common\controller\Api; |
|
|
use fast\Http;
|
|
|
use think\Validate;
|
|
|
use think\Db;
|
|
|
use think\db\Expression;
|
|
|
|
|
|
/**
|
|
|
* 个人中心接口
|
...
|
...
|
@@ -326,57 +327,15 @@ class User extends Api |
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
|
|
|
$is_news = Common::is_new($this->uid);
|
|
|
$limit = config('verify.limit');
|
|
|
$where = ['uid'=>$this->uid];
|
|
|
if($is_news == 1){
|
|
|
//旧人
|
|
|
$where['is_new'] = 0;
|
|
|
}
|
|
|
$res = Db::name('collection')
|
|
|
->alias('c')
|
|
|
->join('goods g','c.g_id = g.id')
|
|
|
->where($where)
|
|
|
->field('g.id,g.image,g.name,g.tag,g.style,g.sale_price1 sale_price,g.expense_price,g.is_new')
|
|
|
->page($page,$limit)
|
|
|
->order('c.id desc')
|
|
|
->useSoftDelete('g.deletetime')
|
|
|
->select();
|
|
|
$collection = Common::selectWhereData('collection',['uid'=>$this->uid],'id,g_id');
|
|
|
$g_ids = array_column($collection,'g_id');
|
|
|
|
|
|
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'] = Common::absolutionUrlOne($value['image']);
|
|
|
$value['style'] = explode('|',$value['style']);
|
|
|
$value['tag'] = explode('|',$value['tag']);
|
|
|
$sale_price = Common::salePrice($value['sale_price']);
|
|
|
if($sale_price){
|
|
|
$value['sale_price'] = $sale_price[0];
|
|
|
}else{
|
|
|
$value['sale_price'] = '';
|
|
|
}
|
|
|
unset($value['is_new']);
|
|
|
}
|
|
|
$arr['data'] = $res;
|
|
|
//总页数
|
|
|
//按照指定的顺序排序
|
|
|
$g_id_str = implode(',',$g_ids);
|
|
|
$exp = new Expression('field(id,'.$g_id_str.')');
|
|
|
|
|
|
$count= Db::name('collection')
|
|
|
->alias('c')
|
|
|
->join('goods g','c.g_id = g.id')
|
|
|
->where($where)
|
|
|
->order('c.id desc')
|
|
|
->useSoftDelete('g.deletetime')
|
|
|
->count();
|
|
|
$arr['total_page'] = ceil($count/$limit);
|
|
|
$limit = config('verify.limit');
|
|
|
$arr = Common::goodsList(['id'=>['in',$g_ids]],$page,$this->uid,$limit,$exp);
|
|
|
$this->success('成功',$arr);
|
|
|
}else{
|
|
|
$this->error('请求方式错误');
|
...
|
...
|
|