Api.php 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\admin\model\Enterprise;
  4. use app\common\api\DictApi;
  5. use app\common\api\EnterpriseApi;
  6. use app\common\model\CurrentcyFileType;
  7. use app\common\model\TalentChecklog;
  8. use app\common\model\TalentCommonFile;
  9. use app\enterprise\model\EnterpriseRecord;
  10. use app\enterprise\common\EnterpriseController;
  11. use app\Request;
  12. use think\exception\ValidateException;
  13. use app\common\api\UploadApi;
  14. class Api extends EnterpriseController {
  15. public function findEnterpriseChangeByPage() {
  16. $order = trim($this->request->param("order")) ?: "desc";
  17. $offset = trim($this->request->param("offset")) ?: 0;
  18. $limit = trim($this->request->param("limit")) ?: 10;
  19. $list = EnterpriseRecord::where('mainId', session("user")["uid"])->limit($offset, $limit)->order('createTime ' . $order)->select()->toArray();
  20. $count = count($list);
  21. if ($count > 0) {
  22. $streetList = DictApi::selectByParentCode('street');
  23. $typeList = DictApi::selectByParentCode('enterprise_type');
  24. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  25. foreach ($list as $k => &$v) {
  26. $v['newIndustryFieldNewName'] = $industryFieldNew[$v['newIndustryFieldNew']];
  27. $v['newEnterpriseType'] = $typeList[$v['newEnterpriseType']];
  28. $v['newStreetName'] = $streetList[$v['newStreet']];
  29. }
  30. }
  31. return json(["total" => $count, "rows" => $list]);
  32. }
  33. public function findUnfinishedChangeRecord() {
  34. return EnterpriseRecord::where('mainId', session("user")["uid"])->where('checkState', '<>', 4)->select()->toArray();
  35. }
  36. public function toAdd() {
  37. $ep = Enterprise::where('id', session("user")["uid"])->find();
  38. $ecr = [
  39. "special" => $ep["special"],
  40. 'enterprise_id' => $ep['id'],
  41. 'newName' => $ep['name'],
  42. 'newIdCard' => $ep['idCard'],
  43. 'newStreet' => $ep['street'],
  44. 'newAddress' => $ep['address'],
  45. 'newLegal' => $ep['legal'],
  46. 'newEphone' => $ep['ephone'],
  47. 'newAgentName' => $ep['agentName'],
  48. 'newAgentEmail' => $ep['agentEmail'],
  49. 'newAgentPhone' => $ep['agentPhone'],
  50. 'type' => $ep['type'],
  51. 'newEnterpriseTag' => $ep['enterpriseTag'],
  52. 'newEnterpriseType' => $ep['enterpriseType'],
  53. 'newIndustryFieldNew' => $ep['industryFieldNew'],
  54. 'newIndustryFieldOld' => $ep['industryFieldOld'],
  55. 'newBankCard' => $ep['bankCard'],
  56. 'newBank' => $ep['bank'],
  57. 'newBankNetwork' => $ep['bankNetwork']
  58. ];
  59. if ($ep["imgurl"]) {
  60. $ecr["imgurl"] = $ep["imgurl"];
  61. $extension = pathinfo($ep["imgurl"])["extension"];
  62. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  63. $ecr["imgurl_is_img"] = 1;
  64. }
  65. }
  66. if ($ep["bankImg"]) {
  67. $ecr["bankImg"] = $ep["bankImg"];
  68. $extension = pathinfo($ep["bankImg"])["extension"];
  69. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  70. $ecr["bankImg_is_img"] = 1;
  71. }
  72. }
  73. if ($ep["domainImg"]) {
  74. $ecr["domainImg"] = $ep["domainImg"];
  75. $extension = pathinfo($ep["domainImg"])["extension"];
  76. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  77. $ecr["domainImg_is_img"] = 1;
  78. }
  79. }
  80. if ($ep["beian"]) {
  81. $ecr["beian"] = $ep["beian"];
  82. $extension = pathinfo($ep["beian"])["extension"];
  83. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  84. $ecr["beian_is_img"] = 1;
  85. }
  86. }
  87. switch ($ep['checkState']) {
  88. case 1:
  89. $ecr['checkStateName'] = '保存未提交审核';
  90. break;
  91. case 2:
  92. $ecr['checkStateName'] = '待审核';
  93. break;
  94. case 3:
  95. $ecr['checkStateName'] = '审核驳回';
  96. break;
  97. case 4:
  98. $ecr['checkStateName'] = '审核通过';
  99. break;
  100. case 5:
  101. $ecr['checkStateName'] = '重新提交';
  102. break;
  103. default:
  104. $ecr['checkStateName'] = '';
  105. }
  106. //20220918增加根据不同的企业类型显示不同的信息变更界面
  107. switch ($ep->special) {
  108. case 0:
  109. return view("", ['ecr' => $ecr]);
  110. break;
  111. case 1:
  112. return view("", ['ecr' => $ecr]);
  113. break;
  114. default:
  115. break;
  116. }
  117. }
  118. public function upsert() {
  119. $data = [
  120. 'id' => \StrUtil::getRequestDecodeParam($this->request, 'enterprise_id'),
  121. 'name' => \StrUtil::getRequestDecodeParam($this->request, 'newName'), //单位名称
  122. 'idCard' => \StrUtil::getRequestDecodeParam($this->request, 'newIdCard'), //统一社会信用代码
  123. 'agentName' => \StrUtil::getRequestDecodeParam($this->request, 'newAgentName'), //人才联络员
  124. 'agentPhone' => \StrUtil::getRequestDecodeParam($this->request, 'newAgentPhone'), //人才联络员电话
  125. 'legal' => \StrUtil::getRequestDecodeParam($this->request, 'newLegal'), //法人
  126. 'street' => \StrUtil::getRequestDecodeParam($this->request, 'newStreet'), //镇街
  127. 'address' => \StrUtil::getRequestDecodeParam($this->request, 'newAddress'), //地址
  128. 'type' => intval($this->request['type']),
  129. 'enterpriseTag' => \StrUtil::getRequestDecodeParam($this->request, 'newEnterpriseTag'), //单位标签
  130. 'enterpriseType' => \StrUtil::getRequestDecodeParam($this->request, 'newEnterpriseType'), //单位类型
  131. 'agentEmail' => \StrUtil::getRequestDecodeParam($this->request, 'newAgentEmail'), //邮箱
  132. 'ephone' => \StrUtil::getRequestDecodeParam($this->request, 'newEphone'), //单位电话
  133. 'industryFieldNew' => \StrUtil::getRequestDecodeParam($this->request, 'newIndustryFieldNew'), //产业领域
  134. 'industryFieldOld' => \StrUtil::getRequestDecodeParam($this->request, 'newIndustryFieldOld'), //行业领域
  135. 'bankCard' => \StrUtil::getRequestDecodeParam($this->request, 'newBankCard'), //银行
  136. 'bank' => \StrUtil::getRequestDecodeParam($this->request, 'newBank'), //开户行
  137. 'bankNetwork' => \StrUtil::getRequestDecodeParam($this->request, 'newBankNetwork')//网点
  138. ];
  139. $response_object = new \stdClass();
  140. try {
  141. if (stripos($data['name'], "(")) {
  142. $data['name'] = str_replace('(', '(', $data['name']);
  143. }
  144. if (stripos($data['name'], ")")) {
  145. $data['name'] = str_replace(')', ')', $data['name']);
  146. }
  147. $ep = Enterprise::where('id', session("user")["uid"])->find();
  148. switch ($ep->special) {
  149. case 0:
  150. if ($ep->type == 2) {
  151. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('jc_change')->check($data);
  152. } else {
  153. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('change')->check($data);
  154. }
  155. break;
  156. case 1:
  157. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('sy_change')->check($data);
  158. break;
  159. default:
  160. break;
  161. }
  162. $record_id = \StrUtil::getRequestDecodeParam($this->request, 'id');
  163. if (!$record_id) {
  164. $record_id = getStringId();
  165. $record_data = [
  166. 'id' => $record_id,
  167. 'mainId' => $data['id'],
  168. 'type' => $data['type'],
  169. 'oldName' => $ep['name'],
  170. 'oldIdCard' => $ep['idCard'],
  171. 'oldIndustryFieldNew' => $ep['industryFieldNew'],
  172. 'oldIndustryFieldOld' => $ep['industryFieldOld'],
  173. 'oldStreet' => $ep['street'],
  174. 'oldAddress' => $ep['address'],
  175. 'oldLegal' => $ep['legal'],
  176. 'oldEphone' => $ep['ephone'],
  177. 'oldAgentName' => $ep['agentName'],
  178. 'oldAgentEmail' => $ep['agentEmail'],
  179. 'oldAgentPhone' => $ep['agentPhone'],
  180. 'oldEnterpriseTag' => $ep['enterpriseTag'],
  181. 'oldEnterpriseType' => $ep['enterpriseType'],
  182. 'oldBankCard' => $ep['bankCard'],
  183. 'oldBank' => $ep['bank'],
  184. 'oldBankNetwork' => $ep['bankNetwork'],
  185. "oldImgurl" => $ep["imgurl"],
  186. "oldBankImg" => $ep["bankImg"],
  187. "oldDomainImg" => $ep["domainImg"],
  188. "oldBeian" => $ep["beian"],
  189. 'newName' => htmlspecialchars($data['name']),
  190. 'newIdCard' => htmlspecialchars($data['idCard']),
  191. 'newIndustryFieldNew' => $data['industryFieldNew'],
  192. 'newIndustryFieldOld' => $data['industryFieldOld'],
  193. 'newStreet' => $data['street'],
  194. 'newAddress' => $data['address'],
  195. 'newLegal' => $data['legal'],
  196. 'newEphone' => $data['ephone'],
  197. 'newAgentName' => $data['agentName'],
  198. 'newAgentEmail' => $data['agentEmail'],
  199. 'newAgentPhone' => $data['agentPhone'],
  200. 'newEnterpriseTag' => $data['enterpriseTag'],
  201. 'newEnterpriseType' => $data['enterpriseType'],
  202. 'newBankCard' => $data['bankCard'],
  203. 'newBank' => $data['bank'],
  204. 'newBankNetwork' => $data['bankNetwork'],
  205. 'checkState' => 1,
  206. 'createTime' => date("Y-m-d H:i:s", time()),
  207. 'createUser' => session("user")["uid"]
  208. ];
  209. $record_data["newImgurl"] = $ep["imgurl"];
  210. $record_data["newBankImg"] = $ep["bankImg"];
  211. $record_data["newDomainImg"] = $ep["domainImg"];
  212. $record_data["newBeian"] = $ep["beian"];
  213. $files = $this->request->file();
  214. if ($files) {
  215. $uploadapi = new UploadApi();
  216. if (array_key_exists('imgurl', $files)) {
  217. $upload_result = $uploadapi->uploadOne($this->request->file('imgurl'), 'system');
  218. if ($upload_result->code == 500) {
  219. return \StrUtil::back($upload_result, "EpChangeEdit.callBack");
  220. }
  221. $record_data["newImgurl"] = $upload_result->filepath;
  222. }
  223. //检验附件 开户许可证
  224. if (array_key_exists('bankImg', $files)) {
  225. $upload_result1 = $uploadapi->uploadOne($this->request->file('bankImg'), 'system');
  226. if ($upload_result1->code == 500) {
  227. return \StrUtil::back($upload_result1, "EpChangeEdit.callBack");
  228. }
  229. $record_data["newBankImg"] = $upload_result1->filepath;
  230. }
  231. //检验附件 行业领域佐证材料
  232. if (array_key_exists('domainImg', $files)) {
  233. $upload_result2 = $uploadapi->uploadOne($this->request->file('domainImg'), 'system');
  234. if ($upload_result2->code == 500) {
  235. return \StrUtil::back($upload_result2, "EpChangeEdit.callBack");
  236. }
  237. $record_data["newDomainImg"] = $upload_result2->filepath;
  238. }
  239. //检验附件 人才联络员备案表
  240. if (array_key_exists('beian', $files)) {
  241. $upload_result3 = $uploadapi->uploadOne($this->request->file('beian'), 'system');
  242. if ($upload_result3->code == 500) {
  243. return \StrUtil::back($upload_result3, "EpChangeEdit.callBack");
  244. }
  245. $record_data["newBeian"] = $upload_result3->filepath;
  246. }
  247. }
  248. if (!$record_data["newImgurl"]) {
  249. throw new ValidateException("请上传营业执照");
  250. }
  251. if ($ep->special == 0) {
  252. if (!$record_data["newBankImg"]) {
  253. throw new ValidateException("请上传开户许可证");
  254. }
  255. if ($ep->type == 1 && !$record_data["newDomainImg"]) {
  256. throw new ValidateException("请上传行业领域佐证材料");
  257. }
  258. }
  259. if (!$record_data["newBeian"]) {
  260. throw new ValidateException("请上传人才联络员信息备案表");
  261. }
  262. EnterpriseRecord::create($record_data);
  263. $log = [
  264. 'id' => getStringId(),
  265. 'mainId' => $record_data['id'],
  266. 'category' => 'enterprise_change',
  267. 'type' => 10,
  268. 'active' => 1,
  269. 'state' => 1,
  270. 'step' => 100,
  271. 'stateChange' => '保存未提交',
  272. 'description' => '机构信息变更记录添加成功',
  273. 'createTime' => date("Y-m-d H:i:s", time()),
  274. 'createUser' => '用户'
  275. ];
  276. $success_msg = "添加成功";
  277. //$res = ['msg' => '添加成功', 'code' => 200, 'obj' => $record_data];
  278. } else {
  279. $record = EnterpriseRecord::find($record_id);
  280. $ep = Enterprise::where('id', session("user")["uid"])->find();
  281. $record->oldName = $ep['name'];
  282. $record->oldIdCard = $ep['idCard'];
  283. $record->oldIndustryFieldNew = $ep['industryFieldNew'];
  284. $record->oldIndustryFieldOld = $ep['industryFieldOld'];
  285. $record->oldStreet = $ep['street'];
  286. $record->oldAddress = $ep['address'];
  287. $record->oldLegal = $ep['legal'];
  288. $record->oldEphone = $ep['ephone'];
  289. $record->oldAgentName = $ep['agentName'];
  290. $record->oldAgentEmail = $ep['agentEmail'];
  291. $record->oldAgentPhone = $ep['agentPhone'];
  292. $record->oldEnterpriseTag = $ep['enterpriseTag'];
  293. $record->oldEnterpriseType = $ep['enterpriseType'];
  294. $record->oldBankCard = $ep['bankCard'];
  295. $record->oldBank = $ep['bank'];
  296. $record->oldBankNetwork = $ep['bankNetwork'];
  297. if ($record->checkState == 1) {
  298. $record->newName = htmlspecialchars($data['name']);
  299. $record->newIdCard = htmlspecialchars($data['idCard']);
  300. $record->newIndustryFieldNew = $data['industryFieldNew'];
  301. $record->newIndustryFieldOld = $data['industryFieldOld'];
  302. $record->newStreet = $data['street'];
  303. $record->newAddress = $data['address'];
  304. $record->newLegal = $data['legal'];
  305. $record->newEphone = $data['ephone'];
  306. $record->newAgentName = $data['agentName'];
  307. $record->newAgentEmail = $data['agentEmail'];
  308. $record->newAgentPhone = $data['agentPhone'];
  309. $record->newEnterpriseTag = $data['enterpriseTag'];
  310. $record->newEnterpriseType = $data['enterpriseType'];
  311. $record->newBankCard = $data['bankCard'];
  312. $record->newBank = $data['bank'];
  313. $record->newBankNetwork = $data['bankNetwork'];
  314. } else {
  315. $fields = array_filter(explode(",", $record->modify_fields));
  316. for ($i = 0; $i < count($fields); $i++) {
  317. $key = lcfirst(substr($fields[$i], 3));
  318. $record[$fields[$i]] = $data[$key]; //仅可修改选择的字段
  319. }
  320. }
  321. $record["newImgurl"] = $record["newImgurl"] ?: $ep["imgurl"];
  322. $record["newBankImg"] = $record["newBankImg"] ?: $ep["bankImg"];
  323. $record["newDomainImg"] = $record["newDomainImg"] ?: $ep["domainImg"];
  324. $record["newBeian"] = $record["newBeian"] ?: $ep["beian"];
  325. $files = $this->request->file();
  326. if ($files) {
  327. $uploadapi = new UploadApi();
  328. $modify_files = array_filter(explode(",", $record->modify_files));
  329. if (strtotime($record->createTime) < strtotime("2022-10-14 23:59:59")) {
  330. //旧typeid需要转换成新的禁用文件格式
  331. $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
  332. "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
  333. foreach ($modify_files as $key => $_typeId) {
  334. if ($oldtypes[$_typeId]) {
  335. $modify_files[$key] = $oldtypes[$_typeId];
  336. }
  337. }
  338. }
  339. $uploadAllowed = $record->checkState == 1 || ($record->checkState != 1 && in_array("newImgurl", $modify_files)) ? true : false;
  340. if (array_key_exists('imgurl', $files) && $uploadAllowed) {
  341. $upload_result = $uploadapi->uploadOne($this->request->file('imgurl'), 'system');
  342. if ($upload_result->code == 500) {
  343. return \StrUtil::back($upload_result, "EpChangeEdit.callBack");
  344. }
  345. $record["newImgurl"] = $upload_result->filepath;
  346. }
  347. //检验附件 开户许可证
  348. $uploadAllowed = $record->checkState == 1 || ($record->checkState != 1 && in_array("newBankImg", $modify_files)) ? true : false;
  349. if (array_key_exists('bankImg', $files) && $uploadAllowed) {
  350. $upload_result1 = $uploadapi->uploadOne($this->request->file('bankImg'), 'system');
  351. if ($upload_result1->code == 500) {
  352. return \StrUtil::back($upload_result1, "EpChangeEdit.callBack");
  353. }
  354. $record["newBankImg"] = $upload_result1->filepath;
  355. }
  356. //检验附件 行业领域佐证材料
  357. $uploadAllowed = $record->checkState == 1 || ($record->checkState != 1 && in_array("newDomainImg", $modify_files)) ? true : false;
  358. if (array_key_exists('domainImg', $files) && $uploadAllowed) {
  359. $upload_result2 = $uploadapi->uploadOne($this->request->file('domainImg'), 'system');
  360. if ($upload_result2->code == 500) {
  361. return \StrUtil::back($upload_result2, "EpChangeEdit.callBack");
  362. }
  363. $record["newDomainImg"] = $upload_result2->filepath;
  364. }
  365. //检验附件 人才联络员备案表
  366. $uploadAllowed = $record->checkState == 1 || ($record->checkState != 1 && in_array("newBeian", $modify_files)) ? true : false;
  367. if (array_key_exists('beian', $files) && $uploadAllowed) {
  368. $upload_result3 = $uploadapi->uploadOne($this->request->file('beian'), 'system');
  369. if ($upload_result3->code == 500) {
  370. return \StrUtil::back($upload_result3, "EpChangeEdit.callBack");
  371. }
  372. $record["newBeian"] = $upload_result3->filepath;
  373. }
  374. }
  375. if (!$record["newImgurl"]) {
  376. throw new ValidateException("请上传营业执照");
  377. }
  378. if ($ep->special == 0) {
  379. if (!$record["newBankImg"]) {
  380. throw new ValidateException("请上传开户许可证");
  381. }
  382. if ($ep->type == 1 && !$record["newDomainImg"]) {
  383. throw new ValidateException("请上传行业领域佐证材料");
  384. }
  385. }
  386. if (!$record["newBeian"]) {
  387. throw new ValidateException("请上传人才联络员信息备案表");
  388. }
  389. $record->updateTime = date("Y-m-d H:i:s");
  390. $record->updateUser = session("user")["uid"];
  391. $record->save();
  392. $log = [
  393. 'id' => getStringId(),
  394. 'category' => 'enterprise_change',
  395. 'mainId' => '',
  396. 'type' => 10,
  397. 'active' => 1,
  398. 'state' => 1,
  399. 'step' => 100,
  400. 'stateChange' => '保存未提交',
  401. 'description' => '机构信息变更记录修改成功',
  402. 'createTime' => date("Y-m-d H:i:s", time()),
  403. 'createUser' => '用户'
  404. ];
  405. $success_msg = "修改成功";
  406. //$res = ['msg' => '修改成功', 'code' => 200, 'obj' => $record];
  407. }
  408. TalentChecklog::create($log);
  409. $response_object->id = $record_id;
  410. $response_object->code = 200;
  411. $response_object->msg = $success_msg;
  412. return \StrUtil::back($response_object, "EpChangeEdit.callBack");
  413. //return json($res);
  414. } catch (ValidateException $e) {
  415. $response_object->code = 500;
  416. $response_object->msg = is_array($e->getError()) ? implode("<br>", $e->getError()) : $e->getError();
  417. return \StrUtil::back($response_object, "EpChangeEdit.callBack");
  418. //return json(["msg" => array_pop($error), 'code' => 500]);
  419. }
  420. }
  421. public function toUpdate() {
  422. $id = trim($this->request['id']);
  423. $ecr = EnterpriseRecord::findOrEmpty($id);
  424. $ep = Enterprise::where('id', $ecr->mainId)->find();
  425. $ecr["special"] = $ep["special"];
  426. if (strtotime($ecr["createTime"]) < strtotime("2022-10-14 23:59:59")) {
  427. $_files = explode(",", $ecr["modify_files"]);
  428. $_new_files = [];
  429. foreach ($_files as $_file) {
  430. $where = [];
  431. $where[] = ["id", "=", $_file];
  432. $_filetype = CurrentcyFileType::where($where)->find();
  433. switch ($_filetype["api"]) {
  434. case "businessLicense":
  435. $_new_files[] = "newImgurl";
  436. break;
  437. case "businessBank";
  438. $_new_files[] = "newBankImg";
  439. break;
  440. case "businessDomain";
  441. $_new_files[] = "newDomainImg";
  442. break;
  443. case "businessBeian";
  444. $_new_files[] = "newBeian";
  445. break;
  446. default:
  447. $_new_files[] = $_file;
  448. break;
  449. }
  450. }
  451. $ecr["modify_files"] = implode(",", $_new_files);
  452. }
  453. if ($ecr["newImgurl"]) {
  454. $extension = pathinfo($ecr["newImgurl"])["extension"];
  455. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  456. $ecr["imgurl_is_img"] = 1;
  457. }
  458. }
  459. if ($ecr["newBankImg"]) {
  460. $extension = pathinfo($ecr["newBankImg"])["extension"];
  461. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  462. $ecr["bankImg_is_img"] = 1;
  463. }
  464. }
  465. if ($ecr["newDomainImg"]) {
  466. $extension = pathinfo($ecr["newDomainImg"])["extension"];
  467. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  468. $ecr["domainImg_is_img"] = 1;
  469. }
  470. }
  471. if ($ecr["newBeian"]) {
  472. $extension = pathinfo($ecr["newBeian"])["extension"];
  473. if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
  474. $ecr["beian_is_img"] = 1;
  475. }
  476. }
  477. switch ($ep->special) {
  478. case 0:
  479. return view("", ['ecr' => $ecr]);
  480. break;
  481. case 1:
  482. return view("", ['ecr' => $ecr]);
  483. break;
  484. default:
  485. break;
  486. }
  487. }
  488. public function submitToCheck() {
  489. $id = trim($this->request->post('id'));
  490. if (!$id) {
  491. return json(['msg' => '记录为空', 'code' => 500]);
  492. }
  493. $obj = EnterpriseRecord::find($id);
  494. if (!$obj) {
  495. return json(['msg' => '提交审核失败,请先填写基础信息', 'code' => 500]);
  496. }
  497. if ($obj['checkState'] != 1 && $obj['checkState'] != 3) {
  498. return json(['msg' => '不能重复提交审核', 'code' => 500]);
  499. }
  500. $ep = EnterpriseApi::getOne($obj->mainId);
  501. //20220918增加根据不同的企业类型显示不同的信息变更界面|20221014废弃使用filetype
  502. /* switch ($ep->special) {
  503. case 0:
  504. $org_type = 'enterpriseChange';
  505. break;
  506. case 1:
  507. $org_type = 'governmentChange';
  508. break;
  509. default:
  510. break;
  511. }
  512. $list = CurrentcyFileType::where('type', $org_type)->where('active', 1)->select();
  513. if (!$list || count($list) <= 0) {
  514. return json(['msg' => '缺少附件', 'code' => 500]);
  515. }
  516. $error_msg = "";
  517. foreach ($list as $k => $v) {
  518. if ($v['must'] == 1) {
  519. $count = TalentCommonFile::where('mainId', $id)->where('typeId', $v['id'])->count();
  520. if ($count == 0) {
  521. if (strlen($error_msg) == 0) {
  522. $error_msg = "以下为必传附件:";
  523. }
  524. $error_msg .= $v['name'] . ";";
  525. }
  526. }
  527. }
  528. if (strlen($error_msg) > 0) {
  529. return json(['msg' => $error_msg, 'code' => 500]);
  530. } */
  531. if ($obj['checkState'] == 3) {
  532. $obj['checkState'] = 5;
  533. $state = 5;
  534. } else {
  535. $obj['checkState'] = 2;
  536. $state = 2;
  537. }
  538. $obj->save();
  539. $log = [
  540. 'id' => getStringId(),
  541. 'category' => 'enterprise_change',
  542. 'mainId' => $id,
  543. 'type' => 10,
  544. 'active' => 1,
  545. 'state' => $state,
  546. 'step' => 100,
  547. 'stateChange' => "<span class='label'>待提交</span>-><span class='label label-success'>待审核</span>",
  548. 'description' => '提交审核',
  549. 'createTime' => date("Y-m-d H:i:s", time()),
  550. 'createUser' => '用户'
  551. ];
  552. TalentChecklog::create($log);
  553. return json(['msg' => '提交审核成功', 'code' => 200, 'obj' => 1]);
  554. }
  555. public function toDetail() {
  556. $id = trim($this->request['id']);
  557. if (!$id) {
  558. return json(['msg' => '记录为空', 'code' => 500]);
  559. }
  560. $ecr = EnterpriseRecord::find($id);
  561. $ep = EnterpriseApi::getOne($ecr['mainId']);
  562. $streetList = DictApi::selectByParentCode('street');
  563. $ecr["special"] = $ep["special"];
  564. $ecr['oldStreetName'] = $streetList[$ecr['oldStreet']];
  565. $ecr['newStreetName'] = $streetList[$ecr['newStreet']];
  566. //20220918增加根据不同的企业类型显示不同的信息变更界面
  567. $time = "2022-10-14 23:59:59";
  568. //营业执照
  569. if (!$ecr["oldImgurl"]) {
  570. $ecr["oldImgurl"] = $ep["imgurl"];
  571. }
  572. if ($ecr["oldImgurl"]) {
  573. $pathinfo = pathinfo($ecr["oldImgurl"]);
  574. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  575. $ecr["oldImgurl_is_img"] = 1;
  576. }
  577. }
  578. if (!$ecr["newImgurl"]) {
  579. //兼容旧filetype
  580. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  581. $where = [];
  582. $where[] = ["mainId", "=", $id];
  583. $where[] = ["api", "=", "businessLicense"];
  584. $where[] = ["active", "=", 1];
  585. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("createTime desc")->find();
  586. if ($_uploadFile) {
  587. $ecr["newImgurl"] = $_uploadFile["url"];
  588. }
  589. }
  590. }
  591. if ($ecr["newImgurl"]) {
  592. $pathinfo = pathinfo($ecr["newImgurl"]);
  593. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  594. $ecr["newImgurl_is_img"] = 1;
  595. }
  596. }
  597. //备案表
  598. if (!$ecr["oldBeian"]) {
  599. $ecr["oldBeian"] = $ep["beian"];
  600. }
  601. if ($ecr["oldBeian"]) {
  602. $pathinfo = pathinfo($ecr["oldBeian"]);
  603. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  604. $ecr["oldBeian_is_img"] = 1;
  605. }
  606. }
  607. if (!$ecr["newBeian"]) {
  608. //兼容旧filetype
  609. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  610. $where = [];
  611. $where[] = ["mainId", "=", $id];
  612. $where[] = ["api", "=", "businessBeian"];
  613. $where[] = ["active", "=", 1];
  614. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("createTime desc")->find();
  615. if ($_uploadFile) {
  616. $ecr["newBeian"] = $_uploadFile["url"];
  617. }
  618. }
  619. }
  620. if ($ecr["newBeian"]) {
  621. $pathinfo = pathinfo($ecr["newBeian"]);
  622. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  623. $ecr["newBeian_is_img"] = 1;
  624. }
  625. }
  626. //行业领域
  627. if (!$ecr["oldDomainImg"]) {
  628. $ecr["oldDomainImg"] = $ep["domainImg"];
  629. }
  630. if ($ecr["oldDomainImg"]) {
  631. $pathinfo = pathinfo($ecr["oldDomainImg"]);
  632. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  633. $ecr["oldDomainImg_is_img"] = 1;
  634. }
  635. }
  636. if (!$ecr["newDomainImg"]) {
  637. //兼容旧filetype
  638. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  639. $where = [];
  640. $where[] = ["mainId", "=", $id];
  641. $where[] = ["api", "=", "businessDomain"];
  642. $where[] = ["active", "=", 1];
  643. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("createTime desc")->find();
  644. if ($_uploadFile) {
  645. $ecr["newDomainImg"] = $_uploadFile["url"];
  646. }
  647. }
  648. }
  649. if ($ecr["newDomainImg"]) {
  650. $pathinfo = pathinfo($ecr["newDomainImg"]);
  651. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  652. $ecr["newDomainImg_is_img"] = 1;
  653. }
  654. }
  655. //开户许可证
  656. if (!$ecr["oldBankImg"]) {
  657. $ecr["oldBankImg"] = $ep["bankImg"];
  658. }
  659. if ($ecr["oldBankImg"]) {
  660. $pathinfo = pathinfo($ecr["oldBankImg"]);
  661. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  662. $ecr["oldBankImg_is_img"] = 1;
  663. }
  664. }
  665. if (!$ecr["newBankImg"]) {
  666. //兼容旧filetype
  667. if (strtotime($ecr["createTime"]) < strtotime($time)) {
  668. $where = [];
  669. $where[] = ["mainId", "=", $id];
  670. $where[] = ["api", "=", "businessBank"];
  671. $where[] = ["active", "=", 1];
  672. $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("createTime desc")->find();
  673. if ($_uploadFile) {
  674. $ecr["newBankImg"] = $_uploadFile["url"];
  675. }
  676. }
  677. }
  678. if ($ecr["newBankImg"]) {
  679. $pathinfo = pathinfo($ecr["newBankImg"]);
  680. if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
  681. $ecr["newBankImg_is_img"] = 1;
  682. }
  683. }
  684. switch ($ep->special) {
  685. case 0:
  686. $tagList = DictApi::selectByParentCode('enterprise_tag');
  687. $typeList = DictApi::selectByParentCode('enterprise_type');
  688. $industryFieldNew = DictApi::selectByParentCode('industry_field');
  689. $industry = DictApi::findDictByCode($ecr['oldIndustryFieldOld']);
  690. $ecr['oldIndustryFieldOldName'] = $industry['name'];
  691. $industry = DictApi::findDictByCode($ecr['newIndustryFieldOld']);
  692. $ecr['newIndustryFieldOldName'] = $industry['name'];
  693. $ecr['oldEnterpriseTagName'] = $tagList[$ecr['oldEnterpriseTag']];
  694. $ecr['newEnterpriseTagName'] = $tagList[$ecr['newEnterpriseTag']];
  695. $ecr['oldEnterpriseTypeName'] = $typeList[$ecr['oldEnterpriseType']];
  696. $ecr['newEnterpriseTypeName'] = $typeList[$ecr['newEnterpriseType']];
  697. $ecr['oldIndustryFieldNewName'] = $industryFieldNew[$ecr['oldIndustryFieldNew']];
  698. $ecr['newIndustryFieldNewName'] = $industryFieldNew[$ecr['newIndustryFieldNew']];
  699. return view("", ['ecr' => $ecr]);
  700. break;
  701. case 1:
  702. return view("", ['ecr' => $ecr]);
  703. break;
  704. default:
  705. break;
  706. }
  707. }
  708. }