123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2022-01-18 11:12:23
- * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 16:07:27
- * 微信类
- */
- namespace app\index\logic;
- use app\index\model\companymodel;
- use app\index\model\inventmodel;
- use app\index\model\usermodel;
- class inventlogic extends baselogic
- {
- /**
- * 设置请求数据规则
- * 20220107
- * wj
- */
- protected function setrules()
- {
- $list = [
- 'newinfo' => [
- ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
- ['name' => 'openid', 'title' => 'openid', 'type' => 'string'],
- ],
- 'getlistbywhere' => [
- ['name' => 'companyid', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
- ['name' => 'passstate', 'title' => 'passstate', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
- ['name' => 'activestate', 'title' => 'activestate', 'type' => 'numeric', 'regex' => '/[0|1]{1}/'],
- ['name' => 'title', 'title' => 'title', 'type' => 'string', 'regex' => '/.{2,}/'],
- ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
- ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
- ],
- 'updatebyid' => [
- ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
- ],
- 'getinfobyid' => [
- ['name' => 'id', 'title' => 'companyid', 'require' => true, 'type' => 'numeric'],
- ],
- 'getcountbyparty' => [
- ['name' => 'partyid', 'title' => 'partyid', 'require' => true, 'type' => 'numeric'],
- ],
- ];
- return $list;
- }
- /**
- * 新建数据
- * 20220119
- * wj
- */
- public function newinfo($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $companyid = $arr['companyid'];
- $m_c = new companymodel();
- $cinfo = $m_c->getinfobyid($companyid);
- if (empty($cinfo)) {
- return backarr(0, "企业信息不存在");
- }
- $openid = $arr['openid'];
- $m_u = new usermodel();
- $uinfo = $m_u->getinfobyopenid($openid);
- if (empty($uinfo)) {
- return backarr(0, "用户信息不存在");
- }
- $m_i = new inventmodel();
- $arr['company_id'] = $companyid;
- $arr['create_user_id'] = $uinfo['id'];
- $id = $m_i->insertData($arr);
- if (empty($id)) {
- return backarr(0, "新增失败");
- }
- return backarr(1, "新增成功", ['id' => $id]);
- }
- /**
- * 获取列表数据 根据条件
- * 20220119
- * wj
- */
- public function getlistbywhere($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $companyid = $arr['companyid'];
- $m_c = new companymodel();
- $cinfo = $m_c->getinfobyid($companyid);
- if (empty($cinfo)) {
- return backarr(0, "企业信息不存在");
- }
- $m_i = new inventmodel();
- $where = [['company_id', '=', $companyid]];
- if (isset($arr['title'])) {
- $where[] = ['title', 'like', '%' . $arr['title'] . '%'];
- }
- if (isset($arr['activestate'])) {
- $where[] = ['active_state', '=', $arr['activestate']];
- }
- if (isset($arr['passstate'])) {
- $where[] = ['pass_state', '=', $arr['passstate']];
- }
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $count = $m_i->getList($where, 'count');
- if ($count <= 0) {
- return backarr(0, "无数据");
- }
- $list = $m_i->getList($where, '*', $page, $size);
- return backarr(1, "查询成功", $list);
- }
- /**
- * 修改数据根据id
- * 20220119
- * wj
- */
- public function updatebyid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $id = $arr['id'];
- $m_i = new inventmodel();
- $row = $m_i->updatebyid($id, $arr);
- if (empty($row)) {
- return backarr(0, "修改失败");
- }
- return backarr(1, "获取成功", ['id' => $id]);
- }
- /**
- * 获取数据根据id
- * 20220119
- * wj
- */
- public function getinfobyid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $id = $arr['id'];
- $m_i = new inventmodel();
- $iinfo = $m_i->getinfobyid($id);
- if (empty($iinfo)) {
- return backarr(0, "数据不存在");
- }
- return backarr(1, "获取成功", $iinfo);
- }
- /**
- * 获取本次活动全部职位总数
- * 20220122
- * wj
- */
- public function getcountbyparty($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $partyid = $arr['partyid'];
- $m_i = new inventmodel();
- $count = $m_i->getcountbyparty($partyid);
- return backarr(1, "获取成功", $count);
- }
- }
|