dever 6 年 前
コミット
6cbeb37241
4 ファイル変更30 行追加27 行削除
  1. 0 16
      lib/Alipay.php
  2. 8 0
      lib/Cmbc.php
  3. 16 10
      lib/Wechat.php
  4. 6 1
      src/Api.php

+ 0 - 16
lib/Alipay.php

@@ -64,7 +64,6 @@ class Alipay extends Core
 	 */
 	public function order($account_id, $project_id, $uid, $username, $product_id, $name, $cash, $openid = false, $type = 1, $order_id = false)
 	{
-		$trade_type = $this->getType($type);
 		$order_id = $this->createOrder($uid, $username, $account_id, $project_id, $product_id, $name, $cash, $this->config['type'], $order_id);
 
 		$aop = new \AopClient();
@@ -132,21 +131,6 @@ class Alipay extends Core
 		return $order;
 	}
 
-	private function getType($type)
-	{
-		switch ($type) {
-			case 1:
-				$type = 'JSAPI';
-				break;
-			
-			case 2:
-				$type = 'NATIVE';
-				break;
-		}
-
-		return $type;
-	}
-
 	private function check($data)
 	{
 		$aop = new \AopClient();

+ 8 - 0
lib/Cmbc.php

@@ -159,6 +159,14 @@ class Cmbc extends Core
 			case 2:
 				$type = 'NATIVE';
 				break;
+
+			case 3:
+				$type = 'APP';
+				break;
+
+			case 4:
+				$type = 'MWEB';
+				break;
 		}
 
 		return $type;

+ 16 - 10
lib/Wechat.php

@@ -39,9 +39,6 @@ class Wechat extends Core
 		$order_id = $this->createOrder($uid, $username, $account_id, $project_id, $product_id, $name, $cash, $this->config->GetType(), $order_id);
 		$tools = new \JsApiPay($this->config);
 
-		if ($openid != -1) {
-			$openid = $openid ? $openid : $tools->GetOpenid();
-		}
 		$input = new \WxPayUnifiedOrder();
 		$input->SetBody($name);
 		$input->SetAttach($name);
@@ -53,11 +50,16 @@ class Wechat extends Core
 		$input->SetNotify_url($this->config->GetNotifyUrl());
 		$input->SetTrade_type($trade_type);
 		$input->SetProduct_id($product_id);
-		if ($openid != -1) {
+		if ($type != 4 && $openid != -1) {
+			$openid = $openid ? $openid : $tools->GetOpenid();
 			$input->SetOpenid($openid);
 		}
-		
-		if ($type == 1 || $type == 3) {
+
+		if ($type == 2) {
+			# 下单信息
+			$this->updateOrderParam($order_id, $input);
+			return $input;
+		} else {
 			$order = \WxPayApi::unifiedOrder($this->config, $input);
 			# 下单信息
 			$order['time'] = '' . time() . '';
@@ -66,10 +68,6 @@ class Wechat extends Core
 			unset($order['mch_id']);
 			$this->updateOrderParam($order_id, $order);
 			return $order;
-		} else {
-			# 下单信息
-			$this->updateOrderParam($order_id, $input);
-			return $input;
 		}
 	}
 
@@ -141,6 +139,10 @@ class Wechat extends Core
 	 */
 	public function page($order, $refer)
 	{
+		if (isset($order['mweb_url'])) {
+			$order['mweb_url'] .= '&redirect_url=' . $refer;
+			return Dever::location($order['mweb_url']);
+		}
 		$refer = urldecode($refer);
 		$tools = new \JsApiPay($this->config);
 		$info = $tools->GetJsApiParameters($order);
@@ -197,6 +199,10 @@ class Wechat extends Core
 			case 3:
 				$type = 'APP';
 				break;
+
+			case 4:
+				$type = 'MWEB';
+				break;
 		}
 
 		return $type;

+ 6 - 1
src/Api.php

@@ -86,7 +86,11 @@ class Api
 		if (!$this->refer) {
 			Dever::alert('没有回调refer');
 		}
-		return $this->method->page($this->get(1), $this->refer);
+		$type = 1;
+		if ($this->h5 == 1) {
+			$type = 4;
+		}
+		return $this->method->page($this->get($type), $this->refer);
 	}
 
 	/**
@@ -123,6 +127,7 @@ class Api
 		$this->order_id = $this->getParam($param, 'order_id');
 		$this->openid = $this->getParam($param, 'openid');
 		$this->other = $this->getParam($param, 'other');
+		$this->h5 = $this->getParam($param, 'h5');
 
 		if (!$this->project_id) {
 			$this->project_id = false;