resumelogic.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. ],
  50. 'getinfobyid' => [
  51. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  52. ],
  53. 'getinfobyuserid' => [
  54. ['name' => 'userid', 'title' => 'userid', 'require' => true, 'type' => 'numeric'],
  55. ],
  56. 'getallinfobyid' => [
  57. ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
  58. ],
  59. 'updatesendstatusbyid' => [
  60. ['name' => 'sendid', 'title' => 'sendid', 'require' => true, 'type' => 'numeric'],
  61. ['name' => 'status', 'title' => 'status', 'require' => true, 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
  62. ],
  63. ];
  64. return $list;
  65. }
  66. /**
  67. * 新增信息
  68. * 20200119
  69. * wj
  70. */
  71. public function newinfobyopenid($arr)
  72. {
  73. $result = $this->checkparam(__FUNCTION__, $arr);
  74. if (1 != $result['status']) {
  75. return $result;
  76. }
  77. $openid = $arr['openid'];
  78. $m_u = new usermodel();
  79. $uinfo = $m_u->getinfobyopenid($openid);
  80. if (empty($uinfo)) {
  81. return backarr(0, "用户信息不存在");
  82. }
  83. $userid = $uinfo['id'];
  84. $m_r = new resumemodel();
  85. $rinfo = $m_r->getinfobyuserid($userid);
  86. if (!empty($rinfo)) {
  87. return backarr(0, "简历已存在");
  88. }
  89. $arr['user_id'] = $uinfo['id'];
  90. $id = $m_r->insertData($arr);
  91. if (empty($id)) {
  92. return backarr(0, "新增失败");
  93. }
  94. return backarr(1, "新增成功", ['id' => $id]);
  95. }
  96. /**
  97. * 新增教育背景
  98. * 20200119
  99. * wj
  100. */
  101. public function newebinfobyopenid($arr)
  102. {
  103. $result = $this->checkparam(__FUNCTION__, $arr);
  104. if (1 != $result['status']) {
  105. return $result;
  106. }
  107. $openid = $arr['openid'];
  108. $m_u = new usermodel();
  109. $uinfo = $m_u->getinfobyopenid($openid);
  110. if (empty($uinfo)) {
  111. return backarr(0, "用户信息不存在");
  112. }
  113. $userid = $uinfo['id'];
  114. $m_r = new resumemodel();
  115. $rinfo = $m_r->getinfobyuserid($userid);
  116. if (empty($rinfo)) {
  117. return backarr(0, "简历不存在");
  118. }
  119. $resumeid = $rinfo['id'];
  120. $arr['resume_id'] = $resumeid;
  121. $arr['user_id'] = $userid;
  122. $m_eb = new educationbackgroundemodel();
  123. $id = $m_eb->insertData($arr);
  124. if (empty($id)) {
  125. return backarr(0, "新增失败");
  126. }
  127. return backarr(1, "新增成功", ['id' => $id]);
  128. }
  129. /**
  130. * 新增工作经历
  131. * 20200119
  132. * wj
  133. */
  134. public function newweinfobyopenid($arr)
  135. {
  136. $result = $this->checkparam(__FUNCTION__, $arr);
  137. if (1 != $result['status']) {
  138. return $result;
  139. }
  140. $openid = $arr['openid'];
  141. $m_u = new usermodel();
  142. $uinfo = $m_u->getinfobyopenid($openid);
  143. if (empty($uinfo)) {
  144. return backarr(0, "用户信息不存在");
  145. }
  146. $userid = $uinfo['id'];
  147. $m_r = new resumemodel();
  148. $rinfo = $m_r->getinfobyuserid($userid);
  149. if (empty($rinfo)) {
  150. return backarr(0, "简历不存在");
  151. }
  152. $resumeid = $rinfo['id'];
  153. $arr['resume_id'] = $resumeid;
  154. $arr['user_id'] = $userid;
  155. $m_we = new workexperiencemodel();
  156. $id = $m_we->insertData($arr);
  157. if (empty($id)) {
  158. return backarr(0, "新增失败");
  159. }
  160. return backarr(1, "新增成功", ['id' => $id]);
  161. }
  162. /**
  163. * 根据openid获取简历
  164. * 20220119
  165. * wj
  166. */
  167. public function getinfobyopenid($arr)
  168. {
  169. $result = $this->checkparam(__FUNCTION__, $arr);
  170. if (1 != $result['status']) {
  171. return $result;
  172. }
  173. $openid = $arr['openid'];
  174. $m_u = new usermodel();
  175. $uinfo = $m_u->getinfobyopenid($openid);
  176. if (empty($uinfo)) {
  177. return backarr(0, "用户信息不存在");
  178. }
  179. $userid = $uinfo['id'];
  180. $m_r = new resumemodel();
  181. $rinfo = $m_r->getinfobyuserid($userid);
  182. if (empty($rinfo)) {
  183. return backarr(0, "简历不存在");
  184. }
  185. $resumeid = $rinfo['id'];
  186. $m_eb = new educationbackgroundemodel();
  187. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  188. $rinfo['eblist'] = $eblist;
  189. $m_we = new workexperiencemodel();
  190. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  191. $rinfo['welist'] = $welist;
  192. return backarr(1, "查询成功", $rinfo);
  193. }
  194. /**
  195. * 根据id获取简历
  196. * 20220119
  197. * wj
  198. */
  199. public function getinfobyid($arr)
  200. {
  201. $result = $this->checkparam(__FUNCTION__, $arr);
  202. if (1 != $result['status']) {
  203. return $result;
  204. }
  205. $id = $arr['id'];
  206. $m_r = new resumemodel();
  207. $rinfo = $m_r->getinfobyid($id);
  208. if (empty($rinfo)) {
  209. return backarr(0, "简历不存在");
  210. }
  211. $resumeid = $rinfo['id'];
  212. $m_eb = new educationbackgroundemodel();
  213. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  214. $rinfo['eblist'] = $eblist;
  215. $m_we = new workexperiencemodel();
  216. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  217. $rinfo['welist'] = $welist;
  218. return backarr(1, "查询成功", $rinfo);
  219. }
  220. /**
  221. * 根据id获取简历、用户信息
  222. * 20220119
  223. * wj
  224. */
  225. public function getallinfobyid($arr)
  226. {
  227. $result = $this->checkparam(__FUNCTION__, $arr);
  228. if (1 != $result['status']) {
  229. return $result;
  230. }
  231. $id = $arr['id'];
  232. $m_r = new resumemodel();
  233. $rinfo = $m_r->getinfobyid($id);
  234. if (empty($rinfo)) {
  235. return backarr(0, "简历不存在");
  236. }
  237. $resumeid = $rinfo['id'];
  238. $m_eb = new educationbackgroundemodel();
  239. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  240. $rinfo['eblist'] = $eblist;
  241. $m_we = new workexperiencemodel();
  242. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  243. $rinfo['welist'] = $welist;
  244. $userid = $rinfo['user_id'];
  245. $m_u = new usermodel();
  246. $uinfo = $m_u->getfieldbyid($userid);
  247. if (empty($uinfo)) {
  248. return backarr(0, "用户信息不存在");
  249. }
  250. $rinfo['userinfo'] = $uinfo;
  251. return backarr(1, "查询成功", $rinfo);
  252. }
  253. /**
  254. * 根据id获取简历
  255. * 20220119
  256. * wj
  257. */
  258. public function getinfobyuserid($arr)
  259. {
  260. $result = $this->checkparam(__FUNCTION__, $arr);
  261. if (1 != $result['status']) {
  262. return $result;
  263. }
  264. $userid = $arr['userid'];
  265. $m_u = new usermodel();
  266. $uinfo = $m_u->getinfobyid($userid);
  267. if (empty($uinfo)) {
  268. return backarr(0, "用户信息不存在");
  269. }
  270. $m_r = new resumemodel();
  271. $rinfo = $m_r->getinfobyuserid($userid);
  272. if (empty($rinfo)) {
  273. return backarr(0, "简历不存在");
  274. }
  275. $resumeid = $rinfo['id'];
  276. $m_eb = new educationbackgroundemodel();
  277. $eblist = $m_eb->getList(['resume_id' => $resumeid], '*', 1, 0);
  278. $rinfo['eblist'] = $eblist;
  279. $m_we = new workexperiencemodel();
  280. $welist = $m_we->getList(['resume_id' => $resumeid], '*', 1, 0);
  281. $rinfo['welist'] = $welist;
  282. return backarr(1, "查询成功", $rinfo);
  283. }
  284. /**
  285. * 简历投递
  286. * 20220119
  287. * wj
  288. */
  289. public function sendresume($arr)
  290. {
  291. $result = $this->checkparam(__FUNCTION__, $arr);
  292. if (1 != $result['status']) {
  293. return $result;
  294. }
  295. $openid = $arr['openid'];
  296. $m_u = new usermodel();
  297. $uinfo = $m_u->getinfobyopenid($openid);
  298. if (empty($uinfo)) {
  299. return backarr(0, "用户信息不存在");
  300. }
  301. $inventid = $arr['inventid'];
  302. $m_i = new inventmodel();
  303. $iinfo = $m_i->getinfobyid($inventid);
  304. if (empty($iinfo)) {
  305. return backarr(0, "岗位不存在");
  306. }
  307. $m_r = new resumemodel();
  308. $userid = $uinfo['id'];
  309. $rinfo = $m_r->getinfobyuserid($userid);
  310. if (empty($rinfo)) {
  311. return backarr(0, "简历不存在");
  312. }
  313. if (isset($arr['partyid'])) {
  314. $partyid = $arr['partyid'];
  315. $m_p = new partymodel();
  316. $pinfo = $m_p->getinfobyid($partyid);
  317. if (empty($pinfo)) {
  318. return backarr(0, "活动不存在");
  319. }
  320. $arr['party_id'] = $pinfo['id'];
  321. }
  322. $arr['send_user_id'] = $userid;
  323. $arr['company_id'] = $iinfo['company_id'];
  324. $arr['resume_id'] = $rinfo['id'];
  325. $arr['invent_id'] = $iinfo['id'];
  326. //未判断重复投递
  327. $m_s = new sendrecordmodel();
  328. $id = $m_s->insertData($arr);
  329. if (empty($id)) {
  330. return backarr(0, "投递失败");
  331. }
  332. return backarr(1, "投递成功", ['id' => $id]);
  333. }
  334. /**
  335. * 根据条件获取简历投地记录
  336. * 企业用户返回 向企业投递的简历 根据 company_id 查
  337. * 非企业用户返回 投递过的简历 根据 send_user_id 查
  338. *
  339. * @return void
  340. */
  341. public function getsendedresumebywhere($arr)
  342. {
  343. $result = $this->checkparam(__FUNCTION__, $arr);
  344. if (1 != $result['status']) {
  345. return $result;
  346. }
  347. $openid = $arr['openid'];
  348. $m_u = new usermodel();
  349. $uinfo = $m_u->getinfobyopenid($openid);
  350. if (empty($uinfo)) {
  351. return backarr(0, "用户信息不存在");
  352. }
  353. $where = [];
  354. if (isset($arr['status'])) {
  355. $where['status'] = $arr['status'];
  356. }
  357. if (1 != $uinfo['is_company']) {
  358. $where['send_user_id'] = $uinfo['id'];
  359. } else {
  360. $where['company_id'] = $uinfo['company_id'];
  361. }
  362. $m_s = new sendrecordmodel();
  363. $count = $m_s->getlist($where, 'count');
  364. if ($count < 0) {
  365. return backarr(0, "无数据");
  366. }
  367. $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
  368. $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
  369. $list = $m_s->getList($where, '*', $page, $size);
  370. return backarr(1, "查询成功", $list);
  371. }
  372. /**
  373. * 修改投递状态 根据投递的id
  374. * 20220127
  375. * wj
  376. * */
  377. public function updatesendstatusbyid($arr)
  378. {
  379. $result = $this->checkparam(__FUNCTION__, $arr);
  380. if (1 != $result['status']) {
  381. return $result;
  382. }
  383. $sendid = $arr['sendid'];
  384. $status = $arr['status'];
  385. $m_s = new sendrecordmodel();
  386. $info = $m_s->getinfobyid($sendid);
  387. if (empty($info)) {
  388. return backarr(0, "无数据");
  389. }
  390. $row = $m_s->updatestatusbyid($info['id'], $status);
  391. return backarr(1, "修改成功", ['id' => $info['id']]);
  392. }
  393. }