123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2022-01-18 11:12:23
- * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 15:51:59
- * 微信类
- */
- namespace app\index\logic;
- use app\index\model\companymodel;
- use app\index\model\inventmodel;
- use app\index\model\usermodel;
- class companylogic extends baselogic
- {
- /**
- * 设置请求数据规则
- * 20220107
- * wj
- */
- protected function setrules()
- {
- $list = [
- 'newinfo' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ['name' => 'organization_code', 'title' => 'organization_code', 'type' => 'string'],
- ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'],
- ],
- 'getinfobyid' => [
- ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
- ],
- 'updatebyid' => [
- ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
- ],
- 'getinfowitchinventbyid' => [
- ['name' => 'id', 'title' => 'id', 'require' => true, 'type' => 'numeric'],
- ['name' => 'activestate', 'title' => 'activestate', 'regex' => '/[0|1|2]{1}/'],
- ],
- ];
- return $list;
- }
- /**
- * 新建信息
- * wj
- * 20220118
- */
- public function newinfo($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $m_u = new usermodel();
- $m_c = new companymodel();
- $openid = $arr['openid'];
- $info = $m_u->getinfobyopenid($openid);
- if (empty($info)) {
- return backarr(0, "用户不存在");
- }
- if (empty($info['is_company'])) {
- return backarr(0, "非企业用户");
- }
- unset($arr['openid']);
- $where = [];
- $cinfo = [];
- if (isset($arr['organization_code'])) {
- $where['organization_code'] = $arr['organization_code'];
- }
- if (isset($arr['companyname'])) {
- $where['companyname'] = $arr['companyname'];
- }
- if (empty(!$where)) {
- $cinfo = $m_c->getinfo($where, ['id']);
- }
- if (empty($cinfo)) {
- $id = $m_c->insertData($arr);
- } else {
- $id = $cinfo['id'];
- }
- $updateDate = ['company_id' => $id];
- $row = $m_u->updatebyid($info['id'], $updateDate);
- return backarr(1, "新增成功", ['id' => $id]);
- }
- /**
- * 根据id获取企业信息
- * wj
- * 20220118
- */
- public function getinfobyid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $id = $arr['id'];
- $m_c = new companymodel();
- $info = $m_c->getinfobyid($id);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- return backarr(1, "获取成功", $info);
- }
- /**
- * 根据id获取企业信息包括岗位
- * wj
- * 20220119
- */
- public function getinfowitchinventbyid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $id = $arr['id'];
- $m_c = new companymodel();
- $info = $m_c->getinfobyid($id);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- $m_i = new inventmodel();
- $where = ['company_id' => $info['id']];
- if (isset($arr['activestate'])) {
- $where['active_state'] = $arr['activestate'];
- }
- $ilist = $m_i->getlist($where, "*", 1, 0);
- $info['invent_list'] = $ilist;
- return backarr(1, "获取成功", $info);
- }
- /**
- * 根据id修改企业信息
- * wj
- * 20220118
- */
- public function updatebyid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $id = $arr['id'];
- unset($arr['id']);
- $m_c = new companymodel();
- $row = $m_c->updatebyid($id, $arr);
- if (empty($row)) {
- return backarr(0, "修改失败");
- }
- return backarr(1, "获取成功", ['id' => $id]);
- }
- /**
- * 获取本次活动全部公司总数
- * 20220122
- * wj
- */
- public function getcountbyparty($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $partyid = $arr['partyid'];
- $m_c = new companymodel();
- $count = $m_c->getcountbyparty($partyid);
- return backarr(1, "获取成功", $count);
- }
- }
|