PaymentController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\Payment;
  5. use App\Models\Shop;
  6. use App\Models\User;
  7. use Auth;
  8. use function compact;
  9. use function view;
  10. class PaymentController extends Controller
  11. {
  12. /**
  13. * Display a listing of the resource.
  14. *
  15. * @return \Illuminate\Http\Response
  16. */
  17. // public function index()
  18. // {
  19. // $payments = Payment::where('seller_id', Auth::user()->seller->id)->paginate(9);
  20. // return view('seller.payment_history', compact('payments'));
  21. // }
  22. /**
  23. * Display a listing of the resource.
  24. *
  25. * @return \Illuminate\Http\Response
  26. */
  27. public function payment_histories(Request $request)
  28. {
  29. $payments = Payment::orderBy('created_at', 'desc')->where('t_type',1)->paginate(15);
  30. return view('backend.sellers.payment_histories.index', compact('payments'));
  31. }
  32. public function payment_histories_cus(Request $request)
  33. {
  34. $payments = Payment::orderBy('created_at', 'desc')->where('t_type',2)->paginate(15);
  35. return view('backend.sellers.payment_histories.index2', compact('payments'));
  36. }
  37. /**
  38. * Show the form for creating a new resource.
  39. *
  40. * @return \Illuminate\Http\Response
  41. */
  42. public function create()
  43. {
  44. //
  45. }
  46. /**
  47. * Store a newly created resource in storage.
  48. *
  49. * @param \Illuminate\Http\Request $request
  50. * @return \Illuminate\Http\Response
  51. */
  52. public function store(Request $request)
  53. {
  54. //
  55. }
  56. /**
  57. * Display the specified resource.
  58. *
  59. * @param int $id
  60. * @return \Illuminate\Http\Response
  61. */
  62. public function show($id)
  63. {
  64. $user = User::find(decrypt($id));
  65. $payments = Payment::where('seller_id', $user->id)->orderBy('created_at', 'desc')->get();
  66. if($payments->count() > 0){
  67. return view('backend.sellers.payment', compact('payments', 'user'));
  68. }
  69. flash(translate('No payment history available for this seller'))->warning();
  70. return back();
  71. }
  72. /**
  73. * Show the form for editing the specified resource.
  74. *
  75. * @param int $id
  76. * @return \Illuminate\Http\Response
  77. */
  78. public function edit($id)
  79. {
  80. //
  81. }
  82. /**
  83. * Update the specified resource in storage.
  84. *
  85. * @param \Illuminate\Http\Request $request
  86. * @param int $id
  87. * @return \Illuminate\Http\Response
  88. */
  89. public function update(Request $request, $id)
  90. {
  91. //
  92. }
  93. /**
  94. * Remove the specified resource from storage.
  95. *
  96. * @param int $id
  97. * @return \Illuminate\Http\Response
  98. */
  99. public function destroy($id)
  100. {
  101. //
  102. }
  103. /**
  104. * Display a listing of the resource.
  105. *
  106. * @return \Illuminate\Http\Response
  107. */
  108. public function salesman_payment_histories(Request $request)
  109. {
  110. $userIds = [];
  111. $users_1 = User::where('pid', '=', Auth::user()->id)->where('user_type', '=', 'seller')->get();//下一级商家
  112. foreach ( $users_1 as $user_1 )
  113. {
  114. $userIds[] = $user_1->id;
  115. $users_2 = User::where('pid', '=', $user_1->id)->where('user_type', '=', 'seller')->get();//下二级商家
  116. foreach ( $users_2 as $user_2 )
  117. {
  118. $userIds[] = $user_2->id;
  119. $users_3 = User::where('pid', '=', $user_2->id)->where('user_type', '=', 'seller')->get();//下二级商家
  120. foreach ( $users_3 as $user_3 )
  121. {
  122. $userIds[] = $user_3->id;
  123. }
  124. }
  125. }
  126. $payments = Payment::orderBy('created_at', 'desc')->whereIn('seller_id', $userIds)->paginate(15);
  127. return view('salesman.sellers.payment_histories.index', compact('payments'));
  128. }
  129. }