Files
spacestation/common/libraries/receiver/Order_datas_entity.php
T
小鱼开发 3f30c5bcb2 fixed
2024-06-18 01:25:24 +08:00

94 lines
3.6 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: lcc
* Date: 2022/1/10
* Time: 16:11
*/
class Order_datas_entity
{
private $ci;
const COLOR_UN_UPLOAD = '#c1b8b9'; //未上传
const COLOR_IS_UPLOAD = '#ff0000'; //已传
const COLOR_UN_CHECK = '#f9394d'; //未通过
const COLOR_CHECK = '#97d248'; //通过
public function __construct()
{
$this->ci = &get_instance();
$this->ci->load->model('receiver/order/receiver_orders_model', 'orders_model');
$this->ci->load->model('receiver/order/receiver_order_datas_model');
$this->ci->load->library('TcOrc');
}
public function get_row($oid)
{
$row = $this->ci->receiver_order_datas_model->get(['o_id' => $oid]);
if (!$row) {
$this->ci->receiver_order_datas_model->add(['o_id' => $oid, 'c_time' => time()]);
$row = $this->ci->receiver_order_datas_model->get(['o_id' => $oid]);
}
return $row;
}
public function data_status($o_data, $order_status)
{
$result = [
'contract_img' => ['text' => '未上传', 'type' => 0, 'color' => self::COLOR_UN_UPLOAD], //合同图片
'pay_img' => ['text' => '未上传', 'type' => 0, 'color' => self::COLOR_UN_UPLOAD], //支付凭证
'cardida' => ['text' => '未上传', 'type' => 0, 'color' => self::COLOR_UN_UPLOAD], //身份证
'business_licence' => ['text' => '未上传', 'type' => 0, 'color' => self::COLOR_UN_UPLOAD], //营业执照
'equity_ck_img' => ['text' => '未上传', 'type' => 0, 'color' => self::COLOR_UN_UPLOAD], //权益确认书
'bill_img' => ['text' => '未上传', 'type' => 1, 'color' => self::COLOR_UN_UPLOAD], //发票
'delivery_ck_img' => ['text' => '未上传', 'type' => 2, 'color' => self::COLOR_UN_UPLOAD], //交车确认图片
'car_img' => ['text' => '未上传', 'type' => 2, 'color' => self::COLOR_UN_UPLOAD], //行驶证
'car_auth_img' => ['text' => '未上传', 'type' => 2, 'color' => self::COLOR_UN_UPLOAD], //车机实名认证
'insurance_img' => ['text' => '未上传', 'type' => 2, 'color' => self::COLOR_UN_UPLOAD], //交强险图片
];
foreach ($result as $key => $item) {
if ($o_data[$key]) {
if ($order_status > $item['type']) {
$result[$key]['text'] = '已审核';
$result[$key]['color'] = self::COLOR_CHECK;
} else {
$result[$key]['text'] = '已上传';
$result[$key]['color'] = self::COLOR_IS_UPLOAD;
}
}
}
return $result;
}
/**
* 识别发票
* @param $oid
* @param $url
* @return array
*/
public function orc_bill_img($oid, $url)
{
$result = $this->ci->tcorc->CarInvoiceInfos($url);
if (!$result['code']) {
return ['code' => 0, 'msg' => $result['msg']];
}
$data = $result['data']['CarInvoiceInfos'];
$bill_code = $bill_time = '';
foreach ($data as $key => $val) {
if ($val['Name'] == '开票日期') {
$bill_time = $val['Value'];
}
if ($val['Name'] == '发票代码') {
$bill_code = $val['Value'];
}
}
if (!$bill_code) return ['code' => 0, 'msg' => '未识别到发票代码'];
//更新订单开票时间
$bill_time && $this->ci->orders_model->update(['bill_time' => $bill_time], ['id' => $oid]);
return ['code' => 1, 'msg' => '识别成功', 'data' => $data];
}
}