/***
* 个人 我的粉丝
*/
public function fensi(){
$page = input('post.page')? :1;//第几页
$num = input('post.num')? :10;//几条数据
$request_data = input('param.');
//$request_data['user_id']=3;
if(!$request_data){
return json_encode(array('code'=>1,'msg'=>'数据为空','data'=>''));
}
if(!(isset($request_data['user_id']) && $request_data['user_id'] )){
return json_encode(array('code'=>1,'msg'=>'用户id不存在','data'=>''));
}
$brr = array();
$recommendationcode = Db::name('user')->where('id',$request_data['user_id'])->value('recommendationcode');
$arr = Db::name('user')->field('id,nickname,mobile,createtime,recommendationcode')->where('superior_code',$recommendationcode)->select();
foreach ($arr as $key=>$val){
$arr[$key]['zhuangtia'] = "直属";
$brr[] =$val['recommendationcode'];
}
$crr = Db::name('user')->field('id,nickname,mobile,createtime,recommendationcode')->where('superior_code','in',$brr)->select();
foreach ($crr as $key=>$val){
$crr[$key]['zhuangtia'] = "推荐";
}
//两个数组合并成一个数组,并根据某个字段重新排序降序
$drr = array_merge($arr,$crr);
$last_names = array_column($drr,'createtime');
array_multisort($last_names,SORT_DESC,$drr);
$start = ($page-1)*$num;
$drr = array_slice($drr,$start,$num);
return json_encode(array('code' => 0 , 'msg' => '成功' , "data" =>$drr));
}