Api.php 40 KB

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