rabin 10 months ago
parent
commit
e18e2aa73e
3 changed files with 7 additions and 5 deletions
  1. 5 2
      lib/Core.php
  2. 1 2
      lib/Yspay.php
  3. 1 1
      src/Api.php

+ 5 - 2
lib/Core.php

@@ -175,12 +175,15 @@ class Core
 	}
 
 	# 退款
-	public function refundByOrder($order_id, $refund_order_id = false, $refund_cash = false)
+	public function refundByOrder($order_id, $refund_order_id = false, $refund_cash = false, $other = false)
 	{
 		$info = Dever::db('pay/order')->one(array('order_id' => $order_id));
 		if ($info && ($info['status'] == 1 || $info['status'] == 2 || $info['status'] == 6)) {
 			if ($info['param']) {
 				$info['param'] = Dever::array_decode($info['param']);
+				if (isset($info['param']['other']) && $info['param']['other'] && $other) {
+					$info['param']['other'] = $other;
+				}
 			}
 			$cash = $refund_cash ? $refund_cash : $info['cash'];
 			$refund_data = array();
@@ -198,7 +201,7 @@ class Core
 				}
 				$refund_order_id = $refund_order_id . '_' . Dever::order();
 			}
-			$state = $this->refund($info['order_id'], $cash, $info, $refund_order_id);
+			$state = $this->refund($info['order_id'], $cash, $info, $refund_order_id, $other);
 			if ($state) {
 				if ($refund_order_id) {
 					$status = 6;

+ 1 - 2
lib/Yspay.php

@@ -290,13 +290,12 @@ class Yspay extends Core
 			if (!isset($other[0])) {
 				$other = array($other);
 			}
-			$request['platformAmount'] = $request['refundAmount'];
+			$request['platformAmount'] = 0;
 			$request['subOrders'] = array();
 			foreach ($other as $k => $v) {
 				$subOrders = array();
 				if (isset($v['amount']) && $v['amount']) {
 					$subOrders['totalAmount'] = round($v['amount'] * 100, 2);
-					$request['platformAmount'] = round($request['platformAmount'] - $subOrders['totalAmount'], 2);
 				} elseif (isset($v['per']) && $v['per']) {
 					$v['per'] = $v['per'] && $v['per'] >= 0 ? $v['per'] : 0;
 					$v['per'] = $v['per']/100;

+ 1 - 1
src/Api.php

@@ -183,7 +183,7 @@ class Api
 		$this->order_id = $this->getParam($param, 'order_id');
 		$this->refund_order_id = $this->getParam($param, 'refund_order_id');
 		$this->refund_cash = $this->getParam($param, 'refund_cash');
-		return $this->method->refundByOrder($this->order_id, $this->refund_order_id, $this->refund_cash);
+		return $this->method->refundByOrder($this->order_id, $this->refund_order_id, $this->refund_cash, $this->other);
 	}
 
 	/**