dever 6 years ago
parent
commit
e02b56ccc1
3 changed files with 11 additions and 5 deletions
  1. 4 2
      lib/Core.php
  2. 2 2
      lib/Wechat.php
  3. 5 1
      src/Api.php

+ 4 - 2
lib/Core.php

@@ -49,10 +49,12 @@ class Core
 	/**
 	 * 创建订单
 	 */
-	protected function createOrder($uid, $username, $account_id, $product_id, $name, $cash, $type)
+	protected function createOrder($uid, $username, $account_id, $product_id, $name, $cash, $type, $order_id = false)
 	{
 		$db = Dever::db('pay/order');
-		$order_id = Dever::order();
+		if (!$order_id) {
+			$order_id = Dever::order();
+		}
 		$info = $db->one(array('order_id' => $order_id));
 		if ($info) {
 			return $this->createOrder();

+ 2 - 2
lib/Wechat.php

@@ -33,10 +33,10 @@ class Wechat extends Core
 	/**
 	 * 获取统一下单的基本信息
 	 */
-	public function order($account_id, $uid, $username, $product_id, $name, $cash, $openid = false, $type = 1)
+	public function order($account_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, $product_id, $name, $cash, $this->config->GetType());
+		$order_id = $this->createOrder($uid, $username, $account_id, $product_id, $name, $cash, $this->config->GetType(), $order_id);
 		$tools = new \JsApiPay($this->config);
 		$openid = $openid ? $openid : $tools->GetOpenid();
 		$input = new \WxPayUnifiedOrder();

+ 5 - 1
src/Api.php

@@ -22,7 +22,7 @@ class Api
 				return $order;
 			}
 		}
-		return $this->method->order($this->account_id, $this->uid, $this->username, $this->product_id, $this->name, $this->cash, $this->openid, $type);
+		return $this->method->order($this->account_id, $this->uid, $this->username, $this->product_id, $this->name, $this->cash, $this->openid, $type, $this->order_id);
 	}
 
 	/**
@@ -98,6 +98,10 @@ class Api
 		$this->order_id = $this->getParam($param, 'order_id');
 		$this->openid = $this->getParam($param, 'openid');
 
+		if (!$this->order_id) {
+			$this->order_id = false;
+		}
+
 		if (!$this->account_id) {
 			Dever::alert('没有账户信息');
 		}