wang jun %!s(int64=3) %!d(string=hai) anos
pai
achega
585302c9cb

+ 60 - 0
application/admin/controller/Home.php

@@ -0,0 +1,60 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2021-11-09 09:39:05
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-18 13:29:22
+ */
+namespace app\admin\controller;
+
+use app\admin\logic\homelogic;
+use think\Controller;
+
+class Home extends AdminBase
+{
+    /**
+     * 获取活动信息
+     * 20220211
+     * wj
+     */
+    public function getpartyinfo()
+    {
+        $param = request()->param();
+        $l_h = new homelogic();
+        $result = $l_h->getpartyinfo($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
+    /**
+     * 获取企业信息
+     * 20220211
+     * wj
+     */
+    public function getcompanyinfo()
+    {
+        $param = request()->param();
+        $l_h = new homelogic();
+        $result = $l_h->getcompanyinfo($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
+    /**
+     * 获取用户信息
+     * 20220211
+     * wj
+     */
+    public function getuserinfo()
+    {
+        $param = request()->param();
+        $l_h = new homelogic();
+        $result = $l_h->getuserinfo($param);
+        if (1 != $result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(200, $result['msg'], $result['data']);
+    }
+}

+ 121 - 0
application/admin/logic/homelogic.php

@@ -0,0 +1,121 @@
+<?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 app\admin\model\partymodel;
+use app\admin\model\partyrecordmodel;
+use app\admin\model\usermodel;
+
+class homelogic extends baselogic
+{
+    /**
+     * 设置请求数据规则
+     * 20220107
+     * wj
+     */
+    protected function setrules()
+    {
+        $list = [];
+        return $list;
+    }
+    /**
+     * 获取活动信息
+     * 20220211
+     * wj
+     */
+    public function getpartyinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $m_p = new partymodel();
+        //总数
+        $count = $m_p->getList([], 'count');
+        //当前活动
+        $time = date('Y-m-d H:i:s');
+        $where = [
+            ['isactive', '=', 1],
+            ['start_time', '<=', $time],
+            ['end_time', '>=', $time],
+        ];
+        $info = $m_p->getInfo($where, ['name', 'id']);
+        //报名企业数量
+        $wherePr = [
+            'party_id' => $info['id'],
+        ];
+        $m_p = new partyrecordmodel();
+        $prcount = $m_p->getListjoincompany($wherePr, 'count');
+        $data = [
+            'count' => $count,
+            'info' => $info,
+            'prcount' => $prcount,
+        ];
+        return backarr(1, '查询成功', $data);
+    }
+    /**
+     * 获取公司信息
+     * 20220211
+     * wj
+     */
+    public function getcompanyinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $m_c = new companymodel();
+        //总数
+        $count = $m_c->getList([], 'count');
+        //获取分组
+        $where0 = ['ispass' => 0];
+        $where1 = ['ispass' => 1];
+        $where2 = ['ispass' => 2];
+        $count0 = $m_c->getList($where0, 'count');
+        $count1 = $m_c->getList($where1, 'count');
+        $count2 = $m_c->getList($where2, 'count');
+        $data = [
+            'count' => empty($count) ? 0 : $count,
+            'count0' => empty($count0) ? 0 : $count0,
+            'count1' => empty($count1) ? 0 : $count1,
+            'count2' => empty($count2) ? 0 : $count2,
+        ];
+        return backarr(1, '查询成功', $data);
+    }
+    /**
+     * 获取用户信息
+     * 20220211
+     * wj
+     */
+    public function getuserinfo($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $m_u = new usermodel();
+        //总数
+        $count = $m_u->getList([], 'count');
+        //获取分组
+        $where1 = ['is_active' => 1];
+        $where2 = ['company_id' => 1];
+        $count1 = $m_u->getList($where1, 'count');
+        $count2 = $m_u->getList($where2, 'count');
+        $count1 = empty($count1) ? 0 : $count1;
+        $count2 = empty($count2) ? 0 : $count2;
+        $data = [
+            'count' => empty($count) ? 0 : $count,
+            'count_isactive_0' => $count - $count1,
+            'count_isactive_1' => $count1,
+            /*'couunt_iscompany_0' => $count - $count2,
+        'couunt_iscompany_1' => $count2,*/
+        ];
+        return backarr(1, '查询成功', $data);
+    }
+}

+ 107 - 0
application/admin/model/partyrecordmodel.php

@@ -0,0 +1,107 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 16:37:16
+ */
+namespace app\admin\model;
+
+use think\Model;
+
+class partyrecordmodel extends Model
+{
+    protected $table = 't_partyrecord';
+
+    public function insertData($data)
+    {
+        if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
+            $data['create_time'] = date("Y-m-d H:i:s");
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+    /**
+     * 获取列表 join company
+     * 20220209
+     * wj
+     */
+    public function getListjoincompany($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $useWhere = ['c.ispass' => 1];
+        if (isset($where['party_id'])) {
+            $useWhere['pr.party_id'] = $where['party_id'];
+        }
+        $sqlObj = $this->alias('pr')->join('t_company c', 'c.id = pr.company_id')->where($useWhere);
+        $order = "pr.id desc";
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}

+ 82 - 0
application/admin/model/usermodel.php

@@ -0,0 +1,82 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 09:43:33
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-19 15:42:39
+ */
+namespace app\admin\model;
+
+use think\Model;
+
+class usermodel extends Model
+{
+    protected $table = 't_users';
+
+    public function insertData($data)
+    {
+        if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
+            $data['create_time'] = date("Y-m-d H:i:s");
+        }
+        $data = $this->formatData($data);
+        if (empty($data)) {
+            return false;
+        }
+
+        $id = $this->insertGetId($data);
+        return empty($id) ? false : $id;
+    }
+    /**
+     * 校验入库数据
+     * 20220119
+     */
+    private function formatData($data)
+    {
+        $useData = [];
+        $fields = $this->getTableFields();
+        foreach ($data as $key => $value) {
+            if (in_array($key, $fields)) {
+                $useData[$key] = $value;
+            }
+        }
+        return $useData;
+    }
+    public function getInfo($where, $field = "*", $row = true)
+    {
+        $info = $this->field($field)->where($where);
+        if ($row) {
+            $info = $info->find();
+        } else {
+            $info = $info->select();
+        }
+        return empty($info) ? false : $info;
+    }
+
+    public function updateinfo($where, $updateData)
+    {
+        $row = $this->where($where)->update($updateData);
+        return empty($row) ? false : $row;
+    }
+
+    public function deleteinfo($where)
+    {
+        $row = $this->where($where)->delete();
+        return empty($row) ? false : $row;
+    }
+
+    public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
+    {
+        $sqlObj = $this->where($where);
+        if ("count" != $field) {
+            $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
+            if ($row) {
+                $data = $sqlObj->find();
+            } else {
+                $data = $sqlObj->select();
+            }
+        } else {
+            $data = $sqlObj = $sqlObj->count();
+        }
+        return $data;
+    }
+}