123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?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' => 'idlist', 'title' => 'idlist', '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['idlist'];
- 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)
- {
- $arr = $this->filterarray($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'];
- if (count($createdate) == count(array_filter($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);
- $data = [
- 'list' => $list,
- 'total' => $count,
- ];
- return backarr(1, "查询成功", $data);
- }
- /**
- * 根据id获取企业信息
- * 20220209
- * wj
- */
- public function getinfobyid($arr)
- {
- $arr = $this->filterarray($arr);
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $where = [];
- $id = $arr['id'];
- $where['id'] = $id;
- $m_c = new companymodel();
- $info = $m_c->getInfo($where);
- if (empty($info)) {
- return backarr(0, "无数据");
- }
- $info = $this->formatinfo($info);
- return backarr(1, "success", $info);
- }
- /**
- * 格式化企业信息
- * 20220209
- * wj
- */
- private function formatinfo($info)
- {
- if (isset($info['enterprisephoto']) && is_string($info['enterprisephoto'])) {
- if (!empty($info['enterprisephoto'])) {
- $jsonArr = json_decode($info['enterprisephoto'], true);
- /*$pregstr = '/^(http:\/\/*)|(https:\/\/*)/';
- foreach ($jsonArr as $key => $value) {
- $matchResult = preg_match($pregstr, $value, $matchArr);
- if ($matchResult) {
- foreach ($matchArr as $mkey => $mvalue) {
- $jsonArr[$key] = str_replace($mvalue, "", $value);
- }
- }
- }*/
- $info['enterprisephoto'] = $jsonArr;
- }
- }
- return $info;
- }
- }
|