예제 #1
0
  /**
   * 前期执行
   */
  public function _initialize(){
	//配置
	$configs = getCache('Config:list');
	$this->configs = $configs;
	$this->assign('configs',$configs);
    //dump($configs);exit;
	//购物车
	/*
	$shopcart=  session('shopcart');
	$this->shopcartnum = count($shopcart);
	$this->assign('shopcartnum', count($shopcart));
	*/
	//上级
	if($_GET['r']){
	  cookie('r',$_GET['r']);
	}
	//会员信息
	$member_msg = session('member_msg');
	$user = unserialize(authcode($member_msg,'DECODE'));
    $user['id'] = 107;//模拟用户

	if($user){
	  if($user['openid'] && !$user['id']){
		$to_url = C('MEMBER_SITE_URL').'/Member/message';
	    header("location:".$to_url);exit;
	  }
	  $model = D('Member');
	  $data['a.id'] = $user['id'];
	  $db_pre = C('DB_PREFIX');
	  $user = $model->alias('a')->join('`'.$db_pre.'member_wallet` as b on a.id=b.member_id')->join('`'.$db_pre.'member_msg` as c on a.id=c.member_id')->field('a.id,a.pid,a.nickname,logo,lv,lv_name,email,utype,username,realname,mobile,password,salt,pv_id,ct_id,province,city,create_time,last_login_time,balance,frozen,c.sex')->where($data)->find();
	  //echo $model->getlastsql();exit;
	  if($user['balance']==null){
		$data['update_time'] = time();
		$model->add($data);
	    $user['balance'] = 0;
		$user['frozen'] = 0;
		$user['update_time'] = time();
	  }
	  //dump($user);
	  $user['username'] = $user['username'] ? $user['username'] : $user['mobile'];
	  $this->user = $user;
	  $this->assign('user',$user);
	}
	$this->iswx = isWeixin();//是否微信浏览器
	$this->login_url = C('SITE_URL').'/index.php/Public/login';
	$this->register_url = C('SITE_URL').'/index.php/Public/register';
	if(!IS_AJAX){
		if($_SERVER['QUERY_STRING']){
		  $from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
		}else{
		  $from_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];	
		}
		$from_url_except = array('login','register','reg_do','verify','checkLogin','check_username','check_email','get_city');
		if(array_search(ACTION_NAME,$from_url_except)===false && CONTROLLER_NAME!='Public'){
		  $_SESSION['self_url'] = $from_url;
		}	
	}
	
	$this->assign('self_url',$_SESSION['self_url']);
  }
