EnterpriseChangeRecord.php 41 KB

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