diff --git a/config/define.php b/config/define.php index d48019e..3f1d0f5 100644 --- a/config/define.php +++ b/config/define.php @@ -40,7 +40,7 @@ define('USER_CASE_LIST_HTML_URL', TCM_DOMAIN . '/user_case_list'); define('USER_CASE_HTML_URL', TCM_DOMAIN . '/user_case'); define('USER_CASE_PDF_PATH', DATACENTER_ROOT.'/tcm_pdf/%d/'); - define('USER_CASE_PDF_URL', TCM_DOMAIN.'/case_pdf/%d/%s.pdf'); + define('USER_CASE_PDF_URL', TCM_DOMAIN.'/case_pdf/%d/'); define('CODE_LOGIN_PARAM_ERROR', 40001); define('CODE_LOGIN_EXIPRE', 40002); @@ -49,4 +49,20 @@ //请求限制 define('_QR_REQUEST_LIMIT', '_rq_request_limit_%s'); + $GLOBALS['notice_mail_list'] = array( + array( + '厘'=>'0.156', + '分'=>'1.56', + '钱'=>'3.12', + '两'=>'15.6', + '斤'=>'249.6', + '担'=>'24960', + '合'=>'', + '升'=>'', + '斗'=>'', + '个'=>'', + '片'=>'', + '味'=>'', + ), + ); diff --git a/control/index.php b/control/index.php index e967614..5a4e8be 100644 --- a/control/index.php +++ b/control/index.php @@ -118,9 +118,9 @@ class index extends publicBase { $m_user_case = new mUserCase(); //生成唯一id 防止重复请求 - $request_id = md5($uinfo['uid'].$case_id.$data['name'].$data['patient_name']); - $request_times = $m_user_case->requestLimit(sprintf(_QR_REQUEST_LIMIT, $request_id),1,60); - if(!$request_times) $this->ajax_json(false, $m_user_case->getError()); + $request_id = md5($uinfo['uid'] . $case_id . $data['name'] . $data['patient_name']); + $request_times = $m_user_case->requestLimit(sprintf(_QR_REQUEST_LIMIT, $request_id), 1, 60); + if (!$request_times) $this->ajax_json(false, $m_user_case->getError()); $id = $m_user_case->createUserCase($uinfo['uid'], $case_id, $data); if (!$id) $this->ajax_json(false, $m_user_case->getError()); @@ -228,70 +228,54 @@ class index extends publicBase { $this->ajax_json(true, '获取成功', array('img_url' => CONTACT_US_IMG_URL)); } - public function export_user_case_list() { + public function export_user_case() { $uinfo = $this->_check_login(); - $page_num = $this->post('page_num') ? $this->post('page_num') : 1; - $page_size = $this->post('page_size') ? $this->post('page_size') : 100; + $id = $this->post('id') + 0; + if ($id) { + $post_url = USER_CASE_HTML_URL; + $data = array( + "uid" => $uinfo['uid'], + "id" => $id, + ); + } else { + $post_url = USER_CASE_LIST_HTML_URL; + $data = array( + "uid" => $uinfo['uid'], + ); + } - $data = array( - "uid" => $this->post('uid'), - "token" => $this->post('token'), - "page_num" => $page_num, - "page_size" => $page_size, - ); $m_user_case = new mUserCase(); - $return = $m_user_case->postCUrl(USER_CASE_LIST_HTML_URL, $data); + $return = $m_user_case->postCUrl($post_url, $data); $res = json_decode($return, 1); if (isset($res['info'])) $this->ajax_json(false, $res['info']); - $pdf_name = md5($uinfo['uid'] . $page_num . $page_size); - $pdf_url = $m_user_case->createPdf($uinfo['uid'], $pdf_name, $return); - - $total = $m_user_case->getUserCaseListCount($uinfo['uid']); - $rdata = array( - 'total' => $total, - 'per_page' => $page_size, - 'last_page' => ceil($total / $page_size), - 'current_page' => $page_num, - 'data' => $pdf_url, - ); - - $this->ajax_json(true, '获取成功', $rdata); - } + $pdf_name = md5($uinfo['uid'] . $id) . ".pdf"; + $m_user_case->createPdf($uinfo['uid'], $pdf_name, $return); - public function export_user_case() { - $uinfo = $this->_check_login(); - - $id = $this->post('id') + 0; - if (empty($id)) $this->ajax_json(false, '参数错误'); + $email = $this->post('email'); + if (!empty($email)) { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $this->ajax_json(false, '邮箱地址无效'); - $data = array( - "uid" => $this->post('uid'), - "token" => $this->post('token'), - "id" => $id, - ); - $m_user_case = new mUserCase(); - $return = $m_user_case->postCUrl(USER_CASE_HTML_URL, $data); + $res = $m_user_case->sendMail(array($email), date('Y年m月d日', time()) . '-医案导出', '', sprintf(USER_CASE_PDF_PATH, $uinfo['uid']) . $pdf_name); + if (!$res) $this->ajax_json(true, '发送失败'); - $res = json_decode($return, 1); - if (isset($res['info'])) $this->ajax_json(false, $res['info']); + $this->ajax_json(true, '发送成功'); + } - $pdf_name = md5($uinfo['uid'] . $id); - $pdf_url = $m_user_case->createPdf($uinfo['uid'], $pdf_name, $return); - - $this->ajax_json(true, '获取成功', array('pdf_url' => $pdf_url)); + $this->ajax_json(true, '获取成功', array('pdf_url' => sprintf(USER_CASE_PDF_URL, $uinfo['uid']) . $pdf_name)); } public function user_case_list() { - $uinfo = $this->_check_login(); + $uid = $this->post('uid') + 0; + if (empty($uid)) $this->ajax_json(false, '参数错误'); $page_num = $this->post('page_num') ? $this->post('page_num') : 1; - $page_size = $this->post('page_size') ? $this->post('page_size') : 100; + $page_size = $this->post('page_size') ? $this->post('page_size') : 500; $m_user_case = new mUserCase(); - $data = $m_user_case->getUserCaseListPdfInfo($uinfo['uid'], $page_num, $page_size); + $data = $m_user_case->getUserCaseListPdfInfo($uid, $page_num, $page_size); if (!$data) $this->ajax_json(false, $m_user_case->getError()); $this->view['data'] = $data['user_case']; @@ -299,37 +283,15 @@ class index extends publicBase { } public function user_case() { - $uinfo = $this->_check_login(); - $id = $this->post('id') + 0; - if (empty($id)) $this->ajax_json(false, '参数错误'); + $uid = $this->post('uid') + 0; + if (empty($uid) || empty($id)) $this->ajax_json(false, '参数错误'); $m_user_case = new mUserCase(); - $data = $m_user_case->getUserCasePdfInfo($uinfo['uid'], $id); + $data = $m_user_case->getUserCasePdfInfo($uid, $id); if (!$data) $this->ajax_json(false, $m_user_case->getError()); $this->view['data'] = $data['user_case']; $this->setViewTpl('index/export_pdf.html'); } - - public function ajax_mail() { - $uinfo = $this->_check_login(); - - $email = $this->post('email'); - if (empty($email)) $this->ajax_json(false, '邮箱地址不能为空'); - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $this->ajax_json(false, '邮箱地址无效'); - - $pdf_url = $this->post('pdf_url'); - if (empty($pdf_url)) $this->ajax_json(false, 'pdf地址不能为空'); - if (!filter_var($pdf_url, FILTER_VALIDATE_URL)) $this->ajax_json(false, 'pdf地址无效'); - - $directory_name = basename(dirname($pdf_url)); - if ($directory_name != $uinfo['uid']) $this->ajax_json(false, '参数错误'); - - $mUserCase = new mUserCase(); - $res = $mUserCase->sendMail(array($email), date('Y年m月d日', time()) . '-医案导出', '', sprintf(USER_CASE_PDF_PATH, $uinfo['uid']) . basename($pdf_url)); - if (!$res) $this->ajax_json(true, '发送失败'); - - $this->ajax_json(true, '发送成功'); - } } diff --git a/model/mUserCase.php b/model/mUserCase.php index f0b3c4a..cb37338 100644 --- a/model/mUserCase.php +++ b/model/mUserCase.php @@ -302,8 +302,6 @@ class mUserCase extends mBase { $mpdf->WriteHTML($pdf_html); - $mpdf->Output($temp_dir . $pdf_name . ".pdf", 'F'); // D表示下载,I表示在浏览器中查看 - - return sprintf(USER_CASE_PDF_URL, $uid, $pdf_name); + return $mpdf->Output($temp_dir . $pdf_name, 'F'); // D表示下载,I表示在浏览器中查看 } } \ No newline at end of file