-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvoiceVerifyController.php
72 lines (65 loc) · 1.56 KB
/
InvoiceVerifyController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace app\modules\gscheck\controllers;
use Yii;
use yii\web\Response;
use yii\rest\Controller;
use yii\filters\ContentNegotiator;
use yii\web\BadRequestHttpException;
use yii\web\ServerErrorHttpException;
use app\common\helpers\ResponseHelper;
use app\modules\gscheck\models\invoiceVerify\ImageOCR;
use app\components\verifyProcedure\verifys\InvoiceData;
use app\modules\gscheck\models\invoiceVerify\InvoiceVerify;
class InvoiceVerifyController extends Controller
{
/**
* @var string|array the configuration for creating the serializer that formats the response data.
*/
public $serializer = 'yii\rest\Serializer';
/**
* @inheritdoc
*/
public $enableCsrfValidation = FALSE;
public function init()
{
parent::init();
Yii::$app->getResponse()->on(Response::EVENT_BEFORE_SEND, [ResponseHelper::className(), 'beforeSend']);
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'contentNegotiator' => [
'class' => ContentNegotiator::className(),
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
],
];
}
/**
* 图片识别
* @return array|array[]
* @throws BadRequestHttpException
* @throws ServerErrorHttpException
*/
public function actionOcr()
{
$params = Yii::$app->request->post();
$model = new ImageOCR();
return $model->process($params);
}
/**
* 单个批量查询
* @return InvoiceData|array
* @throws BadRequestHttpException
*/
public function actionVerify()
{
$params = Yii::$app->request->post();
$model = new InvoiceVerify();
return $model->process($params);
}
}