Auth.php 42 KB

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