EnterpriseChangeRecord.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  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. $medicalCommunityList = \app\common\api\Nhc::getMedicalCommunityMap();
  342. $template = "/enterprise_change_record/hospital/goto_enterprise_change_detail_page";
  343. $ecr["newMedicalCommunityName"] = $medicalCommunityList[$ecr["newMedicalCommunityId"]];
  344. $ecr["oldMedicalCommunityName"] = $medicalCommunityList[$ecr["oldMedicalCommunityId"]];
  345. break;
  346. case CommonConst::ENTERPRISE_GJ:
  347. $template = "/enterprise_change_record/school/goto_enterprise_change_detail_page";
  348. break;
  349. }
  350. return view($template, ['ecr' => $ecr]);
  351. }
  352. public function gotoEnterpriseChangeExaminePage() {
  353. $id = trim($this->request['id']);
  354. if (!$id) {
  355. return json(["msg" => 'ID不能为空!']);
  356. }
  357. $ecr = EnterpriseApi::getOneRecord($id);
  358. $ep = EnterpriseApi::getOne($ecr['mainId']);
  359. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  360. if ($lastLog["active"] == 0 && $lastLog["category"] == "enterprise_change") {
  361. $ecr["checkState"] = $lastLog["state"];
  362. $ecr["checkMsg"] = $lastLog["description"];
  363. }
  364. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  365. $fields = $fieldsAndFiles["fields"];
  366. $files = $fieldsAndFiles["files"];
  367. $modify_fields = [];
  368. foreach ($fields as $key => $value) {
  369. $oldFieldName = "old" . $key;
  370. $newFieldName = "new" . $key;
  371. //if ($ecr[$oldFieldName] != $ecr[$newFieldName]) {
  372. $modify_fields[$newFieldName] = ["field" => $newFieldName, "name" => $value, "checked" => false];
  373. //}
  374. }
  375. if ($ecr["modify_fields"]) {
  376. $_modify_fields = explode(",", $ecr["modify_fields"]);
  377. foreach ($_modify_fields as $_field) {
  378. if ($modify_fields[$_field]) {
  379. $modify_fields[$_field]["checked"] = true;
  380. } else {
  381. $modify_fields[$_field] = ["field" => $_field, "name" => $fields[substr($_field, 3)], "checked" => true];
  382. }
  383. }
  384. }
  385. /* $currencyType = $ep["special"] == 0 ? "enterpriseChange" : "governmentChange";
  386. $where = [];
  387. $where[] = ["type", "=", $currencyType];
  388. $where[] = ["active", "=", 1];
  389. $fileTypes = \app\admin\model\CurrencyFiletype::where($where)->order("sn asc")->column("name", "id");
  390. $where = [];
  391. $where[] = ['mainId', '=', $id];
  392. $uploadTypeIds = TalentCommonFile::distinct(true)->field("typeId")->where($where)->column("typeId"); */
  393. $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
  394. "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
  395. $modify_files = [];
  396. foreach ($files as $key => $value) {
  397. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => false];
  398. }
  399. if ($ecr["modify_files"]) {
  400. $_modify_files = explode(",", $ecr["modify_files"]);
  401. foreach ($_modify_files as $_file) {
  402. if ($modify_files[$_file]) {
  403. $modify_files[$_file]["checked"] = true;
  404. } else {
  405. if (strtotime($ecr["createTime"]) < strtotime($this->compatible_time)) {
  406. //兼容旧的typeid
  407. $_file = $oldtypes[$_file];
  408. }
  409. $modify_files[$_file] = ["field" => $_file, "name" => $files[$_file], "checked" => true];
  410. }
  411. }
  412. }
  413. return view("", ['ecr' => $ecr, 'fields' => $modify_fields, "files" => $modify_files]);
  414. }
  415. public function doExamine() {
  416. $id = trim($this->request['id']);
  417. $doSubmit = $this->request["submit"] == 1 ? true : false;
  418. if (!$id) {
  419. return json(["msg" => 'ID不能为空!', 'code' => 500]);
  420. }
  421. $ecr = EnterpriseApi::getOneRecord($id);
  422. if (!$ecr) {
  423. return json(["msg" => '原始数据不存在!', 'code' => 500]);
  424. }
  425. $oriCheckState = $ecr["checkState"];
  426. if ($oriCheckState == 7 && !EnterpriseApi::chkUserInSuperusers() && !in_array($this->user["type"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ])) {
  427. return json(["msg" => "已经流转到审核,不在审核范围内"]);
  428. }
  429. $checkState = trim($this->request['checkState']);
  430. $files = $this->request["files"];
  431. $fields = $this->request["fields"];
  432. if ($checkState == null || ($checkState != 4 && $checkState != 3)) {
  433. return json(["msg" => '请选择审核状态!', 'code' => 500]);
  434. }
  435. $checkMsg = trim($this->request['checkMsg']);
  436. //如果审核状态为 审核驳回, 需要填写审核意见
  437. if ($checkState == 3 && \StrUtil::isEmpOrNull($checkMsg)) {
  438. return json(["msg" => '审核驳回时,需要填写审核意见!', 'code' => 500]);
  439. }
  440. if ($checkState == 3 && !$files && !$fields) {
  441. return json(["msg" => '审核驳回时,需要选择可修改的字段或者附件!', 'code' => 500]);
  442. }
  443. if (\StrUtil::isNotEmpAndNull($checkMsg) && strlen($checkMsg) > 1000) {
  444. return json(["msg" => '审核意见最多1000个字符!', 'code' => 500]);
  445. }
  446. if ($ecr['checkState'] != 2 && $ecr['checkState'] != 5 && $ecr['checkState'] != 7) {
  447. return json(["msg" => '不在审核范围内!', 'code' => 500]);
  448. }
  449. $lastLog = \app\common\api\TalentLogApi::getLastLog($id, 10);
  450. $companyName = session('user')["companyName"] ?: session('user')["rolename"];
  451. if ($checkState == 4) {
  452. $fields = null;
  453. $files = null;
  454. }
  455. if ($oriCheckState == 7 || $ecr["type"] == 2) {
  456. $stateChangeStr = $checkState == 4 ? "<span class='label label-info'>审核通过</span>" : "<span class='label label-danger'>审核驳回</span>";
  457. $newCheckState = $checkState;
  458. } else {
  459. $stateChangeStr = $checkState == 4 ? "<span class='label label-info'>初审通过</span>" : "<span class='label label-danger'>初审驳回</span>";
  460. $newCheckState = $checkState == 4 ? 7 : 6;
  461. }
  462. if ($doSubmit) {
  463. //如果为审核驳回,更新表中的审核状态 和 审核意见, 直接返回结果
  464. if ($checkState == 3) {
  465. $ecr->checkState = $newCheckState;
  466. $ecr->checkMsg = $checkMsg;
  467. $ecr->updateUser = session('user')['uid'];
  468. $ecr->updateTime = date("Y-m-d H:i:s");
  469. $ecr->modify_fields = $fields ? implode(",", $fields) : null;
  470. $ecr->modify_files = $files ? implode(",", $files) : null;
  471. $ecr->save();
  472. //发送短信
  473. $record_data = [
  474. 'id' => getStringId(),
  475. 'bizId' => getStringId(),
  476. 'userId' => $ecr['mainId'],
  477. 'type' => 2,
  478. 'smsType' => 2,
  479. 'name' => $ecr['newName'],
  480. 'phone' => $ecr['newAgentPhone'],
  481. 'templateCode' => "【晋江市人才服务平台】您好!您提交申请的晋江市现代产业体系人才机构用户/机构信息变更因信息填写错误或材料不完整已被退回,请及时登录“晋江市人才综合服务申报平台”根据审核意见修改并重新提交。。",
  482. 'params' => '机构信息变更',
  483. 'state' => 1,
  484. 'sendingDate' => date("Y-m-d H:i:s", time()),
  485. 'createTime' => date("Y-m-d H:i:s", time())
  486. ];
  487. $smsapi = new ChuanglanSmsApi();
  488. $result = $smsapi->sendSMS($ecr['newAgentPhone'], $record_data['templateCode']);
  489. MessageRecord::create($record_data);
  490. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  491. TalentChecklog::update([
  492. 'id' => $lastLog["id"],
  493. 'active' => 1,
  494. 'state' => $newCheckState,
  495. 'stateChange' => $stateChangeStr,
  496. 'description' => $checkMsg,
  497. 'updateTime' => date("Y-m-d H:i:s", time()),
  498. 'updateUser' => session('user')['name'] . "({$companyName})"
  499. ]);
  500. } else {
  501. TalentChecklog::create([
  502. 'id' => getStringId(),
  503. 'category' => 'enterprise_change',
  504. 'mainId' => $ecr['id'],
  505. 'type' => 10,
  506. 'typeFileId' => null,
  507. 'active' => 1,
  508. 'state' => $newCheckState,
  509. 'step' => 101,
  510. 'stateChange' => $stateChangeStr,
  511. 'description' => $checkMsg,
  512. 'createTime' => date("Y-m-d H:i:s", time()),
  513. 'createUser' => session('user')['name'] . "({$companyName})"
  514. ]);
  515. }
  516. return json(["msg" => '操作成功!', "code" => 200]);
  517. } else {
  518. $ecr->checkState = $newCheckState;
  519. $ecr->checkMsg = $checkMsg;
  520. $ecr->updateUser = session('user')['uid'];
  521. $ecr->updateTime = date("Y-m-d H:i:s");
  522. $ecr->modify_fields = null;
  523. $ecr->modify_files = null;
  524. $ecr->save();
  525. if ($newCheckState == 4) {
  526. $ep = EnterpriseApi::getOne($ecr['mainId']);
  527. $ep->name = $ecr['newName'];
  528. $ep->idCard = $ecr['newIdCard'];
  529. $ep->medicalCommunityId = $ecr['newMedicalCommunityId'];
  530. $ep->isGeneral = $ecr['newIsGeneral'];
  531. $ep->agencyType = $ecr['newAgencyType'];
  532. $ep->enterpriseTag = $ecr['newEnterpriseTag'];
  533. $ep->organizationTag = $ecr['newOrganizationTag'];
  534. $ep->institutionTag = $ecr['newInstitutionTag'];
  535. $ep->street = $ecr['newStreet'];
  536. $ep->province = $ecr['newProvince'];
  537. $ep->city = $ecr['newCity'];
  538. $ep->county = $ecr['newCounty'];
  539. $ep->provinceName = $ecr['newProvinceName'];
  540. $ep->cityName = $ecr['newCityName'];
  541. $ep->countyName = $ecr['newCountyName'];
  542. $ep->address = $ecr['newAddress'];
  543. $ep->legal = $ecr['newLegal'];
  544. $ep->ephone = $ecr['newEphone'];
  545. $ep->agentName = $ecr['newAgentName'];
  546. $ep->agentEmail = $ecr['newAgentEmail'];
  547. $ep->agentPhone = $ecr['newAgentPhone'];
  548. $ep->industryFieldNew = $ecr['newIndustryFieldNew'];
  549. $ep->industryFieldOld = $ecr['newIndustryFieldOld'];
  550. $ep->enterpriseType = $ecr['newEnterpriseType'];
  551. $ep->bankCard = $ecr['newBankCard'];
  552. $ep->bankNetwork = $ecr['newBankNetwork'];
  553. $ep->bank = $ecr['newBank'];
  554. $ep->updateUser = session('user')['uid'];
  555. $ep->updateTime = date("Y-m-d H:i:s");
  556. $ep->imgurl = $ecr['newImgurl'] ?: $ep->imgurl;
  557. $ep->bankImg = $ecr['newBankImg'] ?: $ep->bankImg;
  558. $ep->domainImg = $ecr['newDomainImg'] ?: $ep->domainImg;
  559. $ep->typeImg = $ecr['newTypeImg'];
  560. $ep->beian = $ecr['newBeian'] ?: $ep->beian;
  561. //同步人才库与津贴库 TODO
  562. $ep->save();
  563. //发送短信
  564. $record_data = [
  565. 'id' => getStringId(),
  566. 'bizId' => getStringId(),
  567. 'userId' => $ecr['mainId'],
  568. 'type' => 2,
  569. 'smsType' => 2,
  570. 'name' => $ecr['newName'],
  571. 'phone' => $ecr['newAgentPhone'],
  572. 'templateCode' => "【晋江市人才服务平台】您好!您提交申请的现代产业体系人才{$checkMsg}已审核通过,可登录申报系统做相关事宜申报。",
  573. 'params' => '机构信息变更',
  574. 'state' => 1,
  575. 'sendingDate' => date("Y-m-d H:i:s", time()),
  576. 'createTime' => date("Y-m-d H:i:s", time())
  577. ];
  578. $smsapi = new ChuanglanSmsApi();
  579. $result = $smsapi->sendSMS($ecr['newAgentPhone'], $record_data['templateCode']);
  580. MessageRecord::create($record_data);
  581. }
  582. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  583. TalentChecklog::update([
  584. 'id' => $lastLog["id"],
  585. 'active' => 1,
  586. 'state' => $newCheckState,
  587. 'stateChange' => $stateChangeStr,
  588. 'description' => $checkMsg,
  589. 'updateTime' => date("Y-m-d H:i:s", time()),
  590. 'updateUser' => session('user')['name'] . "({$companyName})"
  591. ]);
  592. } else {
  593. TalentChecklog::create([
  594. 'id' => getStringId(),
  595. 'category' => 'enterprise_change',
  596. 'mainId' => $ecr['id'],
  597. 'type' => 10,
  598. 'typeFileId' => null,
  599. 'active' => 1,
  600. 'state' => $newCheckState,
  601. 'step' => 101,
  602. 'stateChange' => $stateChangeStr,
  603. 'description' => $checkMsg,
  604. 'createTime' => date("Y-m-d H:i:s", time()),
  605. 'createUser' => session('user')['name'] . "({$companyName})"
  606. ]);
  607. }
  608. return json(["msg" => '操作成功!', "code" => 200]);
  609. }
  610. } else {
  611. $ecrUpdData["id"] = $ecr['id'];
  612. $ecrUpdData["updateUser"] = session('user')['uid'];
  613. $ecrUpdData["updateTime"] = date("Y-m-d H:i:s");
  614. $ecrUpdData["modify_fields"] = $fields ? implode(",", $fields) : null;
  615. $ecrUpdData["modify_files"] = $files ? implode(",", $files) : null;
  616. \app\enterprise\model\EnterpriseRecord::update($ecrUpdData);
  617. if ($lastLog["active"] === 0 && $lastLog["category"] == "enterprise_change") {
  618. TalentChecklog::update([
  619. 'id' => $lastLog["id"],
  620. 'state' => $newCheckState,
  621. 'stateChange' => $stateChangeStr,
  622. 'description' => $checkMsg,
  623. 'updateTime' => date("Y-m-d H:i:s", time()),
  624. 'updateUser' => session('user')['name'] . "({$companyName})"
  625. ]);
  626. } else {
  627. TalentChecklog::create([
  628. 'id' => getStringId(),
  629. 'category' => 'enterprise_change',
  630. 'mainId' => $ecr['id'],
  631. 'type' => 10,
  632. 'typeFileId' => null,
  633. 'active' => 0,
  634. 'state' => $newCheckState,
  635. 'step' => 101,
  636. 'stateChange' => $stateChangeStr,
  637. 'description' => $checkMsg,
  638. 'createTime' => date("Y-m-d H:i:s", time()),
  639. 'createUser' => session('user')['name'] . "({$companyName})"
  640. ]);
  641. }
  642. return json(["msg" => '保存成功!', "code" => 200]);
  643. }
  644. }
  645. public function export() {
  646. $columns = ["账号类型",
  647. "原单位名称", "原社会信用代码", "原法人代表", "原所属街道", "原单位地址", "原单位电话", "原单位银行账号", "原单位开户银行", "原单位开户银行网点", "原机构(单位)标签", "原机构类型", "原产业领域", "原行业领域", "原企业标签", "原企业类型", "原经办人", "原经办人电话", "原经办人邮箱",
  648. "新单位名称", "新社会信用代码", "新法人代表", "新所属街道", "新单位地址", "新单位电话", "新单位银行账号", "新单位开户银行", "新单位开户银行网点", "新机构(单位)标签", "新机构类型", "新产业领域", "新行业领域", "新企业标签", "新企业类型", "新经办人", "新经办人电话", "新经办人邮箱",
  649. "申报时间", "审核状态", "备注"];
  650. $rows = EnterpriseApi::getExportList($this->request);
  651. $exportDatas = [];
  652. foreach ($rows as $row) {
  653. if ($row)
  654. $typeName = $exportDatas[] = [
  655. $row["typeName"],
  656. $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"],
  657. $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"],
  658. $row["createTime"], $row["checkStateName"], $row["checkMsg"]
  659. ];
  660. }
  661. if ($rows) {
  662. export($columns, $exportDatas, "机构信息变更列表");
  663. exit();
  664. }
  665. return json(["msg" => "没有可以导出的内容"]);
  666. }
  667. public function findFieldsAndFiles() {
  668. $id = trim($this->request['id']);
  669. $ecr = EnterpriseApi::getOneRecord($id);
  670. $ep = EnterpriseApi::getOne($ecr['mainId']);
  671. if (!$ecr || !$ep || !$id) {
  672. return json(["msg" => '没有对应的企业变更信息!']);
  673. }
  674. $fieldsAndFiles = $this->getFieldAndFilesBySpecialAndType($ep->special, $ep->type);
  675. $fields = $fieldsAndFiles["fields"];
  676. $files = $fieldsAndFiles["files"];
  677. $modify_fields = [];
  678. foreach ($fields as $key => $value) {
  679. $oldFieldName = "old" . $key;
  680. $newFieldName = "new" . $key;
  681. //if ($ecr[$oldFieldName] != $ecr[$newFieldName]) {
  682. $modify_fields[$newFieldName] = ["field" => $newFieldName, "name" => $value, "checked" => false];
  683. //}
  684. }
  685. if ($ecr["modify_fields"]) {
  686. $_modify_fields = explode(",", $ecr["modify_fields"]);
  687. foreach ($_modify_fields as $_field) {
  688. if ($modify_fields[$_field]) {
  689. $modify_fields[$_field]["checked"] = true;
  690. } else {
  691. $modify_fields[$_field] = ["field" => $_field, "name" => $fields[substr($_field, 3)], "checked" => true];
  692. }
  693. }
  694. }
  695. $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
  696. "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
  697. $modify_files = [];
  698. foreach ($files as $key => $value) {
  699. $modify_files[$key] = ["field" => $key, "name" => $value, "checked" => false];
  700. }
  701. if ($ecr["modify_files"]) {
  702. $_modify_files = explode(",", $ecr["modify_files"]);
  703. foreach ($_modify_files as $_file) {
  704. if ($modify_files[$_file]) {
  705. $modify_files[$_file]["checked"] = true;
  706. } else {
  707. if (strtotime($ecr["createTime"]) < strtotime($this->compatible_time)) {
  708. //兼容旧的typeid
  709. $_file = $oldtypes[$_file];
  710. }
  711. $modify_files[$_file] = ["field" => $_file, "name" => $files[$_file], "checked" => true];
  712. }
  713. }
  714. }
  715. return json(["code" => 200, "files" => $modify_files, "fields" => $modify_fields]);
  716. }
  717. public function updateFieldsAndFiles() {
  718. try {
  719. $params = $this->request->param();
  720. $id = $params["id"];
  721. $ecr = EnterpriseApi::getOneRecord($id);
  722. if (!$ecr) {
  723. throw new \think\Exception("没有对应的企业变更信息");
  724. }
  725. if (!in_array($ecr["checkState"], [3, 6])) {
  726. throw new \think\Exception("不是驳回状态,不能修改驳回字段!");
  727. }
  728. if ($ecr["checkState"] == 3 && !EnterpriseApi::chkUserInSuperusers() && !in_array($this->user["type"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ])) {
  729. throw new \think\Exception("已经流转到审核,不在审核范围内");
  730. }
  731. $fields = array_filter(explode(",", $params["fields"]));
  732. $files = array_filter(explode(",", $params["files"]));
  733. if (!$fields && !$files)
  734. throw new \think\Exception("请选择要驳回的字段或附件!");
  735. $data["id"] = $id;
  736. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  737. $data["modify_files"] = $files ? implode(",", $files) : null;
  738. $data["updateTime"] = date("Y-m-d H:i:s");
  739. $data["updateUser"] = session("user")["uid"];
  740. if (\app\enterprise\model\EnterpriseRecord::update($data)) {
  741. return json(["code" => 200, "msg" => "修改成功!"]);
  742. }
  743. } catch (\think\Exception $e) {
  744. return json(["msg" => $e->getMessage()]);
  745. }
  746. }
  747. private function getFieldAndFilesBySpecialAndType($special, $type) {
  748. if ($special == 0) {
  749. if ($type == CommonConst::ENTERPRISE_JC) {
  750. $fields = ["Name" => "企业名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "企业地址", "Street" => "所属街道", "Ephone" => "企业电话", "BankCard" => "企业银行账号", "Bank" => "企业开户银行", "BankNetwork" => "企业开户银行网点",
  751. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  752. $files = ["newImgurl" => "企业营业执照", "newBankImg" => "开户许可证/基本存款账户信息", "newBeian" => "人才联络员信息备案表"];
  753. } else if ($type == CommonConst::ENTERPRISE_WJ) {
  754. $fields = ["Name" => "医院名称", "IdCard" => "登记号", "Legal" => "法人代表", "MedicalCommunityId" => "医共体", "IsGeneral" => "是否总院", "Ephone" => "医院电话", "Province" => "地址省", "City" => "地址市", "County" => "地址县\区", "Address" => "医院地址",
  755. "BankCard" => "银行账号", "Bank" => "开户银行", "BankNetwork" => "开户银行网点",
  756. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  757. $files = ["newImgurl" => "医疗机构执业许可证", "newBankImg" => "开户许可证/基本存款账户信息", "newBeian" => "人才联络员信息备案表"];
  758. } else if ($type == CommonConst::ENTERPRISE_GJ) {
  759. $fields = ["Name" => "学校名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Ephone" => "学校电话", "Province" => "地址省", "City" => "地址市", "County" => "地址县\区", "Address" => "学校地址",
  760. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  761. $files = ["newImgurl" => "办学许可证、法人证书或登记证书", "newBeian" => "人才联络员信息备案表"];
  762. } else {
  763. $fields = ["Name" => "企业名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "企业地址", "Street" => "所属街道", "Ephone" => "企业电话", "BankCard" => "企业银行账号", "Bank" => "企业开户银行", "BankNetwork" => "企业开户银行网点",
  764. "AgencyType" => "机构类型", "IndustryFieldNew" => "产业领域", "IndustryFieldOld" => "行业领域", "EnterpriseTag" => "企业标签", "EnterpriseType" => "企业类型",
  765. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  766. $files = ["newImgurl" => "企业营业执照", "newBankImg" => "开户许可证/基本存款账户信息", "newDomainImg" => "行业领域佐证材料", "newBeian" => "人才联络员信息备案表", "newTypeImg" => "规上、高新技术、专精特新企业上传材料"];
  767. }
  768. } else {
  769. $fields = ["Name" => "单位名称", "IdCard" => "统一社会信用代码", "Legal" => "法人代表", "Address" => "单位地址", "Street" => "所属街道", "Ephone" => "单位电话", "BankCard" => "单位银行账号", "Bank" => "单位开户银行", "BankNetwork" => "单位开户银行网点",
  770. "AgentName" => "人才联络员姓名", "AgentPhone" => "人才联络员电话", "AgentEmail" => "人才联络员邮箱"];
  771. if ($special == 1) {
  772. $fields["InstitutionTag"] = "单位标签";
  773. }
  774. if ($special == 3) {
  775. $fields["OrganizationTag"] = "机构标签";
  776. }
  777. $files = ["newImgurl" => "法人证或批文", "newBankImg" => "开户许可证/基本存款账户信息", "newBeian" => "人才联络员备案表"];
  778. }
  779. return ["fields" => $fields, "files" => $files];
  780. }
  781. }