Auth.php 34 KB

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