完善添加推广员

master
ELF 5 years ago
parent 8ae754f74a
commit 08774a0954

@ -765,11 +765,63 @@ class PromoteService {
return self::$levels[$level] ?? '未知'; 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) public function addPromote($params, $parent = null)
{ {
$data = [ $data = [
'account' => $params['account'], 'account' => $params['account'],
'password' => $params['password'], 'password' => $this->password($params['password']),
'nickname' => $params['nickname'] ?? $params['account'], 'nickname' => $params['nickname'] ?? $params['account'],
'second_pwd' => $params['second_pwd'] ?? null, 'second_pwd' => $params['second_pwd'] ?? null,
'real_name' => $params['real_name'], 'real_name' => $params['real_name'],

@ -1076,6 +1076,10 @@ class PromoteController extends BaseController
$parent = $this->getLoginPromote(); $parent = $this->getLoginPromote();
} }
$promoteService = new PromoteService(); $promoteService = new PromoteService();
$result = $promoteService->checkAddPromote($params);
if (!$result['status']) {
$this->ajaxReturn(['status' => 0, 'msg' => $result['message']]);
}
$status = $promoteService->addPromote($params, $parent); $status = $promoteService->addPromote($params, $parent);
if ($status) { if ($status) {
$this->ajaxReturn(['status' => 1, 'msg' => '添加成功']); $this->ajaxReturn(['status' => 1, 'msg' => '添加成功']);

Loading…
Cancel
Save