Auth.php 44 KB

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