Enterprise.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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()) {
  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. }
  328. if ($newCheckState == 3 || ($checkState == 2 && $ep["type"] != CommonConst::ENTERPRISE_WJ) || ($checkState == 2 && $ep["isGeneral"] == 1) || $checkState == 5) {
  329. $smsapi = new ChuanglanSmsApi();
  330. $result = $smsapi->sendSMS($ep['agentPhone'], $record_data['templateCode']);
  331. MessageRecord::create($record_data);
  332. }
  333. if ($lastLog["active"] === 0) {
  334. TalentChecklog::update([
  335. 'id' => $lastLog["id"],
  336. 'active' => 1,
  337. 'state' => $newCheckState,
  338. 'step' => 101,
  339. 'stateChange' => TalentState::stateEnum($newCheckState),
  340. 'description' => $checkMsg,
  341. 'updateTime' => date("Y-m-d H:i:s", time()),
  342. 'updateUser' => session('user')['name'] . "({$companyName})"
  343. ]);
  344. } else {
  345. TalentChecklog::create([
  346. 'id' => getStringId(),
  347. 'mainId' => $id,
  348. 'type' => 10,
  349. 'typeField' => null,
  350. 'active' => 1,
  351. 'state' => $newCheckState,
  352. 'step' => 101,
  353. 'stateChange' => TalentState::stateEnum($newCheckState),
  354. 'description' => $checkMsg,
  355. 'createTime' => date("Y-m-d H:i:s", time()),
  356. 'createUser' => session('user')['name'] . "({$companyName})"
  357. ]);
  358. }
  359. return json(["msg" => '操作成功!', "code" => 200]);
  360. } else {
  361. $checkData = [
  362. 'id' => $id,
  363. 'modify_fields' => $fields ? implode(",", $fields) : null,
  364. 'modify_files' => $files ? implode(",", $files) : null,
  365. 'checkUser' => session('user')['name'],
  366. 'updateUser' => session('user')['uid'],
  367. 'updateTime' => date("Y-m-d H:i:s")
  368. ];
  369. $res = EnterpriseApi::updateById($checkData);
  370. if ($lastLog["active"] === 0) {
  371. TalentChecklog::update([
  372. 'id' => $lastLog["id"],
  373. 'state' => $newCheckState,
  374. 'step' => 101,
  375. 'stateChange' => TalentState::stateEnum($newCheckState),
  376. 'description' => $checkMsg,
  377. 'updateTime' => date("Y-m-d H:i:s", time()),
  378. 'updateUser' => session('user')['name'] . "({$companyName})"
  379. ]);
  380. } else {
  381. TalentChecklog::create([
  382. 'id' => getStringId(),
  383. 'mainId' => $id,
  384. 'type' => 10,
  385. 'typeField' => null,
  386. 'active' => 0,
  387. 'state' => $newCheckState,
  388. 'step' => 101,
  389. 'stateChange' => TalentState::stateEnum($checkState),
  390. 'description' => $checkMsg,
  391. 'createTime' => date("Y-m-d H:i:s", time()),
  392. 'createUser' => session('user')['name'] . "({$companyName})"
  393. ]);
  394. }
  395. return json(["msg" => '保存成功!', "code" => 200]);
  396. }
  397. } catch (\Exception $e) {
  398. return json(["msg" => $e->getMessage()]);
  399. }
  400. }
  401. public function gotoRejectPage() {
  402. $id = trim($this->request['id']);
  403. $ep = EnterpriseApi::getOne($id);
  404. if (!$ep) {
  405. return "无此企业";
  406. }
  407. if ($ep["checkState"] != 3) {
  408. return "该操作只能对已通过企业进行驳回";
  409. }
  410. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  411. if ($lastLog["active"] != 1 || $lastLog["state"] != $ep["checkState"]) {
  412. return "日志状态与当前状态不一致,已中止操作";
  413. }
  414. $ep["passedUser"] = $lastLog["createUser"];
  415. $ep["passedTime"] = $lastLog["createTime"];
  416. //---------设置产业领域 --------------------------------------------------
  417. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  418. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  419. if ($industryFieldNew != null) {
  420. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  421. }
  422. }
  423. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  424. $fields = $fieldsAndFiles["fields"];
  425. $files = $fieldsAndFiles["files"];
  426. $modify_fields = [];
  427. $modify_files = [];
  428. $_modify_fields = explode(",", $ep["modify_fields"]);
  429. foreach ($fields as $key => $value) {
  430. $modify_fields[$key] = ["field" => $key, "name" => $value];
  431. }
  432. $_modify_files = explode(",", $ep["modify_files"]);
  433. foreach ($files as $key => $value) {
  434. $modify_files[$key] = ["field" => $key, "name" => $value];
  435. }
  436. return view("", ['ep' => $ep, 'fields' => $modify_fields, "files" => $modify_files]);
  437. }
  438. public function doReject() {
  439. $id = trim($this->request['id']);
  440. if (!$id) {
  441. return json(["msg" => 'ID不能为空!']);
  442. }
  443. $ep = EnterpriseApi::getOne($id);
  444. if (!$ep) {
  445. return json(["msg" => '无此企业!']);
  446. }
  447. if ($ep["checkState"] != 3) {
  448. return json(["msg" => '该操作只能对已通过企业进行驳回!']);
  449. }
  450. $checkMsg = $this->request['checkMsg'];
  451. $fields = $this->request['fields'];
  452. $files = $this->request['files'];
  453. if (\StrUtil::isEmpOrNull($checkMsg)) {
  454. return json(["msg" => '请填写审核意见!']);
  455. }
  456. if (strlen($checkMsg) > 1000) {
  457. return json(["msg" => '审核意见最多1000个字符!']);
  458. }
  459. if (!$fields && !$files) {
  460. return json(["msg" => '请选择驳回修改的字段或者附件!']);
  461. }
  462. try {
  463. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  464. if ($lastLog["active"] != 1 || $lastLog["state"] != $ep["checkState"]) {
  465. return json(["msg" => '日志状态与当前状态不一致,已中止操作']);
  466. }
  467. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  468. $checkData = [
  469. 'id' => $id,
  470. 'checkState' => 2,
  471. 'checkMsg' => $checkMsg,
  472. 'modify_fields' => $fields ? implode(",", $fields) : null,
  473. 'modify_files' => $files ? implode(",", $files) : null,
  474. 'checkUser' => session('user')['name'],
  475. 'updateUser' => session('user')['uid'],
  476. 'updateTime' => date("Y-m-d H:i:s")
  477. ];
  478. $res = EnterpriseApi::updateById($checkData);
  479. $tplContent = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。退订回复TD。";
  480. $smsapi = new ChuanglanSmsApi();
  481. $result = $smsapi->sendSMS($ep['agentPhone'], $tplContent);
  482. //短信入库数据
  483. $record_data = [
  484. 'id' => getStringId(),
  485. 'bizId' => $result['msgId'],
  486. 'userId' => $id,
  487. 'type' => 2,
  488. 'smsType' => 2,
  489. 'name' => $ep['name'],
  490. 'phone' => $ep['agentPhone'],
  491. 'params' => '机构注册通过再驳回',
  492. 'state' => $result['code'] == 0 ? 2 : 3,
  493. 'sendingDate' => date("Y-m-d H:i:s", time()),
  494. 'createTime' => date("Y-m-d H:i:s", time()),
  495. 'templateCode' => $tplContent,
  496. "msg" => $result['errorMsg']
  497. ];
  498. MessageRecord::create($record_data);
  499. TalentChecklog::create([
  500. 'id' => getStringId(),
  501. 'mainId' => $id,
  502. 'type' => 10,
  503. 'typeField' => null,
  504. 'active' => 1,
  505. 'state' => 2,
  506. 'step' => 101,
  507. 'stateChange' => TalentState::stateEnum(2),
  508. 'description' => $checkMsg,
  509. 'createTime' => date("Y-m-d H:i:s", time()),
  510. 'createUser' => session('user')['name'] . "({$companyName})"
  511. ]);
  512. return json(["msg" => '操作成功!', "code" => 200]);
  513. } catch (\Exception $e) {
  514. return json(["msg" => $e->getMessage()]);
  515. }
  516. }
  517. public function delEnterprise() {
  518. if (!$id = trim($this->request['id'])) {
  519. return json(["msg" => 'ID不能为空!', "code" => 500]);
  520. }
  521. $ep = EnterpriseApi::getOne($id);
  522. if (!$ep || $ep->delete == 1)
  523. return json(["msg" => '要删除的数据不存在!', "code" => 500]);
  524. $ep->delete = 1;
  525. $ep->deleteUser = session('user')['uid'] . "";
  526. $ep->deleteTime = date('Y-m-d H:i:s');
  527. try {
  528. $ep->save();
  529. return json(["msg" => '操作成功!', "code" => 200]);
  530. } catch (\Exception $e) {
  531. return json(["msg" => $e->getMessage()]);
  532. }
  533. }
  534. public function GotoActivePage() {
  535. $id = trim($this->request['id']);
  536. $ep = EnterpriseApi::getOne($id);
  537. $template = "";
  538. switch ($this->user["type"]) {
  539. case CommonConst::ENTERPRISE_WJ:
  540. $template = "/enterprise/hospital/goto_active_page";
  541. break;
  542. case CommonConst::ENTERPRISE_GJ:
  543. $template = "/enterprise/school/goto_active_page";
  544. break;
  545. }
  546. return view($template, ['ep' => $ep]);
  547. }
  548. public function setActive() {
  549. if (!$id = trim($this->request['id'])) {
  550. return json(["msg" => 'ID不能为空!', "code" => 500]);
  551. }
  552. $ep = EnterpriseApi::getOne($id);
  553. $active = $this->request['active'];
  554. if ($ep['active'] == null || ($ep['active'] != 1 && $ep['active'] != 2)) {
  555. return json(["msg" => '状态有误!', "code" => 500]);
  556. }
  557. if ($ep['active'] == 2) {
  558. $msg = trim($this->request['activeMsg']);
  559. if (empty($msg)) {
  560. return json(["msg" => '请填写拉黑/冻结原因!', "code" => 500]);
  561. }
  562. if (strlen($msg) > 100) {
  563. return json(["msg" => '拉黑/冻结原因 最多100个字符!', "code" => 500]);
  564. }
  565. }
  566. $company = CompanyApi::getOne(session('user')['companyId']);
  567. $ep->active = $active;
  568. $ep->activeMsg = $msg;
  569. $ep->updateUser = session('user')['uid'] . "";
  570. $ep->updateTime = date('y-m-d H:i:s');
  571. try {
  572. $ep->save();
  573. //添加日志
  574. TalentChecklog::create([
  575. 'id' => getStringId(),
  576. 'mainId' => $ep['id'],
  577. 'type' => 10,
  578. 'typeField' => null,
  579. 'active' => 1,
  580. 'state' => TalentState::RCRD_BASEIC_FROZEN,
  581. 'step' => 102,
  582. 'stateChange' => TalentState::stateEnum(10),
  583. 'description' => $msg,
  584. 'createTime' => date("Y-m-d H:i:s", time()),
  585. 'createUser' => session('user')['name'] . "({$company['name']})"
  586. ]);
  587. return json(["msg" => '操作成功!', "code" => 200]);
  588. } catch (\Exception $e) {
  589. return json(["msg" => $e->getMessage()]);
  590. }
  591. }
  592. public function resetPassword() {
  593. if (!$id = trim($this->request['id'])) {
  594. return json(["msg" => 'ID不能为空!', "code" => 500]);
  595. }
  596. $ep = EnterpriseApi::getOne($id);
  597. if (!$ep) {
  598. return json(["msg" => '找不到该用户!', "code" => 500]);
  599. }
  600. $ep->password = hash("md5", 'JJrc@123'); //默认密码
  601. $ep->updateUser = session('user')['uid'] . "";
  602. $ep->updateTime = date("Y-m-d H:i:s");
  603. $ep->save();
  604. $company = CompanyApi::getOne(session('user')['companyId']);
  605. TalentChecklog::create([
  606. 'id' => getStringId(),
  607. 'mainId' => $ep['id'],
  608. 'type' => 10,
  609. 'typeField' => null,
  610. 'active' => 1,
  611. 'state' => null,
  612. 'step' => 103,
  613. 'stateChange' => '重置密码',
  614. 'description' => '重置密码',
  615. 'createTime' => date("Y-m-d H:i:s", time()),
  616. 'createUser' => session('user')['name'] . "({$company['name']})"
  617. ]);
  618. return json(["msg" => '重置密码成功!', "code" => 200]);
  619. }
  620. public function export() {
  621. $res = EnterpriseApi::getList($this->request, true);
  622. $rows = $res["rows"];
  623. $columns = ["单位名称", " 统一社会信用代码", "产业领域", "单位标签", " 所属街道", "单位地址", " 法人代表", " 单位电话", "人才联络员", "人才联络员电话", "人才联络员邮箱", "审核状态", "账号状态", "注册时间", "备注"];
  624. $exportDatas = [];
  625. if ($res["rows"]) {
  626. $stateMaps = [1 => "未审核", 2 => "审核驳回", 3 => "审核通过", 4 => "重新提交", 5 => "初审驳回", 6 => "初审通过"];
  627. $activeMaps = [1 => "账号有效", 2 => "拉黑/冻结"];
  628. foreach ($rows as $row) {
  629. $exportDatas[] = [
  630. $row['name'],
  631. $row['idCard'],
  632. $row['industryFieldNewName'],
  633. $row['enterpriseTagName'],
  634. $row['streetName'],
  635. $row['address'],
  636. $row['legal'],
  637. $row['ephone'],
  638. $row['agentName'],
  639. $row['agentPhone'],
  640. $row['agentEmail'],
  641. $stateMaps[$row["checkState"]],
  642. $activeMaps[$row["active"]],
  643. $row['createTime'],
  644. $row['description']
  645. ];
  646. }
  647. export($columns, $exportDatas, "企业用户信息");
  648. exit();
  649. }
  650. return json(["msg" => "没有可以导出的内容"]);
  651. }
  652. public function findFieldsAndFiles() {
  653. $id = $this->request->param("id");
  654. $ep = EnterpriseApi::getOne($id);
  655. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  656. $fields = $fieldsAndFiles["fields"];
  657. $files = $fieldsAndFiles["files"];
  658. $modify_fields = [];
  659. $modify_files = [];
  660. $_modify_fields = explode(",", $ep["modify_fields"]);
  661. foreach ($fields as $key => $value) {
  662. $checked = in_array($key, $_modify_fields);
  663. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  664. }
  665. $_modify_files = explode(",", $ep["modify_files"]);
  666. foreach ($files as $key => $value) {
  667. $checked = in_array($key, $_modify_files);
  668. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  669. }
  670. return json(["code" => 200, "files" => $modify_files, "fields" => $modify_fields]);
  671. }
  672. public function updateFieldsAndFiles() {
  673. try {
  674. $params = $this->request->param();
  675. $id = $params["id"];
  676. $ep = EnterpriseApi::getOne($id);
  677. if (!$ep) {
  678. throw new \think\Exception("没有对应的企业信息");
  679. }
  680. if (!in_array($ep["checkState"], [2, 5])) {
  681. throw new \think\Exception("不是驳回状态,不能修改驳回字段!");
  682. }
  683. if ($ep["checkState"] == 2 && !EnterpriseApi::chkUserInSuperusers()) {
  684. throw new \think\Exception("已经流转到审核,不在审核范围内");
  685. }
  686. $fields = array_filter(explode(",", $params["fields"]));
  687. $files = array_filter(explode(",", $params["files"]));
  688. if (!$fields && !$files)
  689. throw new \think\Exception("请选择要驳回的字段或附件!");
  690. $data["id"] = $id;
  691. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  692. $data["modify_files"] = $files ? implode(",", $files) : null;
  693. $data["updateTime"] = date("Y-m-d H:i:s");
  694. $data["updateUser"] = session("user")["uid"];
  695. if (EnterpriseApi::updateById($data)) {
  696. return json(["code" => 200, "msg" => "修改成功!"]);
  697. }
  698. } catch (\think\Exception $e) {
  699. return json(["msg" => $e->getMessage()]);
  700. }
  701. }
  702. private function getFieldAndFilesBySpecialAndType($special, $type) {
  703. if ($special == 0) {
  704. if ($type == CommonConst::ENTERPRISE_JC) {
  705. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  706. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  707. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员信息备案表"];
  708. } else if ($type == CommonConst::ENTERPRISE_WJ) {
  709. $fields = ["name" => "医院名称", "idCard" => "登记号", "legal" => "法人代表", "medicalCommunityId" => "医共体", "isGeneral" => "是否总院", "ephone" => "医院电话", "province" => "地址省", "city" => "地址市", "county" => "地址县\区", "address" => "企业地址",
  710. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  711. $files = ["imgurl" => "医疗机构执业许可证", "beian" => "人才联络员信息备案表"];
  712. } else if ($type == CommonConst::ENTERPRISE_GJ) {
  713. $fields = ["name" => "学校名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "ephone" => "学校电话", "province" => "地址省", "city" => "地址市", "county" => "地址县\区", "address" => "学校地址",
  714. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  715. $files = ["imgurl" => "办学许可证、法人证书或登记证书", "beian" => "人才联络员信息备案表"];
  716. } else {
  717. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  718. "agencyType" => "机构类型", "industryFieldNew" => "产业领域", "industryFieldOld" => "行业领域", "enterpriseTag" => "企业标签", "enterpriseType" => "企业类型",
  719. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  720. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "domainImg" => "行业领域佐证材料", "beian" => "人才联络员信息备案表", "typeImg" => "规上、高新技术、专精特新企业上传材料"];
  721. }
  722. } else {
  723. $fields = ["name" => "单位名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "单位地址", "street" => "所属街道", "ephone" => "单位电话", "bankCard" => "单位银行账号", "bank" => "单位开户银行", "bankNetwork" => "单位开户银行网点",
  724. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  725. if ($special == 1) {
  726. $fields["institutionTag"] = "单位标签";
  727. }
  728. if ($special == 3) {
  729. $fields["organizationTag"] = "机构标签";
  730. }
  731. $files = ["imgurl" => "法人证或批文", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员备案表"];
  732. }
  733. return ["fields" => $fields, "files" => $files];
  734. }
  735. }