CommonController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace App\Http\Controllers\AdminApi;
  3. use App\Http\Controllers\AdminController;
  4. use App\Servers\System\BaiduServer;
  5. use App\Servers\System\CommonServer;
  6. use App\Servers\System\SmsServer;
  7. use Illuminate\Support\Facades\Storage;
  8. class CommonController extends AdminController
  9. {
  10. /**
  11. * 发送短信
  12. * @return \Illuminate\Http\JsonResponse
  13. * @throws \End01here\EasySms\Exceptions\CodeErrorException
  14. * @throws \End01here\EasySms\Exceptions\GatewayErrorException
  15. * @throws \End01here\EasySms\Exceptions\MessageException
  16. */
  17. function sendSms()
  18. {
  19. $phone = request()->input('phone', '');
  20. $send_type = request()->input('send_type', 'default');
  21. if (empty($phone)) {
  22. return $this->apiResponseError('请输入手机号码');
  23. }
  24. $send_server = SmsServer::creatServer();
  25. $ret = $send_server->sendCode($phone, $send_type);
  26. if (!$ret) {
  27. return $this->apiResponseError($send_server->getErrorMsg() ?: '短信发送失败');
  28. } else {
  29. return $this->apiResponseSuccess('短信发送成功');
  30. }
  31. }
  32. /**
  33. * 获取身份证orc识别
  34. * @return \Illuminate\Http\JsonResponse
  35. */
  36. function getCardFrontOrc()
  37. {
  38. $commonServer = CommonServer::creatServer();
  39. $id_card = $commonServer->filtrationStr('id_card');//身份证正面
  40. if (empty($id_card)) return $this->apiResponseError( '请上传身份证正面');
  41. $result = BaiduServer::creatServer()->idCard($id_card);
  42. if ($result['code'] == 1){
  43. return $this->apiResponseSuccess($result['msg'],$result['data']);
  44. }else{
  45. return $this->apiResponseError($result['msg']);
  46. }
  47. }
  48. /**
  49. * 获取营业执照orc识别
  50. * @return \Illuminate\Http\JsonResponse
  51. */
  52. function getLicenseOrc()
  53. {
  54. $commonServer = CommonServer::creatServer();
  55. $license_img = $commonServer->filtrationStr('license_img');//营业执照
  56. if (empty($license_img)) return $this->apiResponseError( '请上传营业执照');
  57. $result = BaiduServer::creatServer()->businessLicense($license_img);
  58. if ($result['code'] == 1){
  59. return $this->apiResponseSuccess($result['msg'],$result['data']);
  60. }else{
  61. return $this->apiResponseError($result['msg']);
  62. }
  63. }
  64. /**
  65. * 获取阿里云临时权限
  66. * @return \Illuminate\Http\JsonResponse
  67. */
  68. function getAliSts()
  69. {
  70. $ret = CommonServer::creatServer()->getAliSts();
  71. if (empty($ret['code'])) {
  72. return $this->apiResponseError($ret['msg']);
  73. } else {
  74. return $this->apiResponseSuccess($ret['msg'], $ret['data']);
  75. }
  76. }
  77. /**
  78. * 获取腾讯云临时权限
  79. * @return \Illuminate\Http\JsonResponse
  80. */
  81. function getTxySts()
  82. {
  83. $ret = CommonServer::creatServer()->getTxySts();
  84. if (empty($ret['code'])) {
  85. return $this->apiResponseError($ret['msg']);
  86. } else {
  87. return $this->apiResponseSuccess($ret['msg'], $ret['data']);
  88. }
  89. }
  90. }