dever 3 years ago
parent
commit
5e2ce0cc9d
3 changed files with 14 additions and 4 deletions
  1. 4 1
      lib/Core.php
  2. 1 1
      lib/Test.php
  3. 9 2
      src/Api.php

+ 4 - 1
lib/Core.php

@@ -3,6 +3,8 @@ use Dever;
 
 class Core
 {
+	public $order_id;
+
 	/**
 	 * 更新订单状态
 	 */
@@ -105,7 +107,7 @@ class Core
 	protected function createOrder($uid, $username, $account_id, $project_id, $product_id, $name, $cash, $type, $order_id = false)
 	{
 		if ($this->checkOrder($order_id)) {
-			return $order_id;
+			return $this->order_id = $order_id;
 		}
 		
 		$state = $order_id;
@@ -113,6 +115,7 @@ class Core
 		if (!$state) {
 			$order_id = Dever::order();
 		}
+		$this->order_id = $order_id;
 		$info = $db->one(array('order_id' => $order_id));
 		if ($info) {
 			if (!$state) {

+ 1 - 1
lib/Test.php

@@ -25,7 +25,7 @@ class Test extends Core
 
 		$this->updateOrder($order_id, $cash);
 
-		return 'test';
+		return '';
 	}
 
 	/**

+ 9 - 2
src/Api.php

@@ -79,7 +79,12 @@ class Api
 				$method = $method[1];
 				$param['other'] = $receipt;
 			}
-			return $this->$method($param);
+			$result = array();
+			$result['order'] = $this->$method($param);
+			$result['order_id'] = $this->method->order_id;
+			$result['type'] = $this->type;
+
+			return $result;
 		} else {
 			Dever::alert('错误的source');
 		}
@@ -130,7 +135,7 @@ class Api
 	public function page($param = array())
 	{
 		$this->init($param);
-		if (!$this->refer) {
+		if (!$this->refer && $this->type != 'test') {
 			Dever::alert('没有回调refer');
 		}
 		$type = 1;
@@ -290,6 +295,8 @@ class Api
 			$pay['type'] = 'test';
 		}
 
+		$this->type = $pay['type'];
+
 		$method = '\\Pay\\Lib\\' . ucwords($pay['type']);
 		if (isset($this->refer) && $this->refer) {
 			$pay['refer'] = $this->refer;