Enterprise.php 35 KB

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