更新手机号绑定 新增农科绑定

This commit is contained in:
mkm 2023-01-04 14:48:10 +08:00
parent 441b56c6a4
commit ee464cf5f5

View File

@ -30,6 +30,7 @@ use think\App;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
class User extends BaseController
{
@ -201,6 +202,29 @@ class User extends BaseController
$data = ['account' => $data['phone'], 'phone' => $data['phone']];
}
$this->repository->update($this->request->uid(), $data);
$msg=Db::connect('nongke')->name('szxc_information_usermsg')->where('phone',$data['phone'])->find();
//绑定农科用户
if ($msg){
$find=Db::name('nk_user')->where('n_user_id',$msg['user_id'])->find();
$users=Db::connect('nongke')->name('user')->where('id',$msg['user_id'])->find();
if ($find && $find['user_id']==0){
Db::name('nk_user')->where('id',$find['id'])->update(['user_id'=>$this->request->uid(),'group_id'=>$users['group_id']]);
}else{
$datas=[
'user_id'=>$this->request->uid(),
'n_user_id'=>$users['id'],
'group_id'=>$users['group_id']
];
Db::name('nk_user')->insert($datas);
}
}else{
$datas=[
'user_id'=>$this->request->uid(),
'n_user_id'=>0,
'group_id'=>1
];
Db::name('nk_user')->insert($datas);
}
return app('json')->success('绑定成功');
}