|
@@ -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']]);
|
|
|
+ }
|
|
|
+}
|