WalletService.php 703 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Services\Client;
  3. use App\Models\MemberUser;
  4. use App\Models\WalletTransRecord;
  5. use Illuminate\Support\Facades\Auth;
  6. class WalletService
  7. {
  8. /**
  9. * 获取钱包明细
  10. */
  11. public function getWalletRecords()
  12. {
  13. // 获取当前用户
  14. $user = Auth::user();
  15. // 检查用户状态
  16. if ($user->state !== 'enable') {
  17. throw new \Exception('用户状态异常');
  18. }
  19. // 获取钱包交易记录
  20. $records = WalletTransRecord::where('wallet_id', $user->wallet->id)
  21. ->where('state', 'enable')
  22. ->orderBy('created_at', 'desc')
  23. ->paginate(10);
  24. return $records;
  25. }
  26. }