123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-09-27 09:02:06
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-20 16:33:51
- */
- namespace app\index\logic;
- use app\index\model\groupmodel;
- use app\index\model\jobhuntingmodel;
- use app\index\model\userinfomodel;
- use think\Log;
- class jobhuntinglogic
- {
- private $jobhuntingmodel;
- public function __construct()
- {
- $this->jobhuntingmodel = new jobhuntingmodel();
- }
- /*
- * create by wj
- * edit in 20211026
- * edit by steelxu
- * 增加联系信息
- */
- public function getinfobyid($id)
- {
- $where = ['id' => $id];
- $info = $this->jobhuntingmodel->getInfo($where);
- if (empty($info)) {
- return false;
- }
- //edit by steelxu 20211026
- $t_u = new userinfomodel();
- $uid = $info['createuid'];
- $uinfo = $t_u->selconinfobyid($uid);
- $info['coninfo'] = $uinfo;
- return $info;
- }
- public function insertinfo($info)
- {
- log::info($info);
- if (!isset($info['createuid']) || empty($info['createuid'])) {
- return backarr(0, "请求错误");
- }
- $uid = $info['createuid'];
- $t_u = new userinfomodel();
- $uinfo = $t_u->selconinfobyid($uid);
- if (empty($uinfo)) {
- return backarr(0, "无用户信息");
- }
- if (!isset($info['createdate']) || empty($info['createdate'])) {
- $info['createdate'] = date('Y-m-d H:i:s', time());
- }
- if (isset($info['userstyle'])) {
- if (!is_numeric($info['userstyle']) || !in_array($info['userstyle'], [1, 2])) {
- $info['userstyle'] = 1;
- }
- if (2 == $info['userstyle']) {
- $m_g = new groupmodel();
- if (!isset($info['groupid']) || empty($info['groupid'])) {
- return backarr(0, "无班组id");
- }
- $groupinfo = $m_g->getinfo(['id' => $info['groupid']]);
- if (empty($groupinfo)) {
- return backarr(0, "无组信息");
- }
- }
- if (1 == $info['userstyle']) {
- $m_u = new userinfomodel();
- if (!isset($info['createuid']) || empty($info['createuid'])) {
- return backarr(0, "无创建人id");
- }
- $userinfo = $m_u->getinfo(['id' => $info['createuid']]);
- if (empty($userinfo)) {
- return backarr(0, "无用户信息");
- }
- if (isset($info['groupid'])) {
- unset($info['groupid']);
- }
- }
- }
- if (isset($info['daysalary'])) {
- if (!is_numeric($info['daysalary'])) {
- return backarr(0, "日均工资格式错误");
- }
- }
- /*
- $where = [];
- if (isset($info['userstyle']) && !empty($info['userstyle'])) {
- $where['userstyle'] = $info['userstyle'];
- }
- if (isset($info['createuid']) && !empty($info['createuid'])) {
- $where['createuid'] = $info['createuid'];
- }
- if (isset($info['groupid']) && !empty($info['groupid'])) {
- $where['groupid'] = $info['groupid'];
- }
- if (!empty($where)) {
- $where['isactive'] = 1;
- $jhinfo = $this->jobhuntingmodel->getinfo($where);
- if (!empty($jhinfo)) {
- return backarr(0, "数据已存在");
- }
- }
- */
- $id = $this->jobhuntingmodel->insertData($info);
- if (empty($id)) {
- return backarr(0, "添加失败");
- } else {
- return backarr(1, "添加成功", ['id' => $id]);
- }
- }
- /*
- * 20211002
- * edit by steelxu
- * upade 改为 update
- */
- public function updateinfobyid($id, $updateData)
- {
- $where = ['id' => $id];
- $result = $this->jobhuntingmodel->update($where, $updateData);
- return $result;
- }
- public function updateisactivebyid($param)
- {
- if (!isset($param['id']) || empty($param['id'])) {
- return backarr(0, "请求数据错误");
- }
- $id = $param['id'];
- $info = $this->getinfobyid($id);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- if (1 != $info['isactive']) {
- return backarr(0, "已关闭");
- }
- $updateData = [
- 'isactive' => 0,
- 'unactivetime' => date("y-m-d H:i:s", time()),
- ];
- $updateWhere = [
- 'id' => $id,
- ];
- $row = $this->jobhuntingmodel->updateinfo($updateWhere, $updateData);
- if (!$row) {
- return backarr(0, "修改失败");
- }
- return backarr(1, "操作成功", ['id' => $id]);
- }
- public function incconcountbyid($param)
- {
- if (!isset($param['id']) || empty($param['id'])) {
- return backarr(0, "请求数据错误");
- }
- $id = $param['id'];
- $info = $this->getinfobyid($id);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- $updateWhere = [
- 'id' => $id,
- ];
- $row = $this->jobhuntingmodel->incField($updateWhere, 'concount');
- if (!$row) {
- return backarr(0, "修改失败");
- }
- return backarr(1, "操作成功");
- }
- //根据经纬度获取列表
- /*
- * 20211003
- * edit by steelxu5
- * 需加上 isactive=1,只提供未关闭的信息
- * 20211003
- * edit by steelxu5
- * 需要加上头像和通讯信息,
- *
- */
- public function getlistbyrange($arr)
- {
- $fillArr = ['lng', 'lat'];
- foreach ($fillArr as $key => $value) {
- if (!isset($arr[$value]) || empty($arr[$value])) {
- return backarr(0, "请求数据错误");
- }
- }
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $radii = isset($arr['radii']) && !empty($arr['radii']) ? $arr['radii'] : 100;
- $minlat = $arr['lat'] - $radii;
- $maxlat = $arr['lat'] + $radii;
- $minlng = $arr['lng'] - $radii;
- $maxlng = $arr['lng'] + $radii;
- $where = [
- 'gps_lat' => ['between', $minlat . "," . $maxlat],
- 'gps_lng' => ['between', $minlng . "," . $maxlng],
- 'isactive' => 1,
- 'ispass' => 1,
- ];
- $list = $this->jobhuntingmodel->getList($where, '*', $page, $size);
- if (count($list) <= 0) {
- return backarr(0, "无数据");
- }
- $t_u = new userinfomodel();
- foreach ($list as &$invent) {
- $uid = $invent['createuid'];
- $uinfo = $t_u->selconinfobyid($uid);
- $invent['coninfo'] = $uinfo;
- }
- return backarr(1, "查询成功", $list);
- }
- /*
- * 20211003
- * edit by steelxu5
- * 需加上 isactive=1,只提供未关闭的信息
- *
- */
- public function getlistbyaddress($arr)
- {
- $where = [];
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- if (isset($arr['city'])) {
- $where['city'] = ['like', "%" . $arr['city'] . "%"];
- }
- if (isset($arr['disc'])) {
- $where['disc'] = ['like', "%" . $arr['disc'] . "%"];
- }
- if (isset($arr['address'])) {
- $where['address'] = ['like', "%" . $arr['address'] . "%"];
- }
- if (empty($where)) {
- return backarr(0, "请求数据错误");
- }
- $where['isactive'] = 1; //edit by steelxu 20211003
- $where['ispass'] = 1;
- $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
- if (count($list) <= 0) {
- return backarr(0, "无数据");
- }
- $t_u = new userinfomodel();
- foreach ($list as &$invent) {
- $uid = $invent['createuid'];
- $uinfo = $t_u->selconinfobyid($uid);
- $invent['coninfo'] = $uinfo;
- }
- return backarr(1, "查询成功", $list);
- }
- /*
- * 20211002
- * steelxu5
- * 获取用户本人发的招工信息
- */
- public function getinventlistbycuid($arr)
- {
- $crid = $arr['uid'];
- $list = $this->jobhuntingmodel->sellistbyuid($crid);
- if (count($list) <= 0) {
- return backarr(0, "无数据");
- }
- return backarr(1, "查询成功", $list);
- }
- /*
- * 20211007
- * edit by steelxu5
- * 没有结果时,获取全部信息按地址发布
- *
- */
- public function getlistbytime($arr)
- {
- $where = [];
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $where['isactive'] = 1; //edit by steelxu 20211003
- $where['ispass'] = 1;
- $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
- if (count($list) <= 0) {
- return backarr(0, "无数据");
- }
- $t_u = new userinfomodel();
- foreach ($list as &$invent) {
- $uid = $invent['createuid'];
- $uinfo = $t_u->selconinfobyid($uid);
- $invent['coninfo'] = $uinfo;
- }
- return backarr(1, "查询成功", $list);
- }
- /***
- * 按工种查询
- * 20211026
- * wj
- */
- public function getlistbyworktype($arr)
- {
- if (!isset($arr['worktype']) || empty($arr['worktype'])) {
- return backarr(0, "请求数据错误");
- }
- $where = [];
- $worktype = $arr['worktype'];
- $where['worktype'] = $worktype;
- if (isset($arr['city']) && !empty($arr['city'])) {
- $where['city'] = $arr['city'];
- }
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $where['isactive'] = 1;
- $where['ispass'] = 1;
- /*$order = 'id desc';
- if (isset($arr['order']) && !empty($arr['order'])) {
- $order = $arr['order'];
- }*/
- $list = $this->jobhuntingmodel->getList($where, "*", $page, $size);
- if (count($list) <= 0) {
- return backarr(0, "无数据");
- }
- $t_u = new userinfomodel();
- foreach ($list as &$invent) {
- $uid = $invent['createuid'];
- $uinfo = $t_u->selconinfobyid($uid);
- $invent['coninfo'] = $uinfo;
- }
- return backarr(1, "查询成功", $list);
- }
- /*
- * 20211007
- * wj
- * 根据查询条件返回结果
- * 目前仅pc后台使用
- */
- public function getlistbysearch($arr)
- {
- $where = [];
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- if (isset($arr['userstyle'])) {
- $where['userstyle'] = $arr['userstyle'];
- }
- if (isset($arr['wname'])) {
- $where['wname'] = $arr['wname'];
- }
- if (isset($arr['telno'])) {
- $where['telno'] = $arr['telno'];
- }
- if (isset($arr['isactive'])) {
- $where['isactive'] = $arr['isactive'];
- }
- if (isset($arr['ispass'])) {
- $where['ispass'] = $arr['ispass'];
- }
- if (isset($arr['worktype'])) {
- $where['worktype'] = $arr['worktype'];
- }
- if (isset($arr['createdate']) && is_array($arr['createdate'])) {
- $createdate = array_filter($arr['createdate']);
- if (2 == count($createdate)) {
- $where['createdate'] = $arr['createdate'];
- }
- }
- $order = 'id desc';
- if (isset($arr['order']) && !empty($arr['order'])) {
- $order = $arr['order'];
- }
- $count = $this->jobhuntingmodel->getlistjoinuser($where, "count", $page, $size, $order);
- if ($count < 0) {
- return backarr(0, "无数据");
- }
- $list = $this->jobhuntingmodel->getlistjoinuser($where, "*", $page, $size, $order);
- $data = [
- 'count' => $count ? $count : 0,
- 'list' => $list,
- ];
- return backarr(1, "查询成功", $data);
- }
- /***
- * pc端审核用
- * 未审核 审核失败-》 审核成功
- * 未审核->审核失败
- * 20211117
- * wj
- */
- public function updateispassbyid($arr)
- {
- if (!isset($arr['idlist']) || !is_array($arr['idlist'])) {
- return backarr(0, "请求错误");
- }
- if (!isset($arr['ispass']) || !in_array($arr['ispass'], [2, 1])) {
- return backarr(0, "请求错误");
- }
- $ispass = $arr['ispass'];
- $idlist = $arr['idlist'];
- $passtype = $arr['passtype'];
- $where = ['isactive' => 1];
- switch ($ispass) {
- case 1:
- $where['ispass'] = ['in', [0, 2]];
- break;
- case 2:
- $where['ispass'] = ['in', [0]];
- break;
- }
- $where['id'] = ['in', $idlist];
- $update = [
- 'ispass' => $ispass,
- 'passtime' => date('Y-m-d H:i:s'),
- 'passtype' => $passtype,
- ];
- $row = $this->jobhuntingmodel->updateinfo($where, $update);
- if ($row <= 0) {
- return backarr(0, "修改失败");
- }
- return backarr(1, "修改成功", ['row' => $row, 'idlist' => $idlist, 'ispass' => $ispass]);
- }
- /**
- * pc 后台改数据
- * 20211207
- * wj
- */
- public function updateinfoforadmin($arr)
- {
- if (!isset($arr['id']) || !is_numeric($arr['id'])) {
- return backarr(0, "请求错误");
- }
- $id = $arr['id'];
- $where = ['id' => $id];
- $info = $this->jobhuntingmodel->getInfo($where);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- $updateField = ['info'];
- $upateData = [];
- foreach ($updateField as $key => $value) {
- if (isset($arr[$value])) {
- if ($arr[$value] != $info[$value]) {
- $upateData[$value] = $arr[$value];
- }
- }
- }
- if (empty($upateData)) {
- return backarr(0, "无修改数据");
- }
- $row = $this->jobhuntingmodel->updateinfo($where, $upateData);
- if ($row <= 0) {
- return backarr(0, "修改错误");
- }
- return backarr(1, "修改成功", ['id' => $id]);
- }
- }
|