Api.php 53 KB

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