Api.php 44 KB

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