Auth.php 41 KB

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