예제 #2
0
파일: index.php 프로젝트: macall/baikec_jsd
//将客户ip,传到mapi接口
$request_param['client_ip'] = get_client_ip();
if (isset($request_param['ctl'])) {
    $class = strtolower(strim($request_param['ctl']));
} else {
    $class = 'index';
}
if (isset($request_param['act'])) {
    $act2 = strtolower(strim($request_param['act'])) ? strtolower(strim($request_param['act'])) : "";
} else {
    $act2 = 'index';
}
if (empty($act2)) {
    $act2 = 'index';
}
$is_weixin = isWeixin();
$m_config = getMConfig();
//初始化手机端配置
//用户登陆处理;
user_login();
$user_info = es_session::get('user_info');
$request_param['session_id'] = es_session::id();
require_once APP_ROOT_PATH . 'system/utils/weixin.php';
if ($_REQUEST['code'] && $_REQUEST['state'] == 1 && $m_config['wx_app_key'] && $m_config['wx_app_secret'] && !$user_info) {
    require_once APP_ROOT_PATH . 'system/model/user.php';
    $weixin = new weixin($m_config['wx_app_key'], $m_config['wx_app_secret'], get_domain() . APP_ROOT . "/wap/index.php");
    global $wx_info;
    $wx_info = $weixin->scope_get_userinfo($_REQUEST['code']);
    $GLOBALS['tmpl']->assign('wx_info', $wx_info);
    //用户未登陆
    if ($wx_info['openid']) {
예제 #3
0
 public function showDownList()
 {
     if (isWeixin()) {
         $this->redirect('weixin');
     } else {
         $this->redirect('applist');
     }
 }
예제 #4
0
파일: fmapp.php 프로젝트: baby-bus/babyweb
function isWeixin()
{
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $is_weixin = strpos($agent, 'micromessenger') ? true : false;
    if ($is_weixin) {
        return true;
    } else {
        return false;
    }
}
switch (device()) {
    case "iphone":
        $url = "https://itunes.apple.com/cn/app/fu-mu-jiao-liu-zhong-xin-bao/id468891240?mt=8";
        break;
    case "ipad":
        $url = "https://itunes.apple.com/cn/app/fu-mu-jiao-liu-zhong-xinhd/id633348098?mt=8";
        break;
    case "ipod":
        $url = "https://itunes.apple.com/cn/app/fu-mu-jiao-liu-zhong-xin-bao/id468891240?mt=8";
        break;
    case "android":
        $url = "http://shouji.360tpcdn.com/140730/6faaed3b56f449e7f7412a78b8d1c574/com.sinyee.babybus.usercenter_8.apk";
        if (isWeixin()) {
            $url = "http://url.cn/PlxEfN";
        }
        break;
    default:
        $url = "https://itunes.apple.com/cn/app/fu-mu-jiao-liu-zhong-xin-bao/id468891240?mt=8";
        break;
}
header("Location:{$url}");
예제 #5
0
  /**
   *  收银台
   */
  public function pay(){
	//订单信息
	$model = M('Order');
	if($_REQUEST['order_sn']){
		$data['order_sn'] = $_REQUEST['order_sn'];
		$out_trade_no = $_REQUEST['order_sn'];
		//单一订单支付
		$notify_url = C('SITE_URL') . '/index.php/Wx_Payment/notify';
	}
	if($_REQUEST['mo_sn']){
		$data['mo_sn'] = $_REQUEST['mo_sn'];
		$out_trade_no = $_REQUEST['mo_sn'];
		//多订单合并支付
		$notify_url = C('SITE_URL') . '/index.php/Wx_Payment/notify_merge';
	}
	$data['member_id'] = $this->user['id'];
	$orders = $model->field('id,title,order_sn,total_fee,actual_paid,status')->where($data)->select();
	//echo $model->getlastsql();dump($orders);exit;
	if(!$orders){
		$this->error('订单不存在');
	}
	$total_fee = 0;
	$title = '';
	foreach($orders as $key=>$order){
		$total_fee += $order['total_fee'];
		$titles[] = $order['title'];
		if($order['status']!=1 || $order['pay_status']!=0){
			$this->error('订单:'.$order['order_id'].'状态错误');
		}
	}
	$body = implode(',',$titles);
	//支付接口请求
	/*
	require_once(C('INTERFACE_PATH')."Api/config.php");
	require_once(C('INTERFACE_PATH')."Api/Api.class.php");
	$api = new Api($config);
	$para['m'] = 'Payment';
	$para['a'] = 'wxWapPay';
	if($_REQUEST['order_sn'])$data['order_sn'] = $_REQUEST['order_sn'];
	if($_REQUEST['mo_sn'])$data['mo_sn'] = $_REQUEST['mo_sn'];
	$data['openid'] = 'oO8Umt19WO-Ci88IrRm2ywXgr9OM';
	$result = json_decode($api->get($para,$data),true);
	dump($result);exit;
	*/
	//如果是微信浏览器直接可支付
	$isWeixin = isWeixin();
	if($isWeixin){
		$openId = cookie('wx_real_openid');
		$openId = authcode($openId);
		$body = $body;
		$total_fee = $total_fee*100;
		$total_fee = (string)$total_fee;
		require_once C('INTERFACE_PATH')."wxwappay/lib/WxPay.Api.php";	
		require_once C('INTERFACE_PATH')."wxwappay/unit/WxPay.JsApiPay.php";
		$tools = new JsApiPay();
		$input = new WxPayUnifiedOrder();
		$input->SetBody($body);
		$input->SetOut_trade_no($out_trade_no);
		$input->SetTotal_fee($total_fee);
		$input->SetTime_start(date("YmdHis"));
		$input->SetTime_expire(date("YmdHis", time() + 600));
		//$input->SetGoods_tag("test");
		$input->SetNotify_url($notify_url);
		$input->SetTrade_type("JSAPI");
		$input->SetOpenid($openId);
		$payOrder = WxPayApi::unifiedOrder($input);
		$jsApiParameters = $tools->GetJsApiParameters($payOrder);
		$this->assign('jsApiParameters',$jsApiParameters);		
	}
	$this->assign('isWeixin',$isWeixin);
	$this->assign('order',$order);
	$this->assign('headerTitle','订单支付页');
	$this->assign('headerKeywords','订单支付页');
	$this->assign('headerDescription','订单支付页');
	$this->assign('wx_title','订单支付页');
	$this->assign('wx_desc',C('wx_desc'));
	$this->display();
  }
예제 #6
0
 /**
  *    根据提供的订单信息进行支付
  *
  *    @author    Garbin
  *    @param    none
  *    @return    void
  */
 function index()
 {
     /* 外部提供订单号 */
     $order_id = isset($_GET['order_id']) ? $_GET['order_id'] : 0;
     //数组的形式了
     if (stripos($order_id, "-")) {
         $orders = explode("-", $order_id);
     }
     /* 内部根据订单号收银,获取收多少钱,使用哪个支付接口 */
     $tag = true;
     $order_model =& m('order');
     //        $con= & m('orderextm');
     if ($orders) {
         $order_info['order_list'] = 1;
         foreach ($orders as $key => $id) {
             $order_info[$key] = $order_model->get("order_id={$id} AND buyer_id=" . $this->visitor->get('user_id'));
             $subtotal += $order_info[$key]['order_amount'];
             $order_info['order_amount'] += $order_info[$key]['order_amount'];
             $order_info['order_id'] = $order_id;
             $order_info['order_sn'] += $order_info[$key]['order_sn'];
             $order_info['buy_name'] = $order_info[$key]['buy_name'];
             //取出收获人的地址
             //                   $consignee=$con->get("order_id=".$id);
             if ($order_info[$key]['status'] != ORDER_PENDING) {
                 $this->show_warning('no_such_order');
                 return;
             }
             if (!$order_info[$key]['payment_id']) {
                 //还没有支付选项选择
                 $tag = false;
             }
         }
     } else {
         $order_info = $order_model->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id'));
         $subtotal = $order_info['order_amount'];
         if ($order_info['payment_code'] != 'cod' && $order_info['status'] != ORDER_PENDING) {
             $this->show_no();
             return;
         }
         if (!$order_info['payment_id']) {
             //还没有支付选项选择
             $tag = false;
         }
     }
     //分别判断有没有该订单的信息
     /* 订单有效性判断 */
     $payment_model =& m('payment');
     if (!$tag || !isset($_GET['payment_code'])) {
         /* 若还没有选择支付方式,则让其选择支付方式 */
         $payments = $payment_model->get_enabled(1);
         if (empty($payments)) {
             $this->show_no();
             return;
         }
         $all_payments = array('pc' => array(), 'wap' => array());
         //判断是线上支付还是线下支付
         foreach ($payments as $key => $payment) {
             if ($payment['is_wap'] > 0) {
                 if (isWeixin()) {
                     if ($payment['is_wap'] == 1) {
                         $all_payments['wap'][] = $payment;
                     }
                 } else {
                     if ($payment['is_wap'] > 1) {
                         $all_payments['wap'][] = $payment;
                     }
                 }
             }
         }
         foreach ($payments as $key => $payment) {
             if ($payment['is_wap'] < 1) {
                 $all_payments['pc'][] = $payment;
             }
         }
         if (isWeixin()) {
             $this->assign("iswei", 1);
             $payment_code = 'jspay';
             $payment_info = $payment_model->get("payment_code = '{$payment_code}' AND store_id=1");
             //获取支付接口的相关配
             ///* 生成支付URL或表单 */
             $wx = $this->_get_payment($payment_code, $payment_info);
             //获取该支付接口
             $wxparam = $wx->get_payform($order_info, $payment_code);
             $this->assign("wxparam", $wxparam);
             //wx 参数
         }
         $this->assign('subtotal', $subtotal);
         $this->assign('consignee', $consignee);
         $this->assign("order_id", $order_id);
         $this->assign('order', $order_info);
         $this->assign('payments', $all_payments);
         $this->_curlocal(LANG::get('cashier'));
         $this->_config_seo('title', Lang::get('confirm_payment') . ' - ' . Conf::get('site_title'));
         if (is_wap()) {
             $this->assign("title", "支付中心");
         }
         $this->display('cashier.payment.html');
     } else {
         /* 否则直接到网关支付 */
         $payment_code = $_GET['payment_code'];
         $order_info['payment_code'] = $payment_code;
         $payment_info = $payment_model->get("payment_code = '{$payment_code}' AND store_id=1");
         //获取支付接口的相关配置
         /* 生成支付URL或表单 */
         $payment = $this->_get_payment($payment_code, $payment_info);
         //获取该支付接口
         $payment_form = $payment->get_payform($order_info, $payment_code);
         //            if(isWeixin()){
         //
         //                 $this->assign("wxparam",$payment_form);
         //                $data=$this->fetch("wx.html");
         //                 echo $data;
         //                 exit;
         //             }
         /* 微信支付,则显示提示页面 */
         if ($payment_info['payment_code'] == 'wxnative') {
             /* 跳转到真实收银台 */
             $this->_config_seo('title', Lang::get('cashier'));
             $this->assign('payform', $payment_form);
             $this->assign('payment', $payment_info);
             $this->assign('order', $order_info);
             header('Content-Type:text/html;charset=' . CHARSET);
             if (is_wap()) {
                 $this->assign("title", "立即支付");
             }
             $this->display('cashier.payform_wxnative.html');
             return;
         }
         /* 跳转到真实收银台 */
         $this->_config_seo('title', Lang::get('cashier'));
         $this->assign('payform', $payment_form);
         $this->assign('payment', $payment_info);
         $this->assign('order', $order_info);
         header('Content-Type:text/html;charset=' . CHARSET);
         if (is_wap()) {
             $this->assign("title", "支付成功");
         }
         $this->display('cashier.payform.html');
     }
 }