diff --git a/admin/controllers/biz/Fine.php b/admin/controllers/biz/Fine.php new file mode 100644 index 00000000..3eb7459e --- /dev/null +++ b/admin/controllers/biz/Fine.php @@ -0,0 +1,149 @@ +load->model('receiver/receiver_fine_model'); + $this->load->model('biz/biz_model'); + } + + public function index() + { + $this->lists(); + } + + public function lists(){ + $params = $this->input->get(); + $params['id'] && $_SESSION['srv_biz_id'] = $params['id']; + !strlen($params['status']) && $params['status'] = ''; + $page = $params['page'] ? $params['page'] : 1; + $pagesize = 20; + $where = [ + 'status>=' => 0, + 'biz_id' => $_SESSION['srv_biz_id'] + ]; + strlen($params['status']) && $where['status'] = $params['status']; + $params['title'] && $where['title'] = $params['title']; + $count = $this->receiver_fine_model->count($where); + $lists = []; + if($count){ + $rows = $this->receiver_fine_model->select($where, 'id desc', $page, $pagesize); + $biz_ids = array_unique(array_column($rows,'biz_id')); + $map_biz = []; + if(is_array($biz_ids)){ + $biz_ids = implode(',',array_filter($biz_ids)); + $where_biz = ["id in ({$biz_ids})" => null]; + $map_biz = $this->biz_model->map('id', 'biz_name', $where_biz, '', 0, 0, 'id,biz_name'); + } + foreach ($rows as $val) { + $lists[] = [ + 'id' => $val['id'], + 'biz_id' => $val['biz_id'], + 'biz_name' => $map_biz[$val['biz_id']], + 'title' => $val['title'], + 'price' => $val['price'], + 'status_cn' => $this->receiver_fine_model->get_status($val['status']), + 'c_time' => date('Y-m-d H:i',$val['c_time']), + 'status' => $val['status'], + ]; + } + } + + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['_title'] = '门店精品成本列表'; + $this->data['pager'] = array('count' => ceil($count / $pagesize), 'curr' => $page, 'totle' => $count); + $this->show_view('biz/fine/lists', true); + } + + public function get(){ + $biz_id = $_SESSION['srv_biz_id']; + $id = $this->input->get('id'); + if(!$biz_id){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $row = $this->receiver_fine_model->get(['id'=>$id]); + $info = [ + 'biz_id' => $biz_id, + 'title' => '', + 'price' => '', + 'action' => 'biz/fine/add', + ]; + if($row){ + $info['title'] = $row['title']; + $info['price'] = $row['price']; + $info['action'] = 'biz/fine/edit'; + } + $this->data['info'] = $info; + $this->show_view('biz/fine/get'); + } + + public function add(){ + $info = $this->input->post('info'); + $data = [ + 'biz_id' => $info['biz_id'], + 'title' => $info['title'], + 'price' => $info['price'], + 'status' => 1, + 'c_time' => time(), + ]; + $res = $this->receiver_fine_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->receiver_fine_model->get(['id'=>$info['id']]); + if(!$row){ + return $this->show_json(SYS_CODE_FAIL,'参数错误'); + } + $data = [ + 'title' => $info['title'], + 'price' => $info['price'], + ]; + $res = $this->receiver_fine_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 del() + { + } + + public function batch() + { + $field = $this->input->post('field'); + if ($field === 'ifcheck') { + $status = intval($this->input->post('value')); + $ids = $this->input->post('id'); + $ids = explode(',', $ids); + if (!$ids || count($ids) < 1) { + $this->show_json(0, '请选择要操作的选项'); + } + $ids_str = implode(',', $ids); + $where = ["id in({$ids_str})" => null]; + } else { + $id = intval($this->input->post('id')); + $status = intval($this->input->post('value')); + if (!$id) { + $this->show_json(0, '参数错误'); + } + $where['id'] = $id; + } + $data['status'] = $status; + $this->receiver_fine_model->update($data, $where); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + public function export(){ + } +} diff --git a/admin/controllers/biz/Settle.php b/admin/controllers/biz/Settle.php index 102070e0..0c110e59 100644 --- a/admin/controllers/biz/Settle.php +++ b/admin/controllers/biz/Settle.php @@ -132,7 +132,8 @@ class Settle extends HD_Controller 'profix_insure' => $v['profix_insure'], 'profix_carno' => $v['profix_carno'], 'profix_loan' => $v['profix_loan'], - 'sum_srv' => $v['profix_insure']+$v['profix_carno']+$v['profix_loan'], + 'profix_fine' => $v['profix_fine'], + 'sum_srv' => $v['profix_insure']+$v['profix_carno']+$v['profix_loan']+$v['profix_fine'], 'price_trucking' => $v['price_trucking'], 'name' => $v['name'], 'mobile' => $v['mobile'], diff --git a/admin/controllers/biz/Srv.php b/admin/controllers/biz/Srv.php new file mode 100644 index 00000000..ddf3ad37 --- /dev/null +++ b/admin/controllers/biz/Srv.php @@ -0,0 +1,221 @@ +load->model('auto/auto_business_model'); + + $this->load->model('biz/biz_model'); + $this->load->model('biz/biz_settle_srv_model'); + $this->load->model('sys/sys_finance_model'); + } + + public function index() + { + $this->lists(); + } + + public function lists(){ + $params = $this->input->get(); + $params['id'] && $_SESSION['srv_biz_id'] = $params['id']; + !$params['type'] && $params['type'] = ''; + !strlen($params['status']) && $params['status'] = ''; + $page = $params['page'] ? $params['page'] : 1; + $pagesize = 20; + $where = [ + 'status>=' => 0, + 'biz_id' => $_SESSION['srv_biz_id'] + ]; + strlen($params['status']) && $where['status'] = $params['status']; + $params['type'] && $where['type'] = $params['type']; + $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); + $biz_ids = array_unique(array_column($rows,'biz_id')); + $map_biz = []; + if(is_array($biz_ids)){ + $biz_ids = implode(',',array_filter($biz_ids)); + $where_biz = ["id in ({$biz_ids})" => null]; + $map_biz = $this->biz_model->map('id', 'biz_name', $where_biz, '', 0, 0, 'id,biz_name'); + } + foreach ($rows as $val) { + $other_data = $this->biz_settle_srv_model->get_jsondata($val['type'],$val['jsondata']); + $lists[] = [ + 'id' => $val['id'], + 'biz_id' => $val['biz_id'], + 'biz_name' => $map_biz[$val['biz_id']], + 'title' => $val['title'], + 'other_data' => $other_data, + 's_effect_time' =>$val['s_effect_time'], + 'is_def' => $val['is_def'] ? '是':'否', + 'type_cn' => $this->biz_settle_srv_model->get_type($val['type']), + 'status_cn' => $this->biz_settle_srv_model->get_status($val['status']), + 'c_time' => date('Y-m-d H:i',$val['c_time']), + 'status' => $val['status'], + ]; + } + } + + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['typeAry'] = $this->biz_settle_srv_model->get_type(); + $this->data['_title'] = '门店列表'; + $this->data['pager'] = array('count' => ceil($count / $pagesize), 'curr' => $page, 'totle' => $count); + $this->show_view('biz/srv/lists', true); + } + + public function get(){ + $biz_id = $_SESSION['srv_biz_id']; + $id = $this->input->get('id'); + if(!$biz_id){ + 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'); + $info = [ + 'biz_id' => $biz_id, + 'type' => 1, + '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] + ]; + if($row){ + $info['title'] = $row['title']; + $info['id'] = $row['id']; + $info['type'] = $row['type']; + $info['is_def'] = $row['is_def']; + $info['s_effect_time'] = $row['s_effect_time']; + $info['action'] = 'biz/srv/edit'; + $info['jsondata'] = json_decode($row['jsondata'],true); + } + $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['info'] = $info; + $this->data['typeAry'] = $this->biz_settle_srv_model->get_type(); + $this->show_view('biz/srv/get'); + } + + public function add(){ + $info = $this->input->post('info'); + $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 = []; + 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']; + $jsondata['type'] = $info['jsondata']['type']; + }else{ + $jsondata['rebate'] = $info['jsondata']['rebate']; + $jsondata['finance_id'] = $info['jsondata']['finance_id']; + $jsondata['finance_num'] = $info['jsondata']['finance_num']; + } + //只能有一条默认 + if($info['is_def']){ + $where = [ + 'biz_id' => $info['biz_id'], + 'type' => $info['type'], + 'is_def' => 1 + ]; + $this->biz_settle_srv_model->update(['is_def'=>0],$where); + } + $data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE); + $res = $this->biz_settle_srv_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_srv_model->get(['id'=>$info['id']]); + if(!$row){ + 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'])); + 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']; + $jsondata['type'] = $info['jsondata']['type']; + }else{ + $jsondata['rebate'] = $info['jsondata']['rebate']; + $jsondata['finance_id'] = $info['jsondata']['finance_id']; + $jsondata['finance_num'] = $info['jsondata']['finance_num']; + $finance = $this->sys_finance_model->get(['id'=>intval($jsondata['finance_id'])],'title'); + $jsondata['finance_title'] = $finance['title']; + } + //只能有一条默认 + if($info['is_def']){ + $where = [ + 'biz_id' => $info['biz_id'], + 'type' => $info['type'], + 'is_def' => 1 + ]; + $this->biz_settle_srv_model->update(['is_def'=>0],$where); + } + $data['jsondata'] = json_encode($jsondata,JSON_UNESCAPED_UNICODE); + $res = $this->biz_settle_srv_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 del() + { + } + + public function batch() + { + $field = $this->input->post('field'); + if ($field === 'ifcheck') { + $status = intval($this->input->post('value')); + $ids = $this->input->post('id'); + $ids = explode(',', $ids); + if (!$ids || count($ids) < 1) { + $this->show_json(0, '请选择要操作的选项'); + } + $ids_str = implode(',', $ids); + $where = ["id in({$ids_str})" => null]; + } else { + $id = intval($this->input->post('id')); + $status = intval($this->input->post('value')); + if (!$id) { + $this->show_json(0, '参数错误'); + } + $where['id'] = $id; + } + $data['status'] = $status; + $this->biz_settle_srv_model->update($data, $where); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + public function export(){ + } +} diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index b42dc5bb..d1ec6c71 100755 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -1022,7 +1022,8 @@ class Store extends HD_Controller public function get_info() { $biz_id = $this->input->get('id'); - if (!$this->biz_model->get(['id' => $biz_id])) { + $biz = $this->biz_model->get(array('id' => $biz_id)); + if (!$biz) { return $this->show_json(SYS_CODE_FAIL, '店铺不存在!'); } $base_info = $this->biz_info_model->get(['biz_id' => $biz_id]); @@ -1047,6 +1048,7 @@ class Store extends HD_Controller 'e_time' => $base_info['e_time'] ? date('Y-m-d', $base_info['e_time']) : '', 'type' => $base_info['type'], 'rate' => strlen($base_info['rate']) ? $base_info['rate'] : 0, + 'biz_type' => $biz['type'], ]; $brands = []; $b_rows = $this->biz_trucking_model->select(['biz_id' => $base_info['biz_id'], 'status' => 1], '', '', '', 'auto_b_id,money'); @@ -1120,4 +1122,9 @@ class Store extends HD_Controller } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } + + public function lists_srv(){ + $biz_id = $this->input->get('id'); + echo $biz_id; + } } diff --git a/admin/views/biz/fine/get.php b/admin/views/biz/fine/get.php new file mode 100644 index 00000000..552da594 --- /dev/null +++ b/admin/views/biz/fine/get.php @@ -0,0 +1,81 @@ +
+ diff --git a/admin/views/biz/fine/lists.php b/admin/views/biz/fine/lists.php new file mode 100755 index 00000000..9307c67d --- /dev/null +++ b/admin/views/biz/fine/lists.php @@ -0,0 +1,93 @@ +| ID | +名称 | +成本价 | +状态 | +创建时间 | +
|---|---|---|---|---|
| = $v['id'] ?> | += $v['title'] ?> | += $v['price'] ?> | += $v['status_cn'] ?> | += $v['c_time'] ?> | +
| + 修改 + + + | +||||
| ID | +商家 | +供应商 | +其它参数 | +生效日期 | +类型 | +是否默认 | +状态 | +创建时间 | +
|---|---|---|---|---|---|---|---|---|
| = $v['id'] ?> | += $v['biz_name'] ?> | += $v['title'] ?> | +
+ $v2){?>
+ =$k2?>:= $v2 ?> + }?> + |
+ = $v['s_effect_time'] ?> | += $v['type_cn'] ?> | += $v['is_def'] ?> | += $v['status_cn'] ?> | += $v['c_time'] ?> | +
| + 修改 + + + | +||||||||