EnterpriseChangeRecord.php 40 KB

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