diff --git a/admin/controllers/auto/Finance.php b/admin/controllers/auto/Finance.php
index bf2c70b5..c7f612c8 100644
--- a/admin/controllers/auto/Finance.php
+++ b/admin/controllers/auto/Finance.php
@@ -16,7 +16,8 @@ class Finance extends HD_Controller{
$this->load->model('auto/auto_cars_model');
$this->load->model('auto/auto_finance_model');
- $this->load->model('sys/sys_finance_model');
+ //$this->load->model('sys/sys_finance_model');
+ $this->load->model('sys/sys_supplier_model');
}
public function index(){
@@ -50,7 +51,8 @@ class Finance extends HD_Controller{
$select = "$t1.id,$t1.car_id,$t1.fin_id,$t1.num,$t1.month_pay,$t1.first_pay,$t1.srv_pay,$t1.status";
$rows = $this->auto_finance_model->select_finance($where, 'id desc', $page, $size, $select);
$fin_id_arr = array_column($rows,'fin_id');
- $fin_rows = $this->sys_finance_model->get_map_by_ids($fin_id_arr,'id,title');
+ //$fin_rows = $this->sys_finance_model->get_map_by_ids($fin_id_arr,'id,title');
+ $fin_rows = $this->sys_supplier_model->get_map_by_ids($fin_id_arr,'id,title');
foreach($rows as $key=>$val){
$lists[] = [
'id' => $val['id'],
@@ -94,7 +96,8 @@ class Finance extends HD_Controller{
$info['status'] = $row['status'];
}
$nums = $this->auto_finance_model->get_nums();
- $finance = $this->sys_finance_model->select(['status'=>1],'id desc',1,20,'id,title');
+ //$finance = $this->sys_finance_model->select(['status'=>1],'id desc',1,20,'id,title');
+ $finance = $this->sys_supplier_model->select(['status'=>1, 'type'=>3],'id desc',0,0,'id,title');
!$info['fin_id'] && $info['fin_id'] = $finance[0]['id'];
!$info['num'] && $info['num'] = $nums[0];
!isset($info['status']) && $info['status'] = 1;
@@ -120,8 +123,9 @@ class Finance extends HD_Controller{
}
$row = $this->auto_finance_model->get(['car_id'=>$info['car_id'],'num'=>$info['num'],'fin_id'=>$info['fin_id']]);
if($row){
- $finance = $this->sys_finance_model->get(['id'=>$info['fin_id']]);
- return $this->show_json(SYS_CODE_FAIL, "该车已配置:{$finance['title']}金融-{$info['num']}期");
+ //$finance = $this->sys_finance_model->get(['id'=>$info['fin_id']]);
+ $finance = $this->sys_supplier_model->get(['id'=>$info['fin_id']]);
+ return $this->show_json(SYS_CODE_FAIL, "该车已配置:{$finance['title']}-{$info['num']}期");
}
$adata = [
'car_id' => $info['car_id'],
@@ -154,8 +158,9 @@ class Finance extends HD_Controller{
}
$row = $this->auto_finance_model->get(['car_id'=>$info['car_id'],'num'=>$info['num'],'fin_id'=>$info['fin_id'],'id !='=>$info['id']]);
if($row){
- $finance = $this->sys_finance_model->get(['id'=>$info['fin_id']]);
- return $this->show_json(SYS_CODE_FAIL, "该车已配置:{$finance['title']}金融-{$info['num']}期");
+ //$finance = $this->sys_finance_model->get(['id'=>$info['fin_id']]);
+ $finance = $this->sys_supplier_model->get(['id'=>$info['fin_id']]);
+ return $this->show_json(SYS_CODE_FAIL, "该车已配置:{$finance['title']}-{$info['num']}期");
}
$adata = [
'car_id' => $info['car_id'],
diff --git a/admin/controllers/biz/Srv.php b/admin/controllers/biz/Srv.php
index be69cc0d..2199694f 100644
--- a/admin/controllers/biz/Srv.php
+++ b/admin/controllers/biz/Srv.php
@@ -6,10 +6,11 @@ class Srv extends HD_Controller{
public function __construct(){
parent::__construct();
$this->load->model('auto/auto_business_model');
-
+ $this->load->model('auto/auto_finance_model');
$this->load->model('biz/biz_model');
$this->load->model('biz/biz_settle_srv_model');
- $this->load->model('sys/sys_finance_model');
+ //$this->load->model('sys/sys_finance_model');
+ $this->load->model('sys/sys_supplier_model');
}
public function index()
@@ -20,6 +21,7 @@ class Srv extends HD_Controller{
public function lists(){
$params = $this->input->get();
$params['id'] && $_SESSION['srv_biz_id'] = $params['id'];
+ !$params['insure_type'] && $params['insure_type'] = '';
!$params['type'] && $params['type'] = '';
!$params['title'] && $params['title'] = '';
!strlen($params['status']) && $params['status'] = '';
@@ -30,12 +32,13 @@ class Srv extends HD_Controller{
'biz_id' => $_SESSION['srv_biz_id']
];
strlen($params['status']) && $where['status'] = $params['status'];
+ $params['insure_type'] && $where["json_extract(jsondata, '$.type') = '{$params['insure_type']}'"] = null;
$params['type'] && $where['type'] = $params['type'];
$params['title'] && $where['title'] = $params['title'];
$count = $this->biz_settle_srv_model->count($where);
$lists = [];
if($count){
- $rows = $this->biz_settle_srv_model->select($where, 'is_def desc,id desc', $page, $pagesize);
+ $rows = $this->biz_settle_srv_model->select($where, 'status desc, title, is_def desc, id desc', $page, $pagesize);
$biz_ids = array_unique(array_column($rows,'biz_id'));
$map_biz = [];
if(is_array($biz_ids)){
@@ -63,7 +66,8 @@ class Srv extends HD_Controller{
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['typeAry'] = $this->biz_settle_srv_model->get_type();
- $this->data['_title'] = '门店列表';
+ $this->data['insure_typeAry'] = $this->biz_settle_srv_model->get_insure_type();
+ $this->data['_title'] = '门店水平业务列表';
$this->data['pager'] = array('count' => ceil($count / $pagesize), 'curr' => $page, 'totle' => $count);
$this->show_view('biz/srv/lists', true);
}
@@ -74,18 +78,24 @@ class Srv extends HD_Controller{
$type = $this->input->get('type');
!$type && $type = 1;
if(!$biz_id){
- return $this->show_json(SYS_CODE_FAIL,'参数错误');
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请刷新列表再重新操作');
}
$row = $this->biz_settle_srv_model->get(['id'=>$id]);
- $finances = $this->sys_finance_model->select(['status' => 1], '', 0, 0, 'id,title');
+ $row && $type = $row['type'];
+ $supplier = $this->sys_supplier_model->select(['status' => 1, 'type' => $type], '', 0, 0, 'id,title');
+ //$finances_num = $this->sys_finance_model->get_nums();
+ $finances_num = $this->auto_finance_model->get_nums();
$info = [
'biz_id' => $biz_id,
'type' => $type,
'is_def' => 0,
's_effect_time' => date('Y-m-d'),
'action' => 'biz/srv/add',
- 'jsondata' => ['price'=>300,'type'=>1,'finance_id'=>$finances[0]['id'],'finance_num'=>12]
+ 'is_tiexi' => 0,
+ 'step' => 1, # 1仅用于新增时默认第一步,2为第二步
+ 'jsondata' => ['price'=>300,'type'=>1, 'supplier_id'=>$supplier[0] ? $supplier[0]['id'] : 0,'finance_num'=>$finances_num ? $finances_num[0]: null]
];
+ $view = 'biz/srv/get';
if($row){
$info['title'] = $row['title'];
$info['id'] = $row['id'];
@@ -96,55 +106,78 @@ class Srv extends HD_Controller{
$jsondata = json_decode($row['jsondata'],true);
$jsondata['s_time'] && $jsondata['s_time'] = date('Y-m-d H:i:s',$jsondata['s_time']);
$jsondata['e_time'] && $jsondata['e_time'] = date('Y-m-d H:i:s',$jsondata['e_time']);
+ $info['is_tiexi'] = $row['type'] == 3 && intval($jsondata['rebate']) > 0 ? 1 : 0;
+ $jsondata['supplier_id'] = $jsondata['supplier_id'] ? intval($jsondata['supplier_id']) : 0;
$info['jsondata'] = $jsondata;
+ $view = 'biz/srv/edit';
}
$this->data['yearAry'] = $this->auto_business_model->year();
$this->data['monthAry'] = $this->auto_business_model->month();
- $this->data['finances'] = $finances;
- $this->data['finances_num'] = $this->sys_finance_model->get_nums();
+ $this->data['finances_num'] = $finances_num;
+ $this->data['supplier'] = $supplier;
$this->data['info'] = $info;
$this->data['typeAry'] = $this->biz_settle_srv_model->get_type();
- $this->show_view('biz/srv/get');
+ $this->data['insure_typeAry'] = $this->biz_settle_srv_model->get_insure_type();
+ $this->show_view($view);
}
public function add(){
$info = $this->input->post('info');
+ if (!$info['jsondata']['supplier_id']){
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请先配置供应商');
+ }
+ if ($info['type'] == 2 && !$info['is_def'] && (!$info['s_time'] || !$info['e_time'])){
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请填写时间区间');
+ }
$data = [
'biz_id' => $info['biz_id'],
'c_time' => time(),
'type' => $info['type'],
'is_def' => $info['is_def'] ? 1 : 0,
];
- $info['title'] && $data['title'] = $info['title'];
$info['s_effect_time'] && $data['s_effect_time'] = date('Y-m-d',strtotime($info['s_effect_time']));
$jsondata = [];
+ $jsondata['supplier_id'] = $info['jsondata']['supplier_id'];
+ $supplier = $this->sys_supplier_model->get(['id'=>intval($jsondata['supplier_id'])],'title');
+ $jsondata['supplier_title'] = $supplier['title'];
+ $data['title'] = $jsondata['supplier_title'];
+
if($info['type']==1){
$jsondata['price'] = floatval($info['jsondata']['price']);
}elseif($info['type']==2){
- $info['s_time'] && $jsondata['s_time'] = strtotime($info['s_time']);
- $info['e_time'] && $jsondata['e_time'] = strtotime($info['e_time']);
- $jsondata['rebate'] = $info['jsondata']['rebate'];
+ if ($info['is_def'] == 1){
+ unset($jsondata['s_time']);
+ unset($jsondata['e_time']);
+ }
+ else{
+ $info['s_time'] && $jsondata['s_time'] = strtotime($info['s_time']);
+ $info['e_time'] && $jsondata['e_time'] = strtotime($info['e_time']);
+ }
+ $jsondata['rebate'] = intval($info['jsondata']['rebate']);
$jsondata['type'] = $info['jsondata']['type'];
}else{
- $jsondata['rebate'] = $info['jsondata']['rebate'];
- $jsondata['finance_id'] = $info['jsondata']['finance_id'];
+ $jsondata['rebate'] = $info['is_tiexi'] ? intval($info['jsondata']['rebate']) : 0;
$jsondata['finance_num'] = $info['jsondata']['finance_num'];
- $finance = $this->sys_finance_model->get(['id'=>intval($jsondata['finance_id'])],'title');
- $jsondata['finance_title'] = $finance['title'];
- $data['title'] = $jsondata['finance_title'];
}
//只能有一条默认
if($info['is_def']){
$where = [
'biz_id' => $info['biz_id'],
- 'title' => $info['title'],
+ 'title' => $data['title'],
'type' => $info['type'],
+ 'status' => 1,
'is_def' => 1
];
+ $update = ['is_def'=>0];
if($info['type']==2){
$where["json_extract(jsondata, '$.type') = '{$info['jsondata']['type']}'"] = null;
+ $update['status'] = 0;
}
- $this->biz_settle_srv_model->update(['is_def'=>0],$where);
+ if($info['type']==3){
+ $where["json_extract(jsondata, '$.finance_num') = '{$info['jsondata']['finance_num']}'"] = null;
+ }
+
+ $this->biz_settle_srv_model->update($update,$where);
}
$data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
$res = $this->biz_settle_srv_model->add($data);
@@ -159,42 +192,63 @@ class Srv extends HD_Controller{
$info = $this->input->post('info');
$row = $this->biz_settle_srv_model->get(['id'=>$info['id']]);
if(!$row){
- return $this->show_json(SYS_CODE_FAIL,'参数错误');
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请刷新列表再重新操作');
+ }
+ if (!$info['jsondata']['supplier_id']){
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请先配置供应商');
+ }
+ if ($info['type'] == 2 && !$info['is_def'] && (!$info['s_time'] || !$info['e_time'])){
+ return $this->show_json(SYS_CODE_FAIL,'参数错误,请填写时间区间');
}
$jsondata = json_decode($row['jsondata'],true);
$data = [
'type' => $info['type'],
'is_def' => $info['is_def'] ? 1 : 0,
];
- $info['title'] && $data['title'] = $info['title'];
$info['s_effect_time'] && $data['s_effect_time'] = date('Y-m-d',strtotime($info['s_effect_time']));
+
+ $jsondata['supplier_id'] = $info['jsondata']['supplier_id'];
+ $supplier = $this->sys_supplier_model->get(['id'=>intval($jsondata['supplier_id'])],'title');
+ $jsondata['supplier_title'] = $supplier['title'];
+ $data['title'] = $jsondata['supplier_title'];
+
if($info['type']==1){
$jsondata['price'] = floatval($info['jsondata']['price']);
+
}elseif($info['type']==2){
- $info['s_time'] && $jsondata['s_time'] = strtotime($info['s_time']);
- $info['e_time'] && $jsondata['e_time'] = strtotime($info['e_time']);
- $jsondata['rebate'] = $info['jsondata']['rebate'];
+ if ($info['is_def'] == 1){
+ unset($jsondata['s_time']);
+ unset($jsondata['e_time']);
+ }
+ else{
+ $info['s_time'] && $jsondata['s_time'] = strtotime($info['s_time']);
+ $info['e_time'] && $jsondata['e_time'] = strtotime($info['e_time']);
+ }
+ $jsondata['rebate'] = intval($info['jsondata']['rebate']);
$jsondata['type'] = $info['jsondata']['type'];
}else{
- $jsondata['rebate'] = $info['jsondata']['rebate'];
- $jsondata['finance_id'] = $info['jsondata']['finance_id'];
+ $jsondata['rebate'] = $info['is_tiexi'] ? intval($info['jsondata']['rebate']) : 0;
$jsondata['finance_num'] = $info['jsondata']['finance_num'];
- $finance = $this->sys_finance_model->get(['id'=>intval($jsondata['finance_id'])],'title');
- $jsondata['finance_title'] = $finance['title'];
- $data['title'] = $jsondata['finance_title'];
}
//只能有一条默认
- if($info['is_def']){
+ if($info['is_def'] && $row['status'] == 1){
$where = [
'biz_id' => $info['biz_id'],
- 'title' => $info['title'],
+ 'title' => $data['title'],
'type' => $info['type'],
+ 'status' => 1,
'is_def' => 1,
+ "id != {$info['id']}" => null,
];
+ $update = ['is_def'=>0];
if($info['type']==2){
$where["json_extract(jsondata, '$.type') = '{$info['jsondata']['type']}'"] = null;
+ $update['status'] = 0;
}
- $this->biz_settle_srv_model->update(['is_def'=>0],$where);
+ if($info['type']==3){
+ $where["json_extract(jsondata, '$.finance_num') = '{$info['jsondata']['finance_num']}'"] = null;
+ }
+ $this->biz_settle_srv_model->update($update,$where);
}
$data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE);
$res = $this->biz_settle_srv_model->update($data,['id'=>$info['id']]);
@@ -228,6 +282,34 @@ class Srv extends HD_Controller{
$this->show_json(0, '参数错误');
}
$where['id'] = $id;
+
+ # 参考edit处理:修改状态为正常 + 当前数据为默认
+ if ($status == 1){
+ $row = $this->biz_settle_srv_model->get(['id'=>$id]);
+ $jsondata = json_decode($row['jsondata'],true);
+ if($row['is_def']){
+ $where_u = [
+ 'biz_id' => $row['biz_id'],
+ 'title' => $row['title'],
+ 'type' => $row['type'],
+ 'status' => 1,
+ 'is_def' => 1,
+ "id != {$id}" => null,
+ ];
+ $update = ['is_def'=>0];
+ if($row['type']==2){
+ $where["json_extract(jsondata, '$.type') = '{$jsondata['type']}'"] = null;
+ $update['status'] = 0;
+ }
+ if($row['type']==3){
+ $where["json_extract(jsondata, '$.finance_num') = '{$jsondata['finance_num']}'"] = null;
+ }
+ $this->biz_settle_srv_model->update($update,$where_u);
+ }
+ if ($row['type']==2 && !$row['is_def'] && (!$jsondata['s_time'] || !$jsondata['e_time'])){
+ return $this->show_json(SYS_CODE_FAIL,'请先修改,填写时间区间后,再操作');
+ }
+ }
}
$data['status'] = $status;
$this->biz_settle_srv_model->update($data, $where);
@@ -246,7 +328,7 @@ class Srv extends HD_Controller{
'biz_id' => $biz_id,
'status' => 1
];
- $rows = $this->biz_settle_srv_model->select_groupby('title', $where, '', 0, 20, 'id,title');
+ $rows = $this->biz_settle_srv_model->select_groupby('title', $where, 'is_def desc, id desc', 0, 0, 'id,title');
$this->data['lists'] = $rows;
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
diff --git a/admin/controllers/receiver/Orders.php b/admin/controllers/receiver/Orders.php
index c94dc025..d767dc88 100644
--- a/admin/controllers/receiver/Orders.php
+++ b/admin/controllers/receiver/Orders.php
@@ -20,7 +20,8 @@ class Orders extends HD_Controller
$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_finance_model');
+ $this->load->model('sys/sys_supplier_model');
$this->load->model('sys/sys_company_model');
$this->load->model('app/liche/app_liche_orders_model');
@@ -178,8 +179,10 @@ class Orders extends HD_Controller
$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['finance_rows_nums'] = $this->sys_finance_model->get_nums();
+ //$loan['finance_rows'] = $this->sys_finance_model->select(['status' => 1], '', 0, 0, 'id,title');
+ //$loan['finance_rows_nums'] = $this->sys_finance_model->get_nums();
+ $loan['finance_rows'] = $this->sys_supplier_model->select(['status' => 1, 'type'=>3], '', 0, 0, 'id,title');
+ $loan['finance_rows_nums'] = $this->auto_finance_model->get_nums();
$loan['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : '';
$loan['first_pay'] = 0;
if ($money_json['price_loan']) {
diff --git a/admin/controllers/receiver/orderv2/Orders.php b/admin/controllers/receiver/orderv2/Orders.php
index a20232a4..22fb6145 100644
--- a/admin/controllers/receiver/orderv2/Orders.php
+++ b/admin/controllers/receiver/orderv2/Orders.php
@@ -22,7 +22,8 @@ class Orders extends HD_Controller
$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_finance_model');
+ $this->load->model('sys/sys_supplier_model');
$this->load->model('sys/sys_company_model');
$this->load->model("sys/sys_area_model");
$this->load->model('app/liche/app_liche_orders_model');
@@ -431,7 +432,8 @@ class Orders extends HD_Controller
$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['finance_rows'] = $this->sys_finance_model->select(['status' => 1], '', 0, 0, 'id,title');
+ $loan['finance_rows'] = $this->sys_supplier_model->select(['status' => 1, 'type'=>3], '', 0, 0, 'id,title');
$loan['price_loan'] = $money_json['price_loan'] ? $money_json['price_loan'] : '';
$loan['first_pay'] = 0;
if ($money_json['price_loan']) {
diff --git a/admin/controllers/sys/Supplier.php b/admin/controllers/sys/Supplier.php
new file mode 100644
index 00000000..331535ab
--- /dev/null
+++ b/admin/controllers/sys/Supplier.php
@@ -0,0 +1,264 @@
+load->model("sys/sys_supplier_model", 'supplier_model');
+ $this->load->model('biz/biz_settle_srv_model');
+
+ $this->log_dir = 'sys_' . get_class($this);
+ }
+
+ public function index(){
+ return $this->lists();
+ }
+
+ public function lists(){
+ $params = $this->input->get();
+
+ $where = array();
+ if ($params['keyword']){
+ $params['keyword'] = trim($params['keyword']);
+ $where["(title like '%{$params['keyword']}%' or short like '%{$params['keyword']}%')"] = null;
+ }
+
+ if(strlen($params['status']) > 0){
+ $where['status'] = $params['status'];
+ } else {
+ $params['status'] = '';
+ }
+
+ if($params['type']){
+ $where['type'] = $params['type'];
+ } else {
+ $params['type'] = '';
+ }
+
+ $page = $params['page'];
+ $page = !$page ? 1 : $page;
+ $size = $params['size'];
+ $size = !$size ? 20 : $size;
+
+ $statusAry = $this->supplier_model->status_ary();
+ $typeAry = $this->supplier_model->type_ary();
+
+ $count = $this->supplier_model->count($where);
+ $lists = array();
+ if($count){
+ $orderby = 'status desc, id desc';
+ $select = '*';
+ $rows = $this->supplier_model->select($where, $orderby, $page, $size, $select);
+ foreach($rows as $k => $v){
+ $lists[] = array(
+ 'id' => $v['id'],
+ 'title' => $v['title'],
+ 'short' => $v['short'],
+ 'type' => $v['type'],
+ 'type_name' => $typeAry[$v['type']],
+ 'jsondata' => json_decode($v['jsondata'], true),
+ 'status' => $v['status'],
+ 'status_name' => $statusAry[$v['status']],
+ 'c_time' => date('Y-m-d H:i:s', $v['c_time'])
+ );
+ }
+ }
+
+ $this->data['params'] = $params;
+ $this->data['lists'] = $lists;
+ $this->data['statusAry'] = $statusAry;
+ $this->data['typeAry'] = $typeAry;
+ $this->data['pager'] = array('count'=>ceil($count/$size),'curr'=>$page,'totle'=>$count);
+ $this->data['_title'] = '供应商';
+ $this->show_view('sys/supplier/lists',true);
+ }
+
+ public function get(){
+ $id = $this->input->get('id');
+ if($id){
+ $row = $this->supplier_model->get(array('id' => $id));
+ $info = array(
+ 'id' => $row['id'],
+ 'title' => $row['title'],
+ 'short' => $row['short'],
+ 'type' => $row['type'],
+ 'jsondata' => json_decode($row['jsondata'], true),
+ 'status' => $row['status'],
+ );
+ $action = '/sys/supplier/edit';
+ $title = '编辑供应商';
+ } else {
+ $info = array(
+ 'title' => '',
+ 'short' =>'',
+ 'type' => 1,
+ 'status' => 0,
+ );
+ $action = '/sys/supplier/add';
+ $title = '新增供应商';
+ }
+
+ $this->data['info'] = $info;
+ $this->data['action'] = $action;
+ $this->data['statusAry'] = $this->supplier_model->status_ary();
+ $this->data['typeAry'] = $this->supplier_model->type_ary();
+ $this->data['_title'] = $title;
+ $this->show_view('sys/supplier/get');
+ }
+
+ public function add(){
+ $info = $this->input->post('info');
+
+ $type = trim($info['type']);
+ if(!$type){
+ return $this->show_json(SYS_CODE_FAIL, '请选择供应商类型');
+ }
+
+ $title = trim($info['title']);
+ if(!$title){
+ return $this->show_json(SYS_CODE_FAIL, '请输入供应商名字');
+ }
+ $where = array("title like '%{$title}%'" => null, "type" => $type);
+ $count = $this->supplier_model->count($where);
+ if($count>0){
+ return $this->show_json(SYS_CODE_FAIL, '供应商已经存在');
+ }
+
+ $short = trim($info['short']);
+ $short = $this->short_check($short, $type, $info['id']);
+
+ $add = array(
+ 'title' => $title,
+ 'short' => $short,
+ 'jsondata' => json_encode(array()),
+ 'type' => intval($type),
+ 'status' => intval($info['status']),
+ 'c_time' => time(),
+ );
+
+ $id = $this->supplier_model->add($add);
+ if(!$id){
+ debug_log("[error]# " . $this->supplier_model->db->last_query(), __FUNCTION__, $this->log_dir);
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ public function edit(){
+ $info = $this->input->post('info');
+
+ $row = $this->supplier_model->get(array('id' => $info['id']));
+ if (!$row){
+ return $this->show_json(SYS_CODE_FAIL, '参数错误:ID不存在');
+ }
+
+ $type = trim($info['type']);
+ if(!$type){
+ return $this->show_json(SYS_CODE_FAIL, '请选择供应商类型');
+ }
+
+ $title = trim($info['title']);
+ if(!$title){
+ return $this->show_json(SYS_CODE_FAIL, '请输入供应商名字');
+ }
+ $where = array("title like '%{$title}%'" => null, "type" => $type, "id<>{$info['id']}" => null);
+ $count = $this->supplier_model->count($where);
+ if($count>0){
+ return $this->show_json(SYS_CODE_FAIL, '供应商已经存在');
+ }
+
+ $short = trim($info['short']);
+ $short = $this->short_check($short, $type, $info['id']);
+
+ $upd = array(
+ 'title' => $title,
+ 'short' => $short,
+ 'jsondata' => json_encode(array()),
+ 'type' => intval($type),
+ 'status' => intval($info['status']),
+ );
+
+ $ret = $this->supplier_model->update($upd, array('id' => $info['id']));
+ if(!$ret){
+ debug_log("[error]# " . $this->supplier_model->db->last_query(), __FUNCTION__, $this->log_dir);
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+
+ # title修改要同步
+ if ($row['title'] != $title){
+ $upd = array(
+ 'title' => $title,
+ "jsondata = json_set(jsondata, '$.supplier_title', '{$title}')" => null,
+ );
+ $where = array(
+ 'type' => intval($type),
+ "JSON_UNQUOTE(json_extract(jsondata, '$.supplier_id')) = '{$info['id']}'" => null,
+ );
+ $this->biz_settle_srv_model->update($upd, $where);
+ }
+
+ return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
+ }
+
+ private function short_check($short='', $type=2, $id=0){
+ $short = trim($short);
+ if (!$short){
+ return $short;
+ }
+
+ $short = str_replace(',',',', $short);
+ $short = str_replace(' ',',', $short);
+ $short = str_replace(' ',',', $short);
+ $shorts = explode(',', $short);
+ $shorts_new = array();
+ foreach ($shorts as $short){
+ if (!$short){
+ continue;
+ }
+ $shorts_new[] = $short;
+ $where = array("short like '%{$short}%'" => null, "type" => $type);
+ $id && $where["id<>{$id}"] = null;
+ $count = $this->supplier_model->count($where);
+ if($count>0){
+ $this->show_json(SYS_CODE_FAIL, "简称'{$short}'已经存在");exit();
+ }
+ }
+ $short = implode(',', $shorts_new);
+ return $short;
+ }
+
+ function edit_status(){
+ $id = $this->input->post('id');
+ $status = $this->input->post('status');
+
+ $upd = array('status' => $status);
+ $where = array('id' => $id);
+
+ $ret = $this->supplier_model->update($upd, $where);
+ if(!$ret){
+ debug_log("[error]# " . $this->supplier_model->db->last_query(), __FUNCTION__, $this->log_dir);
+ return $this->show_json(SYS_CODE_FAIL, '保存失败');
+ }
+
+ 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.
+ }
+}
diff --git a/admin/libraries/OrdersList.php b/admin/libraries/OrdersList.php
index 38e80e4c..ff6b4e6f 100644
--- a/admin/libraries/OrdersList.php
+++ b/admin/libraries/OrdersList.php
@@ -596,7 +596,6 @@ class OrdersList
$count = $this->ci->order_loans_model->count_order($where, $t2);
$lists = [];
if ($count) {
- $this->ci->load->model('sys/sys_finance_model');
$fileds = "$t1.o_id,$t1.title,$t1.year,$t1.first_price,$t1.status,$t1.c_time,";
$fileds .= "$t2.rid,$t2.id,$t2.name,$t2.mobile,$t2.sid,$t2.finance_id,$t2.money_json,$t2.bill_time,$t2.admin_id";
$rows = $this->ci->order_loans_model->select_order($where, "$t2.c_time desc", $page, $size, $fileds);
@@ -606,7 +605,10 @@ class OrdersList
$customers = $this->ci->mdCustomers->map('id', 'of_id,of2_id', array("id in({$str_rids})" => null));
$offlineSources = $this->ci->mdCustomers->offlineSources();
$finance_arr = array_column($rows, 'finance_id');
- $finance_rows = $this->ci->sys_finance_model->get_map_by_ids($finance_arr, 'id,title');
+ //$this->ci->load->model('sys/sys_finance_model');
+ //$finance_rows = $this->ci->sys_finance_model->get_map_by_ids($finance_arr, 'id,title');
+ $this->ci->load->model('sys/sys_supplier_model');
+ $finance_rows = $this->ci->sys_supplier_model->get_map_by_ids($finance_arr, 'id,title');
//获取销售
$str_admin_ids = implode(',', array_unique(array_column($rows, 'admin_id')));
!$str_admin_ids && $str_admin_ids = 0;
diff --git a/admin/libraries/Ordersv2List.php b/admin/libraries/Ordersv2List.php
index 501ef4ce..e93e2d53 100644
--- a/admin/libraries/Ordersv2List.php
+++ b/admin/libraries/Ordersv2List.php
@@ -28,7 +28,8 @@ class Ordersv2List
$this->ci->load->model('auto/auto_attr_model');
$this->ci->load->model('items/items_model', 'mdItems');
$this->ci->load->model('area_model');
- $this->ci->load->model('sys/sys_finance_model');
+ //$this->ci->load->model('sys/sys_finance_model');
+ $this->ci->load->model('sys/sys_supplier_model');
$this->ci->load->library('receiver/orders_v2_entity');
$this->ci->load->library('receiver/orders_status_entity');
@@ -471,7 +472,8 @@ class Ordersv2List
$fields['address'] = $info_json['c_address'];
}
if(!$val['payway']){ //分期
- $finance_row = $this->ci->sys_finance_model->get(['id' => $val['finance_id']], 'id,title');
+ //$finance_row = $this->ci->sys_finance_model->get(['id' => $val['finance_id']], 'id,title');
+ $finance_row = $this->ci->sys_supplier_model->get(['id' => $val['finance_id'], 'type'=>3], 'id,title');
$is_sure = $this->ci->receiver_order_status_model->count(['o_id'=>$val['id'],'pid_status'=>1,'status'=>2]);
$finance_row && $fields['price'] = "{$fields['payway_name']}({$finance_row['title']})
{$fields['price_car']}";
$fields['pro_loan'] = $finance_row['title'];
diff --git a/admin/views/biz/srv/edit.php b/admin/views/biz/srv/edit.php
new file mode 100644
index 00000000..415f2a18
--- /dev/null
+++ b/admin/views/biz/srv/edit.php
@@ -0,0 +1,204 @@
+