Enterprise.php 26 KB

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