Api.php 45 KB

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