EnterpriseChangeRecord.php 39 KB

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