Hospital.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\enterprise\common\EnterpriseController;
  4. use app\common\state\CommonConst;
  5. use app\common\api\EnterpriseApi;
  6. use app\common\model\Enterprise;
  7. use app\common\api\Nhc;
  8. use app\common\model\TalentChecklog;
  9. use app\common\model\MessageRecord;
  10. use app\common\api\TalentState;
  11. use app\common\api\ChuanglanSmsApi;
  12. /**
  13. * Description of Hospital
  14. *
  15. * @author sgq
  16. */
  17. class Hospital extends EnterpriseController {
  18. //put your code here
  19. public function list() {
  20. return view("");
  21. }
  22. public function getList() {
  23. $request = $this->request;
  24. $ep = EnterpriseApi::getOne($this->user["uid"]);
  25. if ($ep["isGeneral"] == 1) {
  26. EnterpriseApi::getList($request);
  27. $where = [];
  28. $where[] = ["type", "=", CommonConst::ENTERPRISE_WJ];
  29. $where[] = ["delete", "=", 0];
  30. $where[] = ["isGeneral", "=", 2];
  31. $where[] = ["medicalCommunityId", "=", $ep["medicalCommunityId"]];
  32. $where[] = ["step", "=", 0];
  33. $offset = trim($request->param("offset")) ?: 0;
  34. $limit = trim($request->param("limit")) ?: 10;
  35. $name = urldecode(trim($request->param("name")));
  36. $idCard = urldecode(trim($request->param("idCard")));
  37. $legal = urldecode(trim($request->param("legal")));
  38. $ephone = urldecode(trim($request->param("ephone")));
  39. $agentName = urldecode(trim($request->param("agentName")));
  40. $agentPhone = urldecode(trim($request->param("agentPhone")));
  41. $checkState = urldecode(trim($request->param("checkState")));
  42. if ($name) {
  43. $where[] = ["name", "like", "%{$name}%"];
  44. }
  45. if ($idCard) {
  46. $where[] = ["idCard", "like", "%{$idCard}%"];
  47. }
  48. if ($legal) {
  49. $where[] = ["legal", "like", "%{$legal}%"];
  50. }
  51. if ($ephone) {
  52. $where[] = ["ephone", "like", "%{$ephone}%"];
  53. }
  54. if ($agentName) {
  55. $where[] = ["agentName", "like", "%{$agentName}%"];
  56. }
  57. if ($agentPhone) {
  58. $where[] = ["agentPhone", "like", "%{$agentPhone}%"];
  59. }
  60. if ($checkState) {
  61. $where[] = ["checkState", "=", "{$checkState}"];
  62. }
  63. $count = Enterprise::where($where)->count();
  64. $medicalCommunityList = Nhc::getMedicalCommunityMap();
  65. $list = Enterprise::where($where)->limit($offset, $limit)->order("createTime", 'desc')->select()->toArray();
  66. foreach ($list as $k => &$v) {
  67. unset($v['password']);
  68. $v['medicalCommunityName'] = $v['medicalCommunityId'] ? $medicalCommunityList[$v['medicalCommunityId']] : "";
  69. }
  70. return ["total" => $count, "rows" => $list];
  71. }
  72. }
  73. public function detail() {
  74. $id = $this->request["id"];
  75. $ep = EnterpriseApi::getOne($id);
  76. return view("", ["ep" => $ep]);
  77. }
  78. public function examine() {
  79. $id = $this->request["id"];
  80. $ep = EnterpriseApi::getOne($id);
  81. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  82. if ($lastLog["active"] == 0) {
  83. $ep["checkState"] = $lastLog["state"];
  84. $ep["checkMsg"] = $lastLog["description"];
  85. }
  86. if (!$ep) {
  87. return "无此企业";
  88. }
  89. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  90. $fields = $fieldsAndFiles["fields"];
  91. $files = $fieldsAndFiles["files"];
  92. $modify_fields = [];
  93. $modify_files = [];
  94. $_modify_fields = explode(",", $ep["modify_fields"]);
  95. foreach ($fields as $key => $value) {
  96. $checked = in_array($key, $_modify_fields);
  97. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  98. }
  99. $_modify_files = explode(",", $ep["modify_files"]);
  100. foreach ($files as $key => $value) {
  101. $checked = in_array($key, $_modify_files);
  102. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  103. }
  104. return view("", ['ep' => $ep, 'checkUser' => session('user')['name'], 'fields' => $modify_fields, "files" => $modify_files]);
  105. }
  106. public function doExamine() {
  107. $id = trim($this->request['id']);
  108. $doSubmit = $this->request["submit"] == 1 ? true : false;
  109. if (!$id) {
  110. return json(["msg" => 'ID不能为空!']);
  111. }
  112. $ep = EnterpriseApi::getOne($id);
  113. if (!$ep) {
  114. return json(["msg" => '无此企业!']);
  115. }
  116. $oriCheckState = $ep["checkState"];
  117. if ($ep["step"] > 0 || $ep["isGeneral"] != 2) {
  118. return json(["msg" => "不在审核范围内"]);
  119. }
  120. if (!in_array($ep["checkState"], [1, 2, 4, 5]))
  121. return json(["msg" => "不在审核范围内"]);
  122. $checkState = $this->request['checkState'];
  123. if ($checkState == null || ($checkState != 5 && $checkState != 6)) {
  124. return json(["msg" => '请选择审核状态!']);
  125. }
  126. $checkMsg = $this->request['checkMsg'];
  127. $fields = $this->request['fields'];
  128. $files = $this->request['files'];
  129. if ($checkState == 5 && $ep["type"] == CommonConst::ENTERPRISE_WJ) {
  130. if (\StrUtil::isEmpOrNull($checkMsg)) {
  131. return json(["msg" => '请填写审核意见!']);
  132. }
  133. if (strlen($checkMsg) > 1000) {
  134. return json(["msg" => '审核意见最多1000个字符!']);
  135. }
  136. if (!$fields && !$files) {
  137. return json(["msg" => '请选择驳回修改的字段或者附件!']);
  138. }
  139. }
  140. try {
  141. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  142. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  143. if ($checkState == 6) {
  144. $fields = null;
  145. $files = null;
  146. }
  147. $newCheckState = $checkState;
  148. if ($doSubmit) {
  149. $checkData = [
  150. 'id' => $id,
  151. 'checkState' => $newCheckState,
  152. 'checkMsg' => $checkMsg,
  153. 'modify_fields' => $fields ? implode(",", $fields) : null,
  154. 'modify_files' => $files ? implode(",", $files) : null,
  155. 'checkUser' => session('user')['name'],
  156. 'updateUser' => session('user')['uid'],
  157. 'updateTime' => date("Y-m-d H:i:s")
  158. ];
  159. if ($ep["type"] == CommonConst::ENTERPRISE_WJ) {
  160. if ($newCheckState == 5) {
  161. $checkData["step"] = 0;
  162. } else {
  163. $checkData["step"] = 1;
  164. }
  165. }
  166. $res = EnterpriseApi::updateById($checkData);
  167. //短信入库数据
  168. $record_data = [
  169. 'id' => getStringId(),
  170. 'bizId' => getStringId(),
  171. 'userId' => $id,
  172. 'type' => 2,
  173. 'smsType' => 2,
  174. 'name' => $ep['name'],
  175. 'phone' => $ep['agentPhone'],
  176. 'params' => '机构注册信息',
  177. 'state' => 1,
  178. 'sendingDate' => date("Y-m-d H:i:s", time()),
  179. 'createTime' => date("Y-m-d H:i:s", time())
  180. ];
  181. if ($checkState == 5) {
  182. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。退订回复TD。";
  183. }
  184. if ($checkState == 5) {
  185. $smsapi = new ChuanglanSmsApi();
  186. $result = $smsapi->sendSMS($ep['agentPhone'], $record_data['templateCode']);
  187. MessageRecord::create($record_data);
  188. }
  189. if ($lastLog["active"] === 0) {
  190. TalentChecklog::update([
  191. 'id' => $lastLog["id"],
  192. 'active' => 1,
  193. 'state' => $newCheckState,
  194. 'step' => 101,
  195. 'stateChange' => TalentState::stateEnum($newCheckState),
  196. 'description' => $checkMsg,
  197. 'updateTime' => date("Y-m-d H:i:s", time()),
  198. 'updateUser' => session('user')['name'] . "({$companyName})"
  199. ]);
  200. } else {
  201. TalentChecklog::create([
  202. 'id' => getStringId(),
  203. 'mainId' => $id,
  204. 'type' => 10,
  205. 'typeFileId' => null,
  206. 'active' => 1,
  207. 'state' => $newCheckState,
  208. 'step' => 101,
  209. 'stateChange' => TalentState::stateEnum($newCheckState),
  210. 'description' => $checkMsg,
  211. 'createTime' => date("Y-m-d H:i:s", time()),
  212. 'createUser' => session('user')['name'] . "({$companyName})"
  213. ]);
  214. }
  215. return json(["msg" => '操作成功!', "code" => 200]);
  216. } else {
  217. $checkData = [
  218. 'id' => $id,
  219. 'modify_fields' => $fields ? implode(",", $fields) : null,
  220. 'modify_files' => $files ? implode(",", $files) : null,
  221. 'checkUser' => session('user')['name'],
  222. 'updateUser' => session('user')['uid'],
  223. 'updateTime' => date("Y-m-d H:i:s")
  224. ];
  225. $res = EnterpriseApi::updateById($checkData);
  226. if ($lastLog["active"] === 0) {
  227. TalentChecklog::update([
  228. 'id' => $lastLog["id"],
  229. 'state' => $newCheckState,
  230. 'step' => 101,
  231. 'stateChange' => TalentState::stateEnum($newCheckState),
  232. 'description' => $checkMsg,
  233. 'updateTime' => date("Y-m-d H:i:s", time()),
  234. 'updateUser' => session('user')['name'] . "({$companyName})"
  235. ]);
  236. } else {
  237. TalentChecklog::create([
  238. 'id' => getStringId(),
  239. 'mainId' => $id,
  240. 'type' => 10,
  241. 'typeFileId' => null,
  242. 'active' => 0,
  243. 'state' => $newCheckState,
  244. 'step' => 101,
  245. 'stateChange' => TalentState::stateEnum($checkState),
  246. 'description' => $checkMsg,
  247. 'createTime' => date("Y-m-d H:i:s", time()),
  248. 'createUser' => session('user')['name'] . "({$companyName})"
  249. ]);
  250. }
  251. return json(["msg" => '保存成功!', "code" => 200]);
  252. }
  253. } catch (\Exception $e) {
  254. return json(["msg" => $e->getMessage()]);
  255. }
  256. }
  257. private function getFieldAndFilesBySpecialAndType($special, $type) {
  258. $fields = ["name" => "医院名称", "idCard" => "登记号", "legal" => "法人代表", "medicalCommunityId" => "医共体", "isGeneral" => "是否总院", "ephone" => "医院电话", "province" => "地址省", "city" => "地址市", "county" => "地址县\区", "address" => "医院地址",
  259. "bankCard" => "银行账号", "bank" => "开户银行", "bankNetwork" => "开户银行网点",
  260. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  261. $files = ["imgurl" => "医疗机构执业许可证", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员信息备案表"];
  262. return ["fields" => $fields, "files" => $files];
  263. }
  264. }