Enterprise.php 35 KB

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