postData = $this->request->post(); return true; } //收费列表 public function feeList(){ $postData = $this->postData; $where = []; if(!empty($postData['user_name'])) $where['i.user_name'] = trim($postData['user_name']); if(!empty($postData['status'])) $where['f.status'] = trim($postData['status']); if(!empty($postData['start_time'])) $where['f.fee_time'] = ['>=',$postData['start_time']]; if(!empty($postData['end_time'])) $where['f.fee_time'] = ['<=',$postData['end_time']]; if(!empty($postData['building_name'])) $where['i.property_full_name'] = trim($postData['building_name']); $field = "i.order_no,r.report_no,id.city,id.area,id.building_name,f.status,i.bank_name,f.fee_time,i.user_name,r.id as reportid"; $list = Db::name('report')->alias('r') ->join('inquiry i','r.quot_id=i.id') ->join('property_cert_info id','i.id=id.quot_id') ->join('fee f','r.id=f.report_id','LEFT') ->where($where)->field($field) ->paginate($this->getPage()) ->each(function($item,$key){ $item['status'] = !empty($item['status']) && $item['status'] == 1 ? '已收费' : '未收费'; $item['inquiryCount'] = !empty($item['inquiryCount']) && $item['inquiryCount'] == 1 ? '单套' : '多套'; return $item; }) ->toArray(); return $this->buildSuccess(['list' => $list['data'], 'count' => $list['total']]); } //收费详情页-头部信息 public function feeBaseList(){ $postData = $this->postData; if(!empty($postData['reportid'])){ $reportid = $postData['reportid']; }else{ return $this->buildFailed('请求参数错误'); } //customer_name客户经理 贷款类型还没获取 $field = "i.bank_name,i.bank_branch_name,i.bank_sub_name,i.bank_customer_mgr_name, i.user_name,count(rd.report_id) as inquiryCount,rd.eva_total_value,trp.total_tax, trp.total_loan_value,i.type,r.create_time,r.report_no,r.id as reportid"; $baseinfo = \Db::name('report')->alias('r') ->join('inquiry i','r.quot_id=i.id','LEFT') ->join('report_detail rd','r.id=rd.report_id','LEFT') ->join('total_return_price trp','trp.quot_id=i.id','LEFT') ->join('survey s','i.order_no=s.order_no') ->where(['r.id'=>$reportid])->field($field)->find(); if($baseinfo['type'] == 1){ $baseinfo['type'] = '住宅'; }else{ $baseinfo['type'] = '商业'; } if($baseinfo){ return $this->buildSuccess($baseinfo); } return $this->buildFailed('数据获取失败'); } //收费详情页 数据获取接口 public function fee_detail(){ $postData = $this->postData; $reportid = $postData['reportid']; $fee_info = \Db::name('fee') ->field('report_id,biaozhun_fee,should_fee,mark') ->where(['report_id'=>$reportid])->find(); $building_name = \Db::name('report_detail') ->where(['report_id'=>$reportid])->field('building_name')->select(); foreach ($building_name as $name){ $fee_info['building_name'][] = $name['building_name']; } if($fee_info){ return $this->buildSuccess($fee_info); } return $this->buildFailed('未获取到数据'); } //收费提交接口 public function feeEdit(){ $postData = $this->postData; $reportid = $postData['reportid']; $should_fee = $postData['should_fee']; $saveData['should_fee'] = $should_fee; if($reportid <= 0) return $this->buildFailed('参数错误'); $res = \Db::name('fee')->where(['report_id'=>$reportid])->find(); if(empty($res)) return $this->buildFailed('报告信息错误,不能修改'); $saveData['update_time'] = date('Y-m-d H:i:s'); $res = \Db::name('fee')->where(['report_id'=>$reportid])->update($saveData); if($res){ $result = [ 'code' => 1, 'msg' => '修改成功', ]; $response = \Response::create($result, 'json'); return $response; } return $this->buildFailed('修改失败'); } //批量收费 public function mutilFee(){ $postData = $this->postData; $ids = $postData['ids']; $idArr = explode(',',$ids); \Db::startTrans(); if($idArr){ foreach ($idArr as $id){ $where['report_id'] = $id; $feeRecord = \Db::name('fee')->where($where)->field('status')->find(); if(!$feeRecord){ \Db::rollback(); return $this->buildFailed('参数错误,没有id:'.$id.'的记录'); } if($feeRecord['status'] != 2){ \Db::rollback(); return $this->buildFailed('参数错误,id:'.$id.'的收费状态不是未收费,不能修改'); } $res[] = \Db::name('fee')->where($where)->update(['status'=>1]); unset($where); } if(in_array(false,$res)){ return $this->buildFailed('修改失败'); }else{ \Db::commit(); $result = [ 'code' => 1, 'msg' => '修改成功', ]; $response = \Response::create($result, 'json'); return $response; } } \Db::rollback(); return $this->buildFailed('参数错误'); } }