DoctorService.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace app\api\servies\doctor;
  3. use app\api\response\ZskkErrorResponse;
  4. use app\api\servies\ZskkDefaultService;
  5. use app\api\dao\doctor\DoctorDao;
  6. use app\api\servies\common\CommonService;
  7. use think\facade\Log;
  8. /**
  9. * 后台控制器基类
  10. * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
  11. */
  12. class DoctorService extends ZskkDefaultService {
  13. protected $logName = "DoctorService";
  14. private $doctor = null;
  15. public function __construct(DoctorDao $doctorDao) {
  16. parent::__construct();
  17. $this->doctor = $doctorDao;
  18. }
  19. public function getToken($token)
  20. {
  21. $user = $this->doctor->getToken($token);
  22. return $user;
  23. }
  24. public function changePwd($params,$token)
  25. {
  26. if($params['newpass'] != $params['newrepass']){
  27. $this->throwError('修改的密码两次输出不一致,请重新填写',0030);
  28. }
  29. $pattern = '/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[\W_]).+$/';
  30. if(!preg_match($pattern, $params['newpass']))
  31. {
  32. // $this->throwError('密码必须由数字、字母、特殊符号一起组成',0033);
  33. }
  34. $info = $this->doctor->getToken($token);
  35. if($info['password'] != md5($params['password'])){
  36. $this->throwError('原密码输入错误,请重新输入',0031);
  37. }
  38. $data = $this->doctor->changePwd($info['id'],$params['newpass']);
  39. if(!$data){
  40. $this->throwError('密码修改失败,请重新尝试',0032);
  41. }
  42. return $data;
  43. }
  44. public function changeInfo($info,$token)
  45. {
  46. $user = $this->doctor->getToken($token);
  47. $id = $user['id'];
  48. $data = array();
  49. $data['realname'] = $info['realname'];
  50. $data['email'] = $info['email'];
  51. $data['phone'] = $info['phone'];
  52. $data['doctor_title'] = $info['doctor_title'];
  53. $data['message_push'] = $info['message_push'];
  54. $data['send_sms'] = $info['send_sms'];
  55. $data['attachment'] = $info['attachment'];
  56. $data['is_use_autograph'] = $info['is_use_autograph'];
  57. $data['autograph'] = $info['autograph'];
  58. $data['report_full'] = $info['report_full'];
  59. $data['autograph_type'] = $info['autograph_type'] ?? 1;
  60. $data['attachment_type'] = $info['attachment_type'] ?? 1;
  61. $return = $this->doctor->changeInfo($data,$id,$token);
  62. return $return;
  63. }
  64. public function getPower($id)
  65. {
  66. $info = $this->doctor->getPower($id);
  67. $data = [];
  68. if(!empty($info)){
  69. if(strpos($info,'2')){
  70. //本地写
  71. $data[] = 1;
  72. }
  73. if(strpos($info,'3')){
  74. //本地审核
  75. $data[] = 2;
  76. }
  77. if(strpos($info,'4')){
  78. //本地确认
  79. $data[] = 3;
  80. }
  81. if(strpos($info,'6')){
  82. //本地申请
  83. $data[] = 4;
  84. }
  85. if(strpos($info,'7')){
  86. //远程写
  87. $data[] = 5;
  88. }
  89. if(strpos($info,'8')){
  90. //远程审核
  91. $data[] = 6;
  92. }
  93. }
  94. return $data;
  95. }
  96. // 获取登录代码
  97. public function getLoginCode($token)
  98. {
  99. $doctor = $this->doctor->getCache($token);
  100. if(!$doctor){
  101. return false;
  102. }
  103. $admin = $this->doctor->getFaAdmin($doctor['phone']);
  104. if(!$admin){
  105. return false;
  106. }
  107. $login_code = $this->doctor->getLoginCode($doctor['id']);
  108. if($login_code){
  109. return [
  110. 'code' => $login_code,
  111. 'phone' => $doctor['phone']
  112. ];
  113. }
  114. return false;
  115. }
  116. public function doctorList($institution)
  117. {
  118. $list = $this->doctor->getDoctorList($institution);
  119. return $list;
  120. }
  121. }