Auth.php 41 KB

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