|
|
@@ -507,4 +507,110 @@ class OrderService extends AlibabaAgentBaseService
|
|
507
|
507
|
'rawData' => $result,
|
|
508
|
508
|
];
|
|
509
|
509
|
}
|
|
|
510
|
+
|
|
|
511
|
+ /**
|
|
|
512
|
+ * 查询退款退货原因列表
|
|
|
513
|
+ *
|
|
|
514
|
+ * API: com.alibaba.trade:alibaba.trade.getRefundReasonList-1
|
|
|
515
|
+ *
|
|
|
516
|
+ * 接口文档: https://open.1688.com/api/apidocdetail.htm?id=com.alibaba.trade%3Aalibaba.trade.getRefundReasonList-1
|
|
|
517
|
+ *
|
|
|
518
|
+ * 请求参数:
|
|
|
519
|
+ * - orderId: 订单号(必填)
|
|
|
520
|
+ * - orderEntryIds: 子订单号(可选,多个用逗号分隔)
|
|
|
521
|
+ *
|
|
|
522
|
+ * 返回示例:
|
|
|
523
|
+ * {
|
|
|
524
|
+ * "result": [
|
|
|
525
|
+ * {
|
|
|
526
|
+ * "refundId": "REFUND123456",
|
|
|
527
|
+ * "refundType": "退货退款",
|
|
|
528
|
+ * "refundStatus": "waitSellerAgree",
|
|
|
529
|
+ * "refundReasonList": [
|
|
|
530
|
+ * {
|
|
|
531
|
+ * "reasonId": 1,
|
|
|
532
|
+ * "reasonText": "质量问题"
|
|
|
533
|
+ * }
|
|
|
534
|
+ * ]
|
|
|
535
|
+ * }
|
|
|
536
|
+ * ],
|
|
|
537
|
+ * "success": true
|
|
|
538
|
+ * }
|
|
|
539
|
+ *
|
|
|
540
|
+ * @param array $params 请求参数(orderId 必填)
|
|
|
541
|
+ * @return array|false
|
|
|
542
|
+ */
|
|
|
543
|
+ public function getRefundReasonList(array $params = [])
|
|
|
544
|
+ {
|
|
|
545
|
+ // --- 参数校验 ---
|
|
|
546
|
+ if (empty($params['orderId'])) {
|
|
|
547
|
+ Log::channel('alibaba')->error('[获取退款原因] orderId不能为空');
|
|
|
548
|
+ return false;
|
|
|
549
|
+ }
|
|
|
550
|
+
|
|
|
551
|
+ $businessParams = [
|
|
|
552
|
+ 'orderId' => (string)$params['orderId'],
|
|
|
553
|
+ ];
|
|
|
554
|
+
|
|
|
555
|
+ // 可选参数:子订单号
|
|
|
556
|
+ if (!empty($params['orderEntryIds'])) {
|
|
|
557
|
+ $businessParams['orderEntryIds'] = (string)$params['orderEntryIds'];
|
|
|
558
|
+ }
|
|
|
559
|
+
|
|
|
560
|
+ // --- 调用API ---
|
|
|
561
|
+ $result = $this->executeParam2(
|
|
|
562
|
+ self::NAMESPACE,
|
|
|
563
|
+ 'alibaba.trade.getRefundReasonList',
|
|
|
564
|
+ 1,
|
|
|
565
|
+ $businessParams
|
|
|
566
|
+ );
|
|
|
567
|
+
|
|
|
568
|
+ if ($result === false) {
|
|
|
569
|
+ Log::channel('alibaba')->error('[获取退款原因] API请求失败, params:' . json_encode($businessParams, JSON_UNESCAPED_UNICODE));
|
|
|
570
|
+ return false;
|
|
|
571
|
+ }
|
|
|
572
|
+
|
|
|
573
|
+ Log::channel('alibaba')->info('[获取退款原因] API请求成功, result:' . json_encode($result, JSON_UNESCAPED_UNICODE));
|
|
|
574
|
+
|
|
|
575
|
+ return $this->formatRefundReasonListResult($result);
|
|
|
576
|
+ }
|
|
|
577
|
+
|
|
|
578
|
+ /**
|
|
|
579
|
+ * 格式化退款退货原因列表返回结果
|
|
|
580
|
+ *
|
|
|
581
|
+ * @param array $result API原始返回数据
|
|
|
582
|
+ * @return array
|
|
|
583
|
+ */
|
|
|
584
|
+ protected function formatRefundReasonListResult(array $result): array
|
|
|
585
|
+ {
|
|
|
586
|
+ $success = $result['success'] ?? false;
|
|
|
587
|
+ $refundList = [];
|
|
|
588
|
+
|
|
|
589
|
+ if (isset($result['result']) && is_array($result['result'])) {
|
|
|
590
|
+ foreach ($result['result'] as $item) {
|
|
|
591
|
+ $reasons = [];
|
|
|
592
|
+ if (isset($item['refundReasonList']) && is_array($item['refundReasonList'])) {
|
|
|
593
|
+ foreach ($item['refundReasonList'] as $reason) {
|
|
|
594
|
+ $reasons[] = [
|
|
|
595
|
+ 'reasonId' => $reason['reasonId'] ?? '',
|
|
|
596
|
+ 'reasonText' => $reason['reasonText'] ?? '',
|
|
|
597
|
+ ];
|
|
|
598
|
+ }
|
|
|
599
|
+ }
|
|
|
600
|
+
|
|
|
601
|
+ $refundList[] = [
|
|
|
602
|
+ 'refundId' => $item['refundId'] ?? '',
|
|
|
603
|
+ 'refundType' => $item['refundType'] ?? '',
|
|
|
604
|
+ 'refundStatus' => $item['refundStatus'] ?? '',
|
|
|
605
|
+ 'refundReasonList' => $reasons,
|
|
|
606
|
+ ];
|
|
|
607
|
+ }
|
|
|
608
|
+ }
|
|
|
609
|
+
|
|
|
610
|
+ return [
|
|
|
611
|
+ 'success' => $success,
|
|
|
612
|
+ 'refundList' => $refundList,
|
|
|
613
|
+ 'rawData' => $result,
|
|
|
614
|
+ ];
|
|
|
615
|
+ }
|
|
510
|
616
|
}
|