|
@@ -0,0 +1,838 @@
|
|
|
+<?php
|
|
|
+/*
|
|
|
+ * @Author: wang jun
|
|
|
+ * @Date: 2021-09-27 09:02:06
|
|
|
+ * @Last Modified by: wang jun
|
|
|
+ * @Last Modified time: 2021-12-16 17:43:00
|
|
|
+ */
|
|
|
+namespace app\index\logic;
|
|
|
+
|
|
|
+use app\index\model\companymodel;
|
|
|
+use app\index\model\inventv1model;
|
|
|
+use app\index\model\logmodel;
|
|
|
+use app\index\model\userinfomodel;
|
|
|
+use app\index\model\webusermodel;
|
|
|
+use app\index\model\workermodel;
|
|
|
+use think\Db;
|
|
|
+use think\Log;
|
|
|
+
|
|
|
+class inventv1logic
|
|
|
+{
|
|
|
+ private $inventmodel;
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->inventmodel = new inventv1model();
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * edit in 20211025
|
|
|
+ * edit by steelxu
|
|
|
+ * 增加了发布人的通讯信息
|
|
|
+ */
|
|
|
+ public function getinfobyid($id)
|
|
|
+ {
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $info = $this->inventmodel->getInfo($where);
|
|
|
+ if (empty($info)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //edit by steelxu 20211025
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ $uid = $info['createuid'];
|
|
|
+ $uinfo = $t_u->selconinfobyid($uid);
|
|
|
+ $info['coninfo'] = empty($uinfo) ? false : $uinfo;
|
|
|
+ if (!empty($info['releaseid'])) {
|
|
|
+ $m_wu = new webusermodel();
|
|
|
+ $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
|
|
|
+ if (empty($wuinfo)) {
|
|
|
+ $info['release_user'] = '';
|
|
|
+ } else {
|
|
|
+ $info['release_user'] = $wuinfo['user_name'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $info['release_user'] = '';
|
|
|
+ }
|
|
|
+ $m_c = new companymodel();
|
|
|
+ $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
|
|
|
+ if (empty($cinfo)) {
|
|
|
+ $info['is_company'] = 0;
|
|
|
+ $info['company'] = 0;
|
|
|
+ } else {
|
|
|
+ $info['is_company'] = 1;
|
|
|
+ $info['company'] = $cinfo['company'];
|
|
|
+ }
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 20211221
|
|
|
+ * wj
|
|
|
+ * 查询详细 仅列表用
|
|
|
+ */
|
|
|
+ public function getinfobyidforlist($id)
|
|
|
+ {
|
|
|
+ $where = ['id' => $id];
|
|
|
+ $info = $this->inventmodel->getInfo($where);
|
|
|
+ if (empty($info)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ $uid = $info['createuid'];
|
|
|
+ $uinfo = $t_u->selconinfobyid($uid);
|
|
|
+ $info['coninfo'] = empty($uinfo) ? false : $uinfo;
|
|
|
+ if (!empty($info['releaseid'])) {
|
|
|
+ $m_wu = new webusermodel();
|
|
|
+ $wuinfo = $m_wu->getInfo(['id' => $info['releaseid']], ['user_name']);
|
|
|
+ if (empty($wuinfo)) {
|
|
|
+ $info['release_user'] = '';
|
|
|
+ } else {
|
|
|
+ $info['release_user'] = $wuinfo['user_name'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $info['release_user'] = '';
|
|
|
+ }
|
|
|
+ $m_c = new companymodel();
|
|
|
+ $cinfo = $m_c->getInfo(['userid' => $info['createuid'], 'isactive' => 1, 'ispass' => 1]);
|
|
|
+ if (empty($cinfo)) {
|
|
|
+ $info['is_company'] = 0;
|
|
|
+ $info['company'] = 0;
|
|
|
+ } else {
|
|
|
+ $info['is_company'] = 1;
|
|
|
+ $info['company'] = $cinfo['company'];
|
|
|
+ }
|
|
|
+ return $info;
|
|
|
+ }
|
|
|
+ public function insertinfo($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['daysalary'])) {
|
|
|
+ if (!is_numeric($info['daysalary'])) {
|
|
|
+ return backarr(0, "日结工资格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($info['disstr']) || !empty($info['disstr'])) {
|
|
|
+ if (mb_strlen($info['disstr']) > 20) {
|
|
|
+ return backarr(0, "内容简介过长");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $info['code'] = $this->getCode();
|
|
|
+
|
|
|
+ log::info($info); //调试用
|
|
|
+ $id = $this->inventmodel->insertData($info);
|
|
|
+ if (!$id) {
|
|
|
+ return backarr(0, "操作失败");
|
|
|
+ }
|
|
|
+ return backarr(1, "操作成功", ['id' => $id]);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 20211002
|
|
|
+ * edit by steelxu
|
|
|
+ * upade 改为 update
|
|
|
+ */
|
|
|
+
|
|
|
+ public function updateinfobyid($id, $updateData)
|
|
|
+ {
|
|
|
+ $where = ['id' => $id];
|
|
|
+ //记录userlog wj
|
|
|
+ log::info('update:' . $id);
|
|
|
+ log::info($updateData);
|
|
|
+ $m_l = new logmodel();
|
|
|
+ $jsonData = [
|
|
|
+ 'inventid' => $id,
|
|
|
+ 'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
|
|
|
+ 'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
|
|
|
+ ];
|
|
|
+ $logData = [
|
|
|
+ 'type' => '招工修改',
|
|
|
+ 'json' => json_encode($jsonData),
|
|
|
+ 'create_date' => date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ $m_l->savelog(json_encode($logData));
|
|
|
+ $result = $this->inventmodel->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->inventmodel->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, "无数据");
|
|
|
+ }
|
|
|
+ $isadd = true;
|
|
|
+ $isclose = false;
|
|
|
+ if (!$info['isactive']) {
|
|
|
+ return backarr(0, "已关闭");
|
|
|
+ }
|
|
|
+ if ($info['maxconcount'] > 0) {
|
|
|
+ if ($info['concount'] >= $info['maxconcount']) {
|
|
|
+ $isadd = false;
|
|
|
+ $isclose = true;
|
|
|
+ }
|
|
|
+ if ($isadd) {
|
|
|
+ if ($info['concount'] + 1 >= $info['maxconcount']) {
|
|
|
+ $isclose = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($isclose) {
|
|
|
+ $updateData = [
|
|
|
+ 'isactive' => 0,
|
|
|
+ 'unactivetime' => date("y-m-d H:i:s", time()),
|
|
|
+ ];
|
|
|
+ $updateWhere = [
|
|
|
+ 'id' => $id,
|
|
|
+ ];
|
|
|
+ $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
|
|
|
+ if (!$row) {
|
|
|
+ return backarr(0, "自动关闭修改失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($isadd) {
|
|
|
+ $updateWhere = [
|
|
|
+ 'id' => $id,
|
|
|
+ ];
|
|
|
+ $row = $this->inventmodel->incField($updateWhere, 'concount');
|
|
|
+ if (!$row) {
|
|
|
+ return backarr(0, "修改失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return backarr(1, "操作成功");
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 改联系次数
|
|
|
+ * 20211221
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function updatemaxconcountbyid($param)
|
|
|
+ {
|
|
|
+ if (!isset($param['id']) || empty($param['id']) || !isset($param['maxconcount']) || !is_numeric($param['maxconcount'])) {
|
|
|
+ return backarr(0, "请求数据错误");
|
|
|
+ }
|
|
|
+ $id = $param['id'];
|
|
|
+ $maxconcount = $param['maxconcount'];
|
|
|
+ $info = $this->getinfobyid($id);
|
|
|
+ if (empty($info)) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $updateData = [
|
|
|
+ 'maxconcount' => $maxconcount,
|
|
|
+ ];
|
|
|
+ $updateWhere = [
|
|
|
+ 'id' => $id,
|
|
|
+ ];
|
|
|
+ $row = $this->inventmodel->updateinfo($updateWhere, $updateData);
|
|
|
+ if (!$row) {
|
|
|
+ return backarr(0, "修改失败");
|
|
|
+ }
|
|
|
+ return backarr(1, "操作成功", ['id' => $id]);
|
|
|
+ }
|
|
|
+ //根据经纬度获取列表
|
|
|
+ /*
|
|
|
+ * 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,
|
|
|
+ ];
|
|
|
+ if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
|
|
|
+ $where['isactive'] = $arr['isactive'];
|
|
|
+ }
|
|
|
+ $order = 'id desc';
|
|
|
+ if (isset($arr['order']) && !empty($arr['order'])) {
|
|
|
+ $order = $arr['order'];
|
|
|
+ }
|
|
|
+ $list = $this->inventmodel->getList($where, '*', $page, $size, $order);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ 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['town'])) {
|
|
|
+ $where['town'] = ['like', "%" . $arr['town'] . "%"];
|
|
|
+ }
|
|
|
+ if (isset($arr['address'])) {
|
|
|
+ $where['address'] = ['like', "%" . $arr['address'] . "%"];
|
|
|
+ }
|
|
|
+ if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
|
|
|
+ $where['isactive'] = $arr['isactive'];
|
|
|
+ }
|
|
|
+ if (empty($where)) {
|
|
|
+ return backarr(0, "请求数据错误");
|
|
|
+ }
|
|
|
+ //$where['isactive'] = 1; //edit by steelxu 20211003
|
|
|
+ $where['ispass'] = 1;
|
|
|
+ $order = 'id desc';
|
|
|
+ if (isset($arr['order']) && !empty($arr['order'])) {
|
|
|
+ $order = $arr['order'];
|
|
|
+ }
|
|
|
+ $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ return backarr(1, "查询成功", $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 20211002
|
|
|
+ * steelxu5
|
|
|
+ * 获取用户本人发的招工信息
|
|
|
+ */
|
|
|
+ public function getinventlistbycuid($arr)
|
|
|
+ {
|
|
|
+ $crid = $arr['uid'];
|
|
|
+ $list = $this->inventmodel->sellistbyuid($crid);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
|
|
|
+ $where['isactive'] = $arr['isactive'];
|
|
|
+ }
|
|
|
+ //$where['isactive'] = 1;
|
|
|
+ $where['ispass'] = 1;
|
|
|
+ $order = 'id desc';
|
|
|
+ if (isset($arr['order']) && !empty($arr['order'])) {
|
|
|
+ $order = $arr['order'];
|
|
|
+ }
|
|
|
+ $list = $this->inventmodel->getList($where, "*", $page, $size, $order);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ return backarr(1, "查询成功", $list);
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ * 20211007
|
|
|
+ * wj
|
|
|
+ * 根据查询条件返回结果
|
|
|
+ * 目前仅pc后台使用
|
|
|
+ */
|
|
|
+ public function getlistbysearch($arr)
|
|
|
+ {
|
|
|
+ $m_wu = new webusermodel();
|
|
|
+ $where = [];
|
|
|
+ $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
|
|
|
+ $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
|
|
|
+ if (isset($arr['telno'])) {
|
|
|
+ $where['telno'] = $arr['telno'];
|
|
|
+ }
|
|
|
+ if (isset($arr['wname'])) {
|
|
|
+ $where['wname'] = $arr['wname'];
|
|
|
+ }
|
|
|
+ if (isset($arr['code'])) {
|
|
|
+ $where['code'] = $arr['code'];
|
|
|
+ }
|
|
|
+ if (isset($arr['isactive'])) {
|
|
|
+ $where['isactive'] = $arr['isactive'];
|
|
|
+ }
|
|
|
+ if (isset($arr['ispass'])) {
|
|
|
+ $where['ispass'] = $arr['ispass'];
|
|
|
+ }
|
|
|
+ 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->inventmodel->getlistjoinuser($where, "count", $page, $size, $order);
|
|
|
+ if ($count < 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $list = $this->inventmodel->getlistjoinuser($where, "*", $page, $size, $order);
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ /*foreach ($list as $key => &$value) {
|
|
|
+ if (!empty($value['releaseid'])) {
|
|
|
+ $wuinfo = $m_wu->getInfo(['id' => $value['releaseid']], ['user_name']);
|
|
|
+ if (empty($wuinfo)) {
|
|
|
+ $value['release_user'] = '';
|
|
|
+ } else {
|
|
|
+ $value['release_user'] = $wuinfo['user_name'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $value['release_user'] = '';
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ $data = [
|
|
|
+ 'count' => $count ? $count : 0,
|
|
|
+ 'list' => $list,
|
|
|
+ ];
|
|
|
+ return backarr(1, "查询成功", $data);
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * 20211026
|
|
|
+ * 按工种查询
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function getlistbyworktype($arr)
|
|
|
+ {
|
|
|
+ if (!isset($arr['worktype']) || empty($arr['worktype'])) {
|
|
|
+ return backarr(0, "请求数据错误");
|
|
|
+ }
|
|
|
+ if (!isset($arr['city']) || empty($arr['city'])) {
|
|
|
+ $arr['city'] = "天津";
|
|
|
+ }
|
|
|
+ $where = [];
|
|
|
+ $worktype = $arr['worktype'];
|
|
|
+ $where['worktype'] = $worktype;
|
|
|
+ if (isset($arr['city']) && !empty($arr['city'])) {
|
|
|
+ $where['city'] = ['like', '%' . $arr['city'] . '%'];
|
|
|
+ }
|
|
|
+ if (isset($arr['isactive']) && in_array($arr['isactive'], [0, 1]) && is_numeric($arr['isactive'])) {
|
|
|
+ $where['isactive'] = $arr['isactive'];
|
|
|
+ }
|
|
|
+ $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->inventmodel->getList($where, "*", $page, $size, $order);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ return backarr(1, "查询成功", $list);
|
|
|
+ }
|
|
|
+ //代发
|
|
|
+ // 20211101 wj
|
|
|
+ public function insertinfobyrelease($arr)
|
|
|
+ {
|
|
|
+ $fillFiled = ['telno', 'releaseid', 'info', 'worktype', 'disc', 'city', 'address'];
|
|
|
+ foreach ($fillFiled as $key => $value) {
|
|
|
+ if (!isset($arr[$value]) || empty($arr[$value])) {
|
|
|
+ return backarr(0, "请求错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $m_u = new userinfomodel();
|
|
|
+ $m_wu = new webusermodel();
|
|
|
+ $m_w = new workermodel();
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $telno = $arr['telno'];
|
|
|
+ $userinfo = $m_u->getInfo(['telno' => $telno]);
|
|
|
+ if (empty($userinfo)) {
|
|
|
+ $addData = [
|
|
|
+ 'telno' => $telno,
|
|
|
+ 'isactive' => 0,
|
|
|
+ 'createtime' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'platform' => '管理后台',
|
|
|
+ ];
|
|
|
+ $createuid = $m_u->insertData($addData);
|
|
|
+ if (empty($createuid)) {
|
|
|
+ throw new \Exception("会员创建失败");
|
|
|
+ }
|
|
|
+ $winsertInfo = [
|
|
|
+ 'userid' => $createuid,
|
|
|
+ 'telno' => $telno,
|
|
|
+ ];
|
|
|
+ $wid = $m_w->insertData($winsertInfo);
|
|
|
+ if (empty($wid)) {
|
|
|
+ throw new \Exception("会员工人信息创建失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (1 != $userinfo['isright']) {
|
|
|
+ throw new \Exception("发布状态为无效");
|
|
|
+ }
|
|
|
+ $createuid = $userinfo['id'];
|
|
|
+ }
|
|
|
+ $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
|
|
|
+ if (empty($wuinfo)) {
|
|
|
+ throw new \Exception("用户信息错误");
|
|
|
+ }
|
|
|
+ unset($arr['telno']);
|
|
|
+ $arr['createuid'] = $createuid;
|
|
|
+ if (!isset($arr['createdate']) || empty($arr['createdate'])) {
|
|
|
+ $arr['createdate'] = date('Y-m-d H:i:s', time());
|
|
|
+ }
|
|
|
+ if (isset($arr['daysalary'])) {
|
|
|
+ if (!is_numeric($arr['daysalary'])) {
|
|
|
+ throw new \Exception("日结工资格式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $arr['code'] = $this->getCode();
|
|
|
+ $arr['ispass'] = 1;
|
|
|
+ $arr['passtime'] = date('Y-m-d H:i:s');
|
|
|
+ $arr['passtype'] = 1;
|
|
|
+ if (isset($arr['info']) && !empty($arr['info'])) {
|
|
|
+ if (!isset($arr['disstr']) || empty($arr['disstr'])) {
|
|
|
+ $arr['disstr'] = mb_substr($arr['info'], 0, 10);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $id = $this->inventmodel->insertData($arr);
|
|
|
+ if (!$id) {
|
|
|
+ throw new \Exception("操作失败");
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return backarr(1, "操作成功", ['id' => $id]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return backarr(0, $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private function getCode()
|
|
|
+ {
|
|
|
+ $code = 'I' . date('YmdHis');
|
|
|
+ return $code;
|
|
|
+ }
|
|
|
+ //修改
|
|
|
+ // 20211102 wj
|
|
|
+ public function updateinventfromadmin($arr)
|
|
|
+ {
|
|
|
+ $fillFiled = ['id', 'telno', 'releaseid', 'disstr', 'info', 'worktype', 'disc', 'city', 'address'];
|
|
|
+ foreach ($fillFiled as $key => $value) {
|
|
|
+ if (!isset($arr[$value]) || empty($arr[$value])) {
|
|
|
+ return backarr(0, "请求错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $m_u = new userinfomodel();
|
|
|
+ $m_wu = new webusermodel();
|
|
|
+ $m_i = new inventv1model();
|
|
|
+ $m_w = new workermodel();
|
|
|
+ $inventInfo = $m_i->getInfo(['id' => $arr['id']]);
|
|
|
+ if (empty($inventInfo)) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $wuinfo = $m_wu->getInfo(['id' => $arr['releaseid']]);
|
|
|
+ if (empty($wuinfo)) {
|
|
|
+ throw new \Exception("用户信息错误");
|
|
|
+ }
|
|
|
+ $id = $inventInfo['id'];
|
|
|
+ $telno = $arr['telno'];
|
|
|
+ $userinfo = $m_u->getInfo(['telno' => $telno]);
|
|
|
+ if (empty($userinfo)) {
|
|
|
+ $addData = [
|
|
|
+ 'telno' => $telno,
|
|
|
+ 'isactive' => 0,
|
|
|
+ 'createtime' => date('Y-m-d H:i:s', time()),
|
|
|
+ 'platform' => '管理后台',
|
|
|
+ ];
|
|
|
+ $createuid = $m_u->insertData($addData);
|
|
|
+ if (empty($createuid)) {
|
|
|
+ throw new \Exception("会员创建失败");
|
|
|
+ }
|
|
|
+ $workerAddData = [
|
|
|
+ 'userid' => $createuid,
|
|
|
+ 'telno' => $telno,
|
|
|
+ ];
|
|
|
+ $wid = $m_w->insertData($workerAddData);
|
|
|
+ if (empty($wid)) {
|
|
|
+ throw new \Exception("工人信息创建失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $createuid = $userinfo['id'];
|
|
|
+ }
|
|
|
+ $arr['createuid'] = $createuid;
|
|
|
+ $updateData = [];
|
|
|
+ $updateField = ['createuid', 'city', 'disc', 'address', 'disstr', 'worktypeid', 'worktype', 'daysalary', 'info', 'town'];
|
|
|
+ foreach ($updateField as $key => $value) {
|
|
|
+ if ($arr[$value] !== $inventInfo[$value]) {
|
|
|
+ $updateData[$value] = $arr[$value];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (empty($inventInfo['code'])) {
|
|
|
+ $updateData['code'] = $this->getCode();
|
|
|
+ }
|
|
|
+ $row = $this->inventmodel->updateinfo(['id' => $id], $updateData);
|
|
|
+ if (empty($row)) {
|
|
|
+ throw new \Exception("需改失败");
|
|
|
+ }
|
|
|
+ //修改成功 记录log
|
|
|
+ log::info('update:' . $id);
|
|
|
+ log::info($updateData);
|
|
|
+ $m_l = new logmodel();
|
|
|
+ $jsonData = [
|
|
|
+ 'inventid' => $id,
|
|
|
+ 'webuserid' => isset($updateData['releaseid']) ? $updateData['releaseid'] : '',
|
|
|
+ 'createuid' => isset($updateData['createuid']) ? $updateData['createuid'] : '',
|
|
|
+ ];
|
|
|
+ $logData = [
|
|
|
+ 'type' => '招工修改',
|
|
|
+ 'json' => json_encode($jsonData),
|
|
|
+ 'create_date' => date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ $m_l->savelog(json_encode($logData));
|
|
|
+ Db::commit();
|
|
|
+ return backarr(1, "操作成功", ['id' => $id]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return backarr(0, $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /***
|
|
|
+ * px端审核用
|
|
|
+ * 未审核 审核失败-》 审核成功
|
|
|
+ * 未审核->审核失败
|
|
|
+ * 20211117
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function updateispassbyid($arr)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (!isset($arr['idlist']) || !is_array($arr['idlist'])) {
|
|
|
+ return backarr(0, "请求错误1");
|
|
|
+ }
|
|
|
+ if (!isset($arr['ispass']) || !in_array($arr['ispass'], [2, 1])) {
|
|
|
+ return backarr(0, "请求错误");
|
|
|
+ }
|
|
|
+ $ispass = $arr['ispass'];
|
|
|
+ $idlist = $arr['idlist'];
|
|
|
+ $m_i = new inventv1model();
|
|
|
+ $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' => 2,
|
|
|
+ ];
|
|
|
+ $row = $m_i->updateinfo($where, $update);
|
|
|
+ if ($row <= 0) {
|
|
|
+ return backarr(0, "修改失败");
|
|
|
+ }
|
|
|
+ return backarr(1, "修改成功", ['row' => $row, 'idlist' => $idlist, 'ispass' => $ispass]);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据类型获取列表
|
|
|
+ * 20211213
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function getlistbywhere($arr)
|
|
|
+ {
|
|
|
+ //字段转译 key 请求字段 value 查询使用字段
|
|
|
+ $fileds = [
|
|
|
+ 'a' => 'address', //用字符|分割
|
|
|
+ 'lng' => 'lng',
|
|
|
+ 'lat' => 'lat',
|
|
|
+ 'wt' => 'worktype',
|
|
|
+ 'r' => 'radii',
|
|
|
+ 'od' => 'orderdaysalary', //order daysalary desc
|
|
|
+ 'active' => 'isactive',
|
|
|
+ ];
|
|
|
+ $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
|
|
|
+ $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
|
|
|
+ $useValue = [];
|
|
|
+ $pattern = '/[\'+%-]+/';
|
|
|
+ foreach ($fileds as $key => $value) {
|
|
|
+ if (isset($arr[$key]) && !empty($arr[$key]) && is_string($arr[$key])) {
|
|
|
+ $str = preg_match_all($pattern, $arr[$key]);
|
|
|
+ if ($str) {
|
|
|
+ return backarr(0, "查询请求数据错误");
|
|
|
+ }
|
|
|
+ $useValue[$value] = $arr[$key];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $where = [];
|
|
|
+ if (isset($useValue['address']) && !empty($useValue['address'])) {
|
|
|
+ $addressArr = explode('|', $useValue['address']);
|
|
|
+ $searchAddress = [
|
|
|
+ 'city' => isset($addressArr[0]) ? $addressArr[0] : '',
|
|
|
+ 'disc' => isset($addressArr[1]) ? $addressArr[1] : '',
|
|
|
+ 'town' => isset($addressArr[2]) ? $addressArr[2] : '',
|
|
|
+ 'address' => isset($addressArr[3]) ? $addressArr[3] : '',
|
|
|
+ ];
|
|
|
+ $searchAddress = array_filter($searchAddress);
|
|
|
+ if (!empty($searchAddress)) {
|
|
|
+ $where = array_merge($where, $searchAddress);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($useValue['orderdaysalary']) && !empty($useValue['orderdaysalary'])) {
|
|
|
+ $useValue['orderdaysalary'] = true;
|
|
|
+ } else {
|
|
|
+ $useValue['orderdaysalary'] = false;
|
|
|
+ }
|
|
|
+ if (isset($useValue['radii']) && is_numeric($useValue['radii']) && !empty($useValue['radii'])) {
|
|
|
+ //有经纬度
|
|
|
+ $fillFidle = ['lng', 'lat'];
|
|
|
+ foreach ($fillFidle as $key => $value) {
|
|
|
+ if (isset($useValue[$value]) && is_numeric($useValue[$value]) && !empty($useValue[$value])) {
|
|
|
+ $where[$value] = $useValue[$value];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $where['radii'] = $useValue['radii'];
|
|
|
+ }
|
|
|
+ if (isset($useValue['worktype']) && !empty($useValue['worktype'])) {
|
|
|
+ $where['worktype'] = $useValue['worktype'];
|
|
|
+ }
|
|
|
+ if (isset($useValue['isactive']) && in_array($useValue['isactive'], [0, 1]) && is_numeric($useValue['isactive'])) {
|
|
|
+ $where['isactive'] = $useValue['isactive'];
|
|
|
+ }
|
|
|
+ //$where['isactive'] = 1;
|
|
|
+ $where['ispass'] = 1;
|
|
|
+
|
|
|
+ $order = 'id desc'; //默认时间倒序
|
|
|
+ if ($useValue['orderdaysalary']) {
|
|
|
+ $order = 'daysalary desc'; //工资倒序
|
|
|
+ }
|
|
|
+ $m_i = new inventv1model();
|
|
|
+ $list = $m_i->getlistbymultiplecondition($where, $page, $size, $order);
|
|
|
+ if (count($list) <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $t_u = new userinfomodel();
|
|
|
+ foreach ($list as $key => &$invent) {
|
|
|
+ $list[$key] = $this->getinfobyidforlist($invent['id']);
|
|
|
+ }
|
|
|
+ return backarr(1, "查询成功", $list);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取一定时间内无联系数量 默认5分钟
|
|
|
+ * 20211222
|
|
|
+ * wj
|
|
|
+ */
|
|
|
+ public function getnocalldata($arr)
|
|
|
+ {
|
|
|
+ $page = isset($arr['page']) && !empty($arr['page']) && is_numeric($arr['page']) ? $arr['page'] : 1;
|
|
|
+ $size = isset($arr['size']) && !empty($arr['size']) && is_numeric($arr['size']) ? $arr['size'] : 10;
|
|
|
+ $where = [];
|
|
|
+ if (isset($arr['wname']) && !empty($arr['wname']) && is_string($arr['wname'])) {
|
|
|
+ $where['wname'] = $arr['wname'];
|
|
|
+ }
|
|
|
+ if (isset($arr['telno']) && !empty($arr['telno']) && is_numeric($arr['telno'])) {
|
|
|
+ $where['telno'] = $arr['telno'];
|
|
|
+ }
|
|
|
+ $m_i = new inventv1model();
|
|
|
+ //获取5分钟内无联系招工
|
|
|
+ $count = $m_i->getnocalldata(5, $where, true);
|
|
|
+ if ($count <= 0) {
|
|
|
+ return backarr(0, "无数据");
|
|
|
+ }
|
|
|
+ $list = $m_i->getnocalldata(5, $where, false, $page, $size);
|
|
|
+ $data = [
|
|
|
+ 'count' => $count,
|
|
|
+ 'list' => $list,
|
|
|
+ ];
|
|
|
+ return backarr(1, "查询成功", $data);
|
|
|
+ }
|
|
|
+}
|