增加发票识别

This commit is contained in:
lccsw
2025-12-04 10:11:35 +08:00
parent 2308c4cc91
commit da51a60088
2 changed files with 23 additions and 2 deletions
+22 -1
View File
@@ -19,6 +19,7 @@ class Subsidy extends BaseController
$this->auto_series_model->set_db('ssdb');
$this->biz_model->set_db('ssdb');
$this->receiver_orders_model->set_db('ssdb');
$this->load->library('TcOrc');
}
public function index_post()
@@ -35,6 +36,26 @@ class Subsidy extends BaseController
if (!$result->isSuccess()) {
throw new Exception($result->getMessage());
}
$reqData = $result->getData();
//识别发票
if ($params['businessImg'] && $reqData['orderId']) {
$url = build_qiniu_image_url($params['businessImg']);
$billTime = "";
$ocrResult = $this->tcorc->CarInvoiceInfos($url);
if ($ocrResult['code'] && $ocrResult['data']['CarInvoiceInfos']) {
$carInvoiceInfos = $ocrResult['data']['CarInvoiceInfos'];
foreach ($carInvoiceInfos as $item) {
if ($item['Name'] == '开票日期') {
$billTime = str_replace(['年', '月', '日'], ['-', '-', ''], $item['Value']);
break;
}
}
$billTime = date('Y-m-d', strtotime($billTime));
}
if ($billTime) {
$this->receiver_orders_model->update(['bill_time' => $billTime], ['id' => $reqData['orderId']]);
}
}
$this->return_response();
} catch (Exception $e) {
$this->return_json($e->getMessage());
@@ -86,7 +107,7 @@ class Subsidy extends BaseController
if ($row['businessImg']) {
$insuranceFile[] = ['url' => $row['businessImg'] ? build_qiniu_image_url($row['businessImg']) : ''];
}
if($row['contractImg']){
if ($row['contractImg']) {
$contractFile[] = ['url' => $row['contractImg'] ? build_qiniu_image_url($row['contractImg']) : ''];
}
$data = [
@@ -170,7 +170,7 @@ class AutoUserCouponEntity
$this->ci->load->model('app/licheb/app_licheb_users_model');
$this->ci->app_licheb_users_model->set_db('ssdb');
$this->ci->app_licheb_users_model->sendSmsToManager($bizId, "门店新增了一个订单,请及时到小程序“理车宝-订单”进行处理。");
return new MyRESPONSE(EXIT_SUCCESS, '核销成功');
return new MyRESPONSE(EXIT_SUCCESS, '核销成功', ['orderId' => $orderId]);
} catch (Exception $e) {
$this->ci->db->trans_rollback();
return new MyResponse(EXIT_ERROR, $e->getMessage());