Browse Source

报错文案优化

pull/1/head
pengda 8 months ago
parent
commit
a1a84cad9a
  1. 24
      model/mFormula.php
  2. 7
      model/mUser.php
  3. 22
      model/mUserCase.php

24
model/mFormula.php

@ -136,13 +136,13 @@ class mFormula extends mBase {
//药方信息 //药方信息
$formula = $this->getFormulaById($id); $formula = $this->getFormulaById($id);
if (empty($formula)) { if (empty($formula)) {
$this->setError('查询不到此药方'); $this->setError('抱歉,未找到匹配的药方');
return false; return false;
} }
//自拟药方 判断药方归属 //自拟药方 判断药方归属
if ($uid > 0 && $formula['uid'] > 0 && $formula['uid'] != $uid) { if ($uid > 0 && $formula['uid'] > 0 && $formula['uid'] != $uid) {
$this->setError('这不是你的药方'); $this->setError('抱歉,这不是你的药方');
return false; return false;
} }
@ -245,7 +245,7 @@ class mFormula extends mBase {
//自拟药方 克重不能为0 //自拟药方 克重不能为0
if ($uid > 0 && $num == 0) { if ($uid > 0 && $num == 0) {
$this->setError("{$name}重不能为零"); $this->setError("抱歉,药材{$name}重不能为零");
return false; return false;
} }
@ -264,7 +264,7 @@ class mFormula extends mBase {
} }
if (isset($herb_ids[$temp['herb_id']])) { if (isset($herb_ids[$temp['herb_id']])) {
$this->setError("药材不能重复"); $this->setError("抱歉,药方中存在重复的药材");
return false; return false;
} }
$herb_ids[$temp['herb_id']] = $temp['herb_id']; $herb_ids[$temp['herb_id']] = $temp['herb_id'];
@ -365,24 +365,24 @@ class mFormula extends mBase {
public function saveFormula($uid, $id, $name, $source, $method, $herbs) { public function saveFormula($uid, $id, $name, $source, $method, $herbs) {
if (empty($name)) { if (empty($name)) {
$this->setError('药方名称不能为空'); $this->setError('请填写药方名称');
return false; return false;
} }
$herbs = json_decode($herbs, true); $herbs = json_decode($herbs, true);
if (empty($herbs)) { if (empty($herbs)) {
$this->setError('药方药材不能为空'); $this->setError('请填写药方详情');
return false; return false;
} }
if ($id) { if ($id) {
$formula = $this->getFormulaById($id); $formula = $this->getFormulaById($id);
if (empty($formula)) { if (empty($formula)) {
$this->setError('查询不到此药方'); $this->setError('抱歉,未找到匹配的药方');
return false; return false;
} }
if ($formula['uid'] != $uid) { if ($formula['uid'] != $uid) {
$this->setError('这不是你的药方'); $this->setError('抱歉,这不是你的药方');
return false; return false;
} }
} }
@ -430,7 +430,7 @@ class mFormula extends mBase {
} }
$res = $this->insertFormulaHerb($formula_herb); $res = $this->insertFormulaHerb($formula_herb);
if (!$res) { if (!$res) {
$this->setError('批量添加药方药材关联失败'); $this->setError('添加药方详情失败');
return false; return false;
} }
} else { } else {
@ -447,7 +447,7 @@ class mFormula extends mBase {
} }
$res = $this->mutiUpdateFormulaHerb($id, $formula_herb); $res = $this->mutiUpdateFormulaHerb($id, $formula_herb);
if (!$res) { if (!$res) {
$this->setError('批量更新药方药材关联失败'); $this->setError('更新药方详情失败');
return false; return false;
} }
} }
@ -458,11 +458,11 @@ class mFormula extends mBase {
public function deleteFormula($uid, $id) { public function deleteFormula($uid, $id) {
$formula = $this->getFormulaById($id); $formula = $this->getFormulaById($id);
if (empty($formula)) { if (empty($formula)) {
$this->setError('查询不到此药方'); $this->setError('抱歉,未找到匹配的药方');
return false; return false;
} }
if ($formula['uid'] != $uid) { if ($formula['uid'] != $uid) {
$this->setError('这不是你的药方'); $this->setError('抱歉,这不是你的药方');
return false; return false;
} }

7
model/mUser.php

@ -57,7 +57,7 @@ class mUser extends mBase {
public function getUserInfo($code) { public function getUserInfo($code) {
$openid = $this->getOpenid($code); $openid = $this->getOpenid($code);
if (!$openid) { if (!$openid) {
$this->setError('获取openid失败'); $this->setError('登录失败');
return false; return false;
} }
@ -68,13 +68,13 @@ class mUser extends mBase {
$identifier = $this->createUniqueID($openid); $identifier = $this->createUniqueID($openid);
$user = $this->getUserByIdentifier($identifier); $user = $this->getUserByIdentifier($identifier);
if ($user) { if ($user) {
$this->setError('uid生成失败'); $this->setError('登录失败,用户已存在');
return false; return false;
} }
$uid = $this->createUser(array('identifier' => $identifier, 'openid' => $openid)); $uid = $this->createUser(array('identifier' => $identifier, 'openid' => $openid));
if (!$uid) { if (!$uid) {
$this->setError('用户创建失败'); $this->setError('登录失败,用户不存在');
return false; return false;
} }
@ -90,7 +90,6 @@ class mUser extends mBase {
$jsonres = $this->getCUrl($get_openid_url); $jsonres = $this->getCUrl($get_openid_url);
$get_openid_res = json_decode($jsonres, true); $get_openid_res = json_decode($jsonres, true);
if (empty($get_openid_res['openid'])) { if (empty($get_openid_res['openid'])) {
$this->setError('获取openid失败');
$this->writeLog('user', 'get_openid_error_log', $get_openid_url . "|" . $jsonres); $this->writeLog('user', 'get_openid_error_log', $get_openid_url . "|" . $jsonres);
return false; return false;
} }

22
model/mUserCase.php

@ -50,7 +50,7 @@ class mUserCase extends mBase {
$user_case = $this->getUserCaseById($uid, $id); $user_case = $this->getUserCaseById($uid, $id);
if (empty($user_case)) { if (empty($user_case)) {
$this->setError('找不到相关医案'); $this->setError('抱歉,未找到匹配的医案');
return false; return false;
} }
@ -65,15 +65,15 @@ class mUserCase extends mBase {
public function createUserCase($uid, $formula_id, $data) { public function createUserCase($uid, $formula_id, $data) {
if (empty($data['patient_name'])) { if (empty($data['patient_name'])) {
$this->setError('患者姓名不能为空'); $this->setError('请填写患者姓名');
return false; return false;
} }
if ($data['patient_age'] <= 0) { if ($data['patient_age'] <= 0 || $data['patient_age'] > 127) {
$this->setError('患者年龄不正确'); $this->setError('患者年龄不正确');
return false; return false;
} }
if ($data['sex'] < 0) { if ($data['sex'] < 0) {
$this->setError('患者性别不能为空'); $this->setError('患者性别不正确');
return false; return false;
} }
if ($data['prescribe_num'] <= 0) { if ($data['prescribe_num'] <= 0) {
@ -85,15 +85,15 @@ class mUserCase extends mBase {
return false; return false;
} }
if (empty($data['patient_say'])) { if (empty($data['patient_say'])) {
$this->setError('主诉不能为空'); $this->setError('请填写主诉');
return false; return false;
} }
if (empty($data['first_diagnosis'])) { if (empty($data['first_diagnosis'])) {
$this->setError('舌诊脉诊不能为空'); $this->setError('请填写舌诊脉诊');
return false; return false;
} }
if (empty($data['diagnosis'])) { if (empty($data['diagnosis'])) {
$this->setError('诊断不能为空'); $this->setError('请填写诊断');
return false; return false;
} }
@ -102,12 +102,12 @@ class mUserCase extends mBase {
$mformula = new mFormula(); $mformula = new mFormula();
$formula = $mformula->getFormulaById($formula_id); $formula = $mformula->getFormulaById($formula_id);
if (!$formula) { if (!$formula) {
$this->setError('找不到相关药方'); $this->setError('抱歉,未找到匹配的药方');
return false; return false;
} }
if ($formula['uid'] > 0 && $uid != $formula['uid']) { if ($formula['uid'] > 0 && $uid != $formula['uid']) {
$this->setError('这不是你的药方'); $this->setError('抱歉,这不是你的药方');
return false; return false;
} }
@ -190,7 +190,7 @@ class mUserCase extends mBase {
public function getUserCaseInfo($uid, $id) { public function getUserCaseInfo($uid, $id) {
$user_case = $this->getUserCaseById($uid, $id); $user_case = $this->getUserCaseById($uid, $id);
if (empty($user_case)) { if (empty($user_case)) {
$this->setError('找不到相关医案'); $this->setError('抱歉,未找到匹配的医案');
return false; return false;
} }
@ -199,7 +199,7 @@ class mUserCase extends mBase {
if ($user_case['formula_id'] > 0) { if ($user_case['formula_id'] > 0) {
$formula = $mformula->getFormulaInfo($user_case['formula_id'], $uid); $formula = $mformula->getFormulaInfo($user_case['formula_id'], $uid);
if (empty($formula)) { if (empty($formula)) {
$this->setError('找不到相关药方'); $this->setError('抱歉,未找到匹配的药方');
return false; return false;
} }

Loading…
Cancel
Save