123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?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\admin\logic;
- use app\admin\model\companymodel;
- use think\facade\Log;
- class companylogic extends baselogic
- {
- /**
- * 设置请求数据规则
- * 20220107
- * wj
- */
- protected function setrules()
- {
- $list = [
- 'auditcompany' => [
- ['name' => 'ids', 'title' => 'id', 'require' => true, 'type' => 'array'],
- ['name' => 'ispass', 'title' => 'ispass', 'require' => true, 'type' => 'numeric', 'regex' => '/[1|2]{1}/'],
- ],
- 'getlistbywhere' => [
- ['name' => 'ispass', 'title' => 'ispass', 'type' => 'numeric', 'regex' => '/[0|1|2]{1}/'],
- ['name' => 'companyname', 'title' => 'companyname', 'type' => 'string'],
- ['name' => 'createdate', 'title' => 'createdate', 'type' => 'array'],
- ['name' => 'page', 'title' => 'page', 'type' => 'numeric'],
- ['name' => 'size', 'title' => 'size', 'type' => 'numeric'],
- ],
- ];
- return $list;
- }
- /**
- * 审核公司
- * 20220208
- * wj
- */
- public function auditcompany($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $ids = $arr['ids'];
- if (is_string($ids)) {
- $ids = [$ids];
- }
- $ispass = $arr['ispass'];
- $m_c = new companymodel();
- $successIds = [];
- foreach ($ids as $key => $value) {
- $where = ['id' => $value];
- $info = $m_c->getInfo($where);
- if (empty($info)) {
- log::error("company_id " . $value . " 无对应企业");
- continue;
- }
- if ($ispass != $info['ispass']) {
- $successIds[] = $value;
- $update = ['ispass' => $ispass];
- $m_c->updateinfo($where, $update);
- }
- }
- $data = [
- 'successIds' => $successIds,
- ];
- return backarr(1, "操作成功", $data);
- }
- /**
- * 获取公司列表
- * 20220208
- * wj
- */
- public function getlistbywhere($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $where = [];
- if (isset($arr['ispass'])) {
- $where[] = ['ispass', '=', $arr['ispass']];
- }
- if (isset($arr['companyname'])) {
- $where[] = ['companyname', 'like', '%' . $arr['companyname'] . '%'];
- }
- if (isset($arr['createdate'])) {
- $createdate = $arr['createdate'];
- $where[] = ['create_time', '>=', $createdate[0]];
- $where[] = ['create_time', '<=', $createdate[1]];
- }
- $m_c = new companymodel();
- $count = $m_c->getList($where, 'count');
- if ($count <= 0) {
- return backarr(0, "无数据");
- }
- $page = isset($arr['page']) && !empty($arr['page']) ? $arr['page'] : 1;
- $size = isset($arr['size']) && !empty($arr['size']) ? $arr['size'] : 10;
- $list = $m_c->getList($where, '*', $page, $size);
- return backarr(1, "查询成功", $list);
- }
- }
|