sys_supplier about

This commit is contained in:
qianhy
2023-02-16 15:20:32 +08:00
committed by lccsw
parent 9ff05d6667
commit e3a27f1e41
23 changed files with 1115 additions and 134 deletions
+12 -7
View File
@@ -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'],
+113 -31
View File
@@ -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){
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'] = $info['jsondata']['rebate'];
}
$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){
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'] = $info['jsondata']['rebate'];
}
$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, '保存成功');
}
+6 -3
View File
@@ -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']) {
@@ -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']) {
+264
View File
@@ -0,0 +1,264 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* ref Finance.php
*/
class Supplier extends HD_Controller{
protected $log_dir;
function __construct(){
parent::__construct();
$this->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.
}
}
+4 -2
View File
@@ -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;
+4 -2
View File
@@ -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']})<br>{$fields['price_car']}";
$fields['pro_loan'] = $finance_row['title'];
+204
View File
@@ -0,0 +1,204 @@
<form id="vue-edit" class="am-form am-form-horizontal tab-content" action="/auto/cars/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto;">
<div class="tab-pane fade in active" id="swzc">
<div class="am-form-group wp50">
<label class="am-para-label">业务类型:</label>
<div class="am-para-input">
<select name="type" v-model="info.type" disabled>
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50" v-if="info.type==2">
<label class="am-para-label">保险类型:</label>
<div class="am-para-input">
<select v-model="info.jsondata.type" disabled>
<option v-for="(v,i) in insure_typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50">
<label class="am-para-label">供应商:</label>
<div class="am-para-input">
<select v-model="info.jsondata.supplier_id" :disabled="info.jsondata.supplier_id>0">
<option v-for="(item,key) in supplier" :value="item.id">{{item.title}}</option>
</select>
<input type="hidden" placeholder="供应商" v-model="info.title">
</div>
</div>
<template v-if="info.type==3">
<div class="am-form-group wp50">
<label class="am-para-label">期数:</label>
<div class="am-para-input">
<select v-model="info.jsondata.finance_num" :disabled="info.jsondata.finance_num>0">
<option v-for="item in finances_num" :value="item">{{item}}</option>
</select>
</div>
</div>
</template>
<div class="am-form-group wp50" v-if="info.type!=2">
<label class="am-para-label">生效时间:</label>
<div class="am-para-input">
<input type="text" placeholder="" id="id-time" v-model="info.s_effect_time" autocomplete="off"/>
</div>
</div>
<div class="am-form-group wp100">
<label class="am-para-label">是否默认:</label>
<div class="am-para-input">
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" v-model="info.is_def"/>
</div>
<span v-if="info.type==1">同个供应商,只能有一个默认值</span>
<span v-if="info.type==2">同个供应商 + 保险类型,只能有一个默认值</span>
<span v-if="info.type==3">同个供应商 + 同个期数,只能有一个默认值</span>
</div>
<template v-if="info.type==1">
<div class="am-form-group wp50" >
<label class="am-para-label">结算价:</label>
<div class="am-para-input">
<input type="number" placeholder="请输入结算价" name="price_insure" v-model="info.jsondata.price" style="display: inline;width: 60%"/>
<span></span>
</div>
</div>
</template>
<div class="am-form-group wp100" v-if="info.type==3">
<label class="am-para-label">是否贴息:</label>
<div class="am-para-input">
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" v-model="info.is_tiexi"/>
</div>
</div>
<template v-if="info.type==2 || info.type==3 && info.is_tiexi > 0">
<div class="am-form-group fl">
<label class="am-para-label">返点:</label>
<div class="input-group am-para-input w150">
<input type="number" placeholder="输入返点" v-model="info.jsondata.rebate">
<div class="input-group-addon">%</div>
</div>
</div>
<div class="am-form-group">
<div class="input-group am-para-input">
<span class="f12 clr999 lh-default ml5">百分比</span>
</div>
</div>
</template>
<div class="am-form-group" :style="{'display':info.type==2 && info.is_def==0 ? 'block':'none'}">
<label class="am-para-label">时间区间:</label>
<div class="am-para-input wp60">
<div class="am-para-inline w200">
<input type="text" placeholder="开始时间" autocomplete="off" value="<?=$info['jsondata']['s_time']?>" name="s_time" id="s-time">
</div>
<div class="am-para-inline w200">
<input type="text" placeholder="结束时间" autocomplete="off" value="<?=$info['jsondata']['e_time']?>" name="e_time" id="e-time">
</div>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
</div>
</form>
<script>
require(['laydate'], function (laydate) {
laydate.render({
elem: '#id-time'
});
//日期范围
laydate.render({
elem: '#s-time'
,type: 'datetime'
});
laydate.render({
elem: '#e-time'
,type: 'datetime'
});
});
var loading = 0;
var vue_obj;
$(function(){
vue_obj = new Vue({
el: '#vue-edit',
data: {
info : {jsondata:[]},
typeAry:[],
insure_typeAry:[],
yearAry:[],
monthAry:[],
finances_num:[],
supplier:[],
action:''
},
mounted:function(){
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.typeAry = <?=$typeAry ? json_encode($typeAry) : '[]'?>;
vm.insure_typeAry = <?=$insure_typeAry ? json_encode($insure_typeAry) : '[]'?>;
vm.action = '<?=$info['action']?>';
vm.yearAry = <?=json_encode($yearAry)?>;
vm.monthAry = <?=json_encode($monthAry)?>;
vm.finances_num = <?=json_encode($finances_num)?>;
vm.supplier = <?=json_encode($supplier)?>;
},
methods:{
saveEdit:function(){
var vm = this;
vm.info.s_effect_time = $("#id-time").val();
if(vm.info.type==2){
vm.info.s_time = $("#s-time").val();
vm.info.e_time = $("#e-time").val();
if (vm.info.is_def == 0){
if (vm.info.s_time == '' || vm.info.e_time == '') {
alert("请填写时间区间");
return false;
}
}
}
if(1 == loading){
return 0;
}
loading = 1;
$.ajax({
url: vm.action,
type: 'post',
dataType: 'json',
data: {info:vm.info},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
loading = 0;
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
layer.closeAll();
$.form.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
loading = 0;
layer.closeAll('loading');
}
});
}
},
watch:{
}
});
});
</script>
+71 -47
View File
@@ -1,30 +1,67 @@
<form id="vue-edit" class="am-form am-form-horizontal tab-content" action="/auto/cars/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto;">
<div class="tab-pane fade in active" id="swzc">
<div class="am-form-group wp50" v-if="info.type!=3">
<div class="am-form-group wp100" v-if="info.step<=2">
<b>第一步:选择供应商</b>
</div>
<div class="am-form-group wp50">
<label class="am-para-label">类型:</label>
<div class="am-para-input">
<select name="type" v-model="info.type" disabled>
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50" v-if="info.type==2">
<label class="am-para-label">保险类型:</label>
<div class="am-para-input">
<select v-model="info.jsondata.type" :disabled="info.step==2">
<option v-for="(v,i) in insure_typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50">
<label class="am-para-label">供应商:</label>
<div class="am-para-input">
<input type="text" placeholder="供应商" v-model="info.title">
<select v-model="info.jsondata.supplier_id" :disabled="info.step==2">
<option v-for="(item,key) in supplier" :value="item.id">{{item.title}}</option>
</select>
<input type="hidden" placeholder="供应商" v-model="info.title">
</div>
</div>
<template v-if="info.type==3">
<div class="am-form-group wp50">
<label class="am-para-label">期数:</label>
<div class="am-para-input">
<select v-model="info.jsondata.finance_num" :disabled="info.step==2">
<option v-for="item in finances_num" :value="item">{{item}}</option>
</select>
</div>
</div>
</template>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="nextstep" v-if="info.step==1" :disabled="info.type==3 && info.jsondata.supplier_id==0 && info.jsondata.finance_num > 0|| info.type!=3 && info.jsondata.supplier_id==0 && info.jsondata.finance_num > 0">点击进入下一步</button></div>
</div>
</div>
<div class="fade in tab-pane" v-show="info.step==2" :class="info.step==2?'active':''" id="swzc2">
<div class="am-form-group wp100" v-if="info.step<=2">
<b>第二步:配置业务数据</b>
</div>
<div class="am-form-group wp50" v-if="info.type!=2">
<label class="am-para-label">生效时间:</label>
<div class="am-para-input">
<input type="text" placeholder="" id="id-time" v-model="info.s_effect_time" autocomplete="off"/>
</div>
</div>
<div class="am-form-group wp50">
<label class="am-para-label">类型:</label>
<div class="am-para-input">
<select name="type" v-model="info.type">
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50">
<div class="am-form-group wp100">
<label class="am-para-label">是否默认:</label>
<div class="am-para-input">
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" v-model="info.is_def"/>
</div>
<span v-if="info.type!=2">同个业务类型下,同个供应商只能有一个默认值</span>
<span v-else>保险业务类型下,同个供应商只能有一个默认值,设置当前为默认值会自动下架其他</span>
</div>
<template v-if="info.type==1">
<div class="am-form-group wp50" >
@@ -36,7 +73,13 @@
</div>
</template>
<template v-if="info.type==2 || info.type==3">
<div class="am-form-group wp100" v-if="info.type==3">
<label class="am-para-label">是否贴息:</label>
<div class="am-para-input">
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" v-model="info.is_tiexi"/>
</div>
</div>
<template v-if="info.type==2 || info.type==3 && info.is_tiexi > 0">
<div class="am-form-group fl">
<label class="am-para-label">返点:</label>
<div class="input-group am-para-input w150">
@@ -52,18 +95,6 @@
</div>
</template>
<template v-if="info.type==2">
<div class="am-form-group">
<label class="am-para-label">保险类型:</label>
<div class="input-group am-para-input w150">
<select v-model="info.jsondata.type">
<option value="1">商业险</option>
<option value="2">交强险</option>
</select>
</div>
</div>
</template>
<div class="am-form-group" :style="{'display':info.type==2 ? 'block':'none'}" v-if="info.is_def==0">
<label class="am-para-label">时间区间:</label>
<div class="am-para-input wp60">
@@ -75,28 +106,9 @@
</div>
</div>
</div>
<template v-if="info.type==3">
<div class="am-form-group wp50">
<label class="am-para-label">产品:</label>
<div class="am-para-input">
<select v-model="info.jsondata.finance_id">
<option v-for="(item,key) in finances" :value="item.id">{{item.title}}</option>
</select>
</div>
</div>
<div class="am-form-group wp50">
<label class="am-para-label">期数:</label>
<div class="am-para-input">
<select v-model="info.jsondata.finance_num">
<option v-for="item in finances_num" :value="item">{{item}}</option>
</select>
</div>
</div>
</template>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-form-group" style="margin-bottom: 2rem" v-if="info.step>=2">
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
</div>
</form>
@@ -121,23 +133,25 @@
vue_obj = new Vue({
el: '#vue-edit',
data: {
info : [],
info : {jsondata:[]},
typeAry:[],
insure_typeAry:[],
yearAry:[],
monthAry:[],
finances:[],
finances_num:[],
supplier:[],
action:''
},
mounted:function(){
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.typeAry = <?=$typeAry ? json_encode($typeAry) : '[]'?>;
vm.insure_typeAry = <?=$insure_typeAry ? json_encode($insure_typeAry) : '[]'?>;
vm.action = '<?=$info['action']?>';
vm.yearAry = <?=json_encode($yearAry)?>;
vm.monthAry = <?=json_encode($monthAry)?>;
vm.finances = <?=json_encode($finances)?>;
vm.finances_num = <?=json_encode($finances_num)?>;
vm.supplier = <?=json_encode($supplier)?>;
},
methods:{
saveEdit:function(){
@@ -147,6 +161,12 @@
if(vm.info.type==2){
vm.info.s_time = $("#s-time").val();
vm.info.e_time = $("#e-time").val();
if (vm.info.is_def == 0){
if (vm.info.s_time == '' || vm.info.e_time == '') {
alert("请填写时间区间");
return false;
}
}
}
if(1 == loading){
return 0;
@@ -181,6 +201,10 @@
layer.closeAll('loading');
}
});
},
nextstep:function(){
var vm = this;
vm.info.step = 2;
}
},
watch:{
+16 -3
View File
@@ -14,6 +14,15 @@
<form class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/biz/srv/lists">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl" v-if="params.type==2">
<label class="am-para-label w80">保险类型:</label>
<div class="am-para-inline w100">
<select name="insure_type" v-model="params.insure_type">
<option value="">请选择</option>
<option v-for="(v,i) in insure_typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w80">状态:</label>
<div class="am-para-inline w100">
@@ -38,7 +47,7 @@
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml20">
<button data-title="新增" type="button" :data-modal="'/biz/srv/get?type='+params.type" class="am-btn am-btn-success am-btn-sm w100">
<button :data-title="'新增-'+typeAry[params.type]" type="button" :data-modal="'/biz/srv/get?type='+params.type" class="am-btn am-btn-success am-btn-sm w100">
新增
</button>
</div>
@@ -66,7 +75,7 @@
<td><?= $v['id'] ?></td>
<td><?= $v['biz_name'] ?></td>
<td><?= $v['title'] ?></td>
<td>
<td style="text-align: left; margin-left: 20px">
<?foreach ($v['other_data'] as $k2 => $v2){?>
<?=$k2?>:<?= $v2 ?><br>
<?}?>
@@ -104,11 +113,15 @@
el: '#vue-app',
data: {
params: [],
titleAry:[]
titleAry:[],
typeAry:[],
insure_typeAry:[],
},
mounted: function () {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.typeAry = <?=json_encode($typeAry)?>;
vm.insure_typeAry = <?=json_encode($insure_typeAry)?>;
$.get('/biz/srv/get_title', {"type":<?=$params['type']?>},function(result){
if(result.code && result.data.lists){
vm.titleAry = result.data.lists
+97
View File
@@ -0,0 +1,97 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/supplier/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
<div class="am-form-group">
<label class="am-para-label">类型:</label>
<div class="am-para-input w100">
<select name="type" v-model="info.type">
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label"><span class="com-must-star">*</span>供应商:</label>
<div class="am-para-input"><input type="text" maxlength="64" placeholder="请输入供应商名称" name="title" v-model="info.title"/></div>
</div>
<template v-if="info.type==2">
<div class="am-form-group fl">
<label class="am-para-label">简称:</label>
<div class="am-para-input w200"><input type="text" maxlength="32" placeholder="请输入简称" name="short" v-model="info.short"/></div>
</div>
<div class="am-form-group">
<div class="input-group am-para-input">
<span class="f12 clr999 lh-default ml5">多个关键字用逗号或空格分隔</span>
</div>
</div>
</template>
<div class="am-form-group">
<label class="am-para-label">状态:</label>
<div class="am-para-input w100">
<select name="status" v-model="info.status">
<option v-for="(v,i) in statusAry" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
</div>
</form>
<script>
var loading = 0;
var vue_obj;
$(function(){
vue_obj = new Vue({
el: '#vue-edit',
data: {
info:{},
statusAry:[],
typeAry:[],
action:''
},
mounted:function(){
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
vm.typeAry = <?=json_encode($typeAry)?>;
vm.action = '<?=$action?>';
},
methods:{
saveEdit:function(){
var vm = this;
if(1 == loading){
return 0;
}
loading = 1;
$.ajax({
url: vm.action,
type: 'post',
dataType: 'json',
data: {info:vm.info},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
loading = 0;
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
window.location.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
loading = 0;
layer.closeAll('loading');
}
});
}
},
watch:{}
});
});
</script>
+103
View File
@@ -0,0 +1,103 @@
<div class="coms-table-wrap">
<div class="coms-table-hd clearfix no-border">
<form action="/sys/supplier/lists" class="form-search" onsubmit="return false">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w60">关键词:</label>
<div class="am-para-inline w200">
<input type="text" name="keyword" id="input" placeholder="输入供应商关键字" v-model="params.keyword"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w60">类型:</label>
<div class="am-para-inline w100">
<select name="type" v-model="params.type">
<option value="">请选择</option>
<option :value="i" v-for="(v,i) in typeAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w60">状态:</label>
<div class="am-para-inline w100">
<select name="status" v-model="params.status">
<option value="">请选择</option>
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group fl ml20">
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
<button data-modal="/sys/supplier/get" data-title="新增供应商" type="button" class="am-btn am-btn-success w100 am-btn-sm">新增</button>
</div>
</div>
</form>
</div>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="5%"><span>ID</span></th>
<th width="25%"><span>供应商</span></th>
<th width="12%"><span>创建时间</span></th>
<th width="10%"><span>类型</span></th>
<th width="10%"><span>状态</span></th>
<th width="10%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<tr v-for="(v,i) in lists">
<td>{{v.id}}</td>
<td>{{v.title}} <template v-if="v.short">{{v.short}}</template></td>
<td>{{v.c_time}}</td>
<td>{{v.type_name}}</td>
<td>{{v.status_name}}</td>
<td>
<a href="javascript:void(0);" :data-modal="'sys/supplier/get?id='+v.id" :data-title="'编辑-'+v.title"
class="am-btn am-btn-primary am-btn-xs">编辑</a>
<a data-ajax="post" data-action="/sys/supplier/edit_status" class="am-btn am-btn-danger am-btn-xs"
:data-params-id="v.id" :data-params-status="0" v-if="1==v.status">关闭</a>
<a data-ajax="post" data-action="/sys/supplier/edit_status" class="am-btn am-btn-success am-btn-xs"
:data-params-id="v.id" :data-params-status="1" v-if="0==v.status">开启</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
var vue_obj;
var loading = 0;
$(function(){
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params:[],
lists:[],
statusAry:[],
typeAry:[],
},
mounted:function() {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.lists = <?=json_encode($lists)?>;
vm.statusAry = <?=json_encode($statusAry)?>;
vm.typeAry = <?=json_encode($typeAry)?>;
},
methods:{},
watch:{}
});
<?php page_script($pager) ?>
});
</script>
+1 -1
View File
@@ -19,7 +19,7 @@ class Biz extends HD_Controller
$this->load->model('biz/biz_settle_srv_model');
$this->load->model('biz/biz_trucking_model');
$this->load->model('biz/biz_settle_price_model');
$this->load->model('sys/sys_finance_model');
//$this->load->model('sys/sys_finance_model');
$this->load->library('receiver/orders_v2_entity');
}
+97 -12
View File
@@ -315,6 +315,7 @@ class Order extends CI_Controller{
/**
* 添加成本数据
* @return void
* https://liche-api-dev.xiaoyu.com/plan/order/cost
*/
public function cost(){
$this->load->model('receiver/order/receiver_order_bills_model', 'order_bills_model');
@@ -324,7 +325,8 @@ class Order extends CI_Controller{
$this->load->model('biz/biz_settle_srv_model');
$this->load->model('auto/auto_business_model');
$this->load->model('items/items_cost_model');
$this->load->model('sys/sys_finance_model');
//$this->load->model('sys/sys_finance_model');
$this->load->model('sys/sys_supplier_model');
$page = $this->input->get('page');
$size = $this->input->get('size');
$id = $this->input->get('id');
@@ -339,6 +341,17 @@ class Order extends CI_Controller{
$id && $where['id'] = $id;
$rows = $this->receiver_orders_v2_model->select($where,'',$page,$size);
if($rows){
$supplier2 = $this->sys_supplier_model->select(['status' => 1, 'type' => 2], '', 0, 0, 'id,title,short');
/*//测试 保险公司名 匹配 保险供应商
var_dump($supplier2);
$product = '太平财产保险有限公司'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
$product = '太平保险'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
$product = '太平'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
$product = '中国太平洋财产保险股份有限公司'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
$product = '太平洋'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
$product = '大西洋保险'; var_dump($product); var_dump($this->cost_insure_product($supplier2, $product));
exit();*/
foreach ($rows as $item) {
$biz = $this->biz_model->get(['id'=>$item['biz_id']]);
$money_json = json_decode($item['money_json'],true);
@@ -392,22 +405,33 @@ class Order extends CI_Controller{
$add_data['loan_price'] = 0.00;
}
if($insurance_img){//强险
if($insurance_img && $insurance_img['product']){//强险
$time = strtotime($insurance_img['date']);
$where = [
/*$where = [
'biz_id' => $item['biz_id'],
'title' => $insurance_img['product'],
'type' => 2,
"json_extract(jsondata, '$.type') = '2'" => null,
"json_extract(jsondata, '$.s_time') >= '{$time}'" => null,
"json_extract(jsondata, '$.e_time') <= '{$time}'" => null
];*/
$insure_product = $this->cost_insure_product($supplier2, $insurance_img['product']);
$where = [
'biz_id' => $item['biz_id'],
'title' => $insure_product,
'type' => 2,
'status' => 1,
"json_extract(jsondata, '$.type') = '2'" => null,
"json_extract(jsondata, '$.s_time') <= '{$time}'" => null,
"json_extract(jsondata, '$.e_time') >= '{$time}'" => null
];
$fd_row = $this->biz_settle_srv_model->get($where);
if(!$fd_row){
$where = [
'biz_id' => $item['biz_id'],
'title' => $insurance_img['product'],
'title' => $insure_product,
'type' => 2,
'status' => 1,
'is_def' => 1,
"json_extract(jsondata, '$.type') = '2'" => null,
];
@@ -419,21 +443,32 @@ class Order extends CI_Controller{
$srv_json['insurance_ins_price'] = floatval($insurance_img['price']) * $qx_fd;
}
$srv_json['business_ins_price'] = $srv_json['business_fd'] = 0;
if($business_img){//商业险
if($business_img && $business_img['product']){//商业险
$time = strtotime($business_img['date']);
$where = [
/*$where = [
'biz_id' => $item['biz_id'],
'title' => $business_img['product'],
'type' => 2,
"json_extract(jsondata, '$.type') = '1'" => null,
"json_extract(jsondata, '$.s_time') >= '{$time}'" => null,
"json_extract(jsondata, '$.e_time') <= '{$time}'" => null
];*/
$insure_product = $this->cost_insure_product($supplier2, $business_img['product']);
$where = [
'biz_id' => $item['biz_id'],
'title' => $insure_product,
'status' => 1,
'type' => 2,
"json_extract(jsondata, '$.type') = '1'" => null,
"json_extract(jsondata, '$.s_time') <= '{$time}'" => null,
"json_extract(jsondata, '$.e_time') >= '{$time}'" => null
];
$bis_fd_row = $this->biz_settle_srv_model->get($where);
if(!$bis_fd_row){
$where = [
'biz_id' => $item['biz_id'],
'title' => $business_img['product'],
'title' => $insure_product,
'status' => 1,
'type' => 2,
'is_def' => 1,
"json_extract(jsondata, '$.type') = '1'" => null,
@@ -449,13 +484,20 @@ class Order extends CI_Controller{
$srv_json['fee_carno'] = $money_json['fee_carno'] ? $money_json['fee_carno'] : 0;
$srv_json['cb_fee_carno'] = 0;
if($money_json['fee_carno']>0){
$where = [
/*$where = [
'biz_id' => $item['biz_id'],
'type' => 1,
'status' => 1,
's_effect_time>=' => date('Y-m-01',strtotime($item['bill_time'])),
's_effect_time<=' => date('Y-m-t',strtotime($item['bill_time'])),
];
*/
$where = [
'biz_id' => $item['biz_id'],
'type' => 1,
'status' => 1,
's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])),
];
$free_row = $this->biz_settle_srv_model->get($where);
if(!$free_row){
$free_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>1]);
@@ -470,22 +512,32 @@ class Order extends CI_Controller{
$srv_json['loan_price'] = $money_json['price_loan'];
$loan_row = $this->order_loans_model->get(['o_id'=>$item['id']]);
$finance_id = $item['finance_id'];
$srv_json['loan_product'] = ''; # $loan_row['title'];
$srv_json['loan_product'] = '';
if ($finance_id){
$finance_row = $this->sys_finance_model->get(array('id'=>$finance_id),'title');
//$finance_row = $this->sys_finance_model->get(array('id'=>$finance_id),'title');
$finance_row = $this->sys_supplier_model->get(array('id'=>$finance_id),'title');
$srv_json['loan_product'] = $finance_row ? $finance_row['title'] : '';
}
$srv_json['loan_num'] = $finance_num = $loan_row['num'] ? $loan_row['num'] : 36;
$where = [
/*$where = [
'biz_id' => $item['biz_id'],
'type' => 3,
's_effect_time' => $bill_time_month,
"json_extract(jsondata, '$.finance_id') = '{$finance_id}'" => null,
"json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null,
];*/
$where = [
'biz_id' => $item['biz_id'],
'type' => 3,
'status' => 1,
's_effect_time<=' => date('Y-m-d',strtotime($item['bill_time'])),
"json_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null,
"json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null,
];
$fd_row = $this->biz_settle_srv_model->get($where);
if(!$fd_row){
$fd_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>3]);
$fd_row = $this->biz_settle_srv_model->get(['biz_id'=>$item['biz_id'],'is_def'=>1,'status'=>1,'type'=>3,
"json_extract(jsondata, '$.supplier_id') = '{$finance_id}'" => null, "json_extract(jsondata, '$.finance_num') = '{$finance_num}'" => null]);
}
$fd_jsondata = json_decode($fd_row['jsondata'],true);
$loan_fd = $fd_jsondata['rebate'] ? $fd_jsondata['rebate']/100:0;
@@ -629,4 +681,37 @@ class Order extends CI_Controller{
echo "repair ".count($rows)." rows ok!";
}
/**
* 保险供应商名转换
*/
private function cost_insure_product($supplier2, $product){
if (!$supplier2 || !$product){
return $product;
}
$product_parm = '';
foreach ($supplier2 as $supplier){
if ($product == $supplier['title']){
$product_parm = $supplier['title'];
break;
}
if ($supplier['short']){
$shorts = explode(',', $supplier['short']);
foreach ($shorts as $short){
if (strpos($product, $short) !== false){
$product_parm = $supplier['title'];
break;
}
}
}
/*if ($product == $supplier['title'] || $supplier['short'] && strpos($product,$supplier['short']) !== false){
$product_parm = $supplier['title'];
break;
}*/
}
!$product_parm && $product_parm = $product;
return $product_parm;
}
}
+6 -3
View File
@@ -41,7 +41,8 @@ class Cusorder extends Wxapp{
$this->load->model("biz/biz_model");
$this->load->model('sys/sys_city_model');
$this->load->model('sys/sys_finance_model');
//$this->load->model('sys/sys_finance_model');
$this->load->model('sys/sys_supplier_model');
$this->load->library('receiver/orders_entity');
$this->load->library('receiver/orders_v2_entity');
@@ -122,7 +123,8 @@ class Cusorder extends Wxapp{
if($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
}
if(!$payway){ //分期
$finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
//$finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
$finance_row = $this->sys_supplier_model->get(['id'=>$finance_id,'status'=>1]);
if(!$finance_row){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
@@ -444,7 +446,8 @@ class Cusorder extends Wxapp{
$info_json['c_cardid'] && $car_data['身份证号'] = $info_json['c_cardid'];
$info_json['c_address'] && $car_data['地址'] = $info_json['c_address'];
if(!$row['payway']){
$finance_row = $this->sys_finance_model->get(['id'=>$row['finance_id']],'title');
//$finance_row = $this->sys_finance_model->get(['id'=>$row['finance_id']],'title');
$finance_row = $this->sys_supplier_model->get(['id'=>$row['finance_id']],'title');
$car_data['金融产品'] = $finance_row['title'];
}
//是否存在意向金订单
+4 -2
View File
@@ -28,7 +28,8 @@ class Cusorder2 extends Wxapp{
$this->load->model('auto/auto_cars_model');
$this->load->model("biz/biz_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_city_model');
$this->load->model('app/liche/app_liche_users_model');
@@ -159,7 +160,8 @@ class Cusorder2 extends Wxapp{
if($disc_money) throw new Exception('当前车型没有优惠额度', API_CODE_FAIL);
}
if(!$payway){ //分期
$finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
//$finance_row = $this->sys_finance_model->get(['id'=>$finance_id,'status'=>1]);
$finance_row = $this->sys_supplier_model->get(['id'=>$finance_id,'status'=>1]);
if(!$finance_row){
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
+8 -4
View File
@@ -39,7 +39,8 @@ class CusorderV2 extends Wxapp
$this->load->model("biz/biz_model");
$this->load->model('items/items_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_city_model');
$this->load->model('app/liche/app_liche_users_model');
@@ -144,7 +145,8 @@ class CusorderV2 extends Wxapp
}
}
if (!$payway && $finance_id) { //分期
$finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
//$finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
$finance_row = $this->sys_supplier_model->get(['id' => $finance_id, 'status' => 1]);
if (!$finance_row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
@@ -399,7 +401,8 @@ class CusorderV2 extends Wxapp
}
}
if (!$payway && $finance_id) { //分期
$finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
//$finance_row = $this->sys_finance_model->get(['id' => $finance_id, 'status' => 1]);
$finance_row = $this->sys_supplier_model->get(['id' => $finance_id, 'status' => 1]);
if (!$finance_row) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
@@ -541,7 +544,8 @@ class CusorderV2 extends Wxapp
$car_data['需开具本地发票'] = $row['if_local_bill'] ? '需要' : '不需要';
}
if (!$row['payway'] && $row['brand_id']) {
$finance_row = $this->sys_finance_model->get(['id' => $row['finance_id']], 'title');
//$finance_row = $this->sys_finance_model->get(['id' => $row['finance_id']], 'title');
$finance_row = $this->sys_supplier_model->get(['id' => $row['finance_id']], 'title');
$car_data['按揭信息'] = $finance_row['title'] ? $finance_row['title'] : '';
}
//是否存在意向金订单
+9 -4
View File
@@ -20,7 +20,8 @@ class Finance extends Wxapp{
$this->load->model('auto/auto_series_model');
$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');
}
protected function get(){
@@ -33,10 +34,13 @@ class Finance extends Wxapp{
$where = [
'status' => 1
];
$count = $this->sys_finance_model->count($where);
//$count = $this->sys_finance_model->count($where);
$where['type'] = 3;
$count = $this->auto_supplier_model->count($where);
$lists = [];
if($count){
$rows = $this->sys_finance_model->select($where,'id desc',$page,$size,'id,title');
//$rows = $this->sys_finance_model->select($where,'id desc',$page,$size,'id,title');
$rows = $this->auto_supplier_model->select($where,'id desc',$page,$size,'id,title');
foreach($rows as $key => $val){
$lists[] = $val;
}
@@ -49,7 +53,8 @@ class Finance extends Wxapp{
}
protected function get_nums(){
$list = $this->sys_finance_model->get_nums();
//$list = $this->sys_finance_model->get_nums();
$list = $this->auto_finance_model->get_nums();
$data = [
'list' => $list,
];
+1 -1
View File
@@ -42,7 +42,7 @@ class Auto_finance_model extends HD_Model{
* @return array
*/
public function get_nums(){
$nums = [24,36];
$nums = [12,24,36,48,60];
return $nums;
}
+19 -4
View File
@@ -8,6 +8,7 @@ class Biz_settle_srv_model extends HD_Model
private $type_ary = [
1 => '挂牌', 2=>'保险' , 3=> '按揭'
];
private $insure_type_ary = [1 => '商业险', 2 => '交强险', 3 => '意外险'];
public function __construct()
{
@@ -40,10 +41,23 @@ class Biz_settle_srv_model extends HD_Model
}
}
/**
* 获取保险类型
* @param $type
* @return string|string[]
*/
public function get_insure_type($type){
if(strlen($type)){
return $this->insure_type_ary[$type];
}else{
return $this->insure_type_ary;
}
}
/**
*
* type = 1 (price结算价)
* type = 2 (type 保险类型[1商业险 2交强险] rebate 返点 s_time 开始时间 e_time 结束时间)
* type = 2 (type 保险类型[1商业险 2交强险 3意外险] rebate 返点 s_time 开始时间 e_time 结束时间)
* @param $type
* @param $jsondata
* @return array
@@ -58,13 +72,14 @@ class Biz_settle_srv_model extends HD_Model
break;
case 2:
$res['返点'] = $jsondata['rebate'];
$res['保险类型'] = $jsondata['type'] ==1 ? '商业险' : '交强险';
#$res['保险类型'] = $jsondata['type'] ==1 ? '商业险' : '交强险';
$res['保险类型'] = intval($jsondata['type']) ? $this->get_insure_type(intval($jsondata['type'])) : '';
$res['时间区间'] = $jsondata['s_time']&&$jsondata['e_time'] ? date('Y-m-d',$jsondata['s_time'])."".date('Y-m-d',$jsondata['e_time']) : "";
break;
case 3:
$res['返点'] = $jsondata['rebate'];
$res['产品'] = $jsondata['finance_title'];
$res['期数'] = $jsondata['finance_num'];
$res['返点'] = $jsondata['rebate'];
#$res['产品'] = $jsondata['supplier_title'] ? $jsondata['supplier_title'] : $jsondata['finance_title'];
break;
default:
}
+1 -1
View File
@@ -50,7 +50,7 @@ class Sys_finance_model extends HD_Model
* @return array
*/
public function get_nums(){
$nums = [12,18,24,36,48,60];
$nums = [12,24,36,48,60];
return $nums;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Sys_supplier_model extends HD_Model
{
private $table_name = 'lc_sys_supplier';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* 根据id获取数据
* @param $ids
* @param string $fileds
* @param int $type,默认3是兼容用
* @return array
*/
public function get_map_by_ids($ids, $fileds = '', $type=3)
{
$rows = [];
$ids = array_filter($ids);
if ($ids) {
$cf_ids = implode(',', $ids);
$where = [
"id in ($cf_ids)" => null
];
$type && $where['type'] = $type;
$rows = $this->map('id', '', $where, '', '', '', $fileds);
}
return $rows;
}
/**
* 状态
* @return array
*/
function status_ary(){
$statusAry = array(/*'-1' => '删除',*/ '0' => '关闭', '1' => '开启');
return $statusAry;
}
/**
* 类型
* @return array
*/
function type_ary(){
$typeAry = array('1' => '挂牌', '2' => '保险', '3' => '按揭', '4' =>'精品');
return $typeAry;
}
}
+12
View File
@@ -251,3 +251,15 @@ create table lc_sys_addr (
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='地址管理';
drop table if exists `lc_sys_supplier`;
CREATE TABLE `lc_sys_supplier` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`title` varchar(64) NOT NULL COMMENT '供应商',
`short` varchar(32) NOT NULL DEFAULT '' COMMENT '供应商简称',
`type` tinyint(2) NOT NULL DEFAULT '1' COMMENT '类型(1挂牌 2保险 3按揭 4 精品)',
`jsondata` json DEFAULT NULL COMMENT '配置数据',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:-1删除,0关闭,1开启',
`c_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
`u_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='供应商目录';