Enterprise.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\DictApi;
  6. use app\common\api\EnterpriseApi;
  7. use app\common\model\MessageRecord;
  8. use app\common\model\TalentChecklog;
  9. use app\common\api\TalentState;
  10. use app\common\api\CompanyApi;
  11. use think\facade\Db;
  12. /**
  13. * 企业审核
  14. * checkState 1:用户提交 [2:审核驳回 3:审核通过] 4:重新提交 [5:初审驳回 6:初审通过]
  15. */
  16. class Enterprise extends AdminController {
  17. public function gotoEnterprisePage() {
  18. return view("", []);
  19. }
  20. public function findEnterpriseByPage() {
  21. $res = EnterpriseApi::getList($this->request);
  22. return json($res);
  23. }
  24. public function gotoEnterpriseDetailPage() {
  25. $id = trim($this->request['id']);
  26. $ep = EnterpriseApi::getOne($id);
  27. if (!$ep) {
  28. return "无此企业";
  29. }
  30. //--------设置 审核状态---------------------------------------------------
  31. switch ($ep['checkState']) {
  32. case 1:
  33. $ep['checkStateName'] = "待审核";
  34. break;
  35. case 2:
  36. $ep['checkStateName'] = "审核驳回";
  37. break;
  38. case 3:
  39. $ep['checkStateName'] = "审核通过";
  40. break;
  41. case 4:
  42. $ep['checkStateName'] = "重新提交";
  43. break;
  44. case 5:
  45. $ep['checkStateName'] = "初审驳回";
  46. break;
  47. case 6:
  48. $ep['checkStateName'] = "初审通过";
  49. break;
  50. }
  51. //-------设置账号状态----------------------------------------------------
  52. switch ($ep['active']) {
  53. case 1:
  54. $ep['activeName'] = "账号有效";
  55. break;
  56. case 2:
  57. $ep['activeName'] = "冻结/拉黑";
  58. break;
  59. }
  60. //---------设置 街道-----------------------------------------------------
  61. if (\StrUtil::isNotEmpAndNull($ep['street'])) {
  62. $street_info = DictApi::findByParentCodeAndCode('street', $ep['street']);
  63. if ($street_info != null) {
  64. $ep['streetName'] = $street_info['name'];
  65. }
  66. }
  67. if (\StrUtil::isNotEmpAndNull($ep['agencyType'])) {
  68. $agencyType = DictApi::findByParentCodeAndCode('agency_type', $ep['agencyType']);
  69. $ep["agencyTypeName"] = $agencyType["name"];
  70. }
  71. //---------设置产业领域 --------------------------------------------------
  72. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  73. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  74. if ($industryFieldNew != null) {
  75. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  76. }
  77. }
  78. //---------设置行业领域 --------------------------------------------------
  79. if (\StrUtil::isNotEmpAndNull($ep['industryFieldOld'])) {
  80. $industryFieldOld = DictApi::findByParentCodeAndCode($ep['industryFieldNew'] . "_field", $ep['industryFieldOld']);
  81. if ($industryFieldOld != null) {
  82. $ep['industryFieldOldName'] = $industryFieldOld['name'];
  83. }
  84. }
  85. //---------设置单位标签 --------------------------------------------------
  86. if (\StrUtil::isNotEmpAndNull($ep['enterpriseTag'])) {
  87. $enterpriseTag = DictApi::findByParentCodeAndCode("enterprise_tag", $ep['enterpriseTag']);
  88. if ($enterpriseTag != null) {
  89. $ep['enterpriseTagName'] = $enterpriseTag['name'];
  90. }
  91. }
  92. //---------设置机构标签 --------------------------------------------------
  93. if (\StrUtil::isNotEmpAndNull($ep['organizationTag'])) {
  94. $organizationTag = DictApi::findByParentCodeAndCode("organization_tag", $ep['organizationTag']);
  95. if ($organizationTag != null) {
  96. $ep['organizationTagName'] = $organizationTag['name'];
  97. }
  98. }
  99. //---------设置事业单位标签 --------------------------------------------------
  100. if (\StrUtil::isNotEmpAndNull($ep['institutionTag'])) {
  101. $institutionTag = DictApi::findByParentCodeAndCode("institution_tag", $ep['institutionTag']);
  102. if ($institutionTag != null) {
  103. $ep['institutionTagName'] = $institutionTag['name'];
  104. }
  105. }
  106. //---------设置单位类型 --------------------------------------------------
  107. if (\StrUtil::isNotEmpAndNull($ep['enterpriseType'])) {
  108. $enterpriseType = DictApi::findByParentCodeAndCode("enterprise_type", $ep['enterpriseType']);
  109. if ($enterpriseType != null) {
  110. $ep['enterpriseTypeName'] = $enterpriseType['name'];
  111. }
  112. }
  113. $imgurl_info = pathinfo($ep['imgurl']);
  114. if (in_array($imgurl_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  115. $ep['imgurl_is_img'] = 1;
  116. } else {
  117. $ep['imgurl_is_img'] = 0;
  118. }
  119. $bankImg_info = pathinfo($ep['bankImg']);
  120. if (in_array($bankImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  121. $ep['bankImg_is_img'] = 1;
  122. } else {
  123. $ep['bankImg_is_img'] = 0;
  124. }
  125. $domainImg_info = pathinfo($ep['domainImg']);
  126. if (in_array($domainImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  127. $ep['domainImg_is_img'] = 1;
  128. } else {
  129. $ep['domainImg_is_img'] = 0;
  130. }
  131. $typeImg_info = pathinfo($ep['typeImg']);
  132. if (in_array($typeImg_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  133. $ep['typeImg_is_img'] = 1;
  134. } else {
  135. $ep['typeImg_is_img'] = 0;
  136. }
  137. $beian_info = pathinfo($ep['beian']);
  138. if (in_array($beian_info['extension'], ["jpeg", "jpg", "png", "gif"])) {
  139. $ep['beian_is_img'] = 1;
  140. } else {
  141. $ep['beian_is_img'] = 0;
  142. }
  143. return view("", ['ep' => $ep]);
  144. }
  145. public function gotoExaminePage() {
  146. $id = trim($this->request['id']);
  147. $ep = EnterpriseApi::getOne($id);
  148. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  149. if ($lastLog["active"] == 0) {
  150. $ep["checkState"] = $lastLog["state"];
  151. $ep["checkMsg"] = $lastLog["description"];
  152. }
  153. if (!$ep) {
  154. return "无此企业";
  155. }
  156. //---------设置产业领域 --------------------------------------------------
  157. if (\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])) {
  158. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field', $ep['industryFieldNew']);
  159. if ($industryFieldNew != null) {
  160. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  161. }
  162. }
  163. if ($ep->special == 0) {
  164. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  165. "agencyType" => "机构类型", "industryFieldNew" => "产业领域", "industryFieldOld" => "行业领域", "enterpriseTag" => "企业标签", "enterpriseType" => "企业类型",
  166. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  167. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "domainImg" => "行业领域佐证材料", "beian" => "人才联络员信息备案表", "typeImg" => "规上、高新技术、专精特新企业上传材料"];
  168. } else {
  169. $fields = ["name" => "单位名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "单位地址", "street" => "所属街道", "ephone" => "单位电话", "bankCard" => "单位银行账号", "bank" => "单位开户银行", "bankNetwork" => "单位开户银行网点",
  170. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  171. if ($ep->special == 1) {
  172. $fields["institutionTag"] = "单位标签";
  173. }
  174. if ($ep->special == 3) {
  175. $fields["organizationTag"] = "机构标签";
  176. }
  177. $files = ["imgurl" => "法人证或批文", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员备案表"];
  178. }
  179. $modify_fields = [];
  180. $modify_files = [];
  181. $_modify_fields = explode(",", $ep["modify_fields"]);
  182. foreach ($fields as $key => $value) {
  183. $checked = in_array($key, $_modify_fields);
  184. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  185. }
  186. $_modify_files = explode(",", $ep["modify_files"]);
  187. foreach ($files as $key => $value) {
  188. $checked = in_array($key, $_modify_files);
  189. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  190. }
  191. return view("", ['ep' => $ep, 'checkUser' => session('user')['name'], 'fields' => $modify_fields, "files" => $modify_files]);
  192. }
  193. public function doExamine() {
  194. $id = trim($this->request['id']);
  195. $doSubmit = $this->request["submit"] == 1 ? true : false;
  196. if (!$id) {
  197. return json(["msg" => 'ID不能为空!']);
  198. }
  199. $ep = EnterpriseApi::getOne($id);
  200. if (!$ep) {
  201. return json(["msg" => '无此企业!']);
  202. }
  203. $oriCheckState = $ep["checkState"];
  204. if ($oriCheckState == 6 && !EnterpriseApi::chkUserInSuperusers()) {
  205. return json(["msg" => "已经流转到审核,不在审核范围内"]);
  206. }
  207. if (!in_array($ep["checkState"], [1, 4, 6]))
  208. return json(["msg" => "不在审核范围内"]);
  209. $checkState = $this->request['checkState'];
  210. if ($checkState == null || ($checkState != 2 && $checkState != 3)) {
  211. return json(["msg" => '请选择审核状态!']);
  212. }
  213. $checkMsg = $this->request['checkMsg'];
  214. $fields = $this->request['fields'];
  215. $files = $this->request['files'];
  216. if ($checkState == 2) {
  217. if (\StrUtil::isEmpOrNull($checkMsg)) {
  218. return json(["msg" => '请填写审核意见!']);
  219. }
  220. if (strlen($checkMsg) > 1000) {
  221. return json(["msg" => '审核意见最多1000个字符!']);
  222. }
  223. if (!$fields && !$files) {
  224. return json(["msg" => '请选择驳回修改的字段或者附件!']);
  225. }
  226. }
  227. try {
  228. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  229. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  230. if ($checkState == 3) {
  231. $fields = null;
  232. $files = null;
  233. }
  234. if ($oriCheckState == 6 || $ep["type"] == 2) {
  235. $newCheckState = $checkState;
  236. } else {
  237. $newCheckState = $checkState == 3 ? 6 : 5;
  238. }
  239. if ($doSubmit) {
  240. $checkData = [
  241. 'id' => $id,
  242. 'checkState' => $newCheckState,
  243. 'checkMsg' => $checkMsg,
  244. 'modify_fields' => $fields ? implode(",", $fields) : null,
  245. 'modify_files' => $files ? implode(",", $files) : null,
  246. 'checkUser' => session('user')['name'],
  247. 'updateUser' => session('user')['uid'],
  248. 'updateTime' => date("Y-m-d H:i:s")
  249. ];
  250. $res = EnterpriseApi::updateById($checkData);
  251. //短信入库数据
  252. $record_data = [
  253. 'id' => getStringId(),
  254. 'bizId' => getStringId(),
  255. 'userId' => $id,
  256. 'type' => 2,
  257. 'smsType' => 2,
  258. 'name' => $ep['name'],
  259. 'phone' => $ep['agentPhone'],
  260. 'params' => '机构注册信息',
  261. 'state' => 1,
  262. 'sendingDate' => date("Y-m-d H:i:s", time()),
  263. 'createTime' => date("Y-m-d H:i:s", time())
  264. ];
  265. if ($checkState == 2) {
  266. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。退订回复TD。";
  267. }
  268. if ($newCheckState == 3) {
  269. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交的晋江市现代产业体系人才机构注册信息已审核通过,可登录“晋江市人才综合服务申报平台”做相关事宜申报。退订回复TD。";
  270. }
  271. if ($newCheckState == 3 || $checkState == 2) {
  272. $smsapi = new ChuanglanSmsApi();
  273. $result = $smsapi->sendSMS($ep['agentPhone'], $record_data['templateCode']);
  274. MessageRecord::create($record_data);
  275. }
  276. if ($lastLog["active"] === 0) {
  277. TalentChecklog::update([
  278. 'id' => $lastLog["id"],
  279. 'active' => 1,
  280. 'state' => $newCheckState,
  281. 'step' => 101,
  282. 'stateChange' => TalentState::stateEnum($newCheckState),
  283. 'description' => $checkMsg,
  284. 'updateTime' => date("Y-m-d H:i:s", time()),
  285. 'updateUser' => session('user')['name'] . "({$companyName})"
  286. ]);
  287. } else {
  288. TalentChecklog::create([
  289. 'id' => getStringId(),
  290. 'mainId' => $id,
  291. 'type' => 10,
  292. 'typeField' => null,
  293. 'active' => 1,
  294. 'state' => $newCheckState,
  295. 'step' => 101,
  296. 'stateChange' => TalentState::stateEnum($newCheckState),
  297. 'description' => $checkMsg,
  298. 'createTime' => date("Y-m-d H:i:s", time()),
  299. 'createUser' => session('user')['name'] . "({$companyName})"
  300. ]);
  301. }
  302. return json(["msg" => '操作成功!', "code" => 200]);
  303. } else {
  304. $checkData = [
  305. 'id' => $id,
  306. 'modify_fields' => $fields ? implode(",", $fields) : null,
  307. 'modify_files' => $files ? implode(",", $files) : null,
  308. 'checkUser' => session('user')['name'],
  309. 'updateUser' => session('user')['uid'],
  310. 'updateTime' => date("Y-m-d H:i:s")
  311. ];
  312. $res = EnterpriseApi::updateById($checkData);
  313. if ($lastLog["active"] === 0) {
  314. TalentChecklog::update([
  315. 'id' => $lastLog["id"],
  316. 'state' => $newCheckState,
  317. 'step' => 101,
  318. 'stateChange' => TalentState::stateEnum($newCheckState),
  319. 'description' => $checkMsg,
  320. 'updateTime' => date("Y-m-d H:i:s", time()),
  321. 'updateUser' => session('user')['name'] . "({$companyName})"
  322. ]);
  323. } else {
  324. TalentChecklog::create([
  325. 'id' => getStringId(),
  326. 'mainId' => $id,
  327. 'type' => 10,
  328. 'typeField' => null,
  329. 'active' => 0,
  330. 'state' => $newCheckState,
  331. 'step' => 101,
  332. 'stateChange' => TalentState::stateEnum($checkState),
  333. 'description' => $checkMsg,
  334. 'createTime' => date("Y-m-d H:i:s", time()),
  335. 'createUser' => session('user')['name'] . "({$companyName})"
  336. ]);
  337. }
  338. return json(["msg" => '保存成功!', "code" => 200]);
  339. }
  340. } catch (\Exception $e) {
  341. return json(["msg" => $e->getMessage()]);
  342. }
  343. }
  344. public function delEnterprise() {
  345. if (!$id = trim($this->request['id'])) {
  346. return json(["msg" => 'ID不能为空!', "code" => 500]);
  347. }
  348. $ep = EnterpriseApi::getOne($id);
  349. if (!$ep || $ep->delete == 1)
  350. return json(["msg" => '要删除的数据不存在!', "code" => 500]);
  351. $ep->delete = 1;
  352. $ep->deleteUser = session('user')['uid'] . "";
  353. $ep->deleteTime = date('Y-m-d H:i:s');
  354. try {
  355. $ep->save();
  356. return json(["msg" => '操作成功!', "code" => 200]);
  357. } catch (\Exception $e) {
  358. return json(["msg" => $e->getMessage()]);
  359. }
  360. }
  361. public function GotoActivePage() {
  362. $id = trim($this->request['id']);
  363. $ep = EnterpriseApi::getOne($id);
  364. return view("", ['ep' => $ep]);
  365. }
  366. public function setActive() {
  367. if (!$id = trim($this->request['id'])) {
  368. return json(["msg" => 'ID不能为空!', "code" => 500]);
  369. }
  370. $ep = EnterpriseApi::getOne($id);
  371. $active = $this->request['active'];
  372. if ($ep['active'] == null || ($ep['active'] != 1 && $ep['active'] != 2)) {
  373. return json(["msg" => '状态有误!', "code" => 500]);
  374. }
  375. if ($ep['active'] == 2) {
  376. $msg = trim($this->request['activeMsg']);
  377. if (empty($msg)) {
  378. return json(["msg" => '请填写拉黑/冻结原因!', "code" => 500]);
  379. }
  380. if (strlen($msg) > 100) {
  381. return json(["msg" => '拉黑/冻结原因 最多100个字符!', "code" => 500]);
  382. }
  383. }
  384. $company = CompanyApi::getOne(session('user')['companyId']);
  385. $ep->active = $active;
  386. $ep->activeMsg = $msg;
  387. $ep->updateUser = session('user')['uid'] . "";
  388. $ep->updateTime = date('y-m-d H:i:s');
  389. try {
  390. $ep->save();
  391. //添加日志
  392. TalentChecklog::create([
  393. 'id' => getStringId(),
  394. 'mainId' => $ep['id'],
  395. 'type' => 10,
  396. 'typeField' => null,
  397. 'active' => 1,
  398. 'state' => TalentState::RCRD_BASEIC_FROZEN,
  399. 'step' => 102,
  400. 'stateChange' => TalentState::stateEnum(10),
  401. 'description' => $msg,
  402. 'createTime' => date("Y-m-d H:i:s", time()),
  403. 'createUser' => session('user')['name'] . "({$company['name']})"
  404. ]);
  405. return json(["msg" => '操作成功!', "code" => 200]);
  406. } catch (\Exception $e) {
  407. return json(["msg" => $e->getMessage()]);
  408. }
  409. }
  410. public function resetPassword() {
  411. if (!$id = trim($this->request['id'])) {
  412. return json(["msg" => 'ID不能为空!', "code" => 500]);
  413. }
  414. $ep = EnterpriseApi::getOne($id);
  415. if (!$ep) {
  416. return json(["msg" => '找不到该用户!', "code" => 500]);
  417. }
  418. $ep->password = hash("md5", 'JJrc@123'); //默认密码
  419. $ep->updateUser = session('user')['uid'] . "";
  420. $ep->updateTime = date("Y-m-d H:i:s");
  421. $ep->save();
  422. $company = CompanyApi::getOne(session('user')['companyId']);
  423. TalentChecklog::create([
  424. 'id' => getStringId(),
  425. 'mainId' => $ep['id'],
  426. 'type' => 10,
  427. 'typeField' => null,
  428. 'active' => 1,
  429. 'state' => null,
  430. 'step' => 103,
  431. 'stateChange' => '重置密码',
  432. 'description' => '重置密码',
  433. 'createTime' => date("Y-m-d H:i:s", time()),
  434. 'createUser' => session('user')['name'] . "({$company['name']})"
  435. ]);
  436. return json(["msg" => '重置密码成功!', "code" => 200]);
  437. }
  438. public function export() {
  439. $res = EnterpriseApi::getList($this->request, true);
  440. $rows = $res["rows"];
  441. $columns = ["单位名称", " 统一社会信用代码", "产业领域", "单位标签", " 所属街道", "单位地址", " 法人代表", " 单位电话", "人才联络员", "人才联络员电话", "人才联络员邮箱", "审核状态", "账号状态", "注册时间", "备注"];
  442. $exportDatas = [];
  443. if ($res["rows"]) {
  444. $stateMaps = [1 => "未审核", 2 => "审核驳回", 3 => "审核通过", 4 => "重新提交", 5 => "初审驳回", 6 => "初审通过"];
  445. $activeMaps = [1 => "账号有效", 2 => "拉黑/冻结"];
  446. foreach ($rows as $row) {
  447. $exportDatas[] = [
  448. $row['name'],
  449. $row['idCard'],
  450. $row['industryFieldNewName'],
  451. $row['enterpriseTagName'],
  452. $row['streetName'],
  453. $row['address'],
  454. $row['legal'],
  455. $row['ephone'],
  456. $row['agentName'],
  457. $row['agentPhone'],
  458. $row['agentEmail'],
  459. $stateMaps[$row["checkState"]],
  460. $activeMaps[$row["active"]],
  461. $row['createTime'],
  462. $row['description']
  463. ];
  464. }
  465. export($columns, $exportDatas, "企业用户信息");
  466. exit();
  467. }
  468. return json(["msg" => "没有可以导出的内容"]);
  469. }
  470. public function findFieldsAndFiles() {
  471. $id = $this->request->param("id");
  472. $ep = EnterpriseApi::getOne($id);
  473. if ($ep->special == 0) {
  474. $fields = ["name" => "企业名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "企业地址", "street" => "所属街道", "ephone" => "企业电话", "bankCard" => "企业银行账号", "bank" => "企业开户银行", "bankNetwork" => "企业开户银行网点",
  475. "agencyType" => "机构类型", "industryFieldNew" => "产业领域", "industryFieldOld" => "行业领域", "enterpriseTag" => "企业标签", "enterpriseType" => "企业类型",
  476. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  477. $files = ["imgurl" => "企业营业执照", "bankImg" => "开户许可证/基本存款账户信息", "domainImg" => "行业领域佐证材料", "beian" => "人才联络员信息备案表", "typeImg" => "规上、高新技术、专精特新企业上传材料"];
  478. } else {
  479. $fields = ["name" => "单位名称", "idCard" => "统一社会信用代码", "legal" => "法人代表", "address" => "单位地址", "street" => "所属街道", "ephone" => "单位电话", "bankCard" => "单位银行账号", "bank" => "单位开户银行", "bankNetwork" => "单位开户银行网点",
  480. "agentName" => "人才联络员姓名", "agentPhone" => "人才联络员电话", "agentEmail" => "人才联络员邮箱"];
  481. if ($ep->special == 1) {
  482. $fields["institutionTag"] = "单位标签";
  483. }
  484. if ($ep->special == 3) {
  485. $fields["organizationTag"] = "机构标签";
  486. }
  487. $files = ["imgurl" => "法人证或批文", "bankImg" => "开户许可证/基本存款账户信息", "beian" => "人才联络员备案表"];
  488. }
  489. $modify_fields = [];
  490. $modify_files = [];
  491. $_modify_fields = explode(",", $ep["modify_fields"]);
  492. foreach ($fields as $key => $value) {
  493. $checked = in_array($key, $_modify_fields);
  494. $modify_fields[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  495. }
  496. $_modify_files = explode(",", $ep["modify_files"]);
  497. foreach ($files as $key => $value) {
  498. $checked = in_array($key, $_modify_files);
  499. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => $checked];
  500. }
  501. return json(["code" => 200, "files" => $modify_files, "fields" => $modify_fields]);
  502. }
  503. public function updateFieldsAndFiles() {
  504. try {
  505. $params = $this->request->param();
  506. $id = $params["id"];
  507. $ep = EnterpriseApi::getOne($id);
  508. if (!$ep) {
  509. throw new \think\Exception("没有对应的企业信息");
  510. }
  511. if (!in_array($ep["checkState"], [2, 5])) {
  512. throw new \think\Exception("不是驳回状态,不能修改驳回字段!");
  513. }
  514. if ($ep["checkState"] == 2 && !EnterpriseApi::chkUserInSuperusers()) {
  515. throw new \think\Exception("已经流转到审核,不在审核范围内");
  516. }
  517. $fields = array_filter(explode(",", $params["fields"]));
  518. $files = array_filter(explode(",", $params["files"]));
  519. if (!$fields && !$files)
  520. throw new \think\Exception("请选择要驳回的字段或附件!");
  521. $data["id"] = $id;
  522. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  523. $data["modify_files"] = $files ? implode(",", $files) : null;
  524. $data["updateTime"] = date("Y-m-d H:i:s");
  525. $data["updateUser"] = session("user")["uid"];
  526. if (EnterpriseApi::updateById($data)) {
  527. return json(["code" => 200, "msg" => "修改成功!"]);
  528. }
  529. } catch (\think\Exception $e) {
  530. return json(["msg" => $e->getMessage()]);
  531. }
  532. }
  533. }