BankController.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace App\Http\Controllers\Bank;
  3. use App\Libs\ApiResponse;
  4. use App\Services\Bank\BankService;
  5. use App\Transformer\Bank\BankTransformer;
  6. use App\Exceptions\ApiException;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Routing\Controller as BaseController;
  9. class BankController extends BaseController
  10. {
  11. use ApiResponse;
  12. protected $bankService;
  13. public function __construct(
  14. BankService $bankService
  15. )
  16. {
  17. $this->bankService = $bankService;
  18. }
  19. /**
  20. * 下拉银行卡列表
  21. *
  22. * @return mixed
  23. */
  24. public function bankList()
  25. {
  26. $banks = $this->bankService->bankList();
  27. return $this->success($banks);
  28. }
  29. /**
  30. * 站点银行卡列表
  31. *
  32. * @return mixed
  33. */
  34. public function channelBankAccounts(Request $request)
  35. {
  36. $all = $request->only('is_company');
  37. $banks = $this->bankService->channelBankAccounts($all);
  38. return $this->success($banks, [new BankTransformer(), 'buildCashAccounts']);
  39. }
  40. /**
  41. * 新增银行卡账号
  42. *
  43. * @param Request $request
  44. * @return mixed
  45. * @throws ApiException
  46. */
  47. public function addBankAccount(Request $request)
  48. {
  49. $all = $request->only('account_name', 'identity_card', 'card_number',
  50. 'account_bank', 'bank_id', 'is_company', 'province', 'sms_code', 'bank');
  51. $result = $this->bankService->addBankAccount($all);
  52. return $this->success(['result' => $result ? 1 : 0]);
  53. }
  54. /*
  55. * 删除银行卡账号
  56. *
  57. * @param Request $request
  58. * @return mixed
  59. * @throws ApiException
  60. */
  61. public function delBankAccount(Request $request)
  62. {
  63. $all = $request->only('id', 'delete_all');
  64. $result = $this->bankService->delBankAccount($all);
  65. return $this->success(['result' => $result ? 1 : 0]);
  66. }
  67. /**
  68. * 发送手机验证码
  69. *
  70. * @return mixed
  71. * @throws ApiException
  72. */
  73. public function getBankAccountSms()
  74. {
  75. $result = $this->bankService->getBankAccountSms();
  76. return $this->success(['result' => $result ? 1 : 0]);
  77. }
  78. }