From 01406cac41d5cb57bafaf91036d2026ca5e9cb69 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 13 Apr 2022 14:02:26 +0800 Subject: [PATCH] edit-admin-order --- admin/controllers/receiver/orderv2/Orders.php | 11 +++- admin/libraries/Ordersv2List.php | 58 ++++++++++++++---- admin/views/receiver/orderv2/lists.php | 59 +++++++++++++------ api/controllers/plan/Order.php | 45 ++++++++++++++ .../order/Receiver_orders_v2_model.php | 4 +- 5 files changed, 144 insertions(+), 33 deletions(-) diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php index 7b69de1b..afa80a95 100644 --- a/admin/controllers/receiver/orderv2/Orders.php +++ b/admin/controllers/receiver/orderv2/Orders.php @@ -71,7 +71,11 @@ class Orders extends HD_Controller $where_s["{$t2}.status in ({$key2},{$up_key})"] = null; } $where_s = array_merge($where,$where_s); - $count2 = $this->receiver_orders_v2_model->selectOrders($where_s,'','', '', 1); + $having = 'total = 1'; + if($key==0 && $key2==1){ //已付款 + $having = 'total >= 1'; + } + $count2 = $this->receiver_orders_v2_model->selectOrders($where_s,'','', '', 1,'',$having); }else{ $where_s = [ "id not in (select o_id from lc_receiver_order_status where pid_status={$value['pid_status']} and status=1)" => null @@ -721,6 +725,9 @@ class Orders extends HD_Controller $url = http_host_com('api').'/pdfapi/add_pdf?oid='.$row['id']; $pdf_res = file_get_contents($url); } + if($row['order_time'] == '0000-00-00 00:00:00'){ //更新下定时间 + $this->receiver_orders_v2_model->update(['order_time' => date('Y-m-d H:i:s',strtotime($pay_time))], ['id' => $row['id']]); + } return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } @@ -765,7 +772,7 @@ class Orders extends HD_Controller } $re_data = $this->receiver_order_datas_model->get(['o_id'=>$id]); if(!$re_data){ - $re_data_id = $this->eceiver_order_datas_model->add(['c_time'=>time(),'o_id'=>$id]); + $re_data_id = $this->receiver_order_datas_model->add(['c_time'=>time(),'o_id'=>$id]); }else{ $re_data_id = $re_data['id']; } diff --git a/admin/libraries/Ordersv2List.php b/admin/libraries/Ordersv2List.php index 48d2ff8a..d7df9df1 100644 --- a/admin/libraries/Ordersv2List.php +++ b/admin/libraries/Ordersv2List.php @@ -122,6 +122,16 @@ class Ordersv2List $where["{$this->t1}.c_time <="] = strtotime($c_time[1] . ' 23:59:59'); } } + //下定时间 + if ($params['order_time']) { + $order_time = explode(' ~ ', $params['order_time']); + if ($order_time[0]) { + $where["{$this->t1}.order_time >="] = strtotime($order_time[0] . ' 00:00:00'); + } + if ($order_time[1]) { + $where["{$this->t1}.order_time <="] = strtotime($order_time[1] . ' 23:59:59'); + } + } //开票时间 if ($params['bill_time']) { $bill_time = explode(' ~ ', $params['bill_time']); @@ -191,7 +201,8 @@ class Ordersv2List } $fileds = "{$this->t1}.id,{$this->t1}.name,{$this->t1}.mobile,{$this->t1}.brand_id,{$this->t1}.s_id,{$this->t1}.v_id, {$this->t1}.cor_id,{$this->t1}.incor_id,{$this->t1}.money_json,{$this->t1}.payway,{$this->t1}.status,{$this->t1}.c_time, - {$this->t1}.biz_id,{$this->t1}.bill_time,{$this->t1}.customer_id,{$this->t1}.owner_name,{$this->t1}.owner_mobile,{$this->t1}.main_type,{$this->t1}.info_json"; + {$this->t1}.biz_id,{$this->t1}.bill_time,{$this->t1}.customer_id,{$this->t1}.owner_name,{$this->t1}.owner_mobile,{$this->t1}.main_type,{$this->t1}.info_json, + {$this->t1}.order_time,{$this->t1}.bill_time"; if($params['status_pid']==3){ $where["{$this->t1}.id in (select o_id from lc_receiver_order_status where pid_status=0 and status=2)"] = null; } @@ -202,8 +213,12 @@ class Ordersv2List $where["{$this->t2}.pid_status"] = $params['status_pid']; $up_key = $params['status']+1; $where["{$this->t2}.status in ({$params['status']},{$up_key})"] = null; - $count = $this->ci->mdOrders->selectOrders($where,'', '', '', 1); - $rows = $this->ci->mdOrders->selectOrders($where, "c_time desc", $page, $size, '',$fileds); + $having = "total = 1"; + if($params['status_pid']==0 && $params['status']==1){ + $having = "total >= 1"; + } + $count = $this->ci->mdOrders->selectOrders($where,'', '', '', 1,'',$having); + $rows = $this->ci->mdOrders->selectOrders($where, "c_time desc", $page, $size, '',$fileds,$having); }else{ if(strlen($params['status'])){ $where["id not in (select o_id from lc_receiver_order_status where pid_status={$params['status_pid']} and status=1)"] = null; @@ -282,8 +297,13 @@ class Ordersv2List $fields['biz_name'] = $bizs[$val['biz_id']]; $fields['c_time'] = date('Y-m-d H:i:s', $val['c_time']); $fields['cf_title'] = $customers[$val['customer_id']][0]['cf_title']; - $fields['cf_clues'] = $customers[$val['customer_id']][0]['cf_clues']; - $fields['cf_name'] = $cfroms[$customers[$val['customer_id']][0]['cf_id']][0]['title']; + $cf_name = $cfroms[$customers[$val['customer_id']][0]['cf_id']][0]['title']; + $cf_clues = $customers[$val['customer_id']][0]['cf_clues']; + $fields['cf_name'] = ''; + $cf_name && $fields['cf_name'] = $cf_name.'(线上)
'; + $cf_clues && $fields['cf_name'] .= $cf_clues.'(线下)'; + $fields['order_time'] = $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : ''; + $fields['bill_time'] = $val['bill_time'] != '0000-00-00 00:00:00' ? $val['bill_time'] : ''; $lists[] = $fields; } } @@ -311,12 +331,28 @@ class Ordersv2List } else { $fields1['name'] = ['title' => '客户', 'width' => '14%']; } - $fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'], - 'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'], - 'payway_name' => ['title' => '付款方式', 'width' => '8%'], - 'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'], - 'status_name' => ['title' => '状态', 'width' => '9%'], - 'c_time' => ['title' => '订单时间', 'width' => '9%']]; + if(strlen($status_pid) && $status_pid==0){ + $fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'], + 'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'], + 'payway_name' => ['title' => '付款方式', 'width' => '8%'], + 'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'], + 'status_name' => ['title' => '状态', 'width' => '9%'], + 'order_time' => ['title' => '下定时间', 'width' => '9%']]; + }elseif($status_pid==3){ + $fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'], + 'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'], + 'payway_name' => ['title' => '付款方式', 'width' => '8%'], + 'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'], + 'status_name' => ['title' => '状态', 'width' => '9%'], + 'bill_time' => ['title' => '开票时间', 'width' => '9%']]; + }else{ + $fields2 = ['car_name' => ['title' => '车辆', 'width' => '27%'], + 'biz_name' => ['title' => '门店', 'width' => '12%'], 'price' => ['title' => '车辆平台价', 'width' => '9%'], + 'payway_name' => ['title' => '付款方式', 'width' => '8%'], + 'cf_title' => ['title' => '来源类型', 'width' => '9%'], 'cf_name' => ['title' => '来源','width' => '10%'], + 'status_name' => ['title' => '状态', 'width' => '9%'], + 'c_time' => ['title' => '订单时间', 'width' => '9%']]; + } $fields = array_merge($fields1, $fields2); return $fields; } diff --git a/admin/views/receiver/orderv2/lists.php b/admin/views/receiver/orderv2/lists.php index 222fbfb3..e2d4ef39 100644 --- a/admin/views/receiver/orderv2/lists.php +++ b/admin/views/receiver/orderv2/lists.php @@ -218,6 +218,29 @@ + +
+
+ +
+
+ +
+
+
+ + +
+ +
+
+ +
+
+
+
@@ -247,6 +270,10 @@ + + + + - - - - - - - - - - - - - + + + $val) { ?> + + + +
- (线上)
- (线下) -
@@ -293,6 +310,12 @@ laydate.render({ elem: '#id-create-time', range: '~' }); + laydate.render({ + elem: '#order-time', range: '~' + }); + laydate.render({ + elem: '#id-bill-time', range: '~' + }); $('.id-day-btn').click(function () { var type = $(this).data('date'), date = '', d_obj = new Date(); switch (type) { diff --git a/api/controllers/plan/Order.php b/api/controllers/plan/Order.php index 38c62ddf..c505649f 100644 --- a/api/controllers/plan/Order.php +++ b/api/controllers/plan/Order.php @@ -169,4 +169,49 @@ class Order extends CI_Controller{ echo "no data"; } } + + public function up_order_time(){ + $size = $this->input->get('size'); + !$size && $size = 20; + + $t1 = 'lc_receiver_order_status'; + $t2 = 'lc_receiver_orders_v2'; + + $fields = "$t2.*"; + $where = [ + "$t1.pid_status" => 0, + "$t1.status" => 1, + "$t2.id>=" => 10000, + "$t2.order_time" => '0000-00-00 00:00:00', + ]; + + $this->db->from("$t1"); + $this->db->join("$t2", "$t2.id=$t1.o_id",'left'); + + $this->db->select($fields); + $this->db->where($where); + $this->db->order_by("$t1.id asc"); + $this->db->limit($size); + $rows = $this->db->get()->result_array(); + if($rows){ + foreach($rows as $key=>$val){ + $where = [ + 'o_id'=>$val['id'], + 'status'=>1, + "pay_time <>" => '0000-00-00 00:00:00', + ]; + $pay_row = $this->app_liche_orders_model->select($where,'pay_time asc',1,1); + if($pay_row){ + $order_time = $pay_row[0]['pay_time']; + $res = $this->receiver_orders_v2_model->update(['order_time'=>$order_time],['id'=>$val['id']]); + echo "订单id:{$val['id']},更新{$res}
"; + }else{ + echo "订单id:{$val['id']},未找到支付订单
"; + } + } + }else{ + echo "no data"; + } + + } } diff --git a/common/models/receiver/order/Receiver_orders_v2_model.php b/common/models/receiver/order/Receiver_orders_v2_model.php index 0954a72c..edc1011a 100644 --- a/common/models/receiver/order/Receiver_orders_v2_model.php +++ b/common/models/receiver/order/Receiver_orders_v2_model.php @@ -24,7 +24,7 @@ class Receiver_orders_v2_model extends HD_Model return $this->status_arr; } - public function selectOrders($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0,$fileds="lc_receiver_orders_v2.*") + public function selectOrders($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0,$fileds="lc_receiver_orders_v2.*",$having="total=1") { $this->db->select($fileds.",count(lc_receiver_order_status.status) as total"); $this->db->from('lc_receiver_orders_v2'); @@ -33,7 +33,7 @@ class Receiver_orders_v2_model extends HD_Model $this->db->where($where); } $this->db->group_by('lc_receiver_order_status.o_id'); - $this->db->having('total = 1'); + $this->db->having("$having"); if ($count) { $res = $this->db->count_all_results(); return $res ? $res : 0;