wang jun 3 lat temu
rodzic
commit
faf0e22f7c

+ 0 - 0
application/index/controller/Company.php


+ 0 - 0
application/index/controller/Invent.php


+ 0 - 0
application/index/controller/Resume.php


+ 68 - 0
application/index/controller/User.php

@@ -0,0 +1,68 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 10:57:14
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-18 15:31:24
+ * 微信类
+ */
+namespace app\index\controller;
+
+use app\index\logic\userlogic;
+use think\Controller;
+
+class User extends Base
+{
+    /**
+     * 设置请求数据规则
+     * 20220107
+     * wj
+     */
+    protected function setrules()
+    {
+        $list = [
+            'newinfo' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+            'realauth' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+            'authcompany' => [
+                ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
+            ],
+        ];
+        return $list;
+    }
+    public function newinfo()
+    {
+        $param = request()->param();
+        $l_u = new userlogic();
+        $id = $l_u->newinfo($param);
+        if (empty($id)) {
+            return backjson(0, "新增失败");
+        }
+        return backjson(1, "新增成功", ['id' => $id]);
+    }
+    public function realauth()
+    {
+        $param = request()->param();
+        $l_u = new userlogic();
+        $result = $l_u->realauthbyopenid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        } else {
+            return backjson(200, $result['data']);
+        }
+    }
+    public function authcompany()
+    {
+        $param = request()->param();
+        $l_u = new userlogic();
+        $result = $l_u->updateiscompanybyopenid($param);
+        if (1 != $result['status']) {
+            return backjson(0, $result['msg']);
+        } else {
+            return backjson(200, $result['data']);
+        }
+    }
+}

+ 113 - 0
application/index/logic/userlogic.php

@@ -0,0 +1,113 @@
+<?php
+/*
+ * @Author: wang jun
+ * @Date: 2022-01-18 11:12:23
+ * @Last Modified by: wang jun
+ * @Last Modified time: 2022-01-18 15:46:20
+ * 微信类
+ */
+namespace app\index\logic;
+
+use app\index\model\usermodel;
+
+class userlogic
+{
+    /**
+     * 新建用户
+     * wj
+     * 20220118
+     */
+    public function newinfo($arr)
+    {
+        $m_u = new usermodel();
+        $id = $m_u->insertData($arr);
+        return $id;
+    }
+    /**
+     * 实名认证
+     * wj
+     * 20220118
+     */
+    public function realauthbyopenid($arr)
+    {
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $info = $m_u->getinfobyopenid($openid);
+        if (empty($info)) {
+            return backarr(0, '无用户');
+        }
+        $id = $info['id'];
+        if (isset($arr['sfzid']) && !empty($arr['sfzid']) && is_string($arr['sfzid'])) {
+            $sfzid = $arr['sfzid'];
+            if ($info['sfzid'] != $sfzid) {
+                $hassfzid = $this->hassfzid($sfzid);
+                if ($hassfzid) {
+                    return backarr(0, '身份证已存在');
+                }
+            }
+        }
+        if (isset($arr['telno']) && !empty($arr['telno']) && is_string($arr['telno'])) {
+            if (!isMoblid($arr['telno'])) {
+                return backarr(0, '手机号格式错误');
+            }
+            $telno = $arr['telno'];
+            if ($info['telno'] != $telno) {
+                $hastelno = $this->hastelno($telno);
+                if ($hastelno) {
+                    return backarr(0, '手机号已存在');
+                }
+            }
+        }
+        $updateField = ['user_name', 'telno', 'age', 'gender', 'sfzid', 'email'];
+        $updateData = [];
+        foreach ($updateField as $key => $value) {
+            if (isset($arr[$value])) {
+                if ($info[$value] != $arr[$value]) {
+                    $updateData[$value] = $arr[$value];
+                }
+            }
+        }
+        if (empty($updateData)) {
+            return backarr(0, "无修改数据");
+        }
+        $row = $m_u->updatebyid($id, $updateData);
+        if (empty($row)) {
+            return backarr(0, "修改失败");
+        }
+        return backarr(1, "修改成功", ['id' => $id]);
+    }
+    /**
+     * 验证身份证号
+     */
+    private function hassfzid($sfzid)
+    {
+        $m_u = new usermodel();
+        $info = $m_u->getinfobysfzid($sfzid);
+        return !empty($info);
+    }
+    /**
+     * 验证手机号
+     */
+    private function hastelno($telno)
+    {
+        $m_u = new usermodel();
+        $info = $m_u->getinfobytelno($telno);
+        return !empty($info);
+    }
+    /**
+     * 修改iscompany
+     * wj
+     * 20220118
+     */
+    public function updateiscompanybyopenid($arr)
+    {
+        $openid = $arr['openid'];
+        $m_u = new usermodel();
+        $info = $m_u->getinfobyopenid($openid);
+        if (empty($info)) {
+            return backarr(0, '无用户');
+        }
+        $m_u->updateiscompanybyopenid($openid, 1);
+        return backarr(1, '修改成功', ['id' => $info['id']]);
+    }
+}

