123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2022-01-18 11:12:23
- * @Last Modified by: wang jun
- * @Last Modified time: 2022-01-19 10:24:58
- * 微信类
- */
- namespace app\index\logic;
- use app\index\model\usermodel;
- class userlogic extends baselogic
- {
- /**
- * 设置请求数据规则
- * 20220107
- * wj
- */
- protected function setrules()
- {
- $list = [
- 'newinfo' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ],
- 'realauthbyopenid' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ],
- 'updateiscompanybyopenid' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ],
- ];
- return $list;
- }
- /**
- * 新建用户
- * wj
- * 20220118
- */
- public function newinfo($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $m_u = new usermodel();
- $id = $m_u->insertData($arr);
- if (empty($id)) {
- return backarr(0, "新增失败");
- }
- return backarr(1, "新增成功", ['id' => $id]);
- }
- /**
- * 实名认证
- * wj
- * 20220118
- */
- public function realauthbyopenid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $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)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $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']]);
- }
- }
|