resumelogic.php 12 KB

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