更新退货处理

This commit is contained in:
yaooo 2023-08-17 11:11:53 +08:00
parent 913e268a50
commit 12b834bf33
4 changed files with 47 additions and 1 deletions

View File

@ -884,6 +884,8 @@ class StoreRefundOrderRepository extends BaseRepository
} else {
$storeOrderStatusRepository->createAdminLog($orderStatus);
}
// 通知物流退货
event('refund.deliver', compact('id', 'refund'));
event('refund.agree', compact('id', 'refund'));
});
}

View File

@ -71,6 +71,7 @@ return [
'product.delivery'=>[\app\listener\DeliveryGoods::class],
'product.sell'=>[\app\listener\CloudProduct::class], //商品上下架
'refund.after'=>[\app\listener\AfterRefund::class],
'refund.deliver'=>[\app\listener\DeliverRefund::class],
'order.create'=>[\app\listener\OrderCreate::class],
],

View File

@ -0,0 +1,43 @@
<?php
declare (strict_types=1);
namespace app\listener;
use think\facade\Log;
/**
* 订单退款通知物流
*/
class DeliverRefund
{
public function handle($event)
{
$orderId = $event['refund']['order']['order_id'] ?? 0;
$orderSn = $event['refund']['order']['order_sn'] ?? '';
Log::info('物流退货 - orderId' . $orderId . ' orderSn' . $orderSn);
if ($orderId && $orderSn) {
$this->sendLogistics($orderId, $orderSn);
}
}
//发送物流
public function sendLogistics($orderId, $orderSn)
{
Log::info("发送物流退货信息 orderId: {$orderId}, orderSn: {$orderSn}");
$postUrl = env('LOGISTICS_HOST_URL') . '/api/cancelOrder';
$curlPost = [
'order_id' => $orderId,
'order_sn' => $orderSn,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);
curl_close($ch);
Log::info("物流退货信息" . $data);
}
}

View File

@ -73,7 +73,7 @@ class SendGoodsCode
public function sendLogistics($orderId, $orderSn)
{
Log::info("发送物流信息 orderId: {$orderId}, orderSn: {$orderSn}");
$postUrl = env('LOGISTICS_LOGIS_URL');
$postUrl = env('LOGISTICS_HOST_URL') . '/api/lstSet';
$curlPost = [
'order_id' => $orderId,
'order_sn' => $orderSn,