resumelogic.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2022-01-18 11:12:23
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2022-01-19 17:29:15
  7. * 微信类
  8. */
  9. namespace app\index\logic;
  10. use app\index\model\educationbackgroundemodel;
  11. use app\index\model\inventmodel;
  12. use app\index\model\partymodel;
  13. use app\index\model\resumemodel;
  14. use app\index\model\sendrecordmodel;
  15. use app\index\model\usermodel;
  16. use app\index\model\workexperiencemodel;
  17. class resumelogic extends baselogic
  18. {
  19. /**
  20. * 设置请求数据规则
  21. * 20220107
  22. * wj
  23. */
  24. protected function setrules()
  25. {
  26. $list = [
  27. 'newinfobyopenid' => [
  28. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  29. ],
  30. 'newebinfobyopenid' => [
  31. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  32. ],
  33. 'newweinfobyopenid' => [
  34. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  35. ],
  36. 'getinfobyopenid' => [
  37. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  38. ],
  39. 'sendresume' => [
  40. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  41. ['name' => 'inventid', 'title' => 'inventid', 'require' => true, 'type' => 'numeric'],
  42. ['name' => 'partyid', 'title' => 'partyid', 'type' => 'numeric'],
  43. ],
  44. 'getsendedresumebywhere' => [
  45. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  46. ['name' => 'status', 'title' => 'status', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
  47. ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
  48. ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
  49. ['name' => 'iscompany', 'title' => 'iscompany', 'type' => 'numeric', 'regex' => '/[0|1]{1}/'],
  50. ['name' => 'inventid', 'title' => 'inventid', 'type' => 'numeric'],
  51. ],
  52. 'getinfobyid' => [
  53. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  54. ],
  55. 'getinfobyuserid' => [
  56. ['name' => 'userid', 'title' => 'userid', 'require' => true, 'type' => 'numeric'],
  57. ],
  58. 'getallinfobyid' => [
  59. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  60. ],
  61. 'updatesendstatusbyid' => [
  62. ['name' => 'sendid', 'title' => 'sendid', 'require' => true, 'type' => 'numeric'],
  63. ['name' => 'status', 'title' => 'status', 'require' => true, 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
  64. ],
  65. 'editbyopenid' => [
  66. ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
  67. ],
  68. ];
  69. return $list;
  70. }
  71. /**
  72. * 新增信息
  73. * 20200119
  74. * wj
  75. */
  76. public function newinfobyopenid($arr)
  77. {
  78. $result = $this->checkparam(__FUNCTION__, $arr);
  79. if (1 != $result['status']) {
  80. return $result;
  81. }
  82. $openid = $arr['openid'];
  83. $m_u = new usermodel();
  84. $uinfo = $m_u->getinfobyopenid($openid);
  85. if (empty($uinfo)) {
  86. return backarr(0, "用户信息不存在");
  87. }
  88. $userid = $uinfo['id'];
  89. $m_r = new resumemodel();
  90. $rinfo = $m_r->getinfobyuserid($userid);
  91. if (!empty($rinfo)) {
  92. return backarr(0, "简历已存在");
  93. }
  94. $arr['user_id'] = $uinfo['id'];
  95. $id = $m_r->insertData($arr);
  96. if (empty($id)) {
  97. return backarr(0, "新增失败");
  98. }
  99. return backarr(1, "新增成功", ['id' => $id]);
  100. }
  101. /**
  102. * 新增教育背景
  103. * 20200119
  104. * wj
  105. */
  106. public function newebinfobyopenid($arr)
  107. {
  108. $result = $this->checkparam(__FUNCTION__, $arr);
  109. if (1 != $result['status']) {
  110. return $result;
  111. }
  112. $openid = $arr['openid'];
  113. $m_u = new usermodel();
  114. $uinfo = $m_u->getinfobyopenid($openid);
  115. if (empty($uinfo)) {
  116. return backarr(0, "用户信息不存在");
  117. }
  118. $userid = $uinfo['id'];
  119. $m_r = new resumemodel();
  120. $rinfo = $m_r->getinfobyuserid($userid);
  121. if (empty($rinfo)) {
  122. return backarr(0, "简历不存在");
  123. }
  124. $resumeid = $rinfo['id'];
  125. $arr['resume_id'] = $resumeid;
  126. $arr['user_id'] = $userid;
  127. $m_eb = new educationbackgroundemodel();
  128. $id = $m_eb->insertData($arr);
  129. if (empty($id)) {
  130. return backarr(0, "新增失败");
  131. }
  132. return backarr(1, "新增成功", ['id' => $id]);
  133. }
  134. /**
  135. * 新增工作经历
  136. * 20200119
  137. * wj
  138. */
  139. public function newweinfobyopenid($arr)
  140. {
  141. $result = $this->checkparam(__FUNCTION__, $arr);
  142. if (1 != $result['status']) {
  143. return $result;
  144. }
  145. $openid = $arr['openid'];
  146. $m_u = new usermodel();
  147. $uinfo = $m_u->getinfobyopenid($openid);
  148. if (empty($uinfo)) {
  149. return backarr(0, "用户信息不存在");
  150. }
  151. $userid = $uinfo['id'];
  152. $m_r = new resumemodel();
  153. $rinfo = $m_r->getinfobyuserid($userid);
  154. if (empty($rinfo)) {
  155. return backarr(0, "简历不存在");
  156. }
  157. $resumeid = $rinfo['id'];
  158. $arr['resume_id'] = $resumeid;
  159. $arr['user_id'] = $userid;
  160. $m_we = new workexperiencemodel();
  161. $id = $m_we->insertData($arr);
  162. if (empty($id)) {
  163. return backarr(0, "新增失败");
  164. }
  165. return backarr(1, "新增成功", ['id' => $id]);
  166. }
  167. /**
  168. * 根据openid获取简历
  169. * 20220119
  170. * wj
  171. */
  172. public function getinfobyopenid($arr)
  173. {
  174. $result = $this->checkparam(__FUNCTION__, $arr);
  175. if (1 != $result['status']) {
  176. return $result;
  177. }
  178. $openid = $arr['openid'];
  179. $m_u = new usermodel();
  180. $uinfo = $m_u->getinfobyopenid($openid);
  181. if (empty($uinfo)) {
  182. return backarr(0, "用户信息不存在");
  183. }
  184. $userid = $uinfo['id'];
  185. $m_r = new resumemodel();
  186. $rinfo = $m_r->getinfobyuserid($userid);
  187. if (empty($rinfo)) {
  188. return backarr(0, "简历不存在");
  189. }
  190. $resumeid = $rinfo['id'];
  191. $m_eb = new educationbackgroundemodel();
  192. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  193. $rinfo['eblist'] = $eblist;
  194. $m_we = new workexperiencemodel();
  195. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  196. $rinfo['welist'] = $welist;
  197. return backarr(1, "查询成功", $rinfo);
  198. }
  199. /**
  200. * 根据id获取简历
  201. * 20220119
  202. * wj
  203. */
  204. public function getinfobyid($arr)
  205. {
  206. $result = $this->checkparam(__FUNCTION__, $arr);
  207. if (1 != $result['status']) {
  208. return $result;
  209. }
  210. $id = $arr['id'];
  211. $m_r = new resumemodel();
  212. $rinfo = $m_r->getinfobyid($id);
  213. if (empty($rinfo)) {
  214. return backarr(0, "简历不存在");
  215. }
  216. $resumeid = $rinfo['id'];
  217. $m_eb = new educationbackgroundemodel();
  218. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  219. $rinfo['eblist'] = $eblist;
  220. $m_we = new workexperiencemodel();
  221. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  222. $rinfo['welist'] = $welist;
  223. return backarr(1, "查询成功", $rinfo);
  224. }
  225. /**
  226. * 根据id获取简历、用户信息
  227. * 20220119
  228. * wj
  229. */
  230. public function getallinfobyid($arr)
  231. {
  232. $result = $this->checkparam(__FUNCTION__, $arr);
  233. if (1 != $result['status']) {
  234. return $result;
  235. }
  236. $id = $arr['id'];
  237. $m_r = new resumemodel();
  238. $rinfo = $m_r->getinfobyid($id);
  239. if (empty($rinfo)) {
  240. return backarr(0, "简历不存在");
  241. }
  242. $resumeid = $rinfo['id'];
  243. $m_eb = new educationbackgroundemodel();
  244. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  245. $rinfo['eblist'] = $eblist;
  246. $m_we = new workexperiencemodel();
  247. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  248. $rinfo['welist'] = $welist;
  249. $userid = $rinfo['user_id'];
  250. $m_u = new usermodel();
  251. $uinfo = $m_u->getfieldbyid($userid);
  252. if (empty($uinfo)) {
  253. return backarr(0, "用户信息不存在");
  254. }
  255. $rinfo['userinfo'] = $uinfo;
  256. return backarr(1, "查询成功", $rinfo);
  257. }
  258. /**
  259. * 根据id获取简历
  260. * 20220119
  261. * wj
  262. */
  263. public function getinfobyuserid($arr)
  264. {
  265. $result = $this->checkparam(__FUNCTION__, $arr);
  266. if (1 != $result['status']) {
  267. return $result;
  268. }
  269. $userid = $arr['userid'];
  270. $m_u = new usermodel();
  271. $uinfo = $m_u->getinfobyid($userid);
  272. if (empty($uinfo)) {
  273. return backarr(0, "用户信息不存在");
  274. }
  275. $m_r = new resumemodel();
  276. $rinfo = $m_r->getinfobyuserid($userid);
  277. if (empty($rinfo)) {
  278. return backarr(0, "简历不存在");
  279. }
  280. $resumeid = $rinfo['id'];
  281. $m_eb = new educationbackgroundemodel();
  282. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  283. $rinfo['eblist'] = $eblist;
  284. $m_we = new workexperiencemodel();
  285. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  286. $rinfo['welist'] = $welist;
  287. return backarr(1, "查询成功", $rinfo);
  288. }
  289. /**
  290. * 简历投递
  291. * 20220119
  292. * wj
  293. */
  294. public function sendresume($arr)
  295. {
  296. $result = $this->checkparam(__FUNCTION__, $arr);
  297. if (1 != $result['status']) {
  298. return $result;
  299. }
  300. $openid = $arr['openid'];
  301. $m_u = new usermodel();
  302. $uinfo = $m_u->getinfobyopenid($openid);
  303. if (empty($uinfo)) {
  304. return backarr(0, "用户信息不存在");
  305. }
  306. $inventid = $arr['inventid'];
  307. $m_i = new inventmodel();
  308. $iinfo = $m_i->getinfobyid($inventid);
  309. if (empty($iinfo)) {
  310. return backarr(0, "岗位不存在");
  311. }
  312. $m_r = new resumemodel();
  313. $userid = $uinfo['id'];
  314. $rinfo = $m_r->getinfobyuserid($userid);
  315. if (empty($rinfo)) {
  316. return backarr(0, "简历不存在");
  317. }
  318. if (isset($arr['partyid'])) {
  319. $partyid = $arr['partyid'];
  320. $m_p = new partymodel();
  321. $pinfo = $m_p->getinfobyid($partyid);
  322. if (empty($pinfo)) {
  323. return backarr(0, "活动不存在");
  324. }
  325. $arr['party_id'] = $pinfo['id'];
  326. }
  327. $arr['send_user_id'] = $userid;
  328. $arr['company_id'] = $iinfo['company_id'];
  329. $arr['resume_id'] = $rinfo['id'];
  330. $arr['invent_id'] = $iinfo['id'];
  331. //未判断重复投递
  332. $m_s = new sendrecordmodel();
  333. $id = $m_s->insertData($arr);
  334. if (empty($id)) {
  335. return backarr(0, "投递失败");
  336. }
  337. return backarr(1, "投递成功", ['id' => $id]);
  338. }
  339. /**
  340. * 根据条件获取简历投地记录
  341. * 企业用户返回 向企业投递的简历 根据 company_id 查
  342. * 非企业用户返回 投递过的简历 根据 send_user_id 查
  343. *
  344. * @return void
  345. */
  346. public function getsendedresumebywhere($arr)
  347. {
  348. $result = $this->checkparam(__FUNCTION__, $arr);
  349. if (1 != $result['status']) {
  350. return $result;
  351. }
  352. $openid = $arr['openid'];
  353. $iscompany = isset($arr['iscompany']) ? $arr['iscompany'] : 0;
  354. $m_u = new usermodel();
  355. $uinfo = $m_u->getinfobyopenid($openid);
  356. if (empty($uinfo)) {
  357. return backarr(0, "用户信息不存在");
  358. }
  359. $where = [];
  360. if (isset($arr['inventid'])) {
  361. $where['invent_id'] = $arr['inventid'];
  362. }
  363. if (isset($arr['status'])) {
  364. $where['status'] = $arr['status'];
  365. }
  366. /*if (1 != $uinfo['is_company']) {
  367. $where['send_user_id'] = $uinfo['id'];
  368. } else {
  369. $where['company_id'] = $uinfo['company_id'];
  370. }*/
  371. if (1 != $iscompany) {
  372. $where['send_user_id'] = $uinfo['id'];
  373. } else {
  374. $where['company_id'] = $uinfo['company_id'];
  375. }
  376. $m_s = new sendrecordmodel();
  377. $count = $m_s->getlist($where, 'count');
  378. if ($count < 0) {
  379. return backarr(0, "无数据");
  380. }
  381. $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
  382. $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
  383. $list = $m_s->getList($where, '*', $page, $size);
  384. return backarr(1, "查询成功", $list);
  385. }
  386. /**
  387. * 修改投递状态 根据投递的id
  388. * 20220127
  389. * wj
  390. * */
  391. public function updatesendstatusbyid($arr)
  392. {
  393. $result = $this->checkparam(__FUNCTION__, $arr);
  394. if (1 != $result['status']) {
  395. return $result;
  396. }
  397. $sendid = $arr['sendid'];
  398. $status = $arr['status'];
  399. $m_s = new sendrecordmodel();
  400. $info = $m_s->getinfobyid($sendid);
  401. if (empty($info)) {
  402. return backarr(0, "无数据");
  403. }
  404. $row = $m_s->updatestatusbyid($info['id'], $status);
  405. return backarr(1, "修改成功", ['id' => $info['id']]);
  406. }
  407. /**
  408. * 根据openid修改简历数据
  409. * 20220211
  410. * wj
  411. * */
  412. public function editbyopenid($arr)
  413. {
  414. $result = $this->checkparam(__FUNCTION__, $arr);
  415. if (1 != $result['status']) {
  416. return $result;
  417. }
  418. $openid = $arr['openid'];
  419. $m_u = new usermodel();
  420. $uinfo = $m_u->getinfobyopenid($openid);
  421. if (empty($uinfo)) {
  422. return backarr(0, "用户信息不存在");
  423. }
  424. $m_r = new resumemodel();
  425. $userid = $uinfo['id'];
  426. $rinfo = $m_r->getinfobyuserid($userid);
  427. if (empty($rinfo)) {
  428. return backarr(0, "简历不存在");
  429. }
  430. $fields = ['education', 'work_type', 'working_years', 'personal_description'];
  431. $updateData = [];
  432. foreach ($arr as $key => $value) {
  433. if (in_array($key, $fields)) {
  434. if (!empty($value) && $value != $rinfo[$key]) {
  435. $updateData[$key] = $value;
  436. }
  437. }
  438. }
  439. if (!empty($updateData)) {
  440. $row = $m_r->updatebyid($rinfo['id'], $updateData);
  441. if (empty($row)) {
  442. return backarr(1, "操作失败");
  443. }
  444. }
  445. return backarr(1, "操作成功", ['id' => $rinfo['id']]);
  446. }
  447. }