From daf0ede906f64e5349b25a0f7b256e6fbb1a7187 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 29 Jul 2021 14:18:22 +0800 Subject: [PATCH] edit-licheb-order --- admin/controllers/receiver/Orders.php | 33 ++------ admin/views/receiver/orders/get_bill.php | 84 ++++--------------- admin/views/receiver/orders/oinfo.php | 2 +- api/controllers/wxapp/licheb/Cusorder.php | 4 + api/controllers/wxapp/licheb/Customerlogs.php | 3 +- api/controllers/wxapp/licheb/Customers.php | 2 +- api/controllers/wxapp/licheb/Sms.php | 8 +- api/controllers/wxapp/licheb/Xz.php | 12 +-- common/libraries/receiver/Orders_entity.php | 28 +++++++ 9 files changed, 69 insertions(+), 107 deletions(-) diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php index 6cb0d725..fae18113 100644 --- a/admin/controllers/receiver/Orders.php +++ b/admin/controllers/receiver/Orders.php @@ -243,7 +243,7 @@ class Orders extends HD_Controller{ ]; $bill['id'] = $this->order_bills_model->add($add_data); } - $bill['file'] = $bill['file'] ? build_qiniu_image_url($bill['file']):''; + $bill['src_file'] = $bill['file'] ? build_qiniu_image_url($bill['file']):''; $this->data['bill'] = $bill; return $this->show_view('receiver/orders/get_bill'); } @@ -251,31 +251,9 @@ class Orders extends HD_Controller{ public function edit_bill(){ $id = $this->input->post('id'); $money = $this->input->post('money'); - $file = $_FILES['file']; - if($file){ //上传文件 - $path = FCPATH.'temp/'; - if (!file_exists($path)){ - $oldumask = umask(0); - mkdir($path, 0777, true); - umask($oldumask); - } - $file_name = md5($file['name'] . uniqid()) . '.'.end(explode('.',$file['name'])); - $tmp = $path.$file_name; - move_uploaded_file($file['tmp_name'], $tmp); - - if (!filesize($tmp)) { - return $this->show_json(SYS_CODE_FAIL, '上传文件失败!'); - } - $this->load->library('qiniu'); - $res= $this->qiniu->save($file_name, file_get_contents($tmp)); - unlink($tmp); - if (!$res) { - return $this->show_json(SYS_CODE_FAIL, '上传文件失败!'); - } - $size = getimagesize($res['url']); - $update['file'] = $res['file']; - } + $file = $this->input->post('file'); $money && $update['money'] = $money; + $file && $update['file'] = $file; $result = $this->order_bills_model->update($update,['id'=>$id]); if($result){ return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); @@ -298,6 +276,9 @@ class Orders extends HD_Controller{ if(!$bill['file'] || !$bill['money']){ return $this->show_json(SYS_CODE_FAIL, '未上传开票文件或未填写到账金额!'); } + if(!$bill['cardidA']){ + return $this->show_json(SYS_CODE_FAIL, '未上传用户身份证!'); + } $result = $this->order_bills_model->update(['status'=>1],['o_id'=>$oid]); $this->orders_model->update(['status'=>4],['id'=>$bill['o_id']]); if(!$this->order_agents_model->get(['o_id'=>$oid])){ @@ -320,7 +301,7 @@ class Orders extends HD_Controller{ $update['if_ins'] = $params['if_ins'] ? 1:0; if($params['bx_imgs']){ $imgs = explode(',',$params['bx_imgs']); - $update['ins_img'] = json_encode($imgs,JSON_UNESCAPED_UNICODE); + $update['bx_imgs'] = json_encode($imgs,JSON_UNESCAPED_UNICODE); } if($agent){ $result = $this->order_agents_model->update($update,['id'=>$agent['id']]); diff --git a/admin/views/receiver/orders/get_bill.php b/admin/views/receiver/orders/get_bill.php index 9d8c7c60..9d1e60cd 100644 --- a/admin/views/receiver/orders/get_bill.php +++ b/admin/views/receiver/orders/get_bill.php @@ -1,5 +1,5 @@
+ style="width: 90%;padding-top: 10px">
@@ -9,81 +9,27 @@
- -
- - - - - 查看文件 - - + + +
+
+ + + + +
- 保存 +
diff --git a/admin/views/receiver/orders/oinfo.php b/admin/views/receiver/orders/oinfo.php index 31904e23..a2ca8905 100644 --- a/admin/views/receiver/orders/oinfo.php +++ b/admin/views/receiver/orders/oinfo.php @@ -86,7 +86,7 @@ 上传文件 - 查看文件 +
diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index 636b4e98..b5046a7e 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -275,6 +275,7 @@ class Cusorder extends Wxapp{ 'carid_a_path' => $bill['cardidA'] ? $bill['cardidA'] : '', 'carid_b' => $bill['cardidB'] ? build_qiniu_image_url($bill['cardidB']) : '', 'carid_b_path' => $bill['cardidB'] ? $bill['cardidB'] : '', + 'bill_img' => $bill['file'] ? build_qiniu_image_url($bill['file']) : '' ]; } $bill_status = $bill['status'] ? 2 : 1; @@ -310,6 +311,9 @@ class Cusorder extends Wxapp{ $result = $this->order_deliverys_model->update(['status'=>2],['id'=>$row['id']]); if($result){ $this->orders_model->update(['status'=>6],['id'=>$row['o_id']]); + //完成支付订单 + $this->load->library('receiver/orders_entity'); + $this->orders_entity->finish_after($row['o_id'],1); throw new Exception('修改成功', API_CODE_SUCCESS); }else{ throw new Exception('修改失败', ERR_PARAMS_ERROR); diff --git a/api/controllers/wxapp/licheb/Customerlogs.php b/api/controllers/wxapp/licheb/Customerlogs.php index ef8b0f80..4eb243ec 100644 --- a/api/controllers/wxapp/licheb/Customerlogs.php +++ b/api/controllers/wxapp/licheb/Customerlogs.php @@ -45,11 +45,12 @@ class Customerlogs extends Wxapp{ if($val['type']==2){ $rec_row = $this->receiver_xz_model->get(['id'=>$val['log']],'rec_url,duration'); $content = '拨打电话'; + !$rec_row['duration'] && $content .= '(未接通)'; $rec_row['rec_url'] && $record = $rec_row['rec_url']; $rec_row['duration'] && $second = intval($rec_row['duration']/1000); } $lists[] = [ - 'content' => $content, + 'content' => "【{$val['uname']}】".$content, 'record_url' => $record, 'second' => $second, 'c_time' => date('Y.m.d',$val['c_time']) diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 9c10897e..7fa7686e 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -146,7 +146,7 @@ class Customers extends Wxapp{ if($result){ $uname = $this->session['uname']; $this->load->library('receiver/customers_entity'); - $this->customers_entity->add_log($result,$this->session['uid'],$uname,"【{$uname}】创建客户"); + $this->customers_entity->add_log($result,$this->session['uid'],$uname,"创建客户"); throw new Exception('创建成功', API_CODE_SUCCESS); }else{ throw new Exception('创建失败', ERR_PARAMS_ERROR); diff --git a/api/controllers/wxapp/licheb/Sms.php b/api/controllers/wxapp/licheb/Sms.php index 1970e677..1fb5597d 100644 --- a/api/controllers/wxapp/licheb/Sms.php +++ b/api/controllers/wxapp/licheb/Sms.php @@ -74,21 +74,23 @@ class Sms extends Wxapp{ //通过订单发短信 protected function post_cusorder(){ $this->load->model('receiver/order/receiver_orders_model','orders_model'); + $this->load->model('receiver/receiver_customers_model','customers_model'); $uid = $this->session['uid']; $id = $this->input_param('id'); $content = $this->input_param('content'); - $row = $this->orders_model->get(['id'=>$id,'admin_id'=>$uid]); + $order = $this->orders_model->get(['id'=>$id,'admin_id'=>$uid]); + $row = $this->customers_model->get(['id'=>$order['rid']]); if(!$row || !$content){ throw new Exception('参数错误', ERR_PARAMS_ERROR); } $mobile = $row['mobile']; $content = '【狸车】'.$content; b2m_send_sms($mobile,$content); - $this->load->library('receiver/orders_entity'); + $this->load->library('receiver/customers_entity'); $log = '发送短信+1'; - $this->orders_entity->add_log($id,$uid,$this->session['uname'],$log,1); + $this->customers_entity->add_log($row['id'],$uid,$this->session['uname'],$log,1); throw new Exception('短信发送成功', API_CODE_SUCCESS); } } diff --git a/api/controllers/wxapp/licheb/Xz.php b/api/controllers/wxapp/licheb/Xz.php index e1bec54f..ded3c83f 100644 --- a/api/controllers/wxapp/licheb/Xz.php +++ b/api/controllers/wxapp/licheb/Xz.php @@ -28,13 +28,13 @@ class Xz extends Wxapp{ !$type && $type = 0; $session = $this->session; $admin_id = $session['uid']; + $cf_title = 'customer'; + $cus_id = $id; if($type==1){ //订单 - $row = $this->orders_model->get(['id'=>$id]); - $cf_title = 'order'; - }else{//客户 - $cf_title = 'customer'; - $row = $this->customers_model->get(['id'=>$id]); + $order = $this->orders_model->get(['id'=>$id]); + $cus_id = $order['rid']; } + $row = $this->customers_model->get(['id'=>$cus_id]); if(!$row || !$row['mobile']){ throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM); } @@ -90,7 +90,7 @@ class Xz extends Wxapp{ $add_data = [ 'call_id' => $seq_id, 'display_number' => $result['data']['virtualMobile'], - 'cf_id' => $id, + 'cf_id' => $cus_id, 'cf_uid' => $admin_id, 'cf_title' => $cf_title, 'cf_platform' => 'api', diff --git a/common/libraries/receiver/Orders_entity.php b/common/libraries/receiver/Orders_entity.php index 9852840a..d4d1e992 100644 --- a/common/libraries/receiver/Orders_entity.php +++ b/common/libraries/receiver/Orders_entity.php @@ -199,6 +199,34 @@ class Orders_entity{ $result = $this->ci->order_oplogs_model->add($add_data); return $result; } + /** + * 确认交车 + * @param $oid int 订单id + * @param $app_id int 小程序id + * return boolean + */ + public function finish_after($oid,$app_id){ + $this->ci->load->model('receiver/order/receiver_orders_model','orders_model'); + $this->ci->load->model('receiver/receiver_customers_model','customers_model'); + $this->ci->load->model('apporder/order_purchase_model'); + $row = $this->ci->orders_model->get(['id'=>$oid]); + if(!$row){ + return false; + } + $customers = $this->ci->customers_model->get(['id'=>$row['rid']],'rid'); + $res = false; + //获取线索生成的支付订单 + $clu_order = $this->ci->order_purchase_model->get(['type'=>3,'status'=>2,'cf_id'=>$customers['rid'],'app_id'=>$app_id]); + if($clu_order){ + $res = $this->ci->order_purchase_model->update(['status'=>3],['id'=>$clu_order['id']]); + } + //获取合同生成的支付订单 + $o_order = $this->ci->order_purchase_model->get(['type'=>4,'status'=>2,'cf_id'=>$row['id'],'app_id'=>$app_id]); + if($o_order){ + $res = $this->ci->order_purchase_model->update(['status'=>3],['id'=>$o_order['id']]); + } + return $res; + } } ?>