| | |
| | | { |
| | | // 构建查询规则 |
| | | $model = $this->alias('A') |
| | | ->field('A.*, user.nickName, user.avatarUrl, user.real_name, user.mobile, branch_position.weight, branch_position.name as position_name') |
| | | ->field('A.*, user.nickName, user.avatarUrl, user.real_name, user.mobile, branch_position.weight, branch_position.name as position_name, supplier.name as supplier_name') |
| | | ->with(['branch']) |
| | | ->join('user', 'user.user_id = A.user_id', 'left') |
| | | ->join('branch_position', 'branch_position.position_id = A.position_id', 'left') |
| | | ->join('supplier', 'supplier.shop_supplier_id = A.shop_supplier_id', 'left') |
| | | ->where('A.is_delete', '=', 0) |
| | | ->order(['branch_position.weight' => 'desc', 'A.create_time' => 'desc']); |
| | | // 查询条件 |
| | |
| | | */ |
| | | public function add($data) |
| | | { |
| | | $user_id = $data['user_id']; |
| | | if (MemberModel::detail($data['user_id'])) { |
| | | $this->error = '该用户已经是连盟成员,不能重复添加'; |
| | | return false; |
| | | } |
| | | $data['app_id'] = self::$app_id; |
| | | $this->save($data); |
| | | // 检查真实姓名和电话有没有更改 |
| | |
| | | } |
| | | if ($user['mobile'] != $data['mobile']) { |
| | | $userData['mobile'] = $data['mobile']; |
| | | } |
| | | if (!empty($data['avatarUrl'])) { |
| | | $userData['avatarUrl'] = $data['avatarUrl']; |
| | | } |
| | | if ($userData) { |
| | | $user->save($userData); |
| | |
| | | */ |
| | | public function edit($data) |
| | | { |
| | | return $this->save($data) !== false; |
| | | $this->save($data); |
| | | $userData = []; |
| | | $user = UserModel::detail($data['user_id']); |
| | | if ($user['real_name'] != $data['real_name']) { |
| | | $userData['real_name'] = $data['real_name']; |
| | | } |
| | | if ($user['mobile'] != $data['mobile']) { |
| | | $userData['mobile'] = $data['mobile']; |
| | | } |
| | | if (!empty($data['avatarUrl']) && $data['avatarUrl'] != $user['avatarUrl']) { |
| | | $userData['avatarUrl'] = $data['avatarUrl']; |
| | | } |
| | | if ($userData) { |
| | | $user->save($userData); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |