| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- namespace App\Http\Controllers\AdminApi;
- use App\Http\Controllers\AdminController;
- use App\Servers\System\BaiduServer;
- use App\Servers\System\CommonServer;
- use App\Servers\System\SmsServer;
- use Illuminate\Support\Facades\Storage;
- class CommonController extends AdminController
- {
- /**
- * 发送短信
- * @return \Illuminate\Http\JsonResponse
- * @throws \End01here\EasySms\Exceptions\CodeErrorException
- * @throws \End01here\EasySms\Exceptions\GatewayErrorException
- * @throws \End01here\EasySms\Exceptions\MessageException
- */
- function sendSms()
- {
- $phone = request()->input('phone', '');
- $send_type = request()->input('send_type', 'default');
- if (empty($phone)) {
- return $this->apiResponseError('请输入手机号码');
- }
- $send_server = SmsServer::creatServer();
- $ret = $send_server->sendCode($phone, $send_type);
- if (!$ret) {
- return $this->apiResponseError($send_server->getErrorMsg() ?: '短信发送失败');
- } else {
- return $this->apiResponseSuccess('短信发送成功');
- }
- }
- /**
- * 获取身份证orc识别
- * @return \Illuminate\Http\JsonResponse
- */
- function getCardFrontOrc()
- {
- $commonServer = CommonServer::creatServer();
- $id_card = $commonServer->filtrationStr('id_card');//身份证正面
- if (empty($id_card)) return $this->apiResponseError( '请上传身份证正面');
- $result = BaiduServer::creatServer()->idCard($id_card);
- if ($result['code'] == 1){
- $id_number = empty($result['data']['公民身份号码']['words']) ? '' : $result['data']['公民身份号码']['words'];
- $name = empty($result['data']['姓名']['words']) ? '' : $result['data']['姓名']['words'];
- $sex = empty($result['data']['性别']['words']) ? '' : $result['data']['性别']['words'];
- $birthday = empty($result['data']['出生']['words']) ? '' : $result['data']['出生']['words'];
- if ($birthday) {
- $birthday = substr($birthday, 0, 4) . '-' . substr($birthday, 4, 2) . '-' . substr($birthday, 6, 2);
- }
- $newData = [
- 'name' => $name,
- 'birthday' => $birthday,
- 'sex' => $sex,
- 'id_number' => $id_number,
- ];
- }else{
- $newData = [
- 'name' => '',
- 'birthday' => '',
- 'sex' => '',
- 'id_number' => '',
- ];
- }
- return $this->apiResponseSuccess('获取成功', $newData);
- }
- /**
- * 获取营业执照orc识别
- * @return \Illuminate\Http\JsonResponse
- */
- function getLicenseOrc()
- {
- $commonServer = CommonServer::creatServer();
- $license_img = $commonServer->filtrationStr('license_img');//营业执照
- if (empty($license_img)) return $this->apiResponseError( '请上传营业执照');
- $result = BaiduServer::creatServer()->businessLicense($license_img);
- if ($result['code'] == 1){
- return $this->apiResponseSuccess($result['msg'],$result['data']);
- }else{
- return $this->apiResponseError($result['msg']);
- }
- }
- /**
- * 获取阿里云临时权限
- * @return \Illuminate\Http\JsonResponse
- */
- function getAliSts()
- {
- $ret = CommonServer::creatServer()->getAliSts();
- if (empty($ret['code'])) {
- return $this->apiResponseError($ret['msg']);
- } else {
- return $this->apiResponseSuccess($ret['msg'], $ret['data']);
- }
- }
- /**
- * 获取腾讯云临时权限
- * @return \Illuminate\Http\JsonResponse
- */
- function getTxySts()
- {
- $ret = CommonServer::creatServer()->getTxySts();
- if (empty($ret['code'])) {
- return $this->apiResponseError($ret['msg']);
- } else {
- return $this->apiResponseSuccess($ret['msg'], $ret['data']);
- }
- }
- }
|