EnterpriseChangeRecord.php 40 KB

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