ApplyController.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace App\Http\Controllers\AdminApi;
  3. use App\Http\Controllers\AdminController;
  4. use App\Models\UserModels\WxSignup;
  5. use App\Models\UserModels\WxUser;
  6. class ApplyController extends AdminController
  7. {
  8. function getList(){
  9. $search = request()->input('search','');//搜索内容
  10. $name = request()->input('name','');//推广人
  11. $where = [];
  12. if ($name) $where[] = ['u.name', 'like', "%$name%"];
  13. $list = WxSignup::from('wx_signups as s')
  14. ->leftJoin('wx_users as u', 's.p_id', '=', 'u.id')
  15. ->where($where)
  16. ->where(function ($q) use ($search){
  17. if($search){
  18. $q->where('s.name','like',"%$search%");
  19. $q->orWhere('s.phone','like',"%$search%");
  20. }
  21. })
  22. ->select(['s.id','s.name','s.phone','s.industry','s.created_at','u.name as s_name'])
  23. ->paginate(10);
  24. return $this->apiResponseSuccess('获取信息成功', [
  25. 'list' => $list->items(),
  26. 'total' => $list->total(),
  27. 'limit' => 10
  28. ]);
  29. }
  30. /**
  31. * 获取推广者列表
  32. * @return \Illuminate\Http\JsonResponse
  33. */
  34. function getApplyList(){
  35. $search = request()->input('search','');//搜索内容
  36. $where = [['status',1]];
  37. $list = WxUser::where($where)
  38. ->where(function ($q) use ($search){
  39. if($search){
  40. $q->where('name','like',"%$search%");
  41. $q->orWhere('phone','like',"%$search%");
  42. }
  43. })
  44. ->select(['id','name','phone','pv','uv','created_at'])
  45. ->paginate(10);
  46. foreach ($list as $value){
  47. $value['count'] = WxUser::where('p_id',$value['id'])->where('status',1)->count();
  48. }
  49. return $this->apiResponseSuccess('获取信息成功', [
  50. 'list' => $list->items(),
  51. 'total' => $list->total(),
  52. 'limit' => 10
  53. ]);
  54. }
  55. /**
  56. * 获取下级统计
  57. * @return \Illuminate\Http\JsonResponse
  58. */
  59. function getTotal(){
  60. $m_id = request()->input('m_id','');//用户id
  61. if (empty($m_id)) return $this->apiResponseError( '必要参数缺失');
  62. $where = [['status',1], ['p_id',$m_id]];
  63. $list = WxUser::where($where)
  64. ->select(['id','name','phone','created_at'])
  65. ->paginate(10);
  66. return $this->apiResponseSuccess('获取信息成功', [
  67. 'list' => $list->items(),
  68. 'total' => $list->total(),
  69. 'limit' => 10
  70. ]);
  71. }
  72. }