EnterpriseChangeRecord.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\api\RsApi;
  4. use app\admin\common\AdminController;
  5. use app\admin\model\ApiData;
  6. use app\common\api\ChuanglanSmsApi;
  7. use app\common\api\CompanyApi;
  8. use app\common\api\DictApi;
  9. use app\common\api\EnterpriseApi;
  10. use app\common\api\TalentState;
  11. use app\common\model\CurrentcyFileType;
  12. use app\common\model\MessageRecord;
  13. use app\common\model\TalentChecklog;
  14. use app\common\model\TalentCommonFile;
  15. use app\common\state\CommonConst;
  16. /**
  17. * 企业变更审核
  18. * checkState 1:用户保存 2:用户提交 [3:审核驳回 4:审核通过] 5:重新提交 [6:初审驳回 7:初审通过]
  19. */
  20. class EnterpriseChangeRecord extends AdminController {
  21. private $compatible_time = "2022-10-15 23:59:59";
  22. public function gotoEnterpriseChangeRecordPage() {
  23. $template = "";
  24. $assigns = [];
  25. switch ($this->user["type"]) {
  26. case CommonConst::ENTERPRISE_WJ:
  27. $template = "/enterprise_change_record/hospital/goto_enterprise_change_record_page";
  28. $where[] = ["status", "<>", 3];
  29. $assigns["medicalCommunities"] = \app\common\api\Nhc::getMedicalCommunityList();
  30. break;
  31. case CommonConst::ENTERPRISE_GJ:
  32. $template = "/enterprise_change_record/school/goto_enterprise_change_record_page";
  33. break;
  34. default:
  35. $talentTypeList = DictApi::findChildDictByCode("enterprise_tag");
  36. $industryFieldNewList = DictApi::findChildDictByCode("industry_field");
  37. $streetList = DictApi::findChildDictByCode("street");
  38. $assigns = ['enterprise_tag' => $talentTypeList, 'industryFieldNew' => $industryFieldNewList, 'street' => $streetList];
  39. break;
  40. }
  41. return view($template, $assigns);
  42. }
  43. public function findEnterpriseChangeRecordByPage() {
  44. $res = EnterpriseApi::getRecordList($this->request);
  45. return json($res);
  46. }
  47. public function gotoEnterpriseChangeDetailPage() {
  48. $id = trim($this->request['id']);
  49. if (!$id) {
  50. return json(["msg" => 'ID不能为空!']);
  51. }
  52. $ecr = EnterpriseApi::getOneRecord($id);
  53. $ep = EnterpriseApi::getOne($ecr['mainId']);
  54. if (\StrUtil::isNotEmpAndNull($ecr['oldStreet']) || \StrUtil::isNotEmpAndNull($ecr['newStreet'])) {
  55. $streetList = DictApi::selectByParentCode("street");
  56. if (\StrUtil::isNotEmpAndNull($ecr['oldStreet'])) {
  57. $ecr['oldStreetName'] = $streetList[$ecr['oldStreet']];
  58. }
  59. if (\StrUtil::isNotEmpAndNull($ecr['newStreet'])) {
  60. $ecr['newStreetName'] = $streetList[$ecr['newStreet']];
  61. }
  62. }
  63. $check_info = ApiData::where('action', '=', 'register_check')->where('uid', '=', $ep['idCard'])->where('status', '=', 1)->find();
  64. $force = intval($this->request['force'], 0);
  65. if ($force || !$check_info || !$check_info['status']) {
  66. $rsapi = new RsApi();
  67. switch ($ep['special']) {
  68. case 0:
  69. $ecr['rs'] = $rsapi->I040102($ecr['newIdCard']);
  70. break;
  71. case 1:
  72. $ecr['rs'] = $rsapi->I080101($ep['newIdCard']);
  73. break;
  74. case 2:
  75. $ecr['rs'] = $rsapi->I030501($ep['newName'], $ep['newIdCard']);
  76. break;
  77. }
  78. $api_model_data = [
  79. 'uid' => $ecr['newIdCard'],
  80. 'action' => 'change_record_check',
  81. 'content' => serialize($ecr['rs']),
  82. 'createTime' => time()
  83. ];
  84. ApiData::create($api_model_data);
  85. } else {
  86. $ecr['rs'] = unserialize($check_info['content']);
  87. }
  88. switch ($ecr['checkState']) {
  89. case 1:
  90. $ecr['checkStateName'] = '保存未提交';
  91. break;
  92. case 2:
  93. $ecr['checkStateName'] = '待审核';
  94. break;
  95. case 3:
  96. $ecr['checkStateName'] = '审核驳回';
  97. break;
  98. case 4:
  99. $ecr['checkStateName'] = '审核通过';
  100. break;
  101. case 5:
  102. $ecr['checkStateName'] = '重新提交';
  103. break;
  104. case 6:
  105. $ecr['checkStateName'] = '初审驳回';
  106. break;
  107. case 7:
  108. $ecr['checkStateName'] = '初审通过';
  109. break;
  110. default:
  111. $ecr['checkStateName'] = '';
  112. break;
  113. }
  114. /* $where = [];
  115. $where[] = ['tcf.mainId', '=', $id];
  116. $files = TalentCommonFile::alias("tcf")->field("tcf.*,cft.api")->leftJoin("new_currency_filetype cft", "cft.id=tcf.typeId")->where($where)->select();
  117. $_files = [];
  118. foreach ($files as $k => $v) {
  119. $extension = pathinfo($v["url"])["extension"];
  120. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  121. $v["is_img"] = 1;
  122. } else {
  123. $v["is_img"] = 0;
  124. }
  125. $v['url'] = getStoragePath($v['url']);
  126. $_files[$v["api"]][] = $v;
  127. } */
  128. $time = $this->compatible_time;
  129. //营业执照
  130. if (!$ecr["oldImgurl"]) {
  131. $ecr["oldImgurl"] = $ep["imgurl"];
  132. }
  133. if ($ecr["oldImgurl"]) {
  134. $pathinfo = pathinfo($ecr["oldImgurl"]);
  135. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  136. $ecr["oldImgurl_is_img"] = 1;
  137. }
  138. }
  139. if (!$ecr["newImgurl"]) {
  140. //兼容旧filetype
  141. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  142. $where = [];
  143. $where[] = ["mainId", "=", $id];
  144. $where[] = ["api", "=", "businessLicense"];
  145. $where[] = ["active", "=", 1];
  146. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
  147. if ($_uploadFile) {
  148. $ecr["newImgurl"] = $_uploadFile["url"];
  149. } else {
  150. $ecr["newImgurl"] = $ep["imgurl"];
  151. }
  152. }
  153. }
  154. if ($ecr["newImgurl"]) {
  155. $pathinfo = pathinfo($ecr["newImgurl"]);
  156. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  157. $ecr["newImgurl_is_img"] = 1;
  158. }
  159. }
  160. //备案表
  161. if (!$ecr["oldBeian"]) {
  162. $ecr["oldBeian"] = $ep["beian"];
  163. }
  164. if ($ecr["oldBeian"]) {
  165. $pathinfo = pathinfo($ecr["oldBeian"]);
  166. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  167. $ecr["oldBeian_is_img"] = 1;
  168. }
  169. }
  170. if (!$ecr["newBeian"]) {
  171. //兼容旧filetype
  172. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  173. $where = [];
  174. $where[] = ["mainId", "=", $id];
  175. $where[] = ["api", "=", "businessBeian"];
  176. $where[] = ["active", "=", 1];
  177. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
  178. if ($_uploadFile) {
  179. $ecr["newBeian"] = $_uploadFile["url"];
  180. } else {
  181. $ecr["newBeian"] = $ep["beian"];
  182. }
  183. }
  184. }
  185. if ($ecr["newBeian"]) {
  186. $pathinfo = pathinfo($ecr["newBeian"]);
  187. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  188. $ecr["newBeian_is_img"] = 1;
  189. }
  190. }
  191. //行业领域
  192. if (!$ecr["oldDomainImg"]) {
  193. $ecr["oldDomainImg"] = $ep["domainImg"];
  194. }
  195. if ($ecr["oldDomainImg"]) {
  196. $pathinfo = pathinfo($ecr["oldDomainImg"]);
  197. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  198. $ecr["oldDomainImg_is_img"] = 1;
  199. }
  200. }
  201. if (!$ecr["newDomainImg"]) {
  202. //兼容旧filetype
  203. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  204. $where = [];
  205. $where[] = ["mainId", "=", $id];
  206. $where[] = ["api", "=", "businessDomain"];
  207. $where[] = ["active", "=", 1];
  208. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
  209. if ($_uploadFile) {
  210. $ecr["newDomainImg"] = $_uploadFile["url"];
  211. } else {
  212. $ecr["newDomainImg"] = $ep["domainImg"];
  213. }
  214. }
  215. }
  216. if ($ecr["newDomainImg"]) {
  217. $pathinfo = pathinfo($ecr["newDomainImg"]);
  218. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  219. $ecr["newDomainImg_is_img"] = 1;
  220. }
  221. }
  222. //个别企业类型需要上传附件
  223. if ($ecr["oldTypeImg"]) {
  224. $pathinfo = pathinfo($ecr["oldTypeImg"]);
  225. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  226. $ecr["oldTypeImg_is_img"] = 1;
  227. }
  228. }
  229. if ($ecr["newTypeImg"]) {
  230. $pathinfo = pathinfo($ecr["newTypeImg"]);
  231. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  232. $ecr["newTypeImg_is_img"] = 1;
  233. }
  234. }
  235. //开户许可证
  236. if (!$ecr["oldBankImg"]) {
  237. $ecr["oldBankImg"] = $ep["bankImg"];
  238. }
  239. if ($ecr["oldBankImg"]) {
  240. $pathinfo = pathinfo($ecr["oldBankImg"]);
  241. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  242. $ecr["oldBankImg_is_img"] = 1;
  243. }
  244. }
  245. if (!$ecr["newBankImg"]) {
  246. //兼容旧filetype
  247. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  248. $where = [];
  249. $where[] = ["mainId", "=", $id];
  250. $where[] = ["api", "=", "businessBank"];
  251. $where[] = ["active", "=", 1];
  252. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
  253. if ($_uploadFile) {
  254. $ecr["newBankImg"] = $_uploadFile["url"];
  255. } else {
  256. $ecr["newBankImg"] = $ep["bankImg"];
  257. }
  258. }
  259. }
  260. if ($ecr["newBankImg"]) {
  261. $pathinfo = pathinfo($ecr["newBankImg"]);
  262. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  263. $ecr["newBankImg_is_img"] = 1;
  264. }
  265. }
  266. $ecr["special"] = $ep->special;
  267. switch ($ep->special) {
  268. case 0:
  269. if (\StrUtil::isNotEmpAndNull($ecr['oldAgencyType']) || \StrUtil::isNotEmpAndNull($ecr['newAgencyType'])) {
  270. $agencyTypeList = DictApi::selectByParentCode("agency_type");
  271. if (\StrUtil::isNotEmpAndNull($ecr['oldAgencyType'])) {
  272. $ecr['oldAgencyTypeName'] = $agencyTypeList[$ecr['oldAgencyType']];
  273. }
  274. if (\StrUtil::isNotEmpAndNull($ecr['newAgencyType'])) {
  275. $ecr['newAgencyTypeName'] = $agencyTypeList[$ecr['newAgencyType']];
  276. }
  277. }
  278. if (\StrUtil::isNotEmpAndNull($ecr['oldEnterpriseTag']) || \StrUtil::isNotEmpAndNull($ecr['newEnterpriseTag'])) {
  279. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  280. if (\StrUtil::isNotEmpAndNull($ecr['oldEnterpriseTag'])) {
  281. $ecr['oldEnterpriseTagName'] = $talentTypeList[$ecr['oldEnterpriseTag']];
  282. }
  283. if (\StrUtil::isNotEmpAndNull($ecr['newEnterpriseTag'])) {
  284. $ecr['newEnterpriseTagName'] = $talentTypeList[$ecr['newEnterpriseTag']];
  285. }
  286. }
  287. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldNew']) || \StrUtil::isNotEmpAndNull($ecr['newIndustryFieldNew'])) {
  288. $industryFieldNewList = DictApi::selectByParentCode("industry_field");
  289. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldNew'])) {
  290. $ecr['oldIndustryFieldNewName'] = $industryFieldNewList[$ecr['oldIndustryFieldNew']];
  291. }
  292. if (\StrUtil::isNotEmpAndNull($ecr['newIndustryFieldNew'])) {
  293. $ecr['newIndustryFieldNewName'] = $industryFieldNewList[$ecr['newIndustryFieldNew']];
  294. }
  295. }
  296. if (\StrUtil::isNotEmpAndNull($ecr['oldIndustryFieldOld'])) {
  297. $industry = DictApi::findDictByCode($ecr['oldIndustryFieldOld']);
  298. $ecr['oldIndustryFieldOldName'] = $industry['name'];
  299. }
  300. if (\StrUtil::isNotEmpAndNull($ecr['newIndustryFieldOld'])) {
  301. $industry = DictApi::findDictByCode($ecr['newIndustryFieldOld']);
  302. $ecr['newIndustryFieldOldName'] = $industry['name'];
  303. }
  304. if (\StrUtil::isNotEmpAndNull($ecr['oldEnterpriseType'])) {
  305. $industry = DictApi::findDictByCode($ecr['oldEnterpriseType']);
  306. $ecr['oldEnterpriseTypeName'] = $industry['name'];
  307. }
  308. if (\StrUtil::isNotEmpAndNull($ecr['newEnterpriseType'])) {
  309. $industry = DictApi::findDictByCode($ecr['newEnterpriseType']);
  310. $ecr['newEnterpriseTypeName'] = $industry['name'];
  311. }
  312. break;
  313. case 1:
  314. if (\StrUtil::isNotEmpAndNull($ecr['oldInstitutionTag']) || \StrUtil::isNotEmpAndNull($ecr['newInstitutionTag'])) {
  315. $tagList = DictApi::selectByParentCode("institution_tag");
  316. if (\StrUtil::isNotEmpAndNull($ecr['oldInstitutionTag'])) {
  317. $ecr['oldInstitutionTagName'] = $tagList[$ecr['oldInstitutionTag']];
  318. }
  319. if (\StrUtil::isNotEmpAndNull($ecr['newInstitutionTag'])) {
  320. $ecr['newInstitutionTagName'] = $tagList[$ecr['newInstitutionTag']];
  321. }
  322. }
  323. break;
  324. case 3:
  325. if (\StrUtil::isNotEmpAndNull($ecr['oldOrganizationTag']) || \StrUtil::isNotEmpAndNull($ecr['newOrganizationTag'])) {
  326. $tagList = DictApi::selectByParentCode("organization_tag");
  327. if (\StrUtil::isNotEmpAndNull($ecr['oldOrganizationTag'])) {
  328. $ecr['oldOrganizationTagName'] = $tagList[$ecr['oldOrganizationTag']];
  329. }
  330. if (\StrUtil::isNotEmpAndNull($ecr['newOrganizationTag'])) {
  331. $ecr['newOrganizationTagName'] = $tagList[$ecr['newOrganizationTag']];
  332. }
  333. }
  334. break;
  335. default:
  336. break;
  337. }
  338. $template = "";
  339. switch ($this->user["type"]) {
  340. case CommonConst::ENTERPRISE_WJ:
  341. $template = "/enterprise_change_record/hospital/goto_enterprise_change_detail_page";
  342. break;
  343. case CommonConst::ENTERPRISE_GJ:
  344. $template = "/enterprise_change_record/school/goto_enterprise_change_detail_page";
  345. break;
  346. }
  347. return view($template, ['ecr' => $ecr]);
  348. }
  349. public function gotoEnterpriseChangeExaminePage() {
  350. $id = trim($this->request['id']);
  351. if (!$id) {
  352. return json(["msg" => 'ID不能为空!']);
  353. }
  354. $ecr = EnterpriseApi::getOneRecord($id);
  355. $ep = EnterpriseApi::getOne($ecr['mainId']);
  356. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  357. if ($lastLog["active"] == 0 && $lastLog["category"] == "enterprise_change") {
  358. $ecr["checkState"] = $lastLog["state"];
  359. $ecr["checkMsg"] = $lastLog["description"];
  360. }
  361. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  362. $fields = $fieldsAndFiles["fields"];
  363. $files = $fieldsAndFiles["files"];
  364. $modify_fields = [];
  365. foreach ($fields as $key => $value) {
  366. $oldFieldName = "old" . $key;
  367. $newFieldName = "new" . $key;
  368. //if ($ecr[$oldFieldName] != $ecr[$newFieldName]) {
  369. $modify_fields[$newFieldName] = ["field" => $newFieldName, "name" => $value, "checked" => false];
  370. //}
  371. }
  372. if ($ecr["modify_fields"]) {
  373. $_modify_fields = explode(",", $ecr["modify_fields"]);
  374. foreach ($_modify_fields as $_field) {
  375. if ($modify_fields[$_field]) {
  376. $modify_fields[$_field]["checked"] = true;
  377. } else {
  378. $modify_fields[$_field] = ["field" => $_field, "name" => $fields[substr($_field, 3)], "checked" => true];
  379. }
  380. }
  381. }
  382. /* $currencyType = $ep["special"] == 0 ? "enterpriseChange" : "governmentChange";
  383. $where = [];
  384. $where[] = ["type", "=", $currencyType];
  385. $where[] = ["active", "=", 1];
  386. $fileTypes = \app\admin\model\CurrencyFiletype::where($where)->order("sn asc")->column("name", "id");
  387. $where = [];
  388. $where[] = ['mainId', '=', $id];
  389. $uploadTypeIds = TalentCommonFile::distinct(true)->field("typeId")->where($where)->column("typeId"); */
  390. $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
  391. "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
  392. $modify_files = [];
  393. foreach ($files as $key => $value) {
  394. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => false];
  395. }
  396. if ($ecr["modify_files"]) {
  397. $_modify_files = explode(",", $ecr["modify_files"]);
  398. foreach ($_modify_files as $_file) {
  399. if ($modify_files[$_file]) {
  400. $modify_files[$_file]["checked"] = true;
  401. } else {
  402. if (strtotime($ecr["createTime"]) < strtotime($this->compatible_time)) {
  403. //兼容旧的typeid
  404. $_file = $oldtypes[$_file];
  405. }
  406. $modify_files[$_file] = ["field" => $_file, "name" => $files[$_file], "checked" => true];
  407. }
  408. }
  409. }
  410. return view("", ['ecr' => $ecr, 'fields' => $modify_fields, "files" => $modify_files]);
  411. }
  412. public function doExamine() {
  413. $id = trim($this->request['id']);
  414. $doSubmit = $this->request["submit"] == 1 ? true : false;
  415. if (!$id) {
  416. return json(["msg" => 'ID不能为空!', 'code' => 500]);
  417. }
  418. $ecr = EnterpriseApi::getOneRecord($id);
  419. if (!$ecr) {
  420. return json(["msg" => '原始数据不存在!', 'code' => 500]);
  421. }
  422. $oriCheckState = $ecr["checkState"];
  423. if ($oriCheckState == 7 && !EnterpriseApi::chkUserInSuperusers()) {
  424. return json(["msg" => "已经流转到审核,不在审核范围内"]);
  425. }
  426. $checkState = trim($this->request['checkState']);
  427. $files = $this->request["files"];
  428. $fields = $this->request["fields"];
  429. if ($checkState == null || ($checkState != 4 && $checkState != 3)) {
  430. return json(["msg" => '请选择审核状态!', 'code' => 500]);
  431. }
  432. $checkMsg = trim($this->request['checkMsg']);
  433. //如果审核状态为 审核驳回, 需要填写审核意见
  434. if ($checkState == 3 && \StrUtil::isEmpOrNull($checkMsg)) {
  435. return json(["msg" => '审核驳回时,需要填写审核意见!', 'code' => 500]);
  436. }
  437. if ($checkState == 3 && !$files && !$fields) {
  438. return json(["msg" => '审核驳回时,需要选择可修改的字段或者附件!', 'code' => 500]);
  439. }
  440. if (\StrUtil::isNotEmpAndNull($checkMsg) && strlen($checkMsg) > 1000) {
  441. return json(["msg" => '审核意见最多1000个字符!', 'code' => 500]);
  442. }
  443. if ($ecr['checkState'] != 2 && $ecr['checkState'] != 5 && $ecr['checkState'] != 7) {
  444. return json(["msg" => '不在审核范围内!', 'code' => 500]);
  445. }
  446. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  447. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  448. if ($checkState == 4) {
  449. $fields = null;
  450. $files = null;
  451. }
  452. if ($oriCheckState == 7 || $ecr["type"] == 2) {
  453. $stateChangeStr = $checkState == 4 ? "<span class='label label-info'>审核通过</span>" : "<span class='label label-danger'>审核驳回</span>";
  454. $newCheckState = $checkState;
  455. } else {
  456. $stateChangeStr = $checkState == 4 ? "<span class='label label-info'>初审通过</span>" : "<span class='label label-danger'>初审驳回</span>";
  457. $newCheckState = $checkState == 4 ? 7 : 6;
  458. }
  459. if ($doSubmit) {
  460. //如果为审核驳回,更新表中的审核状态 和 审核意见, 直接返回结果
  461. if ($checkState == 3) {
  462. $ecr->checkState = $newCheckState;
  463. $ecr->checkMsg = $checkMsg;
  464. $ecr->updateUser = session('user')['uid'];
  465. $ecr->updateTime = date("Y-m-d H:i:s");
  466. $ecr->modify_fields = $fields ? implode(",", $fields) : null;
  467. $ecr->modify_files = $files ? implode(",", $files) : null;
  468. $ecr->save();
  469. //发送短信
  470. $record_data = [
  471. 'id' => getStringId(),
  472. 'bizId' => getStringId(),
  473. 'userId' => $ecr['mainId'],
  474. 'type' => 2,
  475. 'smsType' => 2,
  476. 'name' => $ecr['newName'],
  477. 'phone' => $ecr['newAgentPhone'],
  478. 'templateCode' => "【晋江市人才服务平台】您好!您提交申请的晋江市现代产业体系人才机构用户/机构信息变更因信息填写错误或材料不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。。",
  479. 'params' => '机构信息变更',
  480. 'state' => 1,
  481. 'sendingDate' => date("Y-m-d H:i:s", time()),
  482. 'createTime' => date("Y-m-d H:i:s", time())
  483. ];
  484. $smsapi = new ChuanglanSmsApi();
  485. $result = $smsapi->sendSMS($ecr['newAgentPhone'], $record_data['templateCode']);
  486. MessageRecord::create($record_data);
  487. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  488. TalentChecklog::update([
  489. 'id' => $lastLog["id"],
  490. 'active' => 1,
  491. 'state' => $newCheckState,
  492. 'stateChange' => $stateChangeStr,
  493. 'description' => $checkMsg,
  494. 'updateTime' => date("Y-m-d H:i:s", time()),
  495. 'updateUser' => session('user')['name'] . "({$companyName})"
  496. ]);
  497. } else {
  498. TalentChecklog::create([
  499. 'id' => getStringId(),
  500. 'category' => 'enterprise_change',
  501. 'mainId' => $ecr['id'],
  502. 'type' => 10,
  503. 'typeField' => null,
  504. 'active' => 1,
  505. 'state' => $newCheckState,
  506. 'step' => 101,
  507. 'stateChange' => $stateChangeStr,
  508. 'description' => $checkMsg,
  509. 'createTime' => date("Y-m-d H:i:s", time()),
  510. 'createUser' => session('user')['name'] . "({$companyName})"
  511. ]);
  512. }
  513. return json(["msg" => '操作成功!', "code" => 200]);
  514. } else {
  515. $ecr->checkState = $newCheckState;
  516. $ecr->checkMsg = $checkMsg;
  517. $ecr->updateUser = session('user')['uid'];
  518. $ecr->updateTime = date("Y-m-d H:i:s");
  519. $ecr->modify_fields = null;
  520. $ecr->modify_files = null;
  521. $ecr->save();
  522. if ($newCheckState == 4) {
  523. $ep = EnterpriseApi::getOne($ecr['mainId']);
  524. $ep->name = $ecr['newName'];
  525. $ep->idCard = $ecr['newIdCard'];
  526. $ep->medicalCommunityId = $ecr['newMedicalCommunityId'];
  527. $ep->isGeneral = $ecr['newIsGeneral'];
  528. $ep->agencyType = $ecr['newAgencyType'];
  529. $ep->enterpriseTag = $ecr['newEnterpriseTag'];
  530. $ep->organizationTag = $ecr['newOrganizationTag'];
  531. $ep->institutionTag = $ecr['newInstitutionTag'];
  532. $ep->street = $ecr['newStreet'];
  533. $ep->province = $ecr['newProvince'];
  534. $ep->city = $ecr['newCity'];
  535. $ep->county = $ecr['newCounty'];
  536. $ep->provinceName = $ecr['newProvinceName'];
  537. $ep->cityName = $ecr['newCityName'];
  538. $ep->countyName = $ecr['newCountyName'];
  539. $ep->address = $ecr['newAddress'];
  540. $ep->legal = $ecr['newLegal'];
  541. $ep->ephone = $ecr['newEphone'];
  542. $ep->agentName = $ecr['newAgentName'];
  543. $ep->agentEmail = $ecr['newAgentEmail'];
  544. $ep->agentPhone = $ecr['newAgentPhone'];
  545. $ep->industryFieldNew = $ecr['newIndustryFieldNew'];
  546. $ep->industryFieldOld = $ecr['newIndustryFieldOld'];
  547. $ep->enterpriseType = $ecr['newEnterpriseType'];
  548. $ep->bankCard = $ecr['newBankCard'];
  549. $ep->bankNetwork = $ecr['newBankNetwork'];
  550. $ep->bank = $ecr['newBank'];
  551. $ep->updateUser = session('user')['uid'];
  552. $ep->updateTime = date("Y-m-d H:i:s");
  553. $ep->imgurl = $ecr['newImgurl'] ?: $ep->imgurl;
  554. $ep->bankImg = $ecr['newBankImg'] ?: $ep->bankImg;
  555. $ep->domainImg = $ecr['newDomainImg'] ?: $ep->domainImg;
  556. $ep->typeImg = $ecr['newTypeImg'];
  557. $ep->beian = $ecr['newBeian'] ?: $ep->beian;
  558. //同步人才库与津贴库 TODO
  559. $ep->save();
  560. //发送短信
  561. $record_data = [
  562. 'id' => getStringId(),
  563. 'bizId' => getStringId(),
  564. 'userId' => $ecr['mainId'],
  565. 'type' => 2,
  566. 'smsType' => 2,
  567. 'name' => $ecr['newName'],
  568. 'phone' => $ecr['newAgentPhone'],
  569. 'templateCode' => "【晋江市人才服务平台】您好!您提交申请的现代产业体系人才{$checkMsg}已审核通过,可登录申报系统做相关事宜申报。",
  570. 'params' => '机构信息变更',
  571. 'state' => 1,
  572. 'sendingDate' => date("Y-m-d H:i:s", time()),
  573. 'createTime' => date("Y-m-d H:i:s", time())
  574. ];
  575. $smsapi = new ChuanglanSmsApi();
  576. $result = $smsapi->sendSMS($ecr['newAgentPhone'], $record_data['templateCode']);
  577. MessageRecord::create($record_data);
  578. }
  579. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  580. TalentChecklog::update([
  581. 'id' => $lastLog["id"],
  582. 'active' => 1,
  583. 'state' => $newCheckState,
  584. 'stateChange' => $stateChangeStr,
  585. 'description' => $checkMsg,
  586. 'updateTime' => date("Y-m-d H:i:s", time()),
  587. 'updateUser' => session('user')['name'] . "({$companyName})"
  588. ]);
  589. } else {
  590. TalentChecklog::create([
  591. 'id' => getStringId(),
  592. 'category' => 'enterprise_change',
  593. 'mainId' => $ecr['id'],
  594. 'type' => 10,
  595. 'typeField' => null,
  596. 'active' => 1,
  597. 'state' => $newCheckState,
  598. 'step' => 101,
  599. 'stateChange' => $stateChangeStr,
  600. 'description' => $checkMsg,
  601. 'createTime' => date("Y-m-d H:i:s", time()),
  602. 'createUser' => session('user')['name'] . "({$companyName})"
  603. ]);
  604. }
  605. return json(["msg" => '操作成功!', "code" => 200]);
  606. }
  607. } else {
  608. $ecrUpdData["id"] = $ecr['id'];
  609. $ecrUpdData["updateUser"] = session('user')['uid'];
  610. $ecrUpdData["updateTime"] = date("Y-m-d H:i:s");
  611. $ecrUpdData["modify_fields"] = $fields ? implode(",", $fields) : null;
  612. $ecrUpdData["modify_files"] = $files ? implode(",", $files) : null;
  613. \app\enterprise\model\EnterpriseRecord::update($ecrUpdData);
  614. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  615. TalentChecklog::update([
  616. 'id' => $lastLog["id"],
  617. 'state' => $newCheckState,
  618. 'stateChange' => $stateChangeStr,
  619. 'description' => $checkMsg,
  620. 'updateTime' => date("Y-m-d H:i:s", time()),
  621. 'updateUser' => session('user')['name'] . "({$companyName})"
  622. ]);
  623. } else {
  624. TalentChecklog::create([
  625. 'id' => getStringId(),
  626. 'category' => 'enterprise_change',
  627. 'mainId' => $ecr['id'],
  628. 'type' => 10,
  629. 'typeField' => null,
  630. 'active' => 0,
  631. 'state' => $newCheckState,
  632. 'step' => 101,
  633. 'stateChange' => $stateChangeStr,
  634. 'description' => $checkMsg,
  635. 'createTime' => date("Y-m-d H:i:s", time()),
  636. 'createUser' => session('user')['name'] . "({$companyName})"
  637. ]);
  638. }
  639. return json(["msg" => '保存成功!', "code" => 200]);
  640. }
  641. }
  642. public function export() {
  643. $columns = ["账号类型",
  644. "原单位名称", "原社会信用代码", "原法人代表", "原所属街道", "原单位地址", "原单位电话", "原单位银行账号", "原单位开户银行", "原单位开户银行网点", "原机构(单位)标签", "原机构类型", "原产业领域", "原行业领域", "原企业标签", "原企业类型", "原经办人", "原经办人电话", "原经办人邮箱",
  645. "新单位名称", "新社会信用代码", "新法人代表", "新所属街道", "新单位地址", "新单位电话", "新单位银行账号", "新单位开户银行", "新单位开户银行网点", "新机构(单位)标签", "新机构类型", "新产业领域", "新行业领域", "新企业标签", "新企业类型", "新经办人", "新经办人电话", "新经办人邮箱",
  646. "申报时间", "审核状态", "备注"];
  647. $rows = EnterpriseApi::getExportList($this->request);
  648. $exportDatas = [];
  649. foreach ($rows as $row) {
  650. if ($row)
  651. $typeName = $exportDatas[] = [
  652. $row["typeName"],
  653. $row["oldName"], $row["oldIdCard"], $row["oldLegal"], $row["oldStreetName"], $row["oldAddress"], $row["oldEphone"], $row["oldBankCard"], $row["oldBank"], $row["oldBankNetwork"], $row["oldAgencyTagName"], $row["oldAgencyTypeName"], $row["oldIndustryFieldNewName"], $row["oldIndustryFieldOldName"], $row["oldEnterpriseTagName"], $row["oldEnterpriseTypeName"], $row["oldAgentName"], $row["oldAgentPhone"], $row["oldAgentEmail"],
  654. $row["newName"], $row["newIdCard"], $row["newLegal"], $row["newStreetName"], $row["newAddress"], $row["newEphone"], $row["newBankCard"], $row["newBank"], $row["newBankNetwork"], $row["newAgencyTagName"], $row["newAgencyTypeName"], $row["newIndustryFieldNewName"], $row["newIndustryFieldOldName"], $row["newEnterpriseTagName"], $row["newEnterpriseTypeName"], $row["newAgentName"], $row["newAgentPhone"], $row["newAgentEmail"],
  655. $row["createTime"], $row["checkStateName"], $row["checkMsg"]
  656. ];
  657. }
  658. if ($rows) {
  659. export($columns, $exportDatas, "机构信息变更列表");
  660. exit();
  661. }
  662. return json(["msg" => "没有可以导出的内容"]);
  663. }
  664. public function findFieldsAndFiles() {
  665. $id = trim($this->request['id']);
  666. $ecr = EnterpriseApi::getOneRecord($id);
  667. $ep = EnterpriseApi::getOne($ecr['mainId']);
  668. if (!$ecr || !$ep || !$id) {
  669. return json(["msg" => '没有对应的企业变更信息!']);
  670. }
  671. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  672. $fields = $fieldsAndFiles["fields"];
  673. $files = $fieldsAndFiles["files"];
  674. $modify_fields = [];
  675. foreach ($fields as $key => $value) {
  676. $oldFieldName = "old" . $key;
  677. $newFieldName = "new" . $key;
  678. //if ($ecr[$oldFieldName] != $ecr[$newFieldName]) {
  679. $modify_fields[$newFieldName] = ["field" => $newFieldName, "name" => $value, "checked" => false];
  680. //}
  681. }
  682. if ($ecr["modify_fields"]) {
  683. $_modify_fields = explode(",", $ecr["modify_fields"]);
  684. foreach ($_modify_fields as $_field) {
  685. if ($modify_fields[$_field]) {
  686. $modify_fields[$_field]["checked"] = true;
  687. } else {
  688. $modify_fields[$_field] = ["field" => $_field, "name" => $fields[substr($_field, 3)], "checked" => true];
  689. }
  690. }
  691. }
  692. $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
  693. "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
  694. $modify_files = [];
  695. foreach ($files as $key => $value) {
  696. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => false];
  697. }
  698. if ($ecr["modify_files"]) {
  699. $_modify_files = explode(",", $ecr["modify_files"]);
  700. foreach ($_modify_files as $_file) {
  701. if ($modify_files[$_file]) {
  702. $modify_files[$_file]["checked"] = true;
  703. } else {
  704. if (strtotime($ecr["createTime"]) < strtotime($this->compatible_time)) {
  705. //兼容旧的typeid
  706. $_file = $oldtypes[$_file];
  707. }
  708. $modify_files[$_file] = ["field" => $_file, "name" => $files[$_file], "checked" => true];
  709. }
  710. }
  711. }
  712. return json(["code" => 200, "files" => $modify_files, "fields" => $modify_fields]);
  713. }
  714. public function updateFieldsAndFiles() {
  715. try {
  716. $params = $this->request->param();
  717. $id = $params["id"];
  718. $ecr = EnterpriseApi::getOneRecord($id);
  719. if (!$ecr) {
  720. throw new \think\Exception("没有对应的企业变更信息");
  721. }
  722. if (!in_array($ecr["checkState"], [3, 6])) {
  723. throw new \think\Exception("不是驳回状态,不能修改驳回字段!");
  724. }
  725. if ($ecr["checkState"] == 3 && !EnterpriseApi::chkUserInSuperusers()) {
  726. throw new \think\Exception("已经流转到审核,不在审核范围内");
  727. }
  728. $fields = array_filter(explode(",", $params["fields"]));
  729. $files = array_filter(explode(",", $params["files"]));
  730. if (!$fields && !$files)
  731. throw new \think\Exception("请选择要驳回的字段或附件!");
  732. $data["id"] = $id;
  733. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  734. $data["modify_files"] = $files ? implode(",", $files) : null;
  735. $data["updateTime"] = date("Y-m-d H:i:s");
  736. $data["updateUser"] = session("user")["uid"];
  737. if (\app\enterprise\model\EnterpriseRecord::update($data)) {
  738. return json(["code" => 200, "msg" => "修改成功!"]);
  739. }
  740. } catch (\think\Exception $e) {
  741. return json(["msg" => $e->getMessage()]);
  742. }
  743. }
  744. private function getFieldAndFilesBySpecialAndType($special, $type) {
  745. if ($special == 0) {
  746. if ($type == CommonConst::ENTERPRISE_JC) {
  747. $fields = ["Name" => "企业名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "企业地址", "Street" => "所属街道", "Ephone" => "企业电话", "BankCard" => "企业银行账号", "Bank" => "企业开户银行", "BankNetwork" => "企业开户银行网点",
  748. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  749. $files = ["newImgurl" => "企业营业执照", "newBankImg" => "开户许可证/基本存款账户信息", "newBeian" => "人才联络员信息备案表"];
  750. } else if ($type == CommonConst::ENTERPRISE_WJ) {
  751. $fields = ["Name" => "医院名称", "IdCard" => "登记号", "Legal" => "法人代表", "MedicalCommunityId" => "医共体", "IsGeneral" => "是否总院", "Ephone" => "医院电话", "Province" => "地址省", "City" => "地址市", "County" => "地址县\区", "Address" => "企业地址",
  752. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  753. $files = ["newImgurl" => "医疗机构执业许可证", "newBeian" => "人才联络员信息备案表"];
  754. } else if ($type == CommonConst::ENTERPRISE_GJ) {
  755. $fields = ["Name" => "学校名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Ephone" => "学校电话", "Province" => "地址省", "City" => "地址市", "County" => "地址县\区", "Address" => "学校地址",
  756. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  757. $files = ["newImgurl" => "办学许可证、法人证书或登记证书", "newBeian" => "人才联络员信息备案表"];
  758. } else {
  759. $fields = ["Name" => "企业名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "企业地址", "Street" => "所属街道", "Ephone" => "企业电话", "BankCard" => "企业银行账号", "Bank" => "企业开户银行", "BankNetwork" => "企业开户银行网点",
  760. "AgencyType" => "机构类型", "IndustryFieldNew" => "产业领域", "IndustryFieldOld" => "行业领域", "EnterpriseTag" => "企业标签", "EnterpriseType" => "企业类型",
  761. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  762. $files = ["newImgurl" => "企业营业执照", "newBankImg" => "开户许可证/基本存款账户信息", "newDomainImg" => "行业领域佐证材料", "newBeian" => "人才联络员信息备案表", "newTypeImg" => "规上、高新技术、专精特新企业上传材料"];
  763. }
  764. } else {
  765. $fields = ["Name" => "单位名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "单位地址", "Street" => "所属街道", "Ephone" => "单位电话", "BankCard" => "单位银行账号", "Bank" => "单位开户银行", "BankNetwork" => "单位开户银行网点",
  766. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  767. if ($special == 1) {
  768. $fields["InstitutionTag"] = "单位标签";
  769. }
  770. if ($special == 3) {
  771. $fields["OrganizationTag"] = "机构标签";
  772. }
  773. $files = ["newImgurl" => "法人证或批文", "newBankImg" => "开户许可证/基本存款账户信息", "newBeian" => "人才联络员备案表"];
  774. }
  775. return ["fields" => $fields, "files" => $files];
  776. }
  777. }