AccountController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\AccountService;
  5. use App\Services\Api\BalanceLogService;
  6. /**
  7. * 账单明细
  8. * Class AccountController
  9. * @package App\Http\Controllers\Api
  10. */
  11. class AccountController extends webApp
  12. {
  13. /**
  14. * 列表
  15. * @return array
  16. */
  17. public function index()
  18. {
  19. $params = request()->post();
  20. $pageSize = request()->post('pageSize', 15);
  21. $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
  22. $datas = AccountService::make()->getDataList($params, $pageSize);
  23. if ($datas) {
  24. return message(1010, true, $datas);
  25. } else {
  26. return message(1009, false);
  27. }
  28. }
  29. /**
  30. * 明细
  31. * @return array
  32. */
  33. public function info()
  34. {
  35. $id = request()->post('id', 0);
  36. $info = AccountService::make()->getInfo($id);
  37. if ($info) {
  38. return showJson(1010, true, $info);
  39. } else {
  40. return showJson(1004, false);
  41. }
  42. }
  43. /**
  44. * 余额明细
  45. * @return array
  46. */
  47. public function balance()
  48. {
  49. $params = request()->post();
  50. $pageSize = request()->post('pageSize', 15);
  51. $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
  52. $datas = BalanceLogService::make()->getDataList($params, $pageSize);
  53. return message(1010, true, $datas);
  54. }
  55. /**
  56. * 收入提现
  57. * @return array
  58. */
  59. public function withdraw()
  60. {
  61. // try {
  62. $params = request()->all();
  63. if (!$result = BalanceLogService::make()->withdraw($this->userId, $params)) {
  64. return showJson(BalanceLogService::make()->getError(), false);
  65. } else {
  66. return showJson(BalanceLogService::make()->getError(), true, $result);
  67. }
  68. // } catch (\Exception $exception) {
  69. // $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
  70. // return showJson(1046, false, $error);
  71. // }
  72. }
  73. }