新增接收家庭成员邀请接口

This commit is contained in:
彭桃 2023-03-20 15:03:15 +08:00
parent 3fc2fcfe56
commit 437a893973
4 changed files with 75 additions and 0 deletions

View File

@ -1771,7 +1771,57 @@ class Maintainentry extends BaseController
}
// 接收家庭成员邀请
public function receive_invitations(){
$params = get_params();
//用户id
$user_id = $this->request->uid;
$user = Db::table('fa_szxc_information_usermsg')->where('user_id',$user_id)->find();
if($user){
if($user['householder_id']){
$this->apiError('已有户主不能接收邀请');
}else{
$hz = Db::table('fa_szxc_information_usermsg')->where('user_id',$params['user_id'])->find();
if(!$hz){
$this->apiError('邀请人未找到');
}
if($hz['is_hz'] != 1){
$this->apiError('不是户主,不能邀请');
}
Db::startTrans();
try {
$hz_id = $params['hz_id']; //户主id
// 修改用户户主
$data['householder_id'] = $hz_id; //户主id
$data['is_hz'] = 0;
Db::table('fa_szxc_information_usermsg')->where('user_id',$user_id)->update($data);
//写入家庭成员表
$my_user_id = $hz_id;
$f_where[] = ['user_ids','find in set',$my_user_id];
$family_arr = Db::table('fa_szxc_family')->where($f_where)->find();
$time = time();
if($family_arr){
$u_data['user_ids'] = \think\facade\Db::raw("concat(user_ids ,"."',".$user_id."')");
$u_data['updatetime'] = $time;
Db::table('fa_szxc_family')->where('id',$family_arr['id'])->update($u_data);
}else{
$szxc_family['user_ids'] = $my_user_id.','.$user_id;
$szxc_family['householder_id'] = $hz_id;
$szxc_family['createtime'] = $time;
Db::table('fa_szxc_family')->strict(false)->insert($szxc_family);
}
$this->apiSuccess('操作成功');
} catch (ValidateException | \PDOException | Exception $e) {
Db::rollback();
$this->apiError($e->getMessage());
}
}
}else{
$this->apiError('未找到该用户');
}
}
}

View File

@ -192,6 +192,30 @@ class Userinfo extends BaseController
->where('user_id', $userid)
->find();
// 新增被邀请的家庭成员注册,直接加入该家庭
if(isset($post['hz_id']) && !empty($post['hz_id'])){
// 写入家庭成员表
$my_user_id = $userid;
$hz_id = $post['hz_id']; //户主id
$time = time();
$f_where[] = ['user_ids','find in set',$hz_id];
$family_arr = Db::table('fa_szxc_family')->where($f_where)->find();
if($family_arr){
$u_data['user_ids'] = \think\facade\Db::raw("concat(user_ids ,"."',".$my_user_id."')");
$u_data['updatetime'] = $time;
Db::table('fa_szxc_family')->where('id',$family_arr['id'])->update($u_data);
$h_data['householder_id'] = $hz_id;
Db::table('fa_szxc_information_usermsg')->where('user_id',$my_user_id)->update($h_data);
}else{
$szxc_family['user_ids'] = $hz_id.','.$my_user_id;
$szxc_family['householder_id'] = $hz_id;
$szxc_family['createtime'] = $time;
Db::table('fa_szxc_family')->strict(false)->insert($szxc_family);
}
}
// 判断用户地区写入状态
if (!$add){

View File

@ -60,6 +60,7 @@ return [
'disable' => '禁用',
'recovery' => '恢复',
'reset' => '重新设置',
'buy' => '采购商品',
],
'user_action' => [
'login' => '登录',

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B