Api.php 53 KB

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