where(['id' => $userId])->findOrEmpty(); $user['address'] = $user->province_text.$user->city_text.$user->area_text.$user->street_text.$user->village_text.$user->brigade_text.$user->address; $user['gender_text'] = $user->gender_text; $user['status_text'] = $user->status_text; //获取用户余额列表 $user['balance_list'] = UserBalance::field('id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){ $item['app'] = System::where('app_id',$item['appid'])->value('name'); $item['type_text'] = $item->type_text; $item['pay_type_text'] = $item->pay_type_text; unset($item['appid']); })->toArray(); //获取用户积分列表 $user['integral_list'] = UserIntegral::field('id,record_id,amount,total_amount,type,mark,appid,create_time')->where('user_id',$userId)->limit(10)->order('create_time desc')->select()->each(function($item){ $item['app'] = System::where('app_id',$item['appid'])->value('name'); $item['type_text'] = $item->type_text; })->toArray(); unset($user['province'],$user['city'],$user['area'],$user['street'],$user['village'],$user['brigade']); return $user->toArray(); } //用户余额列表 public static function balanceList($params): array { $search = []; if(isset($params['record_id']) && !empty($params['record_id'])){ $search[] = ['record_id','=',$params['record_id']]; } if(isset($params['mark']) && !empty($params['mark'])){ $search[] = ['mark','like','%'.$params['mark'].'%']; } if(isset($params['appid']) && !empty($params['appid'])){ $app = System::field('app_id')->where('id',$params['appid'])->findOrEmpty(); if(!$app->isEmpty()){ $search[] = ['appid','=',$app['app_id']]; } } if(isset($params['pay_type']) && in_array($params['pay_type'],[0,1,2,3,4])){ $search[] = ['pay_type','=',$params['pay_type']]; } //获取用户余额列表 $fields = 'id,record_id,amount,total_amount,type,pay_type,mark,appid,create_time'; $lists = UserBalance::field($fields)->where('user_id',$params['uid'])->where($search)->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){ $item['app'] = System::where('app_id',$item['appid'])->value('name'); $item['type_text'] = $item->type_text; $item['pay_type_text'] = $item->pay_type_text; unset($item['appid']); })->toArray(); $count = UserBalance::field('id')->where('user_id',$params['uid'])->where($search)->count(); return [ 'count' => $count, 'page_no' => $params['page_no'], 'page_size' => $params['page_size'], 'lists' => $lists ]; } //用户积分列表 public static function integralList($params): array { $search = []; if(isset($params['mark']) && !empty($params['mark'])){ $search[] = ['mark','like','%'.$params['mark'].'%']; } if(isset($params['appid']) && !empty($params['appid'])){ $app = System::field('app_id')->where('id',$params['appid'])->findOrEmpty(); if(!$app->isEmpty()){ $search[] = ['appid','=',$app['app_id']]; } } if(isset($params['type']) && in_array($params['type'],[0,1])){ $search[] = ['type','=',$params['type']]; } //获取用户积分列表 $fields = 'id,record_id,amount,total_amount,type,mark,appid,create_time'; $lists = UserIntegral::field($fields)->where('user_id',$params['uid'])->where($search)->page($params['page_no'],$params['page_size'])->order('create_time desc')->select()->each(function($item){ $item['app'] = System::where('app_id',$item['appid'])->value('name'); $item['type_text'] = $item->type_text; })->toArray(); $count = UserIntegral::field('id')->where('user_id',$params['uid'])->where($search)->count(); return [ 'count' => $count, 'page_no' => $params['page_no'], 'page_size' => $params['page_size'], 'lists' => $lists ]; } }