check_user_info($call_back); //流程 wx_url 有值跳转,到微信绑定 // user_info 有值已绑定 //user_info 无值 ,没有账号,“用户未登陆方维主播,请先登录注册再绑定” /*if($this->user_info){ $data['user_info'] = $this->user_info; if($from!='app'){ $show_url = SITE_DOMAIN.'/index.php?c=money_carry_wx.php'; app_redirect($show_url); } }else{ $data['user_info'] = false; } $data['wx_url'] = $this->wx_url; $data['app_down'] = SITE_DOMAIN.'/mapi/index.php?ctl=app_download'; header("Content-Type:text/html; charset=utf-8"); echo(json_encode($data)); exit;*/ } //检查用户是否登陆 public function check_user_info($back_url){ if($_REQUEST['ttype']==1){ return true; } $is_weixin=isWeixin(); if(!$is_weixin){ return false; } fanwe_require(APP_ROOT_PATH."system/utils/weixin.php"); $m_config = load_auto_cache("m_config");//初始化手机端配置 if($m_config['wx_gz_appid']==''||$m_config['wx_gz_secrit']==''){ print_r("公众号未配置");exit; }else{ $wx_appid = strim($m_config['wx_gz_appid']); $wx_secrit = strim($m_config['wx_gz_secrit']); } $wx_status = (($wx_appid&&$wx_secrit))?1:0; if($_REQUEST['code']&&$_REQUEST['state']==1&&$wx_status){ $weixin=new weixin($wx_appid,$wx_secrit,$back_url); $wx_info=$weixin->scope_get_userinfo($_REQUEST['code']); $url1 = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$wx_appid."&secret=".$wx_secrit; $access_token_info=$weixin->https_request($url1); $access_token_info_str=json_decode($access_token_info['body'],1); $url2="https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$access_token_info_str['access_token']."&openid=".$wx_info['openid']."&lang=zh_CN"; $unionid_info=$weixin->https_request($url2); $unionid_info_str=json_decode($unionid_info['body'],1); $wx_info['subscribe']=$unionid_info_str['subscribe']; $wx_info['openid']=$unionid_info_str['openid']; $wx_info['unionid']=$unionid_info_str['unionid']; /*if($wx_info['errcode']>0){ var_dump($wx_info);exit; }*/ }else{ if($is_weixin&&$wx_status){ $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url); $wx_url=$weixin_2->scope_get_code(); app_redirect($wx_url); }else{ $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url); $wx_url=$weixin_2->scope_get_code(); app_redirect($wx_url); } } if($wx_info['openid']!=''){ if($wx_info['unionid']==''){ echo '
公众号未绑定开放平台
';exit; } $has_user = $GLOBALS['db']->getAll("select id,head_image,nick_name from ".DB_PREFIX."user where wx_unionid = '".$wx_info['unionid']."' "); $total = count($has_user); if(intval($total)==0){ $this->wx_url = ''; $this->user_info = false; $app_down = SITE_DOMAIN.'/mapi/index.php?ctl=app_download'; echo '
您还未登陆'.$m_config['short_name'].',请先登录注册再绑定
点击立即下载
';exit; }else{ $data_info = array(); if($has_user['gz_openid']!=$wx_info['openid']){ $data_info['gz_openid'] = $wx_info['openid']; } if($has_user['subscribe']!=$wx_info['subscribe']){ $data_info['subscribe'] = $wx_info['subscribe']; } $user = array(); $html = ''; foreach($has_user as $k=>$v){ $arr[$k] =$v['id']; $user[$k]['head_image'] = get_spec_image($v['head_image']); $user[$k]['nick_name'] = $v['nick_name']; $user[$k]['id'] = $v['id']; fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php'); fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php'); $user_redis = new UserRedisService(); $fields = array("ticket","refund_ticket"); $user_ticket_info = $user_redis->getRow_db($v['id'],$fields); $ticket_catty_ratio = $GLOBALS['db']->getOne("select alone_ticket_ratio from ".DB_PREFIX."user where id=".$v['id']); if($ticket_catty_ratio==''){ $ticket_catty_ratio = $m_config['ticket_catty_ratio']; } $ticket = intval($user_ticket_info['ticket'])-intval($user_ticket_info['refund_ticket']); $money = number_format($ticket*$ticket_catty_ratio,2); $user[$k]['ticket'] =$ticket; $user[$k]['use_ticket'] =$money/$ticket_catty_ratio; $user[$k]['money'] = $money; $ready_refund_id =intval($GLOBALS['db']->getOne("select id from ".DB_PREFIX."user_refund where user_id = ".intval($v['id'])." and (is_pay =0 or is_pay=1)")); $submit = SITE_DOMAIN.'/mapi/index.php?ctl=user_center&act=submitrefundwx&&id='.$k; $html .='
'; $submit = ''; } $arr_id =implode(',',$arr); $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data_info,'UPDATE'," id in (".$arr_id.")"); $user_info = $has_user; es_session::set("user_info_wx", $user); } $user_info['authorizer_access_token'] = $wx_info['authorizer_access_token']; $user_info['authorizer_appid'] = $wx_info['authorizer_appid']; echo ' 微信提现
请选择要领取红包的帐号
'.$html.' '; }else{ $weixin_2=new weixin($wx_appid,$wx_secrit,$back_url,'snsapi_base'); $wx_url=$weixin_2->scope_get_code(); app_redirect($wx_url); } } //充值页面 public function recharge(){ $refresh = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind&act=recharge'; $tips = ' 微信充值 xxxx '; $sql = "select id,name,class_name,logo from ".DB_PREFIX."payment where is_effect = 1 and class_name='Wwxjspay'"; $pay = $GLOBALS['db']->getRow($sql,true,true); if(intval($pay['id'])==0){ $error = "未开启微信充值."; echo str_replace('xxxx',$error,$tips);return; } array_unique($_REQUEST); $m_config = load_auto_cache("m_config");//初始化手机端配置 $user_id = intval(strim($_REQUEST['user_id'])); $is_pay = $_REQUEST['is_pay']; $rule_id = intval($_REQUEST['rule_id']); $rule_money = floatval($_REQUEST['rule_money']); if($is_pay!=''){ $data['error_tip'] = '请输入'.$m_config['account_name']; $data['error_color'] = 'style="color:red"'; if(strim($_REQUEST['user_id'])!=''){ $user_info = $GLOBALS['db']->getOne("select id from ".DB_PREFIX."user where id =".$user_id); $data['error_tip'] = $m_config['account_name'].'不存在'; $data['error_color'] = 'style="color:red"'; if($user_info){ if($is_pay==1){ $data['error_tip'] = ''; $data['error_color'] = 'style="color:red"'; $data['rule_tip'] = "请选择充值金额"; if($rule_id){ $data['rule_tip'] = ''; $sql = "select id,money,name,iap_money,product_id,(diamonds+gift_diamonds) as diamonds from ".DB_PREFIX."recharge_rule where is_effect = 1 and is_delete = 0 and id =".$rule_id; $rule = $GLOBALS['db']->getRow($sql,true,true); $payment_notice['create_time'] = NOW_TIME; $payment_notice['user_id'] = $user_id; $payment_notice['payment_id'] = $pay['id']; $payment_notice['money'] = $rule['money']; $payment_notice['diamonds'] = $rule['diamonds'];//充值时,获得的钻石数量 $payment_notice['recharge_id'] = $rule['id']; $payment_notice['recharge_name'] = $rule['name']; $payment_notice['product_id'] = $rule['product_id']; $payment_notice['notice_sn'] = to_date(NOW_TIME,"YmdHis").rand(100,999); $GLOBALS['db']->autoExecute(DB_PREFIX."payment_notice",$payment_notice,"INSERT","","SILENT"); $notice_id = $GLOBALS['db']->insert_id(); $url = url_mapi("wx_bind#go_pay",array('id'=>$notice_id)); app_redirect(get_domain().'/mapi'.$url); } }else{ $data['error_tip'] = '验证通过'; $data['error_color'] = 'style="color:green"'; } } } } //print_r($data);exit; $rule_list = load_auto_cache("rule_list"); $html = '

