From 6a273548a049f3ad95d132abc628fd8410dfa920 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 1 Feb 2023 14:42:21 +0800 Subject: [PATCH] edit-admin-up_bill_img --- admin/controllers/receiver/orderv2/Orders.php | 35 +++++++++------- admin/views/receiver/orderv2/get/index.php | 41 ++++++++++++++++--- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php index 607260cb..6db6540b 100644 --- a/admin/controllers/receiver/orderv2/Orders.php +++ b/admin/controllers/receiver/orderv2/Orders.php @@ -853,6 +853,7 @@ class Orders extends HD_Controller { $id = $this->input->post('id'); $file = $this->input->post('value'); + $if_usedcar = $this->input->post('if_usedcar'); $row_order = $this->receiver_orders_v2_model->get(array('id' => $id)); if(!$file || !$row_order){ return $this->show_json(SYS_CODE_FAIL, '参数错误'); @@ -864,23 +865,25 @@ class Orders extends HD_Controller }else{ $jsondata = json_decode($row['jsondata'],true); } - //图片识别 - $img_url = build_qiniu_image_url($file); - $orc_res = $this->tcorc->CarInvoiceInfos($img_url); - if (!$orc_res['code']) { - return $this->show_json(SYS_CODE_FAIL, $orc_res['msg']); - } - $bill_time = date('Y-m-d H:i:s'); - $carinfo = $orc_res['data']['CarInvoiceInfos']; - if(is_array($carinfo)){ - foreach($carinfo as $kye=>$val){ - if($val['Name']=='开票日期'){ - $bill_time = $val['Value']; - break; + if(!$if_usedcar){ + //图片识别 + $img_url = build_qiniu_image_url($file); + $orc_res = $this->tcorc->CarInvoiceInfos($img_url); + if (!$orc_res['code']) { + return $this->show_json(2, $orc_res['msg']); + } + $bill_time = date('Y-m-d H:i:s'); + $carinfo = $orc_res['data']['CarInvoiceInfos']; + if(is_array($carinfo)){ + foreach($carinfo as $kye=>$val){ + if($val['Name']=='开票日期'){ + $bill_time = $val['Value']; + break; + } } } + $jsondata['infos'] = $carinfo; } - $jsondata['infos'] = $carinfo; $update['file'] = $file; $update['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE); $result = $this->order_bills_model->update($update, ['o_id' => $row_order['id']]); @@ -897,7 +900,9 @@ class Orders extends HD_Controller , 'com_time' => $bill_time, 'biz_id' => $re_i['biz_id'], 'addr_id' => $re_i['addr_id']); $this->items_entity->add_log($params); } - $this->receiver_orders_v2_model->update(['bill_time' => $bill_time], ['id' => $row_order['id']]); + $update = ['bill_time'=>$bill_time]; + $if_usedcar && $update['if_usedcar'] = 1; + $this->receiver_orders_v2_model->update($update, ['id' => $row_order['id']]); $this->orders_status_entity->set_status($row_order['id'],3,1); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } else { diff --git a/admin/views/receiver/orderv2/get/index.php b/admin/views/receiver/orderv2/get/index.php index 0d936b55..e2ab3374 100644 --- a/admin/views/receiver/orderv2/get/index.php +++ b/admin/views/receiver/orderv2/get/index.php @@ -663,17 +663,46 @@ , shade: 0.3 , time: false }); - var value = $(obj).val(); var that = this; - $.post("/receiver/orderv2/orders/edit_bill", { - 'id': , - 'value': value, - }, function (data) { + var params = { + 'id':, + 'value': $(obj).val() + } + $.post("/receiver/orderv2/orders/edit_bill", params, function (data) { layer.closeAll() - if (data.code) { + if (data.code==1) { layer.msg(data.msg, {time: 2000, icon: 1}, function () { $.form.reload(); }); + } else if(data.code==2) { + layer.open({ + type: 0, + // title: '标题', + content:data.msg, + btn: ['重新上传','二手车'], + btn1:function(index, layero){ + // 按钮1的逻辑 + layer.closeAll() + }, + btn2:function(index, layero){ + // 按钮2的逻辑 + layer.closeAll() + params['if_usedcar'] = 1 + $.post("/receiver/orderv2/orders/edit_bill", params, function (data) { + layer.closeAll() + if (data.code) { + layer.msg(data.msg, {time: 2000, icon: 1}, function () { + $.form.reload(); + }); + }else{ + layer.msg(data.msg, {icon: 2}); + } + },'json') + }, + cancel: function(){ + // 右上角关闭事件的逻辑 + } + }); } else { layer.msg(data.msg, {icon: 2}); }