|
@@ -386,7 +386,7 @@ class UserInfo extends BaseController
|
|
|
]);
|
|
|
if ($validate->check($post) == false) return json_show(1004, $validate->getError());
|
|
|
Db::startTrans();
|
|
|
- $uiq = Db::table("sys_account")->where(["mobile" => $post['mobile']])->find();
|
|
|
+ $uiq = Db::table("sys_account")->field('id')->where(["mobile" => $post['mobile']])->find();
|
|
|
if ($uiq) {
|
|
|
return json_show(1002, "手机号已注册!");
|
|
|
}
|
|
@@ -394,7 +394,7 @@ class UserInfo extends BaseController
|
|
|
try {
|
|
|
$salt = makeSalt();
|
|
|
$password = sha1("dingding123" . $salt);
|
|
|
- $data = [
|
|
|
+ $da = [
|
|
|
'username' => $post['mobile'],
|
|
|
"password" => $password,
|
|
|
"salt" => $salt,
|
|
@@ -404,7 +404,7 @@ class UserInfo extends BaseController
|
|
|
"addtime" => date("Y-m-d H:i:s"),
|
|
|
"updatetime" => date("Y-m-d H:i:s")
|
|
|
];
|
|
|
- $reuslt = Db::table('sys_account')->insert($data, true);
|
|
|
+ $reuslt = Db::table('sys_account')->insert($da, true);
|
|
|
if ($reuslt) {
|
|
|
$data = [
|
|
|
"nickname" => $post['nickname'],
|
|
@@ -466,4 +466,137 @@ class UserInfo extends BaseController
|
|
|
return json_show(1002, "账户注册失败" . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //添加超管账号
|
|
|
+ public function addAdminAccount()
|
|
|
+ {
|
|
|
+
|
|
|
+ $post = $this->request->filter('trim')->post();
|
|
|
+
|
|
|
+ $tmp = Db::table("sys_account")
|
|
|
+ ->field('id')
|
|
|
+ ->where(["mobile" => $post['mobile'], 'is_del' => 0])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if ($tmp) return json_show(1002, "手机号已注册");
|
|
|
+
|
|
|
+ try {
|
|
|
+ $date = date("Y-m-d H:i:s");
|
|
|
+ $salt = makeSalt();
|
|
|
+ $password = sha1("dingding123" . $salt);
|
|
|
+ $da = [
|
|
|
+ 'username' => $post['mobile'],
|
|
|
+ "password" => $password,
|
|
|
+ "salt" => $salt,
|
|
|
+ "mobile" => $post['mobile'],
|
|
|
+ "source" => "paltadd",
|
|
|
+ "status" => 1,
|
|
|
+ "level" => 1,
|
|
|
+ "addtime" => date("Y-m-d H:i:s"),
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $reuslt = Db::table('sys_account')->insert($da, true);
|
|
|
+ if ($reuslt) {
|
|
|
+ $data = [
|
|
|
+ "nickname" => $post['nickname'],
|
|
|
+ "mobile" => $post['mobile'],
|
|
|
+ "email" => $post['email'],
|
|
|
+ "portrait" => "",
|
|
|
+ "sex" => 1,
|
|
|
+ "post" => "",
|
|
|
+ "department" => "",
|
|
|
+ "account_id" => $reuslt,
|
|
|
+ "status" => 1,
|
|
|
+ "addtime" => $date,
|
|
|
+ "updatetime" => $date
|
|
|
+ ];
|
|
|
+ $user = Db::table("sys_user")->insert($data);
|
|
|
+ if ($user != false) {
|
|
|
+ $acount = new AccountCompany();
|
|
|
+ if (!empty($post['companyArr'])) {
|
|
|
+ $company_insert = [];
|
|
|
+ foreach ($post['companyArr'] as $company) {
|
|
|
+ $company_insert[] = [
|
|
|
+ "account_id" => $reuslt,
|
|
|
+ "companyCode" => $company['companyCode'],
|
|
|
+ "companyName" => $company['companyName'],
|
|
|
+ "company_type" => $company['company_type'],
|
|
|
+ "is_main" => $company['is_main'],
|
|
|
+ "status" => 1,
|
|
|
+ "is_del" => 0,
|
|
|
+ "addtime" => $date,
|
|
|
+ "updatetime" => $date,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $u = $acount->saveAll($company_insert);
|
|
|
+ } else {
|
|
|
+ $company_insert = [
|
|
|
+ "account_id" => $reuslt,
|
|
|
+ "companyCode" => '',
|
|
|
+ "companyName" => '',
|
|
|
+ "company_type" => '0',
|
|
|
+ "is_main" => 1,
|
|
|
+ "status" => 1,
|
|
|
+ "is_del" => 0,
|
|
|
+ "addtime" => $date,
|
|
|
+ "updatetime" => $date,
|
|
|
+ ];
|
|
|
+ $u = $acount->save($company_insert);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($u == false) throw new Exception("账户新建失败");
|
|
|
+ Db::commit();
|
|
|
+ return json_show(0, "账户注册成功", ["userid" => $reuslt, "nickname" => $post['nickname']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1002, "账户注册失败");
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(1002, "账户注册失败" . $e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改密码通过旧密码
|
|
|
+ public function passSetByPassword()
|
|
|
+ {
|
|
|
+
|
|
|
+ $param = $this->request->only(['uid', 'old_pass', 'new_pass'], 'post', 'trim');
|
|
|
+
|
|
|
+ $val = Validate::rule([
|
|
|
+ 'uid|用户ID' => 'require|number|gt:0',
|
|
|
+ 'old_pass|旧密码' => 'require|max:255',
|
|
|
+ 'new_pass|新密码' => 'require|min:6|max:255',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($val->check($param) == false) return json_show(1004, $val->getError());
|
|
|
+
|
|
|
+ $acc = Db::name("account")
|
|
|
+ ->field('id,password,salt,status')
|
|
|
+ ->where(['id' => $param['uid'], "is_del" => Account::$account_del])
|
|
|
+ ->findOrEmpty();
|
|
|
+ if (empty($acc)) return json_show(1003, '账户不存在');
|
|
|
+
|
|
|
+ if ($acc['status'] == Account::$account_end) return json_show(1003, '账户已禁用');
|
|
|
+
|
|
|
+ $sha1 = sha1($param['old_pass'] . $acc['salt']);
|
|
|
+ if ($sha1 != $acc['password']) return json_show(1003, '密码错误');
|
|
|
+
|
|
|
+
|
|
|
+ $salt = makeSalt();
|
|
|
+ $password = sha1($param['new_pass'] . $salt);
|
|
|
+
|
|
|
+ $rs = Db::name('account')
|
|
|
+ ->where(['id' => $param['uid'], "is_del" => Account::$account_del])
|
|
|
+ ->update([
|
|
|
+ 'password' => $password,
|
|
|
+ 'salt' => $salt,
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s')
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return $rs ? json_show(0, '修改密码成功') : json_show(1004, '修改密码失败');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|