WalletController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Http\Controllers\Client;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\Client\WalletService;
  5. use Auth;
  6. /**
  7. * @group 用户端
  8. *
  9. * 钱包相关的API接口
  10. */
  11. class WalletController extends Controller
  12. {
  13. protected WalletService $service;
  14. public function __construct(WalletService $service)
  15. {
  16. $this->service = $service;
  17. }
  18. /**
  19. * [钱包管理]获取钱包明细
  20. *
  21. * 获取钱包明细
  22. *
  23. * @authenticated
  24. *
  25. * @response {
  26. * "code": 200,
  27. * "message": "获取成功",
  28. * "data": {
  29. * "records": []
  30. * }
  31. * }
  32. */
  33. public function records()
  34. {
  35. return $this->service->getWalletRecords(Auth::user()->id, request('per_page', 10));
  36. }
  37. /**
  38. * [钱包管理]获取用户钱包
  39. *
  40. * 获取当前用户的钱包信息
  41. *
  42. * @authenticated
  43. *
  44. * @response {
  45. * "code": 200,
  46. * "message": "获取成功",
  47. * "data": {
  48. * "balance": 100.00,
  49. * "freeze": 0.00
  50. * }
  51. * }
  52. */
  53. public function wallet()
  54. {
  55. return $this->service->getUserWallet(Auth::user()->id);
  56. }
  57. }