AccountController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 balance()
  34. {
  35. $params = request()->post();
  36. $pageSize = request()->post('pageSize', 15);
  37. $params['user_id'] = isset($params['user_id']) ? $params['user_id'] : $this->userId;
  38. $datas = BalanceLogService::make()->getDataList($params, $pageSize);
  39. return message(1010, true, $datas);
  40. }
  41. /**
  42. * 收入提现
  43. * @return array
  44. */
  45. public function withdraw()
  46. {
  47. try {
  48. $params = request()->all();
  49. if (!$result = BalanceLogService::make()->withdraw($this->userId, $params)) {
  50. return showJson(BalanceLogService::make()->getError(), false);
  51. } else {
  52. return showJson(BalanceLogService::make()->getError(), true, $result);
  53. }
  54. } catch (\Exception $exception) {
  55. $error = ['data' => $exception->getTrace(), 'err' => $exception->getMessage()];
  56. return showJson(1046, false, $error);
  57. }
  58. }
  59. }