EnterpriseChangeRecord.php 38 KB

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