fix(pay): preserve order note JSON, shared coupon burn, plate free VIP cashier

- Order_Repository: status note merges into JSON as status_note instead of wiping coupon/topic_pay meta
- Extract aksrt_burn_order_coupon / aksrt_coupon_usage_exists for content + topic
- Money plate follow (incl. VIP free) always opens multi-gateway cashier for 0-order ledger
This commit is contained in:
kate522 committed 2026-07-15 13:13:02 +08:00
1 parent 183c11ca55
commit 8ff1408450
8 files changed
+119 -65

No files matched your search

+28 -1
View File
@@ -316,7 +316,17 @@ class AKSRT_Order_Repository {
}
if (!empty($extra['note'])) {
$update_data['note'] = sanitize_textarea_field($extra['note']);
// Preserve JSON pay meta (coupon/topic_pay/content_pay/…); stash human text as status_note.
$status_note = sanitize_textarea_field((string) $extra['note']);
$raw_note = isset($order['note']) && is_string($order['note']) ? $order['note'] : '';
$decoded_note = $raw_note !== '' ? json_decode($raw_note, true) : null;
if (is_array($decoded_note)) {
$decoded_note['status_note'] = $status_note;
$merged = wp_json_encode($decoded_note, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$update_data['note'] = is_string($merged) ? $merged : $status_note;
} else {
$update_data['note'] = $status_note;
}
$format[] = '%s';
}
@@ -331,6 +341,23 @@ class AKSRT_Order_Repository {
'payment_method' => $update_data['payment_method'] ?? ($order['payment_method'] ?? ''),
'payment_transaction_id' => $update_data['payment_transaction_id'] ?? ($order['payment_transaction_id'] ?? ''),
]);
if (isset($update_data['note'])) {
// Keep pre-update JSON payload for listeners (coupon burn etc.);
// only attach status_note if callers mutated note.
$pre_meta = [];
$pre_raw = isset($order['note']) && is_string($order['note']) ? $order['note'] : '';
if ($pre_raw !== '') {
$pre_decoded = json_decode($pre_raw, true);
if (is_array($pre_decoded)) {
$pre_meta = $pre_decoded;
}
}
if ($pre_meta !== []) {
$paid_order['meta_payload'] = $pre_meta;
// Prefer merged DB note (JSON + status_note) for downstream reads.
$paid_order['note'] = $update_data['note'];
}
}
/**
* 订单到账。