update refund parse

This commit is contained in:
2026-03-04 14:29:25 +08:00
parent 26e5c6806c
commit a9ec179ead
2 changed files with 35 additions and 8 deletions
@@ -150,12 +150,18 @@ class Refund extends EntityParse
$tz = $this->getStore()->getTimezoneString();
$raw = \json_encode($record);
// 闪电退款优先使用 INSTANT_REFUND_WITHOUT_RETURN 类型
// 闪电退款: 覆盖退款类型 + 预填订单日期(闪电退款无原始订单,fillOrderDates 查不到)
$refund_type_id = $this->getRefundTypeId($record);
$instant_refund_order_date = null;
if (isset($record['attribute']) && $record['attribute'] !== '') {
$attr = $this->parseRefundItemAttribute($record['attribute']);
if (!empty($attr) && $attr['clj_zero_second_refund']) {
$refund_type_id = RefundType::INSTANT_REFUND_WITHOUT_RETURN->value;
// bgmtc 是「退款后台创建时间」,并非真实订单创建时间。
// 闪电退款场景下 Tmall 不推送原始订单,bgmtc 是我们能获取到的最接近订单创建时间的时间戳(误差在秒~分钟级别),
// 用作 order_created_date / order_paid_date 的近似值。
$date_str = $attr['bgmtc'] ?? $record['created'];
$instant_refund_order_date = Carbon::parse($date_str, $tz)->format('Y-m-d H:i:sP');
}
}
@@ -176,8 +182,8 @@ class Refund extends EntityParse
'platform_product_id' => isset($record['num_iid']) ? strval($record['num_iid']) : null,
'quantity' => $record['num'] ?? 0,
'refund_amount' => (float) ($record['refund_fee'] ?? 0),
'order_created_date' => null, // @attention 暂时设置为 null, 后续会批量更新
'order_paid_date' => null, // @attention 暂时设置为 null 后续会批量更新
'order_created_date' => $instant_refund_order_date, // 闪电退款用 bgmtc 预填,普通退款由 fillOrderDates 回填
'order_paid_date' => $instant_refund_order_date,
'created_date' => Carbon::parse($record['created'], $tz)->format('Y-m-d H:i:sP'),
'updated_date' => isset($record['modified']) ? Carbon::parse($record['modified'], $tz)->format('Y-m-d H:i:sP') : null,
'completed_date' => isset($record['end_time']) ? Carbon::parse($record['end_time'], $tz)->format('Y-m-d H:i:sP') : null,
@@ -424,7 +430,8 @@ class Refund extends EntityParse
$refund_ids[] = strval($record['refund_id']);
$buyer_user_id = $record['buyer_open_uid'] ?? $buyer_user_id;
// bgmtc后台创建时间)优先,否则使用退款创建时间
// bgmtc 是「退款后台创建时间」,非真实订单创建时间
// 但闪电退款场景下是最接近订单创建时间的近似值(误差秒~分钟级)。
if ($created_date === null) {
$date_str = $attr['bgmtc'] ?? $record['created'];
$created_date = Carbon::parse($date_str, $tz)->format('Y-m-d H:i:sP');
@@ -719,7 +726,7 @@ class Refund extends EntityParse
'channel_sub_order_id' => $pairs['chnlObn'] ?? null, // 渠道子订单编号
'last_order' => (bool) ($pairs['lastOrder'] ?? 0), // 是否最后一笔子单
'b2c' => (bool) ($pairs['b2c'] ?? 0), // 是否B2C
'bgmtc' => $pairs['bgmtc'] ?? null, // 退款后台创建时间
'bgmtc' => $pairs['bgmtc'] ?? null, // 退款后台创建时间(非订单创建时间,闪电退款场景用作订单时间近似值)
];
}