|
@@ -0,0 +1,83 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+namespace App\Http\Controllers\Api;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+use App\Http\Controllers\ApiController;
|
|
|
|
|
+use App\Servers\System\BaiduServer;
|
|
|
|
|
+use App\Servers\System\SmsServer;
|
|
|
|
|
+
|
|
|
|
|
+class CommonController extends ApiController
|
|
|
|
|
+{
|
|
|
|
|
+ public $request;
|
|
|
|
|
+ public $smsService;
|
|
|
|
|
+
|
|
|
|
|
+ public function __construct()
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送短信
|
|
|
|
|
+ * @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 getImageOrc(){
|
|
|
|
|
+ $image = request()->input('image','');
|
|
|
|
|
+ $type = request()->input('type',-1);//识别类型
|
|
|
|
|
+
|
|
|
|
|
+ if (empty($image)){
|
|
|
|
|
+ return $this->apiResponseError('请正确上传文件');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!in_array($type,[1,2,3,4])){
|
|
|
|
|
+ return $this->apiResponseError('识别类型出错');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $baiduServer = BaiduServer::creatServer();
|
|
|
|
|
+ if ($type == 1){//身份证含照片的一面识别
|
|
|
|
|
+ $result = $baiduServer->idCard($image,'front');
|
|
|
|
|
+ }elseif ($type == 2){//身份证带国徽的一面识别
|
|
|
|
|
+ $result = $baiduServer->idCard($image,'back');
|
|
|
|
|
+ }elseif ($type == 3){//营业执照识别
|
|
|
|
|
+ $result = $baiduServer->businessLicense($image);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (empty($result) || $result['code'] == 0){
|
|
|
|
|
+ return $this->apiResponseError(empty($result['msg'])?'识别类型错误':$result['msg']);
|
|
|
|
|
+ }
|
|
|
|
|
+ return $this->apiResponseSuccess('成功',$result['data']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|