最新更新内容
This commit is contained in:
		
							parent
							
								
									be6b1e2e69
								
							
						
					
					
						commit
						4578d6519c
					
				
							
								
								
									
										132
									
								
								application/api/controller/backend/Evaluationlevel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								application/api/controller/backend/Evaluationlevel.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,132 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use app\common\library\Ems;
 | 
				
			||||||
 | 
					use app\common\library\Sms;
 | 
				
			||||||
 | 
					use fast\Random;
 | 
				
			||||||
 | 
					use think\Config;
 | 
				
			||||||
 | 
					use think\Validate;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 考评级别
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class Evaluationlevel extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					    protected $noNeedRight = '*';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function geEvaluationlevelData()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $group_id  = $this->request->post('group_id');
 | 
				
			||||||
 | 
					        $page = $this->request->post('page',1);
 | 
				
			||||||
 | 
					        $size = $this->request->post('size',10);
 | 
				
			||||||
 | 
					        if(!$group_id){
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        $where['a.group_id'] = $group_id;
 | 
				
			||||||
 | 
					        // 从数据库中获取所有数据
 | 
				
			||||||
 | 
					        $data = Db::name('evaluation_level')
 | 
				
			||||||
 | 
					                ->field('a.*,p.name as user_group_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                // ->join('party_group w','a.party_id = w.id','LEFT')
 | 
				
			||||||
 | 
					                ->join('user_group p','a.group_id = p.id','LEFT')
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->page($page,$size)
 | 
				
			||||||
 | 
					                ->order('a.id asc')
 | 
				
			||||||
 | 
					                ->select();
 | 
				
			||||||
 | 
					        $count = Db::name('evaluation_level')
 | 
				
			||||||
 | 
					                ->field('a.*,p.name as user_group_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                // ->join('party_group w','a.party_id = w.id','LEFT')
 | 
				
			||||||
 | 
					                ->join('user_group p','a.group_id = p.id','LEFT')
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->order('a.id asc')
 | 
				
			||||||
 | 
					                ->count();
 | 
				
			||||||
 | 
					        $res = [
 | 
				
			||||||
 | 
					                'count' => $count,
 | 
				
			||||||
 | 
					                'data' => $data,
 | 
				
			||||||
 | 
					                ];
 | 
				
			||||||
 | 
					        return $this->success('请求成功',$res);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 单个用户查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getEvaluationlevelFind()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if (!$id) {
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $ret = Db::name('evaluation_level')->where('id',$id)->find();
 | 
				
			||||||
 | 
					        if ($ret) {
 | 
				
			||||||
 | 
					            $this->success(__('Logged in successful'), $ret);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error($this->auth->getError());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function create()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $data = $this->request->post();
 | 
				
			||||||
 | 
					        // if($data['password']){
 | 
				
			||||||
 | 
					        //     $data['password'] = md5($data['password']);
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					        // $data['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        // $data['updatetime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        $result = Db::name('evaluation_level')->strict(false)->insert($data);
 | 
				
			||||||
 | 
					        if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('添加成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('添加失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 更新记录
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param Request $request
 | 
				
			||||||
 | 
					     * @param int $id
 | 
				
			||||||
 | 
					     * @return \think\Response
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function update()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        $data = $this->request->post();
 | 
				
			||||||
 | 
					        $result = Db::name('evaluation_level')->where('id', $id)->strict(false)->update($data);
 | 
				
			||||||
 | 
					        if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('更新成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('更新失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除记录
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param int $id
 | 
				
			||||||
 | 
					     * @return \think\Response
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function delete()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $result = Db::name('evaluation_level')->delete($id);
 | 
				
			||||||
 | 
					        if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('删除成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('删除失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										274
									
								
								application/api/controller/backend/ExcelController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										274
									
								
								application/api/controller/backend/ExcelController.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,274 @@
 | 
				
			|||||||
 | 
					<?php  
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use PhpOffice\PhpSpreadsheet\Spreadsheet;  
 | 
				
			||||||
 | 
					use PhpOffice\PhpSpreadsheet\Writer\Xlsx;  
 | 
				
			||||||
 | 
					use think\Controller;  
 | 
				
			||||||
 | 
					use think\Db;  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ExcelController extends Api  
 | 
				
			||||||
 | 
					{  
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function dailyexport()  
 | 
				
			||||||
 | 
					    {  
 | 
				
			||||||
 | 
					        $ids = $this->request->get('ids','');
 | 
				
			||||||
 | 
					        // $ids = '9,10,12,13,';
 | 
				
			||||||
 | 
					        if(empty($ids)) {
 | 
				
			||||||
 | 
					            return $this->error('缺少用户ID参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        // 转换ID格式
 | 
				
			||||||
 | 
					        $idArray = explode(',', rtrim($ids, ','));
 | 
				
			||||||
 | 
					        $idArray = array_filter($idArray); // 过滤空值
 | 
				
			||||||
 | 
					        if(empty($idArray)) {
 | 
				
			||||||
 | 
					            return $this->error('无效的ID参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // 构建查询条件
 | 
				
			||||||
 | 
					        $where = [
 | 
				
			||||||
 | 
					            'a.id' => ['in', $idArray]
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        //  $this->success('返回成功', $where);
 | 
				
			||||||
 | 
					        // 执行查询
 | 
				
			||||||
 | 
					        $date = Db::name('addition_and_subtraction_records')
 | 
				
			||||||
 | 
					            ->alias('a')
 | 
				
			||||||
 | 
					            ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname,p.project_name,p.scoring_criteria,z.nickname as tb_nickname,a.fj_url')
 | 
				
			||||||
 | 
					            ->join('user u','a.user_id = u.id','LEFT')
 | 
				
			||||||
 | 
					            ->join('user_group g','a.group_id = g.id','LEFT')
 | 
				
			||||||
 | 
					            ->join('user w','a.zm_user_id = w.id','LEFT')
 | 
				
			||||||
 | 
					            ->join('user z','a.tb_user_id = z.id','LEFT')
 | 
				
			||||||
 | 
					            ->join('plus_minus_scoring p','a.assessment_project = p.id','LEFT')
 | 
				
			||||||
 | 
					            ->where($where)
 | 
				
			||||||
 | 
					            ->order('a.id', 'desc')
 | 
				
			||||||
 | 
					            ->select();
 | 
				
			||||||
 | 
					                    // $this->success('返回成功', $date);
 | 
				
			||||||
 | 
					        // 创建一个新的 Excel 文件  
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $spreadsheet = new Spreadsheet();  
 | 
				
			||||||
 | 
					        $sheet = $spreadsheet->getActiveSheet();  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 设置表头  
 | 
				
			||||||
 | 
					        $headers = ['姓名', '记录时间', '加减分类型', '记录人', '加减分项目', '内容', '分值', '附件地址']; // 根据你的 member 表字段进行调整  
 | 
				
			||||||
 | 
					        $columnIndex = 1; // A = 1, B = 2, ...  
 | 
				
			||||||
 | 
					        foreach ($headers as $header) {  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header);  
 | 
				
			||||||
 | 
					            $columnIndex++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 填充数据  
 | 
				
			||||||
 | 
					        $rowNumber = 2; // 从第二行开始填充数据  
 | 
				
			||||||
 | 
					        foreach ($date as $member) {  
 | 
				
			||||||
 | 
					            $type = '加分';
 | 
				
			||||||
 | 
					            if($member['assessment_type'] == 2){
 | 
				
			||||||
 | 
					                $type = '减分';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $columnIndex = 1;  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['nickname']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fsdate']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $type);
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['tb_nickname']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['project_name']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['scoring_criteria']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['score_value']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fj_url']);  
 | 
				
			||||||
 | 
					            $rowNumber++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 保存到 PHP 输出流  
 | 
				
			||||||
 | 
					        $writer = new Xlsx($spreadsheet);  
 | 
				
			||||||
 | 
					        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 | 
				
			||||||
 | 
					        header('Content-Disposition: attachment; filename="' . '加减分数据' . date('YmdHis') . '.xlsx"');
 | 
				
			||||||
 | 
					        // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"');  
 | 
				
			||||||
 | 
					        header('Cache-Control: max-age=0');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 输出到浏览器供用户下载  
 | 
				
			||||||
 | 
					        $writer->save('php://output');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 清理并退出  
 | 
				
			||||||
 | 
					        exit; 
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function groupIndexrecordsex()  
 | 
				
			||||||
 | 
					    {  
 | 
				
			||||||
 | 
					        $ids = $this->request->param('ids','');
 | 
				
			||||||
 | 
					        $searchMonth = $this->request->param('month', date('Y-m'));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // 转换ID格式
 | 
				
			||||||
 | 
					        $idArray = explode(',', rtrim($ids, ','));
 | 
				
			||||||
 | 
					        $group_id = array_filter($idArray); // 过滤空值
 | 
				
			||||||
 | 
					        if(empty($group_id)) {
 | 
				
			||||||
 | 
					            return $this->error('无效的ID参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // 参数验证
 | 
				
			||||||
 | 
					        // if (!$group_id) {
 | 
				
			||||||
 | 
					        //     $this->error('无效的id');
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					        if (!preg_match('/^\d{4}-\d{2}$/', $searchMonth)) {
 | 
				
			||||||
 | 
					            $this->error('月份参数格式错误');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 计算时间范围
 | 
				
			||||||
 | 
					        $firstDay = $searchMonth . '-01 00:00:00';
 | 
				
			||||||
 | 
					        $lastDay = date('Y-m-d 23:59:59', strtotime("last day of $searchMonth"));
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 分页查询用户
 | 
				
			||||||
 | 
					        $users = Db::name('user')
 | 
				
			||||||
 | 
					            ->alias('u')
 | 
				
			||||||
 | 
					            ->field(['u.id', 'u.nickname AS username', 'g.name AS group_name'])
 | 
				
			||||||
 | 
					            ->join('user_group g', 'u.group_id = g.id')
 | 
				
			||||||
 | 
					            ->where('u.id','in', $group_id)
 | 
				
			||||||
 | 
					            ->select();
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 统计分数(使用子查询优化)
 | 
				
			||||||
 | 
					        $scores = Db::name('addition_and_subtraction_records')
 | 
				
			||||||
 | 
					            ->field([
 | 
				
			||||||
 | 
					                'user_id',
 | 
				
			||||||
 | 
					                'SUM(CASE WHEN assessment_type = 1 THEN score_value ELSE 0 END) AS total_addition',
 | 
				
			||||||
 | 
					                'SUM(CASE WHEN assessment_type = 2 THEN score_value ELSE 0 END) AS total_subtraction'
 | 
				
			||||||
 | 
					            ])
 | 
				
			||||||
 | 
					            ->whereTime('fsdate', 'between', [$firstDay, $lastDay])
 | 
				
			||||||
 | 
					            ->group('user_id')
 | 
				
			||||||
 | 
					            ->select();
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 构建返回数据
 | 
				
			||||||
 | 
					        $returnData = [];
 | 
				
			||||||
 | 
					        foreach ($users as $user) {
 | 
				
			||||||
 | 
					            $scoreArray = array_column($scores, null, 'user_id');
 | 
				
			||||||
 | 
					            $total_addition = $scoreArray[$user['id']]['total_addition'] ?? 0;
 | 
				
			||||||
 | 
					            $total_subtraction = $scoreArray[$user['id']]['total_subtraction'] ?? 0;
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					            $returnData[] = [
 | 
				
			||||||
 | 
					                'user_id' =>  $user['id'],
 | 
				
			||||||
 | 
					                'username' => $user['username'],
 | 
				
			||||||
 | 
					                'group_name' => $user['group_name'],
 | 
				
			||||||
 | 
					                'month' => $searchMonth,
 | 
				
			||||||
 | 
					                'total_addition' => floatval($total_addition),
 | 
				
			||||||
 | 
					                'total_subtraction' => floatval($total_subtraction)
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // return $this->success('评价成功', $returnData);
 | 
				
			||||||
 | 
					                    // $this->success('返回成功', $date);
 | 
				
			||||||
 | 
					        // 创建一个新的 Excel 文件  
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $spreadsheet = new Spreadsheet();  
 | 
				
			||||||
 | 
					        $sheet = $spreadsheet->getActiveSheet();  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 设置表头  
 | 
				
			||||||
 | 
					        $headers = ['姓名', '科室', '月份', '加分值', '扣分值']; // 根据你的 member 表字段进行调整  
 | 
				
			||||||
 | 
					        $columnIndex = 1; // A = 1, B = 2, ...  
 | 
				
			||||||
 | 
					        foreach ($headers as $header) {  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header);  
 | 
				
			||||||
 | 
					            $columnIndex++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 填充数据  
 | 
				
			||||||
 | 
					        $rowNumber = 2; // 从第二行开始填充数据  
 | 
				
			||||||
 | 
					        foreach ($returnData as $member) {  
 | 
				
			||||||
 | 
					            $columnIndex = 1;  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['username']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['group_name']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['month']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['total_addition']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['total_subtraction']);  
 | 
				
			||||||
 | 
					            $rowNumber++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 保存到 PHP 输出流  
 | 
				
			||||||
 | 
					        $writer = new Xlsx($spreadsheet);  
 | 
				
			||||||
 | 
					        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 | 
				
			||||||
 | 
					        header('Content-Disposition: attachment; filename="' . '年终考评数据' . date('YmdHis') . '.xlsx"');
 | 
				
			||||||
 | 
					        // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"');  
 | 
				
			||||||
 | 
					        header('Cache-Control: max-age=0');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 输出到浏览器供用户下载  
 | 
				
			||||||
 | 
					        $writer->save('php://output');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 清理并退出  
 | 
				
			||||||
 | 
					        exit; 
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function RejectRedEnvelopesEs()  
 | 
				
			||||||
 | 
					    {  
 | 
				
			||||||
 | 
					        $ids = $this->request->param('ids','');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // 转换ID格式
 | 
				
			||||||
 | 
					        $idArray = explode(',', rtrim($ids, ','));
 | 
				
			||||||
 | 
					        $idArray = array_filter($idArray); // 过滤空值
 | 
				
			||||||
 | 
					        if(empty($idArray)) {
 | 
				
			||||||
 | 
					            return $this->error('无效的ID参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $where = [
 | 
				
			||||||
 | 
					            'a.id' => ['in', $idArray]
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        $date = Db::name('reject_red_envelopes')
 | 
				
			||||||
 | 
					                    ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname')
 | 
				
			||||||
 | 
					                    ->alias('a')
 | 
				
			||||||
 | 
					                    ->join('user u','a.user_id = u.id','LEFT')
 | 
				
			||||||
 | 
					                    ->join('user_group g','a.group_id = g.id','LEFT')
 | 
				
			||||||
 | 
					                    ->join('user w','a.zm_user_id = w.id','LEFT')
 | 
				
			||||||
 | 
					                    ->where($where)
 | 
				
			||||||
 | 
					                    ->order('a.id', 'desc')
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        // return $this->success('查询成功',$date);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // return $this->success('评价成功', $returnData);
 | 
				
			||||||
 | 
					                    // $this->success('返回成功', $date);
 | 
				
			||||||
 | 
					        // 创建一个新的 Excel 文件  
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $spreadsheet = new Spreadsheet();  
 | 
				
			||||||
 | 
					        $sheet = $spreadsheet->getActiveSheet();  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 设置表头  
 | 
				
			||||||
 | 
					        $headers = ['发生时间', '科室', '病区', '当事人姓名', '患者姓名', '人员编号', '退还金额', '退还日期', '退还方式', '备注', '附件地址链接']; // 根据你的 member 表字段进行调整  
 | 
				
			||||||
 | 
					        $columnIndex = 1; // A = 1, B = 2, ...  
 | 
				
			||||||
 | 
					        foreach ($headers as $header) {  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex, 1, $header);  
 | 
				
			||||||
 | 
					            $columnIndex++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 填充数据  
 | 
				
			||||||
 | 
					        $rowNumber = 2; // 从第二行开始填充数据  
 | 
				
			||||||
 | 
					        foreach ($date as $member) {  
 | 
				
			||||||
 | 
					            $fangshi = '现金';
 | 
				
			||||||
 | 
					            if($member['refunding_type'] == 2){
 | 
				
			||||||
 | 
					               $fangshi = '转账'; 
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $columnIndex = 1;  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fsdate']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['group_name']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['bq_name']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['nickname']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['hz_name']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['code']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['refunding_amount']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['thdate']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $fangshi);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['notes']);  
 | 
				
			||||||
 | 
					            $sheet->setCellValueByColumnAndRow($columnIndex++, $rowNumber, $member['fj_url']);  
 | 
				
			||||||
 | 
					            $rowNumber++;  
 | 
				
			||||||
 | 
					        }  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 保存到 PHP 输出流  
 | 
				
			||||||
 | 
					        $writer = new Xlsx($spreadsheet);  
 | 
				
			||||||
 | 
					        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
 | 
				
			||||||
 | 
					        header('Content-Disposition: attachment; filename="' . '拒收红包数据' . date('YmdHis') . '.xlsx"');
 | 
				
			||||||
 | 
					        // header('Content-Disposition: attachment;filename="活动报名列表' . date('YmdHis') . '.xlsx"');  
 | 
				
			||||||
 | 
					        header('Cache-Control: max-age=0');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 输出到浏览器供用户下载  
 | 
				
			||||||
 | 
					        $writer->save('php://output');  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 清理并退出  
 | 
				
			||||||
 | 
					        exit; 
 | 
				
			||||||
 | 
					    }  
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										79
									
								
								application/api/controller/backend/Mail.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								application/api/controller/backend/Mail.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,79 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 站内信控制器
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class Mail extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					    protected $noNeedRight = ['*'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 首页
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getMailData()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // 从数据库中获取所有数据
 | 
				
			||||||
 | 
					        $page = $this->request->post('page',1);
 | 
				
			||||||
 | 
					        $size = $this->request->post('size',10);
 | 
				
			||||||
 | 
					        $data = Db::name('mail')
 | 
				
			||||||
 | 
					                ->field('a.*,w.nickname')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user w','a.user_id = w.id','LEFT')
 | 
				
			||||||
 | 
					                ->page($page,$size)
 | 
				
			||||||
 | 
					                ->order('a.id asc')
 | 
				
			||||||
 | 
					                ->select();
 | 
				
			||||||
 | 
					        $count = Db::name('mail')
 | 
				
			||||||
 | 
					                ->field('a.*,w.nickname')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user w','a.user_id = w.id','LEFT')
 | 
				
			||||||
 | 
					                ->count();
 | 
				
			||||||
 | 
					        $res = [
 | 
				
			||||||
 | 
					                'count' => $count,
 | 
				
			||||||
 | 
					                'data' => $data,
 | 
				
			||||||
 | 
					                ];
 | 
				
			||||||
 | 
					        return $this->success('请求成功',$res);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     *添加数据
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static function createMail($user_id,$notification_content)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $data['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        $data['user_id'] = $user_id;
 | 
				
			||||||
 | 
					        $data['notify_status'] = 1;
 | 
				
			||||||
 | 
					        $data['notification_content'] = $notification_content;
 | 
				
			||||||
 | 
					        $result = Db::name('mail')->strict(false)->insert($data);
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     *修改
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public  function updateMail()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if (!$id) {
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $data = [];
 | 
				
			||||||
 | 
					        $data['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        $data['notify_status'] = 2;
 | 
				
			||||||
 | 
					        $result = Db::name('mail')->where('id', $id)->update($data);
 | 
				
			||||||
 | 
					         if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('更新成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('更新失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -5,6 +5,7 @@ namespace app\api\controller\backend;
 | 
				
			|||||||
use app\common\controller\Api;
 | 
					use app\common\controller\Api;
 | 
				
			||||||
use app\api\model\Admin as AdminModel;
 | 
					use app\api\model\Admin as AdminModel;
 | 
				
			||||||
use think\Db;
 | 
					use think\Db;
 | 
				
			||||||
 | 
					use app\api\controller\backend\Mail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 月度控制器
 | 
					 * 月度控制器
 | 
				
			||||||
@ -263,6 +264,11 @@ class Monthly extends Api
 | 
				
			|||||||
        if (!empty($insertData)) {
 | 
					        if (!empty($insertData)) {
 | 
				
			||||||
            $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData);
 | 
					            $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData);
 | 
				
			||||||
            if ($result) {
 | 
					            if ($result) {
 | 
				
			||||||
 | 
					                $user = Db::name('user')->where('id', $user_id)->find();
 | 
				
			||||||
 | 
					                $group_id = $user['group_id'];
 | 
				
			||||||
 | 
					                $mail_user = Db::name('user')->where('group_id', $group_id)->where('auth_group_id',4)->find();
 | 
				
			||||||
 | 
					                $mail_user_id = $mail_user['id'];
 | 
				
			||||||
 | 
					                Mail::createMail($mail_user_id,'您的科室下有月度自评待审核人员');
 | 
				
			||||||
                return $this->success('数据插入成功', $result);
 | 
					                return $this->success('数据插入成功', $result);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return $this->error('数据插入失败');
 | 
					                return $this->error('数据插入失败');
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										124
									
								
								application/api/controller/backend/PartyStyle.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								application/api/controller/backend/PartyStyle.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,124 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use app\api\model\Admin as AdminModel;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 党风教育控制器
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class PartyStyle extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					    protected $noNeedRight = ['*'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 首页
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getPartyStylData()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $page = $this->request->post('page',1);
 | 
				
			||||||
 | 
					        $size = $this->request->post('size',10);
 | 
				
			||||||
 | 
					        // 从数据库中获取所有数据
 | 
				
			||||||
 | 
					        $data = Db::name('party_style')->select();
 | 
				
			||||||
 | 
					        $count =  Db::name('party_style')->count();
 | 
				
			||||||
 | 
					        $res = [
 | 
				
			||||||
 | 
					                'data' => $data,
 | 
				
			||||||
 | 
					                'count' => $count
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					        return $this->success('请求成功',$res);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     *单个科室查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getPartyStylFind()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // 从数据库中获取所有数据
 | 
				
			||||||
 | 
					        $data = Db::name('party_style')->where('id', $id)->find();
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					        return $this->success('请求成功',$data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     *添加数据
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function create()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $data = $this->request->post();
 | 
				
			||||||
 | 
					        $data['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        $result = Db::name('party_style')->strict(false)->insert($data);
 | 
				
			||||||
 | 
					        if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('添加成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('添加失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 更新记录
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param Request $request
 | 
				
			||||||
 | 
					     * @param int $id
 | 
				
			||||||
 | 
					     * @return \think\Response
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function update()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if (!$id) {
 | 
				
			||||||
 | 
					            return $this->error('参数错误');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        // 获取原始POST数据(包含所有字段)
 | 
				
			||||||
 | 
					        $data = $_POST;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // 移除ID字段(避免更新ID)
 | 
				
			||||||
 | 
					        // unset($data['id']);
 | 
				
			||||||
 | 
					        // return $this->success('更新成功', $data);
 | 
				
			||||||
 | 
					        // 关闭字段严格校验
 | 
				
			||||||
 | 
					        $result = Db::name('party_style')
 | 
				
			||||||
 | 
					            ->where('id', $id)
 | 
				
			||||||
 | 
					            ->strict(false) // 关闭字段白名单校验
 | 
				
			||||||
 | 
					            ->update($data);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if ($result !== false) {
 | 
				
			||||||
 | 
					            return $this->success('更新成功', $result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('更新失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除记录
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param int $id
 | 
				
			||||||
 | 
					     * @return \think\Response
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function delete()
 | 
				
			||||||
 | 
					    {   
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $result = Db::name('party_style')->delete($id);
 | 
				
			||||||
 | 
					        if ($result) {
 | 
				
			||||||
 | 
					            return $this->success('删除成功',$result);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return $this->error('删除失败',$result);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										527
									
								
								application/api/controller/backend/Pdf.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										527
									
								
								application/api/controller/backend/Pdf.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,527 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					use think\Session;
 | 
				
			||||||
 | 
					use PhpOffice\PhpSpreadsheet\Spreadsheet;  
 | 
				
			||||||
 | 
					use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf as PdfWriter;  
 | 
				
			||||||
 | 
					use app\common\model\Member;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Pdf extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected $noNeedRight = ['*'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function exportPdf()  
 | 
				
			||||||
 | 
					    {  
 | 
				
			||||||
 | 
					        $id = $this->request->get('id');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $user = Db::name('politics')
 | 
				
			||||||
 | 
					                ->field('a.*,p.nickname as user_name,p.gender,u.name as group_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user p','a.user_id = p.id','LEFT')
 | 
				
			||||||
 | 
					                ->join('user_group u','a.group_id = u.id','LEFT')
 | 
				
			||||||
 | 
					                ->where('a.id', $id)
 | 
				
			||||||
 | 
					                ->find();
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        // return $this->success('请求成功',$user);
 | 
				
			||||||
 | 
					        $content = htmlspecialchars_decode($user['politics_content']);
 | 
				
			||||||
 | 
					        $FontStyle = 'stsongstdlight';//字体
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        //引入扩展
 | 
				
			||||||
 | 
					        vendor('Tcpdf.tcpdf');
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        //初始化tcpdf className = Tcpdf
 | 
				
			||||||
 | 
					        $pdf = new \Tcpdf('P', 'mm', 'A4', true, 'UTF-8', false); 
 | 
				
			||||||
 | 
					        $pdf->SetFont($FontStyle, '', 12);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 是否显示页眉
 | 
				
			||||||
 | 
					        $pdf->setPrintHeader(false);
 | 
				
			||||||
 | 
							$pdf->setPrintFooter(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置文档对齐,间距,字体,图片
 | 
				
			||||||
 | 
					        $pdf->SetCreator(PDF_CREATOR);
 | 
				
			||||||
 | 
					        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
 | 
				
			||||||
 | 
					        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置页眉页脚 边距
 | 
				
			||||||
 | 
					        $pdf->setHeaderMargin(PDF_MARGIN_HEADER);
 | 
				
			||||||
 | 
					        $pdf->setFooterMargin(PDF_MARGIN_FOOTER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //自动分页
 | 
				
			||||||
 | 
					        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
 | 
				
			||||||
 | 
					        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
 | 
				
			||||||
 | 
					        $pdf->setFontSubsetting(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$if_organization = $user['open_status'] == 1 ? '匿名' : $user['user_name'];
 | 
				
			||||||
 | 
					$gender = $user['gender'] == 1 ? '男' : '女';
 | 
				
			||||||
 | 
					$acceptance_status = $user['acceptance_status'] == 1 ? '待处理' : '已回复';
 | 
				
			||||||
 | 
					// $tuanweifuzerenxinxiPhone = '';
 | 
				
			||||||
 | 
					// if($user_info['tuanweifuzerenxinxi']){
 | 
				
			||||||
 | 
					//     $user_info['tuanweifuzerenxinxi'] = json_decode($user_info['tuanweifuzerenxinxi'], true)[0]['name'];  
 | 
				
			||||||
 | 
					//     $tuanweifuzerenxinxiPhone = json_decode($user_info['tuanweifuzerenxinxi'], true)[0]['phone'];  
 | 
				
			||||||
 | 
					// // }
 | 
				
			||||||
 | 
					// return $this->success('请求成功',$user);
 | 
				
			||||||
 | 
					// var_dump($user);die();
 | 
				
			||||||
 | 
					$table_info_three = '
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					table tr{
 | 
				
			||||||
 | 
						line-height:30px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					table td{
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					<div style="text-align: center; font-size: 36px; font-weight: bold; width: 80%; margin: 50px auto; padding-bottom: 10px;">
 | 
				
			||||||
 | 
					    投诉建议回访表
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					<table width="100%" border="1" cellspacing="0" cellpadding="0">
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>姓名</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['user_name'].'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>科室</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['group_name'].'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
						    <td>投诉时间</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['createtime'].'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>处理状态</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$acceptance_status.'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>处理内容</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['acceptance_content'].'</td>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>受理时间</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['acceptance_time'].'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td>投诉内容</td>
 | 
				
			||||||
 | 
							<td colspan="5">'.$user['politics_content'].'</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<tr>
 | 
				
			||||||
 | 
							<td><p>  </p><p>  </p>本人签字</td>
 | 
				
			||||||
 | 
							<td colspan="5">
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<span style="width:200px;"> 本人签字:        </span>
 | 
				
			||||||
 | 
								<span style="width:100px;"> 年 </span>
 | 
				
			||||||
 | 
								<span style="width:100px;"> 月 </span> 
 | 
				
			||||||
 | 
								<span style="width:100px;"> 日 </span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td><p>  </p>本人所在单位回访意见</td>
 | 
				
			||||||
 | 
							<td colspan="5">
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<p>  </p>
 | 
				
			||||||
 | 
								<span style="width:200px;"> 盖章:          </span>
 | 
				
			||||||
 | 
								<span style="width:100px;"> 年 </span>
 | 
				
			||||||
 | 
								<span style="width:100px;"> 月 </span>
 | 
				
			||||||
 | 
								<span style="width:100px;"> 日 </span>
 | 
				
			||||||
 | 
							</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						</table>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置正文字体,大小   (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
 | 
				
			||||||
 | 
					        $pdf->SetFont($FontStyle, '', 14);
 | 
				
			||||||
 | 
					        //创建页面,渲染PDF
 | 
				
			||||||
 | 
					        $pdf->AddPage();
 | 
				
			||||||
 | 
							$pdf->SetAlpha(0.2); //设置你需要的透明度
 | 
				
			||||||
 | 
							$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
 | 
				
			||||||
 | 
					        $pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
 | 
				
			||||||
 | 
							$pdf->SetAlpha(1);//恢复原始透明度	
 | 
				
			||||||
 | 
					        $pdf->writeHTML($table_info_three, true, false, false, false, '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$pdf->LastPage(); 
 | 
				
			||||||
 | 
					        //文件保存
 | 
				
			||||||
 | 
					        $saveName = date('Y-m-d').'.pdf';
 | 
				
			||||||
 | 
					        $savePath = $saveName;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //PDF输出模式 I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串
 | 
				
			||||||
 | 
					        $pdf->Output($savePath,'D');
 | 
				
			||||||
 | 
					        if(!file_exists($savePath)){
 | 
				
			||||||
 | 
								$pdf->Output($savePath,'D');
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							return json(['status'=>'11','msg'=>'生成成功']);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function personalProfile()  
 | 
				
			||||||
 | 
					    {  
 | 
				
			||||||
 | 
					        $user_id = $this->request->get('id',261);
 | 
				
			||||||
 | 
					        $time = $this->request->get('time',date('Y'));
 | 
				
			||||||
 | 
					        $evaluation_schedule_id = $this->request->post('evaluation_schedule_id');  
 | 
				
			||||||
 | 
					        $scoringrecord_status = $this->request->post('scoringrecord_status');  
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        if($user_id){
 | 
				
			||||||
 | 
					            $where['a.id'] = $user_id;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $user = Db::name('user')
 | 
				
			||||||
 | 
					                ->field('a.*,p.name as group_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user_group p','a.group_id = p.id','LEFT')
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->find();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//  return $this->success('查询成功', $result);
 | 
				
			||||||
 | 
					        // foreach ($result as $key => $value) {
 | 
				
			||||||
 | 
					            // $group_name = Db::name('user_group')->where('id', $value['group_id'])->value('name');
 | 
				
			||||||
 | 
					            $user_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('self_score');
 | 
				
			||||||
 | 
					            $department_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('department_score');
 | 
				
			||||||
 | 
					            $hospital_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('hospital_score');
 | 
				
			||||||
 | 
					            $party_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('party_branch_score');
 | 
				
			||||||
 | 
					            $overall_score_scoringrecord = Db::name('scoringrecord')->where('user_id', $user_id)->where('term', $time)->where('evaluation_schedule_id',$evaluation_schedule_id)->sum('overall_party_score');
 | 
				
			||||||
 | 
					            //获取改年总加分的分值
 | 
				
			||||||
 | 
					            $zongjiafenfenzhi = Db::name('addition_and_subtraction_records')->where('user_id',$user_id)->where('YEAR(createtime)', $time)->where('status',2)->where('assessment_type',1)->sum('score_value');
 | 
				
			||||||
 | 
					            //获取改年总减分的分值
 | 
				
			||||||
 | 
					            $zongjianfenfenzhi = Db::name('addition_and_subtraction_records')->where('user_id', $user_id)->where('YEAR(createtime)', $time)->where('status',2)->where('assessment_type',2)->sum('score_value');
 | 
				
			||||||
 | 
					            $time= $time;
 | 
				
			||||||
 | 
					            $zongjiafen = 0;
 | 
				
			||||||
 | 
					            $scoringrecord_status = '1';
 | 
				
			||||||
 | 
					            $total_score = 0;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if($user_scoringrecord == 0){
 | 
				
			||||||
 | 
					                $scoringrecord_status = '2';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if($department_score_scoringrecord != 0){
 | 
				
			||||||
 | 
					                $scoringrecord_status = '3';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // if($result[$key]['party_score_scoringrecord'] != 0){
 | 
				
			||||||
 | 
					            //     $result[$key]['scoringrecord_status'] = '5';
 | 
				
			||||||
 | 
					            // }
 | 
				
			||||||
 | 
					            // if($result[$key]['overall_score_scoringrecord'] != 0){
 | 
				
			||||||
 | 
					            //     $result[$key]['scoringrecord_status'] = '6';
 | 
				
			||||||
 | 
					            // }
 | 
				
			||||||
 | 
					             if($hospital_score_scoringrecord != 0){
 | 
				
			||||||
 | 
					                $scoringrecord_status = '4';
 | 
				
			||||||
 | 
					                $total_score = $user_scoringrecord * 0.4 + $department_score_scoringrecord * 0.6 + $party_score_scoringrecord * 0.4 + $zongjiafenfenzhi - $zongjianfenfenzhi;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        // return $this->success('查询成功', $result);
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					        // return $this->success('请求成功',$user);
 | 
				
			||||||
 | 
					        // $content = htmlspecialchars_decode($user['politics_content']);
 | 
				
			||||||
 | 
					        $FontStyle = 'stsongstdlight';//字体
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        //引入扩展
 | 
				
			||||||
 | 
					        vendor('Tcpdf.tcpdf');
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        //初始化tcpdf className = Tcpdf
 | 
				
			||||||
 | 
					        $pdf = new \Tcpdf('P', 'mm', 'A4', true, 'UTF-8', false); 
 | 
				
			||||||
 | 
					        $pdf->SetFont($FontStyle, '', 12);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 是否显示页眉
 | 
				
			||||||
 | 
					        $pdf->setPrintHeader(false);
 | 
				
			||||||
 | 
							$pdf->setPrintFooter(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置文档对齐,间距,字体,图片
 | 
				
			||||||
 | 
					        $pdf->SetCreator(PDF_CREATOR);
 | 
				
			||||||
 | 
					        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
 | 
				
			||||||
 | 
					        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置页眉页脚 边距
 | 
				
			||||||
 | 
					        $pdf->setHeaderMargin(PDF_MARGIN_HEADER);
 | 
				
			||||||
 | 
					        $pdf->setFooterMargin(PDF_MARGIN_FOOTER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //自动分页
 | 
				
			||||||
 | 
					        $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
 | 
				
			||||||
 | 
					        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
 | 
				
			||||||
 | 
					        $pdf->setFontSubsetting(true);
 | 
				
			||||||
 | 
					        $pdf->AddPage();
 | 
				
			||||||
 | 
							$pdf->SetAlpha(0.2); //设置你需要的透明度
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$pdf->SetAlpha(1);//恢复原始透明度		
 | 
				
			||||||
 | 
							$pdf->SetFont($FontStyle, '', 16);
 | 
				
			||||||
 | 
							$pdf->Ln(33);
 | 
				
			||||||
 | 
							$html_one = '<h1 style="text-align:center;line-height:50%;">信阳市传染病医院医德医风考评档案</h1>';
 | 
				
			||||||
 | 
							$pdf->writeHTML($html_one, true, false, true, false, '');
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							$pdf->Ln(40);
 | 
				
			||||||
 | 
							$pdf->SetLeftMargin(40);	
 | 
				
			||||||
 | 
							$pdf->Line(78, 107, 155, 107, $style=array());
 | 
				
			||||||
 | 
							$pdf->Line(78, 115, 155, 115, $style=array());
 | 
				
			||||||
 | 
							$pdf->Line(78, 123, 155, 123, $style=array());
 | 
				
			||||||
 | 
							$html_two = '
 | 
				
			||||||
 | 
							<dl style="letter-spacing:2px;font-size:14px;">
 | 
				
			||||||
 | 
								<dd><p style="line-height:80%;">姓<span>  </span>名:<span>      </span>'.$user['nickname'].'</p></dd>
 | 
				
			||||||
 | 
								<dd><p style="line-height:80%;">科<span>  </span>室:<span>      </span>'.$user['group_name'].'</p></dd>
 | 
				
			||||||
 | 
								<dd><p style="line-height:80%;">填表日期:<span>     </span>'.date('Y年m月d日',time()).'</p></dd>
 | 
				
			||||||
 | 
							</dl>';
 | 
				
			||||||
 | 
							$pdf->writeHTML($html_two, true, false, true, false, '');
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							$pdf->SetLeftMargin(55);	
 | 
				
			||||||
 | 
						    $pdf->SetRightMargin(53);	
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
							$pdf->SetLeftMargin(55);
 | 
				
			||||||
 | 
							$pdf->SetRightMargin(53);
 | 
				
			||||||
 | 
							$pdf->Ln(60);	
 | 
				
			||||||
 | 
							$html_three = '
 | 
				
			||||||
 | 
							<p style="text-align:center;line-height:40%;">信阳市第五人民医院</p>
 | 
				
			||||||
 | 
							<p style="text-align:center;line-height:40%;">二○二五年制</p>';
 | 
				
			||||||
 | 
							$pdf->writeHTML($html_three, true, false, true, false, '');	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$pdf->SetLeftMargin(10);
 | 
				
			||||||
 | 
					$table_info_three = '
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					table tr{
 | 
				
			||||||
 | 
					    line-height:40px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					table td{
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					<table width="100%" border="1" cellspacing="0" cellpadding="0">
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>姓名</td>
 | 
				
			||||||
 | 
					<td colspan="2" >'.$user['nickname'].'</td>
 | 
				
			||||||
 | 
					<td>科室</td>
 | 
				
			||||||
 | 
					<td colspan="2">'.$user['group_name'].'</td>
 | 
				
			||||||
 | 
					<td>政治面貌</td>
 | 
				
			||||||
 | 
					<td colspan="3">'.$user['nickname'].'</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>岗位</td>
 | 
				
			||||||
 | 
					<td colspan="2" >'.$user['position'].'</td>
 | 
				
			||||||
 | 
					<td>职称</td>
 | 
				
			||||||
 | 
					<td colspan="2">'.$user['administrative_position'].'</td>
 | 
				
			||||||
 | 
					<td>出生日期</td>
 | 
				
			||||||
 | 
					<td colspan="3">'.$user['birthday'].'</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>自我评价小结</td>
 | 
				
			||||||
 | 
					<td colspan="9">
 | 
				
			||||||
 | 
					<p>  </p>
 | 
				
			||||||
 | 
					<p>  </p>
 | 
				
			||||||
 | 
					</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>自我评价</td>
 | 
				
			||||||
 | 
					<td colspan="9">
 | 
				
			||||||
 | 
					  等级:>  优秀□  良好□  一般□  较差□
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					<span style="width:200px;"> 个人签名:         </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 年 </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 月 </span> 
 | 
				
			||||||
 | 
					<span style="width:100px;"> 日 </span>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>科室评价意见</td>
 | 
				
			||||||
 | 
					<td colspan="9">
 | 
				
			||||||
 | 
					  等级:>  优秀□  良好□  一般□  较差□
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					<span style="width:150px;"> 科室评价负责人签字:       </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 年 </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 月 </span> 
 | 
				
			||||||
 | 
					<span style="width:100px;"> 日 </span>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					<tr >
 | 
				
			||||||
 | 
					<td>单位意见评价</td>
 | 
				
			||||||
 | 
					<td colspan="9">
 | 
				
			||||||
 | 
					  等级:>  优秀□  良好□  一般□  较差□
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					<span style="width:200px;"> (盖章):         </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 年 </span>
 | 
				
			||||||
 | 
					<span style="width:100px;"> 月 </span> 
 | 
				
			||||||
 | 
					<span style="width:100px;"> 日 </span>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					</td>
 | 
				
			||||||
 | 
					</tr>
 | 
				
			||||||
 | 
					</table>';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置正文字体,大小   (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
 | 
				
			||||||
 | 
					         $pdf->SetFont($FontStyle, '', 14);
 | 
				
			||||||
 | 
					        //创建页面,渲染PDF
 | 
				
			||||||
 | 
					        $pdf->AddPage();
 | 
				
			||||||
 | 
							$pdf->SetAlpha(0.2); //设置你需要的透明度
 | 
				
			||||||
 | 
							$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					        $pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
 | 
				
			||||||
 | 
					        $pdf->SetLeftMargin(10);	
 | 
				
			||||||
 | 
						    $pdf->SetRightMargin(10);	
 | 
				
			||||||
 | 
						    
 | 
				
			||||||
 | 
							$pdf->SetLeftMargin(10);
 | 
				
			||||||
 | 
							$pdf->SetRightMargin(10);
 | 
				
			||||||
 | 
							$pdf->SetAlpha(1);//恢复原始透明度	
 | 
				
			||||||
 | 
					        $pdf->SetMargins(0, 10, 10, true);
 | 
				
			||||||
 | 
					        $pdf->writeHTML($table_info_three, true, false, false, false, '');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$table_info_one = '
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					table tr{line-height:40px;}
 | 
				
			||||||
 | 
					table td{
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					table tr{line-height:30px;}
 | 
				
			||||||
 | 
					table td{
 | 
				
			||||||
 | 
					    vertical-align: middle;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					<h1 style="text-align:center;line-height:50%;">信阳市传染病医院医德医风考评档案</h1>
 | 
				
			||||||
 | 
					<table width="100%" border="1" cellspacing="0" cellpadding="0">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						<tr >
 | 
				
			||||||
 | 
							<td colspan="7">考评内容</td>
 | 
				
			||||||
 | 
							<td>分值</td>
 | 
				
			||||||
 | 
							<td>得分</td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						 <tr>
 | 
				
			||||||
 | 
					        <td rowspan="5" ><p>       </p>一、爱岗敬业奉献,恪守职业道德(15分)</td>
 | 
				
			||||||
 | 
					        <td colspan="6">1.服务热情周到,态度和蔼可亲, 着装整洁,举止端庄,语言文明规范,无“生、冷、硬、顶、推、拖”现象。</td>
 | 
				
			||||||
 | 
					        <td style="vertical-align: middle;">3分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">2.加强政治理论和职业道德学习,刻苦钻研与业务工作相关的新知识、新技术,提高专业技术能力和水平,提升医疗服务质量。</td>
 | 
				
			||||||
 | 
					        <td>3分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">3.树立救死扶伤、以病人为中心、全心全意为人民服务的宗旨意识和服务意识,大力弘扬新时代卫生职业精神,热爱本职工作;责任意识强,有效防范杜绝医疗差错、医疗事故的发生。</td>
 | 
				
			||||||
 | 
					        <td>3分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">4.平等对待患者,做到一视同仁,不歧视患者。维护患者合法权益,尊重患者知情权、选择权和隐私权,为患者保守医疗秘密。</td>
 | 
				
			||||||
 | 
					        <td>3分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">5.依法依规开展临床药物、医疗器械及临床医疗技术试验,应用新技术和有创诊疗活动中,遵守医学伦理道德,尊重患者的知情同意权。</td>
 | 
				
			||||||
 | 
					        <td>3分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td rowspan="9"><p>       </p><p>       </p>二、严格遵守“九项”准则,切实规范诊疗行为(75分)</td>
 | 
				
			||||||
 | 
					        <td colspan="6">1.合法按劳取酬,不接受商业提成。依法依规按劳取酬。严禁利用执业之便开单提成;严禁以商业目的进行统方;除就诊医院所在医联体的其他医疗机构,和被纳入医保“双通道”管理的定点零售药店外,严禁安排患者到其他指定地点购买医药耗材等产品;严禁向患者推销商品或服务并从中谋取私利;严禁接受互联网企业与开处方配药有关的费用。</td>
 | 
				
			||||||
 | 
					        <td>10分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">2.严守诚信原则,不参与欺诈骗保。依法依规合理使用医疗保障基金,遵守医保协议管理,向医保患者告知提供的医药服务是否在医保规定的支付范围内。严禁诱导、协助他人冒名或者虚假就医、购药、提供虚假证明材料、串通他人虚开费用单据等手段骗取、套取医疗保障基金。</td>
 | 
				
			||||||
 | 
					        <td>10分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">3.依据规范行医,不实施过度诊疗。严格执行各项规章制度,在诊疗活动中应当向患者说明病情、医疗措施。严禁以单纯增加医疗机构收入或谋取私利为目的过度治疗和过度检查,给患者增加不必要的风险和费用负担。</td>
 | 
				
			||||||
 | 
					        <td>8分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">4.遵守工作规程,不违规接受捐赠。依法依规接受捐赠。严禁以个人名义,或者假借单位名义接受利益相关者的捐赠资助,并据此区别对待患者。</td>
 | 
				
			||||||
 | 
					        <td>7分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">5.恪守保密准则,不泄露患者隐私。确保患者院内信息安全。严禁违规收集、使用、加工、传输、透露、买卖患者在医疗机构内所提供的个人资料、产生的医疗信息。</td>
 | 
				
			||||||
 | 
					        <td>5分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">6.服从诊疗需要,不牟利转介患者。客观公正合理地根据患者需要提供医学信息、运用医疗资源。除因需要在医联体内正常转诊外,严禁以谋取个人利益为目的,经由网上或线下途径介绍、引导患者到指定医疗机构就诊。</td>
 | 
				
			||||||
 | 
					        <td>10分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">7.维护诊疗秩序,不破坏就医公平。坚持平等原则,共建公平就医环境。严禁利用号源、床源、紧缺药品耗材等医疗资源或者检查、手术等诊疗安排收受好处、损公肥私。</td>
 | 
				
			||||||
 | 
					        <td>5分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">8.共建和谐关系,不收受患方“红包”。恪守医德、严格自律。严禁索取或者收受患者及其亲友的礼品、礼金、消费卡和有价证券、股权、其他金融产品等财物;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。</td>
 | 
				
			||||||
 | 
					        <td>10分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">9.恪守交往底线,不收受企业回扣。遵纪守法、廉洁从业。严禁接受药品、医疗设备、医疗器械、医用卫生材料等医疗产品生产、经营企业或者经销人员以任何名义、形式给予的回扣;严禁参加其安排、组织或者支付费用的宴请或者旅游、健身、娱乐等活动安排。</td>
 | 
				
			||||||
 | 
					        <td>10分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td rowspan="2">三、服从指挥调配,团结协作共事(10分)</td>
 | 
				
			||||||
 | 
					        <td colspan="6">1.服从指挥、调配,积极参加上级安排的指令性医疗任务和社会公益性的疫情防控、义诊、对口帮扶和突发公共卫生事件等医疗活动。</td>
 | 
				
			||||||
 | 
					        <td>5分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td colspan="6">2.正确处理同行、同事间的关系,互相尊重,互相配合,取长补短,共同进步。</td>
 | 
				
			||||||
 | 
					        <td>5分</td>
 | 
				
			||||||
 | 
					        <td></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					     <tr >
 | 
				
			||||||
 | 
					        <td colspan="1">总分</td>
 | 
				
			||||||
 | 
							<td colspan="7"></td>
 | 
				
			||||||
 | 
							<td></td>
 | 
				
			||||||
 | 
						</tr>
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					<p></p>
 | 
				
			||||||
 | 
					<h1 style="text-align:center;line-height:50%;">说明:优秀90-100分,良好76-89分,一般60-75分,较差﹤60分。</h1>
 | 
				
			||||||
 | 
					';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //设置正文字体,大小   (stsongstdlight,网上说这个字体支持的文字更全,支持中文不乱码)
 | 
				
			||||||
 | 
					        $pdf->SetFont($FontStyle, '', 10);
 | 
				
			||||||
 | 
					        //创建页面,渲染PDF
 | 
				
			||||||
 | 
					        $pdf->AddPage();
 | 
				
			||||||
 | 
							$pdf->SetAlpha(0.2); //设置你需要的透明度
 | 
				
			||||||
 | 
							$img_file = $_SERVER["DOCUMENT_ROOT"] .'water.png';
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					        $pdf->Image($img_file, 10, 0, 0, 0, '', '', '', true, 300, '', false, false);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							$pdf->SetAlpha(1);//恢复原始透明度	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $pdf->writeHTML($table_info_one, true, false, true, true, '');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							$pdf->LastPage(); 
 | 
				
			||||||
 | 
					        //文件保存
 | 
				
			||||||
 | 
					        $saveName = date('Y-m-d').'.pdf';
 | 
				
			||||||
 | 
					        $savePath = $saveName;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        //PDF输出模式 I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串
 | 
				
			||||||
 | 
					        $pdf->Output($savePath,'D');
 | 
				
			||||||
 | 
					        if(!file_exists($savePath)){
 | 
				
			||||||
 | 
								$pdf->Output($savePath,'D');
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
							return json(['status'=>'11','msg'=>'生成成功']);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -93,7 +93,9 @@ class Politics extends Api
 | 
				
			|||||||
        if ($result === false) {
 | 
					        if ($result === false) {
 | 
				
			||||||
            return $this->error('编辑失败');
 | 
					            return $this->error('编辑失败');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        $user = Db::name('politics')->where('id', $id)->find();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Mail::createMail($user['user_id'],'您的投诉建议已受理,请查看');
 | 
				
			||||||
        return $this->success('编辑成功');
 | 
					        return $this->success('编辑成功');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -255,6 +255,11 @@ class Quarter extends Api
 | 
				
			|||||||
        if (!empty($insertData)) {
 | 
					        if (!empty($insertData)) {
 | 
				
			||||||
            $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData);
 | 
					            $result = Db::name('scoringrecord')->strict(false)->insertAll($insertData);
 | 
				
			||||||
            if ($result) {
 | 
					            if ($result) {
 | 
				
			||||||
 | 
					                $user = Db::name('user')->where('id', $user_id)->find();
 | 
				
			||||||
 | 
					                $group_id = $user['group_id'];
 | 
				
			||||||
 | 
					                $mail_user = Db::name('user')->where('group_id', $group_id)->where('auth_group_id',4)->find();
 | 
				
			||||||
 | 
					                $mail_user_id = $mail_user['id'];
 | 
				
			||||||
 | 
					                Mail::createMail($mail_user_id,'您的科室下有季度自评待审核人员');
 | 
				
			||||||
                return $this->success('数据插入成功', $result);
 | 
					                return $this->success('数据插入成功', $result);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return $this->error('数据插入失败');
 | 
					                return $this->error('数据插入失败');
 | 
				
			||||||
@ -748,6 +753,16 @@ class Quarter extends Api
 | 
				
			|||||||
        // 对比并输出结果
 | 
					        // 对比并输出结果
 | 
				
			||||||
        $result = [];
 | 
					        $result = [];
 | 
				
			||||||
        foreach ($periods as $period) {
 | 
					        foreach ($periods as $period) {
 | 
				
			||||||
 | 
					            if (!isset($scoringQuarters[$period])) {
 | 
				
			||||||
 | 
					        $scoringQuarters[$period] = [
 | 
				
			||||||
 | 
					            'plus_score' => 0,
 | 
				
			||||||
 | 
					            'minus_score' => 0,
 | 
				
			||||||
 | 
					            'self_score' => 0,
 | 
				
			||||||
 | 
					            'department_score' => 0,
 | 
				
			||||||
 | 
					            'hospital_score' => 0,
 | 
				
			||||||
 | 
					            'createtime' => null,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
            list($year, $quarter) = explode('-', $period);
 | 
					            list($year, $quarter) = explode('-', $period);
 | 
				
			||||||
            $quarterStartMonth = ($quarter - 1) * 3 + 1;
 | 
					            $quarterStartMonth = ($quarter - 1) * 3 + 1;
 | 
				
			||||||
            $quarterEndMonth = $quarter * 3;
 | 
					            $quarterEndMonth = $quarter * 3;
 | 
				
			||||||
@ -786,11 +801,11 @@ class Quarter extends Api
 | 
				
			|||||||
                'quarter' => $period,
 | 
					                'quarter' => $period,
 | 
				
			||||||
                'user' => $user['nickname'],
 | 
					                'user' => $user['nickname'],
 | 
				
			||||||
                'currentQuarter' => $currentPeriod,
 | 
					                'currentQuarter' => $currentPeriod,
 | 
				
			||||||
                'plus_score' => $scoringQuarters[$period]['plus_score'] ?? '',
 | 
					                'plus_score' => $scoringQuarters[$period]['plus_score'] ?? 0,
 | 
				
			||||||
                'minus_score' => $scoringQuarters[$period]['minus_score'] ?? '',
 | 
					                'minus_score' => $scoringQuarters[$period]['minus_score'] ?? 0,
 | 
				
			||||||
                'self_score' => $scoringQuarters[$period]['self_score'] ?? '',
 | 
					                'self_score' => $scoringQuarters[$period]['self_score'] ?? 0,
 | 
				
			||||||
                'department_score' => $scoringQuarters[$period]['department_score'] ?? '',
 | 
					                'department_score' => $scoringQuarters[$period]['department_score'] ?? 0,
 | 
				
			||||||
                'hospital_score' => $scoringQuarters[$period]['hospital_score'] ?? '',
 | 
					                'hospital_score' => $scoringQuarters[$period]['hospital_score'] ?? 0,
 | 
				
			||||||
                'if' => isset($scoringQuarters[$period]) ? 2 : 1,
 | 
					                'if' => isset($scoringQuarters[$period]) ? 2 : 1,
 | 
				
			||||||
                'if_period' => $if_period,
 | 
					                'if_period' => $if_period,
 | 
				
			||||||
                'scoringrecord_status' => $scoringrecord_status ?? 2,
 | 
					                'scoringrecord_status' => $scoringrecord_status ?? 2,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										473
									
								
								application/api/controller/backend/Questionnaire.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										473
									
								
								application/api/controller/backend/Questionnaire.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,473 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use app\common\library\Ems;
 | 
				
			||||||
 | 
					use app\common\library\Sms;
 | 
				
			||||||
 | 
					use fast\Random;
 | 
				
			||||||
 | 
					use think\Config;
 | 
				
			||||||
 | 
					use think\Validate;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					use think\Model;
 | 
				
			||||||
 | 
					use fast\Tree;
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 调查问卷接口
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class Questionnaire extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
 | 
				
			||||||
 | 
					    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
 | 
				
			||||||
 | 
					    //如果接口已经设置无需登录,那也就无需鉴权了
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // 无需登录的接口,*表示全部
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*','searchById', 'search'];
 | 
				
			||||||
 | 
					    // 无需鉴权的接口,*表示全部
 | 
				
			||||||
 | 
					    protected $noNeedRight = ['test2'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected $dataLimit = 'personal';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      /**
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * 问卷列表
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    public function questionnaireIndex(){
 | 
				
			||||||
 | 
					        $title = input('questionnaire');
 | 
				
			||||||
 | 
					        $page = input("page",1); 
 | 
				
			||||||
 | 
					        $size = input("size",10); 
 | 
				
			||||||
 | 
					        $Token = $this->request->header('Token');
 | 
				
			||||||
 | 
					        if(!$Token){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $user_id = Db::name('user')->where('token', $Token)->value('id');
 | 
				
			||||||
 | 
					        if(!$user_id){
 | 
				
			||||||
 | 
					            return $this->error('该用户不存在');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        if($title){
 | 
				
			||||||
 | 
					           $where['title'] = ['like',"%$title%"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $data = Db::name('questionnaire')
 | 
				
			||||||
 | 
					                    ->where($where)
 | 
				
			||||||
 | 
					                    ->order('releasetime desc')
 | 
				
			||||||
 | 
					                    ->page($page,$size)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					        foreach ($data as $key => $val){
 | 
				
			||||||
 | 
					            $res = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $val['id'])
 | 
				
			||||||
 | 
					                    ->where('user_id', $user_id)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					            $data[$key]['type'] = '未填写';
 | 
				
			||||||
 | 
					            if($res){
 | 
				
			||||||
 | 
					                $data[$key]['type'] = '已填写';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $count = Db::name('questionnaire')
 | 
				
			||||||
 | 
					                    ->where($where)
 | 
				
			||||||
 | 
					                    ->count();
 | 
				
			||||||
 | 
					        $data = [
 | 
				
			||||||
 | 
					                'count' => $count,
 | 
				
			||||||
 | 
					                'data' => $data
 | 
				
			||||||
 | 
					                ];
 | 
				
			||||||
 | 
					        $this->success('返回成功',$data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					    //单挑查询
 | 
				
			||||||
 | 
					    public function questionnairefind()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    $questionnaireId = input('id');
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    // 1. 查询问卷所有题目(带权重排序)
 | 
				
			||||||
 | 
					    $topics = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					        ->where('questionnaire_id', $questionnaireId)
 | 
				
			||||||
 | 
					        ->order('id desc')  // 注意:原代码中的"wight"应为"weight"的拼写错误
 | 
				
			||||||
 | 
					        ->select();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 2. 预处理题目数据:解码选项
 | 
				
			||||||
 | 
					    $processedTopics = [];
 | 
				
			||||||
 | 
					    foreach ($topics as $topic) {
 | 
				
			||||||
 | 
					        $topic['option'] = json_decode($topic['option'], true);
 | 
				
			||||||
 | 
					        $processedTopics[$topic['id']] = $topic; // 使用ID作为键方便后续匹配
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 3. 查询该问卷所有题目的答题记录
 | 
				
			||||||
 | 
					    $topicIds = array_keys($processedTopics);
 | 
				
			||||||
 | 
					    $answerLogs = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					        ->where('topic_id', 'in', $topicIds)
 | 
				
			||||||
 | 
					        ->select();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 4. 合并答题记录到题目数据
 | 
				
			||||||
 | 
					    foreach ($answerLogs as $log) {
 | 
				
			||||||
 | 
					        $topicId = $log['topic_id'];
 | 
				
			||||||
 | 
					        if (isset($processedTopics[$topicId])) {
 | 
				
			||||||
 | 
					            // 添加 type 标识和答案数据
 | 
				
			||||||
 | 
					            // $processedTopics[$topicId]['type'] = 1;
 | 
				
			||||||
 | 
					            $processedTopics[$topicId]['topic'] = $log['option'];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 5. 转换为数组(保持顺序)
 | 
				
			||||||
 | 
					    $result = array_values($processedTopics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $this->success('查询成功', $result);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    //问卷统计查询
 | 
				
			||||||
 | 
					    public function questionnaireStatistics(){
 | 
				
			||||||
 | 
					        $id = input('id');
 | 
				
			||||||
 | 
					        // 题目
 | 
				
			||||||
 | 
					        $topic = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    ->where('activity_id', $id)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
 | 
					        $jianda = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                    ->order('wight desc')
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					        foreach($jianda as $key => $val){
 | 
				
			||||||
 | 
					            $jianda[$key]['option'] = json_decode($val['option'], true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $jianda_log = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                    ->column('id');
 | 
				
			||||||
 | 
					        $topic_id = implode(',',$jianda_log);
 | 
				
			||||||
 | 
					        $jiandaer = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                    ->where('topic_id','in' ,$topic_id)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					        foreach($jianda as $topic_key => $topic_val){
 | 
				
			||||||
 | 
					                $log_jianda = [];
 | 
				
			||||||
 | 
					                foreach($jiandaer as $log_key => $log_val){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if($topic_val['id'] == $log_val['topic_id']){
 | 
				
			||||||
 | 
					                        array_push($log_jianda, $log_val);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					               
 | 
				
			||||||
 | 
					                $jianda[$topic_key]['list'] = $log_jianda;
 | 
				
			||||||
 | 
					                $jianda[$topic_key]['quantity'] = count($jianda[$topic_key]['list']);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					            // 遍历 $jianda 数组  
 | 
				
			||||||
 | 
					            foreach ($jianda as &$val) { // 使用引用 & 来直接修改原数组  
 | 
				
			||||||
 | 
					                // 遍历 'option' 数组  
 | 
				
			||||||
 | 
					                foreach ($val['option'] as &$option) { // 使用引用 & 来直接修改原数组  
 | 
				
			||||||
 | 
					                    // 初始化 'num' 为 0(以防 'list' 中没有任何匹配的项) 
 | 
				
			||||||
 | 
					                    $option['num'] = 0;  
 | 
				
			||||||
 | 
					                      
 | 
				
			||||||
 | 
					                    // 遍历 'list' 数组  
 | 
				
			||||||
 | 
					                    foreach ($val['list'] as $b) {  
 | 
				
			||||||
 | 
					                        // 检查 'list' 中的 'option' 是否包含当前 'option' 的 'name'  
 | 
				
			||||||
 | 
					                        if (strpos($b['option'], $option['name']) !== false) {  
 | 
				
			||||||
 | 
					                            // 如果找到匹配项,增加 'num' 并退出循环(因为不需要继续检查)  
 | 
				
			||||||
 | 
					                            $option['num']++;  
 | 
				
			||||||
 | 
					                            // break; // 退出当前 'list' 的循环  
 | 
				
			||||||
 | 
					                        }  
 | 
				
			||||||
 | 
					                    }  
 | 
				
			||||||
 | 
					                }  
 | 
				
			||||||
 | 
					                  
 | 
				
			||||||
 | 
					                // 取消对 $val 的引用,避免后续潜在问题  
 | 
				
			||||||
 | 
					                unset($val);  
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					        $this->success('返回成功',$jianda);
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function questionnaireAdd(){
 | 
				
			||||||
 | 
					        $data = input();
 | 
				
			||||||
 | 
					        $data['createtime'] = time();
 | 
				
			||||||
 | 
					        $adddata = Db::name('questionnaire')->strict(false)->insert($data);
 | 
				
			||||||
 | 
					        if ($adddata) {
 | 
				
			||||||
 | 
					            $this->success('已添加');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('添加失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function questionnaireEdit(){
 | 
				
			||||||
 | 
					        $data = input();
 | 
				
			||||||
 | 
					        $id = $data['id'];
 | 
				
			||||||
 | 
					        // $this->success('已更新',$data);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $update = Db::name('questionnaire')->where('id',  $id)->strict(false)->update($data);
 | 
				
			||||||
 | 
					        if ($update) {
 | 
				
			||||||
 | 
					            $this->success('已更新');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('更新失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function questionnaireDel(){
 | 
				
			||||||
 | 
					        $data = input();
 | 
				
			||||||
 | 
					        $id = $data['id'];
 | 
				
			||||||
 | 
					        $delete = Db::name('questionnaire')->where('id',  $id)->delete();
 | 
				
			||||||
 | 
					        if ($delete) {
 | 
				
			||||||
 | 
					            $this->success('已删除');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('删除失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function topicIndex(){
 | 
				
			||||||
 | 
					        $data = input();
 | 
				
			||||||
 | 
					        $id = $data['id'];
 | 
				
			||||||
 | 
					        $topic = Db::name('questionnaire_topic')->where('questionnaire_id',$id)->select();
 | 
				
			||||||
 | 
					        if ($topic) {
 | 
				
			||||||
 | 
					            $this->success('查询成功',$topic);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->success('查询成功',[]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function topicAdd(){
 | 
				
			||||||
 | 
					        $data = $_POST['topic'];
 | 
				
			||||||
 | 
					        $activity_id = $this->request->post('questionnaire_id');
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if (!$activity_id) {
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 解析 JSON 并校验
 | 
				
			||||||
 | 
					        $array = json_decode($data, true);
 | 
				
			||||||
 | 
					        if ($array === null) {
 | 
				
			||||||
 | 
					            $error = json_last_error_msg();
 | 
				
			||||||
 | 
					            $this->error("JSON 解析失败: " . $error);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 遍历处理数据
 | 
				
			||||||
 | 
					        foreach ($array as $key => $val) {
 | 
				
			||||||
 | 
					            $array[$key]['questionnaire_id'] = $activity_id;
 | 
				
			||||||
 | 
					            $array[$key]['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					            $array[$key]['option'] = json_encode($val['option'], JSON_UNESCAPED_UNICODE); // 避免中文转义
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					     
 | 
				
			||||||
 | 
					        // 插入数据库
 | 
				
			||||||
 | 
					        $adddata = Db::name('questionnaire_topic')->strict(false)->insertAll($array);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if ($adddata) {
 | 
				
			||||||
 | 
					            $this->success('已添加');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('添加失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function topicEdit(){
 | 
				
			||||||
 | 
					        $data = $_POST['topic'];
 | 
				
			||||||
 | 
					        $array = json_decode($data, true);
 | 
				
			||||||
 | 
					        //  $this->success('已更新', $array);
 | 
				
			||||||
 | 
					        $id = $array['id'];
 | 
				
			||||||
 | 
					        $array['option'] = json_encode( $array['option'],true);
 | 
				
			||||||
 | 
					        $update = Db::name('questionnaire_topic')->where('id',  $id)->strict(false)->update($array);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($update) {
 | 
				
			||||||
 | 
					            $this->success('已更新');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('内容未更新');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function topicDel(){
 | 
				
			||||||
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $delete = Db::name('questionnaire_topic')->where('id',  $id)->delete();
 | 
				
			||||||
 | 
					        if ($delete) {
 | 
				
			||||||
 | 
					            $this->success('已删除');
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error('删除失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					// --------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					// 移动端
 | 
				
			||||||
 | 
					    public function appIndex(){
 | 
				
			||||||
 | 
					        $title = input('questionnaire');
 | 
				
			||||||
 | 
					        $page = input("page",1); 
 | 
				
			||||||
 | 
					        $size = input("size",10); 
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        if($title){
 | 
				
			||||||
 | 
					        $where['title'] = ['like',"%$title%"];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $data = Db::name('questionnaire')
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->order('releasetime desc')
 | 
				
			||||||
 | 
					                ->page($page,$size)
 | 
				
			||||||
 | 
					                ->select();
 | 
				
			||||||
 | 
					        $one = [];
 | 
				
			||||||
 | 
					        $two = [];
 | 
				
			||||||
 | 
					        $there = [];
 | 
				
			||||||
 | 
					        foreach($data as $key => $val){
 | 
				
			||||||
 | 
					                if(strtotime($val['releasetime']) < time() && strtotime($val['endtime']) > time()){
 | 
				
			||||||
 | 
					                    $id = $val['id'];
 | 
				
			||||||
 | 
					                    $val['log'] = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                                    ->group('member_id')
 | 
				
			||||||
 | 
					                                    ->count();
 | 
				
			||||||
 | 
					                array_push($two,$val);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					              
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
 | 
					        $this->success('返回成功',$two);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					       
 | 
				
			||||||
 | 
					    //单挑查询
 | 
				
			||||||
 | 
					    public function appFind(){
 | 
				
			||||||
 | 
					        $id = input('id');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $data = Db::name('questionnaire')
 | 
				
			||||||
 | 
					                ->where('id', $id)
 | 
				
			||||||
 | 
					                ->order('releasetime desc')
 | 
				
			||||||
 | 
					                ->select();
 | 
				
			||||||
 | 
					        // 题目
 | 
				
			||||||
 | 
					        $topic = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $jianda = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                    ->where('type',1)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $jianda_log = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                    // ->field('id')   
 | 
				
			||||||
 | 
					                    ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                    ->where('type',1)
 | 
				
			||||||
 | 
					                    ->column('id');
 | 
				
			||||||
 | 
					        $topic_id = implode(',',$jianda_log);
 | 
				
			||||||
 | 
					        $jiandaer = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                    // ->field('id')   
 | 
				
			||||||
 | 
					                    ->where('topic_id','in' ,$topic_id)
 | 
				
			||||||
 | 
					                    ->select();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // var_dump($jiandaer);die();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if($jianda_log){
 | 
				
			||||||
 | 
					           foreach($jianda as $topic_key => $topic_val){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $log_jianda = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                foreach($jiandaer as $log_key => $log_val){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if($topic_val['id'] == $log_val['topic_id']){
 | 
				
			||||||
 | 
					                        array_push($log_jianda, $log_val);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					               
 | 
				
			||||||
 | 
					                $jianda[$topic_key]['list'] = $log_jianda;
 | 
				
			||||||
 | 
					           }
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            $jianda_log = [];
 | 
				
			||||||
 | 
					        }   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        foreach($topic as $key => $val){
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
 | 
					            $topic[$key]['count'] = Db::name('questionnaire_topic')
 | 
				
			||||||
 | 
					                                ->where('questionnaire_id', $id)
 | 
				
			||||||
 | 
					                                ->count();
 | 
				
			||||||
 | 
					           
 | 
				
			||||||
 | 
					            $option = json_decode($val['option'],true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $b = [];
 | 
				
			||||||
 | 
					            $c = [];
 | 
				
			||||||
 | 
					                foreach($option as $k => $v){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    $a = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                                ->where('topic_id', $val['id'])
 | 
				
			||||||
 | 
					                                ->where('option','like',"%$k%")
 | 
				
			||||||
 | 
					                                ->count();
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                    $b = [
 | 
				
			||||||
 | 
					                        'name' => $v['name'],
 | 
				
			||||||
 | 
					                        'xvanxiang' => $k,
 | 
				
			||||||
 | 
					                        'mun' => $a
 | 
				
			||||||
 | 
					                    ];
 | 
				
			||||||
 | 
					                    array_push($c,$b);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $topic[$key]['canyurenshu'] = $c;
 | 
				
			||||||
 | 
					            if($val['type'] == 1){
 | 
				
			||||||
 | 
					                unset($topic[$key]);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $topic = array_values($topic);
 | 
				
			||||||
 | 
					        $info = [
 | 
				
			||||||
 | 
					            'data' => $data,
 | 
				
			||||||
 | 
					            'topic' =>$topic,
 | 
				
			||||||
 | 
					            'jianda'=>$jianda
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        $this->success('返回成功',$info);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function appAdd(){
 | 
				
			||||||
 | 
					        $option = $_POST['option'];
 | 
				
			||||||
 | 
					        $Token = $this->request->header('Token');
 | 
				
			||||||
 | 
					        if(!$Token){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $user_id = Db::name('user')->where('token', $Token)->value('id');
 | 
				
			||||||
 | 
					        if(!$user_id){
 | 
				
			||||||
 | 
					            return $this->error('该用户不存在');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $member_id = $user_id;
 | 
				
			||||||
 | 
					        $option = json_decode($option, true);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        foreach($option as $key => $val){
 | 
				
			||||||
 | 
					            $option[$key]['user_id'] = $user_id;
 | 
				
			||||||
 | 
					            $option[$key]['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					            $where = [];
 | 
				
			||||||
 | 
					            if($member_id){
 | 
				
			||||||
 | 
					               $where['user_id'] = $member_id;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if($val['questionnaire_id']){
 | 
				
			||||||
 | 
					                $where['questionnaire_id'] = $val['questionnaire_id'];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            $if = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                    ->where($where)
 | 
				
			||||||
 | 
					                    ->find();
 | 
				
			||||||
 | 
					            if($if){
 | 
				
			||||||
 | 
					                $this->success('问卷只能填写一次哦');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    //   $this->success('提交成功',$option);
 | 
				
			||||||
 | 
					        // $data = json_decode($option,true);
 | 
				
			||||||
 | 
					        $adddata = Db::name('questionnaire_log')
 | 
				
			||||||
 | 
					                ->strict(false)
 | 
				
			||||||
 | 
					                ->insertAll($option);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->success('提交成功',$adddata);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function appFindLog(){
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $member_id = input('member_id');
 | 
				
			||||||
 | 
					        $questionnaire_id = input('questionnaire_id');
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        if($member_id){
 | 
				
			||||||
 | 
					           $where['member_id'] = $member_id;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if($questionnaire_id){
 | 
				
			||||||
 | 
					            $where['questionnaire_id'] = $questionnaire_id;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $if = Db::name('questionnaire_log') 
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->select();
 | 
				
			||||||
 | 
					        if($if){
 | 
				
			||||||
 | 
					            $this->success('返回成功',$if);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $this->error('未查询到');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -47,6 +47,7 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
        $status= $this->request->post('status');
 | 
					        $status= $this->request->post('status');
 | 
				
			||||||
        $time= $this->request->post('fsdate');
 | 
					        $time= $this->request->post('fsdate');
 | 
				
			||||||
        $user_id= $this->request->post('user_id');
 | 
					        $user_id= $this->request->post('user_id');
 | 
				
			||||||
 | 
					        // var_dump($group);die();
 | 
				
			||||||
        $where = [];
 | 
					        $where = [];
 | 
				
			||||||
        //判断该用户有没有权限审核
 | 
					        //判断该用户有没有权限审核
 | 
				
			||||||
        if($this->level == 2){
 | 
					        if($this->level == 2){
 | 
				
			||||||
@ -57,6 +58,7 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
            if ($time) {
 | 
					            if ($time) {
 | 
				
			||||||
                $where['a.fsdate'] = $time;
 | 
					                $where['a.fsdate'] = $time;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            // return $this->success('查询成功1',$where);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if($this->level == 1){
 | 
					        if($this->level == 1){
 | 
				
			||||||
            $where['a.group_id'] = $this->group_id;
 | 
					            $where['a.group_id'] = $this->group_id;
 | 
				
			||||||
@ -69,7 +71,7 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
            if ($user_id) {
 | 
					            if ($user_id) {
 | 
				
			||||||
                $where['a.user_id'] = $user_id;
 | 
					                $where['a.user_id'] = $user_id;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            // return $this->success('查询成功2',$where);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if($this->auth_id == 1 && $group){
 | 
					        if($this->auth_id == 1 && $group){
 | 
				
			||||||
            $where['a.group_id'] = $group;
 | 
					            $where['a.group_id'] = $group;
 | 
				
			||||||
@ -83,6 +85,7 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
            if ($user_id) {
 | 
					            if ($user_id) {
 | 
				
			||||||
                $where['a.user_id'] = $user_id;
 | 
					                $where['a.user_id'] = $user_id;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            // return $this->success('查询成功3',$where);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
         // 获取指定科室及其子科室的ID
 | 
					         // 获取指定科室及其子科室的ID
 | 
				
			||||||
        $groupIds = $this->getGroupAndSubGroupIds($group);
 | 
					        $groupIds = $this->getGroupAndSubGroupIds($group);
 | 
				
			||||||
@ -90,6 +93,7 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
        if (!empty($groupIds)) {
 | 
					        if (!empty($groupIds)) {
 | 
				
			||||||
            $where['a.group_id'] = ['in', $groupIds];
 | 
					            $where['a.group_id'] = ['in', $groupIds];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        // return $this->success('查询成功',$where);
 | 
				
			||||||
        $date = Db::name('reject_red_envelopes')
 | 
					        $date = Db::name('reject_red_envelopes')
 | 
				
			||||||
                    ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname')
 | 
					                    ->field('a.*,u.nickname,g.name as group_name,w.nickname as zm_nickname')
 | 
				
			||||||
                    ->alias('a')
 | 
					                    ->alias('a')
 | 
				
			||||||
@ -159,26 +163,53 @@ class RejectRedEnvelopes extends Api
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 审核
 | 
					     * 审核
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function examine(){
 | 
					   public function examine()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // 1. 参数接收与基础验证
 | 
				
			||||||
        $id = $this->request->post('id');
 | 
					        $id = $this->request->post('id');
 | 
				
			||||||
        $status = $this->request->post('status');
 | 
					        $status = $this->request->post('status');
 | 
				
			||||||
 | 
					        $reason = $this->request->post('reason', ''); // 设置默认值避免未定义警告
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        // 2. 权限验证(前置检查)
 | 
				
			||||||
        if ($this->level == 2) {
 | 
					        if ($this->level == 2) {
 | 
				
			||||||
            return $this->error('您没有权限');
 | 
					            return $this->error('您没有审核权限');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if(!$id || !$status){
 | 
					    
 | 
				
			||||||
            return $this->error('缺少参数');
 | 
					        // 3. 参数有效性验证
 | 
				
			||||||
 | 
					        if (empty($id) || !is_numeric($id)) {
 | 
				
			||||||
 | 
					            return $this->error('缺少有效的红包记录ID');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $where = [
 | 
					        
 | 
				
			||||||
            'id' => $id,
 | 
					        if (!in_array($status, [1, 2, 3])) { // 假设状态值只能是1/2/3
 | 
				
			||||||
        ];
 | 
					            return $this->error('无效的审核状态值');
 | 
				
			||||||
        $update = [
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        // 4. 构建更新数据
 | 
				
			||||||
 | 
					        $updateData = [
 | 
				
			||||||
            'status' => $status,
 | 
					            'status' => $status,
 | 
				
			||||||
 | 
					            // 'audit_time' => date('Y-m-d H:i:s') // 添加审核时间记录
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
        $res = Db::name('reject_red_envelopes')->where($where)->update($update);
 | 
					    
 | 
				
			||||||
        if($res){
 | 
					        // 5. 状态为驳回时的特殊处理
 | 
				
			||||||
            return $this->success('审核成功');
 | 
					        if ($status == 3) {
 | 
				
			||||||
 | 
					            if (empty(trim($reason))) {
 | 
				
			||||||
 | 
					                return $this->error('驳回时必须填写原因');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        return $this->error('审核失败');
 | 
					            $updateData['reason'] = htmlspecialchars($reason); // 防止XSS攻击
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $where = ['id' => $id];
 | 
				
			||||||
 | 
					        $result = Db::name('reject_red_envelopes')
 | 
				
			||||||
 | 
					                ->where($where)
 | 
				
			||||||
 | 
					                ->update($updateData);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        if($result){
 | 
				
			||||||
 | 
					             $this->success('审核成功');
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return $this->error('操作失败,请重试');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										104
									
								
								application/api/controller/backend/Solicitopinions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								application/api/controller/backend/Solicitopinions.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,104 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace app\api\controller\backend;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use app\common\controller\Api;
 | 
				
			||||||
 | 
					use app\api\model\Admin as AdminModel;
 | 
				
			||||||
 | 
					use think\Db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 征求意见
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class Solicitopinions extends Api
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
 | 
					    protected $noNeedRight = ['*'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 首页
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function index()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $param = $this->request->param();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // // 参数验证
 | 
				
			||||||
 | 
					        $validate = $this->validate($param, [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            'page'     => 'number',
 | 
				
			||||||
 | 
					            'size'    => 'number',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (true !== $validate) {
 | 
				
			||||||
 | 
					            return $this->error($validate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $where = [];
 | 
				
			||||||
 | 
					        if(!empty($param['group_id'])){
 | 
				
			||||||
 | 
					            $where['a.group_id'] = $param['group_id'];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $query = Db::name('solicit_opinions')
 | 
				
			||||||
 | 
					            ->field('a.*,p.name as group_name')
 | 
				
			||||||
 | 
					            ->alias('a')
 | 
				
			||||||
 | 
					            // ->join('user w','a.user_id = w.id','LEFT')
 | 
				
			||||||
 | 
					            ->join('user_group p','a.group_id = p.id','LEFT')
 | 
				
			||||||
 | 
					            ->where($where)
 | 
				
			||||||
 | 
					            // ->where('a.deletetime', 'null')
 | 
				
			||||||
 | 
					            ->order('a.id', 'asc');
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        // 分页查询
 | 
				
			||||||
 | 
					        $list = $query->paginate([
 | 
				
			||||||
 | 
					            'page'  => $param['page'] ?? 1,
 | 
				
			||||||
 | 
					            'list_rows' => $param['size'] ?? 10,
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // 处理返回数据
 | 
				
			||||||
 | 
					        $data = [
 | 
				
			||||||
 | 
					            'total' => $list->total(),
 | 
				
			||||||
 | 
					            'list'  => $list->items(),
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					        return $this->success('查询成功', $data);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public function h5add()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $param = $this->request->param();
 | 
				
			||||||
 | 
					        $user_id = $this->request->param('user_id', 0);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $param['politics_type'] = 1;
 | 
				
			||||||
 | 
					        if($user_id != 0){
 | 
				
			||||||
 | 
					            $param['politics_type'] = 2;
 | 
				
			||||||
 | 
					            $user = Db::name('user')
 | 
				
			||||||
 | 
					                ->where('id', $user_id)
 | 
				
			||||||
 | 
					                ->find();
 | 
				
			||||||
 | 
					            $param['nickname'] = $user['nickname'];
 | 
				
			||||||
 | 
					            $param['phone'] = $user['mobile'];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $param['createtime'] = date('Y-m-d H:i:s');
 | 
				
			||||||
 | 
					        $param['weigh'] = 100;
 | 
				
			||||||
 | 
					        // 参数验证
 | 
				
			||||||
 | 
					        $validate = $this->validate($param, [
 | 
				
			||||||
 | 
					            'group_id'                => 'require|number',
 | 
				
			||||||
 | 
					            // 'nickname'  => 'require',
 | 
				
			||||||
 | 
					            'phone'  => 'require|number',
 | 
				
			||||||
 | 
					            'content'  => 'require',
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (true !== $validate) {
 | 
				
			||||||
 | 
					            return $this->error($validate);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        // 更新数据
 | 
				
			||||||
 | 
					        $result = Db::name('solicit_opinions')->strict(false)->insert($param);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					        if ($result === false) {
 | 
				
			||||||
 | 
					            return $this->error('添加失败');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					        return $this->success('添加成功');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -18,6 +18,17 @@ class User extends Api
 | 
				
			|||||||
    protected $noNeedLogin = ['*'];
 | 
					    protected $noNeedLogin = ['*'];
 | 
				
			||||||
    protected $noNeedRight = '*';
 | 
					    protected $noNeedRight = '*';
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    public function getEvaluation()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $id = $this->request->header('Token');
 | 
				
			||||||
 | 
					        if(!$id){
 | 
				
			||||||
 | 
					            return $this->error('缺少参数');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $group_id = Db::name('user')->where('token', $id)->find();
 | 
				
			||||||
 | 
					        if(!$group_id){
 | 
				
			||||||
 | 
					            return $this->error('未查询到该用户科室');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 用户列表
 | 
					     * 用户列表
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@ -165,16 +176,29 @@ class User extends Api
 | 
				
			|||||||
        if (!$id) {
 | 
					        if (!$id) {
 | 
				
			||||||
            $this->error(__('Invalid parameters'));
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $ret = Db::name('user')->where('id',$id)->find();
 | 
					        $ret = Db::name('user')
 | 
				
			||||||
 | 
					                ->field('a.*, u.name as gorup_name, d.name as party_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user_group u','a.group_id = u.id','LEFT')
 | 
				
			||||||
 | 
					                ->join('party_group d','a.party_id = d.id','LEFT')
 | 
				
			||||||
 | 
					                ->where('a.id',$id)
 | 
				
			||||||
 | 
					                ->find();
 | 
				
			||||||
 | 
					       $startDate = $time . '-01-01';
 | 
				
			||||||
 | 
					        $endDate = $time . '-12-31';
 | 
				
			||||||
 | 
					         
 | 
				
			||||||
        $date = Db::name('addition_and_subtraction_records')
 | 
					        $date = Db::name('addition_and_subtraction_records')
 | 
				
			||||||
            ->field('a.*,p.project_name,p.scoring_criteria')
 | 
					            ->field('a.*,p.project_name,p.scoring_criteria')
 | 
				
			||||||
            ->alias('a')
 | 
					            ->alias('a')
 | 
				
			||||||
            ->join('plus_minus_scoring p','a.assessment_project = p.id','LEFT')
 | 
					            ->join('plus_minus_scoring p','a.assessment_project = p.id','LEFT')
 | 
				
			||||||
                    ->where('user_id', $id)
 | 
					            ->where('a.user_id', $id)
 | 
				
			||||||
                    ->where('YEAR(createtime)', $time)
 | 
					            ->where('a.status', 2)
 | 
				
			||||||
                    ->where('status',2)
 | 
					            ->whereBetween('a.createtime', [$startDate, $endDate]) // 使用日期范围
 | 
				
			||||||
            ->order('a.id', 'desc')
 | 
					            ->order('a.id', 'desc')
 | 
				
			||||||
            ->select();
 | 
					            ->select();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!$date){
 | 
				
			||||||
 | 
					            $date = [];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        $array = [
 | 
					        $array = [
 | 
				
			||||||
                'user' => $ret,
 | 
					                'user' => $ret,
 | 
				
			||||||
                'date' => $date,
 | 
					                'date' => $date,
 | 
				
			||||||
@ -186,4 +210,27 @@ class User extends Api
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     /**
 | 
				
			||||||
 | 
					     * 单个用户查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getH5UserFind()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $id = $this->request->post('user_id');
 | 
				
			||||||
 | 
					        if (!$id) {
 | 
				
			||||||
 | 
					            $this->error(__('Invalid parameters'));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        $ret = Db::name('user')
 | 
				
			||||||
 | 
					                ->field('a.nickname,a.mobile,a.position,a.certificate_code,a.license_code,a.license_image,p.name as user_group_name')
 | 
				
			||||||
 | 
					                ->alias('a')
 | 
				
			||||||
 | 
					                ->join('user_group p','a.group_id = p.id','LEFT')
 | 
				
			||||||
 | 
					                ->where('a.id',$id)
 | 
				
			||||||
 | 
					                ->find();
 | 
				
			||||||
 | 
					        if ($ret) {
 | 
				
			||||||
 | 
					            $this->success(__('Logged in successful'), $ret);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->error($this->auth->getError());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user