From 028a8d80cba24761c4e314e8723df4c312c271e3 Mon Sep 17 00:00:00 2001 From: xxb Date: Fri, 30 Jul 2021 11:45:19 +0800 Subject: [PATCH] admin sys add finance manger and company short is must --- admin/controllers/biz/brand/Brand.php | 4 +- admin/controllers/sys/Company.php | 12 +- admin/controllers/sys/Finance.php | 199 ++++++++++++++++++++++++ admin/views/biz/brand/edit.php | 4 +- admin/views/sys/company/get.php | 4 +- admin/views/sys/finance/get.php | 116 ++++++++++++++ admin/views/sys/finance/lists.php | 93 +++++++++++ common/models/sys/Sys_finance_model.php | 27 ++++ sql/sys.sql | 19 +++ 9 files changed, 470 insertions(+), 8 deletions(-) create mode 100644 admin/controllers/sys/Finance.php create mode 100644 admin/views/sys/finance/get.php create mode 100644 admin/views/sys/finance/lists.php create mode 100644 common/models/sys/Sys_finance_model.php diff --git a/admin/controllers/biz/brand/Brand.php b/admin/controllers/biz/brand/Brand.php index 4f5eb6ab..f5d99fef 100755 --- a/admin/controllers/biz/brand/Brand.php +++ b/admin/controllers/biz/brand/Brand.php @@ -63,8 +63,8 @@ class Brand extends HD_Controller //获取公司ID列表 $where = array('status' => 1); $orderby = 'id desc'; - $select = 'id, title'; - $map_company = $this->company_model->map('id', 'title', $where, $orderby, 0, 0, $select); + $select = 'id, short'; + $map_company = $this->company_model->map('id', 'short', $where, $orderby, 0, 0, $select); $this->data['info'] = $info; $this->data['action'] = $action; diff --git a/admin/controllers/sys/Company.php b/admin/controllers/sys/Company.php index 27114fcd..27522ff9 100644 --- a/admin/controllers/sys/Company.php +++ b/admin/controllers/sys/Company.php @@ -100,9 +100,13 @@ class Company extends HD_Controller{ public function add(){ $info = $this->input->post('info'); $title = trim($info['title']); + $short = trim($info['short']); if(!$title){ return $this->show_json(SYS_CODE_FAIL, '请输入公司名称'); } + if(!$short){ + return $this->show_json(SYS_CODE_FAIL, '请输入公司简称'); + } $where = array("title like '{$title}'" => null); $count = $this->company_model->count($where); @@ -112,7 +116,7 @@ class Company extends HD_Controller{ $add = array( 'title' => $title, - 'short' => $info['short'] ? $info['short'] : '', + 'short' => $short, 'status' => intval($info['status']) ); @@ -128,9 +132,13 @@ class Company extends HD_Controller{ public function edit(){ $info = $this->input->post('info'); $title = trim($info['title']); + $short = trim($info['short']); if(!$title){ return $this->show_json(SYS_CODE_FAIL, '请输入公司名称'); } + 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); @@ -140,7 +148,7 @@ class Company extends HD_Controller{ $upd = array( 'title' => $title, - 'short' => $info['short'] ? $info['short'] : '', + 'short' => $short ? $short : '', 'status' => intval($info['status']) ); diff --git a/admin/controllers/sys/Finance.php b/admin/controllers/sys/Finance.php new file mode 100644 index 00000000..3e0dccea --- /dev/null +++ b/admin/controllers/sys/Finance.php @@ -0,0 +1,199 @@ +load->model("sys/sys_finance_model", 'finance_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']){ + $where["(title like '%{$params['keyword']}%')"] = null; + } + + if(strlen($params['status']) > 0){ + $where['status'] = $params['status']; + } else { + $params['status'] = ''; + } + + $page = $params['page']; + $page = !$page ? 1 : $page; + $size = $params['size']; + $size = !$size ? 20 : $size; + + $statusAry = $this->finance_model->status_ary(); + + $count = $this->finance_model->count($where); + $lists = array(); + if($count){ + $orderby = 'id desc'; + $select = 'id, title, money_min, money_max, first_pay, month_min, month_max, status'; + $rows = $this->finance_model->select($where, $orderby, $page, $size, $select); + foreach($rows as $k => $v){ + $lists[] = array( + 'id' => $v['id'], + 'title' => $v['title'], + 'money' => "{$v['money_min']}-{$v['money_max']}", + 'first_pay' => $v['first_pay'], + "month" => "{$v['month_min']}-{$v['month_max']}", + 'status' => $v['status'], + 'status_name' => $statusAry[$v['status']], + ); + } + } + + $this->data['params'] = $params; + $this->data['lists'] = $lists; + $this->data['statusAry'] = $statusAry; + $this->data['pager'] = array('count'=>ceil($count/$size),'curr'=>$page,'totle'=>$count); + $this->data['_title'] = '金融产品'; + $this->show_view('sys/finance/lists',true); + } + + public function get(){ + $id = $this->input->get('id'); + if($id){ + $row = $this->finance_model->get(array('id' => $id)); + $info = array( + 'id' => $row['id'], + 'title' => $row['title'], + 'logo' => $row['logo'], + 'logo_url' => $row['logo'] ? build_qiniu_image_url($row['logo']) : '', + 'money_min' => $row['money_min'], + 'money_max' => $row['money_max'], + 'first_pay' => $row['first_pay'], + 'month_min' => $row['month_min'], + 'month_max' => $row['month_max'], + 'status' => $row['status'], + ); + $action = '/sys/finance/edit'; + $title = '编辑金融产品'; + } else { + $info = array( + 'title' => '', + 'status' => 0, + ); + $action = '/sys/finance/add'; + $title = '新增金融产品'; + } + + $this->data['info'] = $info; + $this->data['action'] = $action; + $this->data['statusAry'] = $this->finance_model->status_ary(); + $this->data['_title'] = $title; + $this->show_view('sys/finance/get'); + } + + public function add(){ + $info = $this->input->post('info'); + $title = trim($info['title']); + if(!$title){ + return $this->show_json(SYS_CODE_FAIL, '请输入标题'); + } + + $where = array("title like '{$title}'" => null); + $count = $this->finance_model->count($where); + if($count>0){ + return $this->show_json(SYS_CODE_FAIL, '产品已经存在'); + } + + $add = array( + 'title' => $title, + 'logo' => $info['logo'] ? $info['logo'] : '', + 'money_min' => floatval($info['money_min']), + 'money_max' => floatval($info['money_max']), + 'first_pay' => floatval($info['first_pay']), + 'month_min' => intval($info['month_min']), + 'month_max' => intval($info['month_max']), + 'status' => intval($info['status']), + ); + + $id = $this->finance_model->add($add); + if(!$id){ + debug_log("[error]# " . $this->finance_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'); + $title = trim($info['title']); + if(!$title){ + return $this->show_json(SYS_CODE_FAIL, '请输入产品名称'); + } + + $where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null); + $count = $this->finance_model->count($where); + if($count>0){ + return $this->show_json(SYS_CODE_FAIL, '产品已存在'); + } + + $upd = array( + 'title' => $title, + 'logo' => $info['logo'] ? $info['logo'] : '', + 'money_min' => floatval($info['money_min']), + 'money_max' => floatval($info['money_max']), + 'first_pay' => floatval($info['first_pay']), + 'month_min' => intval($info['month_min']), + 'month_max' => intval($info['month_max']), + 'status' => intval($info['status']), + ); + + $ret = $this->finance_model->update($upd, array('id' => $info['id'])); + if(!$ret){ + debug_log("[error]# " . $this->finance_model->db->last_query(), __FUNCTION__, $this->log_dir); + return $this->show_json(SYS_CODE_FAIL, '保存失败'); + } + + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + function edit_status(){ + $id = $this->input->post('id'); + $status = $this->input->post('status'); + + $upd = array('status' => $status); + $where = array('id' => $id); + + $ret = $this->finance_model->update($upd, $where); + if(!$ret){ + debug_log("[error]# " . $this->finance_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. + } +} \ No newline at end of file diff --git a/admin/views/biz/brand/edit.php b/admin/views/biz/brand/edit.php index a85c5f02..6a56c115 100755 --- a/admin/views/biz/brand/edit.php +++ b/admin/views/biz/brand/edit.php @@ -24,7 +24,7 @@
-
+
diff --git a/admin/views/sys/company/get.php b/admin/views/sys/company/get.php index 16486ce1..943b645f 100644 --- a/admin/views/sys/company/get.php +++ b/admin/views/sys/company/get.php @@ -1,10 +1,10 @@ -
+
- +
diff --git a/admin/views/sys/finance/get.php b/admin/views/sys/finance/get.php new file mode 100644 index 00000000..8fc4caec --- /dev/null +++ b/admin/views/sys/finance/get.php @@ -0,0 +1,116 @@ + +
+ +
+
+
+ +
+
+ + + +
+
+
+
+ +
+ + 万元 +
+
+
+ +
+ + - + + 万元 +
+
+
+ +
+ + - + + +
+
+
+ +
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/admin/views/sys/finance/lists.php b/admin/views/sys/finance/lists.php new file mode 100644 index 00000000..c3fb033b --- /dev/null +++ b/admin/views/sys/finance/lists.php @@ -0,0 +1,93 @@ + +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
ID名称首付(万元)额度(万元)期限(月)状态操作
{{v.id}}{{v.title}}{{v.first_pay}}{{v.money}}{{v.month}}{{v.status_name}} + 编辑 + 关闭 + 开启 +
+
+
+
+
+
+ +
+
+
+ + diff --git a/common/models/sys/Sys_finance_model.php b/common/models/sys/Sys_finance_model.php new file mode 100644 index 00000000..07312236 --- /dev/null +++ b/common/models/sys/Sys_finance_model.php @@ -0,0 +1,27 @@ +table_name, 'default'); + } + + /** + * 状态 + * @return array + */ + function status_ary(){ + $statusAry = array(/*'-1' => '删除',*/ '0' => '关闭', '1' => '开启'); + + return $statusAry; + } +} \ No newline at end of file diff --git a/sql/sys.sql b/sql/sys.sql index 4a866120..0601866d 100644 --- a/sql/sys.sql +++ b/sql/sys.sql @@ -204,3 +204,22 @@ create table lc_sys_company ( ) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='公司管理'; +-- ---------------------------- +-- Title:金融产品 +-- Author:xusir +-- Table:lc_sys_finance +-- --------------------------- +drop table if exists lc_sys_finance; +create table lc_sys_finance ( + id int(10) unsigned not null auto_increment comment '自增id', + title varchar(64) not null comment '公司名称', + logo varchar(128) not null default '' comment '菜单图标', + money_min decimal(12,2) not null default 0.00 comment '最低额度(万元)', + money_max decimal(12,2) not null default 0.00 comment '最高额度(万元)', + first_pay decimal(12,2) not null default 0.00 comment '首付(万元)', + month_min int not null default 0 comment '最低期限(月)', + month_max int not null default 0 comment '最高期限(月)', + status tinyint(1) not null default '1' comment '状态:-1删除,0关闭,1开启', + primary key (id) +) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='金融产品'; +