Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
833f94bf3a | ||
|
|
aad83072a8 |
No files matched your search
@@ -73,7 +73,7 @@ export const paymentSection = {
|
|||||||
route: '/payment/gateway',
|
route: '/payment/gateway',
|
||||||
status: 'available',
|
status: 'available',
|
||||||
title: '收款接口',
|
title: '收款接口',
|
||||||
desc: '微信/支付宝接口选择、PayPal/Stripe 开关、货币结算、显示顺序与订单编号前缀。',
|
desc: '微信/支付宝接口选择、PayPal/Stripe 开关、货币结算、显示顺序与订单支付时效。',
|
||||||
canonicalDomain: 'payment',
|
canonicalDomain: 'payment',
|
||||||
section: 'gateway',
|
section: 'gateway',
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ const currencyOptions = [
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 收款接口 — 参考主题双下拉式重构:微信/支付宝接口选择(官方/易支付/关闭)、
|
* 收款接口 — 参考主题双下拉式重构:微信/支付宝接口选择(官方/易支付/关闭)、
|
||||||
* PayPal/Stripe 独立开关、货币与结算、订单与编号(含三个前缀)、
|
* PayPal/Stripe 独立开关、货币与结算、订单与编号、
|
||||||
* 收款接口显示顺序,以及 5 个凭据配置块(支付宝/微信/PayPal/Stripe/易支付)。
|
* 收款接口显示顺序,以及 5 个凭据配置块(支付宝/微信/PayPal/Stripe/易支付)。
|
||||||
*/
|
*/
|
||||||
export const gatewaySchema = {
|
export const gatewaySchema = {
|
||||||
key: 'payment.gateway',
|
key: 'payment.gateway',
|
||||||
title: '收款接口',
|
title: '收款接口',
|
||||||
icon: 'fa fas fa-credit-card',
|
icon: 'fa fas fa-credit-card',
|
||||||
description: '配置收款通道:微信与支付宝可在官方/易支付之间选择,PayPal 与 Stripe 独立开关。订单前缀、流水号前缀、提现单号前缀在本页配置。',
|
description: '配置收款通道:微信与支付宝可在官方/易支付之间选择,PayPal 与 Stripe 独立开关。订单、资金流水与提现统一使用同一套自动流水号,无需配置前缀。',
|
||||||
defaults: {
|
defaults: {
|
||||||
pay_wechat_sdk_options: 'null',
|
pay_wechat_sdk_options: 'null',
|
||||||
pay_alipay_sdk_options: 'null',
|
pay_alipay_sdk_options: 'null',
|
||||||
@@ -49,9 +49,6 @@ export const gatewaySchema = {
|
|||||||
pay_alipay_settle: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
|
pay_alipay_settle: { settle_rate: '1', settle_mark: '¥', settle_unit: '元' },
|
||||||
pay_sdk_custom_title_s: false,
|
pay_sdk_custom_title_s: false,
|
||||||
pay_sdk_custom_title: '',
|
pay_sdk_custom_title: '',
|
||||||
payment_order_prefix: 'AKSRT',
|
|
||||||
payment_flow_prefix: 'AK',
|
|
||||||
payment_withdrawal_prefix: 'TX',
|
|
||||||
payment_order_expiry: 30,
|
payment_order_expiry: 30,
|
||||||
pay_wait_float_s: true,
|
pay_wait_float_s: true,
|
||||||
pay_sdk_order: {},
|
pay_sdk_order: {},
|
||||||
@@ -167,11 +164,8 @@ export const gatewaySchema = {
|
|||||||
key: 'order',
|
key: 'order',
|
||||||
title: '订单与编号',
|
title: '订单与编号',
|
||||||
icon: 'fa fas fa-hashtag',
|
icon: 'fa fas fa-hashtag',
|
||||||
description: '订单号、流水号与提现单号的前缀配置(原名配置项保留于此)。',
|
description: '订单支付时效与浮窗提示;订单、资金流水与提现的流水号由系统统一自动分配,无需配置。',
|
||||||
fields: [
|
fields: [
|
||||||
{ key: 'payment_order_prefix', label: '订单前缀', type: 'input', default: 'AKSRT', help: '订单号生成前缀' },
|
|
||||||
{ key: 'payment_flow_prefix', label: '流水号前缀', type: 'input', sanitize_type: 'business_prefix', default: 'AK', maxlength: 12, help: '仅允许字母、数字、下划线和短横线,最多 12 位。' },
|
|
||||||
{ key: 'payment_withdrawal_prefix', label: '提现单号前缀', type: 'input', sanitize_type: 'business_prefix', default: 'TX', maxlength: 12, help: '仅允许字母、数字、下划线和短横线,最多 12 位。' },
|
|
||||||
{ key: 'payment_order_expiry', label: '订单支付时效(分钟)', type: 'number', default: 30, min: 5, max: 1440, help: '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)' },
|
{ key: 'payment_order_expiry', label: '订单支付时效(分钟)', type: 'number', default: 30, min: 5, max: 1440, help: '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)' },
|
||||||
{ key: 'pay_wait_float_s', label: '浮窗显示待支付订单', type: 'switch', default: true, help: '将用户待支付订单一直显示在右上角,提醒用户付款' },
|
{ key: 'pay_wait_float_s', label: '浮窗显示待支付订单', type: 'switch', default: true, help: '将用户待支付订单一直显示在右上角,提醒用户付款' },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ export const knowledgeSchema = {
|
|||||||
{ key: 'pay_mark', label: '付费标记', type: 'input', default: '付费' },
|
{ key: 'pay_mark', label: '付费标记', type: 'input', default: '付费' },
|
||||||
{ key: 'payment_show_ip', label: '显示用户IP', type: 'switch', default: false },
|
{ key: 'payment_show_ip', label: '显示用户IP', type: 'switch', default: false },
|
||||||
{ key: 'payment_show_device', label: '显示设备信息', type: 'switch', default: false },
|
{ key: 'payment_show_device', label: '显示设备信息', type: 'switch', default: false },
|
||||||
{ key: 'payment_show_order_no', label: '显示订单号', type: 'switch', default: true },
|
{ key: 'payment_show_order_no', label: '显示流水号', type: 'switch', default: true },
|
||||||
{ key: 'payment_show_create_time', label: '显示创建时间', type: 'switch', default: true },
|
{ key: 'payment_show_create_time', label: '显示创建时间', type: 'switch', default: true },
|
||||||
{ key: 'payment_show_pay_time', label: '显示支付时间', type: 'switch', default: true },
|
{ key: 'payment_show_pay_time', label: '显示支付时间', type: 'switch', default: true },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -92,8 +92,71 @@
|
|||||||
.aksrt-orders-page__empty i { display: block; margin-bottom: 12px; color: var(--color-primary, #3b82f6); font-size: 30px; }
|
.aksrt-orders-page__empty i { display: block; margin-bottom: 12px; color: var(--color-primary, #3b82f6); font-size: 30px; }
|
||||||
.aksrt-orders-page__empty h3 { margin: 0 0 7px; font-size: 15px; }.aksrt-orders-page__empty p { margin: 0 0 16px; color: var(--orders-muted); font-size: 13px; }
|
.aksrt-orders-page__empty h3 { margin: 0 0 7px; font-size: 15px; }.aksrt-orders-page__empty p { margin: 0 0 16px; color: var(--orders-muted); font-size: 13px; }
|
||||||
|
|
||||||
.aksrt-order-detail__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; padding: 12px 16px; border-top: 1px solid var(--orders-line); background: var(--surface-2, #f7f8fb); }
|
/* ---- Order detail modal (front-end order center) ---- */
|
||||||
.aksrt-order-detail__hero { display: flex; align-items: center; justify-content: space-between; padding: 15px; border-radius: 11px; background: color-mix(in srgb, var(--color-primary, #3b82f6) 9%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__hero.is-pending { background: color-mix(in srgb, var(--color-warning, #c87819) 11%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__hero.is-paid { background: color-mix(in srgb, var(--color-success, #168560) 10%, var(--surface-2, #f7f8fb)); }.aksrt-order-detail__status-pill { font-size: 12px; font-weight: 700; }.aksrt-order-detail__hero-amount { font-size: 23px; font-variant-numeric: tabular-nums; }.aksrt-order-detail__product { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 11px; align-items: center; }.aksrt-order-detail__thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }.aksrt-order-detail__thumb--empty { display: grid; place-items: center; background: var(--surface-2, #f4f6f9); color: var(--color-primary, #3b82f6); }.aksrt-order-detail__product-title { display: block; line-height: 1.4; }.aksrt-order-detail__product-meta { display: block; margin-top: 5px; color: var(--orders-muted); font-size: 12px; }.aksrt-order-detail__list { margin: 0; border: 1px solid var(--orders-line); border-radius: 10px; overflow: hidden; }.aksrt-order-detail__list > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); padding: 10px 12px; border-bottom: 1px solid var(--orders-line); font-size: 12px; }.aksrt-order-detail__list > div:last-child { border-bottom: 0; }.aksrt-order-detail__list dt { color: var(--orders-muted); }.aksrt-order-detail__list dd { margin: 0; overflow-wrap: anywhere; text-align: right; font-variant-numeric: tabular-nums; }
|
/* The dialog is portalled to <body>, so it cannot inherit the page-scoped
|
||||||
|
`--orders-*` aliases; it re-declares the few tokens it needs on the shell. */
|
||||||
|
.aksrt-order-detail-modal {
|
||||||
|
--detail-ink: var(--color-ink, #333333);
|
||||||
|
--detail-muted: var(--color-ink-3, #777777);
|
||||||
|
--detail-line: var(--color-line-stronger, rgba(50, 50, 50, .12));
|
||||||
|
--detail-surface: var(--surface-1, #fff);
|
||||||
|
--detail-surface-2: var(--surface-2, #eee);
|
||||||
|
--detail-surface-3: var(--surface-4, #f8f8f8);
|
||||||
|
--detail-primary: var(--color-primary, #f04494);
|
||||||
|
--detail-warning: var(--color-warning, #f59e0b);
|
||||||
|
--detail-success: var(--color-success, #10b981);
|
||||||
|
}
|
||||||
|
|
||||||
|
.aksrt-order-detail-modal:not(.aksrt-modal-runtime--bottom) .aksrt-modal-runtime__dialog { width: min(480px, calc(100vw - 32px)); }
|
||||||
|
.aksrt-order-detail-modal .aksrt-modal-runtime__header { padding: 15px 18px 14px; border-bottom: 1px solid var(--detail-line); }
|
||||||
|
.aksrt-order-detail-modal .aksrt-modal-runtime__title { font-size: 16px; font-weight: 700; }
|
||||||
|
.aksrt-order-detail-modal .aksrt-modal-runtime__content { display: flex; flex-direction: column; gap: 18px; padding: 16px 18px 0; }
|
||||||
|
|
||||||
|
.aksrt-order-detail__skeleton { display: grid; gap: 12px; padding: 4px 0; }
|
||||||
|
|
||||||
|
/* Status banner — a single local variable drives the whole colour scheme. */
|
||||||
|
.aksrt-order-detail__hero { --hero-accent: var(--detail-primary); --hero-text: color-mix(in srgb, var(--hero-accent) 72%, var(--detail-ink)); display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid color-mix(in srgb, var(--hero-accent) 20%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--hero-accent) 12%, var(--detail-surface)); }
|
||||||
|
.aksrt-order-detail__hero.is-pending { --hero-accent: var(--detail-warning); }
|
||||||
|
.aksrt-order-detail__hero.is-paid { --hero-accent: var(--detail-success); }
|
||||||
|
.aksrt-order-detail__hero.is-refunded, .aksrt-order-detail__hero.is-closed { --hero-accent: var(--detail-muted); }
|
||||||
|
.aksrt-order-detail__hero-icon { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--hero-accent) 16%, transparent); color: var(--hero-text); font-size: 19px; }
|
||||||
|
.aksrt-order-detail__hero-copy { display: grid; flex: 1 1 auto; gap: 4px; min-width: 0; }
|
||||||
|
.aksrt-order-detail__status { color: var(--hero-text); font-size: 15px; font-weight: 750; line-height: 1.2; }
|
||||||
|
.aksrt-order-detail__desc { margin: 0; color: var(--detail-muted); font-size: 12px; line-height: 1.45; }
|
||||||
|
.aksrt-order-detail__countdown { color: var(--hero-text); font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||||
|
.aksrt-order-detail__hero-amount { display: grid; flex: 0 0 auto; gap: 3px; justify-items: end; text-align: right; }
|
||||||
|
.aksrt-order-detail__hero-amount strong { color: var(--detail-ink); font-size: 21px; font-weight: 750; line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
|
||||||
|
.aksrt-order-detail__hero-amount span { color: var(--detail-muted); font-size: 11px; }
|
||||||
|
|
||||||
|
.aksrt-order-detail__group { display: grid; gap: 10px; }
|
||||||
|
.aksrt-order-detail__group-title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--detail-ink); font-size: 13px; font-weight: 700; line-height: 1.3; }
|
||||||
|
.aksrt-order-detail__group-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--detail-primary); }
|
||||||
|
|
||||||
|
.aksrt-order-detail__product { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--detail-line); border-radius: 12px; background: var(--detail-surface); }
|
||||||
|
.aksrt-order-detail__thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; }
|
||||||
|
.aksrt-order-detail__thumb--empty { display: grid; place-items: center; background: var(--detail-surface-2); color: var(--detail-primary); font-size: 19px; }
|
||||||
|
.aksrt-order-detail__product-copy { display: grid; gap: 6px; min-width: 0; }
|
||||||
|
.aksrt-order-detail__product-title { display: -webkit-box; overflow: hidden; color: var(--detail-ink); font-size: 14px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
||||||
|
.aksrt-order-detail__product-meta { display: inline-flex; justify-self: start; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--detail-primary) 9%, var(--detail-surface-2)); color: var(--detail-primary); font-size: 11px; font-weight: 650; line-height: 1.5; }
|
||||||
|
|
||||||
|
.aksrt-order-detail__list { display: grid; margin: 0; overflow: hidden; border: 1px solid var(--detail-line); border-radius: 12px; background: var(--detail-surface); }
|
||||||
|
.aksrt-order-detail__list > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 12px; padding: 11px 13px; border-bottom: 1px solid var(--detail-line); }
|
||||||
|
.aksrt-order-detail__list > div:last-child { border-bottom: 0; }
|
||||||
|
.aksrt-order-detail__list dt { color: var(--detail-muted); font-size: 12.5px; }
|
||||||
|
.aksrt-order-detail__list dd { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; margin: 0; color: var(--detail-ink); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
|
||||||
|
.aksrt-order-detail__value-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.aksrt-order-detail__value-text.is-mono { font-family: var(--font-mono, monospace); font-size: 12.5px; letter-spacing: .01em; }
|
||||||
|
.aksrt-order-detail__copy { display: inline-grid; flex: 0 0 auto; width: 24px; height: 24px; padding: 0; place-items: center; border: 1px solid var(--detail-line); border-radius: 7px; background: var(--detail-surface-3); color: var(--detail-muted); font-size: 11px; line-height: 1; cursor: pointer; transition: color .15s ease, border-color .15s ease; }
|
||||||
|
.aksrt-order-detail__copy:hover { border-color: color-mix(in srgb, var(--detail-primary) 45%, var(--detail-line)); color: var(--detail-primary); }
|
||||||
|
.aksrt-order-detail__copy.is-copied { border-color: color-mix(in srgb, var(--detail-success) 45%, var(--detail-line)); color: var(--detail-success); }
|
||||||
|
|
||||||
|
.aksrt-order-detail__refresh-state { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid color-mix(in srgb, var(--detail-warning) 26%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--detail-warning) 10%, var(--detail-surface-2)); color: var(--detail-ink); font-size: 12.5px; }
|
||||||
|
.aksrt-order-detail__refresh-state > i { color: var(--detail-warning); font-size: 15px; }
|
||||||
|
.aksrt-order-detail__refresh-state p { margin: 0; }
|
||||||
|
.aksrt-order-detail__refresh-state button { grid-column: 2; justify-self: start; }
|
||||||
|
|
||||||
|
.aksrt-order-detail-modal .aksrt-order-detail__actions { position: sticky; bottom: 0; z-index: 2; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 0 -18px; padding: 13px 18px; border-top: 1px solid var(--detail-line); background: var(--detail-surface); }
|
||||||
|
.aksrt-order-detail-modal .aksrt-order-detail__actions > button { flex: 0 0 auto; min-height: 38px; padding: 0 16px; white-space: nowrap; }
|
||||||
|
|
||||||
/* Orders extensions */
|
/* Orders extensions */
|
||||||
.aksrt-orders-page__extra-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
|
.aksrt-orders-page__extra-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
|
||||||
@@ -112,5 +175,5 @@
|
|||||||
.aksrt-coupon-card__meta { margin-bottom: 4px; color: var(--muted-2-color, #888); font-size: 12px; }
|
.aksrt-coupon-card__meta { margin-bottom: 4px; color: var(--muted-2-color, #888); font-size: 12px; }
|
||||||
.aksrt-orders-page__field { margin-bottom: 12px; }
|
.aksrt-orders-page__field { margin-bottom: 12px; }
|
||||||
.aksrt-orders-page__input, .aksrt-orders-page__select, .aksrt-orders-page__textarea { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid var(--main-border-color, #ddd); border-radius: 6px; }
|
.aksrt-orders-page__input, .aksrt-orders-page__select, .aksrt-orders-page__textarea { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid var(--main-border-color, #ddd); border-radius: 6px; }
|
||||||
@media (max-width: 767px) { .uc-orders-panel__head { grid-template-columns: 1fr; gap: 17px; }.aksrt-orders-page__stats { max-width: none; }.aksrt-orders-page__search { flex-wrap: wrap; }.aksrt-orders-page__search input { min-width: 150px; }.aksrt-orders-page__search .btn-primary { margin-left: auto; }.aksrt-orders-page__filter-toggle { margin-left: auto; }.aksrt-orders-page__card-rail time { width: 100%; margin-left: 0; order: 3; }.aksrt-orders-page__card-main { grid-template-columns: 48px minmax(0, 1fr); }.aksrt-orders-page__card-img, .aksrt-orders-page__card-art { width: 48px; height: 48px; }.aksrt-orders-page__card-value { grid-column: 2; text-align: left; }.aksrt-orders-page__card-actions > :not(.aksrt-orders-page__countdown) { flex: 1 1 auto; }.aksrt-orders-page__countdown { width: 100%; }.aksrt-order-detail__actions > * { flex: 1; } }
|
@media (max-width: 767px) { .uc-orders-panel__head { grid-template-columns: 1fr; gap: 17px; }.aksrt-orders-page__stats { max-width: none; }.aksrt-orders-page__search { flex-wrap: wrap; }.aksrt-orders-page__search input { min-width: 150px; }.aksrt-orders-page__search .btn-primary { margin-left: auto; }.aksrt-orders-page__filter-toggle { margin-left: auto; }.aksrt-orders-page__card-rail time { width: 100%; margin-left: 0; order: 3; }.aksrt-orders-page__card-main { grid-template-columns: 48px minmax(0, 1fr); }.aksrt-orders-page__card-img, .aksrt-orders-page__card-art { width: 48px; height: 48px; }.aksrt-orders-page__card-value { grid-column: 2; text-align: left; }.aksrt-orders-page__card-actions > :not(.aksrt-orders-page__countdown) { flex: 1 1 auto; }.aksrt-orders-page__countdown { width: 100%; }.aksrt-order-detail-modal .aksrt-order-detail__actions > button { flex: 1 1 0; min-width: 0; padding: 0 10px; } }
|
||||||
html.dark .aksrt-orders-page__stat, html.dark .aksrt-orders-page__card { background: var(--surface-1, #1a1d24); } html.dark .aksrt-orders-page__card-rail, html.dark .aksrt-orders-page__filter-panel, html.dark .aksrt-order-detail__actions { background: var(--surface-2, #12151b); }
|
html.dark .aksrt-orders-page__stat, html.dark .aksrt-orders-page__card { background: var(--surface-1, #1a1d24); } html.dark .aksrt-orders-page__card-rail, html.dark .aksrt-orders-page__filter-panel { background: var(--surface-2, #12151b); }
|
||||||
@@ -994,7 +994,7 @@
|
|||||||
var number = document.createElement('span');
|
var number = document.createElement('span');
|
||||||
number.className = 'uc-withdraw-history__number muted-2-color em09';
|
number.className = 'uc-withdraw-history__number muted-2-color em09';
|
||||||
var numberLabel = document.createElement('span');
|
var numberLabel = document.createElement('span');
|
||||||
numberLabel.textContent = '提现单号:';
|
numberLabel.textContent = '流水号:';
|
||||||
number.appendChild(numberLabel);
|
number.appendChild(numberLabel);
|
||||||
var code = document.createElement('code');
|
var code = document.createElement('code');
|
||||||
code.textContent = text(item && item.withdrawal_number);
|
code.textContent = text(item && item.withdrawal_number);
|
||||||
|
|||||||
+138
-14
@@ -70,35 +70,104 @@
|
|||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function statusMeta(status) {
|
||||||
|
var map = {
|
||||||
|
pending: { icon: "fa-clock", desc: "订单已生成,请在有效期内完成支付" },
|
||||||
|
paid: { icon: "fa-check-circle", desc: "支付已完成,相关权益已发放至账户" },
|
||||||
|
refunding: { icon: "fa-hourglass-half", desc: "退款申请已受理,正在处理中" },
|
||||||
|
refunded: { icon: "fa-undo-alt", desc: "退款已完成,款项将原路退回" },
|
||||||
|
closed: { icon: "fa-times-circle", desc: "订单已关闭,如有需要可重新下单" },
|
||||||
|
};
|
||||||
|
return map[status] || map.closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function amountCaption(status) {
|
||||||
|
if (status === "pending") return "应付款";
|
||||||
|
if (status === "closed") return "订单金额";
|
||||||
|
return "实付款";
|
||||||
|
}
|
||||||
|
|
||||||
|
function paymentMethodText(order) {
|
||||||
|
var method = order && order.payment_method ? order.payment_method : {};
|
||||||
|
// 卡密核销不是真实收银渠道,直接回退的原始 key 对用户没有意义。
|
||||||
|
if (method.value === "card_pass") return "卡密核销";
|
||||||
|
return String(method.label || "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function detailRow(label, value, copyable) {
|
||||||
|
var text = value == null ? "" : String(value);
|
||||||
|
var cell = '<span class="aksrt-order-detail__value-text' + (copyable ? " is-mono" : "") + '">' +
|
||||||
|
escapeHtml(text || "—") + "</span>";
|
||||||
|
if (copyable && text !== "") {
|
||||||
|
cell += '<button class="aksrt-order-detail__copy" type="button" data-aksrt-order-copy="' +
|
||||||
|
escapeHtml(text) + '" aria-label="复制' + escapeHtml(label) + '" title="复制' + escapeHtml(label) + '">' +
|
||||||
|
'<i class="fa fas fa-copy" aria-hidden="true"></i></button>';
|
||||||
|
}
|
||||||
|
return "<div><dt>" + escapeHtml(label) + "</dt><dd>" + cell + "</dd></div>";
|
||||||
|
}
|
||||||
|
|
||||||
function renderDetail(state, order, session) {
|
function renderDetail(state, order, session) {
|
||||||
var allowedActions = order.allowed_actions || {};
|
var allowedActions = order.allowed_actions || {};
|
||||||
var reconciliation = order.reconciliation || {};
|
var reconciliation = order.reconciliation || {};
|
||||||
|
var paymentMethod = order.payment_method || {};
|
||||||
var image = order.image || "";
|
var image = order.image || "";
|
||||||
var title = order.product_name || "订单";
|
var title = order.product_name || "订单";
|
||||||
var status = order.status_group || "closed";
|
var status = order.status_group || "closed";
|
||||||
var html = '<div class="aksrt-order-detail__hero is-' + escapeHtml(status) + '">';
|
var meta = statusMeta(status);
|
||||||
html += '<span class="aksrt-order-detail__status-pill is-' + escapeHtml(status) + '">' + escapeHtml(order.status_label || "") + "</span>";
|
var timeLeft = Number(order.time_left || 0);
|
||||||
html += '<strong class="aksrt-order-detail__hero-amount">' + formatMoney(order) + "</strong></div>";
|
var html = "";
|
||||||
|
|
||||||
|
// 状态横幅:整块配色只由 --hero-accent 驱动,换状态只改一处变量。
|
||||||
|
html += '<section class="aksrt-order-detail__hero is-' + escapeHtml(status) + '">';
|
||||||
|
html += '<span class="aksrt-order-detail__hero-icon" aria-hidden="true"><i class="fa fas ' + meta.icon + '"></i></span>';
|
||||||
|
html += '<div class="aksrt-order-detail__hero-copy">';
|
||||||
|
html += '<strong class="aksrt-order-detail__status">' + escapeHtml(order.status_label || "") + "</strong>";
|
||||||
|
html += '<p class="aksrt-order-detail__desc">' + escapeHtml(meta.desc) + "</p>";
|
||||||
|
if (status === "pending" && timeLeft > 0) {
|
||||||
|
html += '<span class="aksrt-order-detail__countdown" data-aksrt-order-countdown="' + timeLeft + '">剩余支付时间 ' + timeLeft + " 秒</span>";
|
||||||
|
}
|
||||||
|
html += "</div>";
|
||||||
|
html += '<div class="aksrt-order-detail__hero-amount"><strong>' + formatMoney(order) + "</strong>";
|
||||||
|
html += "<span>" + escapeHtml(amountCaption(status)) + "</span></div></section>";
|
||||||
|
|
||||||
|
html += '<section class="aksrt-order-detail__group">';
|
||||||
|
html += '<h4 class="aksrt-order-detail__group-title">商品信息</h4>';
|
||||||
html += '<div class="aksrt-order-detail__product">';
|
html += '<div class="aksrt-order-detail__product">';
|
||||||
html += image
|
html += image
|
||||||
? '<img src="' + escapeHtml(image) + '" class="aksrt-order-detail__thumb" alt="">'
|
? '<img src="' + escapeHtml(image) + '" class="aksrt-order-detail__thumb" alt="">'
|
||||||
: '<span class="aksrt-order-detail__thumb aksrt-order-detail__thumb--empty"><i class="fa fas fa-book"></i></span>';
|
: '<span class="aksrt-order-detail__thumb aksrt-order-detail__thumb--empty" aria-hidden="true"><i class="fa fas fa-book"></i></span>';
|
||||||
html += '<div><strong class="aksrt-order-detail__product-title">' + escapeHtml(title) + "</strong>";
|
html += '<div class="aksrt-order-detail__product-copy">';
|
||||||
html += '<span class="aksrt-order-detail__product-meta">' + escapeHtml(order.product_type_label || "") + "</span></div></div>";
|
html += '<strong class="aksrt-order-detail__product-title">' + escapeHtml(title) + "</strong>";
|
||||||
|
html += '<span class="aksrt-order-detail__product-meta">' + escapeHtml(order.product_type_label || "") + "</span>";
|
||||||
|
html += "</div></div></section>";
|
||||||
|
|
||||||
|
html += '<section class="aksrt-order-detail__group">';
|
||||||
|
html += '<h4 class="aksrt-order-detail__group-title">交易信息</h4>';
|
||||||
html += '<dl class="aksrt-order-detail__list">';
|
html += '<dl class="aksrt-order-detail__list">';
|
||||||
[["订单编号", order.order_number], ["流水号", order.flow_number || "—"], ["创建时间", order.created_at], ["支付时间", order.paid_at || "—"]].forEach(function (row) {
|
[
|
||||||
html += "<div><dt>" + escapeHtml(row[0]) + "</dt><dd>" + escapeHtml(row[1] || "—") + "</dd></div>";
|
["流水号", order.order_number],
|
||||||
|
["支付方式", paymentMethodText(order)],
|
||||||
|
["创建时间", order.created_at],
|
||||||
|
["支付时间", order.paid_at],
|
||||||
|
].forEach(function (row) {
|
||||||
|
html += detailRow(row[0], row[1], row[0] === "流水号");
|
||||||
});
|
});
|
||||||
html += "</dl>";
|
html += "</dl></section>";
|
||||||
|
|
||||||
if (reconciliation.state === "refresh_available") {
|
if (reconciliation.state === "refresh_available") {
|
||||||
html += '<div class="aksrt-order-detail__refresh-state" role="status">支付状态可能仍在同步,请刷新后查看。';
|
html += '<div class="aksrt-order-detail__refresh-state" role="status">';
|
||||||
html += '<button class="btn-outline" type="button" data-aksrt-order-refresh="' + escapeHtml(order.order_number) + '">刷新支付状态</button></div>';
|
html += '<i class="fa fas fa-info-circle" aria-hidden="true"></i>';
|
||||||
|
html += "<p>支付状态可能仍在同步,请刷新后查看。</p>";
|
||||||
|
html += '<button class="btn-outline" type="button" data-aksrt-order-refresh="' + escapeHtml(order.order_number) + '">刷新支付状态</button>';
|
||||||
|
html += "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
html += '<footer class="aksrt-modal__footer aksrt-order-detail__actions">';
|
html += '<footer class="aksrt-modal__footer aksrt-order-detail__actions">';
|
||||||
html += '<button class="btn-outline" type="button" data-aksrt-modal-close>关闭</button>';
|
html += '<button class="btn-outline" type="button" data-aksrt-modal-close>关闭</button>';
|
||||||
if (allowedActions.can_cancel) html += '<button class="btn-ghost" type="button" data-aksrt-order-cancel="' + escapeHtml(order.order_number) + '">关闭订单</button>';
|
if (allowedActions.can_cancel) html += '<button class="btn-ghost" type="button" data-aksrt-order-cancel="' + escapeHtml(order.order_number) + '">关闭订单</button>';
|
||||||
if (allowedActions.can_pay) html += '<button class="btn-primary" type="button" data-aksrt-order-pay="' + escapeHtml(order.order_number) + '" data-aksrt-order-method="' + escapeHtml((order.payment_method || {}).value || "") + '">继续支付</button>';
|
if (allowedActions.can_pay) html += '<button class="btn-primary" type="button" data-aksrt-order-pay="' + escapeHtml(order.order_number) + '" data-aksrt-order-method="' + escapeHtml(paymentMethod.value || "") + '">继续支付</button>';
|
||||||
html += "</footer>";
|
html += "</footer>";
|
||||||
|
|
||||||
session.content.innerHTML = html;
|
session.content.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +180,7 @@
|
|||||||
headers: actionKey ? { "Idempotency-Key": state.operationKeys[actionKey] } : {},
|
headers: actionKey ? { "Idempotency-Key": state.operationKeys[actionKey] } : {},
|
||||||
kind: "orders",
|
kind: "orders",
|
||||||
title: "订单详情",
|
title: "订单详情",
|
||||||
|
className: "aksrt-order-detail-modal",
|
||||||
responseType: "json",
|
responseType: "json",
|
||||||
cache: !refresh,
|
cache: !refresh,
|
||||||
cacheKey: "orders:detail:" + orderNumber,
|
cacheKey: "orders:detail:" + orderNumber,
|
||||||
@@ -186,7 +256,7 @@
|
|||||||
: "";
|
: "";
|
||||||
return '<article class="aksrt-orders-page__card" data-aksrt-order-card="' + escapeHtml(order.order_number) + '" data-order-status="' + escapeHtml(order.status_group || "") + '">' +
|
return '<article class="aksrt-orders-page__card" data-aksrt-order-card="' + escapeHtml(order.order_number) + '" data-order-status="' + escapeHtml(order.status_group || "") + '">' +
|
||||||
'<div class="aksrt-orders-page__card-rail"><span>' + escapeHtml(order.product_type_label || "") + '</span><time>' + escapeHtml(order.created_at || "") + '</time><span class="aksrt-orders-page__card-status is-' + escapeHtml(order.status_group || "") + '">' + escapeHtml(order.status_label || "") + "</span></div>" +
|
'<div class="aksrt-orders-page__card-rail"><span>' + escapeHtml(order.product_type_label || "") + '</span><time>' + escapeHtml(order.created_at || "") + '</time><span class="aksrt-orders-page__card-status is-' + escapeHtml(order.status_group || "") + '">' + escapeHtml(order.status_label || "") + "</span></div>" +
|
||||||
'<div class="aksrt-orders-page__card-main">' + image + '<div class="aksrt-orders-page__card-copy"><h3>' + escapeHtml(order.product_name || "订单") + "</h3><p>订单号 " + escapeHtml(order.order_number) + "</p></div><div class=\"aksrt-orders-page__card-value\"><strong>" + formatMoney(order) + "</strong><span>实付</span></div></div>" +
|
'<div class="aksrt-orders-page__card-main">' + image + '<div class="aksrt-orders-page__card-copy"><h3>' + escapeHtml(order.product_name || "订单") + "</h3><p>流水号 " + escapeHtml(order.order_number) + "</p></div><div class=\"aksrt-orders-page__card-value\"><strong>" + formatMoney(order) + "</strong><span>实付</span></div></div>" +
|
||||||
'<footer class="aksrt-orders-page__card-actions">' + countdown + actionHtml(order) + "</footer></article>";
|
'<footer class="aksrt-orders-page__card-actions">' + countdown + actionHtml(order) + "</footer></article>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,12 +293,22 @@
|
|||||||
if (list) list.after(root);
|
if (list) list.after(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function countdownScopes(state) {
|
||||||
|
// 详情弹窗挂在 body 上,不在 state.root 内,需要单独纳入倒计时扫描。
|
||||||
|
var scopes = [state.root];
|
||||||
|
if (state.detailSession && state.detailSession.content) scopes.push(state.detailSession.content);
|
||||||
|
return scopes;
|
||||||
|
}
|
||||||
|
|
||||||
function updateCountdowns(state) {
|
function updateCountdowns(state) {
|
||||||
state.root.querySelectorAll("[data-aksrt-order-countdown]").forEach(function (node) {
|
countdownScopes(state).forEach(function (scope) {
|
||||||
|
if (!scope || !scope.querySelectorAll) return;
|
||||||
|
scope.querySelectorAll("[data-aksrt-order-countdown]").forEach(function (node) {
|
||||||
var value = Math.max(0, Number(node.getAttribute("data-aksrt-order-countdown") || 0) - 1);
|
var value = Math.max(0, Number(node.getAttribute("data-aksrt-order-countdown") || 0) - 1);
|
||||||
node.setAttribute("data-aksrt-order-countdown", String(value));
|
node.setAttribute("data-aksrt-order-countdown", String(value));
|
||||||
node.textContent = value ? "剩余支付时间 " + value + " 秒" : "订单即将关闭";
|
node.textContent = value ? "剩余支付时间 " + value + " 秒" : "订单即将关闭";
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderView(state, view) {
|
function renderView(state, view) {
|
||||||
@@ -343,6 +423,44 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyOrderValue(button) {
|
||||||
|
var value = button.getAttribute("data-aksrt-order-copy") || "";
|
||||||
|
if (!value) return;
|
||||||
|
var icon = button.querySelector("i");
|
||||||
|
var settle = function (ok) {
|
||||||
|
notyf(ok ? "流水号已复制" : "复制失败,请手动选择复制", ok ? "success" : "danger");
|
||||||
|
if (!ok) return;
|
||||||
|
button.classList.add("is-copied");
|
||||||
|
if (icon) icon.className = "fa fas fa-check";
|
||||||
|
window.setTimeout(function () {
|
||||||
|
button.classList.remove("is-copied");
|
||||||
|
if (icon) icon.className = "fa fas fa-copy";
|
||||||
|
}, 1600);
|
||||||
|
};
|
||||||
|
var fallback = function () {
|
||||||
|
try {
|
||||||
|
var field = document.createElement("textarea");
|
||||||
|
field.value = value;
|
||||||
|
field.setAttribute("readonly", "readonly");
|
||||||
|
field.style.position = "fixed";
|
||||||
|
field.style.top = "-1000px";
|
||||||
|
field.style.opacity = "0";
|
||||||
|
document.body.appendChild(field);
|
||||||
|
field.select();
|
||||||
|
document.execCommand("copy");
|
||||||
|
document.body.removeChild(field);
|
||||||
|
settle(true);
|
||||||
|
} catch (error) {
|
||||||
|
settle(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(value).then(function () { settle(true); }, fallback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fallback();
|
||||||
|
}
|
||||||
|
|
||||||
function closest(target, selector) {
|
function closest(target, selector) {
|
||||||
return target && target.closest ? target.closest(selector) : null;
|
return target && target.closest ? target.closest(selector) : null;
|
||||||
}
|
}
|
||||||
@@ -416,6 +534,12 @@
|
|||||||
};
|
};
|
||||||
state.onDocumentClick = function (event) {
|
state.onDocumentClick = function (event) {
|
||||||
if (!state.detailSession || window.AksrtModalRuntime.getActive() !== state.detailSession.shell) return;
|
if (!state.detailSession || window.AksrtModalRuntime.getActive() !== state.detailSession.shell) return;
|
||||||
|
var copy = closest(event.target, "[data-aksrt-order-copy]");
|
||||||
|
if (copy) {
|
||||||
|
event.preventDefault();
|
||||||
|
copyOrderValue(copy);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var refresh = closest(event.target, "[data-aksrt-order-refresh]");
|
var refresh = closest(event.target, "[data-aksrt-order-refresh]");
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
@@ -377,7 +377,7 @@
|
|||||||
if (data.redirect && (data.payment_url || data.qr_content)) {
|
if (data.redirect && (data.payment_url || data.qr_content)) {
|
||||||
callback(options, "onPending", data);
|
callback(options, "onPending", data);
|
||||||
if (!data.order_number) {
|
if (!data.order_number) {
|
||||||
var missing = { ok: false, status: 500, json: { message: "支付订单号缺失" } };
|
var missing = { ok: false, status: 500, json: { message: "流水号缺失" } };
|
||||||
callback(options, "onError", missing);
|
callback(options, "onError", missing);
|
||||||
return missing;
|
return missing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1567,7 +1567,7 @@ if (!function_exists('aksrt_get_paid_box_html')) {
|
|||||||
}
|
}
|
||||||
$amount_text = $cash_symbol . aksrt_format_price($order_amount);
|
$amount_text = $cash_symbol . aksrt_format_price($order_amount);
|
||||||
}
|
}
|
||||||
$paid_info = '<div class="flex jsb"><span>' . esc_html__('订单号', 'aksrt') . '</span><span>' . esc_html($order_number) . '</span></div>';
|
$paid_info = '<div class="flex jsb"><span>' . esc_html__('流水号', 'aksrt') . '</span><span>' . esc_html($order_number) . '</span></div>';
|
||||||
if ($paid_at !== '') {
|
if ($paid_at !== '') {
|
||||||
$paid_info .= '<div class="flex jsb"><span>' . esc_html__('支付时间', 'aksrt') . '</span><span>' . esc_html($paid_at) . '</span></div>';
|
$paid_info .= '<div class="flex jsb"><span>' . esc_html__('支付时间', 'aksrt') . '</span><span>' . esc_html($paid_at) . '</span></div>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ $currency_labels = [
|
|||||||
$status = (string) ($item['status'] ?? '') === 'pending' ? 'pending' : 'settled';
|
$status = (string) ($item['status'] ?? '') === 'pending' ? 'pending' : 'settled';
|
||||||
$amount = $format($item['amount'] ?? 0, $unit);
|
$amount = $format($item['amount'] ?? 0, $unit);
|
||||||
$order_number = trim((string) ($item['order_number'] ?? ''));
|
$order_number = trim((string) ($item['order_number'] ?? ''));
|
||||||
$order_number = $order_number !== '' ? $order_number : __('订单编号未知', 'aksrt');
|
$order_number = $order_number !== '' ? $order_number : __('流水号未知', 'aksrt');
|
||||||
$post = get_post((int) ($item['post_id'] ?? 0));
|
$post = get_post((int) ($item['post_id'] ?? 0));
|
||||||
$source = $post instanceof WP_Post && $post->post_type === 'post'
|
$source = $post instanceof WP_Post && $post->post_type === 'post'
|
||||||
? get_the_title($post)
|
? get_the_title($post)
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ $status_options = [
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<form class="aksrt-orders-page__search" data-aksrt-orders-search>
|
<form class="aksrt-orders-page__search" data-aksrt-orders-search>
|
||||||
<label class="screen-reader-text" for="aksrt-order-number"><?php esc_html_e('按订单号查找', 'aksrt'); ?></label>
|
<label class="screen-reader-text" for="aksrt-order-number"><?php esc_html_e('按流水号查找', 'aksrt'); ?></label>
|
||||||
<i class="fa fas fa-search" aria-hidden="true"></i>
|
<i class="fa fas fa-search" aria-hidden="true"></i>
|
||||||
<input id="aksrt-order-number" value="<?php echo esc_attr($order_number); ?>" maxlength="32" placeholder="<?php esc_attr_e('输入订单号开头快速查找', 'aksrt'); ?>">
|
<input id="aksrt-order-number" value="<?php echo esc_attr($order_number); ?>" maxlength="32" placeholder="<?php esc_attr_e('输入流水号开头快速查找', 'aksrt'); ?>">
|
||||||
<button class="btn-primary" type="submit"><?php esc_html_e('查找', 'aksrt'); ?></button>
|
<button class="btn-primary" type="submit"><?php esc_html_e('查找', 'aksrt'); ?></button>
|
||||||
<button class="aksrt-orders-page__filter-toggle" type="button" data-aksrt-orders-filter-toggle aria-expanded="false" aria-controls="aksrt-orders-filter-panel"><i class="fa fas fa-sliders-h" aria-hidden="true"></i> <?php esc_html_e('筛选', 'aksrt'); ?></button>
|
<button class="aksrt-orders-page__filter-toggle" type="button" data-aksrt-orders-filter-toggle aria-expanded="false" aria-controls="aksrt-orders-filter-panel"><i class="fa fas fa-sliders-h" aria-hidden="true"></i> <?php esc_html_e('筛选', 'aksrt'); ?></button>
|
||||||
</form>
|
</form>
|
||||||
@@ -112,7 +112,7 @@ $status_options = [
|
|||||||
<div class="aksrt-orders-page__card-rail"><span><?php echo esc_html((string) ($order['product_type_label'] ?? '')); ?></span><time><?php echo esc_html((string) ($order['created_at'] ?? '')); ?></time><span class="aksrt-orders-page__card-status is-<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>"><?php echo esc_html((string) ($order['status_label'] ?? '')); ?></span></div>
|
<div class="aksrt-orders-page__card-rail"><span><?php echo esc_html((string) ($order['product_type_label'] ?? '')); ?></span><time><?php echo esc_html((string) ($order['created_at'] ?? '')); ?></time><span class="aksrt-orders-page__card-status is-<?php echo esc_attr((string) ($order['status_group'] ?? '')); ?>"><?php echo esc_html((string) ($order['status_label'] ?? '')); ?></span></div>
|
||||||
<div class="aksrt-orders-page__card-main">
|
<div class="aksrt-orders-page__card-main">
|
||||||
<?php if (!empty($order['image'])) : ?><img class="aksrt-orders-page__card-img" src="<?php echo esc_url((string) $order['image']); ?>" alt=""><?php else : ?><div class="aksrt-orders-page__card-art" aria-hidden="true"><i class="fa fas fa-book"></i></div><?php endif; ?>
|
<?php if (!empty($order['image'])) : ?><img class="aksrt-orders-page__card-img" src="<?php echo esc_url((string) $order['image']); ?>" alt=""><?php else : ?><div class="aksrt-orders-page__card-art" aria-hidden="true"><i class="fa fas fa-book"></i></div><?php endif; ?>
|
||||||
<div class="aksrt-orders-page__card-copy"><h3><?php echo esc_html((string) ($order['product_name'] ?? __('订单', 'aksrt'))); ?></h3><p><?php printf(esc_html__('订单号 %s', 'aksrt'), esc_html($number)); ?></p></div>
|
<div class="aksrt-orders-page__card-copy"><h3><?php echo esc_html((string) ($order['product_name'] ?? __('订单', 'aksrt'))); ?></h3><p><?php printf(esc_html__('流水号 %s', 'aksrt'), esc_html($number)); ?></p></div>
|
||||||
<div class="aksrt-orders-page__card-value"><strong><?php echo $amount; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong><span><?php esc_html_e('实付', 'aksrt'); ?></span></div>
|
<div class="aksrt-orders-page__card-value"><strong><?php echo $amount; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong><span><?php esc_html_e('实付', 'aksrt'); ?></span></div>
|
||||||
</div>
|
</div>
|
||||||
<footer class="aksrt-orders-page__card-actions">
|
<footer class="aksrt-orders-page__card-actions">
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ final class PayFlows {
|
|||||||
echo '<p class="description">' . esc_html__('仅展示已经确认发生的现金、余额和积分变动;流水不可编辑。', 'aksrt') . '</p>';
|
echo '<p class="description">' . esc_html__('仅展示已经确认发生的现金、余额和积分变动;流水不可编辑。', 'aksrt') . '</p>';
|
||||||
echo '<form method="get" style="margin:12px 0;display:flex;gap:6px;align-items:center;flex-wrap:wrap;">';
|
echo '<form method="get" style="margin:12px 0;display:flex;gap:6px;align-items:center;flex-wrap:wrap;">';
|
||||||
echo '<input type="hidden" name="page" value="' . esc_attr(self::PAGE_SLUG) . '">';
|
echo '<input type="hidden" name="page" value="' . esc_attr(self::PAGE_SLUG) . '">';
|
||||||
echo '<input type="search" name="s" value="' . esc_attr($keyword) . '" placeholder="' . esc_attr__('流水号 / 订单号 / 提现单号 / 渠道交易号', 'aksrt') . '" style="min-width:280px;">';
|
echo '<input type="search" name="s" value="' . esc_attr($keyword) . '" placeholder="' . esc_attr__('账本流水号 / 流水号 / 渠道交易号', 'aksrt') . '" style="min-width:280px;">';
|
||||||
echo '<input type="number" min="1" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text">';
|
echo '<input type="number" min="1" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text">';
|
||||||
echo '<select name="event_type"><option value="">' . esc_html__('全部事件', 'aksrt') . '</option>';
|
echo '<select name="event_type"><option value="">' . esc_html__('全部事件', 'aksrt') . '</option>';
|
||||||
foreach ($query->event_types() as $key => $label) {
|
foreach ($query->event_types() as $key => $label) {
|
||||||
@@ -70,7 +70,7 @@ final class PayFlows {
|
|||||||
echo '</form>';
|
echo '</form>';
|
||||||
echo '<p>' . esc_html(sprintf(__('共 %d 条流水', 'aksrt'), (int) $result['total'])) . '</p>';
|
echo '<p>' . esc_html(sprintf(__('共 %d 条流水', 'aksrt'), (int) $result['total'])) . '</p>';
|
||||||
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
|
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
|
||||||
echo '<th style="width:180px">' . esc_html__('流水号 / 时间', 'aksrt') . '</th>';
|
echo '<th style="width:180px">' . esc_html__('账本流水号 / 时间', 'aksrt') . '</th>';
|
||||||
echo '<th style="width:130px">' . esc_html__('事件', 'aksrt') . '</th>';
|
echo '<th style="width:130px">' . esc_html__('事件', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('用户与分录', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('用户与分录', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('关联业务', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('关联业务', 'aksrt') . '</th>';
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class PayIncome {
|
|||||||
echo '<input type="number" min="0" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
echo '<input type="number" min="0" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
||||||
echo '<input type="number" min="0" name="post_id" value="' . esc_attr($post_id > 0 ? (string) $post_id : '') . '" placeholder="' . esc_attr__('文章 ID', 'aksrt') . '" class="small-text" /> ';
|
echo '<input type="number" min="0" name="post_id" value="' . esc_attr($post_id > 0 ? (string) $post_id : '') . '" placeholder="' . esc_attr__('文章 ID', 'aksrt') . '" class="small-text" /> ';
|
||||||
echo '<select name="currency"><option value="">' . esc_html__('全部货币', 'aksrt') . '</option><option value="CNY"' . selected($currency, 'CNY', false) . '>CNY</option><option value="points"' . selected($currency, 'points', false) . '>' . esc_html__('积分', 'aksrt') . '</option></select> ';
|
echo '<select name="currency"><option value="">' . esc_html__('全部货币', 'aksrt') . '</option><option value="CNY"' . selected($currency, 'CNY', false) . '>CNY</option><option value="points"' . selected($currency, 'points', false) . '>' . esc_html__('积分', 'aksrt') . '</option></select> ';
|
||||||
echo '<input type="search" name="order_number" value="' . esc_attr($order_number) . '" placeholder="' . esc_attr__('订单号', 'aksrt') . '" /> ';
|
echo '<input type="search" name="order_number" value="' . esc_attr($order_number) . '" placeholder="' . esc_attr__('流水号', 'aksrt') . '" /> ';
|
||||||
echo '<input type="date" name="date_from" value="' . esc_attr($date_from) . '" /> — <input type="date" name="date_to" value="' . esc_attr($date_to) . '" /> ';
|
echo '<input type="date" name="date_from" value="' . esc_attr($date_from) . '" /> — <input type="date" name="date_to" value="' . esc_attr($date_to) . '" /> ';
|
||||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||||
if ($user_id > 0) {
|
if ($user_id > 0) {
|
||||||
@@ -127,7 +127,7 @@ class PayIncome {
|
|||||||
$pages = max(1, (int) ($result['max_pages'] ?? 1));
|
$pages = max(1, (int) ($result['max_pages'] ?? 1));
|
||||||
|
|
||||||
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
|
echo '<table class="wp-list-table widefat fixed striped"><thead><tr>';
|
||||||
echo '<th><input type="checkbox" form="aksrt-pay-batch-settle-income" aria-label="' . esc_attr__('全选待结算记录', 'aksrt') . '" /></th><th>ID</th><th>' . esc_html__('用户', 'aksrt') . '</th><th>' . esc_html__('订单号', 'aksrt') . '</th><th>' . esc_html__('金额', 'aksrt') . '</th><th>' . esc_html__('状态', 'aksrt') . '</th><th>' . esc_html__('时间', 'aksrt') . '</th><th>' . esc_html__('操作', 'aksrt') . '</th>';
|
echo '<th><input type="checkbox" form="aksrt-pay-batch-settle-income" aria-label="' . esc_attr__('全选待结算记录', 'aksrt') . '" /></th><th>ID</th><th>' . esc_html__('用户', 'aksrt') . '</th><th>' . esc_html__('流水号', 'aksrt') . '</th><th>' . esc_html__('金额', 'aksrt') . '</th><th>' . esc_html__('状态', 'aksrt') . '</th><th>' . esc_html__('时间', 'aksrt') . '</th><th>' . esc_html__('操作', 'aksrt') . '</th>';
|
||||||
echo '</tr></thead><tbody>';
|
echo '</tr></thead><tbody>';
|
||||||
if (!$items) {
|
if (!$items) {
|
||||||
echo '<tr><td colspan="8">' . esc_html__('暂无分成记录', 'aksrt') . '</td></tr>';
|
echo '<tr><td colspan="8">' . esc_html__('暂无分成记录', 'aksrt') . '</td></tr>';
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class PayOrders {
|
|||||||
}
|
}
|
||||||
echo '</select> ';
|
echo '</select> ';
|
||||||
echo '<input type="number" min="0" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
echo '<input type="number" min="0" name="user_id" value="' . esc_attr($user_id > 0 ? (string) $user_id : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
||||||
echo '<input type="search" name="s" value="' . esc_attr($search) . '" placeholder="' . esc_attr__('订单号 / 流水号 / 类型 / 用户', 'aksrt') . '" /> ';
|
echo '<input type="search" name="s" value="' . esc_attr($search) . '" placeholder="' . esc_attr__('流水号 / 账本流水号 / 类型 / 用户', 'aksrt') . '" /> ';
|
||||||
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
submit_button(__('筛选', 'aksrt'), 'secondary', '', false);
|
||||||
if ($product_id > 0 || $product_type !== '' || $user_id > 0 || $pay_method !== '') {
|
if ($product_id > 0 || $product_type !== '' || $user_id > 0 || $pay_method !== '') {
|
||||||
$filter_bits = [];
|
$filter_bits = [];
|
||||||
@@ -200,7 +200,7 @@ class PayOrders {
|
|||||||
|
|
||||||
echo '<table class="wp-list-table widefat fixed striped">';
|
echo '<table class="wp-list-table widefat fixed striped">';
|
||||||
echo '<thead><tr>';
|
echo '<thead><tr>';
|
||||||
echo '<th>' . esc_html__('订单号', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('流水号', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('用户', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('用户', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('商品信息', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('商品信息', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('金额 / 支付方式', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('金额 / 支付方式', 'aksrt') . '</th>';
|
||||||
@@ -295,8 +295,8 @@ class PayOrders {
|
|||||||
|
|
||||||
echo '<table class="widefat striped" style="max-width:960px;"><tbody>';
|
echo '<table class="widefat striped" style="max-width:960px;"><tbody>';
|
||||||
$rows = [
|
$rows = [
|
||||||
__('订单号', 'aksrt') => $order_number,
|
__('流水号', 'aksrt') => $order_number,
|
||||||
__('支付流水号', 'aksrt') => $flow_number !== '' ? $flow_number : '—',
|
__('账本流水号', 'aksrt') => $flow_number !== '' ? $flow_number : '—',
|
||||||
__('用户', 'aksrt') => $user ? $user->display_name . ' (#' . $user_id . ')' : (string) $user_id,
|
__('用户', 'aksrt') => $user ? $user->display_name . ' (#' . $user_id . ')' : (string) $user_id,
|
||||||
__('商品类型', 'aksrt') => (string) ($order['product_type'] ?? ''),
|
__('商品类型', 'aksrt') => (string) ($order['product_type'] ?? ''),
|
||||||
__('商品 ID', 'aksrt') => (string) ($order['product_id'] ?? ''),
|
__('商品 ID', 'aksrt') => (string) ($order['product_id'] ?? ''),
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class PayWithdrawals {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo '</select> ';
|
echo '</select> ';
|
||||||
echo '<input type="search" name="s" value="' . esc_attr($keyword) . '" placeholder="' . esc_attr__('提现单号 / 用户 ID', 'aksrt') . '" /> ';
|
echo '<input type="search" name="s" value="' . esc_attr($keyword) . '" placeholder="' . esc_attr__('流水号 / 用户 ID', 'aksrt') . '" /> ';
|
||||||
echo '<input type="number" min="1" name="user_id" value="' . esc_attr($user_filter > 0 ? (string) $user_filter : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
echo '<input type="number" min="1" name="user_id" value="' . esc_attr($user_filter > 0 ? (string) $user_filter : '') . '" placeholder="' . esc_attr__('用户 ID', 'aksrt') . '" class="small-text" /> ';
|
||||||
echo '<label>' . esc_html__('从', 'aksrt') . ' <input type="date" name="date_from" value="' . esc_attr($date_from) . '"></label> ';
|
echo '<label>' . esc_html__('从', 'aksrt') . ' <input type="date" name="date_from" value="' . esc_attr($date_from) . '"></label> ';
|
||||||
echo '<label>' . esc_html__('至', 'aksrt') . ' <input type="date" name="date_to" value="' . esc_attr($date_to) . '"></label> ';
|
echo '<label>' . esc_html__('至', 'aksrt') . ' <input type="date" name="date_to" value="' . esc_attr($date_to) . '"></label> ';
|
||||||
@@ -113,7 +113,7 @@ class PayWithdrawals {
|
|||||||
|
|
||||||
echo '<table class="wp-list-table widefat fixed striped">';
|
echo '<table class="wp-list-table widefat fixed striped">';
|
||||||
echo '<thead><tr>';
|
echo '<thead><tr>';
|
||||||
echo '<th>' . esc_html__('提现单号', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('流水号', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('用户', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('用户', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('金额明细', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('金额明细', 'aksrt') . '</th>';
|
||||||
echo '<th>' . esc_html__('渠道 / 账户', 'aksrt') . '</th>';
|
echo '<th>' . esc_html__('渠道 / 账户', 'aksrt') . '</th>';
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ defined('ABSPATH') || exit;
|
|||||||
*
|
*
|
||||||
* 页面结构 1:1 复刻参考主题 Zibll 的「支付&付费」section(知识付费 / 余额充值 /
|
* 页面结构 1:1 复刻参考主题 Zibll 的「支付&付费」section(知识付费 / 余额充值 /
|
||||||
* VIP会员 / 创作分成 / 推广返佣 / 收款接口),并按产品需求新增「提现策略」子页。
|
* VIP会员 / 创作分成 / 推广返佣 / 收款接口),并按产品需求新增「提现策略」子页。
|
||||||
* 收款接口仅保留支付宝、微信、PayPal、Stripe、易支付;订单前缀 / 流水号前缀 /
|
* 收款接口仅保留支付宝、微信、PayPal、Stripe、易支付;订单、资金流水与提现
|
||||||
* 提现单号前缀配置保留并收口在收款接口页。
|
* 统一使用同一套流水号,无可配置前缀。
|
||||||
*/
|
*/
|
||||||
class SchemaPayment {
|
class SchemaPayment {
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class SchemaPayment {
|
|||||||
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
|
['key' => 'pay_mark', 'label' => '付费标记', 'type' => 'input', 'default' => '付费'],
|
||||||
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
|
['key' => 'payment_show_ip', 'label' => '显示用户IP', 'type' => 'switch', 'default' => false],
|
||||||
['key' => 'payment_show_device', 'label' => '显示设备信息', 'type' => 'switch', 'default' => false],
|
['key' => 'payment_show_device', 'label' => '显示设备信息', 'type' => 'switch', 'default' => false],
|
||||||
['key' => 'payment_show_order_no', 'label' => '显示订单号', 'type' => 'switch', 'default' => true],
|
['key' => 'payment_show_order_no', 'label' => '显示流水号', 'type' => 'switch', 'default' => true],
|
||||||
['key' => 'payment_show_create_time', 'label' => '显示创建时间', 'type' => 'switch', 'default' => true],
|
['key' => 'payment_show_create_time', 'label' => '显示创建时间', 'type' => 'switch', 'default' => true],
|
||||||
['key' => 'payment_show_pay_time', 'label' => '显示支付时间', 'type' => 'switch', 'default' => true],
|
['key' => 'payment_show_pay_time', 'label' => '显示支付时间', 'type' => 'switch', 'default' => true],
|
||||||
]],
|
]],
|
||||||
@@ -406,9 +406,6 @@ class SchemaPayment {
|
|||||||
['key' => 'pay_sdk_custom_title', 'label' => '自定义收款标题', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_sdk_custom_title_s', 'value' => true], 'help' => '可使用变量:订单类型 %order_type%,例如:%order_type%-AKSRT;注意控制总长度,太长会导致部分接口报错'],
|
['key' => 'pay_sdk_custom_title', 'label' => '自定义收款标题', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'pay_sdk_custom_title_s', 'value' => true], 'help' => '可使用变量:订单类型 %order_type%,例如:%order_type%-AKSRT;注意控制总长度,太长会导致部分接口报错'],
|
||||||
]],
|
]],
|
||||||
['key' => 'order', 'title' => '订单与编号', 'fields' => [
|
['key' => 'order', 'title' => '订单与编号', 'fields' => [
|
||||||
['key' => 'payment_order_prefix', 'label' => '订单前缀', 'type' => 'input', 'default' => 'AKSRT', 'help' => '订单号生成前缀'],
|
|
||||||
['key' => 'payment_flow_prefix', 'label' => '流水号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'AK', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
|
|
||||||
['key' => 'payment_withdrawal_prefix', 'label' => '提现单号前缀', 'type' => 'input', 'sanitize_type' => 'business_prefix', 'default' => 'TX', 'maxlength' => 12, 'help' => '仅允许字母、数字、下划线和短横线,最多 12 位。'],
|
|
||||||
['key' => 'payment_order_expiry', 'label' => '订单支付时效(分钟)', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 1440, 'help' => '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)'],
|
['key' => 'payment_order_expiry', 'label' => '订单支付时效(分钟)', 'type' => 'number', 'default' => 30, 'min' => 5, 'max' => 1440, 'help' => '用户下单后,最大支付时间,超过后订单将自动关闭(不能低于5分钟)'],
|
||||||
['key' => 'pay_wait_float_s', 'label' => '浮窗显示待支付订单', 'type' => 'switch', 'default' => true, 'help' => '将用户待支付订单一直显示在右上角,提醒用户付款'],
|
['key' => 'pay_wait_float_s', 'label' => '浮窗显示待支付订单', 'type' => 'switch', 'default' => true, 'help' => '将用户待支付订单一直显示在右上角,提醒用户付款'],
|
||||||
]],
|
]],
|
||||||
|
|||||||
@@ -892,9 +892,6 @@ class SchemaProvider {
|
|||||||
}
|
}
|
||||||
$type = (string) ($field['type'] ?? 'text');
|
$type = (string) ($field['type'] ?? 'text');
|
||||||
$sanitize_type = (string) ($field['sanitize_type'] ?? '');
|
$sanitize_type = (string) ($field['sanitize_type'] ?? '');
|
||||||
if ($sanitize_type === 'business_prefix') {
|
|
||||||
return \AKSRT\Finance\BusinessNumber::normalize_prefix($value, (string) ($field['default'] ?? 'AK'));
|
|
||||||
}
|
|
||||||
if ($sanitize_type !== '') {
|
if ($sanitize_type !== '') {
|
||||||
return $this->sanitize_value($value, $sanitize_type);
|
return $this->sanitize_value($value, $sanitize_type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,30 +7,28 @@ namespace AKSRT\Finance;
|
|||||||
|
|
||||||
defined('ABSPATH') || exit;
|
defined('ABSPATH') || exit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一业务流水号分配器。
|
||||||
|
*
|
||||||
|
* 订单号、资金流水号、提现单号共用同一套号码规则,不再按业务类型区分,
|
||||||
|
* 也不再存在任何可配置前缀:{YmdHis}{6 位随机数},共 20 字符。
|
||||||
|
* 该长度同时满足数据库 VARCHAR(32) 列与各网关 out_trade_no ≤32 字符的限制。
|
||||||
|
*/
|
||||||
final class BusinessNumber {
|
final class BusinessNumber {
|
||||||
|
|
||||||
public const MAX_PREFIX_LENGTH = 12;
|
/**
|
||||||
|
* 生成一个统一流水号。
|
||||||
public static function normalize_prefix(mixed $value, string $fallback): string {
|
*
|
||||||
$prefix = strtoupper(trim(sanitize_text_field(is_scalar($value) ? (string) $value : '')));
|
* @param \DateTimeInterface|null $now 分配时刻,默认取站内时区的当前时间。
|
||||||
$prefix = (string) preg_replace('/[^A-Z0-9_-]/', '', $prefix);
|
* @param int|null $random 0-999999 的随机后缀,默认随机取值。
|
||||||
$prefix = substr($prefix, 0, self::MAX_PREFIX_LENGTH);
|
*/
|
||||||
if ($prefix !== '') {
|
public static function allocate(?\DateTimeInterface $now = null, ?int $random = null): string {
|
||||||
return $prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fallback = strtoupper((string) preg_replace('/[^A-Z0-9_-]/', '', $fallback));
|
|
||||||
return substr($fallback !== '' ? $fallback : 'AK', 0, self::MAX_PREFIX_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function candidate(string $prefix, ?\DateTimeInterface $now = null, ?int $random = null): string {
|
|
||||||
$prefix = self::normalize_prefix($prefix, 'AK');
|
|
||||||
if ($now === null) {
|
if ($now === null) {
|
||||||
$now = new \DateTimeImmutable('now', wp_timezone());
|
$now = new \DateTimeImmutable('now', wp_timezone());
|
||||||
}
|
}
|
||||||
$random = $random ?? random_int(0, 999999);
|
$random = $random ?? random_int(0, 999999);
|
||||||
$random = max(0, min(999999, $random));
|
$random = max(0, min(999999, $random));
|
||||||
|
|
||||||
return $prefix . $now->format('YmdHis') . str_pad((string) $random, 6, '0', STR_PAD_LEFT);
|
return $now->format('YmdHis') . str_pad((string) $random, 6, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ final class FinancialFlowService {
|
|||||||
*
|
*
|
||||||
* 卡密是平台自发的预付凭证:核销那一刻既没有第三方现金流入,也不产生账本资产分录,
|
* 卡密是平台自发的预付凭证:核销那一刻既没有第三方现金流入,也不产生账本资产分录,
|
||||||
* 订单金额还可能为 0(会员卡)或以积分计价(积分卡)。因此这里只落一条与订单关联的
|
* 订单金额还可能为 0(会员卡)或以积分计价(积分卡)。因此这里只落一条与订单关联的
|
||||||
* order_payment 流水,不生成任何现金/资产分录,让订单在详情页具备可追溯的「支付流水号」。
|
* order_payment 流水,不生成任何现金/资产分录,让订单在详情页具备可追溯的「账本流水号」。
|
||||||
*
|
*
|
||||||
* 余额卡与积分卡的核销走账本(LedgerService::credit),其流水由 record_ledger() 落库;
|
* 余额卡与积分卡的核销走账本(LedgerService::credit),其流水由 record_ledger() 落库;
|
||||||
* 本方法供会员卡这类无账本参与的卡种调用。
|
* 本方法供会员卡这类无账本参与的卡种调用。
|
||||||
@@ -122,7 +122,7 @@ final class FinancialFlowService {
|
|||||||
* 卡密核销的资产入账走账本,但订单号是随机生成的、不能进 LedgerCommand
|
* 卡密核销的资产入账走账本,但订单号是随机生成的、不能进 LedgerCommand
|
||||||
* (payload_hash 覆盖 metadata,塞入随机号会破坏账本幂等重放)。因此账本
|
* (payload_hash 覆盖 metadata,塞入随机号会破坏账本幂等重放)。因此账本
|
||||||
* 提交之后再调用本方法补挂关联;同时把 event_type 归一为 order_payment,
|
* 提交之后再调用本方法补挂关联;同时把 event_type 归一为 order_payment,
|
||||||
* 让订单详情页的「支付流水号」能反查到它。
|
* 让订单详情页的「账本流水号」能反查到它。
|
||||||
*
|
*
|
||||||
* @return bool 是否发生了更新
|
* @return bool 是否发生了更新
|
||||||
*/
|
*/
|
||||||
@@ -218,12 +218,10 @@ final class FinancialFlowService {
|
|||||||
return new \WP_Error('aksrt_flow_db', __('无法开启资金流水事务', 'aksrt'), ['status' => 500]);
|
return new \WP_Error('aksrt_flow_db', __('无法开启资金流水事务', 'aksrt'), ['status' => 500]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$settings = \AKSRT\Settings\Settings::get_order_settings();
|
|
||||||
$prefix = BusinessNumber::normalize_prefix($settings['flow_prefix'] ?? 'AK', 'AK');
|
|
||||||
$flow_id = 0;
|
$flow_id = 0;
|
||||||
$flow_number = '';
|
$flow_number = '';
|
||||||
for ($attempt = 1; $attempt <= self::MAX_NUMBER_ATTEMPTS; $attempt++) {
|
for ($attempt = 1; $attempt <= self::MAX_NUMBER_ATTEMPTS; $attempt++) {
|
||||||
$flow_number = BusinessNumber::candidate($prefix);
|
$flow_number = BusinessNumber::allocate();
|
||||||
$metadata = is_array($flow['metadata'] ?? null) ? $flow['metadata'] : [];
|
$metadata = is_array($flow['metadata'] ?? null) ? $flow['metadata'] : [];
|
||||||
$inserted = $wpdb->insert($this->flow_table(), [
|
$inserted = $wpdb->insert($this->flow_table(), [
|
||||||
'flow_number' => $flow_number,
|
'flow_number' => $flow_number,
|
||||||
|
|||||||
@@ -726,8 +726,8 @@ class ChargeCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡密核销订单号:走统一的订单号分配器,受后台「订单前缀」控制
|
* 卡密核销订单号:走统一的流水号分配器,不再使用任何可配置前缀
|
||||||
* (Settings::get_order_settings()['prefix'],默认 AKSRT)。
|
* (见 {@see \AKSRT\Finance\BusinessNumber::allocate()})。
|
||||||
*
|
*
|
||||||
* @return string|\WP_Error
|
* @return string|\WP_Error
|
||||||
*/
|
*/
|
||||||
@@ -743,16 +743,11 @@ class ChargeCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卡密核销订单的渠道交易号:与资金流水同源,受后台「流水号前缀」控制
|
* 卡密核销订单的渠道交易号:与资金流水号同源,统一走流水号分配器,
|
||||||
* (Settings::get_order_settings()['flow_prefix'],默认 AK)。
|
* 不再消费任何后台前缀配置。
|
||||||
*/
|
*/
|
||||||
private function card_pass_transaction_number(): string {
|
private function card_pass_transaction_number(): string {
|
||||||
$prefix = 'AK';
|
return \AKSRT\Finance\BusinessNumber::allocate();
|
||||||
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_order_settings')) {
|
|
||||||
$settings = \AKSRT\Settings\Settings::get_order_settings();
|
|
||||||
$prefix = \AKSRT\Finance\BusinessNumber::normalize_prefix($settings['flow_prefix'] ?? 'AK', 'AK');
|
|
||||||
}
|
|
||||||
return \AKSRT\Finance\BusinessNumber::candidate($prefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ trait OrderRepositoryCore {
|
|||||||
public function create(array $data): string {
|
public function create(array $data): string {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$order_number = $data['order_number'] ?? $this->generate_order_number();
|
$order_number = $data['order_number'] ?? $this->allocate_order_number();
|
||||||
|
|
||||||
// Preserve JSON pay meta (VIP/content/coupon). Only strip tags for plain text notes.
|
// Preserve JSON pay meta (VIP/content/coupon). Only strip tags for plain text notes.
|
||||||
$note_raw = (string) ($data['note'] ?? '');
|
$note_raw = (string) ($data['note'] ?? '');
|
||||||
@@ -811,39 +811,13 @@ trait OrderRepositoryCore {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a unique order number using the admin-configured prefix.
|
* 分配订单号。
|
||||||
*
|
*
|
||||||
* Column + major gateways (WeChat out_trade_no) cap at 32 chars, so the
|
* 订单号不再是独立编号体系:与资金流水号、提现单号共用统一流水号规则,
|
||||||
* prefix is trimmed to leave room for {YmdHis}{4 digits} (=18).
|
* 由 {@see \AKSRT\Finance\BusinessNumber::allocate()} 生成,不带任何前缀。
|
||||||
*/
|
*/
|
||||||
public function allocate_order_number(): string {
|
public function allocate_order_number(): string {
|
||||||
return $this->generate_order_number();
|
return \AKSRT\Finance\BusinessNumber::allocate();
|
||||||
}
|
|
||||||
|
|
||||||
private function generate_order_number(): string {
|
|
||||||
$prefix = 'AKSRT';
|
|
||||||
if (class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_order_settings')) {
|
|
||||||
$settings = \AKSRT\Settings\Settings::get_order_settings();
|
|
||||||
$configured = sanitize_text_field((string) ($settings['prefix'] ?? ''));
|
|
||||||
if ($configured !== '') {
|
|
||||||
$prefix = $configured;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep only gateway-safe chars (REST + WeChat/Alipay out_trade_no).
|
|
||||||
$prefix = preg_replace('/[^A-Za-z0-9_-]/', '', $prefix);
|
|
||||||
if (!is_string($prefix) || $prefix === '') {
|
|
||||||
$prefix = 'AKSRT';
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = date('YmdHis') . str_pad((string) random_int(0, 9999), 4, '0', STR_PAD_LEFT);
|
|
||||||
// Reserve 18 for body; leave ≥1 char of prefix so numbers stay human-readable.
|
|
||||||
$max_prefix = max(1, 32 - strlen($body));
|
|
||||||
if (strlen($prefix) > $max_prefix) {
|
|
||||||
$prefix = substr($prefix, 0, $max_prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $prefix . $body;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class PaymentOrchestrator {
|
|||||||
public static function pay(GatewayInterface $gateway, array $order, array $opts = []): array {
|
public static function pay(GatewayInterface $gateway, array $order, array $opts = []): array {
|
||||||
$order_number = sanitize_text_field((string) ($order['order_number'] ?? ''));
|
$order_number = sanitize_text_field((string) ($order['order_number'] ?? ''));
|
||||||
if ($order_number === '' || !class_exists('AKSRT\\Payment\\OrderRepository')) {
|
if ($order_number === '' || !class_exists('AKSRT\\Payment\\OrderRepository')) {
|
||||||
return self::fail('aksrt_pay_failed', __('订单号无效。', 'aksrt'));
|
return self::fail('aksrt_pay_failed', __('流水号无效。', 'aksrt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$method = sanitize_key((string) ($order['payment_method'] ?? ''));
|
$method = sanitize_key((string) ($order['payment_method'] ?? ''));
|
||||||
|
|||||||
@@ -232,9 +232,8 @@ class UserOrders {
|
|||||||
])),
|
])),
|
||||||
];
|
];
|
||||||
if ($detail) {
|
if ($detail) {
|
||||||
$view['flow_number'] = $order_number !== '' && $group !== OrderCenterQuery::STATUS_PENDING
|
// 前台订单详情只暴露统一流水号(order_number);账本流水号为后台口径,
|
||||||
? \AKSRT\Finance\FinancialFlowQuery::get_instance()->order_payment_number($order_number)
|
// 不下发到前台,避免同一单据出现两个对外号码。
|
||||||
: '';
|
|
||||||
$view['paid_at'] = (string) ($order['paid_at'] ?? '');
|
$view['paid_at'] = (string) ($order['paid_at'] ?? '');
|
||||||
$view['expires_at'] = (string) ($order['expires_at'] ?? '');
|
$view['expires_at'] = (string) ($order['expires_at'] ?? '');
|
||||||
$view['reconciliation'] = $reconciliation ?: ['state' => 'not_needed', 'required' => false];
|
$view['reconciliation'] = $reconciliation ?: ['state' => 'not_needed', 'required' => false];
|
||||||
|
|||||||
@@ -147,11 +147,9 @@ class Withdrawal {
|
|||||||
'source' => 'balance',
|
'source' => 'balance',
|
||||||
'operation_key' => $operation_key,
|
'operation_key' => $operation_key,
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: $account;
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: $account;
|
||||||
$order_settings = \AKSRT\Settings\Settings::get_order_settings();
|
|
||||||
$prefix = \AKSRT\Finance\BusinessNumber::normalize_prefix($order_settings['withdrawal_prefix'] ?? 'TX', 'TX');
|
|
||||||
$ok = false;
|
$ok = false;
|
||||||
for ($attempt = 1; $attempt <= 5; $attempt++) {
|
for ($attempt = 1; $attempt <= 5; $attempt++) {
|
||||||
$withdrawal_number = \AKSRT\Finance\BusinessNumber::candidate($prefix);
|
$withdrawal_number = \AKSRT\Finance\BusinessNumber::allocate();
|
||||||
$ok = $wpdb->insert($this->table(), [
|
$ok = $wpdb->insert($this->table(), [
|
||||||
'withdrawal_number' => $withdrawal_number,
|
'withdrawal_number' => $withdrawal_number,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ trait CreditsPaymentGroups {
|
|||||||
/**
|
/**
|
||||||
* 获取订单设置
|
* 获取订单设置
|
||||||
*
|
*
|
||||||
* @return array{prefix:string,flow_prefix:string,withdrawal_prefix:string,expiry:int,show_user:bool,show_paycount:bool,no_logged_in:bool,cookie_day:int,no_logged_remind:bool,wait_float:bool,mark:string,box_position:string,show_ip:bool,show_device:bool,show_order_no:bool,show_create_time:bool,show_pay_time:bool,status_texts:array,service:array}
|
* @return array{expiry:int,show_user:bool,show_paycount:bool,no_logged_in:bool,cookie_day:int,no_logged_remind:bool,wait_float:bool,mark:string,box_position:string,show_ip:bool,show_device:bool,show_order_no:bool,show_create_time:bool,show_pay_time:bool,status_texts:array,service:array}
|
||||||
*/
|
*/
|
||||||
public static function get_order_settings(): array {
|
public static function get_order_settings(): array {
|
||||||
return PaymentRuntime::get_order_settings();
|
return PaymentRuntime::get_order_settings();
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ final class MailTemplates {
|
|||||||
public static function definitions(): array {
|
public static function definitions(): array {
|
||||||
return [
|
return [
|
||||||
'links_submit_admin' => self::event('友情链接提交通知', '新友情链接提交:{title}\n提交人:{username}\n链接:{url}\n请登录后台审核。', ['title', 'username', 'url']),
|
'links_submit_admin' => self::event('友情链接提交通知', '新友情链接提交:{title}\n提交人:{username}\n链接:{url}\n请登录后台审核。', ['title', 'username', 'url']),
|
||||||
'order_paid_admin' => self::event('新订单通知(管理员)', '收到一笔新订单。\n订单号:{order_number}\n用户:{username}\n商品:{product}\n金额:{amount} {currency}\n支付方式:{payment_method}', ['order_number', 'username', 'product', 'amount', 'currency', 'payment_method']),
|
'order_paid_admin' => self::event('新订单通知(管理员)', '收到一笔新订单。\n流水号:{order_number}\n用户:{username}\n商品:{product}\n金额:{amount} {currency}\n支付方式:{payment_method}', ['order_number', 'username', 'product', 'amount', 'currency', 'payment_method']),
|
||||||
'withdraw_submitted_admin' => self::event('提现申请通知(管理员)', '用户 {username} 提交了提现申请。\n提现单号:{withdrawal_number}\n金额:{amount}\n方式:{method}', ['username', 'withdrawal_number', 'amount', 'method']),
|
'withdraw_submitted_admin' => self::event('提现申请通知(管理员)', '用户 {username} 提交了提现申请。\n流水号:{withdrawal_number}\n金额:{amount}\n方式:{method}', ['username', 'withdrawal_number', 'amount', 'method']),
|
||||||
'post_pending_admin' => self::event('投稿待审核通知', '用户 {username} 提交了待审核内容:{title}\n查看地址:{url}', ['username', 'title', 'url']),
|
'post_pending_admin' => self::event('投稿待审核通知', '用户 {username} 提交了待审核内容:{title}\n查看地址:{url}', ['username', 'title', 'url']),
|
||||||
'auth_apply_admin' => self::event('身份认证申请通知', '用户 {username} 提交了身份认证申请,请登录后台审核。\n查看地址:{url}', ['username', 'url']),
|
'auth_apply_admin' => self::event('身份认证申请通知', '用户 {username} 提交了身份认证申请,请登录后台审核。\n查看地址:{url}', ['username', 'url']),
|
||||||
'ban_appeal_admin' => self::event('账号申诉通知', '用户 {username} 提交了账号申诉。\n查看地址:{url}', ['username', 'url']),
|
'ban_appeal_admin' => self::event('账号申诉通知', '用户 {username} 提交了账号申诉。\n查看地址:{url}', ['username', 'url']),
|
||||||
@@ -27,9 +27,9 @@ final class MailTemplates {
|
|||||||
'password_reset' => self::event('密码重置验证码', '您好 {username},\n\n您正在重置 {site_name} 的账号密码,验证码为:\n\n【{code}】\n\n验证码 10 分钟内有效。如非本人操作,请忽略此邮件。', ['username', 'site_name', 'code']),
|
'password_reset' => self::event('密码重置验证码', '您好 {username},\n\n您正在重置 {site_name} 的账号密码,验证码为:\n\n【{code}】\n\n验证码 10 分钟内有效。如非本人操作,请忽略此邮件。', ['username', 'site_name', 'code']),
|
||||||
'change_code' => self::event('敏感操作验证码', '您好 {username},\n\n您正在进行敏感操作,验证码为:\n\n【{code}】\n\n验证码 5 分钟内有效。如非本人操作,请忽略此邮件。', ['username', 'site_name', 'code']),
|
'change_code' => self::event('敏感操作验证码', '您好 {username},\n\n您正在进行敏感操作,验证码为:\n\n【{code}】\n\n验证码 5 分钟内有效。如非本人操作,请忽略此邮件。', ['username', 'site_name', 'code']),
|
||||||
'change_notice' => self::event('账号邮箱已变更', '您好 {username},\n\n您的账号邮箱已成功修改为:{new_email}\n\n如果这不是您的操作,请立即联系站点管理员。', ['username', 'site_name', 'new_email']),
|
'change_notice' => self::event('账号邮箱已变更', '您好 {username},\n\n您的账号邮箱已成功修改为:{new_email}\n\n如果这不是您的操作,请立即联系站点管理员。', ['username', 'site_name', 'new_email']),
|
||||||
'order_paid' => self::event('订单支付成功', '您好 {username},\n\n您的订单已支付成功。\n订单号:{order_number}\n商品:{product}\n金额:{amount} {currency}\n\n查看订单:{url}', ['username', 'order_number', 'product', 'amount', 'currency', 'url']),
|
'order_paid' => self::event('订单支付成功', '您好 {username},\n\n您的订单已支付成功。\n流水号:{order_number}\n商品:{product}\n金额:{amount} {currency}\n\n查看订单:{url}', ['username', 'order_number', 'product', 'amount', 'currency', 'url']),
|
||||||
'order_status' => self::event('订单状态更新', '您好 {username},\n\n您的订单 {order_number} 状态已更新为:{status}。\n商品:{product}\n查看详情:{url}', ['username', 'order_number', 'status', 'product', 'url']),
|
'order_status' => self::event('订单状态更新', '您好 {username},\n\n您的订单 {order_number} 状态已更新为:{status}。\n商品:{product}\n查看详情:{url}', ['username', 'order_number', 'status', 'product', 'url']),
|
||||||
'withdraw_submitted' => self::event('提现申请已提交', '您好 {username},\n\n您的提现申请已提交。\n提现单号:{withdrawal_number}\n金额:{amount}\n方式:{method}', ['username', 'withdrawal_number', 'amount', 'method']),
|
'withdraw_submitted' => self::event('提现申请已提交', '您好 {username},\n\n您的提现申请已提交。\n流水号:{withdrawal_number}\n金额:{amount}\n方式:{method}', ['username', 'withdrawal_number', 'amount', 'method']),
|
||||||
'withdraw_completed' => self::event('提现状态更新', '您好 {username},\n\n您的提现申请 {withdrawal_number} 当前状态为:{status}。\n金额:{amount}\n{note}', ['username', 'withdrawal_number', 'status', 'amount', 'note']),
|
'withdraw_completed' => self::event('提现状态更新', '您好 {username},\n\n您的提现申请 {withdrawal_number} 当前状态为:{status}。\n金额:{amount}\n{note}', ['username', 'withdrawal_number', 'status', 'amount', 'note']),
|
||||||
'affiliate_commission' => self::event('返佣到账通知', '您好 {username},\n\n您的推广返佣已到账。\n金额:{amount}\n来源订单:{order_number}\n查看收益:{url}', ['username', 'amount', 'order_number', 'url']),
|
'affiliate_commission' => self::event('返佣到账通知', '您好 {username},\n\n您的推广返佣已到账。\n金额:{amount}\n来源订单:{order_number}\n查看收益:{url}', ['username', 'amount', 'order_number', 'url']),
|
||||||
'creator_income' => self::event('创作分成到账通知', '您好 {username},\n\n您的创作分成已到账。\n金额:{amount}\n来源订单:{order_number}\n查看收益:{url}', ['username', 'amount', 'order_number', 'url']),
|
'creator_income' => self::event('创作分成到账通知', '您好 {username},\n\n您的创作分成已到账。\n金额:{amount}\n来源订单:{order_number}\n查看收益:{url}', ['username', 'amount', 'order_number', 'url']),
|
||||||
|
|||||||
@@ -454,9 +454,6 @@ class PaymentRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'prefix' => sanitize_text_field((string) ($s['payment_order_prefix'] ?? 'AKSRT')),
|
|
||||||
'flow_prefix' => \AKSRT\Finance\BusinessNumber::normalize_prefix($s['payment_flow_prefix'] ?? 'AK', 'AK'),
|
|
||||||
'withdrawal_prefix' => \AKSRT\Finance\BusinessNumber::normalize_prefix($s['payment_withdrawal_prefix'] ?? 'TX', 'TX'),
|
|
||||||
'expiry' => $expiry,
|
'expiry' => $expiry,
|
||||||
'show_user' => !isset($s['pay_show_user']) || !empty($s['pay_show_user']),
|
'show_user' => !isset($s['pay_show_user']) || !empty($s['pay_show_user']),
|
||||||
'show_paycount' => !isset($s['pay_show_paycount']) || !empty($s['pay_show_paycount']),
|
'show_paycount' => !isset($s['pay_show_paycount']) || !empty($s['pay_show_paycount']),
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ if ($is_need_purchase && $user_amount > 0) {
|
|||||||
</div>
|
</div>
|
||||||
<?php if (is_array($paid_order) && !empty($paid_order['order_number'])) : ?>
|
<?php if (is_array($paid_order) && !empty($paid_order['order_number'])) : ?>
|
||||||
<div class="resource-download-box__paid-meta">
|
<div class="resource-download-box__paid-meta">
|
||||||
<span><?php printf(esc_html__('订单号:%s', 'aksrt'), esc_html((string) $paid_order['order_number'])); ?></span>
|
<span><?php printf(esc_html__('流水号:%s', 'aksrt'), esc_html((string) $paid_order['order_number'])); ?></span>
|
||||||
<?php if (!empty($paid_order['paid_at'])) : ?>
|
<?php if (!empty($paid_order['paid_at'])) : ?>
|
||||||
<span><?php printf(esc_html__('支付时间:%s', 'aksrt'), esc_html((string) $paid_order['paid_at'])); ?></span>
|
<span><?php printf(esc_html__('支付时间:%s', 'aksrt'), esc_html((string) $paid_order['paid_at'])); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -5,13 +5,14 @@
|
|||||||
*
|
*
|
||||||
* 背景(已修复的缺陷):
|
* 背景(已修复的缺陷):
|
||||||
* 卡密充值(balance/credits)与兑换(vip)虽已建订单,但订单号硬编码为
|
* 卡密充值(balance/credits)与兑换(vip)虽已建订单,但订单号硬编码为
|
||||||
* `CARD{卡ID}`、渠道交易号硬编码为 `card_pass_{卡ID}`,均不受后台
|
* `CARD{卡ID}`、渠道交易号硬编码为 `card_pass_{卡ID}`;且卡密核销产生的资金流水
|
||||||
* 「订单前缀 / 流水号前缀」控制;且卡密核销产生的资金流水没有挂到订单上
|
* 没有挂到订单上(order_number 为 NULL),订单详情页的「账本流水号」永远显示「—」。
|
||||||
* (order_number 为 NULL),订单详情页的「支付流水号」永远显示「—」。
|
|
||||||
*
|
*
|
||||||
* 处置:
|
* 处置:
|
||||||
* - 订单号走 OrderRepository::allocate_order_number()(消费 payment_order_prefix);
|
* - 订单号走 OrderRepository::allocate_order_number();
|
||||||
* - 渠道交易号走 BusinessNumber::candidate(flow_prefix)(消费 payment_flow_prefix);
|
* - 渠道交易号走 BusinessNumber::allocate();
|
||||||
|
* - 两者与资金流水号、提现单号同源,均为无前缀的统一流水号,
|
||||||
|
* 后台不再提供任何前缀配置项;
|
||||||
* - 余额/积分卡的流水由账本落库后用 attach_order_to_ledger_flow() 补挂订单号,
|
* - 余额/积分卡的流水由账本落库后用 attach_order_to_ledger_flow() 补挂订单号,
|
||||||
* 并把 event_type 归一为 order_payment;会员卡(0 元、无账本参与)由
|
* 并把 event_type 归一为 order_payment;会员卡(0 元、无账本参与)由
|
||||||
* record_card_pass_payment() 直接落一条零分录的 order_payment 流水。
|
* record_card_pass_payment() 直接落一条零分录的 order_payment 流水。
|
||||||
@@ -47,11 +48,12 @@ test('卡密订单号不再硬编码 CARD 前缀,改走统一分配器', () =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('渠道交易号不再硬编码 card_pass_ 前缀,改走流水号前缀', () => {
|
test('渠道交易号不再硬编码 card_pass_ 前缀,改走统一流水号分配器', () => {
|
||||||
assert.doesNotMatch(card, /'card_pass_'\s*\.\s*\$card_id/);
|
assert.doesNotMatch(card, /'card_pass_'\s*\.\s*\$card_id/);
|
||||||
assert.match(card, /card_pass_transaction_number\(\)/);
|
assert.match(card, /card_pass_transaction_number\(\)/);
|
||||||
assert.match(card, /BusinessNumber::normalize_prefix\(\$settings\['flow_prefix'\]/);
|
// 不再读取任何前缀配置,直接取统一流水号
|
||||||
assert.match(card, /BusinessNumber::candidate\(\$prefix\)/);
|
assert.doesNotMatch(card, /normalize_prefix|flow_prefix|get_order_settings/);
|
||||||
|
assert.match(card, /private function card_pass_transaction_number\(\): string \{\s*return \\AKSRT\\Finance\\BusinessNumber::allocate\(\);/);
|
||||||
// create_redeem_order 只接收调用方传入的交易号,不再自行拼前缀
|
// create_redeem_order 只接收调用方传入的交易号,不再自行拼前缀
|
||||||
assert.match(card, /'payment_transaction_id'\s*=>\s*\$order_status === Order::STATUS_PAID \? \$transaction_number : ''/);
|
assert.match(card, /'payment_transaction_id'\s*=>\s*\$order_status === Order::STATUS_PAID \? \$transaction_number : ''/);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,16 +4,24 @@ use AKSRT\Finance\BusinessNumber;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
final class BusinessNumberTest extends TestCase {
|
final class BusinessNumberTest extends TestCase {
|
||||||
public function test_prefix_is_uppercased_filtered_and_limited(): void {
|
public function test_allocate_uses_site_time_and_six_digit_random_suffix(): void {
|
||||||
self::assertSame('AK', BusinessNumber::normalize_prefix('', 'AK'));
|
$time = new DateTimeImmutable('2026-08-25 13:14:15', new DateTimeZone('Asia/Shanghai'));
|
||||||
self::assertSame('TX_TEST-9', BusinessNumber::normalize_prefix(' tx_测test-9 ', 'TX'));
|
self::assertSame('20260825131415000007', BusinessNumber::allocate($time, 7));
|
||||||
self::assertSame('ABCDEFGHIJKL', BusinessNumber::normalize_prefix('abcdefghijklmnop', 'AK'));
|
self::assertSame('20260825131415999999', BusinessNumber::allocate($time, 999999));
|
||||||
self::assertSame('TX', BusinessNumber::normalize_prefix('中文', 'TX'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_candidate_uses_supplied_site_time_and_six_digit_random_suffix(): void {
|
public function test_allocate_is_prefix_free_and_within_gateway_limit(): void {
|
||||||
$time = new DateTimeImmutable('2026-08-25 13:14:15', new DateTimeZone('Asia/Shanghai'));
|
$time = new DateTimeImmutable('2026-08-25 13:14:15', new DateTimeZone('Asia/Shanghai'));
|
||||||
self::assertSame('AK20260825131415000007', BusinessNumber::candidate('ak', $time, 7));
|
$number = BusinessNumber::allocate($time, 0);
|
||||||
self::assertMatchesRegularExpression('/^TX\d{14}\d{6}$/', BusinessNumber::candidate('TX', $time, 999999));
|
self::assertSame('20260825131415000000', $number);
|
||||||
|
// 订单号 / 流水号 / 提现单号共用同一长度,须同时满足 VARCHAR(32) 与网关 out_trade_no ≤32。
|
||||||
|
self::assertSame(20, strlen($number));
|
||||||
|
self::assertLessThanOrEqual(32, strlen($number));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_allocate_clamps_out_of_range_random_suffix(): void {
|
||||||
|
$time = new DateTimeImmutable('2026-01-01 00:00:00', new DateTimeZone('Asia/Shanghai'));
|
||||||
|
self::assertSame('20260101000000999999', BusinessNumber::allocate($time, 1000000));
|
||||||
|
self::assertSame('20260101000000000000', BusinessNumber::allocate($time, -5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,32 @@ test('financial flow and withdrawal numbers use the new-only schema', () => {
|
|||||||
assert.match(schema, /CREATE TABLE \{\$prefix\}aksrt_withdrawal \([\s\S]*?withdrawal_number VARCHAR\(32\) NOT NULL[\s\S]*?UNIQUE KEY uniq_withdrawal_number \(withdrawal_number\)/)
|
assert.match(schema, /CREATE TABLE \{\$prefix\}aksrt_withdrawal \([\s\S]*?withdrawal_number VARCHAR\(32\) NOT NULL[\s\S]*?UNIQUE KEY uniq_withdrawal_number \(withdrawal_number\)/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('order settings expose strict flow and withdrawal prefixes', () => {
|
test('order, flow and withdrawal numbers share one prefix-free allocator', () => {
|
||||||
const schema = read('assets/admin/src/schema/sections/payment/gateway.js')
|
const jsSchema = read('assets/admin/src/schema/sections/payment/gateway.js')
|
||||||
|
const phpSchema = read('src/Admin/Schema/SchemaPayment.php')
|
||||||
const provider = read('src/Admin/SchemaProvider.php')
|
const provider = read('src/Admin/SchemaProvider.php')
|
||||||
assert.match(schema, /key:\s*'payment_flow_prefix'[^{\n]*sanitize_type:\s*'business_prefix'[^{\n]*default:\s*'AK'/)
|
const runtime = read('src/Settings/PaymentRuntime.php')
|
||||||
assert.match(schema, /key:\s*'payment_withdrawal_prefix'[^{\n]*sanitize_type:\s*'business_prefix'[^{\n]*default:\s*'TX'/)
|
const number = read('src/Finance/BusinessNumber.php')
|
||||||
assert.match(provider, /business_prefix[\s\S]*?BusinessNumber::normalize_prefix/)
|
|
||||||
|
// 三个前缀配置项及其校验/归一化链路必须彻底消失。
|
||||||
|
for (const source of [jsSchema, phpSchema]) {
|
||||||
|
assert.doesNotMatch(source, /payment_order_prefix|payment_flow_prefix|payment_withdrawal_prefix/)
|
||||||
|
assert.doesNotMatch(source, /business_prefix/)
|
||||||
|
}
|
||||||
|
assert.doesNotMatch(provider, /business_prefix|normalize_prefix/)
|
||||||
|
assert.doesNotMatch(runtime, /payment_order_prefix|payment_flow_prefix|payment_withdrawal_prefix/)
|
||||||
|
assert.doesNotMatch(runtime, /['"](prefix|flow_prefix|withdrawal_prefix)['"]\s*=>/)
|
||||||
|
assert.doesNotMatch(number, /normalize_prefix|MAX_PREFIX_LENGTH|candidate\(/)
|
||||||
|
|
||||||
|
// 唯一入口:无前缀的统一流水号分配器。
|
||||||
|
assert.match(number, /public static function allocate\(\?\\?DateTimeInterface/)
|
||||||
|
assert.match(number, /YmdHis/)
|
||||||
|
|
||||||
|
// 订单号、资金流水号、提现单号、卡密渠道交易号全部收敛到该分配器。
|
||||||
|
assert.match(read('src/Payment/OrderRepositoryCore.php'), /BusinessNumber::allocate\(\)/)
|
||||||
|
assert.match(read('src/Finance/FinancialFlowService.php'), /BusinessNumber::allocate\(\)/)
|
||||||
|
assert.match(read('src/Payment/Withdrawal.php'), /BusinessNumber::allocate\(\)/)
|
||||||
|
assert.match(read('src/Payment/ChargeCard.php'), /BusinessNumber::allocate\(\)/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('ledger and business state write their flow before commit', () => {
|
test('ledger and business state write their flow before commit', () => {
|
||||||
@@ -35,10 +55,14 @@ test('ledger and business state write their flow before commit', () => {
|
|||||||
test('native and front-end surfaces expose immutable business numbers', () => {
|
test('native and front-end surfaces expose immutable business numbers', () => {
|
||||||
assert.match(read('src/Admin/Native/PayMenus.php'), /PayFlows::PAGE_SLUG/)
|
assert.match(read('src/Admin/Native/PayMenus.php'), /PayFlows::PAGE_SLUG/)
|
||||||
assert.match(read('src/Admin/Native/PayFlows.php'), /流水明细/)
|
assert.match(read('src/Admin/Native/PayFlows.php'), /流水明细/)
|
||||||
assert.match(read('src/Admin/Native/PayOrders.php'), /支付流水号/)
|
// 后台同时提供业务流水号与账本流水号两个口径
|
||||||
assert.match(read('src/Admin/Native/PayWithdrawals.php'), /提现单号/)
|
assert.match(read('src/Admin/Native/PayOrders.php'), /账本流水号/)
|
||||||
assert.match(read('src/Payment/UserOrders.php'), /\$view\['flow_number'\]/)
|
assert.match(read('src/Admin/Native/PayWithdrawals.php'), /esc_html__\('流水号'/)
|
||||||
assert.match(read('assets/js/order-center.js'), /\["流水号", order\.flow_number \|\| "—"\]/)
|
assert.doesNotMatch(read('src/Admin/Native/PayWithdrawals.php'), /提现单号/)
|
||||||
|
// 前台订单详情只对外暴露统一流水号:账本流水号既不下发也不展示
|
||||||
|
assert.match(read('assets/js/order-center.js'), /\["流水号", order\.order_number\]/)
|
||||||
|
assert.doesNotMatch(read('assets/js/order-center.js'), /flow_number|账本流水号/)
|
||||||
|
assert.doesNotMatch(read('src/Payment/UserOrders.php'), /\$view\['flow_number'\]/)
|
||||||
assert.match(read('inc/helpers/user-center-renderers/credits-wallet-ledger.php'), /withdrawal_number/)
|
assert.match(read('inc/helpers/user-center-renderers/credits-wallet-ledger.php'), /withdrawal_number/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ test('paid article and sidebar widget use the Zibll purchase-card DOM', () => {
|
|||||||
assert.match(pay, /function aksrt_get_paid_box_html/);
|
assert.match(pay, /function aksrt_get_paid_box_html/);
|
||||||
assert.match(pay, /pay-box zib-widget paid-box order-type-/);
|
assert.match(pay, /pay-box zib-widget paid-box order-type-/);
|
||||||
assert.match(pay, /flex ac jb-green padding-10 em09/);
|
assert.match(pay, /flex ac jb-green padding-10 em09/);
|
||||||
assert.match(pay, /订单号/);
|
assert.match(pay, /流水号/);
|
||||||
|
assert.doesNotMatch(pay, /'订单号'/);
|
||||||
assert.match(pay, /支付时间/);
|
assert.match(pay, /支付时间/);
|
||||||
assert.match(pay, /支付金额/);
|
assert.match(pay, /支付金额/);
|
||||||
assert.match(pay, /hidden-box show/);
|
assert.match(pay, /hidden-box show/);
|
||||||
|
|||||||
Reference in new issue
Block a user