+ 47 - 2
application/index/model/usermodel.php

@@ -3,7 +3,7 @@
  * @Author: wang jun
  * @Date: 2022-01-18 09:43:33
  * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-18 11:08:11
+ * @Last Modified time: 2022-01-18 15:49:13
  */
 namespace app\index\model;
 
@@ -68,7 +68,29 @@ class usermodel extends Model
     public function getinfobyopenid($openid)
     {
         $where = ['openid' => $openid];
-        $info = $this->where($where);
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /**
+     * 根据openid获取信息
+     * wj
+     * 20220118
+     */
+    public function getinfobysfzid($sfzid)
+    {
+        $where = ['sfzid' => $sfzid];
+        $info = $this->where($where)->find();
+        return $info;
+    }
+    /**
+     * 根据telno获取信息
+     * wj
+     * 20220118
+     */
+    public function getinfobytelno($telno)
+    {
+        $where = ['telno' => $telno];
+        $info = $this->where($where)->find();
         return $info;
     }
     /**
@@ -83,4 +105,27 @@ class usermodel extends Model
         $row = $this->where($where)->update($updateData);
         return $row;
     }
+    /**
+     * 根据openid获取修改iscompany
+     * wj
+     * 20220118
+     */
+    public function updateiscompanybyopenid($openid, $iscompany = 1)
+    {
+        $where = ['openid' => $openid];
+        $updateData = ['is_company' => $iscompany];
+        $row = $this->where($where)->update($updateData);
+        return $row;
+    }
+    /**
+     * 根据openid获取修改iscompany
+     * wj
+     * 20220118
+     */
+    public function updatebyid($id, $updateData)
+    {
+        $where = ['id' => $id];
+        $row = $this->where($where)->update($updateData);
+        return $row;
+    }
 }

+ 22 - 22
config/database.php

@@ -11,51 +11,51 @@
 
 return [
     // 数据库类型
-    'type'            => 'mysql',
+    'type' => 'mysql',
     // 服务器地址
-    'hostname'        => '127.0.0.1',
+    'hostname' => '42.193.106.113',
     // 数据库名
-    'database'        => '',
+    'database' => 'recruit',
     // 用户名
-    'username'        => 'root',
+    'username' => 'root',
     // 密码
-    'password'        => '',
+    'password' => 'zhonghui0123',
     // 端口
-    'hostport'        => '',
+    'hostport' => '3306',
     // 连接dsn
-    'dsn'             => '',
+    'dsn' => '',
     // 数据库连接参数
-    'params'          => [],
+    'params' => [],
     // 数据库编码默认采用utf8
-    'charset'         => 'utf8',
+    'charset' => 'utf8mb4',
     // 数据库表前缀
-    'prefix'          => '',
+    'prefix' => '',
     // 数据库调试模式
-    'debug'           => true,
+    'debug' => true,
     // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
-    'deploy'          => 0,
+    'deploy' => 0,
     // 数据库读写是否分离 主从式有效
-    'rw_separate'     => false,
+    'rw_separate' => false,
     // 读写分离后 主服务器数量
-    'master_num'      => 1,
+    'master_num' => 1,
     // 指定从服务器序号
-    'slave_no'        => '',
+    'slave_no' => '',
     // 自动读取主库数据
-    'read_master'     => false,
+    'read_master' => false,
     // 是否严格检查字段是否存在
-    'fields_strict'   => true,
+    'fields_strict' => true,
     // 数据集返回类型
-    'resultset_type'  => 'array',
+    'resultset_type' => 'array',
     // 自动写入时间戳字段
-    'auto_timestamp'  => false,
+    'auto_timestamp' => false,
     // 时间字段取出后的默认时间格式
     'datetime_format' => 'Y-m-d H:i:s',
     // 是否需要进行SQL性能分析
-    'sql_explain'     => false,
+    'sql_explain' => false,
     // Builder类
-    'builder'         => '',
+    'builder' => '',
     // Query类
-    'query'           => '\\think\\db\\Query',
+    'query' => '\\think\\db\\Query',
     // 是否需要断线重连
     'break_reconnect' => false,
     // 断线标识字符串