@pisell/pisellos 2.3.196 → 2.3.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +3 -0
- package/dist/modules/Order/index.js +127 -46
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.js +180 -176
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/small-ticket.d.ts +3 -0
- package/dist/shared/receipt/small-ticket.js +26 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/OrderInvoicePreview/index.js +13 -8
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/index.js +66 -57
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
- package/lib/modules/Order/index.d.ts +3 -0
- package/lib/modules/Order/index.js +85 -16
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.js +16 -4
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/small-ticket.d.ts +3 -0
- package/lib/shared/receipt/small-ticket.js +24 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/OrderInvoicePreview/index.js +6 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/index.js +37 -33
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
- package/package.json +1 -1
|
@@ -1600,7 +1600,37 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1600
1600
|
}, new _decimal.default(0));
|
|
1601
1601
|
}
|
|
1602
1602
|
getDepositAmount(tempOrder, summary) {
|
|
1603
|
-
|
|
1603
|
+
const summaryAmount = summary.deposit_amount;
|
|
1604
|
+
const amount = summaryAmount === '' ? tempOrder.deposit_amount : summaryAmount ?? tempOrder.deposit_amount;
|
|
1605
|
+
return _decimal.default.min(_decimal.default.max(new _decimal.default(amount || 0), 0), this.getOrderExpectedAmount(summary));
|
|
1606
|
+
}
|
|
1607
|
+
isDepositSelectionDisabled(tempOrder) {
|
|
1608
|
+
return tempOrder._extend?.depositSelectionDisabled === true || tempOrder.is_deposit === 0 && new _decimal.default(tempOrder.deposit_amount || 0).gt(0);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
/** Cap only the active target; product rules, manual intent and saved snapshots stay raw. */
|
|
1612
|
+
applyEffectiveDepositSummary(tempOrder, summary) {
|
|
1613
|
+
const disabled = this.isDepositSelectionDisabled(tempOrder);
|
|
1614
|
+
if (disabled) {
|
|
1615
|
+
tempOrder._extend = {
|
|
1616
|
+
...(tempOrder._extend || {}),
|
|
1617
|
+
depositSelectionDisabled: true
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
const depositAmount = this.getDepositAmount(tempOrder, summary).toFixed(2);
|
|
1621
|
+
const hasDepositAmount = new _decimal.default(depositAmount).gt(0);
|
|
1622
|
+
const nextSummary = {
|
|
1623
|
+
...summary,
|
|
1624
|
+
deposit_amount: depositAmount,
|
|
1625
|
+
deposit: hasDepositAmount ? {
|
|
1626
|
+
...(summary.deposit || {}),
|
|
1627
|
+
total: depositAmount,
|
|
1628
|
+
hasDeposit: true
|
|
1629
|
+
} : undefined
|
|
1630
|
+
};
|
|
1631
|
+
tempOrder.deposit_amount = depositAmount;
|
|
1632
|
+
tempOrder.is_deposit = hasDepositAmount && tempOrder.is_deposit === 1 && !disabled ? 1 : 0;
|
|
1633
|
+
return nextSummary;
|
|
1604
1634
|
}
|
|
1605
1635
|
normalizeDepositAmount(amount) {
|
|
1606
1636
|
return _decimal.default.max(new _decimal.default(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
@@ -1614,8 +1644,19 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1614
1644
|
if (!source || typeof source !== 'object') return null;
|
|
1615
1645
|
const record = source;
|
|
1616
1646
|
const rawDepositAmount = record.deposit_amount ?? record.summary?.deposit_amount;
|
|
1647
|
+
if (rawDepositAmount === undefined || rawDepositAmount === null || rawDepositAmount === '') return null;
|
|
1617
1648
|
const depositAmount = this.normalizeDepositAmount(rawDepositAmount ?? 0);
|
|
1618
|
-
if (!new _decimal.default(depositAmount).gt(0))
|
|
1649
|
+
if (!new _decimal.default(depositAmount).gt(0)) {
|
|
1650
|
+
// A saved zero is meaningful for an existing deposit product, but must not
|
|
1651
|
+
// freeze ordinary historical retail orders when a deposit product is added.
|
|
1652
|
+
const products = Array.isArray(record.products) ? record.products : [];
|
|
1653
|
+
const hasDepositContext = this.normalizeDepositFlag(record.is_deposit) === 1 || products.some(product => Number(product?.deposit?.total) > 0) || (0, _utils.calculateOrderProductsDeposit)(products.map(product => ({
|
|
1654
|
+
...product
|
|
1655
|
+
})), {
|
|
1656
|
+
productsByUid: record._extend?.productsByUid
|
|
1657
|
+
}).hasDeposit;
|
|
1658
|
+
if (!hasDepositContext) return null;
|
|
1659
|
+
}
|
|
1619
1660
|
return {
|
|
1620
1661
|
// 兼容历史数据:旧快照缺少 is_deposit 时,沿用正定金金额的推导规则。
|
|
1621
1662
|
isDeposit: this.normalizeDepositFlag(record.is_deposit) ?? 1,
|
|
@@ -1679,7 +1720,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1679
1720
|
return tempOrder.is_deposit === 1 && depositAmount.gt(0);
|
|
1680
1721
|
}
|
|
1681
1722
|
getOrderExpectedAmount(summary) {
|
|
1682
|
-
|
|
1723
|
+
const expected = summary.expect_amount;
|
|
1724
|
+
const amount = expected === '' ? summary.total_amount : expected ?? summary.total_amount;
|
|
1725
|
+
return _decimal.default.max(new _decimal.default(amount || 0), 0);
|
|
1683
1726
|
}
|
|
1684
1727
|
isDepositCovered(params) {
|
|
1685
1728
|
const depositAmount = this.getDepositAmount(params.tempOrder, params.summary);
|
|
@@ -1728,7 +1771,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1728
1771
|
});
|
|
1729
1772
|
}
|
|
1730
1773
|
resolveNextOrderPaymentType(tempOrder) {
|
|
1731
|
-
const depositAmount =
|
|
1774
|
+
const depositAmount = this.getDepositAmount(tempOrder, this.store.summary || (0, _utils.createEmptySummary)());
|
|
1732
1775
|
if (!this.isDepositOrder(tempOrder, depositAmount)) return 'normal';
|
|
1733
1776
|
if (depositAmount.lte(0)) return 'normal';
|
|
1734
1777
|
if (this.hasPaidNormalPayment(tempOrder.payments || [])) return 'normal';
|
|
@@ -2229,6 +2272,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2229
2272
|
tempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
|
|
2230
2273
|
}
|
|
2231
2274
|
}
|
|
2275
|
+
summary = this.applyEffectiveDepositSummary(tempOrder, summary);
|
|
2232
2276
|
const isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
|
|
2233
2277
|
if (!isPayableAmountUnchanged) return null;
|
|
2234
2278
|
const currentPaidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
@@ -2244,8 +2288,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2244
2288
|
tempOrder.surcharges = (0, _lodashEs.cloneDeep)(snapshot.surcharges);
|
|
2245
2289
|
}
|
|
2246
2290
|
tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
|
|
2247
|
-
tempOrder.deposit_amount = this.normalizeDepositAmount(summary.deposit_amount || 0);
|
|
2248
|
-
tempOrder.is_deposit = shouldUseManualDepositOverride ? new _decimal.default(tempOrder.deposit_amount).gt(0) ? 1 : 0 : historicalDepositSnapshot?.isDeposit ?? (new _decimal.default(tempOrder.deposit_amount).gt(0) ? 1 : 0);
|
|
2249
2291
|
const previousSummary = this.store.summary;
|
|
2250
2292
|
this.store.summary = summary;
|
|
2251
2293
|
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
@@ -2378,7 +2420,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2378
2420
|
const tempOrder = this.store.tempOrder;
|
|
2379
2421
|
if (!tempOrder) return null;
|
|
2380
2422
|
const summary = this.store.summary || (0, _utils.createEmptySummary)();
|
|
2381
|
-
const depositAmount = tempOrder
|
|
2423
|
+
const depositAmount = this.getDepositAmount(tempOrder, summary);
|
|
2382
2424
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2383
2425
|
const amountGap = this.calculateSummaryAmountGap({
|
|
2384
2426
|
tempOrder,
|
|
@@ -2386,10 +2428,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2386
2428
|
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
2387
2429
|
});
|
|
2388
2430
|
return {
|
|
2389
|
-
isDeposit: tempOrder
|
|
2390
|
-
depositAmount,
|
|
2391
|
-
expectAmount: summary.expect_amount
|
|
2392
|
-
totalAmount: summary.total_amount
|
|
2431
|
+
isDeposit: this.isDepositOrder(tempOrder, depositAmount),
|
|
2432
|
+
depositAmount: depositAmount.toFixed(2),
|
|
2433
|
+
expectAmount: String(summary.expect_amount ?? '0.00'),
|
|
2434
|
+
totalAmount: String(summary.total_amount ?? '0.00'),
|
|
2393
2435
|
amountGap,
|
|
2394
2436
|
summary
|
|
2395
2437
|
};
|
|
@@ -2707,6 +2749,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2707
2749
|
return this.core.getModule(this.salesSummaryModuleName);
|
|
2708
2750
|
}
|
|
2709
2751
|
applyOrderProductsDepositSummary(tempOrder, summary) {
|
|
2752
|
+
const isExistingDepositDisabled = this.isDepositSelectionDisabled(tempOrder);
|
|
2753
|
+
if (isExistingDepositDisabled) {
|
|
2754
|
+
tempOrder._extend = {
|
|
2755
|
+
...(tempOrder._extend || {}),
|
|
2756
|
+
depositSelectionDisabled: true
|
|
2757
|
+
};
|
|
2758
|
+
}
|
|
2710
2759
|
const depositSummary = (0, _utils.calculateOrderProductsDeposit)(tempOrder.products || [], {
|
|
2711
2760
|
productsByUid: tempOrder._extend?.productsByUid
|
|
2712
2761
|
});
|
|
@@ -2728,10 +2777,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2728
2777
|
hasDeposit: true
|
|
2729
2778
|
} : undefined
|
|
2730
2779
|
};
|
|
2731
|
-
const isExistingDepositDisabled = tempOrder.is_deposit === 0 && new _decimal.default(tempOrder.deposit_amount || 0).gt(0);
|
|
2732
2780
|
tempOrder.deposit_amount = depositAmount;
|
|
2733
2781
|
tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
|
|
2734
|
-
return shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
2782
|
+
return this.applyEffectiveDepositSummary(tempOrder, shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary));
|
|
2735
2783
|
}
|
|
2736
2784
|
async recalculateSummary(options) {
|
|
2737
2785
|
if (options?.isCurrentOrder && !options.isCurrentOrder()) return null;
|
|
@@ -3066,11 +3114,15 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3066
3114
|
updateTempOrderDepositAmount(amount) {
|
|
3067
3115
|
const tempOrder = this.ensureTempOrder();
|
|
3068
3116
|
const depositAmount = this.normalizeDepositAmount(amount);
|
|
3117
|
+
tempOrder._extend = {
|
|
3118
|
+
...(tempOrder._extend || {}),
|
|
3119
|
+
depositSelectionDisabled: new _decimal.default(depositAmount).lte(0)
|
|
3120
|
+
};
|
|
3069
3121
|
const previousSummary = this.store.summary || (0, _utils.createEmptySummary)();
|
|
3070
|
-
const summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, {
|
|
3122
|
+
const summaryWithDeposit = this.applyEffectiveDepositSummary(tempOrder, this.applyDepositAmountToSummary(tempOrder, {
|
|
3071
3123
|
...(0, _utils.createEmptySummary)(),
|
|
3072
3124
|
...previousSummary
|
|
3073
|
-
}, depositAmount);
|
|
3125
|
+
}, depositAmount));
|
|
3074
3126
|
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
3075
3127
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3076
3128
|
const summary = {
|
|
@@ -4018,7 +4070,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4018
4070
|
// 库存/商品券校验与自动预约共用草稿,全部门禁通过后才发布完整批次。
|
|
4019
4071
|
const tempOrder = availabilityCommitGuard && !mutation.commit ? (0, _lodashEs.cloneDeep)(liveTempOrder) : mutation.draft;
|
|
4020
4072
|
const beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
4021
|
-
const guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
4073
|
+
const guardedMutationFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'currency_code', 'currency_symbol', 'currency_format', ...(!booking && Array.isArray(product._extend?.holder_relations) ? ['holder_relations'] : [])];
|
|
4022
4074
|
const readGuardedMutationFields = order => Object.fromEntries(guardedMutationFields.map(key => [key, order[key]]));
|
|
4023
4075
|
const guardedMutationBaseline = availabilityCommitGuard ? (0, _lodashEs.cloneDeep)(readGuardedMutationFields(liveTempOrder)) : null;
|
|
4024
4076
|
const beforePublish = () => {
|
|
@@ -5881,6 +5933,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5881
5933
|
};
|
|
5882
5934
|
const rawSummary = raw.summary && typeof raw.summary === 'object' ? raw.summary : {};
|
|
5883
5935
|
const historicalDepositSnapshot = this.getHistoricalDepositSnapshot(sourceLastOrderInfo);
|
|
5936
|
+
if (historicalDepositSnapshot && this.normalizeDepositFlag(raw.is_deposit) === null) {
|
|
5937
|
+
nextTempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
|
|
5938
|
+
}
|
|
5884
5939
|
const summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(s => ({
|
|
5885
5940
|
...(s || {})
|
|
5886
5941
|
})) : (0, _lodashEs.cloneDeep)(nextTempOrder.surcharges || []);
|
|
@@ -5934,6 +5989,20 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5934
5989
|
createIfMissing: false,
|
|
5935
5990
|
isCurrentOrder: () => this.orderReplacement === replacement
|
|
5936
5991
|
});
|
|
5992
|
+
} else if (!isMergedSalesDetailHydrate && [rawSummary.expect_amount, rawSummary.total_amount].some(amount => amount !== undefined && amount !== null && amount !== '')) {
|
|
5993
|
+
// Keep the remote baseline intact; only normalize the active priced order.
|
|
5994
|
+
const previousSummary = this.store.summary;
|
|
5995
|
+
const summary = this.applyEffectiveDepositSummary(nextTempOrder, previousSummary);
|
|
5996
|
+
summary.amount_gap = this.calculateSummaryAmountGap({
|
|
5997
|
+
tempOrder: nextTempOrder,
|
|
5998
|
+
summary,
|
|
5999
|
+
orderPaidAmount: this.calculatePaidPaymentSummary(nextTempOrder.payments || []).gapPaidAmount
|
|
6000
|
+
});
|
|
6001
|
+
this.store.summary = summary;
|
|
6002
|
+
this.updateTempOrderPaymentStatus(nextTempOrder, {
|
|
6003
|
+
previousSummary,
|
|
6004
|
+
summary
|
|
6005
|
+
});
|
|
5937
6006
|
}
|
|
5938
6007
|
return nextTempOrder;
|
|
5939
6008
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud saved orders with no payment rows report a zero gap, even while unpaid.
|
|
3
|
+
* Restore the OS payment target from the same snapshot, without repricing products.
|
|
4
|
+
* Voided rows are local payment history and are omitted from cloud checkout.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeUnpaidOrderAmountGap<T extends Record<string, any>>(order: T): T;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizeUnpaidOrderAmountGap = normalizeUnpaidOrderAmountGap;
|
|
7
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const UNPAID_STATUSES = new Set(['unpaid', 'payment_pending', 'payment_processing']);
|
|
10
|
+
const CANCELLED_STATUSES = new Set(['cancelled', 'canceled', 'voided']);
|
|
11
|
+
function firstValue(...values) {
|
|
12
|
+
return values.find(value => value != null && String(value).trim() !== '');
|
|
13
|
+
}
|
|
14
|
+
function money(value) {
|
|
15
|
+
if (typeof value !== 'string' && typeof value !== 'number') return undefined;
|
|
16
|
+
try {
|
|
17
|
+
const amount = new _decimal.default(value);
|
|
18
|
+
return amount.isFinite() ? amount : undefined;
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Cloud saved orders with no payment rows report a zero gap, even while unpaid.
|
|
26
|
+
* Restore the OS payment target from the same snapshot, without repricing products.
|
|
27
|
+
* Voided rows are local payment history and are omitted from cloud checkout.
|
|
28
|
+
*/
|
|
29
|
+
function normalizeUnpaidOrderAmountGap(order) {
|
|
30
|
+
const summary = order.summary && typeof order.summary === 'object' && !Array.isArray(order.summary) ? order.summary : {};
|
|
31
|
+
const status = String(firstValue(order.payment_status, summary.payment_status, order.original_payment_status) ?? '').trim().toLowerCase();
|
|
32
|
+
if (!UNPAID_STATUSES.has(status) || CANCELLED_STATUSES.has(String(order.status ?? '').trim().toLowerCase())) return order;
|
|
33
|
+
if (Array.isArray(order.refunds) && order.refunds.length > 0) return order;
|
|
34
|
+
|
|
35
|
+
// An omitted collection is a sparse patch, not proof that the order has no payments.
|
|
36
|
+
if (!Array.isArray(order.payments) || order.payments.some(payment => String(payment?.status ?? '').trim().toLowerCase() !== 'voided')) return order;
|
|
37
|
+
for (const field of ['order_paid_amount', 'customer_paid_amount', 'total_refund_amount', 'paid_amount', 'payment_amount']) {
|
|
38
|
+
const values = [summary[field], order[field]].filter(value => value != null && String(value).trim() !== '');
|
|
39
|
+
if (values.some(value => !money(value)?.isZero())) return order;
|
|
40
|
+
}
|
|
41
|
+
const gapValue = firstValue(summary.amount_gap, order.amount_gap);
|
|
42
|
+
if (gapValue !== undefined && !money(gapValue)?.isZero()) return order;
|
|
43
|
+
const expected = money(firstValue(summary.expect_amount, order.expect_amount, summary.total_amount, order.total_amount));
|
|
44
|
+
if (!expected?.gt(0)) return order;
|
|
45
|
+
let target = expected;
|
|
46
|
+
if (Number(order.is_deposit) === 1) {
|
|
47
|
+
const deposit = money(firstValue(summary.deposit_amount, order.deposit_amount, 0));
|
|
48
|
+
if (!deposit || deposit.lt(0) || deposit.gt(expected)) return order;
|
|
49
|
+
if (deposit.gt(0)) target = deposit;
|
|
50
|
+
}
|
|
51
|
+
const amountGap = target.toFixed(2);
|
|
52
|
+
return {
|
|
53
|
+
...order,
|
|
54
|
+
amount_gap: amountGap,
|
|
55
|
+
summary: {
|
|
56
|
+
...summary,
|
|
57
|
+
amount_gap: amountGap
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "duration" | "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
package/lib/server/index.js
CHANGED
|
@@ -1731,6 +1731,7 @@ class Server {
|
|
|
1731
1731
|
customer_id,
|
|
1732
1732
|
ids,
|
|
1733
1733
|
extension_type,
|
|
1734
|
+
application_code,
|
|
1734
1735
|
strategy_context
|
|
1735
1736
|
} = data;
|
|
1736
1737
|
const {
|
|
@@ -1765,6 +1766,7 @@ class Server {
|
|
|
1765
1766
|
schedule_datetime,
|
|
1766
1767
|
customer_id,
|
|
1767
1768
|
extension_type,
|
|
1769
|
+
application_code,
|
|
1768
1770
|
strategy_context
|
|
1769
1771
|
}
|
|
1770
1772
|
});
|
|
@@ -1780,6 +1782,7 @@ class Server {
|
|
|
1780
1782
|
schedule_datetime,
|
|
1781
1783
|
customer_id,
|
|
1782
1784
|
extension_type,
|
|
1785
|
+
application_code,
|
|
1783
1786
|
strategy_context
|
|
1784
1787
|
});
|
|
1785
1788
|
if (subscriberId && typeof callback === 'function') {
|
|
@@ -1881,6 +1884,7 @@ class Server {
|
|
|
1881
1884
|
schedule_date,
|
|
1882
1885
|
schedule_datetime: scheduleDatetime,
|
|
1883
1886
|
product_id: productId,
|
|
1887
|
+
application_code: data?.application_code ?? this.extractQueryParam(url || '', 'application_code') ?? undefined,
|
|
1884
1888
|
...(data && typeof data === 'object' ? {
|
|
1885
1889
|
customer_id: data.customer_id,
|
|
1886
1890
|
strategy_context: data.strategy_context
|
|
@@ -3515,8 +3519,13 @@ class Server {
|
|
|
3515
3519
|
}
|
|
3516
3520
|
getSmallTicketShopInfo() {
|
|
3517
3521
|
const shopInfo = this.getAppData('shop_info') || {};
|
|
3522
|
+
// WebPOS getData does not expose core/default_domain; read the business
|
|
3523
|
+
// shop model directly when the expanded shop_info has not loaded it yet.
|
|
3524
|
+
const shopCore = this.app?.models?.getStore?.().getDataByModel?.('core', 'core') || this.app?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || {};
|
|
3518
3525
|
return {
|
|
3519
3526
|
...shopInfo,
|
|
3527
|
+
default_domain: shopInfo.default_domain || shopCore.default_domain,
|
|
3528
|
+
private_domain_protocol: shopInfo.private_domain_protocol || shopCore.private_domain_protocol,
|
|
3520
3529
|
currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
|
|
3521
3530
|
currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
|
|
3522
3531
|
tax_title: shopInfo.tax_title || this.getAppData('tax_title'),
|
|
@@ -6078,8 +6087,11 @@ class Server {
|
|
|
6078
6087
|
customer_id,
|
|
6079
6088
|
extension_type,
|
|
6080
6089
|
product_id,
|
|
6090
|
+
application_code,
|
|
6081
6091
|
strategy_context
|
|
6082
6092
|
} = context;
|
|
6093
|
+
// 仅 Kiosk 查询额外按商品销售渠道过滤。
|
|
6094
|
+
const isVisibleProduct = product => (product?.status || 'published') === 'published' && (application_code !== 'kiosk' || Array.isArray(product?.channel_application) && product.channel_application.includes('kiosk'));
|
|
6083
6095
|
const queryIds = Array.isArray(ids) ? ids.map(id => Number(id)).filter(id => Number.isFinite(id)) : [];
|
|
6084
6096
|
this.logInfo('computeProductQueryResult 开始', {
|
|
6085
6097
|
menuListIdsCount: menu_list_ids?.length ?? 0,
|
|
@@ -6127,7 +6139,7 @@ class Server {
|
|
|
6127
6139
|
count: productsWithPrice.length,
|
|
6128
6140
|
ids: uniqueIds
|
|
6129
6141
|
});
|
|
6130
|
-
const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(
|
|
6142
|
+
const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(isVisibleProduct);
|
|
6131
6143
|
const extensionFilteredProducts = this.filterProductsByExtensionTypes(filteredProducts, extension_type);
|
|
6132
6144
|
(0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
|
|
6133
6145
|
mode: 'ids',
|
|
@@ -6157,7 +6169,7 @@ class Server {
|
|
|
6157
6169
|
count: allProductsWithPrice.length,
|
|
6158
6170
|
productId: pid
|
|
6159
6171
|
});
|
|
6160
|
-
const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(
|
|
6172
|
+
const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(isVisibleProduct), extension_type);
|
|
6161
6173
|
const item = published.find(p => Number(p.id) === pid) ?? null;
|
|
6162
6174
|
(0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
|
|
6163
6175
|
mode: 'single',
|
|
@@ -6186,7 +6198,7 @@ class Server {
|
|
|
6186
6198
|
});
|
|
6187
6199
|
const tStatus = performance.now();
|
|
6188
6200
|
const beforeStatusCount = filteredProducts.length;
|
|
6189
|
-
filteredProducts = filteredProducts.filter(
|
|
6201
|
+
filteredProducts = filteredProducts.filter(isVisibleProduct);
|
|
6190
6202
|
(0, _product.perfMark)('computeQuery.filterByStatus(extensionType)', performance.now() - tStatus, {
|
|
6191
6203
|
before: beforeStatusCount,
|
|
6192
6204
|
after: filteredProducts.length
|
|
@@ -6269,7 +6281,7 @@ class Server {
|
|
|
6269
6281
|
});
|
|
6270
6282
|
const tStatus = performance.now();
|
|
6271
6283
|
const beforeStatusCount = filteredProducts.length;
|
|
6272
|
-
filteredProducts = filteredProducts.filter(
|
|
6284
|
+
filteredProducts = filteredProducts.filter(isVisibleProduct);
|
|
6273
6285
|
(0, _product.perfMark)('computeQuery.filterByStatus', performance.now() - tStatus, {
|
|
6274
6286
|
before: beforeStatusCount,
|
|
6275
6287
|
after: filteredProducts.length
|
|
@@ -8,6 +8,7 @@ var _lodashEs = require("lodash-es");
|
|
|
8
8
|
var _localEftposState = require("../../../modules/Order/localEftposState");
|
|
9
9
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
10
|
var _BaseModule = require("../../../modules/BaseModule");
|
|
11
|
+
var _unpaidAmountGap = require("../../../modules/Order/unpaidAmountGap");
|
|
11
12
|
var _orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
|
|
12
13
|
var _types = require("./types");
|
|
13
14
|
var _paymentUtils = require("../../../modules/Order/payment-utils");
|
|
@@ -251,7 +252,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
251
252
|
this.logInfo('订单子项身份已规范化', context);
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
|
-
return result.order;
|
|
255
|
+
return (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(result.order);
|
|
255
256
|
}
|
|
256
257
|
|
|
257
258
|
/**
|
|
@@ -15,6 +15,9 @@ export interface SmallTicketShopInfo {
|
|
|
15
15
|
currency_code?: string;
|
|
16
16
|
primary_locale?: string;
|
|
17
17
|
timezone?: string;
|
|
18
|
+
/** Customer-facing shop domain, supplied by the host shop context. */
|
|
19
|
+
default_domain?: string;
|
|
20
|
+
private_domain_protocol?: string;
|
|
18
21
|
[key: string]: any;
|
|
19
22
|
}
|
|
20
23
|
export interface BuildSmallTicketDataParams {
|
|
@@ -7,6 +7,7 @@ exports.buildSmallTicketData = buildSmallTicketData;
|
|
|
7
7
|
exports.hasSmallTicketData = hasSmallTicketData;
|
|
8
8
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
9
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
|
+
var _unpaidAmountGap = require("../../modules/Order/unpaidAmountGap");
|
|
10
11
|
var _holderRelations = require("../../modules/Order/holderRelations");
|
|
11
12
|
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
12
13
|
var _templateVisibility = require("./templateVisibility");
|
|
@@ -300,7 +301,8 @@ const LABELS = {
|
|
|
300
301
|
}
|
|
301
302
|
};
|
|
302
303
|
function buildSmallTicketData(params) {
|
|
303
|
-
const
|
|
304
|
+
const normalizedOrder = (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(params.order || {});
|
|
305
|
+
const order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
|
|
304
306
|
const shopInfo = params.shopInfo || {};
|
|
305
307
|
const locales = resolveLocales(shopInfo, params.locales);
|
|
306
308
|
const productMap = params.productMap || {};
|
|
@@ -393,10 +395,14 @@ function buildBaseData(params) {
|
|
|
393
395
|
financials
|
|
394
396
|
} = params;
|
|
395
397
|
const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
398
|
+
const rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
|
|
396
399
|
return {
|
|
397
400
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
398
401
|
note: stringify(order.note),
|
|
399
402
|
shop_order_number: stringify(order.shop_order_number),
|
|
403
|
+
...(rewardClaim ? {
|
|
404
|
+
reward_claim: rewardClaim
|
|
405
|
+
} : {}),
|
|
400
406
|
order_number: orderNumber,
|
|
401
407
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
402
408
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
@@ -415,6 +421,23 @@ function buildBaseData(params) {
|
|
|
415
421
|
} : {})
|
|
416
422
|
};
|
|
417
423
|
}
|
|
424
|
+
function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
|
|
425
|
+
const domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
|
|
426
|
+
const orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
|
|
427
|
+
if (!domain || !orderNumber) return undefined;
|
|
428
|
+
try {
|
|
429
|
+
const protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
|
|
430
|
+
const base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : `${protocol}://${domain}`);
|
|
431
|
+
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
const url = new URL('/claim-purchase-rewards', base);
|
|
435
|
+
url.searchParams.set('shop_order_number', orderNumber);
|
|
436
|
+
return url.toString();
|
|
437
|
+
} catch {
|
|
438
|
+
return undefined;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
418
441
|
function buildProducts(order, locale, productMap) {
|
|
419
442
|
const products = Array.isArray(order.products) ? order.products : [];
|
|
420
443
|
const allergyByProductUid = buildProductAllergyMap(order, locale);
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"duration" | "
|
|
378
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -485,19 +485,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
485
485
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
486
486
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
487
487
|
*/
|
|
488
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
489
|
-
action: "reloadCatalog";
|
|
490
|
-
} | {
|
|
491
|
-
action: "add";
|
|
492
|
-
cacheItem: any;
|
|
493
|
-
} | {
|
|
494
|
-
action: "requiresDetail";
|
|
495
|
-
payload: AddProductRequiresDetailPayload;
|
|
496
|
-
} | {
|
|
497
|
-
action: "requiresBookingEdit";
|
|
498
|
-
cacheItem: any;
|
|
499
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
500
|
-
};
|
|
488
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
501
489
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
502
490
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
503
491
|
/**
|
|
@@ -130,9 +130,12 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
130
130
|
const task = (async () => {
|
|
131
131
|
const [snapshot, context, template] = await Promise.all([this.loadSource(input), this.loadContext(input), (0, _loadCustomerInvoiceLayout.loadCustomerInvoiceTemplate)(this.request, input)]);
|
|
132
132
|
const source = (0, _loadPaymentMethods.withPaymentMethodNames)(snapshot, context.methods);
|
|
133
|
-
const
|
|
133
|
+
const appPlugin = this.core.getPlugin('app');
|
|
134
|
+
const getData = appPlugin?.getData?.();
|
|
134
135
|
if (getData?.('shop_id') != null && String(getData('shop_id')) !== String(input.shopId)) throw new Error('Invoice shop changed');
|
|
135
136
|
const coreData = getData?.('core');
|
|
137
|
+
const hostApp = appPlugin?.getApp?.();
|
|
138
|
+
const shopCore = hostApp?.models?.getStore?.().getDataByModel?.('core', 'core') || hostApp?.data?.store?.getStore?.().getDataByModel?.('core', 'core') || coreData?.core || coreData || {};
|
|
136
139
|
const shop = {
|
|
137
140
|
...(coreData?.core?.shop || coreData?.shop || {}),
|
|
138
141
|
...(getData?.('shop_info') || {}),
|
|
@@ -142,6 +145,8 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
142
145
|
tax_country_code: getData('tax_country_code')
|
|
143
146
|
} : {})
|
|
144
147
|
};
|
|
148
|
+
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
149
|
+
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
145
150
|
if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
|
|
146
151
|
const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
|
|
147
152
|
const remembered = this.languageSelection?.code;
|
|
@@ -321,6 +321,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
321
321
|
stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
|
|
322
322
|
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
323
323
|
supportsVenueTicketExtras(): boolean;
|
|
324
|
+
/** The venue retail write path accepts per-line Holder relations for both templates. */
|
|
325
|
+
supportsVenueExtraHolders(): boolean;
|
|
324
326
|
/**
|
|
325
327
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
326
328
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|