Browse Source

RPC退款

master
weigang 6 years ago
parent
commit
5971299980
  1. 7
      app/JsonRpc/OrdersService.php

7
app/JsonRpc/OrdersService.php

@ -129,7 +129,7 @@ class OrdersService implements OrdersServiceInterface
* @param $note * @param $note
* @return array * @return array
*/ */
public function onlineSingleRefund($user_id, $note, $global_order_id, $order_child_id=null, $order_goods_id=null)
public function onlineSingleRefund($user_id, $note, $global_order_id, $order_child_id='', $order_goods_id='')
{ {
Db::beginTransaction(); Db::beginTransaction();
@ -168,7 +168,7 @@ class OrdersService implements OrdersServiceInterface
// 子订单 // 子订单
$orderChild = null; $orderChild = null;
if ($order_child_id) { if ($order_child_id) {
$orderChild = Order::query()->with('store:user_id')->where(['order_main_id' => $orderMain->global_order_id, 'id' => $order_child_id])->first();
$orderChild = Order::query()->with('store')->where(['order_main_id' => $orderMain->global_order_id, 'id' => $order_child_id])->first();
} }
// 订单商品 // 订单商品
@ -222,13 +222,14 @@ class OrdersService implements OrdersServiceInterface
]); ]);
throw new ErrorCodeException(ErrorCode::ORDER_REFUND_FAIL); throw new ErrorCodeException(ErrorCode::ORDER_REFUND_FAIL);
} }
// 开始退款 // 开始退款
$config = config('wxpay'); $config = config('wxpay');
$app = Factory::payment($config); $app = Factory::payment($config);
$app['guzzle_handler'] = CoroutineHandler::class; $app['guzzle_handler'] = CoroutineHandler::class;
$result = $app->refund->byOutTradeNumber( $result = $app->refund->byOutTradeNumber(
$orderMain->global_order_id, $orderMain->global_order_id,
$orderMain->global_order_id,
$orderMain->global_order_id.$order_child_id.$order_goods_id,
bcmul($orderMain->money, 100, 0), bcmul($orderMain->money, 100, 0),
bcmul($refundAmount, 100, 0), bcmul($refundAmount, 100, 0),
[ [

Loading…
Cancel
Save