'.$m_config['short_name'].'直播

'.$m_config['account_name'].'
'; if($data['error_tip']){ $html.=' 
'.$data['error_tip'].'
'; } $html.='
充值金额
'; foreach($rule_list as $k=>$v){ $html.='

购买'.$v['diamonds'].'钻石

'; } $html.='
应付金额
'.$rule_money.' '; if($data['rule_tip']){ $html.=$data['rule_tip']; } $html.='
确认支付
'; echo ' '.$m_config['short_name'].'充值 '.$html.' '; } /* * 微信公众号充值 */ public function go_pay(){ $refresh = SITE_DOMAIN.'/mapi/index.php?ctl=wx_bind&act=recharge'; $notice_id = $_REQUEST['id']; $payment_notice = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."payment_notice where id = ".$notice_id,true,true); $payment_info = $GLOBALS['db']->getRow("select id,class_name from ".DB_PREFIX."payment where id=".intval($payment_notice['payment_id']),true,true); $class_name = $payment_info['class_name']."_payment"; fanwe_require(APP_ROOT_PATH."system/payment/".$class_name.".php"); $o = new $class_name; $pay_info= $o->get_payment_code($notice_id); $html = ' 微信支付
支付金额为'.$payment_notice['money'].'

'; echo $html;exit; } } ?>