@pisell/pisellos 2.2.323 → 2.2.324
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +509 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/dist/modules/BookingContext/utils/productExtend.js +122 -29
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/Discount/index.js +1 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/salesSettings.d.ts +32 -0
- package/dist/modules/OpenData/salesSettings.js +80 -0
- package/dist/modules/OpenData/types.d.ts +16 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +54 -11
- package/dist/modules/Order/index.js +2699 -1411
- package/dist/modules/Order/types.d.ts +43 -5
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
- package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +6 -2
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +161 -51
- package/dist/modules/ResourcePlanner/planner.js +58 -2
- package/dist/modules/ResourcePlanner/types.d.ts +13 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +58 -39
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +1312 -1154
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +4 -0
- package/dist/shared/receipt/small-ticket.js +70 -12
- package/dist/solution/BaseSales/index.d.ts +39 -5
- package/dist/solution/BaseSales/index.js +1828 -1462
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +676 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +15 -3
- package/dist/solution/BookingTicket/index.js +249 -135
- package/dist/solution/BookingTicket/types.d.ts +14 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/dist/solution/OrderInvoicePreview/index.js +14 -8
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +166 -67
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/dist/solution/UnifiedBookingSales/index.js +3374 -1177
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.js +6 -0
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +287 -0
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/lib/modules/BookingContext/utils/productExtend.js +96 -7
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/Discount/index.js +1 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/salesSettings.d.ts +32 -0
- package/lib/modules/OpenData/salesSettings.js +70 -0
- package/lib/modules/OpenData/types.d.ts +16 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +54 -11
- package/lib/modules/Order/index.js +659 -80
- package/lib/modules/Order/types.d.ts +43 -5
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
- package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +6 -2
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +74 -0
- package/lib/modules/ResourcePlanner/planner.js +52 -1
- package/lib/modules/ResourcePlanner/types.d.ts +13 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +25 -9
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +124 -16
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +4 -0
- package/lib/shared/receipt/small-ticket.js +63 -8
- package/lib/solution/BaseSales/index.d.ts +39 -5
- package/lib/solution/BaseSales/index.js +212 -18
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +222 -14
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +15 -3
- package/lib/solution/BookingTicket/index.js +47 -4
- package/lib/solution/BookingTicket/types.d.ts +14 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/lib/solution/OrderInvoicePreview/index.js +7 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +72 -2
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/lib/solution/UnifiedBookingSales/index.js +1316 -73
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
- package/lib/utils/platform.d.ts +2 -0
- package/lib/utils/platform.js +7 -0
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
package/lib/server/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var _paymentUtils = require("../modules/Order/payment-utils");
|
|
|
33
33
|
var _salesNotes = require("../modules/Order/salesNotes");
|
|
34
34
|
var _orderCollectionIdentity = require("../modules/Order/utils/orderCollectionIdentity");
|
|
35
35
|
var _osPrivatePayload = require("../utils/os-private-payload");
|
|
36
|
+
var _posReceiptAutoPrint = require("../utils/pos-receipt-auto-print");
|
|
36
37
|
var _OpenData = require("../modules/OpenData");
|
|
37
38
|
var _modules = require("./modules");
|
|
38
39
|
Object.keys(_modules).forEach(function (key) {
|
|
@@ -123,6 +124,7 @@ class Server {
|
|
|
123
124
|
salesSearchSubscribers = new Map();
|
|
124
125
|
deviceTaskActionsRegistered = false;
|
|
125
126
|
localPaymentUpdateQueues = new Map();
|
|
127
|
+
paymentIdentityRefreshes = new Map();
|
|
126
128
|
floorPlanQuerySubscribers = new Map();
|
|
127
129
|
|
|
128
130
|
// 模块注册表 - 定义所有可用的模块配置
|
|
@@ -873,8 +875,52 @@ class Server {
|
|
|
873
875
|
order_id: fresh?.order_id
|
|
874
876
|
});
|
|
875
877
|
}
|
|
878
|
+
if (syncedOrder) {
|
|
879
|
+
// 不占用 sync_sales 的执行超时:慢速补取不能让已成功的 checkout 被再次提交。
|
|
880
|
+
void this.refreshMissingPaymentIds(syncedOrder, title).catch(error => {
|
|
881
|
+
this.logWarning(`${title}: 后台补齐付款 ID 失败`, {
|
|
882
|
+
order_id: syncedOrder?.order_id,
|
|
883
|
+
error: this.getUnknownErrorMessage(error)
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
}
|
|
876
887
|
return syncedOrder;
|
|
877
888
|
}
|
|
889
|
+
hasPaidPaymentWithoutId(order) {
|
|
890
|
+
return (order?.payments || []).some(payment => {
|
|
891
|
+
const paymentId = payment.order_payment_id ?? payment.id;
|
|
892
|
+
return payment.status === 'paid' && (paymentId === undefined || paymentId === null || String(paymentId).trim() === '');
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
async refreshMissingPaymentIds(order, title) {
|
|
896
|
+
if (!this.hasPaidPaymentWithoutId(order) || !(Number(order.order_id) > 0) || Number(order.need_sync || 0) === 1 || Number(order.is_draft_order || 0) === 1) {
|
|
897
|
+
return order;
|
|
898
|
+
}
|
|
899
|
+
const key = String(order.order_id);
|
|
900
|
+
let refresh = this.paymentIdentityRefreshes.get(key);
|
|
901
|
+
if (!refresh) {
|
|
902
|
+
// checkout 已成功,只补取付款身份;补取失败不能让 sync_sales 重试 checkout。
|
|
903
|
+
refresh = this.fetchAndPersistSalesOrderByLookup(key, {
|
|
904
|
+
forceRemote: true
|
|
905
|
+
}, `${title}.paymentIdentityRefresh`, order);
|
|
906
|
+
this.paymentIdentityRefreshes.set(key, refresh);
|
|
907
|
+
}
|
|
908
|
+
try {
|
|
909
|
+
const result = await refresh;
|
|
910
|
+
const refreshedOrder = result.order || this.order?.getLocalOrderFromMemoryByLookup?.(key) || order;
|
|
911
|
+
if (this.hasPaidPaymentWithoutId(refreshedOrder)) {
|
|
912
|
+
this.logWarning(`${title}: 付款 ID 尚未补齐,下次读取详情重试`, {
|
|
913
|
+
order_id: order.order_id,
|
|
914
|
+
code: result.code
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
return refreshedOrder;
|
|
918
|
+
} finally {
|
|
919
|
+
if (this.paymentIdentityRefreshes.get(key) === refresh) {
|
|
920
|
+
this.paymentIdentityRefreshes.delete(key);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
878
924
|
|
|
879
925
|
/**
|
|
880
926
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
@@ -1685,6 +1731,7 @@ class Server {
|
|
|
1685
1731
|
customer_id,
|
|
1686
1732
|
ids,
|
|
1687
1733
|
extension_type,
|
|
1734
|
+
application_code,
|
|
1688
1735
|
strategy_context
|
|
1689
1736
|
} = data;
|
|
1690
1737
|
const {
|
|
@@ -1719,6 +1766,7 @@ class Server {
|
|
|
1719
1766
|
schedule_datetime,
|
|
1720
1767
|
customer_id,
|
|
1721
1768
|
extension_type,
|
|
1769
|
+
application_code,
|
|
1722
1770
|
strategy_context
|
|
1723
1771
|
}
|
|
1724
1772
|
});
|
|
@@ -1734,6 +1782,7 @@ class Server {
|
|
|
1734
1782
|
schedule_datetime,
|
|
1735
1783
|
customer_id,
|
|
1736
1784
|
extension_type,
|
|
1785
|
+
application_code,
|
|
1737
1786
|
strategy_context
|
|
1738
1787
|
});
|
|
1739
1788
|
if (subscriberId && typeof callback === 'function') {
|
|
@@ -1834,7 +1883,12 @@ class Server {
|
|
|
1834
1883
|
return this.computeProductQueryResult({
|
|
1835
1884
|
schedule_date,
|
|
1836
1885
|
schedule_datetime: scheduleDatetime,
|
|
1837
|
-
product_id: productId
|
|
1886
|
+
product_id: productId,
|
|
1887
|
+
application_code: data?.application_code ?? this.extractQueryParam(url || '', 'application_code') ?? undefined,
|
|
1888
|
+
...(data && typeof data === 'object' ? {
|
|
1889
|
+
customer_id: data.customer_id,
|
|
1890
|
+
strategy_context: data.strategy_context
|
|
1891
|
+
} : {})
|
|
1838
1892
|
});
|
|
1839
1893
|
};
|
|
1840
1894
|
|
|
@@ -3465,8 +3519,13 @@ class Server {
|
|
|
3465
3519
|
}
|
|
3466
3520
|
getSmallTicketShopInfo() {
|
|
3467
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') || {};
|
|
3468
3525
|
return {
|
|
3469
3526
|
...shopInfo,
|
|
3527
|
+
default_domain: shopInfo.default_domain || shopCore.default_domain,
|
|
3528
|
+
private_domain_protocol: shopInfo.private_domain_protocol || shopCore.private_domain_protocol,
|
|
3470
3529
|
currency_symbol: shopInfo.currency_symbol || this.getAppData('shop_symbol') || this.getAppData('currency_symbol'),
|
|
3471
3530
|
currency_code: shopInfo.currency_code || this.getAppData('shop_currency_code') || this.getAppData('currency_code'),
|
|
3472
3531
|
tax_title: shopInfo.tax_title || this.getAppData('tax_title'),
|
|
@@ -4319,7 +4378,11 @@ class Server {
|
|
|
4319
4378
|
});
|
|
4320
4379
|
return;
|
|
4321
4380
|
}
|
|
4322
|
-
|
|
4381
|
+
let localOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
4382
|
+
const orderId = data?.order_id ?? data?.orderId;
|
|
4383
|
+
if (!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup)) {
|
|
4384
|
+
localOrder = await this.order.getLocalOrderByLookup(orderId);
|
|
4385
|
+
}
|
|
4323
4386
|
if (!localOrder) {
|
|
4324
4387
|
this.logWarning(`${title}: 本地订单不存在,跳过核销状态更新`, {
|
|
4325
4388
|
lookup,
|
|
@@ -4410,6 +4473,7 @@ class Server {
|
|
|
4410
4473
|
const data = extractedTemplateSettings.data;
|
|
4411
4474
|
const invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
|
|
4412
4475
|
const invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
|
|
4476
|
+
const receiptAutoPrintPaymentStatuses = (0, _posReceiptAutoPrint.normalizePosReceiptAutoPrintPaymentStatuses)(data?.[_posReceiptAutoPrint.OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD]);
|
|
4413
4477
|
this.logInfo(`${title}: 开始处理`, {
|
|
4414
4478
|
backendPath,
|
|
4415
4479
|
order_id: data?.order_id,
|
|
@@ -4422,7 +4486,8 @@ class Server {
|
|
|
4422
4486
|
data,
|
|
4423
4487
|
title,
|
|
4424
4488
|
invoiceLayoutConfig,
|
|
4425
|
-
invoiceTemplateSettings
|
|
4489
|
+
invoiceTemplateSettings,
|
|
4490
|
+
receiptAutoPrintPaymentStatuses
|
|
4426
4491
|
});
|
|
4427
4492
|
}
|
|
4428
4493
|
const normalizedData = await this.normalizeCheckoutSubmitData(data, title);
|
|
@@ -4437,13 +4502,13 @@ class Server {
|
|
|
4437
4502
|
});
|
|
4438
4503
|
if (pendingResult?.status === true) {
|
|
4439
4504
|
const pendingOrder = pendingResult.data;
|
|
4440
|
-
if (pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.
|
|
4505
|
+
if (pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt()) {
|
|
4441
4506
|
try {
|
|
4442
4507
|
await this.dispatchLocalReceiptPrint({
|
|
4443
4508
|
checkoutData,
|
|
4444
4509
|
order: pendingOrder,
|
|
4445
4510
|
response: pendingResult,
|
|
4446
|
-
requireFullyPaid:
|
|
4511
|
+
requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
|
|
4447
4512
|
invoiceLayoutConfig,
|
|
4448
4513
|
invoiceTemplateSettings
|
|
4449
4514
|
});
|
|
@@ -4481,7 +4546,8 @@ class Server {
|
|
|
4481
4546
|
data,
|
|
4482
4547
|
title,
|
|
4483
4548
|
invoiceLayoutConfig,
|
|
4484
|
-
invoiceTemplateSettings
|
|
4549
|
+
invoiceTemplateSettings,
|
|
4550
|
+
receiptAutoPrintPaymentStatuses
|
|
4485
4551
|
} = params;
|
|
4486
4552
|
if (!this.app?.request?.post) {
|
|
4487
4553
|
this.logError(`${title}: sync checkout app.request 不可用`);
|
|
@@ -4512,13 +4578,13 @@ class Server {
|
|
|
4512
4578
|
}
|
|
4513
4579
|
const response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
4514
4580
|
const syncedOrder = syncResult.syncedOrder;
|
|
4515
|
-
if (syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.
|
|
4581
|
+
if (syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt())) {
|
|
4516
4582
|
try {
|
|
4517
4583
|
await this.dispatchLocalReceiptPrint({
|
|
4518
4584
|
checkoutData: syncResult.checkoutData,
|
|
4519
4585
|
order: syncedOrder,
|
|
4520
4586
|
response: syncResult.normalizedResponse,
|
|
4521
|
-
requireFullyPaid:
|
|
4587
|
+
requireFullyPaid: receiptAutoPrintPaymentStatuses === undefined,
|
|
4522
4588
|
invoiceLayoutConfig,
|
|
4523
4589
|
invoiceTemplateSettings
|
|
4524
4590
|
});
|
|
@@ -4738,6 +4804,13 @@ class Server {
|
|
|
4738
4804
|
if (this.core.context?.getPlatform?.() !== 'android') return true;
|
|
4739
4805
|
return this.app?.storage?.getStorage?.(AUTO_PRINT_STORAGE_KEY) !== 'false';
|
|
4740
4806
|
}
|
|
4807
|
+
|
|
4808
|
+
/** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
|
|
4809
|
+
shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
|
|
4810
|
+
if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
|
|
4811
|
+
const paymentStatus = String(order?.payment_status || '').toLowerCase();
|
|
4812
|
+
return statuses.some(status => status === 'paid' ? this.isSalesOrderFullyPaid(order) : paymentStatus === status);
|
|
4813
|
+
}
|
|
4741
4814
|
shouldBuildSmallTicketData(order, invoiceTemplateSettings) {
|
|
4742
4815
|
if (!order || typeof order !== 'object') return false;
|
|
4743
4816
|
const flag = order.small_ticket_data_flag ?? order.smallTicketDataFlag;
|
|
@@ -5096,7 +5169,7 @@ class Server {
|
|
|
5096
5169
|
const code = typeof value === 'number' ? value : Number(value);
|
|
5097
5170
|
return Number.isFinite(code) ? code : 500;
|
|
5098
5171
|
}
|
|
5099
|
-
async fetchAndPersistSalesOrderByLookup(lookup, data, title) {
|
|
5172
|
+
async fetchAndPersistSalesOrderByLookup(lookup, data, title, paymentIdentityOrder) {
|
|
5100
5173
|
if (!this.order?.getLocalOrderByLookup || !this.order?.upsertOrdersFromRemote) {
|
|
5101
5174
|
this.logError(`${title}: Order 模块未注册`);
|
|
5102
5175
|
return {
|
|
@@ -5150,13 +5223,44 @@ class Server {
|
|
|
5150
5223
|
};
|
|
5151
5224
|
}
|
|
5152
5225
|
const localBeforeRefresh = this.order.getLocalOrderFromMemoryByLookup?.(lookup) || (this.shouldForceRemoteSalesDetail(data) ? await this.order.getLocalOrderByLookup(lookup) : null);
|
|
5226
|
+
let orderToPersist = fresh;
|
|
5227
|
+
if (paymentIdentityOrder) {
|
|
5228
|
+
if (String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments)) {
|
|
5229
|
+
throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
|
|
5230
|
+
}
|
|
5231
|
+
// 请求期间可能又产生本地改动,不能用这次补取清除待同步状态。
|
|
5232
|
+
if (!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1) {
|
|
5233
|
+
return {
|
|
5234
|
+
code: 200,
|
|
5235
|
+
message: '',
|
|
5236
|
+
order: localBeforeRefresh || paymentIdentityOrder
|
|
5237
|
+
};
|
|
5238
|
+
}
|
|
5239
|
+
const remotePayments = fresh.payments;
|
|
5240
|
+
const paidPayments = (localBeforeRefresh.payments || []).filter(payment => payment.status === 'paid');
|
|
5241
|
+
const paymentIdsComplete = paidPayments.every(payment => {
|
|
5242
|
+
const localKeys = new Set((0, _paymentUtils.getOrderPaymentIdentityKeys)(payment));
|
|
5243
|
+
const matches = remotePayments.filter(remotePayment => (0, _paymentUtils.getOrderPaymentIdentityKeys)(remotePayment).some(key => localKeys.has(key)));
|
|
5244
|
+
const paymentId = matches[0]?.order_payment_id ?? matches[0]?.id;
|
|
5245
|
+
return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
|
|
5246
|
+
});
|
|
5247
|
+
if (!paymentIdsComplete) {
|
|
5248
|
+
throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
|
|
5249
|
+
}
|
|
5250
|
+
orderToPersist = {
|
|
5251
|
+
...fresh,
|
|
5252
|
+
payments: (0, _paymentUtils.mergeOrderPaymentListsByIdentity)(localBeforeRefresh.payments, remotePayments, {
|
|
5253
|
+
preserveUnmatchedExisting: true
|
|
5254
|
+
})
|
|
5255
|
+
};
|
|
5256
|
+
}
|
|
5153
5257
|
if ((0, _localEftposState.requiresLocalPaymentRefresh)(localBeforeRefresh)) {
|
|
5154
5258
|
if (String(fresh.order_id) !== String(localBeforeRefresh.order_id)) {
|
|
5155
5259
|
throw new Error('远端订单身份不匹配,请重新刷新');
|
|
5156
5260
|
}
|
|
5157
|
-
await this.order.completeLocalPaymentRefresh(
|
|
5261
|
+
await this.order.completeLocalPaymentRefresh(orderToPersist);
|
|
5158
5262
|
} else {
|
|
5159
|
-
await this.order.upsertOrdersFromRemote([
|
|
5263
|
+
await this.order.upsertOrdersFromRemote([orderToPersist]);
|
|
5160
5264
|
}
|
|
5161
5265
|
let savedOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
5162
5266
|
if (!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup)) {
|
|
@@ -5251,7 +5355,8 @@ class Server {
|
|
|
5251
5355
|
if (!this.shouldForceRemoteSalesDetail(data)) {
|
|
5252
5356
|
const localOrder = await this.order.getLocalOrderByLookup(lookup);
|
|
5253
5357
|
if (localOrder) {
|
|
5254
|
-
const
|
|
5358
|
+
const refreshedOrder = await this.refreshMissingPaymentIds(localOrder, 'handleOrderSalesDetail');
|
|
5359
|
+
const enrichedOrder = await this.withSalesDetailProductSnapshots(refreshedOrder);
|
|
5255
5360
|
this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
5256
5361
|
lookup
|
|
5257
5362
|
});
|
|
@@ -5982,8 +6087,11 @@ class Server {
|
|
|
5982
6087
|
customer_id,
|
|
5983
6088
|
extension_type,
|
|
5984
6089
|
product_id,
|
|
6090
|
+
application_code,
|
|
5985
6091
|
strategy_context
|
|
5986
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'));
|
|
5987
6095
|
const queryIds = Array.isArray(ids) ? ids.map(id => Number(id)).filter(id => Number.isFinite(id)) : [];
|
|
5988
6096
|
this.logInfo('computeProductQueryResult 开始', {
|
|
5989
6097
|
menuListIdsCount: menu_list_ids?.length ?? 0,
|
|
@@ -6031,7 +6139,7 @@ class Server {
|
|
|
6031
6139
|
count: productsWithPrice.length,
|
|
6032
6140
|
ids: uniqueIds
|
|
6033
6141
|
});
|
|
6034
|
-
const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(
|
|
6142
|
+
const filteredProducts = productsWithPrice.filter(p => uniqueIds.includes(Number(p?.id))).filter(isVisibleProduct);
|
|
6035
6143
|
const extensionFilteredProducts = this.filterProductsByExtensionTypes(filteredProducts, extension_type);
|
|
6036
6144
|
(0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
|
|
6037
6145
|
mode: 'ids',
|
|
@@ -6061,7 +6169,7 @@ class Server {
|
|
|
6061
6169
|
count: allProductsWithPrice.length,
|
|
6062
6170
|
productId: pid
|
|
6063
6171
|
});
|
|
6064
|
-
const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(
|
|
6172
|
+
const published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(isVisibleProduct), extension_type);
|
|
6065
6173
|
const item = published.find(p => Number(p.id) === pid) ?? null;
|
|
6066
6174
|
(0, _product.perfMark)('computeProductQueryResult', performance.now() - tTotal, {
|
|
6067
6175
|
mode: 'single',
|
|
@@ -6090,7 +6198,7 @@ class Server {
|
|
|
6090
6198
|
});
|
|
6091
6199
|
const tStatus = performance.now();
|
|
6092
6200
|
const beforeStatusCount = filteredProducts.length;
|
|
6093
|
-
filteredProducts = filteredProducts.filter(
|
|
6201
|
+
filteredProducts = filteredProducts.filter(isVisibleProduct);
|
|
6094
6202
|
(0, _product.perfMark)('computeQuery.filterByStatus(extensionType)', performance.now() - tStatus, {
|
|
6095
6203
|
before: beforeStatusCount,
|
|
6096
6204
|
after: filteredProducts.length
|
|
@@ -6173,7 +6281,7 @@ class Server {
|
|
|
6173
6281
|
});
|
|
6174
6282
|
const tStatus = performance.now();
|
|
6175
6283
|
const beforeStatusCount = filteredProducts.length;
|
|
6176
|
-
filteredProducts = filteredProducts.filter(
|
|
6284
|
+
filteredProducts = filteredProducts.filter(isVisibleProduct);
|
|
6177
6285
|
(0, _product.perfMark)('computeQuery.filterByStatus', performance.now() - tStatus, {
|
|
6178
6286
|
before: beforeStatusCount,
|
|
6179
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
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type CustomerInvoiceLanguageCode = 'en' | 'zh_CN' | 'zh_HK' | 'ja' | 'pt' | 'cn_en';
|
|
1
|
+
export type CustomerInvoiceLanguageCode = 'en' | 'zh_CN' | 'zh_HK' | 'ja' | 'pt' | 'cn_en' | 'ja_en';
|
|
2
2
|
export interface CustomerInvoiceLanguageOption {
|
|
3
3
|
code: CustomerInvoiceLanguageCode;
|
|
4
4
|
locales: string[];
|
|
@@ -26,15 +26,17 @@ const aliases = {
|
|
|
26
26
|
pt_br: 'pt',
|
|
27
27
|
pt_pt: 'pt',
|
|
28
28
|
cn_en: 'cn_en',
|
|
29
|
-
en_cn: 'cn_en'
|
|
29
|
+
en_cn: 'cn_en',
|
|
30
|
+
ja_en: 'ja_en'
|
|
30
31
|
};
|
|
31
32
|
function normalizeCustomerInvoiceLanguage(value) {
|
|
32
33
|
return aliases[value.trim().toLowerCase().replace(/-/g, '_')];
|
|
33
34
|
}
|
|
34
35
|
function option(code) {
|
|
36
|
+
const locales = code === 'cn_en' ? ['en', 'zh_CN'] : code === 'ja_en' ? ['ja', 'en'] : [code];
|
|
35
37
|
return {
|
|
36
38
|
code,
|
|
37
|
-
locales
|
|
39
|
+
locales
|
|
38
40
|
};
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -53,6 +55,6 @@ function resolveCustomerInvoiceLanguages(language, pageLocale) {
|
|
|
53
55
|
const normalized = normalizeCustomerInvoiceLanguage(pageLocale);
|
|
54
56
|
// A page locale is a single language, never a bilingual printer mode.
|
|
55
57
|
const requested = pageLocale.toLowerCase().replace(/_/g, '-');
|
|
56
|
-
const fallback = normalized && normalized !== 'cn_en' ? normalized : requested.startsWith('zh-tw') || requested.startsWith('zh-hk') ? 'zh_HK' : requested.startsWith('zh') ? 'zh_CN' : requested.startsWith('ja') ? 'ja' : requested.startsWith('pt') ? 'pt' : 'en';
|
|
58
|
+
const fallback = normalized && normalized !== 'cn_en' && normalized !== 'ja_en' ? normalized : requested.startsWith('zh-tw') || requested.startsWith('zh-hk') ? 'zh_HK' : requested.startsWith('zh') ? 'zh_CN' : requested.startsWith('ja') ? 'ja' : requested.startsWith('pt') ? 'pt' : 'en';
|
|
57
59
|
return [option(fallback)];
|
|
58
60
|
}
|
|
@@ -15,6 +15,10 @@ 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?: string;
|
|
21
|
+
private_domain_protocol?: string;
|
|
18
22
|
[key: string]: any;
|
|
19
23
|
}
|
|
20
24
|
export interface BuildSmallTicketDataParams {
|
|
@@ -7,11 +7,13 @@ 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");
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
const DEFAULT_LOCALES = ['en', 'zh_CN'];
|
|
16
|
+
const BOOKING_ID_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15
17
|
|
|
16
18
|
// Attach provenance to a private copy BEFORE any locale-dependent filtering.
|
|
17
19
|
// Symbols survive the existing spread-based normalization, never enter JSON,
|
|
@@ -84,6 +86,7 @@ const LABELS = {
|
|
|
84
86
|
cashReceived: 'Cash received',
|
|
85
87
|
changeDue: 'Change due',
|
|
86
88
|
eftpos: 'Eftpos',
|
|
89
|
+
creditCard: 'Credit card',
|
|
87
90
|
wallet: 'Wallet',
|
|
88
91
|
giftCard: 'Gift card',
|
|
89
92
|
pointCard: 'Point card',
|
|
@@ -130,6 +133,7 @@ const LABELS = {
|
|
|
130
133
|
cashReceived: '收取现金',
|
|
131
134
|
changeDue: '找零',
|
|
132
135
|
eftpos: '刷卡支付',
|
|
136
|
+
creditCard: '信用卡',
|
|
133
137
|
wallet: '钱包支付',
|
|
134
138
|
giftCard: '礼品卡',
|
|
135
139
|
pointCard: '积分卡',
|
|
@@ -176,6 +180,7 @@ const LABELS = {
|
|
|
176
180
|
cashReceived: '收取現金',
|
|
177
181
|
changeDue: '找零',
|
|
178
182
|
eftpos: '刷卡支付',
|
|
183
|
+
creditCard: '信用卡',
|
|
179
184
|
wallet: '錢包支付',
|
|
180
185
|
giftCard: '禮品卡',
|
|
181
186
|
pointCard: '積分卡',
|
|
@@ -220,6 +225,7 @@ const LABELS = {
|
|
|
220
225
|
asap: 'できるだけ早く',
|
|
221
226
|
cash: '現金',
|
|
222
227
|
eftpos: 'カード',
|
|
228
|
+
creditCard: 'クレジットカード',
|
|
223
229
|
wallet: 'ウォレット',
|
|
224
230
|
giftCard: 'ギフトカード',
|
|
225
231
|
pointCard: 'ポイントカード',
|
|
@@ -265,6 +271,7 @@ const LABELS = {
|
|
|
265
271
|
asap: 'Assim que possível',
|
|
266
272
|
cash: 'Dinheiro',
|
|
267
273
|
eftpos: 'Cartão',
|
|
274
|
+
creditCard: 'Cartão de crédito',
|
|
268
275
|
wallet: 'Carteira',
|
|
269
276
|
giftCard: 'Cartão-presente',
|
|
270
277
|
pointCard: 'Cartão de pontos',
|
|
@@ -294,7 +301,8 @@ const LABELS = {
|
|
|
294
301
|
}
|
|
295
302
|
};
|
|
296
303
|
function buildSmallTicketData(params) {
|
|
297
|
-
const
|
|
304
|
+
const normalizedOrder = (0, _unpaidAmountGap.normalizeUnpaidOrderAmountGap)(params.order || {});
|
|
305
|
+
const order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
|
|
298
306
|
const shopInfo = params.shopInfo || {};
|
|
299
307
|
const locales = resolveLocales(shopInfo, params.locales);
|
|
300
308
|
const productMap = params.productMap || {};
|
|
@@ -387,10 +395,14 @@ function buildBaseData(params) {
|
|
|
387
395
|
financials
|
|
388
396
|
} = params;
|
|
389
397
|
const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
398
|
+
const rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
|
|
390
399
|
return {
|
|
391
400
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
392
401
|
note: stringify(order.note),
|
|
393
402
|
shop_order_number: stringify(order.shop_order_number),
|
|
403
|
+
...(rewardClaim ? {
|
|
404
|
+
reward_claim: rewardClaim
|
|
405
|
+
} : {}),
|
|
394
406
|
order_number: orderNumber,
|
|
395
407
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
396
408
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
@@ -409,6 +421,26 @@ function buildBaseData(params) {
|
|
|
409
421
|
} : {})
|
|
410
422
|
};
|
|
411
423
|
}
|
|
424
|
+
function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
|
|
425
|
+
const default_domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
|
|
426
|
+
const private_domain = typeof shopInfo.private_domain === 'string' ? shopInfo.private_domain.trim() : '';
|
|
427
|
+
// 私有域名优先于默认域名
|
|
428
|
+
const domain = default_domain;
|
|
429
|
+
const orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
|
|
430
|
+
if (!domain || !orderNumber) return undefined;
|
|
431
|
+
try {
|
|
432
|
+
const protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
|
|
433
|
+
const base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : `${protocol}://${domain}`);
|
|
434
|
+
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
const url = new URL('/claim-purchase-rewards', base);
|
|
438
|
+
url.searchParams.set('shop_order_number', orderNumber);
|
|
439
|
+
return url.toString();
|
|
440
|
+
} catch {
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
412
444
|
function buildProducts(order, locale, productMap) {
|
|
413
445
|
const products = Array.isArray(order.products) ? order.products : [];
|
|
414
446
|
const allergyByProductUid = buildProductAllergyMap(order, locale);
|
|
@@ -1190,7 +1222,9 @@ function buildFees(params) {
|
|
|
1190
1222
|
total_amount: formatMoney(firstPresentValue(summary.total_amount, order.total_amount) ?? 0, currencySymbol),
|
|
1191
1223
|
original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
|
|
1192
1224
|
product_expect_amount: formatMoney(productExpectAmount ?? 0, currencySymbol),
|
|
1193
|
-
|
|
1225
|
+
...(isNonZero(itemDiscountAmount) ? {
|
|
1226
|
+
item_discount_amount: formatCalculatedMoney(itemDiscountAmount, currencySymbol)
|
|
1227
|
+
} : {}),
|
|
1194
1228
|
expect_amount: formatMoney(financials.totalAmount, currencySymbol),
|
|
1195
1229
|
product_quantity: toNumber(firstPresentValue(summary.product_quantity, products.reduce((sum, product) => sum + product.product_quantity, 0)), 0),
|
|
1196
1230
|
has_pay: formatMoney(financials.orderPaidAmount, currencySymbol),
|
|
@@ -1384,7 +1418,8 @@ function buildAppointmentRows(params) {
|
|
|
1384
1418
|
return [{
|
|
1385
1419
|
...receiptKey(booking, 'booking-id'),
|
|
1386
1420
|
item: label(locale, 'bookingId'),
|
|
1387
|
-
|
|
1421
|
+
// 异步落单时可能只有内部关联 UUID;留空后由下方过滤移除整行。
|
|
1422
|
+
value: BOOKING_ID_UUID_PATTERN.test(bookingId) ? '' : bookingId,
|
|
1388
1423
|
...association
|
|
1389
1424
|
}, {
|
|
1390
1425
|
...receiptKey(booking, 'booking-time', 'shared'),
|
|
@@ -2434,12 +2469,30 @@ function appendMaskedCardCode(name, code) {
|
|
|
2434
2469
|
function trimDecimal(value) {
|
|
2435
2470
|
return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
|
|
2436
2471
|
}
|
|
2472
|
+
function getLocalizedPaymentName(value, locale) {
|
|
2473
|
+
if (typeof value === 'string') return value.trim();
|
|
2474
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return '';
|
|
2475
|
+
const candidates = [value[locale], value[locale.replace('_', '-')], value[locale.replace('-', '_')], value.original, value.auto, value.default, value.en];
|
|
2476
|
+
for (const candidate of candidates) {
|
|
2477
|
+
if (typeof candidate === 'string' && candidate.trim()) return candidate.trim();
|
|
2478
|
+
}
|
|
2479
|
+
return '';
|
|
2480
|
+
}
|
|
2481
|
+
function getExplicitPaymentName(payment, locale) {
|
|
2482
|
+
// Cloud order snapshots retain the localized name in metadata after reload.
|
|
2483
|
+
const candidates = [payment.name, payment.title, payment.payment_method_name, payment.method_name, payment.metadata?.custom_payment_name];
|
|
2484
|
+
for (const candidate of candidates) {
|
|
2485
|
+
const name = getLocalizedPaymentName(candidate, locale);
|
|
2486
|
+
if (name) return name;
|
|
2487
|
+
}
|
|
2488
|
+
return '';
|
|
2489
|
+
}
|
|
2437
2490
|
function getFundRecordPaymentName(payment, locale) {
|
|
2438
2491
|
const fundRecord = getFundRecord(payment);
|
|
2439
2492
|
if (!fundRecord) return '';
|
|
2440
|
-
const name =
|
|
2493
|
+
const name = getLocalizedPaymentName(fundRecord.wallet_pass_name, locale);
|
|
2441
2494
|
if (!name && !maskMachineCode(fundRecord.code)) return '';
|
|
2442
|
-
const fallbackName =
|
|
2495
|
+
const fallbackName = getExplicitPaymentName(payment, locale) || getLocalizedPaymentName(payment.code, locale);
|
|
2443
2496
|
return appendMaskedCardCode(name || fallbackName, fundRecord.code);
|
|
2444
2497
|
}
|
|
2445
2498
|
function appendMachineCodeToName(name, payment) {
|
|
@@ -2449,13 +2502,15 @@ function appendMachineCodeToName(name, payment) {
|
|
|
2449
2502
|
function paymentMethodName(payment, locale) {
|
|
2450
2503
|
const fundRecordName = getFundRecordPaymentName(payment, locale);
|
|
2451
2504
|
if (fundRecordName) return fundRecordName;
|
|
2452
|
-
const
|
|
2453
|
-
if (
|
|
2505
|
+
const name = getExplicitPaymentName(payment, locale);
|
|
2506
|
+
if (name) return appendMachineCodeToName(name, payment);
|
|
2454
2507
|
const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
|
|
2455
2508
|
if (code.includes('cash')) return label(locale, 'cash');
|
|
2456
|
-
if (code.includes('eftpos')
|
|
2509
|
+
if (code.includes('eftpos')) return label(locale, 'eftpos');
|
|
2457
2510
|
if (code.includes('wallet')) return label(locale, 'wallet');
|
|
2458
2511
|
if (code.includes('gift')) return label(locale, 'giftCard');
|
|
2512
|
+
if (code === 'credit_card' || code.startsWith('credit_card_')) return label(locale, 'creditCard');
|
|
2513
|
+
if (code.includes('card')) return label(locale, 'eftpos');
|
|
2459
2514
|
return stringify(payment.code || payment.type || payment.payment_method || payment.method);
|
|
2460
2515
|
}
|
|
2461
2516
|
function getSummary(order) {
|