Beispiel #1
0
	public function pay()
	{
		$orderName = $_GET['orderName'];
		$orderid = $_GET['orderid'];

		if (!$orderid) {
			$orderid = $_GET['single_orderid'];
		}

		$payHandel = new payHandle($this->token, $_GET['from']);
		$orderInfo = $payHandel->beforePay($orderid);
		$price = $orderInfo['price'];

		if (!$orderInfo['old_price']) {
			exit('必须有价格才能支付');
		}

		$from = (isset($_GET['from']) ? $_GET['from'] : 'shop');
		$alipayConfig = $this->alipayConfig;
		$now_pay_type = '';

		if ($alipayConfig) {
			$pay_setting = array();
			$config_info = unserialize($alipayConfig['info']);

			foreach ($config_info as $key => $value) {
				if (is_array($value)) {
					if ($value['open']) {
						$key = ($key == 'alipay' ? 'Alipaytype' : ucwords($key));
						$pay_setting[$key] = $value;
						$now_pay_type = $key;
					}
				}
			}
		}

		if (empty($alipayConfig) || empty($now_pay_type)) {
			$now_pay_type = 'Alipaytype';
		}

		$this->assign('isFuwu', $this->isFuwu);
		$this->assign('isWechat', $this->isWechat);
		$this->assign('price', $price);
		$this->assign('orderName', $orderName);
		$this->assign('orderid', $orderid);
		$this->assign('from', $from);
		$this->assign('token', $this->token);
		$this->assign('wecha_id', $this->wecha_id);
		$this->assign('pay_setting', $pay_setting);
		$wxuser = M('Wxuser')->where(array('token' => $this->token))->find();
		$user = M('Users')->where(array('id' => $wxuser['uid']))->find();

		if (0 < $user['is_syn']) {
			$_GET['source'] = 'pigcms';
			redirect($user['source_domain'] . A('Home/Auth')->getCallbackUrl($user['is_syn'], 'pay') . http_build_query($_GET));
		}
		else {
			$obj = new Member_card_coupon_recordModel();
			$coupons = $obj->get_coupon($this->wecha_id, $this->token, $price);
			$this->assign('coupons', $coupons);
			$this->display('check');
		}
	}