diff --git a/admin/controllers/biz/Seprice.php b/admin/controllers/biz/Seprice.php new file mode 100644 index 00000000..42325f35 --- /dev/null +++ b/admin/controllers/biz/Seprice.php @@ -0,0 +1,174 @@ +load->model('biz/biz_model'); + $this->load->model('biz/biz_settle_price_model'); + $this->load->model('auto/auto_business_model'); + } + + public function index() + { + $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + $page = $params['page'] ? $params['page'] : 1; + $size = $params['size'] ? $params['size'] : 50; + !strlen($params['status']) && $params['status'] = ''; + !strlen($params['year']) && $params['year'] = date('Y'); + !strlen($params['month']) && $params['month'] = ''; + $biz_row = $this->biz_model->get(['id'=>$params['biz_id']]); + if(!$biz_row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + + $where = [ + 'biz_id' => $biz_row['id'], + 'status>=' => 0, + 'year' => date('Y') + ]; + strlen($params['status']) && $where['status'] = $params['status']; + strlen($params['year']) && $where['year'] = $params['year']; + strlen($params['month']) && $where['month'] = $params['month']; + $lists = []; + $total = $this->biz_settle_price_model->count($where); + if($total){ + $rows = $this->biz_settle_price_model->select($where,'id desc',$page,$size); + foreach ($rows as $item) { + $temp = [ + 'id' => $item['id'], + 'money_json' => $this->biz_settle_price_model->get_jsondata($item['money_json']), + 'show_time' => "{$item['year']}-{$item['month']}", + 'status' => $item['status'], + 'status_cn' => $item['status'] ? '正常' : '禁用', + 'c_time' => date('Y-m-d H:i',$item['c_time']) + ]; + $lists[] = $temp; + } + } + $this->data['yearAry'] = $this->auto_business_model->year(); + $this->data['monthAry'] = $this->auto_business_model->month(); + $this->data['params'] = $params; + $this->data['lists'] = $lists; + $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page,'totle'=>$total); + $this->data['_title'] = "{$biz_row['biz_name']}-费用管理"; + $this->show_view('biz/seprice/lists',true); + } + + public function get(){ + $params = $this->input->get(); + $row = $this->biz_settle_price_model->get(['id'=>$params['id']]); + $info = []; + if($row){ + $info['id'] = $row['id']; + $info['money_json'] = json_decode($row['money_json'],true); + $info['year'] = $row['year']; + $info['month'] = $row['month']; + $info['action'] = '/biz/seprice/edit'; + $biz_id = $params['biz_id']; + }else{ + $biz_row = $this->biz_model->get(['id'=>$params['biz_id']]); + if(!$biz_row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $biz_id = $biz_row['id']; + $info['money_json'] = [ + 'rent' => '', + 'base_manager' => '', + 'base_employees' => '', + 'wat_ele' => '', + 'media' => '', + 'marketing' => '', + 'drive' => '', + 'commission' => '', + 'trucking' => '' + ]; + $info['year'] = date('Y'); + $info['month'] = intval(date('m')); + $info['action'] = '/biz/seprice/add'; + } + $info['biz_id'] = $biz_id; + $this->data['info'] = $info; + $this->data['yearAry'] = $this->auto_business_model->year(); + $this->data['monthAry'] = $this->auto_business_model->month(); + $this->show_view('biz/seprice/get'); + } + + public function add(){ + $info = $this->input->post('info'); + $biz_row = $this->biz_model->get(['id'=>$info['biz_id']]); + if(!$biz_row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $data = [ + 'money_json' => json_encode($info['money_json'],JSON_UNESCAPED_UNICODE), + 'biz_id' => $info['biz_id'], + 'year' => $info['year'], + 'month' => $info['month'], + 'c_time' => time() + ]; + $res = $this->biz_settle_price_model->add($data); + if($res){ + return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); + }else{ + return $this->show_json(SYS_CODE_FAIL,'保存失败'); + } + } + + public function edit(){ + $info = $this->input->post('info'); + $row = $this->biz_settle_price_model->get(['id'=>$info['id']]); + if(!$row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $data = [ + 'money_json' => json_encode($info['money_json'],JSON_UNESCAPED_UNICODE), + 'year' => $info['year'], + 'month' => $info['month'], + ]; + $res = $this->biz_settle_price_model->update($data,['id'=>$info['id']]); + if($res){ + return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); + }else{ + return $this->show_json(SYS_CODE_FAIL,'保存失败'); + } + } + + public function edit_status(){ + $id = $this->input->post('id'); + $value = $this->input->post('value'); + $row = $this->biz_settle_price_model->get(['id'=>$id]); + if(!$row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $update = [ + 'status' => $value ? 0 : 1 + ]; + $res = $this->biz_settle_price_model->update($update,['id'=>$id]); + if($res){ + return $this->show_json(SYS_CODE_SUCCESS,'保存成功'); + }else{ + return $this->show_json(SYS_CODE_FAIL,'保存失败'); + } + } + public function del() + { + } + + public function batch() + { + + } + public function export(){ + + } + +} diff --git a/admin/controllers/biz/Settle.php b/admin/controllers/biz/Settle.php index bf48229d..76840cc9 100644 --- a/admin/controllers/biz/Settle.php +++ b/admin/controllers/biz/Settle.php @@ -5,11 +5,6 @@ require_once COMMPATH.'third_party/PHPExcel.php'; class Settle extends HD_Controller { - private $biz_type = [ - 1 => ['liche' => 0.25 , 'partner' => 0.75], - 2 => ['liche' => 0.35 , 'partner' => 0.65], - ]; - public function __construct() { parent::__construct(); @@ -26,6 +21,8 @@ class Settle extends HD_Controller $this->load->model('biz/biz_settle_static_model'); $this->load->model('biz/biz_info_model'); $this->load->model('biz/biz_trucking_model'); + $_biz_type = $this->input->get('_biz_type'); + $_SESSION['is_brand'] = $_biz_type==1 ? $_biz_type : ''; } public function index() @@ -370,6 +367,7 @@ class Settle extends HD_Controller $temp['total_need'] = $v['rent'] + $v['wat_ele'] + $v['manager_wage'] + $v['employee_wage'] + $v['commission'] + $v['price_trucking']; $temp['price_ml'] = $v['price_total'] - $temp['total_need']; $temp['profix_partner'] = $v['profix_partner'] + $v['profix_partner_oflow']; + $temp['money_json'] = json_decode($v['money_json'],true); $lists[] = $temp; } } @@ -381,7 +379,8 @@ class Settle extends HD_Controller $this->data['type_arr'] = $this->biz_settle_static_model->other_price_type(); $this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page,'totle'=>$total); $this->data['_title'] = '商家结算管理'; - $this->show_view('biz/settle/lists_static',true); + $view = $_SESSION['is_brand'] ? 'biz/settle/lists_static_brand' : 'biz/settle/lists_static'; + $this->show_view($view,true); } diff --git a/admin/views/biz/seprice/get.php b/admin/views/biz/seprice/get.php new file mode 100644 index 00000000..364cbe7a --- /dev/null +++ b/admin/views/biz/seprice/get.php @@ -0,0 +1,140 @@ +
+ diff --git a/admin/views/biz/seprice/lists.php b/admin/views/biz/seprice/lists.php new file mode 100755 index 00000000..92be62be --- /dev/null +++ b/admin/views/biz/seprice/lists.php @@ -0,0 +1,111 @@ +| ID | +费用明细 | +有效月份 | +状态 | +创建时间 | +操作 | +
|---|---|---|---|---|---|
| {{item.id}} | +
+ {{key}}:{{val}} + |
+ {{item.show_time}} | +{{item.status_cn}} | +{{item.c_time}} | ++ 编辑 + + 禁用 + + + 启用 + + | +
| + ID + | +门店 | +单车总毛利 | +服务费 | +佣金 | +门店费用 | +精品 | +其它费用 | +总利润 | +分润 | +时间 | +
|---|---|---|---|---|---|---|---|---|---|---|
| + {{v.id}} + | +{{v.biz_name}} | +{{v.profix_car}} | ++ | + | + + | ++ + | ++ + | +{{v.price_ml}} | +
+ 狸车分润:{{v.profix_liche}} + 品牌店分润:{{v.profix_partner}} + |
+ {{v.month_str}} | +
| + 查看明细 + | +||||||||||