Auth.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\EnterpriseApi;
  6. use app\common\model\MessageRecord;
  7. use app\common\model\TalentChecklog;
  8. use think\facade\Cache;
  9. use app\common\validate\Enterprise;
  10. use app\common\validate\Person;
  11. use think\exception\ValidateException;
  12. use think\facade\Request;
  13. use app\common\api\UploadApi;
  14. use app\enterprise\model\Talent;
  15. use app\common\api\TalentState;
  16. use think\facade\Db;
  17. use app\common\state\CommonConst;
  18. use app\common\api\Nhc;
  19. class Auth extends BaseController {
  20. private function checkRegisterTime($special, $type1, $type2 = null) {
  21. $now = time();
  22. $key = "";
  23. $agency_label = "";
  24. $registerCfg = \app\common\model\SysConfig::where("key", "register")->find();
  25. if ($registerCfg) {
  26. $registerCfg = json_decode($registerCfg["value"], true);
  27. switch ($special) {
  28. case 0://企业
  29. if ($type1 == 1) {
  30. //晋江人才
  31. if ($type2 == 1) {
  32. //4341
  33. $key = "jjrc_4341";
  34. $agency_label = "晋江市现代产业体系人才(4341现代产业体系)";
  35. } else {
  36. //非4341
  37. $key = "jjrc_no4341";
  38. $agency_label = "晋江市现代产业体系人才(非4341现代产业体系)";
  39. }
  40. } else if ($type1 == 2) {
  41. //电路人才
  42. $key = "jcrc";
  43. $agency_label = "集成电路优秀人才";
  44. }
  45. break;
  46. case 1://事业
  47. if ($type1 == "institution_common") {
  48. $key = "sy_nomedia";
  49. $agency_label = "事业单位-非媒体单位";
  50. } else if ($type1 == "institution_media") {
  51. $key = "sy_media";
  52. $agency_label = "事业单位-媒体单位";
  53. }
  54. break;
  55. case 3://民非
  56. if ($type1 == "minfei") {
  57. $key = "mbfqy";
  58. $agency_label = "民办非企业";
  59. }
  60. break;
  61. }
  62. if ($registerCfg[$key]) {
  63. list($startdate, $enddate) = explode(" - ", $registerCfg[$key]);
  64. $starttime = strtotime($startdate . "00:00:00");
  65. $endtime = strtotime($enddate . "23:59:59");
  66. if ($starttime && $endtime && ($now < $starttime || $now > $endtime)) {
  67. $response_object = new \StdClass();
  68. $response_object->code = 500;
  69. $response_object->msg = sprintf("您注册的类型【%s】不在可注册时间内(%s)", $agency_label, $registerCfg[$key]);
  70. return $response_object;
  71. }
  72. }
  73. }
  74. return true;
  75. }
  76. public function register() {
  77. $msg = "";
  78. if ($this->request->isPost()) {
  79. $source = 3; //intval($this->request['source']);
  80. $response_object = new \StdClass();
  81. $special = \StrUtil::getRequestDecodeParam($this->request, 'special');
  82. $data = [
  83. 'username' => \StrUtil::getRequestDecodeParam($this->request, 'username'),
  84. 'password' => \StrUtil::getRequestDecodeParam($this->request, 'password'),
  85. 're_password' => \StrUtil::getRequestDecodeParam($this->request, 're_password'),
  86. 'name' => \StrUtil::getRequestDecodeParam($this->request, 'name'),
  87. 'idCard' => \StrUtil::getRequestDecodeParam($this->request, 'idCard'),
  88. 'agentName' => \StrUtil::getRequestDecodeParam($this->request, 'agentName'),
  89. 'agentPhone' => \StrUtil::getRequestDecodeParam($this->request, 'agentPhone'),
  90. 'verificationCode' => \StrUtil::getRequestDecodeParam($this->request, 'verificationCode'),
  91. 'legal' => \StrUtil::getRequestDecodeParam($this->request, 'legal'),
  92. 'street' => \StrUtil::getRequestDecodeParam($this->request, 'street'),
  93. 'province' => \StrUtil::getRequestDecodeParam($this->request, 'province'),
  94. 'city' => \StrUtil::getRequestDecodeParam($this->request, 'city'),
  95. 'county' => \StrUtil::getRequestDecodeParam($this->request, 'county'),
  96. 'address' => \StrUtil::getRequestDecodeParam($this->request, 'address'),
  97. 'type' => intval($this->request['type']),
  98. 'agencyType' => intval($this->request['agencyType']),
  99. 'enterpriseTag' => \StrUtil::getRequestDecodeParam($this->request, 'enterpriseTag'),
  100. 'organizationTag' => \StrUtil::getRequestDecodeParam($this->request, 'organizationTag'),
  101. 'institutionTag' => \StrUtil::getRequestDecodeParam($this->request, 'institutionTag'),
  102. 'enterpriseType' => \StrUtil::getRequestDecodeParam($this->request, 'enterpriseType'),
  103. 'agentEmail' => \StrUtil::getRequestDecodeParam($this->request, 'agentEmail'),
  104. 'ephone' => \StrUtil::getRequestDecodeParam($this->request, 'ephone'),
  105. 'medicalCommunityId' => \StrUtil::getRequestDecodeParam($this->request, 'medicalCommunityId'),
  106. 'isGeneral' => \StrUtil::getRequestDecodeParam($this->request, 'isGeneral'),
  107. 'industryFieldNew' => \StrUtil::getRequestDecodeParam($this->request, 'industryFieldNew'),
  108. 'industryFieldOld' => \StrUtil::getRequestDecodeParam($this->request, 'industryFieldOld'),
  109. 'bankCard' => \StrUtil::getRequestDecodeParam($this->request, 'bankCard'),
  110. 'bank' => \StrUtil::getRequestDecodeParam($this->request, 'bank'),
  111. 'bankNetwork' => \StrUtil::getRequestDecodeParam($this->request, 'bankNetwork')
  112. ];
  113. try {
  114. $data['checkState'] = 1;
  115. if (stripos($data['name'], "(")) {
  116. $data['name'] = str_replace('(', '(', $data['name']);
  117. }
  118. if (stripos($data['name'], ")")) {
  119. $data['name'] = str_replace(')', ')', $data['name']);
  120. }
  121. $files = $this->request->file();
  122. switch ($special) {
  123. case 'qiye':
  124. if ($data['type'] == 1) {
  125. if ($data["agencyType"] == 1) {
  126. validate(Enterprise::class)->batch(true)->scene('add')->check($data);
  127. $registerTimeLimitReturnObj = $this->checkRegisterTime(0, $data['type'], $data["agencyType"]);
  128. if ($registerTimeLimitReturnObj !== true)
  129. return \StrUtil::back($registerTimeLimitReturnObj, "Register.epCallBack");
  130. if (!array_key_exists('domainImg', $files) || $files['domainImg'] == '') {
  131. $response_object->code = 500;
  132. $response_object->msg = '行业领域佐证材料不能为空';
  133. return \StrUtil::back($response_object, "Register.epCallBack");
  134. }
  135. } else {
  136. validate(Enterprise::class)->batch(true)->scene('add2')->check($data);
  137. $registerTimeLimitReturnObj = $this->checkRegisterTime(0, $data['type'], $data["agencyType"]);
  138. if ($registerTimeLimitReturnObj !== true)
  139. return \StrUtil::back($registerTimeLimitReturnObj, "Register.epCallBack");
  140. }
  141. $checkTypes = ["guishang", "gaoxinjishu", "zhuanjingtexin"];
  142. if (in_array($data["enterpriseType"], $checkTypes) && (!array_key_exists('typeImg', $files) || $files['typeImg'] == '')) {
  143. $response_object->code = 500;
  144. $response_object->msg = '规上、高新技术、专精特新企业需要上传佐证材料';
  145. return \StrUtil::back($response_object, "Register.epCallBack");
  146. }
  147. if (!array_key_exists('bankImg', $files) || $files['bankImg'] == '') {
  148. $response_object->code = 500;
  149. $response_object->msg = '开户许可证/基本存款账户信息不能为空';
  150. return \StrUtil::back($response_object, "Register.epCallBack");
  151. }
  152. } else {
  153. validate(Enterprise::class)->batch(true)->scene('jc_add')->check($data); //集成电路
  154. $registerTimeLimitReturnObj = $this->checkRegisterTime(0, $data['type']);
  155. if ($registerTimeLimitReturnObj !== true)
  156. return \StrUtil::back($registerTimeLimitReturnObj, "Register.epCallBack");
  157. }
  158. if (!array_key_exists('imgurl', $files) || $files['imgurl'] == '') {
  159. $response_object->code = 500;
  160. $response_object->msg = '营业执照不能为空';
  161. return \StrUtil::back($response_object, "Register.epCallBack");
  162. }
  163. if (!array_key_exists('beian', $files) || $files['beian'] == '') {
  164. $response_object->code = 500;
  165. $response_object->msg = '人才联络员备案表不能为空';
  166. return \StrUtil::back($response_object, "Register.epCallBack");
  167. }
  168. $data['special'] = 0;
  169. break;
  170. case 'minfei':
  171. $data['type'] = CommonConst::ENTERPRISE_NORMAL;
  172. $registerTimeLimitReturnObj = $this->checkRegisterTime(3, $data['organizationTag']);
  173. if ($registerTimeLimitReturnObj !== true)
  174. return \StrUtil::back($registerTimeLimitReturnObj, "Register.epCallBack");
  175. if (!array_key_exists('imgurl', $files) || $files['imgurl'] == '') {
  176. $response_object->code = 500;
  177. $response_object->msg = '营业执照不能为空';
  178. return \StrUtil::back($response_object, "Register.epCallBack");
  179. }
  180. if (!array_key_exists('bankImg', $files) || $files['bankImg'] == '') {
  181. $response_object->code = 500;
  182. $response_object->msg = '开户许可证/基本存款账户信息不能为空';
  183. return \StrUtil::back($response_object, "Register.epCallBack");
  184. }
  185. if (!array_key_exists('beian', $files) || $files['beian'] == '') {
  186. $response_object->code = 500;
  187. $response_object->msg = '人才联络员备案表不能为空';
  188. return \StrUtil::back($response_object, "Register.epCallBack");
  189. }
  190. $data['special'] = 3;
  191. break;
  192. case 'shiye':
  193. $data['type'] = CommonConst::ENTERPRISE_NORMAL;
  194. validate(Enterprise::class)->batch(true)->scene('sy_add')->check($data); //事业单位
  195. $registerTimeLimitReturnObj = $this->checkRegisterTime(1, $data['institutionTag']);
  196. if ($registerTimeLimitReturnObj !== true)
  197. return \StrUtil::back($registerTimeLimitReturnObj, "Register.epCallBack");
  198. if (!array_key_exists('imgurl', $files) || $files['imgurl'] == '') {
  199. $response_object->code = 500;
  200. $response_object->msg = '法人代表证或批文不能为空';
  201. return \StrUtil::back($response_object, "Register.epCallBack");
  202. }
  203. $data['special'] = 1;
  204. break;
  205. case "weijian":
  206. $data["type"] = CommonConst::ENTERPRISE_WJ; //卫健
  207. validate(\app\common\validate\Hospital::class)->batch(true)->scene('add')->check($data);
  208. if (!array_key_exists('imgurl', $files) || $files['imgurl'] == '') {
  209. $response_object->code = 500;
  210. $response_object->msg = '请上传医疗机构执业许可证';
  211. return \StrUtil::back($response_object, "Register.epCallBack");
  212. }
  213. if (!array_key_exists('beian', $files) || $files['beian'] == '') {
  214. $response_object->code = 500;
  215. $response_object->msg = '请上传人才联络员备案表';
  216. return \StrUtil::back($response_object, "Register.epCallBack");
  217. }
  218. if ($data["isGeneral"] == 1 || ($data["isGeneral"] == 0 && Nhc::hasGeneralHospital($data["medicalCommunityId"]))) {
  219. $data["step"] = 1; //直接进入卫健复审
  220. $data["checkState"] = 6; //初审通过
  221. } else {
  222. $data["step"] = 0;
  223. }
  224. break;
  225. case "gaojiao":
  226. $data["type"] = CommonConst::ENTERPRISE_GJ; //高教
  227. validate(\app\common\validate\School::class)->batch(true)->scene('add')->check($data);
  228. if (!array_key_exists('imgurl', $files) || $files['imgurl'] == '') {
  229. $response_object->code = 500;
  230. $response_object->msg = '请上传办学许可证、法人证书或登记证书';
  231. return \StrUtil::back($response_object, "Register.epCallBack");
  232. }
  233. if (!array_key_exists('beian', $files) || $files['beian'] == '') {
  234. $response_object->code = 500;
  235. $response_object->msg = '请上传人才联络员备案表不能为空';
  236. return \StrUtil::back($response_object, "Register.epCallBack");
  237. }
  238. break;
  239. }
  240. //检验验证码
  241. $codeResult = MessageRecord::where('smsType', 1)->where('phone', $data['agentPhone'])->order('createTime', 'desc')->find();
  242. if (!$codeResult) {
  243. $response_object->code = 500;
  244. $response_object->msg = '请先发送验证码';
  245. return \StrUtil::back($response_object, "Register.epCallBack");
  246. }
  247. if ($codeResult['params'] != $data["verificationCode"]) {
  248. $response_object->code = 500;
  249. $response_object->msg = '验证码错误';
  250. return \StrUtil::back($response_object, "Register.epCallBack");
  251. }
  252. if (time() - strtotime($codeResult['createTime']) > 300) {
  253. $response_object->code = 500;
  254. $response_object->msg = '验证码过期,请重新发送';
  255. return \StrUtil::back($response_object, "Register.epCallBack");
  256. }
  257. $uploadapi = new UploadApi();
  258. //检验附件 营业执照
  259. if (array_key_exists('imgurl', $files)) {
  260. $upload_result = $uploadapi->uploadOne($this->request->file('imgurl'), 'system');
  261. if ($upload_result->code == 500) {
  262. return \StrUtil::back($upload_result, "Register.epCallBack");
  263. }
  264. $imgurl = $upload_result->filepath;
  265. } else {
  266. $imgurl = '';
  267. }
  268. //检验附件 开户许可证
  269. if (array_key_exists('bankImg', $files)) {
  270. $upload_result1 = $uploadapi->uploadOne($this->request->file('bankImg'), 'system');
  271. if ($upload_result1->code == 500) {
  272. return \StrUtil::back($upload_result1, "Register.epCallBack");
  273. }
  274. $bankImg = $upload_result1->filepath;
  275. } else {
  276. $bankImg = '';
  277. }
  278. //检验附件 行业领域佐证材料
  279. if (array_key_exists('domainImg', $files)) {
  280. $upload_result2 = $uploadapi->uploadOne($this->request->file('domainImg'), 'system');
  281. if ($upload_result2->code == 500) {
  282. return \StrUtil::back($upload_result2, "Register.epCallBack");
  283. }
  284. $domainImg = $upload_result2->filepath;
  285. } else {
  286. $domainImg = '';
  287. }
  288. //检验附件 行业领域佐证材料
  289. if (array_key_exists('typeImg', $files)) {
  290. $upload_result4 = $uploadapi->uploadOne($this->request->file('typeImg'), 'system');
  291. if ($upload_result4->code == 500) {
  292. return \StrUtil::back($upload_result4, "Register.epCallBack");
  293. }
  294. $typeImg = $upload_result4->filepath;
  295. } else {
  296. $typeImg = '';
  297. }
  298. //检验附件 人才联络员备案表
  299. if (array_key_exists('beian', $files)) {
  300. $upload_result3 = $uploadapi->uploadOne($this->request->file('beian'), 'system');
  301. if ($upload_result3->code == 500) {
  302. return \StrUtil::back($upload_result3, "Register.epCallBack");
  303. }
  304. $beian = $upload_result3->filepath;
  305. } else {
  306. $beian = '';
  307. }
  308. $data["provinceName"] = $data["province"] ? \app\common\api\LocationApi::getNameByCode($data["province"]) : null;
  309. $data["cityName"] = $data["city"] ? \app\common\api\LocationApi::getNameByCode($data["city"]) : null;
  310. $data["countyName"] = $data["county"] ? \app\common\api\LocationApi::getNameByCode($data["county"]) : null;
  311. $data['id'] = getStringId();
  312. $data['password'] = hash('md5', $data['password']);
  313. $data['source'] = $source;
  314. $data['imgurl'] = $imgurl;
  315. $data['bankImg'] = $bankImg;
  316. $data['domainImg'] = $domainImg;
  317. $data["typeImg"] = $typeImg;
  318. $data['beian'] = $beian;
  319. $data['createTime'] = date("Y-m-d H:i:s", time());
  320. $data['updateTime'] = date("Y-m-d H:i:s", time());
  321. $data['active'] = 1;
  322. \app\common\model\Enterprise::create($data);
  323. TalentChecklog::create([
  324. 'id' => getStringId(),
  325. 'mainId' => $data['id'],
  326. 'type' => 10,
  327. 'typeField' => null,
  328. 'active' => 1,
  329. 'state' => 1,
  330. 'step' => 100,
  331. 'stateChange' => '用户提交',
  332. 'description' => '用户注册',
  333. 'createTime' => date("Y-m-d H:i:s", time()),
  334. 'createUser' => '用户'
  335. ]);
  336. $response_object->code = 200;
  337. $response_object->msg = '注册成功';
  338. return \StrUtil::back($response_object, "Register.epCallBack");
  339. } catch (ValidateException $e) {
  340. $error = $e->getError();
  341. $response_object->code = 500;
  342. $response_object->msg = array_pop($error);
  343. return \StrUtil::back($response_object, "Register.epCallBack");
  344. }
  345. }
  346. $medicalCommunities = Nhc::getMedicalCommunityList();
  347. return view("", ["msg" => $msg, "medicalCommunities" => $medicalCommunities]);
  348. }
  349. public function enterprise_edit() {
  350. $temp = session('temp');
  351. if (empty($temp)) {
  352. return redirect("/");
  353. }
  354. $ep = EnterpriseApi::getOne(session('temp')['uid']);
  355. if ($this->request->isPost()) {
  356. $response_object = new \StdClass();
  357. $data = $ep->toArray();
  358. $data = [
  359. 'name' => \StrUtil::getRequestDecodeParam($this->request, 'name'), //单位名称
  360. 'idCard' => \StrUtil::getRequestDecodeParam($this->request, 'idCard'), //统一社会信用代码
  361. 'agentName' => \StrUtil::getRequestDecodeParam($this->request, 'agentName'), //人才联络员
  362. 'legal' => \StrUtil::getRequestDecodeParam($this->request, 'legal'), //法人
  363. 'street' => \StrUtil::getRequestDecodeParam($this->request, 'street'), //镇街
  364. 'province' => \StrUtil::getRequestDecodeParam($this->request, 'province'), //省
  365. 'city' => \StrUtil::getRequestDecodeParam($this->request, 'city'), //市
  366. 'county' => \StrUtil::getRequestDecodeParam($this->request, 'county'), //县
  367. 'address' => \StrUtil::getRequestDecodeParam($this->request, 'address'), //地址
  368. 'type' => intval($this->request['type']),
  369. 'agencyType' => intval($this->request['agencyType']),
  370. 'enterpriseTag' => \StrUtil::getRequestDecodeParam($this->request, 'enterpriseTag'), //单位标签
  371. 'organizationTag' => \StrUtil::getRequestDecodeParam($this->request, 'organizationTag'), //机构标签
  372. 'institutionTag' => \StrUtil::getRequestDecodeParam($this->request, 'institutionTag'), //事业单位标签
  373. 'enterpriseType' => \StrUtil::getRequestDecodeParam($this->request, 'enterpriseType'), //单位类型
  374. 'agentPhone' => \StrUtil::getRequestDecodeParam($this->request, 'agentPhone'), //手机
  375. 'agentEmail' => \StrUtil::getRequestDecodeParam($this->request, 'agentEmail'), //邮箱
  376. 'ephone' => \StrUtil::getRequestDecodeParam($this->request, 'ephone'), //单位电话
  377. 'medicalCommunityId' => \StrUtil::getRequestDecodeParam($this->request, 'medicalCommunityId'), //卫健专属:医共体
  378. 'isGeneral' => \StrUtil::getRequestDecodeParam($this->request, 'isGeneral'), //卫健专属:是否总院
  379. 'industryFieldNew' => \StrUtil::getRequestDecodeParam($this->request, 'industryFieldNew'), //产业领域
  380. 'industryFieldOld' => \StrUtil::getRequestDecodeParam($this->request, 'industryFieldOld'), //行业领域
  381. 'bankCard' => \StrUtil::getRequestDecodeParam($this->request, 'bankCard'), //银行
  382. 'bank' => \StrUtil::getRequestDecodeParam($this->request, 'bank'), //开户行
  383. 'bankNetwork' => \StrUtil::getRequestDecodeParam($this->request, 'bankNetwork')//网点
  384. ];
  385. $ep->modify_fields = null; //注释注册驳回:如果要开启驳回,注释或者删掉这句话及上面那段 $data = [...];
  386. if ($ep->modify_fields) {
  387. $modify_fields = explode(",", $ep->modify_fields);
  388. foreach ($modify_fields as $field) {
  389. $data[$field] = \StrUtil::getRequestDecodeParam($this->request, $field);
  390. }
  391. }
  392. $modify_files = ["imgurl", "bankImg", "domainImg", "typeImg", "beian"]; //注释注册驳回:如果要开启驳回,用explode(",", $ep->modify_files)替换["imgurl", "bankImg", "domainImg", "typeImg", "beian"]这句代码;
  393. $files = $this->request->file();
  394. if ($files) {
  395. $uploadapi = new UploadApi();
  396. if (array_key_exists('imgurl', $files) && in_array('imgurl', $modify_files)) {
  397. $upload_result = $uploadapi->uploadOne($this->request->file('imgurl'), 'system');
  398. if ($upload_result->code == 500) {
  399. return \StrUtil::back($upload_result, "Register.epCallBack");
  400. }
  401. $data["imgurl"] = $upload_result->filepath;
  402. }
  403. //检验附件 开户许可证
  404. if (array_key_exists('bankImg', $files) && in_array('bankImg', $modify_files)) {
  405. $upload_result1 = $uploadapi->uploadOne($this->request->file('bankImg'), 'system');
  406. if ($upload_result1->code == 500) {
  407. return \StrUtil::back($upload_result1, "Register.epCallBack");
  408. }
  409. $data["bankImg"] = $upload_result1->filepath;
  410. }
  411. //检验附件 行业领域佐证材料
  412. if (array_key_exists('domainImg', $files) && in_array('domainImg', $modify_files)) {
  413. $upload_result2 = $uploadapi->uploadOne($this->request->file('domainImg'), 'system');
  414. if ($upload_result2->code == 500) {
  415. return \StrUtil::back($upload_result2, "Register.epCallBack");
  416. }
  417. $data["domainImg"] = $upload_result2->filepath;
  418. }
  419. //检验附件 行业领域佐证材料
  420. if (array_key_exists('typeImg', $files) && in_array('typeImg', $modify_files)) {
  421. $upload_result4 = $uploadapi->uploadOne($this->request->file('typeImg'), 'system');
  422. if ($upload_result4->code == 500) {
  423. return \StrUtil::back($upload_result4, "Register.epCallBack");
  424. }
  425. $data["typeImg"] = $upload_result4->filepath;
  426. }
  427. //检验附件 人才联络员备案表
  428. if (array_key_exists('beian', $files) && in_array('beian', $modify_files)) {
  429. $upload_result3 = $uploadapi->uploadOne($this->request->file('beian'), 'system');
  430. if ($upload_result3->code == 500) {
  431. return \StrUtil::back($upload_result3, "Register.epCallBack");
  432. }
  433. $data["beian"] = $upload_result3->filepath;
  434. }
  435. }
  436. try {
  437. if ($data['name'] && stripos($data['name'], "(")) {
  438. $data['name'] = str_replace('(', '(', $data['name']);
  439. }
  440. if ($data['name'] && stripos($data['name'], ")")) {
  441. $data['name'] = str_replace(')', ')', $data['name']);
  442. }
  443. $data['id'] = $ep->id;
  444. $data['checkState'] = 4;
  445. if ($ep->special == 0) {
  446. $idCardName = "营业执照";
  447. if ($data["type"] == CommonConst::ENTERPRISE_NORMAL) {
  448. if ($data["agencyType"] == 1) {
  449. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('change')->check($data);
  450. if (!$data["domainImg"] && !$ep->domainImg) {
  451. $response_object->code = 500;
  452. $response_object->msg = "行业领域佐证材料不能为空";
  453. return \StrUtil::back($response_object, "Register.epCallBack");
  454. }
  455. } else {
  456. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('change2')->check($data);
  457. }
  458. $checkTypes = ["guishang", "gaoxinjishu", "zhuanjingtexin"];
  459. if (in_array($data["enterpriseType"], $checkTypes) && (!$data["typeImg"] && !$ep->typeImg)) {
  460. $response_object->code = 500;
  461. $response_object->msg = '规上、高新技术、专精特新企业需要上传佐证材料';
  462. return \StrUtil::back($response_object, "Register.epCallBack");
  463. }
  464. if (!$data["bankImg"] && !$ep->bankImg) {
  465. $response_object->code = 500;
  466. $response_object->msg = '开户许可证/基本存款账户信息不能为空';
  467. return \StrUtil::back($response_object, "Register.epCallBack");
  468. }
  469. } else if ($data["type"] == CommonConst::ENTERPRISE_JC) {
  470. //集成电路
  471. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('jc_change')->check($data);
  472. } else if ($data["type"] == CommonConst::ENTERPRISE_WJ) {
  473. //卫健医院
  474. validate(\app\common\validate\Hospital::class)->batch(true)->scene('change')->check($data);
  475. $idCardName = "医疗机构执业许可证";
  476. if ($data["isGeneral"] == 1 || ($data["isGeneral"] == 0 && Nhc::hasGeneralHospital($data["medicalCommunityId"]))) {
  477. $data["step"] = 1; //直接进入卫健复审
  478. $data["checkState"] = 6; //初审通过
  479. } else {
  480. $data["step"] = 0;
  481. }
  482. } else if ($data["type"] == CommonConst::ENTERPRISE_GJ) {
  483. //高教学校
  484. validate(\app\common\validate\School::class)->batch(true)->scene('change')->check($data);
  485. $idCardName = "办学许可证、法人证书或登记证书";
  486. } else {
  487. throw new ValidateException("未知注册类型");
  488. }
  489. if (!$data["imgurl"] && !$ep->imgurl) {
  490. $response_object->code = 500;
  491. $response_object->msg = $idCardName . '不能为空';
  492. return \StrUtil::back($response_object, "Register.epCallBack");
  493. }
  494. if (!$data["beian"] && !$ep->beian) {
  495. $response_object->code = 500;
  496. $response_object->msg = '人才联络员备案表不能为空';
  497. return \StrUtil::back($response_object, "Register.epCallBack");
  498. }
  499. } else {
  500. validate(\app\common\validate\Enterprise::class)->batch(true)->scene('sy_change')->check($data);
  501. if (!$data["imgurl"] && !$ep->imgurl) {
  502. $response_object->code = 500;
  503. $response_object->msg = '法人代表证或批文不能为空';
  504. return \StrUtil::back($response_object, "Register.epCallBack");
  505. }
  506. }
  507. $data["provinceName"] = $data["province"] ? \app\common\api\LocationApi::getNameByCode($data["province"]) : null;
  508. $data["cityName"] = $data["city"] ? \app\common\api\LocationApi::getNameByCode($data["city"]) : null;
  509. $data["countyName"] = $data["county"] ? \app\common\api\LocationApi::getNameByCode($data["county"]) : null;
  510. //unset($data["agentPhone"]);
  511. $data["updateTime"] = date("Y-m-d H:i:s");
  512. $ep->update($data);
  513. TalentChecklog::create([
  514. 'id' => getStringId(),
  515. 'mainId' => $data['id'],
  516. 'type' => 10,
  517. 'typeField' => null,
  518. 'active' => 1,
  519. 'state' => 4,
  520. 'step' => 100,
  521. 'stateChange' => '用户提交',
  522. 'description' => '用户信息修改成功',
  523. 'createTime' => date("Y-m-d H:i:s", time()),
  524. 'createUser' => '用户'
  525. ]);
  526. $response_object->code = 200;
  527. $response_object->msg = '修改成功';
  528. return \StrUtil::back($response_object, "Register.epCallBack");
  529. } catch (ValidateException $e) {
  530. $error = $e->getError();
  531. $response_object->code = 500;
  532. $response_object->msg = array_pop($error);
  533. return \StrUtil::back($response_object, "Register.epCallBack");
  534. }
  535. }
  536. if ($ep->imgurl) {
  537. $pathinfo = pathinfo($ep->imgurl);
  538. if (in_array($pathinfo["extension"], ["jpg", "jpeg", "png", "gif"])) {
  539. $ep->imgurl_is_img = 1;
  540. }
  541. }
  542. if ($ep->domainImg) {
  543. $pathinfo = pathinfo($ep->domainImg);
  544. if (in_array($pathinfo["extension"], ["jpg", "jpeg", "png", "gif"])) {
  545. $ep->domainImg_is_img = 1;
  546. }
  547. }
  548. if ($ep->typeImg) {
  549. $pathinfo = pathinfo($ep->typeImg);
  550. if (in_array($pathinfo["extension"], ["jpg", "jpeg", "png", "gif"])) {
  551. $ep->typeImg_is_img = 1;
  552. }
  553. }
  554. if ($ep->beian) {
  555. $pathinfo = pathinfo($ep->beian);
  556. if (in_array($pathinfo["extension"], ["jpg", "jpeg", "png", "gif"])) {
  557. $ep->beian_is_img = 1;
  558. }
  559. }
  560. if ($ep->bankImg) {
  561. $pathinfo = pathinfo($ep->bankImg);
  562. if (in_array($pathinfo["extension"], ["jpg", "jpeg", "png", "gif"])) {
  563. $ep->bankImg_is_img = 1;
  564. }
  565. }
  566. $template = "";
  567. $msg = session('temp')['msg'];
  568. $assigns = ["msg" => $msg, "ep" => $ep];
  569. switch ($ep->type) {
  570. case CommonConst::ENTERPRISE_WJ:
  571. $template = "/auth/hospital/enterprise_edit";
  572. $assigns["medicalCommunities"] = Nhc::getMedicalCommunityList();
  573. break;
  574. case CommonConst::ENTERPRISE_GJ;
  575. $template = "/auth/school/enterprise_edit";
  576. break;
  577. }
  578. return view($template, $assigns);
  579. }
  580. public function findBackPassword() {
  581. $type = intval($this->request['type']);
  582. if (\StrUtil::isEmpOrNull($type)) {
  583. return json(['msg' => '请选择账号类型', 'code' => 500]);
  584. }
  585. $username = \StrUtil::getRequestDecodeParam($this->request, 'username');
  586. if (\StrUtil::isEmpOrNull($username)) {
  587. return json(['msg' => '请填写账号', 'code' => 500]);
  588. }
  589. $password = \StrUtil::getRequestDecodeParam($this->request, 'password');
  590. if (\StrUtil::isEmpOrNull($password)) {
  591. return json(['msg' => '请填写新密码', 'code' => 500]);
  592. }
  593. $rePassword = \StrUtil::getRequestDecodeParam($this->request, 'rePassword');
  594. if (\StrUtil::isEmpOrNull($rePassword)) {
  595. return json(['msg' => '请填写重复新密码', 'code' => 500]);
  596. }
  597. if ($password != $rePassword) {
  598. return json(['msg' => '两次密码填写不一致', 'code' => 500]);
  599. }
  600. if (!preg_match("/^(?=.*\d)(?=.*[A-Za-z]).{8,}$/", $password)) {
  601. return json(['msg' => '密码必须包含字母、数字、特殊字符且长度超过8位', 'code' => 500]);
  602. }
  603. $phone = \StrUtil::getRequestDecodeParam($this->request, 'phone');
  604. if (\StrUtil::isEmpOrNull($phone)) {
  605. return json(['msg' => '请填写手机号', 'code' => 500]);
  606. }
  607. $verificationCode = \StrUtil::getRequestDecodeParam($this->request, 'verificationCode');
  608. if (\StrUtil::isEmpOrNull($verificationCode)) {
  609. return json(['msg' => '请填写验证码', 'code' => 500]);
  610. }
  611. //检验验证码
  612. $codeResult = MessageRecord::where('smsType', 1)->where('phone', $phone)->order('createTime', 'desc')->find();
  613. if (!$codeResult || (time() - strtotime($codeResult['sendingDate']) > 300)) {
  614. return json(['msg' => '请先发送验证码', 'code' => 500]);
  615. }
  616. if ($codeResult['params'] != $verificationCode) {
  617. return json(['msg' => '验证码不正确', 'code' => 500]);
  618. }
  619. $password = hash('md5', $password);
  620. if ($type == 1) {
  621. $count = \app\common\model\Enterprise::where('username', $username)->where('agentPhone', $phone)->count();
  622. if ($count == 0) {
  623. return json(['msg' => '未找到相关账号,请仔细核对账号及手机号信息!', 'code' => 500]);
  624. }
  625. if ($count > 1) {
  626. return json(['msg' => '找到多个账户,请联系相关单位处理!', 'code' => 500]);
  627. }
  628. $ep = \app\common\model\Enterprise::where('username', $username)->where('agentPhone', $phone)->find();
  629. $ep->password = $password;
  630. $ep->save();
  631. } else {
  632. //个人账户找回密码TODO
  633. }
  634. return json(['msg' => '找回密码成功!', 'code' => 200]);
  635. }
  636. public function verificationCode() {
  637. $phone = $this->request["phone"];
  638. $type = $this->request["type"];
  639. //校验手机号码是否为空
  640. if (\StrUtil::isEmpOrNull($phone)) {
  641. return json(["msg" => "请填写手机号码!"], 500);
  642. }
  643. if (\StrUtil::isEmpOrNull($type)) {
  644. return json(["msg" => "请填写手机号码!"], 500);
  645. }
  646. //校验手机号码格式是否正确
  647. if (\StrUtil::isMoblePhone($phone)) {
  648. return json(["msg" => "请填写正确的手机号码!"], 500);
  649. }
  650. $record = Cache::get("verify_{$type}_{$phone}");
  651. if ($record) {
  652. $time = time();
  653. if ($time - $record <= 60) {
  654. return json(["msg" => "一分钟内请勿频繁发送短信!"], 500);
  655. }
  656. }
  657. $code = '';
  658. for ($i = 1; $i <= 6; $i++) {
  659. $code .= rand(0, 9);
  660. }
  661. //$code = 999999;
  662. $template = "【晋江市人才服务平台】尊敬的用户,您的短信验证码为{$code},5分钟内有效。若非本人操作请忽略。";
  663. $smsapi = new ChuanglanSmsApi();
  664. $result = $smsapi->sendSMS($phone, $template);
  665. $result = json_decode($result, true);
  666. $id = getStringId();
  667. $record_data = [
  668. 'id' => $id,
  669. 'bizId' => $id,
  670. 'type' => 2,
  671. 'smsType' => 1,
  672. 'phone' => $phone,
  673. 'params' => $code,
  674. 'templateCode' => $template,
  675. 'state' => $result['code'] == 0 ? 2 : 3,
  676. 'sendingDate' => date("Y-m-d H:i:s", time()),
  677. 'createTime' => date("Y-m-d H:i:s", time()),
  678. 'msg' => $result['errorMsg']
  679. ];
  680. MessageRecord::create($record_data);
  681. if ($result['code'] == 0) {
  682. Cache::set("verify_{$type}_{$phone}", time());
  683. return json(["msg" => '验证码发送成功'], 200);
  684. } else {
  685. return json(["msg" => '验证码发送失败'], 500);
  686. }
  687. }
  688. public function person_register() {
  689. $source = intval($this->request['source']);
  690. $response_object = new \StdClass();
  691. $response_object->code = 500;
  692. $data = [
  693. 'username' => \StrUtil::getRequestDecodeParam($this->request, 'username'),
  694. 'password' => \StrUtil::getRequestDecodeParam($this->request, 'password'),
  695. 'name' => \StrUtil::getRequestDecodeParam($this->request, 'name'),
  696. 'idCard' => \StrUtil::getRequestDecodeParam($this->request, 'idCard'),
  697. 'sex' => \StrUtil::getRequestDecodeParam($this->request, 'sex'),
  698. 'phone' => \StrUtil::getRequestDecodeParam($this->request, 'phone'),
  699. ];
  700. $verificationCode = \StrUtil::getRequestDecodeParam($this->request, 'verificationCode');
  701. try {
  702. validate(Person::class)->batch(false)->scene('add')->check($data);
  703. //检验验证码
  704. $codeResult = MessageRecord::where('smsType', 1)->where('phone', $data['phone'])->order('createTime', 'desc')->find();
  705. if (!$codeResult) {
  706. throw new ValidateException("请先发送验证码");
  707. }
  708. if (!$verificationCode) {
  709. throw new ValidateException("请输入手机验证码");
  710. }
  711. if ($codeResult["params"] != $verificationCode) {
  712. throw new ValidateException("验证码错误");
  713. }
  714. if (time() - strtotime($codeResult['createTime']) > 300) {
  715. throw new ValidateException("验证码过期,请重新发送");
  716. }
  717. $info = Talent::where('card_number', $data['idCard'])->alias("ti")
  718. ->field("ti.*,e.type as enterpriseType")
  719. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  720. ->where('ti.checkState', TalentState::CERTIFICATED)->find();
  721. $oldWhere = [];
  722. $oldWhere[] = ["idCard", "=", $data['idCard']];
  723. $oldWhere[] = ["checkState", "=", \app\common\state\MainState::PASS];
  724. $oldWhere[] = ["isPublic", "=", 6];
  725. $oldWhere[] = ["isEffect", "=", 1];
  726. $oldInfo = Db::table("un_talent_info")->where($oldWhere)->find();
  727. if (!$info && !$oldInfo) {
  728. throw new ValidateException("人才库中不存在该证件号码,注册失败");
  729. }
  730. $certificateExpireTime = $info ? $info["certificateExpireTime"] : $oldInfo["qzgccrcActiveTime"];
  731. $phone = $info ? $info["phone"] : $oldInfo["phone"];
  732. $type = $info ? $info["enterpriseType"] : $oldInfo["type"];
  733. if (!strtotime($certificateExpireTime) || strtotime($certificateExpireTime) < time()) {
  734. throw new ValidateException("人才库中该证件号码所属人才的人才证书已过期,注册失败");
  735. }
  736. if ($phone != $data["phone"]) {
  737. throw new ValidateException("手机号码必须与人才库中一致,可联系企业经办人修改人才库手机号码");
  738. }
  739. $data["id"] = getStringId();
  740. $data["type"] = $type;
  741. $data["createTime"] = date("Y-m-d H:i:s");
  742. $data["updateTime"] = date("Y-m-d H:i:s");
  743. $data["password"] = md5($data["password"]);
  744. $data["active"] = 1;
  745. \app\admin\model\Person::insert($data);
  746. $response_object->code = 200;
  747. $response_object->msg = "注册成功";
  748. return json($response_object);
  749. } catch (ValidateException $e) {
  750. $response_object->msg = $e->getMessage();
  751. return json($response_object);
  752. } catch (\think\db\exception\DbException $e) {
  753. $response_object->msg = $e->getMessage();
  754. return json($response_object);
  755. }
  756. }
  757. }