Api.php 58 KB

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