Enterprise.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\admin\model\ApiData;
  5. use app\common\api\ChuanglanSmsApi;
  6. use app\common\api\DictApi;
  7. use app\common\api\EnterpriseApi;
  8. use app\common\model\MessageRecord;
  9. use app\common\model\TalentChecklog;
  10. use app\common\api\TalentState;
  11. use app\common\api\CompanyApi;
  12. use think\facade\Db;
  13. use app\admin\api\RsApi;
  14. use app\common\state\CommonConst;
  15. /**
  16. * 企业审核
  17. * checkState 1:用户提交 [2:审核驳回 3:审核通过] 4:重新提交 [5:初审驳回 6:初审通过]
  18. */
  19. class Enterprise extends AdminController {
  20. public function gotoEnterprisePage() {
  21. $template = "";
  22. switch ($this->user["type"]) {
  23. case CommonConst::ENTERPRISE_WJ:
  24. $template = "/enterprise/hospital/goto_enterprise_page";
  25. break;
  26. case CommonConst::ENTERPRISE_GJ:
  27. $template = "/enterprise/school/goto_enterprise_page";
  28. break;
  29. }
  30. return view($template, []);
  31. }
  32. public function findEnterpriseByPage() {
  33. $res = EnterpriseApi::getList($this->request);
  34. return json($res);
  35. }
  36. public function gotoEnterpriseDetailPage() {
  37. $id = trim($this->request['id']);
  38. $ep = EnterpriseApi::getOne($id);
  39. if (!in_array($ep["type"], [CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ])) {
  40. $check_info = ApiData::where('action', '=', 'register_check')->where('uid', '=', $ep['idCard'])->where('status', '=', 1)->find();
  41. $force = intval($this->request['force'], 0);
  42. if ($force || !$check_info || !$check_info['status']) {
  43. $rsapi = new RsApi();
  44. switch ($ep['special']) {
  45. case 0:
  46. $ep['rs'] = $rsapi->I040102($ep['idCard']);
  47. break;
  48. case 1:
  49. $ep['rs'] = $rsapi->I080101($ep['idCard']);
  50. break;
  51. case 3:
  52. $ep['rs'] = $rsapi->I030501($ep['name'], $ep['idCard']);
  53. break;
  54. }
  55. ApiData::where('action', '=', 'register_check')->where('uid', '=', $ep['idCard'])->where('status', '=', 1)->update(['status' => 0, 'updateTime' => time()]);
  56. $api_model_data = [
  57. 'uid' => $ep['idCard'],
  58. 'action' => 'register_check',
  59. 'content' => serialize($ep['rs']),
  60. 'createTime' => time()
  61. ];
  62. ApiData::create($api_model_data);
  63. } else {
  64. $ep['rs'] = unserialize($check_info['content']);
  65. }
  66. }
  67. if (!$ep) {
  68. return "无此企业";
  69. }
  70. //--------设置 审核状态---------------------------------------------------
  71. switch ($ep['checkState']) {
  72. case 1:
  73. $ep['checkStateName'] = "待审核";
  74. break;
  75. case 2:
  76. $ep['checkStateName'] = "审核驳回";
  77. break;
  78. case 3:
  79. $ep['checkStateName'] = "审核通过";
  80. break;
  81. case 4:
  82. $ep['checkStateName'] = "重新提交";
  83. break;
  84. case 5:
  85. $ep['checkStateName'] = "初审驳回";
  86. break;
  87. case 6:
  88. $ep['checkStateName'] = "初审通过";
  89. break;
  90. }
  91. //-------设置账号状态----------------------------------------------------
  92. switch ($ep['active']) {
  93. case 1:
  94. $ep['activeName'] = "账号有效";
  95. break;
  96. case 2:
  97. $ep['activeName'] = "冻结/拉黑";
  98. break;
  99. }
  100. //---------设置 街道-----------------------------------------------------
  101. if (\StrUtil::isNotEmpAndNull($ep['street'])) {
  102. $street_info = DictApi::findByParentCodeAndCode('street', $ep['street']);
  103. if ($street_info != null) {
  104. $ep['streetName'] = $street_info['name'];
  105. }
  106. }
  107. if (\StrUtil::isNotEmpAndNull($ep['agencyType'])) {
  108. $agencyType = DictApi::findByParentCodeAndCode('agency_type', $ep['agencyType']);
  109. $ep["agencyTypeName"] = $agencyType["name"];
  110. }
  111. //---------设置产业领域 --------------------------------------------------
  112. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  113. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  114. if ($industryFieldNew != null) {
  115. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  116. }
  117. }
  118. //---------设置行业领域 --------------------------------------------------
  119. if (\StrUtil::isNotEmpAndNull($ep['industryFieldOld'])) {
  120. $industryFieldOld = DictApi::findByParentCodeAndCode($ep['industryFieldNew'] . "_field", $ep['industryFieldOld']);
  121. if ($industryFieldOld != null) {
  122. $ep['industryFieldOldName'] = $industryFieldOld['name'];
  123. }
  124. }
  125. //---------设置单位标签 --------------------------------------------------
  126. if (\StrUtil::isNotEmpAndNull($ep['enterpriseTag'])) {
  127. $enterpriseTag = DictApi::findByParentCodeAndCode("enterprise_tag", $ep['enterpriseTag']);
  128. if ($enterpriseTag != null) {
  129. $ep['enterpriseTagName'] = $enterpriseTag['name'];
  130. }
  131. }
  132. //---------设置机构标签 --------------------------------------------------
  133. if (\StrUtil::isNotEmpAndNull($ep['organizationTag'])) {
  134. $organizationTag = DictApi::findByParentCodeAndCode("organization_tag", $ep['organizationTag']);
  135. if ($organizationTag != null) {
  136. $ep['organizationTagName'] = $organizationTag['name'];
  137. }
  138. }
  139. //---------设置事业单位标签 --------------------------------------------------
  140. if (\StrUtil::isNotEmpAndNull($ep['institutionTag'])) {
  141. $institutionTag = DictApi::findByParentCodeAndCode("institution_tag", $ep['institutionTag']);
  142. if ($institutionTag != null) {
  143. $ep['institutionTagName'] = $institutionTag['name'];
  144. }
  145. }
  146. //---------设置单位类型 --------------------------------------------------
  147. if (\StrUtil::isNotEmpAndNull($ep['enterpriseType'])) {
  148. $enterpriseType = DictApi::findByParentCodeAndCode("enterprise_type", $ep['enterpriseType']);
  149. if ($enterpriseType != null) {
  150. $ep['enterpriseTypeName'] = $enterpriseType['name'];
  151. }
  152. }
  153. $imgurl_info = pathinfo($ep['imgurl']);
  154. if (in_array($imgurl_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  155. $ep['imgurl_is_img'] = 1;
  156. } else {
  157. $ep['imgurl_is_img'] = 0;
  158. }
  159. $bankImg_info = pathinfo($ep['bankImg']);
  160. if (in_array($bankImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  161. $ep['bankImg_is_img'] = 1;
  162. } else {
  163. $ep['bankImg_is_img'] = 0;
  164. }
  165. $domainImg_info = pathinfo($ep['domainImg']);
  166. if (in_array($domainImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  167. $ep['domainImg_is_img'] = 1;
  168. } else {
  169. $ep['domainImg_is_img'] = 0;
  170. }
  171. $typeImg_info = pathinfo($ep['typeImg']);
  172. if (in_array($typeImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  173. $ep['typeImg_is_img'] = 1;
  174. } else {
  175. $ep['typeImg_is_img'] = 0;
  176. }
  177. $beian_info = pathinfo($ep['beian']);
  178. if (in_array($beian_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  179. $ep['beian_is_img'] = 1;
  180. } else {
  181. $ep['beian_is_img'] = 0;
  182. }
  183. $template = "";
  184. switch ($this->user["type"]) {
  185. case CommonConst::ENTERPRISE_WJ:
  186. $template = "/enterprise/hospital/goto_enterprise_detail_page";
  187. $ep["medicalCommunityName"] = \app\common\api\Nhc::getMedicalCommunityMap()[$ep["medicalCommunityId"]];
  188. break;
  189. case CommonConst::ENTERPRISE_GJ:
  190. $template = "/enterprise/school/goto_enterprise_detail_page";
  191. break;
  192. }
  193. $assign['ep'] = $ep;
  194. return view($template, $assign);
  195. }
  196. public function gotoExaminePage() {
  197. $id = trim($this->request['id']);
  198. $ep = EnterpriseApi::getOne($id);
  199. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  200. if ($lastLog["active"] == 0) {
  201. $ep["checkState"] = $lastLog["state"];
  202. $ep["checkMsg"] = $lastLog["description"];
  203. }
  204. if (!$ep) {
  205. return "无此企业";
  206. }
  207. //---------设置产业领域 --------------------------------------------------
  208. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  209. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  210. if ($industryFieldNew != null) {
  211. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  212. }
  213. }
  214. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  215. $fields = $fieldsAndFiles["fields"];
  216. $files = $fieldsAndFiles["files"];
  217. $modify_fields = [];
  218. $modify_files = [];
  219. $_modify_fields = explode(",", $ep["modify_fields"]);
  220. foreach ($fields as $key => $value) {
  221. $checked = in_array($key, $_modify_fields);
  222. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  223. }
  224. $_modify_files = explode(",", $ep["modify_files"]);
  225. foreach ($files as $key => $value) {
  226. $checked = in_array($key, $_modify_files);
  227. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  228. }
  229. $template = "";
  230. switch ($this->user["type"]) {
  231. case CommonConst::ENTERPRISE_WJ:
  232. $template = "/enterprise/hospital/goto_examine_page";
  233. break;
  234. case CommonConst::ENTERPRISE_GJ:
  235. $template = "/enterprise/school/goto_examine_page";
  236. break;
  237. }
  238. return view($template, ['ep' => $ep, 'checkUser' => session('user')['name'], 'fields' => $modify_fields, "files" => $modify_files]);
  239. }
  240. public function doExamine() {
  241. $id = trim($this->request['id']);
  242. $doSubmit = $this->request["submit"] == 1 ? true : false;
  243. if (!$id) {
  244. return json(["msg" => 'ID不能为空!']);
  245. }
  246. $ep = EnterpriseApi::getOne($id);
  247. if (!$ep) {
  248. return json(["msg" => '无此企业!']);
  249. }
  250. $oriCheckState = $ep["checkState"];
  251. if ($oriCheckState == 6 && !EnterpriseApi::chkUserInSuperusers() && !in_array($this->user["type"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ])) {
  252. return json(["msg" => "已经流转到复审,不在审核范围内"]);
  253. }
  254. if (!in_array($ep["checkState"], [1, 4, 6]))
  255. return json(["msg" => "不在审核范围内"]);
  256. $checkState = $this->request['checkState'];
  257. if ($checkState == null || ($checkState != 5 && $checkState != 2 && $checkState != 3)) {
  258. return json(["msg" => '请选择审核状态!']);
  259. }
  260. $checkMsg = $this->request['checkMsg'];
  261. $fields = $this->request['fields'];
  262. $files = $this->request['files'];
  263. if ($checkState == 2 || ($checkState == 5 && $ep["type"] == CommonConst::ENTERPRISE_WJ)) {
  264. if ($checkState == 5 && $ep["isGeneral"] == 1) {
  265. return json(["msg" => '总院不能驳回到分院!']);
  266. }
  267. if (\StrUtil::isEmpOrNull($checkMsg)) {
  268. return json(["msg" => '请填写审核意见!']);
  269. }
  270. if (strlen($checkMsg) > 1000) {
  271. return json(["msg" => '审核意见最多1000个字符!']);
  272. }
  273. if (!$fields && !$files) {
  274. return json(["msg" => '请选择驳回修改的字段或者附件!']);
  275. }
  276. }
  277. try {
  278. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  279. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  280. if ($checkState == 3) {
  281. $fields = null;
  282. $files = null;
  283. }
  284. if ($oriCheckState == 6 || $ep["type"] == 2) {
  285. $newCheckState = $checkState;
  286. } else {
  287. $newCheckState = $checkState == 3 ? 6 : 5;
  288. }
  289. if ($doSubmit) {
  290. $checkData = [
  291. 'id' => $id,
  292. 'checkState' => $newCheckState,
  293. 'checkMsg' => $checkMsg,
  294. 'modify_fields' => $fields ? implode(",", $fields) : null,
  295. 'modify_files' => $files ? implode(",", $files) : null,
  296. 'checkUser' => session('user')['name'],
  297. 'updateUser' => session('user')['uid'],
  298. 'updateTime' => date("Y-m-d H:i:s")
  299. ];
  300. if ($ep["type"] == CommonConst::ENTERPRISE_WJ) {
  301. if ($newCheckState == 2 || $newCheckState == 5) {
  302. $checkData["step"] = 0;
  303. } else {
  304. $checkData["step"] = 2;
  305. }
  306. }
  307. $res = EnterpriseApi::updateById($checkData);
  308. //短信入库数据
  309. $record_data = [
  310. 'id' => getStringId(),
  311. 'bizId' => getStringId(),
  312. 'userId' => $id,
  313. 'type' => 2,
  314. 'smsType' => 2,
  315. 'name' => $ep['name'],
  316. 'phone' => $ep['agentPhone'],
  317. 'params' => '机构注册信息',
  318. 'state' => 1,
  319. 'sendingDate' => date("Y-m-d H:i:s", time()),
  320. 'createTime' => date("Y-m-d H:i:s", time())
  321. ];
  322. if ($checkState == 2 || $checkState == 5) {
  323. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。退订回复TD。";
  324. }
  325. if ($newCheckState == 3) {
  326. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息已审核通过,可登录“晋江市人才综合服务申报平台”做相关事宜申报。退订回复TD。";
  327. queue("app\job\Enterprise", ["type" => 1, "id" => $id]);
  328. }
  329. if ($newCheckState == 3 || ($checkState == 2 && $ep["type"] != CommonConst::ENTERPRISE_WJ) || ($checkState == 2 && $ep["isGeneral"] == 1) || $checkState == 5) {
  330. $smsapi = new ChuanglanSmsApi();
  331. $result = $smsapi->sendSMS($ep['agentPhone'], $record_data['templateCode']);
  332. MessageRecord::create($record_data);
  333. }
  334. if ($lastLog["active"] === 0) {
  335. TalentChecklog::update([
  336. 'id' => $lastLog["id"],
  337. 'active' => 1,
  338. 'state' => $newCheckState,
  339. 'step' => 101,
  340. 'stateChange' => TalentState::stateEnum($newCheckState),
  341. 'description' => $checkMsg,
  342. 'updateTime' => date("Y-m-d H:i:s", time()),
  343. 'updateUser' => session('user')['name'] . "({$companyName})"
  344. ]);
  345. } else {
  346. TalentChecklog::create([
  347. 'id' => getStringId(),
  348. 'mainId' => $id,
  349. 'type' => 10,
  350. 'typeFileId' => null,
  351. 'active' => 1,
  352. 'state' => $newCheckState,
  353. 'step' => 101,
  354. 'stateChange' => TalentState::stateEnum($newCheckState),
  355. 'description' => $checkMsg,
  356. 'createTime' => date("Y-m-d H:i:s", time()),
  357. 'createUser' => session('user')['name'] . "({$companyName})"
  358. ]);
  359. }
  360. return json(["msg" => '操作成功!', "code" => 200]);
  361. } else {
  362. $checkData = [
  363. 'id' => $id,
  364. 'modify_fields' => $fields ? implode(",", $fields) : null,
  365. 'modify_files' => $files ? implode(",", $files) : null,
  366. 'checkUser' => session('user')['name'],
  367. 'updateUser' => session('user')['uid'],
  368. 'updateTime' => date("Y-m-d H:i:s")
  369. ];
  370. $res = EnterpriseApi::updateById($checkData);
  371. if ($lastLog["active"] === 0) {
  372. TalentChecklog::update([
  373. 'id' => $lastLog["id"],
  374. 'state' => $newCheckState,
  375. 'step' => 101,
  376. 'stateChange' => TalentState::stateEnum($newCheckState),
  377. 'description' => $checkMsg,
  378. 'updateTime' => date("Y-m-d H:i:s", time()),
  379. 'updateUser' => session('user')['name'] . "({$companyName})"
  380. ]);
  381. } else {
  382. TalentChecklog::create([
  383. 'id' => getStringId(),
  384. 'mainId' => $id,
  385. 'type' => 10,
  386. 'typeFileId' => null,
  387. 'active' => 0,
  388. 'state' => $newCheckState,
  389. 'step' => 101,
  390. 'stateChange' => TalentState::stateEnum($checkState),
  391. 'description' => $checkMsg,
  392. 'createTime' => date("Y-m-d H:i:s", time()),
  393. 'createUser' => session('user')['name'] . "({$companyName})"
  394. ]);
  395. }
  396. return json(["msg" => '保存成功!', "code" => 200]);
  397. }
  398. } catch (\Exception $e) {
  399. return json(["msg" => $e->getMessage()]);
  400. }
  401. }
  402. public function gotoRejectPage() {
  403. $id = trim($this->request['id']);
  404. $ep = EnterpriseApi::getOne($id);
  405. if (!$ep) {
  406. return "无此企业";
  407. }
  408. if ($ep["checkState"] != 3) {
  409. return "该操作只能对已通过企业进行驳回";
  410. }
  411. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  412. if ($lastLog["active"] != 1 || $lastLog["state"] != $ep["checkState"]) {
  413. return "日志状态与当前状态不一致,已中止操作";
  414. }
  415. $ep["passedUser"] = $lastLog["createUser"];
  416. $ep["passedTime"] = $lastLog["createTime"];
  417. //---------设置产业领域 --------------------------------------------------
  418. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  419. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  420. if ($industryFieldNew != null) {
  421. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  422. }
  423. }
  424. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  425. $fields = $fieldsAndFiles["fields"];
  426. $files = $fieldsAndFiles["files"];
  427. $modify_fields = [];
  428. $modify_files = [];
  429. $_modify_fields = explode(",", $ep["modify_fields"]);
  430. foreach ($fields as $key => $value) {
  431. $modify_fields[$key] = ["field" => $key, "name" => $value];
  432. }
  433. $_modify_files = explode(",", $ep["modify_files"]);
  434. foreach ($files as $key => $value) {
  435. $modify_files[$key] = ["field" => $key, "name" => $value];
  436. }
  437. return view("", ['ep' => $ep, 'fields' => $modify_fields, "files" => $modify_files]);
  438. }
  439. public function doReject() {
  440. $id = trim($this->request['id']);
  441. if (!$id) {
  442. return json(["msg" => 'ID不能为空!']);
  443. }
  444. $ep = EnterpriseApi::getOne($id);
  445. if (!$ep) {
  446. return json(["msg" => '无此企业!']);
  447. }
  448. if ($ep["checkState"] != 3) {
  449. return json(["msg" => '该操作只能对已通过企业进行驳回!']);
  450. }
  451. $checkMsg = $this->request['checkMsg'];
  452. $fields = $this->request['fields'];
  453. $files = $this->request['files'];
  454. if (\StrUtil::isEmpOrNull($checkMsg)) {
  455. return json(["msg" => '请填写审核意见!']);
  456. }
  457. if (strlen($checkMsg) > 1000) {
  458. return json(["msg" => '审核意见最多1000个字符!']);
  459. }
  460. if (!$fields && !$files) {
  461. return json(["msg" => '请选择驳回修改的字段或者附件!']);
  462. }
  463. try {
  464. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  465. if ($lastLog["active"] != 1 || $lastLog["state"] != $ep["checkState"]) {
  466. return json(["msg" => '日志状态与当前状态不一致,已中止操作']);
  467. }
  468. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  469. $checkData = [
  470. 'id' => $id,
  471. 'checkState' => 2,
  472. 'checkMsg' => $checkMsg,
  473. 'modify_fields' => $fields ? implode(",", $fields) : null,
  474. 'modify_files' => $files ? implode(",", $files) : null,
  475. 'checkUser' => session('user')['name'],
  476. 'updateUser' => session('user')['uid'],
  477. 'updateTime' => date("Y-m-d H:i:s")
  478. ];
  479. $res = EnterpriseApi::updateById($checkData);
  480. $tplContent = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。退订回复TD。";
  481. $smsapi = new ChuanglanSmsApi();
  482. $result = $smsapi->sendSMS($ep['agentPhone'], $tplContent);
  483. //短信入库数据
  484. $record_data = [
  485. 'id' => getStringId(),
  486. 'bizId' => $result['msgId'],
  487. 'userId' => $id,
  488. 'type' => 2,
  489. 'smsType' => 2,
  490. 'name' => $ep['name'],
  491. 'phone' => $ep['agentPhone'],
  492. 'params' => '机构注册通过再驳回',
  493. 'state' => $result['code'] == 0 ? 2 : 3,
  494. 'sendingDate' => date("Y-m-d H:i:s", time()),
  495. 'createTime' => date("Y-m-d H:i:s", time()),
  496. 'templateCode' => $tplContent,
  497. "msg" => $result['errorMsg']
  498. ];
  499. MessageRecord::create($record_data);
  500. TalentChecklog::create([
  501. 'id' => getStringId(),
  502. 'mainId' => $id,
  503. 'type' => 10,
  504. 'typeFileId' => null,
  505. 'active' => 1,
  506. 'state' => 2,
  507. 'step' => 101,
  508. 'stateChange' => TalentState::stateEnum(2),
  509. 'description' => $checkMsg,
  510. 'createTime' => date("Y-m-d H:i:s", time()),
  511. 'createUser' => session('user')['name'] . "({$companyName})"
  512. ]);
  513. return json(["msg" => '操作成功!', "code" => 200]);
  514. } catch (\Exception $e) {
  515. return json(["msg" => $e->getMessage()]);
  516. }
  517. }
  518. public function delEnterprise() {
  519. if (!$id = trim($this->request['id'])) {
  520. return json(["msg" => 'ID不能为空!', "code" => 500]);
  521. }
  522. $ep = EnterpriseApi::getOne($id);
  523. if (!$ep || $ep->delete == 1)
  524. return json(["msg" => '要删除的数据不存在!', "code" => 500]);
  525. $ep->delete = 1;
  526. $ep->deleteUser = session('user')['uid'] . "";
  527. $ep->deleteTime = date('Y-m-d H:i:s');
  528. try {
  529. $ep->save();
  530. return json(["msg" => '操作成功!', "code" => 200]);
  531. } catch (\Exception $e) {
  532. return json(["msg" => $e->getMessage()]);
  533. }
  534. }
  535. public function GotoActivePage() {
  536. $id = trim($this->request['id']);
  537. $ep = EnterpriseApi::getOne($id);
  538. $template = "";
  539. switch ($this->user["type"]) {
  540. case CommonConst::ENTERPRISE_WJ:
  541. $template = "/enterprise/hospital/goto_active_page";
  542. break;
  543. case CommonConst::ENTERPRISE_GJ:
  544. $template = "/enterprise/school/goto_active_page";
  545. break;
  546. }
  547. return view($template, ['ep' => $ep]);
  548. }
  549. public function setActive() {
  550. if (!$id = trim($this->request['id'])) {
  551. return json(["msg" => 'ID不能为空!', "code" => 500]);
  552. }
  553. $ep = EnterpriseApi::getOne($id);
  554. $active = $this->request['active'];
  555. if ($ep['active'] == null || ($ep['active'] != 1 && $ep['active'] != 2)) {
  556. return json(["msg" => '状态有误!', "code" => 500]);
  557. }
  558. if ($ep['active'] == 2) {
  559. $msg = trim($this->request['activeMsg']);
  560. if (empty($msg)) {
  561. return json(["msg" => '请填写拉黑/冻结原因!', "code" => 500]);
  562. }
  563. if (strlen($msg) > 100) {
  564. return json(["msg" => '拉黑/冻结原因 最多100个字符!', "code" => 500]);
  565. }
  566. }
  567. $company = CompanyApi::getOne(session('user')['companyId']);
  568. $ep->active = $active;
  569. $ep->activeMsg = $msg;
  570. $ep->updateUser = session('user')['uid'] . "";
  571. $ep->updateTime = date('y-m-d H:i:s');
  572. try {
  573. $ep->save();
  574. //添加日志
  575. TalentChecklog::create([
  576. 'id' => getStringId(),
  577. 'mainId' => $ep['id'],
  578. 'type' => 10,
  579. 'typeFileId' => null,
  580. 'active' => 1,
  581. 'state' => TalentState::RCRD_BASEIC_FROZEN,
  582. 'step' => 102,
  583. 'stateChange' => TalentState::stateEnum(10),
  584. 'description' => $msg,
  585. 'createTime' => date("Y-m-d H:i:s", time()),
  586. 'createUser' => session('user')['name'] . "({$company['name']})"
  587. ]);
  588. return json(["msg" => '操作成功!', "code" => 200]);
  589. } catch (\Exception $e) {
  590. return json(["msg" => $e->getMessage()]);
  591. }
  592. }
  593. public function resetPassword() {
  594. if (!$id = trim($this->request['id'])) {
  595. return json(["msg" => 'ID不能为空!', "code" => 500]);
  596. }
  597. $ep = EnterpriseApi::getOne($id);
  598. if (!$ep) {
  599. return json(["msg" => '找不到该用户!', "code" => 500]);
  600. }
  601. $ep->password = hash("md5", 'JJrc@123'); //默认密码
  602. $ep->updateUser = session('user')['uid'] . "";
  603. $ep->updateTime = date("Y-m-d H:i:s");
  604. $ep->save();
  605. $company = CompanyApi::getOne(session('user')['companyId']);
  606. TalentChecklog::create([
  607. 'id' => getStringId(),
  608. 'mainId' => $ep['id'],
  609. 'type' => 10,
  610. 'typeFileId' => null,
  611. 'active' => 1,
  612. 'state' => null,
  613. 'step' => 103,
  614. 'stateChange' => '重置密码',
  615. 'description' => '重置密码',
  616. 'createTime' => date("Y-m-d H:i:s", time()),
  617. 'createUser' => session('user')['name'] . "({$company['name']})"
  618. ]);
  619. return json(["msg" => '重置密码成功!', "code" => 200]);
  620. }
  621. public function export() {
  622. $res = EnterpriseApi::getList($this->request, true);
  623. $rows = $res["rows"];
  624. $columns = ["单位名称", " 统一社会信用代码", "产业领域", "单位标签", " 所属街道", "单位地址", " 法人代表", " 单位电话", "人才联络员", "人才联络员电话", "人才联络员邮箱", "审核状态", "账号状态", "注册时间", "备注"];
  625. $exportDatas = [];
  626. if ($res["rows"]) {
  627. $stateMaps = [1 => "未审核", 2 => "审核驳回", 3 => "审核通过", 4 => "重新提交", 5 => "初审驳回", 6 => "初审通过"];
  628. $activeMaps = [1 => "账号有效", 2 => "拉黑/冻结"];
  629. foreach ($rows as $row) {
  630. $exportDatas[] = [
  631. $row['name'],
  632. $row['idCard'],
  633. $row['industryFieldNewName'],
  634. $row['enterpriseTagName'],
  635. $row['streetName'],
  636. $row['address'],
  637. $row['legal'],
  638. $row['ephone'],
  639. $row['agentName'],
  640. $row['agentPhone'],
  641. $row['agentEmail'],
  642. $stateMaps[$row["checkState"]],
  643. $activeMaps[$row["active"]],
  644. $row['createTime'],
  645. $row['description']
  646. ];
  647. }
  648. export($columns, $exportDatas, "企业用户信息");
  649. exit();
  650. }
  651. return json(["msg" => "没有可以导出的内容"]);
  652. }
  653. public function findFieldsAndFiles() {
  654. $id = $this->request->param("id");
  655. $ep = EnterpriseApi::getOne($id);
  656. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  657. $fields = $fieldsAndFiles["fields"];
  658. $files = $fieldsAndFiles["files"];
  659. $modify_fields = [];
  660. $modify_files = [];
  661. $_modify_fields = explode(",", $ep["modify_fields"]);
  662. foreach ($fields as $key => $value) {
  663. $checked = in_array($key, $_modify_fields);
  664. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  665. }
  666. $_modify_files = explode(",", $ep["modify_files"]);
  667. foreach ($files as $key => $value) {
  668. $checked = in_array($key, $_modify_files);
  669. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  670. }
  671. return json(["code" => 200, "files" => $modify_files, "fields" => $modify_fields]);
  672. }
  673. public function updateFieldsAndFiles() {
  674. try {
  675. $params = $this->request->param();
  676. $id = $params["id"];
  677. $ep = EnterpriseApi::getOne($id);
  678. if (!$ep) {
  679. throw new \think\Exception("没有对应的企业信息");
  680. }
  681. if (!in_array($ep["checkState"], [2, 5])) {
  682. throw new \think\Exception("不是驳回状态,不能修改驳回字段!");
  683. }
  684. if ($ep["checkState"] == 2 && !EnterpriseApi::chkUserInSuperusers() && !in_array($this->user["type"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ])) {
  685. throw new \think\Exception("已经流转到审核,不在审核范围内");
  686. }
  687. $fields = array_filter(explode(",", $params["fields"]));
  688. $files = array_filter(explode(",", $params["files"]));
  689. if (!$fields && !$files)
  690. throw new \think\Exception("请选择要驳回的字段或附件!");
  691. $data["id"] = $id;
  692. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  693. $data["modify_files"] = $files ? implode(",", $files) : null;
  694. $data["updateTime"] = date("Y-m-d H:i:s");
  695. $data["updateUser"] = session("user")["uid"];
  696. if (EnterpriseApi::updateById($data)) {
  697. return json(["code" => 200, "msg" => "修改成功!"]);
  698. }
  699. } catch (\think\Exception $e) {
  700. return json(["msg" => $e->getMessage()]);
  701. }
  702. }
  703. private function getFieldAndFilesBySpecialAndType($special, $type) {
  704. if ($special == 0) {
  705. if ($type == CommonConst::ENTERPRISE_JC) {
  706. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  707. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  708. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员信息备案表"];
  709. } else if ($type == CommonConst::ENTERPRISE_WJ) {
  710. $fields = ["name" => "医院名称", "idCard" => "登记号", "legal" => "法人代表", "medicalCommunityId" => "医共体", "isGeneral" => "是否总院", "ephone" => "医院电话", "province" => "地址省", "city" => "地址市", "county" => "地址县\区", "address" => "医院地址",
  711. "bankCard" => "银行账号", "bank" => "开户银行", "bankNetwork" => "开户银行网点",
  712. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  713. $files = ["imgurl" => "医疗机构执业许可证", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员信息备案表"];
  714. } else if ($type == CommonConst::ENTERPRISE_GJ) {
  715. $fields = ["name" => "学校名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "ephone" => "学校电话", "province" => "地址省", "city" => "地址市", "county" => "地址县\区", "address" => "学校地址",
  716. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  717. $files = ["imgurl" => "办学许可证、法人证书或登记证书", "beian" => "人才联络员信息备案表"];
  718. } else {
  719. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  720. "agencyType" => "机构类型", "industryFieldNew" => "产业领域", "industryFieldOld" => "行业领域", "enterpriseTag" => "企业标签", "enterpriseType" => "企业类型",
  721. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  722. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "domainImg" => "行业领域佐证材料", "beian" => "人才联络员信息备案表", "typeImg" => "规上、高新技术、专精特新企业上传材料"];
  723. }
  724. } else {
  725. $fields = ["name" => "单位名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "单位地址", "street" => "所属街道", "ephone" => "单位电话", "bankCard" => "单位银行账号", "bank" => "单位开户银行", "bankNetwork" => "单位开户银行网点",
  726. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  727. if ($special == 1) {
  728. $fields["institutionTag"] = "单位标签";
  729. }
  730. if ($special == 3) {
  731. $fields["organizationTag"] = "机构标签";
  732. }
  733. $files = ["imgurl" => "法人证或批文", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员备案表"];
  734. }
  735. return ["fields" => $fields, "files" => $files];
  736. }
  737. }