564 lines
23 KiB
PHP
564 lines
23 KiB
PHP
<?php
|
|
|
|
namespace app\api\model;
|
|
|
|
use think\Db;
|
|
use think\Log;
|
|
use think\Model;
|
|
|
|
class UserData extends Model
|
|
{
|
|
private $redis;
|
|
|
|
public function __construct($data = [])
|
|
{
|
|
parent::__construct($data);
|
|
$this->redis = \think\Cache::store('redis')->handler();
|
|
}
|
|
//获取腾讯IM
|
|
public function get_tencent_im($user_id)
|
|
{
|
|
$tencent_im = $this->where('user_id', $user_id)->value('tencent_im');
|
|
if(empty($tencent_im)){
|
|
$tencent_im = model('Tencent')->tencent_user_sig_info('u'.$user_id);
|
|
$data = [
|
|
'nick' => db::name('user')->where('id', $user_id)->value('nickname'),
|
|
'face_url' => db::name('user')->where('id', $user_id)->value('avatar'),
|
|
];
|
|
model('Tencent')->account_import($user_id,$data);
|
|
if(empty($tencent_im)){
|
|
return ['code' => 0, 'msg' => '获取腾讯IM唯一标识失败','data' =>null];
|
|
}
|
|
//更新腾讯IM唯一标识
|
|
$this->where(['user_id' => $user_id])->update(['tencent_im' => $tencent_im]);
|
|
}
|
|
return $tencent_im;
|
|
}
|
|
|
|
//第一次修改用户信息
|
|
public function modify_fist_user_info($nick_name, $birthday, $sex, $head_pic,$reg_code,$uid)
|
|
{
|
|
$text = $nick_name;
|
|
if(!empty($text)) {
|
|
$result = model('Tencent')->content_moderation('Text', $text);
|
|
if($result['code'] != 1) {
|
|
return ['code' => 0, 'msg' => '昵称有违禁词!','data' =>null];
|
|
}
|
|
}
|
|
$data = [];
|
|
$data['id'] = $uid;
|
|
if (!empty($nick_name)) {
|
|
$data['nickname'] = $nick_name;
|
|
$nick_name_info = db::name('user')->where('nickname', $nick_name)->find();
|
|
if(!empty($nick_name_info)){
|
|
if($uid != $nick_name_info['id']){
|
|
return['code' => 0, 'msg' => '该昵称已被占用','data' =>null];
|
|
}
|
|
}
|
|
if(mb_strlen($nick_name) > 24){
|
|
return['code' => 0, 'msg' => '昵称长度不能超过24个字符','data' =>null];
|
|
}
|
|
}
|
|
|
|
if (!empty($birthday)) {
|
|
$data['birthday'] = $birthday;
|
|
}
|
|
if (!empty($reg_code)) {
|
|
// $data['init_code'] = $reg_code;
|
|
//绑定
|
|
$reslut = model('api/Invited')->invited_bind($reg_code, $uid);
|
|
if ($reslut['code'] == 0) {
|
|
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
}
|
|
}
|
|
|
|
if (!empty($head_pic)) {
|
|
$data['avatar'] = $head_pic;
|
|
}
|
|
|
|
$data['sex'] =$sex;
|
|
$data['updatetime'] = time();
|
|
|
|
$reslut = model('User')->update($data);
|
|
if ($reslut) {
|
|
$user_info = model('User')->where('id', $uid)->field('id,nickname,avatar,user_code')->find();
|
|
|
|
return ['code' => 1, 'msg' => '修改成功', 'data' => $user_info];
|
|
} else {
|
|
return ['code' => 0, 'msg' => '修改失败,','data' =>null];
|
|
}
|
|
}
|
|
|
|
//根据性别选择用户头像
|
|
public function modify_pic_user_info($sex)
|
|
{
|
|
if (empty($sex)){
|
|
return ['code' => 0, 'msg' => '选择性别!','data' =>null];
|
|
}
|
|
if ($sex==1){
|
|
$impag = Db::name('user_head_pic')
|
|
->where('sex',1)->where('is_delete',1)->orderRaw('rand()')->find();
|
|
if(empty($impag)){
|
|
return ['code' => 0, 'msg' => '暂无头像','data' =>null];
|
|
}
|
|
return ['code' => 1, 'msg' => '男生图像', 'data' => $impag['head_pic']];
|
|
}
|
|
|
|
if ($sex==2){
|
|
$impag = Db::name('user_head_pic')
|
|
->where('sex',2)->where('is_delete',1)->orderRaw('rand()')->find();
|
|
if(empty($impag)){
|
|
return ['code' => 0, 'msg' => '暂无头像','data' =>null];
|
|
}
|
|
return ['code' => 1, 'msg' => '女生图像', 'data' => $impag['head_pic']];
|
|
}
|
|
return ['code' => 0, 'msg' => '获取失败','data' =>null];
|
|
}
|
|
|
|
//修改用户 信息
|
|
public function modify_user_info($uid, $nick_name, $birthday, $sex, $head_pic, $images, $autograph,$tag_id)
|
|
{
|
|
$text = $nick_name . $autograph ;
|
|
if(!empty($text)) {
|
|
$result = model('Tencent')->content_moderation('Text', $text);
|
|
if($result['code'] != 1) {
|
|
return ['code' => 0, 'msg' => '昵称或简介有违禁词!','data' =>null];
|
|
}
|
|
}
|
|
|
|
$data = [];
|
|
$data['uid'] = $uid;
|
|
if (!empty($nick_name)) {
|
|
$data['nick_name'] = $nick_name;
|
|
$data['base64_nick_name'] = base64_encode($nick_name);
|
|
$nick_name_info = db::name('user')->where('base64_nick_name', $data['base64_nick_name'])->find();
|
|
if(!empty($nick_name_info)){
|
|
if($uid != $nick_name_info['uid']){
|
|
return['code' => 0, 'msg' => '该昵称已被占用','data' =>null];
|
|
}
|
|
}
|
|
if(mb_strlen($nick_name) > 24){
|
|
return['code' => 0, 'msg' => '昵称长度不能超过24个字符','data' =>null];
|
|
}
|
|
}
|
|
if (!empty($birthday)) {
|
|
$data['birthday'] = $birthday;
|
|
$constellation = $this->get_user_constellation($birthday);
|
|
$data['constellation'] = $constellation['data'];
|
|
}
|
|
|
|
if (!empty($head_pic)) {
|
|
// $data['head_pic'] = $param['path'];
|
|
$filepath_url = get_filepath_url();
|
|
$params = parse_url($filepath_url);
|
|
$param = parse_url($head_pic);
|
|
if(isset($param['host'])) {
|
|
if (!empty($param['path'])) {
|
|
if($params['host'] == $param['host']) {
|
|
$head_pic = $param['path'];
|
|
$head_pic = trim($head_pic, '/');
|
|
}
|
|
$data['head_pic'] = $head_pic;
|
|
}
|
|
} else {
|
|
$data['head_pic'] = $head_pic;
|
|
}
|
|
}
|
|
|
|
if (!empty($autograph)) {
|
|
$data['autograph'] = $autograph;
|
|
}
|
|
|
|
$validate = validate('admin/User');
|
|
$reslut = $validate->scene('apiEditInfo')->check($data);
|
|
if ($reslut !== true) {
|
|
return ['code' => 0, 'msg' => $validate->getError(),'data' =>null];
|
|
}
|
|
$data['sex'] = $sex;
|
|
$data['update_time'] = time();
|
|
|
|
$images_data = explode(',', json_decode($images));
|
|
|
|
//开启事务
|
|
db::startTrans();
|
|
try{
|
|
$reslut = db::name('user')->where('uid', $uid)->update($data);
|
|
if (!$reslut) {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
$tag_data = [];
|
|
if(!empty($tag_id)){
|
|
//删除之前的标签
|
|
$deldt['tag_id'] = '';
|
|
$delres = db::name('user_data')->where('uid', $uid)->update($deldt);
|
|
if (!$delres) {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
$tag_data['tag_id'] = $tag_id;
|
|
$tareslut = db::name('user_data')->where('uid', $uid)->update($tag_data);
|
|
if (!$tareslut) {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
}
|
|
if (!empty($images_data)) {
|
|
//删除之前的图片
|
|
$deldata['is_delete'] = 2;
|
|
$deldata['delete_time'] = time();
|
|
$reslutd = db::name('user_home_bgimages')->where('uid', $uid)->update($deldata);
|
|
if($reslutd){
|
|
//循环插入图片
|
|
$dd['uid'] = $uid;
|
|
$dd['add_time'] = time();
|
|
$dd['update_time'] = time();
|
|
foreach ($images_data as $key => $value) {
|
|
$dd['image'] = $value;
|
|
db::name('user_home_bgimages')->insert($dd);
|
|
}
|
|
}else {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
}
|
|
|
|
Db::commit();
|
|
return ['code' => 1, 'msg' => '修改成功','data' =>null];
|
|
} catch (\Exception $e) {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
|
|
}
|
|
|
|
//修改,设置用户密码
|
|
public function modify_password($password,$user_id)
|
|
{
|
|
if (empty($user_id)) {
|
|
return ['code' => 0, 'msg' => '登录失效,请重新登录','data' =>null];
|
|
}
|
|
|
|
$reslut = db::name('user')->where('id' , $user_id)->update(['password' => md5($password)]);
|
|
|
|
if ($reslut) {
|
|
return ['code' => 1, 'msg' => '修改成功','data' =>null];
|
|
} else {
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
}
|
|
|
|
//修改手机号
|
|
public function modify_mobile($new_mobile,$user_id)
|
|
{
|
|
//查询旧手机号
|
|
$mobile = db::name('user')->where(['id' => $user_id])->value('username');
|
|
//查询是否实名
|
|
$is_real = db::name('user_auth')->where(['mobile' => $mobile,'is_real' => 1])->find();
|
|
if($is_real){
|
|
//开启事务
|
|
db::startTrans();
|
|
//修改实名手机号
|
|
$red = db::name('user_auth')->where(['id' => $is_real['id']])->update(['mobile' => $new_mobile]);
|
|
$reslut = db::name('user')->where(['id' => $user_id])->update(['username' => $new_mobile,'mobile' => $new_mobile]);
|
|
if ($reslut && $red) {
|
|
Db::commit();
|
|
return ['code' => 1, 'msg' => '修改成功','data' =>null];
|
|
} else {
|
|
db::rollback();
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
}else{
|
|
$reslut = db::name('user')->where(['id' => $user_id])->update(['username' => $new_mobile,'mobile' => $new_mobile]);
|
|
if ($reslut) {
|
|
return ['code' => 1, 'msg' => '修改成功','data' =>null];
|
|
}
|
|
}
|
|
return ['code' => 0, 'msg' => '修改失败','data' =>null];
|
|
}
|
|
|
|
//实名认证
|
|
public function real_name($user_id,$real_name,$id_card)
|
|
{
|
|
$user_mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
|
if(empty($user_mobile)){
|
|
return ['code' => 0, 'msg' => '请先绑定手机号','data' =>null];
|
|
}
|
|
$auth = [
|
|
'mobile' => $user_mobile,
|
|
'real_name' => $real_name,
|
|
'card_id' => $id_card,
|
|
'is_real' => 3
|
|
];
|
|
db::name('user_auth')->insert($auth);
|
|
|
|
$config = get_system_config();
|
|
//获取Access Token
|
|
$access_token = $this->redis->get('access_token_'.$config['tencent_app_id']);
|
|
//判断是否过期
|
|
if(empty($access_token)){
|
|
$access_token = model('Tencent')->getAccessToken($config['tencent_app_id'],$config['tencent_app_secret']);
|
|
$this->redis->set('access_token_'.$config['tencent_app_id'],$access_token,1000);
|
|
sleep(1);
|
|
//获取SignTicket
|
|
$sign_ticket = model('Tencent')->getSignTicket($access_token,$config['tencent_app_id']);
|
|
$this->redis->set('sign_ticket_'.$config['tencent_app_id'],$sign_ticket,1100);
|
|
}
|
|
$sign_ticket = $this->redis->get('sign_ticket_'.$config['tencent_app_id']);
|
|
|
|
//获取NONCE Ticket
|
|
$nonce_ticket = model('Tencent')->getNonceTicket($access_token,$user_id,$config['tencent_app_id']);
|
|
//获取随机字符串
|
|
$nonceStr = generateRandom(32);
|
|
//生成一个订单号 并保存在redis
|
|
$orderNo = generateRandom(12);
|
|
//保存在redis
|
|
$this->redis->set('order_no_tencent_'.$user_id,$orderNo,3600);
|
|
//生成签名
|
|
$sign = model('Tencent')->getSign($user_id,$nonceStr,$sign_ticket,$config['tencent_app_id']);
|
|
//生成faceId
|
|
$faceId = model('Tencent')->getFaceId($orderNo,$real_name,$id_card,$sign,$user_id,$config['tencent_app_id'],$nonceStr);
|
|
|
|
$data = [
|
|
'userid' => 'u'.$user_id,
|
|
'nonce' => $nonceStr,
|
|
'sign' => $sign,
|
|
'appid' => $config['tencent_app_id'],
|
|
'orderNo' => $orderNo,
|
|
'apiVersion'=>'1.0.0',
|
|
'licence'=>$config['tencent_licence'],
|
|
'faceId' => $faceId
|
|
];
|
|
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
|
}
|
|
|
|
//实名认证结果
|
|
public function real_name_result($user_id,$orderNo)
|
|
{
|
|
$user_mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
|
//修改状态
|
|
$reslut = db::name('user_auth')->where('mobile' , $user_mobile)->update(['is_real' => 1]);
|
|
if(!$reslut){
|
|
return ['code' => 0, 'msg' => '实名失败','data' =>null];
|
|
}
|
|
return ['code' => 1, 'msg' => '实名成功','data' =>null];
|
|
}
|
|
|
|
//实名认证后的信息
|
|
public function real_name_info($user_id)
|
|
{
|
|
$mobile = db::name('user')->where(['id' => $user_id,'status'=>1])->value('mobile');
|
|
$data = db::name('user_auth')->where('mobile' , $mobile)->field('real_name,card_id,is_real,mobile')->find();
|
|
if(!$data){
|
|
return ['code' => 0, 'msg' => '未实名','data' =>null];
|
|
}
|
|
|
|
$datas = [
|
|
'real_name' => name_format($data['real_name']),
|
|
'card_id' => id_format($data['card_id']),
|
|
'mobile' => $data['mobile'],
|
|
'is_real' => $data['is_real']
|
|
];
|
|
return ['code' => 1, 'msg' => '获取成功','data' =>$datas];
|
|
}
|
|
|
|
//用户的财富等级和经验值
|
|
public function user_wealth_icon($user_id)
|
|
{
|
|
$data = $this->field('wealth_level,wealth_exp')->where('user_id',$user_id)->find();
|
|
if(!$data){
|
|
return localpath_to_netpath('data/default/xin.png');
|
|
}
|
|
$icon = db::name('vs_wealth_level')->where('level',$data['wealth_level'])->value('image');
|
|
if($icon == ''){
|
|
return localpath_to_netpath('data/default/xin.png');
|
|
}
|
|
return $icon;
|
|
}
|
|
|
|
//用户的魅力等级和经验值
|
|
public function user_charm_icon($user_id)
|
|
{
|
|
$data = $this->field('charm_level,charm_exp')->where('user_id',$user_id)->find();
|
|
if(!$data){
|
|
return localpath_to_netpath('data/default/xin.png');
|
|
}
|
|
$icon = db::name('vs_charm_level')->where('level',$data['charm_level'])->value('image');
|
|
if($icon == ''){
|
|
return localpath_to_netpath('data/default/xin.png');
|
|
}
|
|
return $icon;
|
|
}
|
|
|
|
//房间历史足迹
|
|
public function user_room_history_list($uid,$page,$page_limit){
|
|
$list = db::name('user_visit_log')->alias('a')->join('fa_vs_room b','a.to_id = b.id')
|
|
->field('b.id as room_id,b.room_number,b.room_name,b.room_cover,b.room_intro,b.label_id,b.room_password,b.is_show_room,b.today_hot_value as hot_value')
|
|
->where('a.from_uid',$uid)
|
|
->where('a.type',2)
|
|
->where('b.type_id','<>',6)
|
|
->where('b.room_status',1)
|
|
->order('a.id desc')
|
|
->page($page,$page_limit)
|
|
->select();
|
|
if($list){
|
|
foreach($list as &$item){
|
|
if($item['is_show_room'] == 2){ //是否显示房间 1是2否
|
|
//查询当前房间是否有主持在麦上
|
|
$room_host_info = db::name('vs_room_pit')->where(['room_id' => $item['room_id'], 'pit_number' => 9])->value('user_id');
|
|
if($room_host_info == 0){
|
|
unset($list[$item]);
|
|
continue;
|
|
}
|
|
}
|
|
$item['label_icon'] = db::name('vs_room_label')->where('id',$item['label_id'])->value('label_icon');
|
|
//获取房间用户总数
|
|
$item['user_count'] = db::name('vs_room_visitor')->where('room_id',$item['room_id'])->count();
|
|
//房间是否有靓号 7房间靓号
|
|
$item['room_number'] = model('Decorate')->user_decorate_detail($item['room_id'],7);
|
|
// $item['hot_value'] = $item['hot_value'] * 10;
|
|
}
|
|
$list = array_values((array)$list);
|
|
}else{
|
|
$list = [];
|
|
}
|
|
|
|
return ['code' => 1, 'msg' => '获取成功','data' =>$list];
|
|
}
|
|
|
|
//删除房间历史足迹
|
|
public function delete_room_history($uid){
|
|
$reslut = db::name('user_visit_log')->where(['from_uid' => $uid,'type' => 2])->delete();
|
|
if($reslut){
|
|
return ['code' => 1, 'msg' => '删除成功','data' =>null];
|
|
}
|
|
return ['code' => 0, 'msg' => '删除失败','data' =>null];
|
|
}
|
|
|
|
|
|
//绑定提现账户的信息
|
|
public function bind_withdraw_account($user_id,$system='')
|
|
{
|
|
if($system == 'iOS'){
|
|
$lists['ali']['name'] = "支付宝";
|
|
$lists['wx']['name'] = "微信";
|
|
$lists['bank']['name'] = "银行卡";
|
|
$lists['ali_tl']['name'] = "支付宝(通联)";
|
|
$lists['wx_tl']['name'] = "微信(通联)";
|
|
$lists['ali']['icon'] = localpath_to_netpath('data/default/alipay.png');
|
|
$lists['wx']['icon'] = localpath_to_netpath('data/default/wxpay.png');
|
|
$lists['bank']['icon'] = localpath_to_netpath('data/default/bankpay.png');
|
|
$lists['ali_tl']['icon'] = localpath_to_netpath('data/default/alipay.png');
|
|
$lists['wx_tl']['icon'] = localpath_to_netpath('data/default/wxpay.png');
|
|
$lists['ali']['is_with_draw_open'] = get_system_config_value('withdraw_ali');
|
|
$lists['wx']['is_with_draw_open'] = get_system_config_value('withdraw_wx');
|
|
$lists['bank']['is_with_draw_open'] = get_system_config_value('withdraw_bank');
|
|
$lists['ali_tl']['is_with_draw_open'] = 0;
|
|
$lists['wx_tl']['is_with_draw_open'] = 0;
|
|
$lists['ali']['is_bind'] = db::name('user_data')->where('user_id',$user_id)->value('alipay_account') ? 1 : 0;
|
|
$lists['wx']['is_bind'] = 0;
|
|
$lists['bank']['is_bind'] = db::name('user_data')->where('user_id',$user_id)->value('bank_card_number') ? 1 : 0;
|
|
$lists['ali_tl']['is_bind'] = 0;
|
|
$lists['wx_tl']['is_bind'] = 0;
|
|
$lists['ali']['type'] = 2;
|
|
$lists['wx']['type'] = 1;
|
|
$lists['bank']['type'] = 3;
|
|
$lists['ali_tl']['type'] = 4;
|
|
$lists['wx_tl']['type'] = 5;
|
|
// $lists['ali']['is_pay_open'] = 0;
|
|
// $lists['wx']['is_pay_open'] = 0;
|
|
// $lists['bank']['is_pay_open'] = 0;
|
|
// $lists['ali_tl']['is_pay_open'] = 0;
|
|
// $lists['wx_tl']['is_pay_open'] = 0;
|
|
$lists['ali']['is_pay_open'] = get_system_config_value('pay_open_ali');
|
|
$lists['wx']['is_pay_open'] = get_system_config_value('pay_open_wx');
|
|
$lists['bank']['is_pay_open'] = get_system_config_value('pay_open_bank');
|
|
$lists['ali_tl']['is_pay_open'] = get_system_config_value('pay_open_ali_tl');
|
|
$lists['wx_tl']['is_pay_open'] = get_system_config_value('pay_open_wx_tl');
|
|
}else{
|
|
$lists['ali']['name'] = "支付宝";
|
|
$lists['wx']['name'] = "微信";
|
|
$lists['bank']['name'] = "银行卡";
|
|
$lists['ali_tl']['name'] = "支付宝(通联)";
|
|
$lists['wx_tl']['name'] = "微信(通联)";
|
|
$lists['ali']['icon'] = localpath_to_netpath('data/default/alipay.png');
|
|
$lists['wx']['icon'] = localpath_to_netpath('data/default/wxpay.png');
|
|
$lists['bank']['icon'] = localpath_to_netpath('data/default/bankpay.png');
|
|
$lists['ali_tl']['icon'] = localpath_to_netpath('data/default/alipay.png');
|
|
$lists['wx_tl']['icon'] = localpath_to_netpath('data/default/wxpay.png');
|
|
$lists['ali']['is_with_draw_open'] = get_system_config_value('withdraw_ali');
|
|
$lists['wx']['is_with_draw_open'] = get_system_config_value('withdraw_wx');
|
|
$lists['bank']['is_with_draw_open'] = get_system_config_value('withdraw_bank');
|
|
$lists['ali_tl']['is_with_draw_open'] = 0;
|
|
$lists['wx_tl']['is_with_draw_open'] = 0;
|
|
$lists['ali']['is_bind'] = db::name('user_data')->where('user_id',$user_id)->value('alipay_account') ? 1 : 0;
|
|
$lists['wx']['is_bind'] = 0;
|
|
$lists['bank']['is_bind'] = db::name('user_data')->where('user_id',$user_id)->value('bank_card_number') ? 1 : 0;
|
|
$lists['ali_tl']['is_bind'] = 0;
|
|
$lists['wx_tl']['is_bind'] = 0;
|
|
$lists['ali']['type'] = 2;
|
|
$lists['wx']['type'] = 1;
|
|
$lists['bank']['type'] = 3;
|
|
$lists['ali_tl']['type'] = 4;
|
|
$lists['wx_tl']['type'] = 5;
|
|
$lists['ali']['is_pay_open'] = get_system_config_value('pay_open_ali');
|
|
$lists['wx']['is_pay_open'] = get_system_config_value('pay_open_wx');
|
|
$lists['bank']['is_pay_open'] = get_system_config_value('pay_open_bank');
|
|
$lists['ali_tl']['is_pay_open'] = get_system_config_value('pay_open_ali_tl');
|
|
$lists['wx_tl']['is_pay_open'] = get_system_config_value('pay_open_wx_tl');
|
|
}
|
|
|
|
return ['code' => 1, 'msg' => '获取成功','data' =>$lists];
|
|
}
|
|
|
|
//绑定
|
|
public function bind_xinxi($user_id,$type,$alipay_account,$bank_card_number,$bank_user_name,$bank_card,$open_bank)
|
|
{
|
|
if($type == 2){
|
|
$data = [
|
|
// 'alipay_name' => $alipay_name,// 姓名
|
|
'alipay_account' => $alipay_account,// 支付宝账号
|
|
];
|
|
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
|
if(!$reslut){
|
|
return ['code' => 0, 'msg' => '绑定失败','data' =>null];
|
|
}
|
|
}
|
|
|
|
if($type == 3){
|
|
$data = [
|
|
'bank_card_number' => $bank_card_number,
|
|
'bank_user_name' => $bank_user_name,
|
|
'bank_card' => $bank_card,
|
|
'open_bank' => $open_bank,
|
|
];
|
|
$reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
|
if(!$reslut){
|
|
return ['code' => 0, 'msg' => '绑定失败','data' =>null];
|
|
}
|
|
}
|
|
|
|
// if($type == 3){
|
|
// $data = [
|
|
// 'user_id' => $user_id,
|
|
// ];
|
|
// $reslut = db::name('user_data')->where('user_id',$user_id)->update($data);
|
|
// if(!$reslut){
|
|
// return ['code' => 0, 'msg' => '绑定失败','data' =>null];
|
|
// }
|
|
// }
|
|
return ['code' => 1, 'msg' => '绑定成功','data' =>null];
|
|
}
|
|
|
|
//绑定的详情
|
|
public function bind_xinxi_detail($user_id,$type)
|
|
{
|
|
if($type == 2){
|
|
$data = db::name('user_data')->where('user_id',$user_id)->field('id,alipay_name,alipay_account')->find();
|
|
}
|
|
if($type == 3){
|
|
$data = db::name('user_data')->where('user_id',$user_id)->field('id,bank_card_number,bank_user_name,bank_card,open_bank')->find();
|
|
}
|
|
return ['code' => 1, 'msg' => '获取成功','data' =>$data];
|
|
}
|
|
} |