From 6fb1f17d584adc627240cc270ade31d8d59a329d Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Tue, 2 Apr 2024 10:58:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=92=8C=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=A2=9E=E5=8A=A00?= =?UTF-8?q?=E5=85=83=E8=B4=A6=E6=88=B7=E9=92=B1=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie6c7b0bcda62e898bb9d15864d11c7111e79fa0d --- .../backstage/controllers/User.php | 7 +++++ .../backstage/models/User_model.php | 30 ++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/backstage/application/backstage/controllers/User.php b/backstage/application/backstage/controllers/User.php index 29d8dae..68f7df4 100644 --- a/backstage/application/backstage/controllers/User.php +++ b/backstage/application/backstage/controllers/User.php @@ -456,6 +456,10 @@ class User extends CI_Controller $rs = $this->idcard_model->bandIdCard($userId, $cardNo); $result .= ',' . $rs['msg']; } + + // 如果没账户,就开0元账户 + $this->user_model->createEmptyAccount($userId); + // // 导入IC卡号 // if ($userId && $cardNo) { // $rs = $this->idcard_model->bandIdCard($userId, $cardNo); @@ -680,6 +684,9 @@ class User extends CI_Controller } } + // 如果没账户,就开0元账户 + $this->user_model->createEmptyAccount($userId); + array_push($currentData, $result); array_push($currentData, $password); array_push($list, $currentData); diff --git a/backstage/application/backstage/models/User_model.php b/backstage/application/backstage/models/User_model.php index a7f29fe..13117be 100644 --- a/backstage/application/backstage/models/User_model.php +++ b/backstage/application/backstage/models/User_model.php @@ -192,6 +192,9 @@ class User_model extends CI_Model }else{ $result = $this->tb_user->insert($field); if ($result) { + // 创建空账户 + $this->createEmptyAccount($result); + $img_id = intval($data['img_id']); if($img_id) { $card = substr(md5("yzms".$result), 10, 10); @@ -201,7 +204,7 @@ class User_model extends CI_Model $this->rs['msg'] = '添加用户成功!'; $this->rs['user_id'] = $result; } else { - $this->rs['msg'] = '添加用户成功!'; + $this->rs['msg'] = '添加用户失败!'; } } @@ -370,6 +373,9 @@ class User_model extends CI_Model $this->rs['user_id'] = $result; return $this->rs; } + // 创建空账户 + $this->createEmptyAccount($result); + $this->rs['success'] = true; $this->rs['msg'] = '添加用户成功!'. $idCardMsg; $this->rs['user_id'] = $result; @@ -406,6 +412,28 @@ class User_model extends CI_Model } + // 创建空账户 + public function createEmptyAccount($user_id){ + // 判断用户是否已经存在账户 + $userAccount = $this->db->query("select * from tb_account WHERE user_id = ?",array($user_id))->row_array(); + if(empty($userAccount)){ + // 创建账户 type_id = 2, supplier_id = 当前登录者 supplier_id (若管理者没有关联supplier_id,则取tb_company关联的供应商id),recharge_fund_type = 2 + $supplierId = $this->session->userdata("supplierId"); + if(empty($supplierId)){ + // 查找 tb_supplier 关联的供应商 + $supplier = $this->db->query("select * from tb_supplier WHERE company_id = ?",array($this->session->companyId))->row_array(); + $supplierId = $supplier['id']; + } + $insertData = array( + 'user_id' => $user_id, + 'type_id' => 2, + 'supplier_id' => $supplierId, + 'recharge_fund_type' => 2, + 'account' => 0, + ); + $this->db->insert('tb_account',$insertData); + } + } /** 设置 隐藏 与 恢复 * @param $id * @param $enabled