From 08774a09546923748598e19acf3b7ca91b456815 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Tue, 5 Nov 2019 18:45:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B7=BB=E5=8A=A0=E6=8E=A8?= =?UTF-8?q?=E5=B9=BF=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Base/Service/PromoteService.class.php | 54 ++++++++++++++++++- .../Controller/PromoteController.class.php | 4 ++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index 179249605..47b7092be 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -765,11 +765,63 @@ class PromoteService { return self::$levels[$level] ?? '未知'; } + public function checkAddPromote($params) + { + $account = isset($params['account']) ? trim($params['account']) : ''; + $password = $params['password'] ?? ''; + $repassword = $params['repassword'] ?? ''; + $mobile = $params['mobile_phone'] ?? ''; + $idcard = $params['idcard'] ?? ''; + $realName = $params['real_name'] ?? ''; + + if ($account == '') { + return [ + 'status' => false, + 'message' => '请输入推广员账号', + ]; + } + if (strlen($account) > 15 || strlen($account) < 6) { + return [ + 'status' => false, + 'message' => '账号长度为6-15个字符', + ]; + } + if ($password == '') { + return [ + 'status' => false, + 'message' => '请输入登录密码', + ]; + } + if ($repassword != $password) { + return [ + 'status' => false, + 'message' => '确认密码跟密码不一致', + ]; + } + if (strlen($password) < 6) { + return [ + 'status' => false, + 'message' => '密码长度必须大于6位', + ]; + } + $promote = M('promote', 'tab_')->field(['id'])->where(['account' => $account])->find(); + if ($promote) { + return [ + 'status' => false, + 'message' => '渠道账号已存在', + ]; + } + return [ + 'status' => true, + 'message' => '验证成功', + ]; + } + public function addPromote($params, $parent = null) { $data = [ 'account' => $params['account'], - 'password' => $params['password'], + 'password' => $this->password($params['password']), 'nickname' => $params['nickname'] ?? $params['account'], 'second_pwd' => $params['second_pwd'] ?? null, 'real_name' => $params['real_name'], diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 50b732cbb..98bcdb311 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -1076,6 +1076,10 @@ class PromoteController extends BaseController $parent = $this->getLoginPromote(); } $promoteService = new PromoteService(); + $result = $promoteService->checkAddPromote($params); + if (!$result['status']) { + $this->ajaxReturn(['status' => 0, 'msg' => $result['message']]); + } $status = $promoteService->addPromote($params, $parent); if ($status) { $this->ajaxReturn(['status' => 1, 'msg' => '添加成功']);