From 02b38fd74be4e029d116c79bdf59a3e654bbcbb5 Mon Sep 17 00:00:00 2001
From: lccsw <1127794702@qq.com>
Date: Thu, 30 Dec 2021 17:09:11 +0800
Subject: [PATCH] edit-order-opt
---
admin/controllers/Img.php | 31 +
admin/controllers/Upload.php | 4 +-
admin/controllers/auto/Attr.php | 10 +-
admin/controllers/auto/Business.php | 399 +++++++++
admin/controllers/auto/Cars.php | 20 +-
admin/controllers/auto/Series.php | 6 +-
admin/controllers/biz/Settle.php | 443 ++++++++++
admin/controllers/biz/store/Store.php | 108 ++-
admin/controllers/receiver/orderv2/Orders.php | 827 ++++++++++++++++++
admin/controllers/sys/Company.php | 49 +-
admin/libraries/Ordersv2List.php | 386 ++++++++
admin/views/auto/business/get.php | 300 +++++++
admin/views/auto/business/lists.php | 307 +++++++
admin/views/biz/settle/add.php | 73 ++
admin/views/biz/settle/lists.php | 248 ++++++
admin/views/biz/settle/lists_static.php | 138 +++
admin/views/biz/store/edit.php | 13 +
admin/views/biz/store/get_info.php | 307 +++++++
admin/views/biz/store/lists.php | 6 +
admin/views/img.php | 81 ++
.../views/receiver/orderv2/get/add_paylog.php | 77 ++
.../views/receiver/orderv2/get/agentinfo.php | 175 ++++
admin/views/receiver/orderv2/get/ckinfo.php | 251 ++++++
admin/views/receiver/orderv2/get/get_bill.php | 94 ++
admin/views/receiver/orderv2/get/index.php | 656 ++++++++++++++
admin/views/receiver/orderv2/get/lists.php | 612 +++++++++++++
admin/views/receiver/orderv2/get/loaninfo.php | 106 +++
admin/views/receiver/orderv2/get/oinfo.php | 233 +++++
admin/views/receiver/orderv2/get/paylog.php | 96 ++
admin/views/receiver/orderv2/lists.php | 614 +++++++++++++
admin/views/sys/company/get.php | 22 +-
admin/views/sys/company/lists.php | 4 +
admin/views/uploadpdf.php | 7 +
api/controllers/Pdfapi.php | 9 +-
api/controllers/Welcome.php | 4 +
api/controllers/plan/Biz.php | 159 ++++
api/controllers/plan/Liche.php | 73 ++
api/controllers/plan/Order.php | 101 +++
api/controllers/plan/Plan.php | 3 +-
api/controllers/wxapp/Wxapp.php | 5 +
api/controllers/wxapp/app/Business.php | 79 ++
api/controllers/wxapp/app/Series.php | 13 +-
api/controllers/wxapp/liche/Order.php | 66 +-
api/controllers/wxapp/liche/Pay.php | 106 ++-
api/controllers/wxapp/liche/Protocol.php | 235 ++++-
api/controllers/wxapp/liche/User.php | 19 +-
api/controllers/wxapp/liche/Wxnotify_v3.php | 56 +-
api/controllers/wxapp/licheb/Cusorder.php | 34 +-
api/controllers/wxapp/licheb/CusorderV2.php | 775 ++++++++++++++++
api/controllers/wxapp/licheb/Cusorderdata.php | 192 ++++
api/controllers/wxapp/licheb/Loan.php | 117 +--
api/controllers/wxapp/licheb/Protocol.php | 68 ++
api/controllers/wxapp/licheb/Services.php | 14 +-
api/views/wxapp/licheb/pdf_img.php | 18 +
common/helpers/comm_helper.php | 14 +
common/libraries/Pdftk.php | 131 +++
common/libraries/Qyrobot.php | 86 ++
.../libraries/receiver/Order_datas_entity.php | 108 +++
.../receiver/Orders_status_entity.php | 105 +++
.../libraries/receiver/Orders_v2_entity.php | 633 ++++++++++++++
common/libraries/receiver/Sign_entity.php | 42 +-
common/models/app/App_checkdata_model.php | 19 +
.../app/liche/App_liche_orders_model.php | 2 +-
common/models/auto/Auto_business_model.php | 25 +
common/models/auto/Auto_cars_model.php | 4 +-
common/models/auto/Auto_series_model.php | 4 +-
common/models/biz/Biz_info_model.php | 13 +
common/models/biz/Biz_settle_model.php | 38 +
common/models/biz/Biz_settle_static_model.php | 22 +
common/models/biz/Biz_trucking_model.php | 13 +
.../order/Receiver_order_contracts_model.php | 6 +-
.../order/Receiver_order_datas_model.php | 48 +
.../order/Receiver_order_status_model.php | 65 ++
.../order/Receiver_orders_v2_model.php | 54 ++
common/models/sys/Sys_company_model.php | 9 +
common/services/apporder/Payment_service.php | 265 +++---
common/third_party/esign/comm/initConfig.php | 6 +-
sql/app/app.sql | 20 +
sql/app/liche.sql | 49 +-
sql/biz.sql | 3 +-
sql/receiver/order.sql | 2 +-
sql/sys.sql | 2 +
www/api/pdf/agent_tpl.pdf | Bin 0 -> 200848 bytes
www/api/pdf/car_tpl.pdf | Bin 0 -> 372630 bytes
www/api/pdf/ck_tpl.pdf | Bin 0 -> 115519 bytes
85 files changed, 10346 insertions(+), 291 deletions(-)
create mode 100644 admin/controllers/Img.php
create mode 100644 admin/controllers/auto/Business.php
create mode 100644 admin/controllers/biz/Settle.php
create mode 100644 admin/controllers/receiver/orderv2/Orders.php
create mode 100644 admin/libraries/Ordersv2List.php
create mode 100644 admin/views/auto/business/get.php
create mode 100644 admin/views/auto/business/lists.php
create mode 100644 admin/views/biz/settle/add.php
create mode 100644 admin/views/biz/settle/lists.php
create mode 100644 admin/views/biz/settle/lists_static.php
create mode 100644 admin/views/biz/store/get_info.php
create mode 100644 admin/views/img.php
create mode 100644 admin/views/receiver/orderv2/get/add_paylog.php
create mode 100644 admin/views/receiver/orderv2/get/agentinfo.php
create mode 100644 admin/views/receiver/orderv2/get/ckinfo.php
create mode 100644 admin/views/receiver/orderv2/get/get_bill.php
create mode 100644 admin/views/receiver/orderv2/get/index.php
create mode 100644 admin/views/receiver/orderv2/get/lists.php
create mode 100644 admin/views/receiver/orderv2/get/loaninfo.php
create mode 100644 admin/views/receiver/orderv2/get/oinfo.php
create mode 100644 admin/views/receiver/orderv2/get/paylog.php
create mode 100644 admin/views/receiver/orderv2/lists.php
create mode 100644 api/controllers/plan/Biz.php
create mode 100644 api/controllers/plan/Liche.php
create mode 100644 api/controllers/plan/Order.php
create mode 100644 api/controllers/wxapp/app/Business.php
create mode 100644 api/controllers/wxapp/licheb/CusorderV2.php
create mode 100644 api/controllers/wxapp/licheb/Cusorderdata.php
create mode 100644 api/views/wxapp/licheb/pdf_img.php
create mode 100644 common/libraries/Pdftk.php
create mode 100644 common/libraries/receiver/Order_datas_entity.php
create mode 100644 common/libraries/receiver/Orders_status_entity.php
create mode 100644 common/libraries/receiver/Orders_v2_entity.php
create mode 100644 common/models/app/App_checkdata_model.php
create mode 100644 common/models/auto/Auto_business_model.php
create mode 100644 common/models/biz/Biz_info_model.php
create mode 100644 common/models/biz/Biz_settle_model.php
create mode 100644 common/models/biz/Biz_settle_static_model.php
create mode 100644 common/models/biz/Biz_trucking_model.php
create mode 100644 common/models/receiver/order/Receiver_order_datas_model.php
create mode 100644 common/models/receiver/order/Receiver_order_status_model.php
create mode 100644 common/models/receiver/order/Receiver_orders_v2_model.php
create mode 100644 www/api/pdf/agent_tpl.pdf
create mode 100644 www/api/pdf/car_tpl.pdf
create mode 100644 www/api/pdf/ck_tpl.pdf
diff --git a/admin/controllers/Img.php b/admin/controllers/Img.php
new file mode 100644
index 00000000..ae257e2e
--- /dev/null
+++ b/admin/controllers/Img.php
@@ -0,0 +1,31 @@
+input->get('imgs');
+ $arr_imgs = explode(',',base64_decode($b64_imgs));
+ $lists = [];
+ if($arr_imgs){
+ foreach ($arr_imgs as $item) {
+ $lists[] = [
+ 'alt' => '',
+ 'pid' => '',
+ 'src' => build_qiniu_image_url($item),
+ 'thumb' => build_qiniu_image_url($item)
+ ];
+ }
+ }
+ $data['lists'] = $lists;
+ $data['_title'] = '大图';
+ return $this->load->view('img', $data);
+ }
+
+ public function imgs(){
+ $data = '/liche/0f48c61017285abc0cff63f59ea5a25f.jpg,/liche/be842659e04f9b5b7bf3f9ab1459c611.jpg';
+ echo base64_encode($data);
+ }
+}
diff --git a/admin/controllers/Upload.php b/admin/controllers/Upload.php
index 35e5f81a..386d4c98 100755
--- a/admin/controllers/Upload.php
+++ b/admin/controllers/Upload.php
@@ -47,12 +47,14 @@ class Upload extends CI_Controller
$types = $this->input->get('type');
$uptype = $this->input->get('uptype');
$source = $this->input->get('source');
+ $field = $this->input->get('field');
$data['mode'] = $mode ? $mode : '1';
$data['types'] = $types;
$data['uptype'] = $uptype ? $uptype : 'qiniu';
$data['mimes'] = $this->file_mime($data['types']);
$data['source'] = $source ? $source : '';
+ $data['field'] = $field ? $field : 'file';
$this->load->view('uploadpdf', $data);
}
@@ -145,4 +147,4 @@ class Upload extends CI_Controller
return join(',', array_unique($mime));
}
-}
\ No newline at end of file
+}
diff --git a/admin/controllers/auto/Attr.php b/admin/controllers/auto/Attr.php
index 915a7ff8..c00a2387 100644
--- a/admin/controllers/auto/Attr.php
+++ b/admin/controllers/auto/Attr.php
@@ -169,11 +169,11 @@ class Attr extends HD_Controller{
* @return bool
*/
function json_lists(){
- $s_id = $this->input->post('s_id');
- $status = $this->input->post('status');
- $type = $this->input->post('type');
- $page = $this->input->post('page');
- $size = $this->input->post('size');
+ $s_id = $this->input->get_post('s_id');
+ $status = $this->input->get_post('status');
+ $type = $this->input->get_post('type');
+ $page = $this->input->get_post('page');
+ $size = $this->input->get_post('size');
$where = array();
$s_id && $where['s_id'] = $s_id;
diff --git a/admin/controllers/auto/Business.php b/admin/controllers/auto/Business.php
new file mode 100644
index 00000000..dc095a2f
--- /dev/null
+++ b/admin/controllers/auto/Business.php
@@ -0,0 +1,399 @@
+load->model('auto/auto_brand_model');
+ $this->load->model('auto/auto_series_model');
+ $this->load->model('auto/auto_attr_model');
+ $this->load->model('auto/auto_cars_model');
+ $this->load->model('auto/auto_business_model');
+ }
+
+ public function index()
+ {
+ $params = $this->input->get();
+
+ $where = array();
+ if($params['brand_id']){
+ $where['brand_id'] = $params['brand_id'];
+ } else{
+ $params['brand_id'] = '';
+ }
+
+ if($params['s_id']){
+ $where['s_id'] = $params['s_id'];
+ } else{
+ $params['s_id'] = '';
+ }
+ if($params['v_id']){
+ $where['v_id'] = $params['v_id'];
+ } else{
+ $params['V_id'] = '';
+ }
+ if(strlen($params['status']) > 0){
+ $where['status'] = $params['status'];
+ } else {
+ $params['status'] = '';
+ }
+ if($params['city_id']){
+ $where['city_id'] = $params['city_id'];
+ } else{
+ $params['city_id'] = '';
+ }
+ if($params['year']){
+ $where['year'] = $params['year'];
+ }elseif(!isset($params['year'])){
+ $where['year'] = $params['year'] = date('Y');
+ }
+ if($params['month']){
+ $where['month'] = $params['month'];
+ }elseif(!isset($params['month'])){
+ $where['month'] = $params['month'] = intval(date('m'));
+ }
+ $page = $params['page'];
+ $page = !$page ? 1 : $page;
+ $size = $params['size'];
+ $size = !$size ? 20 : $size;
+
+ //获取品牌map
+ $where_brand = array('status > -1' => null);
+ $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name');
+ //状态
+ $statusAry = array('0' => '关闭', '1' => '开启');
+
+ $total = $this->auto_business_model->count($where);
+ $lists = array();
+ if($total){
+ $orderby = 'id desc';
+ $select = '*';
+ $rows = $this->auto_business_model->select($where, $orderby, $page, $size, $select);
+ if($rows){
+ $s_ids = array_unique(array_column($rows,'s_id'));
+ $attr_ids = array_unique(array_column($rows,'v_id'));
+ $city_ids = array_unique(array_column($rows,'city_id'));
+ //获取车系列表
+ $map_sery = array();
+ if($s_ids){
+ $str_ids = implode(',', $s_ids);
+ $where_sery = array("id in ({$str_ids})" => null);
+ $map_sery = $this->auto_series_model->map('id', 'name', $where_sery, 'id desc', 0, 0, 'id,name');
+ }
+ $map_attr = array();
+ if($attr_ids){
+ $str_ids = implode(',', $attr_ids);
+ $where_attr = array("id in ({$str_ids})" => null);
+ $map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title, type');
+ }
+ if($city_ids){
+ $str_ids = implode(',', $city_ids);
+ $where_city = array("city_id in ({$str_ids})" => null);
+ $map_city = $this->sys_city_model->map('city_id', 'name', $where_city, 'id desc', 0 , 0, 'city_id, name');
+ }
+ //属性按'车型-车身颜色-内饰颜色'排序
+ foreach($rows as $v){
+ $title = "{$map_brand[$v['brand_id']]} {$map_sery[$v['s_id']]} {$map_attr[$v['v_id']]}";
+ $city_cn = $map_city[$v['city_id']];
+ $month = date('Y-m',strtotime("{$v['year']}-{$v['month']}"));
+ $lists[] = array(
+ 'id' => $v['id'],
+ 'title' => $title,
+ 'status' => $v['status'],
+ 'price_car' => $v['price_car'] > 0 ? $v['price_car'] : '0.00',
+ 'price_floor' => $v['price_floor'] > 0 ? $v['price_floor'] : '0.00',
+ 'price_coplus' => $v['price_coplus'] > 0 ? $v['price_coplus'] : '0.00',
+ 'price_color' => $v['price_color'] > 0 ? $v['price_color'] : '0.00',
+ 'profix_car' => $v['profix_car'],
+ 'profix_insure' => $v['profix_insure'],
+ 'profix_carno' => $v['profix_carno'],
+ 'profix_loan' => $v['profix_loan'],
+ 'city_cn'=> $city_cn,
+ 'month' => $month,
+ 's_effect_time' => $v['s_effect_time'] ? date('Y-m-d',$v['s_effect_time']) : '',
+ 'effect_status' => $v['if_effect'] ? '生效中' : '未生效',
+ );
+ }
+ }
+ }
+
+ $this->data['params'] = $params;
+ $this->data['lists'] = $lists;
+ $this->data['statusAry'] = $statusAry;
+ $this->data['brandAry'] = $map_brand;
+ $this->data['cityAry'] = $this->sys_city_model->select(['status'=>1],'id desc',0,0,'city_id,name');
+ $this->data['yearAry'] = $this->auto_business_model->year();
+ $this->data['monthAry'] = $this->auto_business_model->month();
+ $this->data['_title'] = '商务政策管理';
+ $this->show_view('auto/business/lists',true);
+ }
+
+ public function lists()
+ {
+ // TODO: Implement lists() method.
+ }
+
+ public function get()
+ {
+ $id = $this->input->get('id');
+ $map_brand = $this->auto_brand_model->map('id', 'name', ['status>'=>-1], 'id desc', 0 , 0, 'id, name');
+ $city_rows = $this->sys_city_model->select(['status'=>1],'id desc',0,0,'city_id,name');
+ $row = $this->auto_business_model->get(['id'=>$id]);
+ if($id && $row){
+ $info = [
+ 'id' => $row['id'],
+ 'city_id' => $row['city_id'],
+ 'brand_id' => $row['brand_id'],
+ 's_id' => $row['s_id'],
+ 'v_id' => $row['v_id'],
+ 'price_car' => $row['price_car'],
+ 'price_floor' => $row['price_floor'],
+ 'price_color' => $row['price_color'],
+ 'price_coplus' => $row['price_coplus'],
+ 'profix_car' => $row['profix_car'],
+ 'profix_carno' => $row['profix_carno'],
+ 'profix_insure' => $row['profix_insure'],
+ 'profix_loan' => $row['profix_loan'],
+ 'delivery_day' => $row['delivery_day'],
+ 'date' => date('Y-m',strtotime("{$row['year']}-{$row['month']}")),
+ 'year' => $row['year'],
+ 'month' => intval($row['month']),
+ 'colors' => json_decode($row['colors'],true),
+ 's_effect_time' => $row['s_effect_time'] ? date('Y-m-d',$row['s_effect_time']) : '',
+ 'action' => 'auto/business/edit',
+ ];
+ if($this->input->get('type')=='copy'){ //复制
+ $info['month'] = intval(date('m'));
+ $info['action'] = 'auto/business/add';
+ $info['s_effect_time'] = date('Y-m-d');
+ }
+ }else{
+ $info = [
+ 'city_id' => '',
+ 'brand_id' => '',
+ 's_id' => '',
+ 'v_id' => '',
+ 'price_car' => 0.00,
+ 'price_floor' => 0.00,
+ 'price_color' => 0.00,
+ 'price_coplus' => 0.00,
+ 'profix_car' => 0.00,
+ 'profix_carno' => 0.00,
+ 'profix_insure' => 0.00,
+ 'profix_loan' => 0.00,
+ 'delivery_day' => 0,
+ 'action' => 'auto/business/add',
+ 'year' => date('Y'),
+ 'month' => intval(date('m')),
+ 's_effect_time' => date('Y-m-d'),
+ 'colors' => []
+ ];
+ }
+ $this->data['info'] = $info;
+ $this->data['brandAry'] = $map_brand;
+ $this->data['city_rows'] = $city_rows;
+ $this->data['yearAry'] = $this->auto_business_model->year();
+ $this->data['monthAry'] = $this->auto_business_model->month();
+ $this->data['_title'] = '添加';
+ $this->show_view('auto/business/get');
+ }
+
+ public function add()
+ {
+ $info = $this->input->post('info');
+ $res = $this->valid_data($info);
+ if(!$res['code']){
+ return $this->show_json(SYS_CODE_FAIL,$res['msg']);
+ }
+ $year = $info['year'];
+ $month = intval($info['month']);
+ $where = [
+ 'brand_id' => $info['brand_id'],
+ 's_id' => $info['s_id'],
+ 'v_id' => $info['v_id'],
+ 'city_id' => $info['city_id'],
+ 'year' => $year,
+ 'month' => $month,
+ 'status>='=>0
+ ];
+ if($this->auto_business_model->get($where)){
+ return ['code'=>0,'msg'=>'数据已存在'];
+ }
+ $data = [
+ 'brand_id' => $info['brand_id'],
+ 's_id' => $info['s_id'],
+ 'v_id' => $info['v_id'],
+ 'city_id' => $info['city_id'],
+ 'year' => $year,
+ 'month' => $month,
+ 'status' => 1,
+ 'c_time' => time()
+ ];
+ $info['price_car'] && $data['price_car'] = $info['price_car'];
+ $info['price_floor'] && $data['price_floor'] = $info['price_floor'];
+ $info['price_coplus'] && $data['price_coplus'] = $info['price_coplus'];
+ $info['price_color'] && $data['price_color'] = $info['price_color'];
+ $info['profix_car'] && $data['profix_car'] = $info['profix_car'];
+ $info['profix_carno'] && $data['profix_carno'] = $info['profix_carno'];
+ $info['profix_insure'] && $data['profix_insure'] = $info['profix_insure'];
+ $info['profix_loan'] && $data['profix_loan'] = $info['profix_loan'];
+ $info['colors'] && $data['colors'] = json_encode($info['colors'],JSON_UNESCAPED_UNICODE);
+ $info['s_effect_time'] && $data['s_effect_time'] = strtotime($info['s_effect_time']);
+ $info['delivery_day'] && $data['delivery_day'] = $info['delivery_day'];
+ if(time()>$data['s_effect_time']){
+ $data['if_effect'] = 1;
+ }
+ $this->auto_business_model->add($data);
+ return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
+ }
+
+ public function edit()
+ {
+ $info = $this->input->post('info');
+ if(!$this->auto_business_model->get(['id'=>$info['id']])){
+ return $this->show_json(SYS_CODE_FAIL,'参数错误');
+ }
+ $res = $this->valid_data($info);
+ if(!$res['code']){
+ return $this->show_json(SYS_CODE_FAIL,$res['msg']);
+ }
+ $year = $info['year'];
+ $month = intval($info['month']);
+ $where = [
+ 'brand_id' => $info['brand_id'],
+ 's_id' => $info['s_id'],
+ 'v_id' => $info['v_id'],
+ 'city_id' => $info['city_id'],
+ 'year' => $year,
+ 'month' => $month,
+ 'status>='=>0,
+ 'id !=' => $info['id']
+ ];
+ if($this->auto_business_model->get($where)){
+ return ['code'=>0,'msg'=>'数据已存在'];
+ }
+ $data = [
+ 'city_id' => $info['city_id'],
+ 'brand_id' => $info['brand_id'],
+ 's_id' => $info['s_id'],
+ 'v_id' => $info['v_id'],
+ 'year' => $year,
+ 'month' => $month,
+ ];
+ $info['price_car'] && $data['price_car'] = $info['price_car'];
+ $info['price_floor'] && $data['price_floor'] = $info['price_floor'];
+ $info['price_coplus'] && $data['price_coplus'] = $info['price_coplus'];
+ $info['price_color'] && $data['price_color'] = $info['price_color'];
+ $info['profix_car'] && $data['profix_car'] = $info['profix_car'];
+ $info['profix_carno'] && $data['profix_carno'] = $info['profix_carno'];
+ $info['profix_insure'] && $data['profix_insure'] = $info['profix_insure'];
+ $info['profix_loan'] && $data['profix_loan'] = $info['profix_loan'];
+ $info['colors'] && $data['colors'] = json_encode($info['colors'],JSON_UNESCAPED_UNICODE);
+ $info['s_effect_time'] && $data['s_effect_time'] = strtotime($info['s_effect_time']);
+ $info['delivery_day'] && $data['delivery_day'] = $info['delivery_day'];
+ if(time()>$data['s_effect_time']){
+ $data['if_effect'] = 1;
+ }
+ $this->auto_business_model->update($data,['id'=>$info['id']]);
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ public function del()
+ {
+ // TODO: Implement del() method.
+ }
+
+ public function batch()
+ {
+ // TODO: Implement batch() method.
+ }
+
+ public function export()
+ {
+ // TODO: Implement export() method.
+ }
+ function edit_status(){
+ $id = $this->input->post('id');
+ $field = $this->input->post('field');
+ $value = $this->input->post('value');
+ $status = $this->input->post('status');
+
+ if('status' == $field){
+ $status = $value;
+ }
+
+ $upd = array('status' => $status);
+
+ if(is_numeric($id)){
+ $where = array('id' => $id);
+ } else {
+ $where = array("id in ({$id})" => null);
+ }
+
+ $ret = $this->auto_business_model->update($upd, $where);
+ if(!$ret){
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ function add_copy(){
+ $id = $this->input->post('id');
+ $row = $this->auto_business_model->get(['id'=>$id]);
+ if(!$row){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ $year = date('Y');
+ $month = date('m');
+ $where = [
+ 'brand_id' => $row['brand_id'],
+ 's_id' => $row['s_id'],
+ 'v_id' => $row['v_id'],
+ 'city_id' => $row['city_id'],
+ 'year' => $year,
+ 'month' => $month,
+ 'status>='=>0
+ ];
+ if($this->auto_business_model->get($where)){
+ return $this->show_json(SYS_CODE_FAIL, '本月该数据已存在');
+ }
+ $data = [
+ 'city_id' => $row['city_id'],
+ 'brand_id' => $row['brand_id'],
+ 's_id' => $row['s_id'],
+ 'v_id' => $row['v_id'],
+ 'year' => $year,
+ 'month' => $month,
+ 'status' => 1,
+ 'c_time' => time()
+ ];
+ $row['price_car'] && $data['price_car'] = $row['price_car'];
+ $row['price_floor'] && $data['price_floor'] = $row['price_floor'];
+ $row['price_coplus'] && $data['price_coplus'] = $row['price_coplus'];
+ $row['price_color'] && $data['price_color'] = $row['price_color'];
+ $this->auto_business_model->add($data);
+ return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
+ }
+ private function valid_data($info){
+ if(!$info['brand_id']){
+ return ['code'=>0,'msg'=>'请选择品牌'];
+ }
+ if(!$info['s_id']){
+ return ['code'=>0,'msg'=>'请选择车系'];
+ }
+ if(!$info['v_id']){
+ return ['code'=>0,'msg'=>'请选择车型'];
+ }
+ if(!$info['city_id']){
+ return ['code'=>0,'msg'=>'请选择城市'];
+ }
+ return ['code'=>1,'msg'=>'验证成功'];
+ }
+}
diff --git a/admin/controllers/auto/Cars.php b/admin/controllers/auto/Cars.php
index 972eb05d..6c952448 100644
--- a/admin/controllers/auto/Cars.php
+++ b/admin/controllers/auto/Cars.php
@@ -325,11 +325,11 @@ class Cars extends HD_Controller{
* @return bool
*/
function json_get(){
- $brand_id = $this->input->post('brand_id');
- $s_id = $this->input->post('s_id');
- $v_id = $this->input->post('v_id');
- $cor_id = $this->input->post('cor_id');
- $incor_id = $this->input->post('incor_id');
+ $brand_id = $this->input->get_post('brand_id');
+ $s_id = $this->input->get_post('s_id');
+ $v_id = $this->input->get_post('v_id');
+ $cor_id = $this->input->get_post('cor_id');
+ $incor_id = $this->input->get_post('incor_id');
$where = array(
'status' => 1,
@@ -339,12 +339,12 @@ class Cars extends HD_Controller{
);
$row = $this->auto_cars_model->get($where);
- $data = array(
- 'id' => $row['id'],
- 'price_car' => $row['price_car']
- );
+// $data = array(
+// 'id' => $row['id'],
+// 'price_car' => $row['price_car']
+// );
- $this->data = $data;
+ $this->data = $row;
return $this->show_json(SYS_CODE_SUCCESS);
}
diff --git a/admin/controllers/auto/Series.php b/admin/controllers/auto/Series.php
index 5b60bc21..670617ec 100644
--- a/admin/controllers/auto/Series.php
+++ b/admin/controllers/auto/Series.php
@@ -66,9 +66,9 @@ class Series extends HD_Controller{
* @return bool
*/
public function json_lists(){
- $brand_id = $this->input->post('brand_id');
- $page = $this->input->post('page');
- $size = $this->input->post('size');
+ $brand_id = $this->input->get_post('brand_id');
+ $page = $this->input->get_post('page');
+ $size = $this->input->get_post('size');
$where = array('status > -1' => null);
$brand_id && $where['brand_id'] = $brand_id;
diff --git a/admin/controllers/biz/Settle.php b/admin/controllers/biz/Settle.php
new file mode 100644
index 00000000..dd218a1a
--- /dev/null
+++ b/admin/controllers/biz/Settle.php
@@ -0,0 +1,443 @@
+ ['liche' => 0.25 , 'partner' => 0.75],
+ 2 => ['liche' => 0.35 , 'partner' => 0.65],
+ ];
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->load->model('auto/auto_brand_model');
+ $this->load->model('auto/auto_series_model');
+ $this->load->model('auto/auto_attr_model');
+ $this->load->model('auto/auto_business_model');
+
+ $this->load->model('items/items_model');
+
+ $this->load->model('biz/biz_model');
+ $this->load->model('biz/biz_settle_model');
+ $this->load->model('biz/biz_settle_static_model');
+ $this->load->model('biz/biz_info_model');
+ }
+
+ public function index()
+ {
+ $this->lists();
+ }
+
+ public function lists()
+ {
+ $params = $this->input->get();
+
+ $where = array();
+ $t1 = 'lc_biz_settle';
+ $t2 = 'lc_receiver_orders_v2';
+
+ if($params['biz_id']){
+ $where["$t1.biz_id"] = $params['biz_id'];
+ } else{
+ $params['biz_id'] = '';
+ }
+
+ if($params['brand_id']){
+ $where["$t2.brand_id"] = $params['brand_id'];
+ } else{
+ $params['brand_id'] = '';
+ }
+
+ if($params['s_id']){
+ $where["$t2.s_id"] = $params['s_id'];
+ } else{
+ $params['s_id'] = '';
+ }
+ if($params['v_id']){
+ $where["$t2.v_id"] = $params['v_id'];
+ } else{
+ $params['v_id'] = '';
+ }
+ if($params['year']){
+ $where['year'] = $params['year'];
+ }elseif(!isset($params['year'])){
+ $where['year'] = $params['year'] = date('Y');
+ }
+ if($params['month']){
+ $where['month'] = $params['month'];
+ }elseif(!isset($params['month'])){
+ $where['month'] = $params['month'] = intval(date('m'));
+ }
+ $page = $params['page'];
+ $page = !$page ? 1 : $page;
+ $size = $params['size'];
+ $size = !$size ? 20 : $size;
+
+ //获取品牌map
+ $where_brand = array('status > -1' => null);
+ $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name');
+
+ $total = $this->biz_settle_model->selectOrders($where, '', '', '',1);
+ $lists = array();
+ if($total){
+ $orderby = "$t1.id desc";
+ $select = "$t1.*,$t2.sid,$t2.name,$t2.mobile,$t2.s_id,$t2.v_id,$t2.brand_id,$t2.cor_id,$t2.item_id";
+ $rows = $this->biz_settle_model->selectOrders($where, $orderby, $page, $size,0, $select);
+ if($rows){
+ $s_ids = array_unique(array_filter(array_column($rows,'s_id')));
+ $cor_ids = array_unique(array_filter(array_column($rows,'cor_id')));
+ $v_ids = array_unique(array_filter(array_column($rows,'v_id')));
+ $attr_ids = array_merge($cor_ids,$v_ids);
+ $item_ids = array_unique(array_filter(array_column($rows,'item_id')));
+ //获取车系列表
+ $map_sery = array();
+ if($s_ids){
+ $str_ids = implode(',', $s_ids);
+ $where_sery = array("id in ({$str_ids})" => null);
+ $map_sery = $this->auto_series_model->map('id', 'name', $where_sery, 'id desc', 0, 0, 'id,name');
+ }
+ $map_attr = array();
+ if($attr_ids){
+ $str_ids = implode(',', $attr_ids);
+ $where_attr = array("id in ({$str_ids})" => null);
+ $map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title, type');
+ }
+ $biz_ids = array_unique(array_column($rows,'biz_id'));
+ $map_biz = [];
+ if($biz_ids){
+ $biz_ids = implode(',',array_filter($biz_ids));
+ $where_biz = ["id in ({$biz_ids})" => null];
+ $map_biz = $this->biz_model->map('id', 'biz_name', $where_biz, '', 0, 0, 'id,biz_name');
+ }
+ $map_item = [];
+ if($item_ids){
+ $str_item_ids = implode(',',$item_ids);
+ $where_item = ["id in ({$str_item_ids})" => null];
+ $map_item = $this->items_model->map('id', 'vin', $where_item, '', 0, 0, 'id,vin');
+ }
+ foreach($rows as $v){
+ $title = "{$map_brand[$v['brand_id']]} {$map_sery[$v['s_id']]} {$map_attr[$v['v_id']]} {$map_attr[$v['cor_id']]}";
+ $month = date('Y-m',strtotime("{$v['year']}-{$v['month']}"));
+ $lists[] = array(
+ 'id' => $v['id'],
+ 'o_id' => $v['o_id'],
+ 'title' => $title,
+ 'biz_name' => $map_biz[$v['biz_id']],
+ 'profix_car' => $v['profix_car'],
+ 'profix_insure' => $v['profix_insure'],
+ 'profix_carno' => $v['profix_carno'],
+ 'profix_loan' => $v['profix_loan'],
+ 'price_trucking' => $v['price_trucking'],
+ 'name' => $v['name'],
+ 'mobile' => $v['mobile'],
+ 'sid' => $v['sid'],
+ 'month' => $month,
+ 'vin' => $map_item[$v['item_id']]
+ );
+ }
+ }
+ }
+
+ $this->data['params'] = $params;
+ $this->data['lists'] = $lists;
+ $this->data['brandAry'] = $map_brand;
+ $this->data['yearAry'] = $this->auto_business_model->year();
+ $this->data['monthAry'] = $this->auto_business_model->month();
+ $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page,'totle'=>$total);
+ $this->data['_title'] = '商家结算管理';
+ $this->show_view('biz/settle/lists',true);
+ }
+
+ public function get(){
+ }
+
+ public function add(){
+
+ }
+
+ public function edit()
+ {
+ }
+
+ public function del()
+ {
+ }
+
+ public function batch()
+ {
+
+ }
+
+ public function export()
+ {
+ $biz_id = $this->input->get('id');
+ $month = $this->input->get('month');
+ $year = date('Y');
+ !$month && $month = intval(date('m'));
+ $where = [
+ 'biz_id' => $biz_id,
+ 'year' => $year,
+ 'month' => $month
+ ];
+ $type_arr = $this->biz_settle_static_model->other_price_type();
+ $biz = $this->biz_model->get(['id'=>$biz_id],'biz_name');
+ $row = $this->biz_settle_static_model->get($where);
+ $sheet_data = [];
+ if($row){
+ $sheet_data[] = [
+ '门店','单车总毛利','税后单车总毛利','水平业务总毛利',
+ '店面租金','水电费','店长工资','店员工资',
+ '抽成','拖车费','其它费用','总利润',
+ '狸车分润','合伙人分润','时间'];
+ $row['month_str'] = date('Y-m',strtotime("{$row['year']}-{$row['month']}"));
+ $row['total_need'] = $row['rent'] + $row['wat_ele'] + $row['manager_wage'] + $row['employee_wage'] + $row['commission'] + $row['price_trucking'];
+ $row['price_ml'] = $row['price_total'] - $row['total_need'];
+ $other_price = '';
+ $other_json = json_decode($row['price_other'],true);
+ if($other_json){
+ foreach($other_json as $key=>$val){
+ $type_cn = $type_arr[$val['type']];
+ $other_price .= $val['name'].$val['money']."({$type_cn})\n";
+ }
+ }
+ $sheet_data[] = [
+ $biz['biz_name'],
+ $row['profix_car'],
+ $row['profix_car_after'],
+ $row['price_all'],
+ $row['rent'],
+ $row['wat_ele'],
+ $row['manager_wage'],
+ $row['employee_wage'],
+ $row['commission'],
+ $row['price_trucking'],
+ $other_price,
+ $row['price_ml'],
+ $row['profix_liche'],
+ $row['profix_partner'],
+ $row['month_str']
+ ];
+ }
+ $t1 = 'lc_biz_settle';
+ $t2 = 'lc_receiver_orders_v2';
+ $where = [
+ "{$t1}.biz_id" => $biz_id,
+ "{$t1}.year" => $year,
+ "{$t1}.month" => $month
+ ];
+ $orderby = "$t1.id desc";
+ $select = "$t1.*,$t2.sid,$t2.name,$t2.mobile,$t2.s_id,$t2.v_id,$t2.brand_id,$t2.cor_id,$t2.item_id";
+ $all_rows = $this->biz_settle_model->selectOrders($where, $orderby, 0, 0,0, $select);
+ $sheet_data2 = [];
+ if($all_rows){
+ $sheet_data2[] = ['门店','订单信息','品牌车型','车架号','单车利润','保险利润','贷款利润','挂牌利润','拖车费','时间'];
+ $s_ids = array_unique(array_filter(array_column($all_rows,'s_id')));
+ $cor_ids = array_unique(array_filter(array_column($all_rows,'cor_id')));
+ $v_ids = array_unique(array_filter(array_column($all_rows,'v_id')));
+ $attr_ids = array_merge($cor_ids,$v_ids);
+ $item_ids = array_unique(array_filter(array_column($all_rows,'item_id')));
+ //获取车系列表
+ $map_sery = array();
+ if($s_ids){
+ $str_ids = implode(',', $s_ids);
+ $where_sery = array("id in ({$str_ids})" => null);
+ $map_sery = $this->auto_series_model->map('id', 'name', $where_sery, 'id desc', 0, 0, 'id,name');
+ }
+ $map_attr = array();
+ if($attr_ids){
+ $str_ids = implode(',', $attr_ids);
+ $where_attr = array("id in ({$str_ids})" => null);
+ $map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title, type');
+ }
+ $map_item = [];
+ if($item_ids){
+ $str_item_ids = implode(',',$item_ids);
+ $where_item = ["id in ({$str_item_ids})" => null];
+ $map_item = $this->items_model->map('id', 'vin', $where_item, '', 0, 0, 'id,vin');
+ }
+ foreach($all_rows as $v){
+ $title = "{$map_brand[$v['brand_id']]} {$map_sery[$v['s_id']]} {$map_attr[$v['v_id']]} {$map_attr[$v['cor_id']]}";
+ $vin = $map_item[$v['item_id']];
+ $month_str = date('Y-m',strtotime("{$v['year']}-{$v['month']}"));
+ $sheet_data2[] = array(
+ $biz['biz_name'],
+ "{$v['name']} {$v['mobile']}",
+ $title,
+ $vin,
+ $v['profix_car'],
+ $v['profix_insure'],
+ $v['profix_loan'],
+ $v['profix_carno'],
+ $v['price_trucking'],
+ $month_str,
+ );
+ }
+ }
+ $cells = array('A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
+ $obpe = new PHPExcel();
+ if($sheet_data){
+ $obpe->setactivesheetindex(0);
+ foreach($sheet_data as $key=>$val){
+ foreach($val as $k2=>$v2){
+ $cell = $cells[$k2];
+ $k = $key+1;
+ $obpe->getactivesheet()->setcellvalue("{$cell}{$k}", $v2);
+ }
+ }
+ }
+ if($sheet_data2){
+ //创建一个新的工作空间(sheet)
+ $obpe->createSheet();
+ $obpe->setactivesheetindex(1);
+ foreach($sheet_data2 as $key=>$val){
+ foreach($val as $k2=>$v2){
+ $cell = $cells[$k2];
+ $k = $key+1;
+ $obpe->getactivesheet()->setcellvalue("{$cell}{$k}", $v2);
+ }
+ }
+ }
+
+ $filename = $biz['biz_name']."_{$year}年{$month}月_结算表";
+
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
+ header("Content-Type:application/force-download");
+ header("Content-Type:application/vnd.ms-execl");
+ header("Content-Type:application/octet-stream");
+ header("Content-Type:application/download");;
+ header('Content-Disposition:attachment;filename='. $filename .'.xlsx');
+ header("Content-Transfer-Encoding:binary");
+
+ $writer = PHPExcel_IOFactory::createWriter($obpe, 'Excel2007');
+ $writer->save('php://output');
+ }
+ //统计合计
+ public function lists_static(){
+ $params = $this->input->get();
+
+ $where = [];
+ if($params['year']){
+ $where['year'] = $params['year'];
+ }elseif(!isset($params['year'])){
+ $where['year'] = $params['year'] = date('Y');
+ }
+ if($params['month']){
+ $where['month'] = $params['month'];
+ }elseif(!isset($params['month'])){
+ $where['month'] = $params['month'] = intval(date('m'));
+ }
+ if($params['id']){
+ $where['biz_id'] = $params['id'];
+ }
+ $page = $params['page'];
+ $page = !$page ? 1 : $page;
+ $size = $params['size'];
+ $size = !$size ? 20 : $size;
+
+ $total = $this->biz_settle_static_model->count($where);
+ $lists = array();
+ if($total){
+ $orderby = 'id desc';
+ $select = '*';
+ $rows = $this->biz_settle_static_model->select($where, $orderby, $page, $size, $select);
+ if($rows){
+ $biz_ids = array_unique(array_column($rows,'biz_id'));
+ $map_biz = [];
+ if($biz_ids){
+ $biz_ids = implode(',',$biz_ids);
+ $where_biz = ["id in ({$biz_ids})" => null];
+ $map_biz = $this->biz_model->map('id', 'biz_name', $where_biz, '', 0, 0, 'id,biz_name');
+ }
+ //属性按'车型-车身颜色-内饰颜色'排序
+ foreach($rows as $v){
+ $temp = $v;
+ $temp['biz_name'] = $map_biz[$v['biz_id']];
+ $temp['month_str'] = date('Y-m',strtotime("{$v['year']}-{$v['month']}"));
+ $temp['price_other'] = $v['price_other'] ? json_decode($v['price_other']) : [];
+ $temp['total_need'] = $v['rent'] + $v['wat_ele'] + $v['manager_wage'] + $v['employee_wage'] + $v['commission'] + $v['price_trucking'];
+ $temp['price_ml'] = $v['price_total'] - $temp['total_need'];
+ $lists[] = $temp;
+ }
+ }
+ }
+ $this->data['params'] = $params;
+ $this->data['lists'] = $lists;
+ $this->data['yearAry'] = $this->auto_business_model->year();
+ $this->data['monthAry'] = $this->auto_business_model->month();
+ $this->data['type_arr'] = $this->biz_settle_static_model->other_price_type();
+ $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page,'totle'=>$total);
+ $this->data['_title'] = '商家结算管理';
+ $this->show_view('biz/settle/lists_static',true);
+
+ }
+
+ //重新统计
+ public function edit_static(){
+ $id = $this->input->post('id');
+ $row = $this->biz_settle_static_model->get(['id'=>$id]);
+ if(!$row){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $all_other = 0; //共同承担其它费用
+ $liche_other = 0; //狸车承担其它费用
+ $partner_other = 0; //合伙人承担其它费用
+ $price_other = json_decode($row['price_other'],true);
+ if($price_other){
+ foreach($price_other as $item){
+ if($item['type']==2){
+ $partner_other += $item['money'];
+ }elseif($item['type']==1){
+ $liche_other += $item['money'];
+ }else{
+ $all_other += $item['money'];
+ }
+ }
+ }
+ $biz_info = $this->biz_info_model->get(['biz_id'=>$row['biz_id']]);
+ $type_config = $this->biz_type[$biz_info['type']];
+ $price_need = $row['rent'] + $row['wat_ele'] + $row['employee_wage'] + $row['manager_wage'] + $row['commission'] + $row['price_trucking'];
+ $price_ml = $row['price_total'] - $price_need - $all_other;
+ $update['profix_liche'] = $price_ml*$type_config['liche']-$liche_other;
+ $update['profix_partner'] = $price_ml*$type_config['partner']-$partner_other;
+ $this->biz_settle_static_model->update($update,['id'=>$row['id']]);
+
+ return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
+ }
+
+ public function add_price(){
+ $id = $this->input->get_post('id');
+ $row = $this->biz_settle_static_model->get(['id'=>$id]);
+ if(!$row){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ if($this->input->method()=='post'){
+ $lists = $this->input->post('lists');
+ if(!is_array($lists)){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $price_other = [];
+ foreach($lists as $key=>$val){
+ if($val['money']){
+ $price_other[] = [
+ 'name' => $val['name'],
+ 'money' => $val['money'],
+ 'type' => $val['type'] ? $val['type'] : 0
+ ];
+ }
+ }
+ $up_data['price_other'] = json_encode($price_other,JSON_UNESCAPED_UNICODE);
+ $this->biz_settle_static_model->update($up_data,['id'=>$id]);
+ return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
+ }
+ $lists = $row['price_other'] ? json_decode($row['price_other']) : [];
+ $this->data['id'] = $id;
+ $this->data['lists'] = $lists;
+ $this->data['type_arr'] = $this->biz_settle_static_model->other_price_type();
+ $this->show_view('biz/settle/add');
+ }
+}
diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php
index 23ae87aa..0fd9fbaf 100755
--- a/admin/controllers/biz/store/Store.php
+++ b/admin/controllers/biz/store/Store.php
@@ -18,7 +18,10 @@ class Store extends HD_Controller
$this->load->helper('image_helper');
$this->load->model("biz/biz_model");
$this->load->model("biz/biz_tagdata_model");
+ $this->load->model("biz/biz_info_model");
+ $this->load->model("biz/biz_trucking_model");
$this->load->model('app/licheb/app_licheb_users_model', 'mdLichebUsers');
+ $this->load->model('auto/auto_brand_model');
$this->load->model("biz/biz_brand_model", 'bizBrand');
$this->load->model('area_model');
@@ -105,6 +108,7 @@ class Store extends HD_Controller
$v['brand_name'] = $brand['brand_name'];
$v['c_time'] = date('Y-m-d H:i:s', $v['c_time']);
$v['type_name'] = $typeAry[$v['type']];
+ $v['type'] = $v['type'];
$bizlists[] = $v;
}
@@ -163,6 +167,7 @@ class Store extends HD_Controller
if ($id) {
$biz = $this->biz_model->get(array('id' => $id, 'status>-1' => null));
+
if (!$biz || empty($biz)) {
return $this->show_json(SYS_CODE_FAIL, '店铺不存在!');
}
@@ -216,7 +221,8 @@ class Store extends HD_Controller
'province_id' => '350',
'type' => 0,
'company_id' => 0,
- 'auto_brands' => array()
+ 'auto_brands' => array(),
+ 'car_brand_id' => 0
);//默认福建城市
$this->data['biz'] = $biz;
}
@@ -262,6 +268,11 @@ class Store extends HD_Controller
$biz['type'] = intval($this->input->post('type', true));
$biz['company_id'] = intval($this->input->post('company_id', true));
$biz['srv_company_id'] = intval($this->input->post('srv_company_id', true));
+ $biz['car_brand_id'] = intval($this->input->post('car_brand_id',true));
+
+ if ($biz['type']==1 && !$biz['car_brand_id']){
+ return $this->show_json(SYS_CODE_FAIL, '请选择车型品牌');
+ }
$auto_brands = $this->input->post('auto_brands');
if ($auto_brands) {
@@ -329,7 +340,11 @@ class Store extends HD_Controller
$biz['type'] = intval($this->input->post('type', true));
$biz['company_id'] = intval($this->input->post('company_id', true));
$biz['srv_company_id'] = intval($this->input->post('srv_company_id', true));
+ $biz['car_brand_id'] = intval($this->input->post('car_brand_id',true));
+ if ($biz['type']==1 && !$biz['car_brand_id']){
+ return $this->show_json(SYS_CODE_FAIL, '请选择车型品牌');
+ }
//上传头像
$biz['headimg'] = $this->input->post('headimg');
@@ -997,5 +1012,96 @@ class Store extends HD_Controller
end:
return array($status, $data, $msg);
}
+
+ public function get_info(){
+ $biz_id = $this->input->get('id');
+ if(!$this->biz_model->get(['id'=>$biz_id])){
+ return $this->show_json(SYS_CODE_FAIL, '店铺不存在!');
+ }
+ $base_info = $this->biz_info_model->get(['biz_id'=>$biz_id]);
+ if(!$base_info){
+ $this->biz_info_model->add(['biz_id'=>$biz_id,'c_time'=>time()]);
+ $base_info = $this->biz_info_model->get(['biz_id'=>$biz_id]);
+ }
+ $info = [
+ 'id' => $base_info['id'],
+ 'biz_id' => $base_info['biz_id'],
+ 'name' => $base_info['name'],
+ 'mobile' => $base_info['mobile'],
+ 'margin' => $base_info['margin'],
+ 'area' => $base_info['area'],
+ 'rent' => $base_info['rent'],
+ 'wat_ele' => $base_info['wat_ele'],
+ 'employee_wage' => $base_info['employee_wage'],
+ 'manager_wage' => $base_info['manager_wage'],
+ 'commission' => $base_info['commission'],
+ 's_time' => $base_info['s_time'] ? date('Y-m-d',$base_info['s_time']) : '',
+ 'e_time' => $base_info['e_time'] ? date('Y-m-d',$base_info['e_time']) : '',
+ 'type' => $base_info['type'],
+ ];
+ $brands = [];
+ $b_rows = $this->biz_trucking_model->select(['biz_id'=>$base_info['biz_id'],'status'=>1],'','','','auto_b_id,money');
+ if($b_rows){
+ $auto_b_ids = array_column($b_rows,'auto_b_id');
+ $auto_b_ids = $auto_b_ids ? implode(',',$auto_b_ids) : 0;
+ $where["id in ($auto_b_ids)"] = null;
+ $auto_rows = $this->auto_brand_model->map('id','name',$where,'','','','id,name');
+ foreach($b_rows as $key=>$val){
+ $brands[] = [
+ 'id' => $val['auto_b_id'],
+ 'name' => $auto_rows[$val['auto_b_id']],
+ 'money' => $val['money']
+ ];
+ }
+ }
+ $this->data['type_arr'] = [1=>'扩展',2=>'新增'];
+ $this->data['brands'] = $brands;
+ $this->data['info'] = $info;
+ $this->data['_title'] = '编辑门店基本信息';
+ $this->show_view('biz/store/get_info', true);
+ }
+ public function edit_info(){
+ $info = $this->input->post('info');
+ $brands = $this->input->post('brands');
+ if(!$this->biz_info_model->get(['id'=>$info['id']])){
+ return $this->show_json(SYS_CODE_FAIL, '错数错误!');
+ }
+ $up_data = [
+ 'name' => $info['name'],
+ 'mobile' => $info['mobile'],
+ 'margin' => $info['margin'],
+ 'area' => $info['area'],
+ 'rent' => $info['rent'],
+ 'wat_ele' => $info['wat_ele'],
+ 'employee_wage' => $info['employee_wage'],
+ 'manager_wage' => $info['manager_wage'],
+ 'commission' => $info['commission'],
+ 's_time' => $info['s_time'] ? strtotime($info['s_time']) : 0,
+ 'e_time' => $info['e_time'] ? strtotime($info['e_time']) : 0,
+ 'type' => $info['type'],
+ ];
+ $this->biz_info_model->update($up_data,['id'=>$info['id']]);
+ $b_ids = array_column($brands,'id');
+ if($b_ids){
+ $b_ids = implode(',',$b_ids);
+ $this->biz_trucking_model->update(['status'=>-1],["auto_b_id not in ({$b_ids})"=>null,'biz_id'=>$info['biz_id']]);
+ foreach($brands as $key=>$val){
+ $s_row = $this->biz_trucking_model->get(['biz_id'=>$info['biz_id'],'auto_b_id'=>$val['id']]);
+ $data = [
+ 'money' => $val['money'],
+ 'status' => 1
+ ];
+ if($s_row){
+ $this->biz_trucking_model->update($data,['id'=>$s_row['id']]);
+ }else{
+ $data['biz_id'] = $info['biz_id'];
+ $data['auto_b_id'] = $val['id'];
+ $data['c_time'] = time();
+ $this->biz_trucking_model->add($data);
+ }
+ }
+ }
+ return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
+ }
}
diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php
new file mode 100644
index 00000000..abe75840
--- /dev/null
+++ b/admin/controllers/receiver/orderv2/Orders.php
@@ -0,0 +1,827 @@
+load->model('receiver/order/receiver_orders_v2_model');
+ $this->load->model('receiver/order/receiver_order_status_model');
+ $this->load->model('receiver/order/receiver_order_datas_model');
+ $this->load->model('receiver/order/receiver_order_signs_model', 'order_signs_model');
+ $this->load->model('receiver/order/receiver_order_loans_model', 'order_loans_model');
+ $this->load->model('receiver/order/receiver_order_ckcars_model', 'order_ckcars_model');
+ $this->load->model('receiver/order/receiver_order_bills_model', 'order_bills_model');
+ $this->load->model('receiver/order/receiver_order_agents_model', 'order_agents_model');
+ $this->load->model('receiver/order/receiver_order_deliverys_model', 'order_deliverys_model');
+ $this->load->model('receiver/order/receiver_order_contracts_model', 'order_contracts_model');
+ $this->load->model('receiver/receiver_customers_model', 'customers_model');
+ $this->load->model('auto/auto_series_model');
+ $this->load->model('auto/auto_brand_model');
+ $this->load->model('auto/auto_attr_model');
+ $this->load->model('auto/auto_finance_model');
+ $this->load->model('sys/sys_finance_model');
+ $this->load->model('sys/sys_company_model');
+ $this->load->model('app/liche/app_liche_orders_model');
+ $this->load->model('app/app_checkdata_model');
+
+ $this->load->library('receiver/orders_entity');
+ $this->load->library('receiver/orders_v2_entity');
+ $this->load->library('receiver/orders_status_entity');
+ $this->load->library('receiver/order_datas_entity');
+ $this->load->library('Ordersv2List');
+ $this->load->library('qyrobot');
+ }
+
+ public function index()
+ {
+ $this->lists();
+ }
+
+ public function lists()
+ {
+ $params = $this->input->get();
+ $statusAry = $this->receiver_order_status_model->statusAry();
+ $status_arr = array();
+ $t1 = 'lc_receiver_orders_v2';
+ $t2 = 'lc_receiver_order_status';
+ foreach ($statusAry as $key => $value) {
+ if (!$value['show']) {
+ continue;
+ }
+ $cate = $where = array();
+ $where = ["$t1.status<>" => -1];
+ if(is_product()){
+ $where["{$t1}.brand_id<>3"] = null;//狸车品牌不显示
+ $where["{$t1}.biz_id<>1"] = null;//biz_id=1不显示
+ }
+ if ($value['list']) {
+ foreach ($value['list'] as $key2 => $value2) {
+ if($key2){
+ $where_s = [];
+ $key==1 && $where_s["{$t1}.payway"] = 0;//分期
+ if($key2){
+ $where_s["{$t2}.pid_status"] = $value['pid_status'];
+ $up_key = $key2+1;
+ $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);
+ }else{
+ $where_s = [
+ "id not in (select o_id from lc_receiver_order_status where pid_status={$value['pid_status']} and status=1)" => null
+ ];
+ $key==1 && $where_s['payway'] = 0;
+ $where_s = array_merge($where,$where_s);
+ $count2 = $this->receiver_orders_v2_model->count($where_s);
+ }
+ $cate[] = array("id" => $key2, "name" => $value2, "count" => $count2);
+ }
+ }
+ $status_arr[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => 0);
+ }
+ $where = ["{$t1}.status<>" => -1];
+ if(is_product()){
+ $where["{$t1}.brand_id<>"] = 3;//狸车品牌不显示
+ $where["{$t1}.biz_id<>"] = 1;//biz_id=1不显示
+ }
+ $params['status_pid'] == 5 && $params['status'] = 1;
+ $params['count_all'] = $this->receiver_orders_v2_model->count($where);//全部
+ $params['list_type'] = 'all';
+ $result = $this->ordersv2list->lists($params['status_pid'], $params);
+ $this->data = $result;
+ $this->data['status_arr'] = $status_arr;
+ return $this->show_view($result['view'], true);
+ }
+
+ public function get()
+ {
+ $id = $this->input->get('id');
+
+ $row = $this->receiver_orders_v2_model->get(['id' => $id]);
+ $customers = $this->customers_model->get(['id' => $row['customer_id']], 'cf_title');
+ if (!$row) {
+ return $this->show_json(SYS_CODE_FAIL, '订单不存在!');
+ }
+ $money_json = json_decode($row['money_json'], true);
+ $deposit = $money_json['price_book'];
+ $jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
+ $row['price_discount'] = $money_json['price_discount'];
+ //售价详细信息
+ $sale_detail = "指导价:".number_format($money_json['price_car'],2);
+ $money_json['price_discount'] && $sale_detail .= ',优惠金额:'.number_format($money_json['price_discount'],2);
+ $money_json['price_color'] && $sale_detail .= ',颜色加价:'.number_format($money_json['price_color'],2);
+ $money_json['price_coplus'] && $sale_detail .= ',公司加价:'.number_format($money_json['price_coplus'],2);
+ $row['sale_detail'] = $sale_detail;
+ $sale_price = $this->orders_v2_entity->total_price($row['id']);
+ $row['sale_price'] = number_format($sale_price, 2);
+ $row['info_json'] = json_decode($row['info_json'], true);
+ $row['status'] = intval($row['status']);
+ $row['price'] = number_format($money_json['price_car'], 2);
+ $row['deposit'] = number_format($deposit, 2);
+ $row['c_time'] = date('Y-m-d', $row['c_time']);
+ $row['cf_title'] = $customers['cf_title'];
+ $row['payway'] = intval($row['payway']);
+ $row['item_id'] = intval($row['item_id']);
+ $row['cardid'] = $row['info_json']['c_cardid'] ? $row['info_json']['c_cardid'] :'';
+ $row['address'] = $row['info_json']['c_address'] ? $row['info_json']['c_address'] : '';
+ $row['owner_cardid'] = $row['info_json']['c_owner_cardid'] ? $row['info_json']['c_owner_cardid'] : '';
+ $row['credit'] = $row['info_json']['c_credit'] ? $row['info_json']['c_credit'] : '';
+ $row['company'] = $row['info_json']['c_company'] ? $row['info_json']['c_company'] : '';
+ $row['note'] = $jsondata['note'] ? $jsondata['note'] : '';
+ //获取车信息
+ $brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
+ $serie = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
+ $row['brand_name'] = $brand['name'];
+ $row['s_name'] = $serie['name'];
+ $attr_arr = [$row['v_id'], $row['cor_id'], $row['incor_id']];
+ $attr = $this->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
+ $row['v_name'] = isset($attr[$row['v_id']]) ? $attr[$row['v_id']][0]['title'] : '';
+ $row['cor_name'] = isset($attr[$row['cor_id']]) ? $attr[$row['cor_id']][0]['title'] : '';
+ $row['incor_name'] = isset($attr[$row['incor_id']]) ? $attr[$row['incor_id']][0]['title'] : '';
+ //获取选择车辆vin
+ if ($row['item_id']) {
+ $this->load->model('items/items_model', 'mdItems');
+ $row_goods = $this->mdItems->get(array('id' => $row['item_id']));
+ $row['vin'] = $row_goods['vin'];
+ }
+ $row['delry_time'] = $row['delry_time'] != '0000-00-00 00:00:00'
+ ? str_replace(" 00:00:00", "", $row['delry_time']) : '';
+ //获取车辆服务费
+ $srv_info = $this->orders_v2_entity->order_srv_money($row['id'], 2);
+ $srv_info['total'] = number_format($srv_info['total'], 2);
+ $srv_detail = "";
+ if ($srv_info['list']) {
+ foreach ($srv_info['list'] as $key => $val) {
+ $d = $srv_detail ? ',' : '';
+ $srv_detail .= $d . $val['title'] . ":" . number_format($val['money'], 2);
+ }
+ }
+ $srv_info['detail'] = $srv_detail;
+ $row['srv_info'] = $srv_info;
+ //获取贷款信息
+ if (!$row['payway']) {
+ $loan = $this->order_loans_model->get(['o_id' => $row['id']]);
+
+ $loan['notify_file'] = $loan['notify_file'] ? build_qiniu_image_url($loan['notify_file']) : '';
+ $loan['notify_file_name'] = $loan['notify_file'] ? end(explode('/', $loan['notify_file'])) : '';
+ $loan['lend_file'] = $loan['lend_file'] ? build_qiniu_image_url($loan['lend_file']) : '';
+ $loan['lend_file_name'] = $loan['lend_file'] ? end(explode('/', $loan['lend_file'])) : '';
+
+ $loan['finance_rows'] = $this->sys_finance_model->select(['status' => 1], '', 0, 0, 'id,title');
+ $loan['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : '';
+ $loan['first_pay'] = 0;
+ if ($money_json['price_loan']) {
+ $loan['first_pay'] = $sale_price - $money_json['price_loan'];
+ }
+ !$loan['num'] && $loan['num'] = 12;
+ $loan['loan_time'] = $loan['loan_time'] != '0000-00-00 00:00:00' ? date('Y-m-d', strtotime($loan['loan_time'])) : '';
+ $status_array = $this->receiver_order_status_model->select(['o_id'=>$row['id'],'pid_status'=>1],'','','id,status');
+ $loan['status_array'] = array_column($status_array,'status');
+ $row['loan_info'] = $loan;
+ }
+ //获取审核资料信息
+ $img_data = $this->receiver_order_datas_model->get(['o_id'=>$row['id'],'status>='=>0]);
+ $row['imgs_status'] = $this->order_datas_entity->data_ckinfo($img_data,$row['main_type']);
+
+ //获取开票
+ $bill = $this->order_bills_model->get(['o_id' => $row['id']], 'status,file');
+ $bill_status = $this->receiver_order_status_model->get(['o_id'=>$row['id'],'pid_status'=>3,'status'=>1]); //是否已开票
+ $bill['file'] = $bill['file'] ? build_qiniu_image_url($bill['file']) : '';
+ $bill['file_type'] = $bill['file'] && strstr($bill['file'], '.pdf') ? 'pdf' : 'img';
+ $bill['cardidA'] = $img_data['cardida'];
+ $bill['cardidB'] = $img_data['cardidb'];
+ $bill['business_licence'] = $img_data['business_licence'];
+ $bill['status'] = $bill_status ? 1 : 0;
+ $row_goods['company_id'] && $item_company = $this->sys_company_model->get(['id'=>$row_goods['company_id']],'id,short');
+ if(!$item_company){
+ $item_html = '车辆归属未选择';
+ }else{
+ $item_html = "车辆公司归属【{$item_company['short']}】";
+ }
+ $pay_order = $this->app_liche_orders_model->get(['type'=>3,'status'=>1,'o_id'=>$row['id']],'mch_id');
+ $pay_order && $pay_compay = $this->sys_company_model->get(['wx_mchid' => $pay_order['mch_id']],'id,short');
+ $pay_html = '';
+ if($pay_compay){
+ $ck_html = $pay_compay['id'] == $item_company['id'] ? '一致' : '不一致';
+ $pay_html = "与尾款收款公司【{$pay_compay['short']}】 {$ck_html}";
+ }
+ $bill['warning'] = $item_html. $pay_html;
+ $row['bill'] = $bill;
+ //获取合同文件
+ $contracts = $this->order_contracts_model->select(['o_id' => $row['id'], 'status' => 1], '', '', '', 'id,type,file,status');
+ $contract_data = [];
+ if ($contracts) {
+ foreach ($contracts as $key => $val) {
+ $contract_data[$val['type']] = [
+ 'type' => $val['type'],
+ 'status' => $val['status'],
+// 'src' => http_host_com('api').'/'.$val['file'],
+ 'src' => http_host_com('api').'/wxapp/licheb/protocol/pdf_img?id='.$val['id'],
+ ];
+ }
+ }
+ $row['contract_data'] = $contract_data;
+
+ //获取销售员
+ if ($row['sale_id']) {
+ $this->load->model('app/licheb/app_licheb_users_model', 'licheb_users_model');
+ $this->load->model("biz/biz_model");
+ $row_admin = $this->licheb_users_model->get(array('id' => $row['sale_id']));
+ $biz_id = $row_admin['biz_id'];
+ $row_biz = array();
+ if ($biz_id) {
+ $row_biz = $this->biz_model->get(array('id' => $biz_id));
+ }
+ $admin_name = $row_admin ? "{$row_biz['biz_name']} {$row_admin['uname']}" : "";
+ $row['admin_name'] = $admin_name;
+ }
+ $info = $row;
+ $this->data['info'] = $info;
+
+ $this->data['_title'] = '订单详情';
+ return $this->show_view('receiver/orderv2/get/index', true);
+ }
+
+ //添加单条数据
+ public function add()
+ {
+ }
+
+ //编辑单条数据
+ public function edit()
+ {
+ $params = $this->input->post();
+ if (!$params['id']) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $result = '';
+ if ($params['type'] == 1) {//修改备注
+ $re = $this->receiver_orders_v2_model->get(['id' => $params['id']]);
+ $jsondata = json_decode($re['jsondata'], true);
+ $jsondata['note'] = $params['note'];
+ $upd = array('jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE));
+ $result = $this->receiver_orders_v2_model->update($upd, ['id' => $params['id']]);
+ } else if ($params['type'] == 2) {//修改营业执照
+ if (!$params['business_licence']) {
+ return $this->show_json(SYS_CODE_FAIL, '请上传营业执照');
+ }
+ if (!$this->order_bills_model->get(['o_id' => $params['id']])) {
+ $this->order_bills_model->add(['o_id' => $params['id'], 'c_time' => time()]);
+ }
+ $result = $this->order_bills_model->update(array('business_licence' => $params['business_licence']), ['o_id' => $params['id']]);
+ }
+ if ($result) {
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ } else {
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ /**
+ * 更新身份证信息
+ * @return bool
+ */
+ function edit_cardID()
+ {
+ $o_id = $this->input->post('o_id');
+ $cardidA = $this->input->post('cardidA');
+ $cardidB = $this->input->post('cardidB');
+ if (!$this->receiver_order_datas_model->get(['o_id' => $o_id])) {
+ $this->order_bills_model->add(['o_id' => $o_id, 'c_time' => time()]);
+ }
+ if (!$cardidA || !$cardidB) {
+ return $this->show_json(SYS_CODE_FAIL, '请上传身份证照片');
+ }
+
+ $this->load->library('TcOrc');
+ $cardidA_src = build_qiniu_image_url($cardidA);
+ $result = $this->tcorc->IdentityCard($cardidA_src);
+ if (!$result['code']) {
+ return $this->show_json(SYS_CODE_FAIL, '身份证校验不通过');
+ } else {
+ //校验姓名
+ $uname = $result['data']['Name'];
+ $row_order = $this->receiver_orders_v2_model->get(['id' => $o_id]);
+ if ($uname != $row_order['name']) {
+ return $this->show_json(SYS_CODE_FAIL, '身份证姓名与客户不一致');
+ }
+ }
+
+ $upd = array(
+ 'cardidA' => $cardidA,
+ 'cardidB' => $cardidB,
+ 'status' => 1
+ );
+ $result = $this->order_bills_model->update($upd, ['o_id' => $o_id]);
+ if ($result) {
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ } else {
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ //删除单条数据
+ public function del()
+ {
+
+ }
+
+ //批量操作(默认修改状态)
+ public function batch()
+ {
+
+ }
+
+ //导出数据列表
+ public function export()
+ {
+ $params = $this->input->get();
+ $params['page'] = 1;
+ $params['size'] = 10000;
+ $indexs = [];
+ if ($params['export_type']) {
+ $result = $this->orderslist->export_data($params['status_pid'], $params);
+ $fileName = '保险明细';
+ $data = $result['data'];
+ $indexs = $result['indexs'];
+ } else {
+ $fieldAry = $this->orderslist->get_fields($params['status_pid'], 1);
+ foreach ($fieldAry as $key => $value) {
+ $indexs[$key] = $value['title'];
+ }
+ $result = $this->orderslist->lists($params['status_pid'], $params);
+ $fileName = $result['_title'];
+ foreach ($result['lists'] as $key => $value) {
+ $temp = array();
+ foreach ($fieldAry as $key2 => $value2) {
+ $temp[$key2] = $value[$key2];
+ }
+ $data[] = $temp;
+ }
+ array_unshift($data, $indexs);
+ }
+ $this->load->library('excel');
+ return $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
+ }
+
+ //修改分期
+ public function edit_loan()
+ {
+ $params = $this->input->post();
+ $info = $params['info'];
+ $oid = $params['id'] ? $params['id'] : $info['id'];
+ $file = $_FILES['file'];
+ $row = $this->order_loans_model->get(['o_id' => $oid]);
+ if (!$row) {
+ $this->order_loans_model->add(['o_id' => $oid, 'c_time' => time()]);
+ $row = $this->order_loans_model->get(['o_id' => $oid]);
+ }
+ $update = [];
+ 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, '上传文件失败!');
+ }
+ if ($params['type']) {
+ $update['lend_file'] = $res['file'];
+ } else {
+ $update['notify_file'] = $res['file'];
+ }
+ $this->data['file_url'] = build_qiniu_image_url($res['file']);
+ }
+ strlen($params['status']) && $update['status'] = $params['status'];
+ if ($params['status'] == 1) { //等待放款
+ $finance_id = $info['finance_id'];
+ $price_loan = $info['loan_info']['price_loan'];
+ if (!$row['notify_file']) {
+ return $this->show_json(SYS_CODE_FAIL, '请先上传按揭通知函!');
+ }
+ if (!$finance_id || !$price_loan) {
+ return $this->show_json(SYS_CODE_FAIL, '请填写完整信息!');
+ }
+ $order_row = $this->receiver_orders_v2_model->get(['id' => $row['o_id']], 'id,mobile,money_json');
+ $money_json = json_decode($order_row['money_json'], true);
+ $money_json['price_loan'] = $price_loan;
+ $this->receiver_orders_v2_model->update(['finance_id' => $finance_id, 'money_json' => json_encode($money_json, JSON_UNESCAPED_UNICODE)], ['id' => $row['o_id']]);
+ //生成购车订单
+ $this->load->model('app/liche/app_liche_users_model');
+ $userinfo = $this->app_liche_users_model->get(['mobile'=>$order_row['mobile']]);
+ $this->orders_v2_entity->add_order($order_row['id'],$userinfo['id']);
+ $result = $this->orders_status_entity->set_status($oid,1,1);
+ }elseif($params['status'] == 2){ //完成按揭
+ $loan_time = $info['loan_info']['loan_time'];
+ if (!$loan_time) {
+ return $this->show_json(SYS_CODE_FAIL, '请选择放款时间!');
+ }
+ if (!$row['lend_file']) {
+ return $this->show_json(SYS_CODE_FAIL, '请先上传按揭放款函!');
+ }
+ $update['loan_time'] = date('Y-m-d H:i:s', strtotime($loan_time));
+ $result = $this->orders_status_entity->set_status($oid,1,2);
+ }
+ if($update){
+ $result = $this->order_loans_model->update($update, ['id' => $row['id']]);
+ }
+ return $result ? $this->show_json(SYS_CODE_SUCCESS, '保存成功') : $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+
+ public function edit_item()
+ {
+ $this->load->model("items/items_model");
+
+ $id = $this->input->post('id');
+ $item_id = $this->input->post('item_id');
+ $row = $this->receiver_orders_v2_model->get(['id' => $id]);
+ if (!$row) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ if (!$item_id) return $this->show_json(SYS_CODE_FAIL, '请选择车辆!');
+
+ if ($this->receiver_order_status_model->get(['o_id'=>$id,'pid_status'=>3,'status'=>1])) {
+ return $this->show_json(SYS_CODE_FAIL, '已开票,不能修改!');
+ }
+ $res = $this->receiver_orders_v2_model->update(['item_id' => $item_id], ['id' => $id]);
+ if (!$res) {
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ if ($row['item_id'] && $row['item_id'] != $item_id) {
+ $this->items_model->update(['status' => 1], ['id' => $row['item_id']]);
+ }
+ $result = $this->items_model->update(['status' => 2], ['id' => $item_id]);
+
+ if ($result) {
+ $this->orders_status_entity->set_status($id,2,1);
+ }
+ if ($result) {
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ } else {
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ //查看发票信息
+ public function get_bill()
+ {
+ $oid = $this->input->get('oid');
+ $row = $this->receiver_orders_v2_model->get(['id' => $oid]);
+ $bill = $this->order_bills_model->get(['o_id' => $oid]);
+ if (!$row) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ if (!$bill) {
+ $add_data = [
+ 'o_id' => $row['id'],
+ 'c_time' => time()
+ ];
+ $bill['id'] = $this->order_bills_model->add($add_data);
+ }
+ $bill['src_file'] = $bill['file'] ? build_qiniu_image_url($bill['file']) : '';
+ $bill['bill_time'] = $row['bill_time'] != '0000-00-00 00:00:00' ? $row['bill_time'] : '';
+ $this->data['bill'] = $bill;
+ return $this->show_view('receiver/orderv2/get/get_bill');
+ }
+
+ //编辑发票信息
+ public function edit_bill()
+ {
+ $id = $this->input->post('id');
+ $file = $this->input->post('value');
+ $row_order = $this->receiver_orders_v2_model->get(array('id' => $id));
+ if(!$file || !$row_order){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ $row = $this->order_bills_model->get(['o_id' => $row_order['id']]);
+ if(!$row){
+ $this->order_bills_model->add(['c_time'=>time(),'o_id'=>$row_order['id']]);
+ }
+ $update['file'] = $file;
+ $result = $this->order_bills_model->update($update, ['o_id' => $row_order['id']]);
+ if ($result) {
+ //更新开票时间
+ $this->load->model('items/items_model');
+ $bill_time = date('Y-m-d H:i:s');
+ $upd = array('bill_time' => $bill_time);
+ $where = array('id' => $row_order['item_id']);
+ $ret = $this->items_model->update($upd, $where);
+ if ($ret) { //添加开票日志
+ $this->load->library('entity/items_entity');
+ $re_i = $this->items_model->get(['id' => $row_order['item_id']]);
+ $params = array('item_id' => $row_order['item_id'], 'type' => 3, 'uid' => $this->uid, 'uname' => $this->username
+ , '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']]);
+ $this->orders_status_entity->set_status($row_order['id'],3,1);
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ } else {
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ //确定交款
+ public function edit_jk()
+ {
+ $oid = $this->input->post('oid');
+ $row = $this->receiver_orders_v2_model->get(['id' => $oid]);
+ if (!$row) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误!');
+ }
+ $bill = $this->order_bills_model->get(['o_id' => $oid]);
+ if (!$bill['file'] || !$bill['money']) {
+ return $this->show_json(SYS_CODE_FAIL, '未上传开票文件或未填写到账金额!');
+ }
+ $where = [
+ 'o_id' => $oid,
+ 'status' => 1,
+ 'pay_price>' => 0
+ ];
+ $sum = $this->app_liche_orders_model->sum('total_price', $where); //已收金额
+ $need_price = $this->orders_v2_entity->recevable_price($oid); //应收金额
+ if ($sum['total_price'] < $need_price) {
+ return $this->show_json(SYS_CODE_FAIL, '修改失败,已收金额小于应收金额!');
+ }
+ $this->order_bills_model->update(['status' => 2], ['o_id' => $oid]);
+ $this->orders_status_entity->set_status($oid,3,1);
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ //获取合同图片
+ public function get_cimgs()
+ {
+ $type = $this->input->get('type');
+ $oid = $this->input->get('oid');
+ $row = $this->order_contracts_model->get(['type' => $type, 'o_id' => $oid]);
+ $info['title'] = '相册标题';
+ $info['id'] = '222';
+ $info['start'] = 0;
+ $data = [];
+ if ($row) {
+ $imgs = json_decode($row['imgs'], true);
+ foreach ($imgs as $key => $val) {
+ $data[] = [
+ 'alt' => '图片名',
+ 'pid' => $key,
+ 'src' => build_qiniu_image_url($val),
+ 'thumb' => build_qiniu_image_url($val)
+ ];
+ }
+ }
+ $info['data'] = $data;
+ $this->data['info'] = $info;
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ //支付列表
+ public function get_paylog()
+ {
+ $params = $this->input->get();
+ if ($params['d_type'] == 'ajax') {
+ $page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
+ $size = $params['size'] = $params['size'] ? intval($params['size']) : 10;
+ $list = [];
+ $where = [
+ 'o_id' => $params['id'],
+ 'status' => 1,
+ 'pay_price>' => 0
+ ];
+ $count = $this->app_liche_orders_model->count($where);
+ if ($count) {
+ $rows = $this->app_liche_orders_model->select($where, 'id desc', $page, $size, 'id,total_price,type,pay_time,mch_id,descrip,status,pid,img,admin_id');
+ $type_arr = $this->app_liche_orders_model->get_type_arr();
+ foreach ($rows as $item) {
+ $company = '';
+ if ($item['mch_id']) {
+ $company = $this->sys_company_model->get(['wx_mchid' => $item['mch_id']], 'short');
+ }
+ $opt_name = '用户';
+ if($item['admin_id']){
+ $admin_user = $this->sys_admin_model->get(array('id' => $item['admin_id']),'username');
+ $opt_name = $admin_user['username'];
+ }
+ $list[] = [
+ 'id'=> $item['id'],
+ 'money' => $item['total_price'],
+ 'type_cn' => $type_arr[$item['type']],
+ 'pay_time' => $item['pay_time'],
+ 'company' => $company ? $company['short'] : '',
+ 'opt_name' => $opt_name,
+ 'descrip' => $item['descrip'],
+ 'img' => $item['img'] ? build_qiniu_image_url($item['img']) : '',
+ ];
+ }
+ }
+ $sum = $this->app_liche_orders_model->sum('total_price', ['o_id'=>$params['id'],'status'=>1,'pay_price>'=>0]);
+ $this->data['pay_price'] = $sum['total_price'];
+ $this->data['need_price'] = $this->orders_v2_entity->recevable_price($params['id']);
+ $this->data['list'] = $list;
+ $hasNext = ceil($count / $size) > $page ? 1 : 0;
+ $this->data['commonPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext);
+ return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
+ }
+ $this->data['id'] = $this->input->get('id');
+ return $this->show_view('receiver/orderv2/get/paylog');
+ }
+
+ //添加支付日志
+ public function add_paylog()
+ {
+ $id = $this->input->get_post('id');
+ $row = $this->receiver_orders_v2_model->get(['id' => $id]);
+ $srv_price = $this->orders_v2_entity->order_srv_money($row['id']);
+ $need_price = $this->orders_v2_entity->recevable_price($row['id']);
+ $car_price = $need_price-$srv_price;
+ if ($this->input->method() == 'post') {
+ $money = $this->input->post('money');
+ $pay_time = $this->input->post('pay_time');
+ $wx_mchid = $this->input->post('wx_mchid');
+ $descrip = $this->input->post('descrip');
+ $type = $this->input->post('type');
+ $img = $this->input->post('img');
+ if (!$money || !$pay_time || !$row || !$wx_mchid) {
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ $p_row = $this->app_liche_orders_model->get(['pid'=>0,'o_id'=>$row['id']]);
+ $last_p_row = $this->app_liche_orders_model->get(['o_id'=>$row['id'],'type'=>3,'pid'=>$p_row['id'],'status>='=>0]); //尾款父订单
+
+ if($type==6){ //尾款
+ if($money>$car_price){
+ return $this->show_json(SYS_CODE_FAIL, '车款金额错误');
+ }
+ $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$row['id'],'status'=>0,'type'=>1]); //定金更新成无效订单
+ if(!$this->app_liche_orders_model->count(['pid'=>$last_p_row['id'],'type'=>3,'status'=>1])){
+ $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$row['id'],'type'=>3]); //尾款更新成无效订单
+ }
+ }else{ //服务费
+ if($money>$srv_price){
+ return $this->show_json(SYS_CODE_FAIL, '服务费金额错误');
+ }
+ $this->app_liche_orders_model->update(['status'=>-1],['o_id'=>$row['id'],'type'=>2,'status'=>0]); //未支付更新成无效订单
+ }
+ $this->load->helper('order');
+ $sid = create_order_no(350200, 'liche', 1, $type);
+ $data = [
+ 'o_id' => $row['id'],
+ 'sid' => $sid,
+ 'pid' => $p_row['id'],
+ 'mch_id' => $wx_mchid,
+ 'admin_id' => $this->uid,
+ 'brand_id' => $row['brand_id'],
+ 's_id' => $row['s_id'],
+ 'v_id' => $row['v_id'],
+ 'cor_id' => $row['cor_id'],
+ 'incor_id' => $row['incor_id'],
+ 'total_price' => $money,
+ 'pay_price' => $money,
+ 'type' => $type,
+ 'status' => 1,
+ 'pay_time' => date('Y-m-d H:i:s',strtotime($pay_time)),
+ 'c_time' => time()
+ ];
+ $p_row['uid'] && $data['uid'] = $p_row['uid'];
+ $p_row['entrust_uid'] && $data['entrust_uid'] = $p_row['entrust_uid'];
+ $img && $data['img'] = $img;
+ $descrip && $data['descrip'] = $descrip;
+ $this->app_liche_orders_model->add($data);
+ if($this->app_liche_orders_model->count(['status'=>1,'o_id'=>$row['id']])==1 && $money>=100){ //企业微信推送
+ $this->qyrobot->deposit_notify_v2($row['id']);
+ }
+ $where = [
+ 'status'=>1,
+ 'o_id'=>$row['id'],
+ 'pid>'=>0
+ ];
+ $last_p_row && $where['id <>'] = $last_p_row['id'];
+ $is_pay = $this->app_liche_orders_model->sum('total_price',$where); //已支付金额
+ if($need_price && $is_pay['total_price']>=$need_price){ //完成支付
+ $last_p_row && $this->app_liche_orders_model->update(['status'=>1],['id'=>$last_p_row['id']]);//完成未支付尾款
+ $this->orders_status_entity->set_status($row['id'],0,1);
+ }
+ if(!$this->order_contracts_model->count(['o_id'=>$row['id']])){ //生成合同
+ $url = http_host_com('api').'/pdfapi/add_pdf?oid='.$row['id'];
+ $pdf_res = file_get_contents($url);
+ }
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ $companys = $this->sys_company_model->select(['status' => 1, 'wx_mchid!=' => ''], 'id desc', '', '', 'id,wx_mchid,short');
+ $type = [];
+ $srv_price >0 && $type[] = ['id'=>2,'name'=>'服务费'];
+ $type[] = ['id'=>6,'name'=>'车款'];
+ $this->data['type'] = $type;
+ $this->data['companys'] = $companys;
+ $this->data['id'] = $this->input->get('id');
+ return $this->show_view('receiver/orderv2/get/add_paylog');
+ }
+ //取消配车
+ public function edit_ckcar(){
+ $this->load->model('items/items_model');
+ $id = $this->input->post('id');
+ $row = $this->receiver_orders_v2_model->get(['id'=>$id]);
+ if(!$row || !$row['item_id']){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ if ($this->receiver_order_status_model->get(['o_id'=>$id,'pid_status'=>3,'status'=>1])) {
+ return $this->show_json(SYS_CODE_FAIL, '订单已开票,不能修改!');
+ }
+ $res = $this->receiver_orders_v2_model->update(['item_id'=>0],['id'=>$row['id']]);
+ if($res){
+ $this->items_model->update(['status' => 1,'bill_time'=>'0000-00-00 00:00:00'], ['id' => $row['item_id']]);
+ $this->receiver_order_status_model->delete(['o_id'=>$id,'pid_status'=>2,'status'=>1]);
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }else{
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ //修改图片
+ public function edit_imgs(){
+ $id = $this->input->post('id');
+ $field = $this->input->post('filed');
+ $value = $this->input->post('value');
+ $row = $this->receiver_orders_v2_model->get(['id'=>$id]);
+ if(!$row){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ $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]);
+ }else{
+ $re_data_id = $re_data['id'];
+ }
+ if($field=='ins_img' || $field=='other_img'){
+ $val_arr = json_decode($row[$field],true);
+ $val_arr[] = $value;
+ $value = json_encode($val_arr,JSON_UNESCAPED_UNICODE);
+ }
+ $update = [
+ $field => $value
+ ];
+ $res = $this->receiver_order_datas_model->update($update,['id'=>$re_data_id]);
+ if($res){
+ $this->orders_status_entity->set_status($id,6,1);
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }else{
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ public function edit_ckimg(){
+ $type = $this->input->post('type');
+ $ifcheck = $this->input->post('ifcheck');
+ $o_id = $this->input->post('id');
+ $img_data = $this->receiver_order_datas_model->get(['o_id'=>$o_id]);
+ if(!$img_data){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误');
+ }
+ $ck_row = $this->app_checkdata_model->get(['cf_id'=>$img_data['id'],'app_id'=>2,'type'=>$type]);
+ if($ck_row){
+ $update = [
+ 'ifcheck' => $ifcheck ? 1 : -1,
+ ];
+ $res = $this->app_checkdata_model->update($update,['id'=>$ck_row['id']]);
+ }else{
+ $add_data = [
+ 'cf_id' => $img_data['id'],
+ 'app_id' => 2,
+ 'type' => $type,
+ 'datatype' => 'img',
+ 'ifcheck' => $ifcheck ? 1 : -1,
+ 'c_time' => time()
+ ];
+ $res = $this->app_checkdata_model->add($add_data);
+ }
+ if($res){
+ $count = $this->app_checkdata_model->count(['ifcheck'=>1,'cf_id'=>$img_data['id'],'datatype'=>'img']);
+ if($count==5){
+ $this->orders_status_entity->set_status($img_data['o_id'],6,2);
+ }
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }else{
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+ }
+
+ public function test(){
+ $o_id = 10062;
+ $res = $this->orders_v2_entity->create_pdf($o_id);
+ print_r($res);
+ }
+}
diff --git a/admin/controllers/sys/Company.php b/admin/controllers/sys/Company.php
index 0e230b42..345388e1 100644
--- a/admin/controllers/sys/Company.php
+++ b/admin/controllers/sys/Company.php
@@ -42,13 +42,17 @@ class Company extends HD_Controller{
$size = !$size ? 20 : $size;
$statusAry = $this->company_model->status_ary();
+ $typeAry = $this->company_model->type_ary();
$count = $this->company_model->count($where);
$lists = array();
if($count){
$orderby = 'id desc';
- $select = 'id, title, short, status';
+ $select = 'id, title, short, status, city_id,type';
$rows = $this->company_model->select($where, $orderby, $page, $size, $select);
+ $city_ids = array_column($rows,'city_id') ? implode(',',array_column($rows,'city_id')) : '';
+ $city_lists = [];
+ $city_ids && $city_lists = $this->sys_city_model->map('city_id','name',["city_id in ({$city_ids})"=>null],'','','','city_id,name');
foreach($rows as $k => $v){
$lists[] = array(
'id' => $v['id'],
@@ -56,6 +60,8 @@ class Company extends HD_Controller{
'short' => $v['short'],
'status' => $v['status'],
'status_name' => $statusAry[$v['status']],
+ 'type_name' => $typeAry[$v['type']],
+ 'city_name' => $city_lists[$v['city_id']] ? $city_lists[$v['city_id']] : '',
);
}
}
@@ -81,6 +87,8 @@ class Company extends HD_Controller{
'img_seal' => $row['img_seal'],
'img_seal_url' => $row['img_seal'] ? build_qiniu_image_url($row['img_seal']) : '',
'status' => $row['status'],
+ 'city_id' => $row['city_id'] ? $row['city_id'] : '',
+ 'type' => $row['type']
);
$action = '/sys/company/edit';
$title = '编辑公司';
@@ -91,14 +99,19 @@ class Company extends HD_Controller{
'credit_code' => '',
'wx_mchid' => '',
'status' => 0,
+ 'city_id' => '',
+ 'type' => 0
);
$action = '/sys/company/add';
$title = '新增公司';
}
+ $city_lists = $this->sys_city_model->select(['status'=>1],'id desc','','','city_id,name');
+ $this->data['city_lists'] = $city_lists;
$this->data['info'] = $info;
$this->data['action'] = $action;
$this->data['statusAry'] = $this->company_model->status_ary();
+ $this->data['typeAry'] = $this->company_model->type_ary();
$this->data['_title'] = $title;
$this->show_view('sys/company/get');
}
@@ -113,20 +126,25 @@ class Company extends HD_Controller{
if(!$short){
return $this->show_json(SYS_CODE_FAIL, '请输入公司简称');
}
-
- $where = array("title like '{$title}'" => null);
- $count = $this->company_model->count($where);
- if($count>0){
- return $this->show_json(SYS_CODE_FAIL, '公司已存在');
+ if(!$info['city_id']){
+ return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
+// $where = array("title like '{$title}'" => null);
+// $count = $this->company_model->count($where);
+// if($count>0){
+// return $this->show_json(SYS_CODE_FAIL, '公司已存在');
+// }
+
$add = array(
'title' => $title,
'short' => $short,
'credit_code' => $info['credit_code'] ? $info['credit_code'] : '',
'wx_mchid' => $info['wx_mchid'] ? $info['wx_mchid'] : '',
'img_seal' => $info['img_seal'] ? $info['img_seal'] : '',
- 'status' => intval($info['status'])
+ 'status' => intval($info['status']),
+ 'city_id' => $info['city_id'],
+ 'type' => intval($info['type'])
);
$id = $this->company_model->add($add);
@@ -148,20 +166,25 @@ class Company extends HD_Controller{
if(!$short){
return $this->show_json(SYS_CODE_FAIL, '请输入公司简称');
}
-
- $where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
- $count = $this->company_model->count($where);
- if($count>0){
- return $this->show_json(SYS_CODE_FAIL, '公司已存在');
+ if(!$info['city_id']){
+ return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
+// $where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
+// $count = $this->company_model->count($where);
+// if($count>0){
+// return $this->show_json(SYS_CODE_FAIL, '公司已存在');
+// }
+
$upd = array(
'title' => $title,
'short' => $short ? $short : '',
'credit_code' => $info['credit_code'] ? $info['credit_code'] : '',
'wx_mchid' => $info['wx_mchid'] ? $info['wx_mchid'] : '',
'img_seal' => $info['img_seal'] ? $info['img_seal'] : '',
- 'status' => intval($info['status'])
+ 'status' => intval($info['status']),
+ 'city_id' => $info['city_id'],
+ 'type' => intval($info['type'])
);
$ret = $this->company_model->update($upd, array('id' => $info['id']));
diff --git a/admin/libraries/Ordersv2List.php b/admin/libraries/Ordersv2List.php
new file mode 100644
index 00000000..f533b445
--- /dev/null
+++ b/admin/libraries/Ordersv2List.php
@@ -0,0 +1,386 @@
+ '客户姓名', 'mobile' => '客户手机号', 'sid' => '订单号');
+ private $paywayAry = array(0 => '贷款', 1 => '全款');
+ private $t1 = 'lc_receiver_orders_v2';
+ private $t2 = 'lc_receiver_order_status';
+
+ public function __construct()
+ {
+ $this->ci = &get_instance();
+ $this->ci->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders');
+ $this->ci->load->model('receiver/order/receiver_order_status_model');
+ $this->ci->load->model('receiver/order/receiver_order_agents_model', 'order_agents_model');
+ $this->ci->load->model('app/licheb/app_licheb_users_model', 'mdLichebUsers');
+ $this->ci->load->model('receiver/receiver_customers_model', 'mdCustomers');
+ $this->ci->load->model('receiver/receiver_clues_cfrom_model', 'mdCluesCfrom');
+ $this->ci->load->model("biz/biz_model");
+ $this->ci->load->model('auto/auto_series_model');
+ $this->ci->load->model('auto/auto_brand_model');
+ $this->ci->load->model('auto/auto_attr_model');
+
+ $this->ci->load->library('receiver/orders_v2_entity');
+ $this->ci->load->library('receiver/orders_status_entity');
+ }
+
+ public function lists($status_pid, $params = array())
+ {
+// $result = $show_info = array();
+ !$params['qdjl_id'] && $params['qdjl_id'] = '';
+ !$params['cf_title'] && $params['cf_title'] = '';
+ !$params['cf_clues'] && $params['cf_clues'] = '';
+ !strlen($params['payway']) && $params['payway'] = '';
+ !$params['biz_type'] && $params['biz_type'] = '';
+ $fieldAry = $this->get_fields($status_pid);
+ $show_info['cfTitleAry'] = $this->ci->mdCustomers->get_sdata('cfrom');//来源类型
+ $show_info['cfCluesAry'] = $this->ci->mdCustomers->get_sdata('cfrom_clues');//线下来源
+ $show_info['paywayAry'] = $this->paywayAry;//付款方式
+ $show_info['bizTypeAry'] = $this->ci->biz_model->type_ary();//门店类型
+ //渠道经理
+ $show_info['qdjl_lists'] = $this->ci->mdLichebUsers->select(array('group_id' => 4, 'status' => 1, 'biz_id<>' => '0')
+ , 'id desc', 0, 0, 'id,uname as name');
+ $result = $this->orders($params);
+ $result['show_info'] = $show_info;
+ $result['fieldAry'] = $fieldAry;
+ return $result;
+ }
+
+ /**
+ * Notes:全部订单
+ * Created on: 2021/9/18 15:13
+ * Created by: dengbw
+ * @param array $params
+ * @return array
+ */
+ private function orders($params = array())
+ {
+ $page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
+ $size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
+ $status_arr = $this->ci->receiver_order_status_model->statusAry();
+ $order_status_cn = $this->ci->mdOrders->get_status();
+ $view_type = 'orders';
+ $where = ["{$this->t1}.status>=" => 0];
+ $_title = '全部订单';
+ $view = 'receiver/orderv2/lists';
+ $params['status_pid']==1 && $where["{$this->t1}.payway"] = 0;
+// if(strlen($params['status_pid']) && $params['status']){
+// $where["{$this->t2}.pid_status"] = $params['status_pid'];
+// $where["{$this->t2}.status"] = $params['status'];
+// }
+ if(is_product()){
+ $where["{$this->t1}.biz_id<>"] = 1;
+ }
+ if ($_SESSION['admin_info']['biz_id']) {
+ $biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
+ $where["{$this->t1}.biz_id in ($biz_ids)"] = null;
+ }
+ if ($params['biz_type']) {
+ $where["{$this->t1}.biz_id in (select id from lc_biz where type = " . $params['biz_type'] . ' and status=1)'] = null;
+ }
+ if ($params['cf_title'] || $params['cf_clues'] || $params['cfrom_id'] || $params['cfrom_id2']) {
+ $where_c = 'status>=0';
+ if ($params['cfrom_id'] == 24) {
+ $where_c .= ' and cf_id = 24';
+ $params['cfrom_id2'] && $where_c .= ' and t_id = ' . $params['cfrom_id2'];
+ } else {
+ if ($params['cfrom_id2']) {
+ $where_c .= ' and cf_id = ' . $params['cfrom_id2'];
+ } else if ($params['cfrom_id']) {
+ $cf_rows = $this->ci->mdCluesCfrom->select(['pid' => $params['cfrom_id']], '', '', '', 'id');
+ $cf_ids = array_column($cf_rows, 'id');
+ $cf_ids[] = $params['cfrom_id'];
+ $cf_str_ids = implode(',', array_filter($cf_ids));
+ $cf_str_ids && $where_c .= " and cf_id in ({$cf_str_ids})";
+ }
+ }
+ $params['cf_title'] && $where_c .= ' and cf_title = "' . $params['cf_title'] . '"';
+ $params['cf_clues'] && $where_c .= ' and cf_clues = "' . $params['cf_clues'] . '"';
+ $where["{$this->t1}.customer_id in (select id from lc_receiver_customers where " . $where_c . ')'] = null;
+ }
+ if (strlen($params['payway'])) {
+ $where["{$this->t1}.payway"] = $params['payway'];
+ }
+ if ($params['qdjl_id']) {//渠道经理
+ $where["{$this->t1}.biz_id in(select biz_id from lc_app_licheb_channel_biz where uid={$params['qdjl_id']})"] = null;
+ }
+ if ($params['title']) {
+ $where["{$this->t1}.{$params['search_tp']} like '%{$params['title']}%'"] = null;
+ }
+ //创建时间
+ if ($params['c_time']) {
+ $c_time = explode(' ~ ', $params['c_time']);
+ if ($c_time[0]) {
+ $where["{$this->t1}.c_time >="] = strtotime($c_time[0] . ' 00:00:00');
+ }
+ if ($c_time[1]) {
+ $where["{$this->t1}.c_time <="] = strtotime($c_time[1] . ' 23:59:59');
+ }
+ }
+ //开票时间
+ if ($params['bill_time']) {
+ $bill_time = explode(' ~ ', $params['bill_time']);
+ if ($bill_time[0]) {
+ $where["{$this->t1}.bill_time >="] = $bill_time[0] . ' 00:00:00';
+ }
+ if ($bill_time[1]) {
+ $where["{$this->t1}.bill_time <="] = $bill_time[1] . ' 23:59:59';
+ }
+ }
+ if ($params['brand_id']) {//品牌
+ $where["{$this->t1}.brand_id"] = $params['brand_id'];
+ } else {
+ if(is_product()){
+ $where["{$this->t1}.brand_id<>"] = 3;//狸车品牌不显示
+ }
+ $params['brand_id'] = '';
+ }
+ if ($params['s_id']) {//车系
+ $where["{$this->t1}.s_id"] = $params['s_id'];
+ } else {
+ $params['s_id'] = '';
+ }
+ if ($params['v_id']) {//车型
+ $where["{$this->t1}.v_id"] = $params['v_id'];
+ } else {
+ $params['v_id'] = '';
+ }
+ if ($params['cor_id']) {//车身颜色
+ $where["{$this->t1}.cor_id"] = $params['cor_id'];
+ } else {
+ $params['cor_id'] = '';
+ }
+ //销售员筛选
+ if ($params['admin_id']) {
+ $where["{$this->t1}.admin_id"] = $params['admin_id'];
+ } else {
+ if ($params['biz_id_admin']) {//指定店铺所有销售员
+ $where["{$this->t1}.biz_id"] = $params['biz_id_admin'];
+ } else {
+ //指定城市的所有门店
+ $where_biz = array();
+ if ($params['county_id_admin']) {
+ $where_biz['county_id'] = $params['county_id_admin'];
+ } else if ($params['city_id_admin']) {
+ $where_biz['city_id'] = $params['city_id_admin'];
+ }
+ if ($where_biz) {
+ $where_biz['status>-1'] = null;
+ $rows_biz = $this->ci->biz_model->select($where_biz, 'id desc', 0, 0, 'id');
+ if ($rows_biz) {
+ $str_ids = implode(',', array_column($rows_biz, 'id'));
+ $where["{$this->t1}.biz_id in({$str_ids})"] = null;
+ } else {
+ $where["{$this->t1}.biz_id"] = -1;
+ }
+ }
+ }
+ !$params['city_id_admin'] && $params['city_id_admin'] = '';
+ !$params['county_id_admin'] && $params['county_id_admin'] = '';
+ !$params['biz_id_admin'] && $params['biz_id_admin'] = '';
+ $params['admin_id'] = '';
+ }
+ if($params['vin']){
+ $where = ["{$this->t1}.status>=" => 0];
+ $where["{$this->t1}.item_id in(select id from lc_items where vin like '%{$params['vin']}%')"] = null;
+ }
+ $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";
+ if(strlen($params['status_pid']) && $params['status']){
+ $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);
+ }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;
+ }
+ $count = $this->ci->mdOrders->count($where);
+ $rows = $this->ci->mdOrders->select($where, "c_time desc", $page, $size,$fileds);
+ }
+ $lists = [];
+ if ($count) {
+ //客户来源
+ $str_rids = implode(',', array_unique(array_column($rows, 'customer_id')));
+ !$str_rids && $str_rids = 0;
+ $customers = $this->ci->mdCustomers->map('id', '', array("id in({$str_rids})" => null),'','','','id,cf_title,cf_clues,cf_id');
+ $cfroms = [];
+ if($customers){
+ foreach($customers as $key=>$val){
+ $cf_id_arr[] = $val[0]['cf_id'];
+ }
+ //获取来源
+ $cfroms = $this->ci->mdCluesCfrom->get_map_by_ids($cf_id_arr, 'id,title');
+ }
+ //门店
+ $str_biz_ids = implode(',', array_unique(array_column($rows, 'biz_id')));
+ !$str_biz_ids && $str_biz_ids = 0;
+ $bizs = $this->ci->biz_model->map('id', 'biz_name', array("id in({$str_biz_ids})" => null));
+ //品牌车型
+ $brand_arr = array_unique(array_column($rows, 'brand_id'));
+ $brands = $this->ci->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
+ //车系车型
+ $series_arr = array_unique(array_column($rows, 's_id'));
+ $series = $this->ci->auto_series_model->get_map_by_ids($series_arr, 'id,name');
+ //获取属性
+ $v_arr = array_unique(array_column($rows, 'v_id'));
+ $cor_arr = array_unique(array_column($rows, 'cor_id'));
+ $incor_arr = array_unique(array_column($rows, 'incor_id'));
+ $attr_arr = array_merge($v_arr, $cor_arr, $incor_arr);
+ $attr = $this->ci->auto_attr_model->get_map_by_ids($attr_arr, 'id,title');
+ foreach ($rows as $key => $val) {
+ $money_json = json_decode($val['money_json'],true);
+ $info_json = json_decode($val['info_json'],true);
+ $fields = array();
+ $brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
+ $series_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
+ $v_name = isset($attr[$val['v_id']]) ? $attr[$val['v_id']][0]['title'] : '';
+ $cor_name = isset($attr[$val['cor_id']]) ? $attr[$val['cor_id']][0]['title'] : '';
+ $fields['o_id'] = $val['id'];
+ $fields['bill_time'] = $val['bill_time'];
+ $fields['mobile'] = $val['mobile'];
+ if(Orders_v2_entity::V2_START_ID<$val['id']){
+ if($val['main_type']){
+ $name = $info_json['c_company'];
+ $mobile = $val['mobile'];
+ }else{
+ $name = $val['owner_name'];
+ $mobile = $val['owner_mobile'];
+ }
+ $open_url = '/receiver/orderv2/orders/get?id=';
+ $fields['name'] = $size > 1000 ? $$name
+ : '' . $name . '
' . $mobile . '';
+
+ }else{
+ $open_url = '/receiver/orders/get?id=';
+ $o_tp = '(旧订单)';
+ $fields['name'] = $size > 1000 ? $val['name']
+ : '' . $val['name']. $o_tp . '
' . $val['mobile'] . '';
+ }
+ $fields['car_name'] = "{$brand_name}-{$series_name}-{$v_name}-{$cor_name}";
+ $fields['price'] = number_format($money_json['price_car'], 2);
+ $fields['payway_name'] = $this->paywayAry[$val['payway']];
+ $fields['incor_name'] = isset($attr[$val['incor_id']]) ? $attr[$val['incor_id']][0]['title'] : '';
+ if(strlen($params['status_pid']) && $params['status_pid']!=5){
+ $fields['status_name'] = $this->ci->orders_status_entity->last_status_cn($val['id'],$params['status_pid']);
+ }else{
+ $fields['status_name'] = $order_status_cn[$val['status']];
+ }
+ $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['rid']][0]['cf_title'];
+ $fields['cf_clues'] = $customers[$val['rid']][0]['cf_clues'];
+ $fields['cf_name'] = $cfroms[$customers[$val['rid']][0]['cf_id']][0]['title'];
+ $lists[] = $fields;
+ }
+ }
+ $pager = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
+ $_title = $size > 1000 ? $_title : $_title . '列表';
+ $view_type != 'orders' && $status_arr = [];
+ return array('lists' => $lists, 'pager' => $pager, 'params' => $params, 'status_arr' => $status_arr
+ , 'searchTpAry' => $this->searchTpAry, 'view' => $view, 'view_type' => $view_type, '_title' => $_title);
+ }
+
+ /**
+ * Notes:获取字段
+ * Created on: 2021/10/29 15:38
+ * Created by: dengbw
+ * @param $status_pid
+ * @param int $export
+ * @return array
+ */
+ public function get_fields($status_pid, $export = 0)
+ {
+ $fields1 = $fields2 = [];
+ if ($export) {
+ $fields1['name'] = ['title' => '客户姓名'];
+ $fields1['mobile'] = ['title' => '客户电话'];
+ } else {
+ $fields1['name'] = ['title' => '客户', 'width' => '14%'];
+ }
+ if (strlen($status_pid) && $status_pid == 0) {
+ $fields2 = ['car_name' => ['title' => '车辆', 'width' => '22%'],
+ 'biz_name' => ['title' => '门店', 'width' => '10%'], 'price' => ['title' => '合同价', 'width' => '7%'],
+ 'payway_name' => ['title' => '付款', 'width' => '5%'],'admin_name' => ['title' => '销售员', 'width' => '7%'],
+ 'cf_title' => ['title' => '来源类型', 'width' => '8%'],'cf_name' => ['title' => '来源','width' => '10%'],
+ 'status_name' => ['title' => '合同状态', 'width' => '7%'], 'order_time' => ['title' => '下定时间', 'width' => '12%']];
+ $fields = array_merge($fields1, $fields2);
+ } else if ($status_pid == 1) {
+ $fields2 = ['title' => ['title' => '分期产品', 'width' => '15%'],
+ 'price_loan' => ['title' => '贷款金额', 'width' => '10%'], 'c_time' => ['title' => '分期时间', 'width' => '7%'],
+ 'cf_title' => ['title' => '来源类型', 'width' => '10%'], 'cf_name' => ['title' => '来源','width' => '10%'],
+ 'status_name' => ['title' => '状态', 'width' => '10%']];
+ $fields = array_merge($fields1, $fields2);
+ } else if ($status_pid == 2 || $status_pid == 3 || $status_pid == 4 || $status_pid == 5) {
+ $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%']];
+ $status_pid==4 && $fields2['u_time'] = ['title'=>'更新时间','width'=>'9%'];
+ $fields = array_merge($fields1, $fields2);
+ } 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;
+ }
+ /*
+ * 导出数据
+ */
+ public function export_data($pid,$params){
+ $indexs = [
+ 'name' => '客户姓名',
+ 'mobile' => '手机号',
+ 'c_time' => '订单时间',
+ 'bill_time' => '开票时间',
+ 'if_ins_db' => '是否代办',
+ 'company' => '保险公司',
+ 'business_risk' => '商业险金额',
+ 'ins_risk' => '交强险金额'
+ ];
+ $result = $this->lists($pid, $params);
+ foreach ($result['lists'] as $key => $value) {
+ $temp = [
+ 'name' => $value['name'],
+ 'mobile' => $value['mobile'],
+ 'c_time' => $value['c_time'],
+ 'if_ins_db' => '',
+ 'company' => '',
+ 'business_risk' => '',
+ 'ins_risk' => ''
+ ];
+ $temp['bill_time'] = $value['bill_time'] != '0000-00-00 00:00:00' ? $value['bill_time'] : '';
+ $agent = $this->ci->order_agents_model->get(['o_id' => $value['o_id']],'jsondata');
+ if($agent){
+ $agent_jsondata = $agent['jsondata'] ? json_decode($agent['jsondata'], true) : '';
+ if (isset($agent_jsondata['if_ins_db']) && $agent_jsondata['if_ins_db']) {
+ $temp['if_ins_db'] = '是';
+ isset($agent_jsondata['company']) && $temp['company'] = $agent_jsondata['company'];
+ isset($agent_jsondata['ins_risk']) && $temp['ins_risk'] = $agent_jsondata['ins_risk'];
+ isset($agent_jsondata['business_risk']) && $temp['business_risk'] = $agent_jsondata['business_risk'];
+ }else{
+ $temp['if_ins_db'] = '否';
+ }
+ }
+ $data[] = $temp;
+ }
+ array_unshift($data, $indexs);
+ return ['data'=>$data,'indexs'=>$indexs];
+ }
+
+}
+
+?>
diff --git a/admin/views/auto/business/get.php b/admin/views/auto/business/get.php
new file mode 100644
index 00000000..1925492d
--- /dev/null
+++ b/admin/views/auto/business/get.php
@@ -0,0 +1,300 @@
+
| + + ID + | +裸车报价 | +车辆底价 | +单车利润 | +保险利润 | +贷款利润 | +挂牌利润 | + +城市 | +时间 | +生效时间 | +是否生效 | +操作 | +
|---|---|---|---|---|---|---|---|---|---|---|---|
| 车型:{{v.title}} | +|||||||||||
| + + {{v.id}} + | +{{v.price_car}} | +{{v.price_floor}} | +{{v.profix_car}} | +{{v.profix_insure}} | +{{v.profix_loan}} | +{{v.profix_carno}} | + +{{v.city_cn}} | +{{v.month}} | +{{v.s_effect_time}} | +{{v.effect_status}} | ++ + 复制 + + 编辑 + 关闭 + 开启 + | +
| + ID + | +门店 | +订单信息 | +单车利润 | +保险利润 | +贷款利润 | +挂牌利润 | +拖车费 | +时间 | +
|---|---|---|---|---|---|---|---|---|
| + {{v.id}} + | +{{v.biz_name}} | +
+
+ {{v.name}} {{v.mobile}} + {{v.title}} {{v.vin}} + + |
+ {{v.profix_car}} | +{{v.profix_insure}} | +{{v.profix_loan}} | +{{v.profix_carno}} | +{{v.price_trucking}} | +{{v.month}} | +
| + ID + | +门店 | +单车总毛利 | +税后单车总毛利 | +水平业务总毛利 | +门店费用 | +其它费用 | +总利润 | +分润 | +时间 | +操作 | +
|---|---|---|---|---|---|---|---|---|---|---|
| + {{v.id}} + | +{{v.biz_name}} | +{{v.profix_car}} | +{{v.profix_car_after}} | +{{v.price_all}} | +
+ 店面租金:{{v.rent}} + 水电费:{{v.wat_ele}} + 店长工资:{{v.manager_wage}} + 店员工资:{{v.employee_wage}} + 抽成:{{v.commission}} + 拖车费:{{v.price_trucking}} + 总费用:{{v.total_need}} + |
+
+
+ {{item.name}}:{{item.money}}({{type_arr[item.type]}}) + + |
+ {{v.price_ml}} | +
+ 狸车分润:{{v.profix_liche}} + 合伙人分润:{{v.profix_partner}} + |
+ {{v.month_str}} | +
+ 查看明细 + 新增费用 + 重新结算 + |
+