Auth.php 36 KB

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