@pisell/pisellos 2.3.105 → 2.3.107
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/Discount/index.js +4 -1
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +89 -16
- package/dist/modules/Order/types.d.ts +13 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +57 -3
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +172 -49
- package/dist/modules/ResourcePlanner/types.d.ts +19 -0
- package/dist/modules/Rules/index.js +1 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +1734 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +5 -1
- package/dist/solution/BaseSales/index.js +120 -45
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -3
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +614 -462
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/index.js +4 -1
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +69 -1
- package/lib/modules/Order/types.d.ts +13 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +58 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +141 -35
- package/lib/modules/ResourcePlanner/types.d.ts +19 -0
- package/lib/modules/Rules/index.js +1 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +455 -105
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +5 -1
- package/lib/solution/BaseSales/index.js +84 -7
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -3
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +128 -35
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/package.json +1 -1
|
@@ -4,9 +4,135 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.computeAvailability = computeAvailability;
|
|
7
|
+
exports.getDefaultInvoiceLayoutConfig = getDefaultInvoiceLayoutConfig;
|
|
8
|
+
exports.getDefaultInvoiceTemplateSettings = getDefaultInvoiceTemplateSettings;
|
|
9
|
+
exports.normalizeInvoiceLayoutConfig = normalizeInvoiceLayoutConfig;
|
|
10
|
+
exports.normalizeInvoiceLayoutFromTemplateSettings = normalizeInvoiceLayoutFromTemplateSettings;
|
|
11
|
+
exports.normalizeInvoiceTemplateSettings = normalizeInvoiceTemplateSettings;
|
|
12
|
+
exports.normalizeRawInvoiceTemplateSettings = normalizeRawInvoiceTemplateSettings;
|
|
13
|
+
exports.resolveInvoiceReceiptLocales = resolveInvoiceReceiptLocales;
|
|
7
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
15
|
var _getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
|
|
16
|
+
var _types = require("./types");
|
|
9
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function parseInvoiceRecord(value) {
|
|
22
|
+
let parsed = value;
|
|
23
|
+
if (typeof parsed === 'string') {
|
|
24
|
+
try {
|
|
25
|
+
parsed = JSON.parse(parsed);
|
|
26
|
+
} catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return isRecord(parsed) ? parsed : null;
|
|
31
|
+
}
|
|
32
|
+
function getDefaultInvoiceLayoutConfig() {
|
|
33
|
+
return {
|
|
34
|
+
module: _types.INVOICE_MODULE_KEYS.map(key => ({
|
|
35
|
+
key,
|
|
36
|
+
is_show: 1
|
|
37
|
+
}))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getDefaultInvoiceTemplateSettings() {
|
|
41
|
+
return {
|
|
42
|
+
template: 'DEFAULT',
|
|
43
|
+
language: {},
|
|
44
|
+
modules: []
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const INVOICE_RECEIPT_LOCALE_ORDER = ['en', 'zh_CN', 'zh_HK', 'ja', 'pt'];
|
|
48
|
+
const INVOICE_RECEIPT_LOCALE_MAPPING = {
|
|
49
|
+
en: ['en'],
|
|
50
|
+
zh_cn: ['zh_CN'],
|
|
51
|
+
zh_hk: ['zh_HK'],
|
|
52
|
+
ja: ['ja'],
|
|
53
|
+
pt: ['pt'],
|
|
54
|
+
cn_en: ['en', 'zh_CN']
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 将非 DEFAULT Invoice 模板启用的语言转换为 small_ticket_data locale。
|
|
59
|
+
* cn_en 是中英组合打印模式,因此展开为 en 与 zh_CN 两份数据。
|
|
60
|
+
*/
|
|
61
|
+
function resolveInvoiceReceiptLocales(settings) {
|
|
62
|
+
if (typeof settings?.template !== 'string' || settings.template.trim().length === 0 || settings.template.trim().toUpperCase() === 'DEFAULT' || !isRecord(settings.language)) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const enabledLocales = new Set();
|
|
66
|
+
Object.entries(settings.language).forEach(([rawKey, count]) => {
|
|
67
|
+
if (typeof count !== 'number' || !Number.isFinite(count) || count <= 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const key = rawKey.trim().toLowerCase().replace(/-/g, '_');
|
|
71
|
+
INVOICE_RECEIPT_LOCALE_MAPPING[key]?.forEach(locale => {
|
|
72
|
+
enabledLocales.add(locale);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
return INVOICE_RECEIPT_LOCALE_ORDER.filter(locale => enabledLocales.has(locale));
|
|
76
|
+
}
|
|
77
|
+
function normalizeInvoiceTemplate(value) {
|
|
78
|
+
if (typeof value !== 'string' || value.trim().length === 0) return 'DEFAULT';
|
|
79
|
+
return value.trim().toUpperCase() === 'DEFAULT' ? 'DEFAULT' : value;
|
|
80
|
+
}
|
|
81
|
+
function normalizeInvoiceLanguage(value) {
|
|
82
|
+
if (!isRecord(value)) return {};
|
|
83
|
+
if (Object.values(value).some(item => typeof item !== 'number')) return {};
|
|
84
|
+
return {
|
|
85
|
+
...value
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function normalizeInvoiceModules(value) {
|
|
89
|
+
if (!Array.isArray(value)) return [];
|
|
90
|
+
if (value.some(item => !isRecord(item) || typeof item.key !== 'string')) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
return value.map(item => ({
|
|
94
|
+
...item
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 规范化已经提取出的公开 template_settings 值,供打印入口复用。
|
|
100
|
+
*/
|
|
101
|
+
function normalizeRawInvoiceTemplateSettings(value) {
|
|
102
|
+
const parsed = parseInvoiceRecord(value);
|
|
103
|
+
if (!parsed) return getDefaultInvoiceTemplateSettings();
|
|
104
|
+
return {
|
|
105
|
+
...parsed,
|
|
106
|
+
template: normalizeInvoiceTemplate(parsed.template),
|
|
107
|
+
language: normalizeInvoiceLanguage(parsed.language),
|
|
108
|
+
modules: normalizeInvoiceModules(parsed.modules)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 从 OpenData Documents section 的两个扁平字段中构造 Native Invoice 配置。
|
|
114
|
+
*/
|
|
115
|
+
function normalizeInvoiceTemplateSettings(config) {
|
|
116
|
+
const parsedEdit = parseInvoiceRecord(config?.['documents.invoice_edit']);
|
|
117
|
+
return normalizeRawInvoiceTemplateSettings({
|
|
118
|
+
...(parsedEdit ?? {}),
|
|
119
|
+
template: normalizeInvoiceTemplate(config?.['documents.invoice_template'])
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function normalizeInvoiceLayoutFromTemplateSettings(settings) {
|
|
123
|
+
const modules = normalizeRawInvoiceTemplateSettings(settings).modules;
|
|
124
|
+
if (modules.length === 0) return getDefaultInvoiceLayoutConfig();
|
|
125
|
+
return {
|
|
126
|
+
module: modules
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 将 invoice_edit.modules 原样投影为 Web Invoice 使用的 module 字段。
|
|
132
|
+
*/
|
|
133
|
+
function normalizeInvoiceLayoutConfig(config) {
|
|
134
|
+
return normalizeInvoiceLayoutFromTemplateSettings(normalizeInvoiceTemplateSettings(config));
|
|
135
|
+
}
|
|
10
136
|
function toBoolean(value) {
|
|
11
137
|
if (typeof value === 'boolean') return value;
|
|
12
138
|
if (typeof value === 'string') return value === 'true' || value === '1';
|
|
@@ -176,6 +176,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
176
176
|
consumeSessionStorageRestore(): Record<string, any> | null;
|
|
177
177
|
notifyTempOrderChanged(): void;
|
|
178
178
|
private createDefaultTempOrderInstance;
|
|
179
|
+
private clearTempOrderPointCardSnapshot;
|
|
180
|
+
private writePointCardSnapshotFromPrepareConfig;
|
|
179
181
|
private createExternalSaleNumber;
|
|
180
182
|
private ensureExternalSaleNumber;
|
|
181
183
|
private ensureRequestUniqueIdempotencyToken;
|
|
@@ -632,4 +634,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
632
634
|
getOrderInfo(order_id: number): Promise<any>;
|
|
633
635
|
getVouchers(): any[];
|
|
634
636
|
}
|
|
635
|
-
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
637
|
+
export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
@@ -72,6 +72,13 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
72
72
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
73
73
|
return `${String(payment.voucher_id)}::${String(payment.status || '')}`;
|
|
74
74
|
}
|
|
75
|
+
function hasPersistedOrderId(orderId) {
|
|
76
|
+
if (orderId === undefined || orderId === null || orderId === '') return false;
|
|
77
|
+
if (typeof orderId === 'string' && orderId.startsWith('LOCAL_')) return false;
|
|
78
|
+
const normalizedOrderId = Number(orderId);
|
|
79
|
+
if (Number.isFinite(normalizedOrderId)) return normalizedOrderId > 0;
|
|
80
|
+
return String(orderId).trim() !== '';
|
|
81
|
+
}
|
|
75
82
|
class OrderModule extends _BaseModule.BaseModule {
|
|
76
83
|
defaultName = 'order';
|
|
77
84
|
defaultVersion = '1.0.0';
|
|
@@ -473,6 +480,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
473
480
|
const discountList = prepareConfigResult?.discountList;
|
|
474
481
|
this.store.availableWalletIds = prepareConfigResult?.availableWalletIds || [];
|
|
475
482
|
this.store.virtualCurrencyList = prepareConfigResult?.virtualCurrencyList || [];
|
|
483
|
+
if (prepareConfigResult) {
|
|
484
|
+
this.writePointCardSnapshotFromPrepareConfig({
|
|
485
|
+
orderId,
|
|
486
|
+
customerId: params.customerId,
|
|
487
|
+
availableWalletPassList: prepareConfigResult.availableWalletPassList || []
|
|
488
|
+
});
|
|
489
|
+
}
|
|
476
490
|
if (discountList) {
|
|
477
491
|
const currentDiscountList = this.store.discount?.getDiscountList() || [];
|
|
478
492
|
const currentEditDiscounts = currentDiscountList.filter(discount => discount?.isEditMode);
|
|
@@ -991,6 +1005,32 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
991
1005
|
now: (0, _utils.formatDateTime)(new Date())
|
|
992
1006
|
});
|
|
993
1007
|
}
|
|
1008
|
+
clearTempOrderPointCardSnapshot(tempOrder) {
|
|
1009
|
+
const orderMetaList = (0, _utils.normalizeOrderMetaList)(tempOrder.order_meta_list);
|
|
1010
|
+
if (!orderMetaList) return;
|
|
1011
|
+
const nextOrderMetaList = {
|
|
1012
|
+
...orderMetaList
|
|
1013
|
+
};
|
|
1014
|
+
delete nextOrderMetaList.point_cards_snapshot;
|
|
1015
|
+
if (Object.keys(nextOrderMetaList).length === 0) {
|
|
1016
|
+
delete tempOrder.order_meta_list;
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
tempOrder.order_meta_list = nextOrderMetaList;
|
|
1020
|
+
}
|
|
1021
|
+
writePointCardSnapshotFromPrepareConfig(params) {
|
|
1022
|
+
const tempOrder = this.store.tempOrder;
|
|
1023
|
+
if (!tempOrder) return;
|
|
1024
|
+
if (String(tempOrder.customer_id ?? '') !== String(params.customerId)) return;
|
|
1025
|
+
const effectiveOrderId = params.orderId ?? tempOrder.order_id;
|
|
1026
|
+
if (hasPersistedOrderId(effectiveOrderId)) return;
|
|
1027
|
+
tempOrder.order_meta_list = {
|
|
1028
|
+
...((0, _utils.normalizeOrderMetaList)(tempOrder.order_meta_list) || {}),
|
|
1029
|
+
point_cards_snapshot: (0, _utils.buildPointCardSnapshotFromWalletPassList)(params.availableWalletPassList)
|
|
1030
|
+
};
|
|
1031
|
+
this.persistTempOrder();
|
|
1032
|
+
this.saveDraftInBackground();
|
|
1033
|
+
}
|
|
994
1034
|
createExternalSaleNumber() {
|
|
995
1035
|
const timestamp = (0, _dayjs.default)().format('YYYYMMDDHHmmssSSS');
|
|
996
1036
|
const random6 = String(Math.floor(Math.random() * 1000000)).padStart(6, '0');
|
|
@@ -2659,6 +2699,10 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2659
2699
|
email: tempOrder.email
|
|
2660
2700
|
});
|
|
2661
2701
|
const nextCustomerId = tempOrder.customer_id ?? null;
|
|
2702
|
+
if (String(previousCustomerId ?? '') !== String(nextCustomerId ?? '') && !hasPersistedOrderId(tempOrder.order_id)) {
|
|
2703
|
+
this.store.availableWalletIds = [];
|
|
2704
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2705
|
+
}
|
|
2662
2706
|
this.persistTempOrder();
|
|
2663
2707
|
return {
|
|
2664
2708
|
customerId: tempOrder.customer_id,
|
|
@@ -2695,6 +2739,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2695
2739
|
if (String(previousCustomerId ?? '') !== String(nextCustomerId ?? '')) {
|
|
2696
2740
|
this.store.availableWalletIds = [];
|
|
2697
2741
|
this.store.virtualCurrencyList = [];
|
|
2742
|
+
if (!hasPersistedOrderId(tempOrder.order_id)) {
|
|
2743
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2744
|
+
}
|
|
2698
2745
|
(0, _utils.clearTempOrderHolderAssignments)(tempOrder);
|
|
2699
2746
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2700
2747
|
this.applyDiscount();
|
|
@@ -2734,6 +2781,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2734
2781
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
2735
2782
|
this.store.availableWalletIds = [];
|
|
2736
2783
|
this.store.virtualCurrencyList = [];
|
|
2784
|
+
if (!hasPersistedOrderId(tempOrder.order_id)) {
|
|
2785
|
+
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
2786
|
+
}
|
|
2737
2787
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
2738
2788
|
this.applyDiscount();
|
|
2739
2789
|
this.persistTempOrder();
|
|
@@ -4666,7 +4716,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4666
4716
|
params.forceRemote = false;
|
|
4667
4717
|
}
|
|
4668
4718
|
const res = await this.request.get(`/order/sales/${encodeURIComponent(lookup)}`, {
|
|
4669
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes'],
|
|
4719
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'order_meta_list', 'refunds', 'notes'],
|
|
4670
4720
|
...(params.forceRemote ? {
|
|
4671
4721
|
forceRemote: true
|
|
4672
4722
|
} : {})
|
|
@@ -4965,6 +5015,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4965
5015
|
nextTempOrder.contacts_info = raw.contacts_info && typeof raw.contacts_info === 'object' && !Array.isArray(raw.contacts_info) ? {
|
|
4966
5016
|
...raw.contacts_info
|
|
4967
5017
|
} : null;
|
|
5018
|
+
nextTempOrder.order_meta_list = (0, _utils.normalizeOrderMetaList)(raw.order_meta_list);
|
|
4968
5019
|
nextTempOrder._extend = raw._extend && typeof raw._extend === 'object' ? {
|
|
4969
5020
|
...raw._extend,
|
|
4970
5021
|
productsByUid: raw._extend.productsByUid || {}
|
|
@@ -5122,6 +5173,23 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5122
5173
|
row.metadata.booking_uid = row.booking_uid;
|
|
5123
5174
|
}
|
|
5124
5175
|
row = (0, _bundleDiscountHydration.restoreHydratedBundleDiscounts)(row, _utils.normalizeOrderProductDiscountList);
|
|
5176
|
+
const rawOriginalPrice = Number(row.original_price);
|
|
5177
|
+
const rawSellingPrice = Number(row.selling_price);
|
|
5178
|
+
const hasProductDiscounts = Array.isArray(row.discount_list) && row.discount_list.length > 0;
|
|
5179
|
+
const hasBundleDiscounts = row.product_bundle.some(bundle => Array.isArray(bundle?.discount_list) && bundle.discount_list.length > 0);
|
|
5180
|
+
const isUndiscountedV2Line = String(row.metadata.price_schema_version) === '2' && Number.isFinite(rawOriginalPrice) && Number.isFinite(rawSellingPrice) && new _decimal.default(rawOriginalPrice).eq(rawSellingPrice) && !hasProductDiscounts && !hasBundleDiscounts;
|
|
5181
|
+
if (isUndiscountedV2Line) {
|
|
5182
|
+
const hasPriceValue = value => value !== undefined && value !== null && value !== '';
|
|
5183
|
+
row.product_bundle = row.product_bundle.map(bundle => {
|
|
5184
|
+
if (!bundle || (0, _utils.isMarkdownBundle)(bundle) || hasPriceValue(bundle.original_price) || hasPriceValue(bundle.product_price) || !hasPriceValue(bundle.bundle_selling_price)) {
|
|
5185
|
+
return bundle;
|
|
5186
|
+
}
|
|
5187
|
+
return {
|
|
5188
|
+
...bundle,
|
|
5189
|
+
original_price: bundle.bundle_selling_price
|
|
5190
|
+
};
|
|
5191
|
+
});
|
|
5192
|
+
}
|
|
5125
5193
|
const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
5126
5194
|
if (!existingIdentity) {
|
|
5127
5195
|
row.metadata.unique_identification_number = (0, _utils.createUuidV4)();
|
|
@@ -195,6 +195,17 @@ export interface OrderProductSku {
|
|
|
195
195
|
export interface OrderLocalizedText {
|
|
196
196
|
[locale: string]: string | null;
|
|
197
197
|
}
|
|
198
|
+
export interface PointCardSnapshotItem {
|
|
199
|
+
id: number | string;
|
|
200
|
+
tag: 'point_card';
|
|
201
|
+
product_id?: number | string;
|
|
202
|
+
product_name: string;
|
|
203
|
+
par_value: string;
|
|
204
|
+
used_par_value: string;
|
|
205
|
+
}
|
|
206
|
+
export interface OrderMetaList {
|
|
207
|
+
point_cards_snapshot?: PointCardSnapshotItem[];
|
|
208
|
+
}
|
|
198
209
|
export interface OrderProduct extends OrderProductIdentity {
|
|
199
210
|
order_detail_id: number | null;
|
|
200
211
|
num: number;
|
|
@@ -361,6 +372,7 @@ export interface OrderTempOrder {
|
|
|
361
372
|
contacts: any[];
|
|
362
373
|
contacts_info: Record<string, any> | null;
|
|
363
374
|
holder: Record<string, any> | null;
|
|
375
|
+
order_meta_list?: OrderMetaList;
|
|
364
376
|
metadata: Record<string, any>;
|
|
365
377
|
summary?: OrderSummary;
|
|
366
378
|
_extend?: {
|
|
@@ -566,6 +578,7 @@ export interface SubmitSalesOrderParams {
|
|
|
566
578
|
contacts: any[];
|
|
567
579
|
contacts_info: Record<string, any> | null;
|
|
568
580
|
holder: Record<string, any> | null;
|
|
581
|
+
order_meta_list?: OrderMetaList;
|
|
569
582
|
metadata: Record<string, any>;
|
|
570
583
|
summary?: OrderSummary;
|
|
571
584
|
small_ticket_data_flag?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import type { CartItem } from "../Cart";
|
|
3
|
-
import type { OrderProductDiscountItem, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder } from './types';
|
|
3
|
+
import type { OrderProductDiscountItem, OrderMetaList, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder, PointCardSnapshotItem } from './types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
5
|
import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
|
|
6
6
|
import { createUuidV4 } from './utils/orderCollectionIdentity';
|
|
@@ -16,6 +16,9 @@ export interface OrderProductsDepositSummary {
|
|
|
16
16
|
hasDeposit: boolean;
|
|
17
17
|
}
|
|
18
18
|
import type { WindowPlugin } from '../../plugins';
|
|
19
|
+
export declare function normalizePointCardSnapshotItem(value: unknown): PointCardSnapshotItem | null;
|
|
20
|
+
export declare function buildPointCardSnapshotFromWalletPassList(value: unknown): PointCardSnapshotItem[];
|
|
21
|
+
export declare function normalizeOrderMetaList(value: unknown): OrderMetaList | undefined;
|
|
19
22
|
/**
|
|
20
23
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
21
24
|
*
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "buildManualProductDiscountItem", {
|
|
|
9
9
|
return _manualProductDiscount.buildManualProductDiscountItem;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
exports.buildPointCardSnapshotFromWalletPassList = buildPointCardSnapshotFromWalletPassList;
|
|
12
13
|
exports.buildSubmitPayload = buildSubmitPayload;
|
|
13
14
|
exports.calculateOrderProductsDeposit = calculateOrderProductsDeposit;
|
|
14
15
|
exports.clearTempOrderHolderAssignments = clearTempOrderHolderAssignments;
|
|
@@ -67,7 +68,9 @@ exports.mergeOrderProductDisplayFields = mergeOrderProductDisplayFields;
|
|
|
67
68
|
exports.mergeRelationForms = void 0;
|
|
68
69
|
exports.normalizeBookingIsAll = normalizeBookingIsAll;
|
|
69
70
|
exports.normalizeBookingSubType = normalizeBookingSubType;
|
|
71
|
+
exports.normalizeOrderMetaList = normalizeOrderMetaList;
|
|
70
72
|
exports.normalizeOrderProductDiscountList = normalizeOrderProductDiscountList;
|
|
73
|
+
exports.normalizePointCardSnapshotItem = normalizePointCardSnapshotItem;
|
|
71
74
|
exports.normalizeProductSkuOptions = normalizeProductSkuOptions;
|
|
72
75
|
exports.normalizeSubmitBooking = normalizeSubmitBooking;
|
|
73
76
|
exports.normalizeSubmitCollectPaxValue = normalizeSubmitCollectPaxValue;
|
|
@@ -129,6 +132,55 @@ var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
|
129
132
|
var _salesNotes = require("./salesNotes");
|
|
130
133
|
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
131
134
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
135
|
+
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
136
|
+
function isPlainObject(value) {
|
|
137
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
138
|
+
}
|
|
139
|
+
function normalizeSnapshotScalar(value) {
|
|
140
|
+
if (value === undefined || value === null) return undefined;
|
|
141
|
+
if (typeof value === 'string') return value.trim() ? value : undefined;
|
|
142
|
+
if (typeof value === 'number') return Number.isFinite(value) ? value : undefined;
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
function normalizePointCardSnapshotItem(value) {
|
|
146
|
+
if (!isPlainObject(value)) return null;
|
|
147
|
+
const id = normalizeSnapshotScalar(value.id);
|
|
148
|
+
if (id === undefined) return null;
|
|
149
|
+
if (String(value.tag || '').trim().toLowerCase() !== POINT_CARD_SNAPSHOT_TAG) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const snapshot = {
|
|
153
|
+
id,
|
|
154
|
+
tag: 'point_card',
|
|
155
|
+
product_name: String(value.product_name ?? ''),
|
|
156
|
+
par_value: String(value.par_value ?? ''),
|
|
157
|
+
used_par_value: String(value.used_par_value ?? '')
|
|
158
|
+
};
|
|
159
|
+
const productId = normalizeSnapshotScalar(value.product_id);
|
|
160
|
+
if (productId !== undefined) {
|
|
161
|
+
snapshot.product_id = productId;
|
|
162
|
+
}
|
|
163
|
+
return snapshot;
|
|
164
|
+
}
|
|
165
|
+
function buildPointCardSnapshotFromWalletPassList(value) {
|
|
166
|
+
if (!Array.isArray(value)) return [];
|
|
167
|
+
return value.reduce((result, item) => {
|
|
168
|
+
const normalized = normalizePointCardSnapshotItem(item);
|
|
169
|
+
if (normalized) result.push(normalized);
|
|
170
|
+
return result;
|
|
171
|
+
}, []);
|
|
172
|
+
}
|
|
173
|
+
function normalizeOrderMetaList(value) {
|
|
174
|
+
if (value === undefined) return undefined;
|
|
175
|
+
if (!isPlainObject(value)) return undefined;
|
|
176
|
+
const normalized = {};
|
|
177
|
+
if (Object.prototype.hasOwnProperty.call(value, 'point_cards_snapshot')) {
|
|
178
|
+
normalized.point_cards_snapshot = buildPointCardSnapshotFromWalletPassList(value.point_cards_snapshot);
|
|
179
|
+
}
|
|
180
|
+
if (Object.keys(normalized).length > 0) return normalized;
|
|
181
|
+
return {};
|
|
182
|
+
}
|
|
183
|
+
|
|
132
184
|
/**
|
|
133
185
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
134
186
|
*
|
|
@@ -1248,6 +1300,7 @@ function buildSubmitPayload(params) {
|
|
|
1248
1300
|
start_time: _startTime,
|
|
1249
1301
|
customer: _customer,
|
|
1250
1302
|
discount_list: _discountList,
|
|
1303
|
+
order_meta_list: _orderMetaList,
|
|
1251
1304
|
tax_fee: _rootTaxFee,
|
|
1252
1305
|
total_amount: _totalAmount,
|
|
1253
1306
|
total_refund_amount: _totalRefundAmount,
|
|
@@ -1258,6 +1311,7 @@ function buildSubmitPayload(params) {
|
|
|
1258
1311
|
...tempOrderRest
|
|
1259
1312
|
} = tempOrder;
|
|
1260
1313
|
const resolvedBusinessCode = businessCode ?? tempOrder.business_code;
|
|
1314
|
+
const normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1261
1315
|
const submitType = resolveSubmitOrderType({
|
|
1262
1316
|
requestedType: type,
|
|
1263
1317
|
tempOrderType: tempOrder.type,
|
|
@@ -1324,7 +1378,10 @@ function buildSubmitPayload(params) {
|
|
|
1324
1378
|
} : {}),
|
|
1325
1379
|
products: (tempOrder.products || []).map(product => normalizeSubmitProduct(product, {
|
|
1326
1380
|
virtualSettlementMode
|
|
1327
|
-
}))
|
|
1381
|
+
})),
|
|
1382
|
+
...(normalizedOrderMetaList !== undefined ? {
|
|
1383
|
+
order_meta_list: normalizedOrderMetaList
|
|
1384
|
+
} : {})
|
|
1328
1385
|
};
|
|
1329
1386
|
if (!enhance) return payload;
|
|
1330
1387
|
const enhancedPayload = enhance(payload, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, GetProductTimeRangesRuntimeOptions, ProductTimeRangeGroup } from './types';
|
|
2
2
|
export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
|
|
3
3
|
export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest, runtimeOptions?: GetProductTimeRangesRuntimeOptions): ProductTimeRangeGroup[];
|
|
4
|
-
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery): AvailabilityQueryResult;
|
|
5
|
-
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams): AvailabilitySelectionValidationResult;
|
|
4
|
+
export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilityQueryResult;
|
|
5
|
+
export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilitySelectionValidationResult;
|