@pisell/pisellos 2.3.6 → 2.3.8
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/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +18 -2
- package/dist/modules/Order/index.js +392 -222
- package/dist/modules/Order/types.d.ts +15 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +114 -28
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +8 -3
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.d.ts +8 -1
- package/dist/solution/BaseSales/index.js +145 -104
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +18 -2
- package/lib/modules/Order/index.js +229 -40
- package/lib/modules/Order/types.d.ts +15 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +84 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.d.ts +8 -1
- package/lib/solution/BaseSales/index.js +58 -22
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -491,7 +491,7 @@ export interface OrderPaymentData {
|
|
|
491
491
|
voucher_id?: string | number;
|
|
492
492
|
origin_amount?: string;
|
|
493
493
|
service_fee?: string;
|
|
494
|
-
status?: 'active' | 'voided' | string;
|
|
494
|
+
status?: 'active' | 'paid' | 'voided' | 'payment_pending' | string;
|
|
495
495
|
/** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
496
496
|
payment_time?: string;
|
|
497
497
|
wallet_pass_usage_unit?: unknown;
|
|
@@ -537,6 +537,7 @@ export interface SyncPaymentsToOrderParams {
|
|
|
537
537
|
smallTicketDataFlag?: number;
|
|
538
538
|
businessCode?: string;
|
|
539
539
|
channel?: string;
|
|
540
|
+
confirmPendingVoucherPayments?: boolean;
|
|
540
541
|
}
|
|
541
542
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
542
543
|
isFullyPaid: boolean;
|
|
@@ -696,6 +697,7 @@ export interface OrderModuleAPI {
|
|
|
696
697
|
payments?: OrderPaymentSource[];
|
|
697
698
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
698
699
|
smallTicketDataFlag?: number;
|
|
700
|
+
confirmPendingVoucherPayments?: boolean;
|
|
699
701
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
700
702
|
}) => Promise<T>;
|
|
701
703
|
submitTempOrderAsync: <T = any>(params?: {
|
|
@@ -707,6 +709,7 @@ export interface OrderModuleAPI {
|
|
|
707
709
|
payments?: OrderPaymentSource[];
|
|
708
710
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
709
711
|
smallTicketDataFlag?: number;
|
|
712
|
+
confirmPendingVoucherPayments?: boolean;
|
|
710
713
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
711
714
|
}) => Promise<T>;
|
|
712
715
|
getOrderPayments: () => OrderPaymentData[];
|
|
@@ -714,7 +717,17 @@ export interface OrderModuleAPI {
|
|
|
714
717
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
715
718
|
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
|
|
716
719
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
717
|
-
updateVoucherOrderPayments: (payments: OrderPaymentSource[]
|
|
720
|
+
updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
|
|
721
|
+
status?: 'paid' | 'payment_pending';
|
|
722
|
+
}) => OrderPaymentData[];
|
|
723
|
+
confirmPendingVoucherPayments: (options?: {
|
|
724
|
+
persist?: boolean;
|
|
725
|
+
recalculateSummary?: boolean;
|
|
726
|
+
}) => OrderPaymentData[];
|
|
727
|
+
discardPendingVoucherPayments: (options?: {
|
|
728
|
+
persist?: boolean;
|
|
729
|
+
recalculateSummary?: boolean;
|
|
730
|
+
}) => OrderPaymentData[];
|
|
718
731
|
sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
|
|
719
732
|
saveDraft: () => Promise<void>;
|
|
720
733
|
hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OrderProductDiscountItem } from '../types';
|
|
2
|
+
type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
|
|
3
|
+
export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
|
|
4
|
+
export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Order/utils/bundleDiscountHydration.ts
|
|
20
|
+
var bundleDiscountHydration_exports = {};
|
|
21
|
+
__export(bundleDiscountHydration_exports, {
|
|
22
|
+
expandHydratedProductsForDiscountCollection: () => expandHydratedProductsForDiscountCollection,
|
|
23
|
+
restoreHydratedBundleDiscounts: () => restoreHydratedBundleDiscounts
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(bundleDiscountHydration_exports);
|
|
26
|
+
var BUNDLE_MAP_ID_KEY = "custom_product_bundle_map_id";
|
|
27
|
+
function getBundleMapId(bundle) {
|
|
28
|
+
var _a;
|
|
29
|
+
const metadataMapId = (_a = bundle == null ? void 0 : bundle.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
30
|
+
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
31
|
+
return String(metadataMapId);
|
|
32
|
+
}
|
|
33
|
+
if ((bundle == null ? void 0 : bundle._id) !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
34
|
+
return String(bundle._id);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function getDiscountBundleMapId(discount) {
|
|
39
|
+
var _a;
|
|
40
|
+
const mapId = (_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
41
|
+
if (mapId === void 0 || mapId === null || mapId === "")
|
|
42
|
+
return null;
|
|
43
|
+
return String(mapId);
|
|
44
|
+
}
|
|
45
|
+
function hasSameBundleDiscount(discountList, discount) {
|
|
46
|
+
var _a;
|
|
47
|
+
const targetOrderDiscountId = discount.order_discount_id;
|
|
48
|
+
if (targetOrderDiscountId !== void 0 && targetOrderDiscountId !== null) {
|
|
49
|
+
return discountList.some((item) => (item == null ? void 0 : item.order_discount_id) === targetOrderDiscountId);
|
|
50
|
+
}
|
|
51
|
+
const targetResourceId = ((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id) ?? (discount == null ? void 0 : discount.resource_id) ?? (discount == null ? void 0 : discount.discount_id);
|
|
52
|
+
const targetMapId = getDiscountBundleMapId(discount);
|
|
53
|
+
return discountList.some((item) => {
|
|
54
|
+
var _a2;
|
|
55
|
+
const resourceId = ((_a2 = item == null ? void 0 : item.discount) == null ? void 0 : _a2.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.discount_id);
|
|
56
|
+
return resourceId === targetResourceId && String((item == null ? void 0 : item.amount) ?? "") === String((discount == null ? void 0 : discount.amount) ?? "") && getDiscountBundleMapId(item) === targetMapId;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
60
|
+
if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
|
|
61
|
+
return product;
|
|
62
|
+
}
|
|
63
|
+
const bundleByMapId = /* @__PURE__ */ new Map();
|
|
64
|
+
product.product_bundle.forEach((bundle) => {
|
|
65
|
+
if (!bundle || typeof bundle !== "object")
|
|
66
|
+
return;
|
|
67
|
+
const mapId = getBundleMapId(bundle);
|
|
68
|
+
if (mapId)
|
|
69
|
+
bundleByMapId.set(mapId, bundle);
|
|
70
|
+
});
|
|
71
|
+
if (!bundleByMapId.size)
|
|
72
|
+
return product;
|
|
73
|
+
const mainDiscountList = [];
|
|
74
|
+
const bundleDiscounts = [];
|
|
75
|
+
product.discount_list.forEach((discount) => {
|
|
76
|
+
const mapId = getDiscountBundleMapId(discount);
|
|
77
|
+
if (mapId && bundleByMapId.has(mapId)) {
|
|
78
|
+
bundleDiscounts.push({ mapId, discount });
|
|
79
|
+
} else {
|
|
80
|
+
mainDiscountList.push(discount);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (!bundleDiscounts.length)
|
|
84
|
+
return product;
|
|
85
|
+
return {
|
|
86
|
+
...product,
|
|
87
|
+
discount_list: normalizeDiscountList(mainDiscountList),
|
|
88
|
+
product_bundle: product.product_bundle.map((bundle) => {
|
|
89
|
+
if (!bundle || typeof bundle !== "object")
|
|
90
|
+
return bundle;
|
|
91
|
+
const mapId = getBundleMapId(bundle);
|
|
92
|
+
if (!mapId)
|
|
93
|
+
return bundle;
|
|
94
|
+
const matchedDiscounts = bundleDiscounts.filter((item) => item.mapId === mapId).map((item) => item.discount);
|
|
95
|
+
if (!matchedDiscounts.length)
|
|
96
|
+
return bundle;
|
|
97
|
+
const currentDiscountList = Array.isArray(bundle.discount_list) ? [...bundle.discount_list] : [];
|
|
98
|
+
for (const discount of matchedDiscounts) {
|
|
99
|
+
if (!hasSameBundleDiscount(currentDiscountList, discount)) {
|
|
100
|
+
currentDiscountList.push(discount);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
...bundle,
|
|
105
|
+
discount_list: normalizeDiscountList(currentDiscountList),
|
|
106
|
+
metadata: {
|
|
107
|
+
...bundle.metadata || {},
|
|
108
|
+
[BUNDLE_MAP_ID_KEY]: mapId
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function expandHydratedProductsForDiscountCollection(products) {
|
|
115
|
+
const expanded = [];
|
|
116
|
+
for (const product of products || []) {
|
|
117
|
+
expanded.push(product);
|
|
118
|
+
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
119
|
+
if (!Array.isArray(bundle == null ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0)
|
|
120
|
+
continue;
|
|
121
|
+
expanded.push({
|
|
122
|
+
...product,
|
|
123
|
+
product_id: bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? (product == null ? void 0 : product.product_id),
|
|
124
|
+
num: bundle.num ?? bundle.quantity ?? (product == null ? void 0 : product.num),
|
|
125
|
+
product_quantity: bundle.quantity ?? bundle.num ?? (product == null ? void 0 : product.product_quantity),
|
|
126
|
+
original_price: bundle.original_price ?? bundle.product_price ?? bundle.price,
|
|
127
|
+
selling_price: bundle.bundle_selling_price ?? bundle.price,
|
|
128
|
+
is_charge_tax: bundle.is_charge_tax ?? (product == null ? void 0 : product.is_charge_tax),
|
|
129
|
+
discount_list: bundle.discount_list
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return expanded;
|
|
134
|
+
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
expandHydratedProductsForDiscountCollection,
|
|
138
|
+
restoreHydratedBundleDiscounts
|
|
139
|
+
});
|
|
@@ -254,6 +254,10 @@ export declare function clearTempOrderHolderAssignments(tempOrder: OrderTempOrde
|
|
|
254
254
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
255
255
|
*/
|
|
256
256
|
export declare function getOrderProductLineUid(product: Record<string, any> | null | undefined): string | null;
|
|
257
|
+
export declare function getRuntimeProductOrigin(tempOrder: OrderTempOrder | null | undefined, product: any): Record<string, any> | null;
|
|
258
|
+
export declare function isHolderConfigRequired(holderConfig: any): boolean;
|
|
259
|
+
export declare function productRequiresFormSubject(tempOrder: OrderTempOrder | null | undefined, product: any): boolean;
|
|
260
|
+
export declare function resolveIsFormSubject(tempOrder: OrderTempOrder | null | undefined, product?: any): boolean;
|
|
257
261
|
/**
|
|
258
262
|
* 判断展示字段是否为空(含 i18n 对象全空)。
|
|
259
263
|
*
|
|
@@ -49,9 +49,11 @@ __export(utils_exports, {
|
|
|
49
49
|
getBundleSignedUnit: () => getBundleSignedUnit,
|
|
50
50
|
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
51
51
|
getProductSkuOptions: () => getProductSkuOptions,
|
|
52
|
+
getRuntimeProductOrigin: () => getRuntimeProductOrigin,
|
|
52
53
|
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
53
54
|
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
54
55
|
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
56
|
+
isHolderConfigRequired: () => isHolderConfigRequired,
|
|
55
57
|
isMarkdownBundle: () => isMarkdownBundle,
|
|
56
58
|
isTempOrder: () => isTempOrder,
|
|
57
59
|
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
@@ -65,7 +67,9 @@ __export(utils_exports, {
|
|
|
65
67
|
normalizeProductSkuOptions: () => normalizeProductSkuOptions,
|
|
66
68
|
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
67
69
|
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
70
|
+
productRequiresFormSubject: () => productRequiresFormSubject,
|
|
68
71
|
resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
|
|
72
|
+
resolveIsFormSubject: () => resolveIsFormSubject,
|
|
69
73
|
resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
|
|
70
74
|
resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
|
|
71
75
|
resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
|
|
@@ -376,6 +380,42 @@ function normalizeOrderProductDiscountList(discountList) {
|
|
|
376
380
|
return normalized;
|
|
377
381
|
});
|
|
378
382
|
}
|
|
383
|
+
function resolveSubmitBundleMapId(bundle) {
|
|
384
|
+
var _a;
|
|
385
|
+
const metadataMapId = (_a = bundle.metadata) == null ? void 0 : _a.custom_product_bundle_map_id;
|
|
386
|
+
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
387
|
+
return metadataMapId;
|
|
388
|
+
}
|
|
389
|
+
if (bundle._id !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
390
|
+
return bundle._id;
|
|
391
|
+
}
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
function collectSubmitProductDiscountList(product) {
|
|
395
|
+
const submitDiscountList = Array.isArray(product == null ? void 0 : product.discount_list) ? [...product.discount_list] : [];
|
|
396
|
+
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
397
|
+
if (!bundle || typeof bundle !== "object")
|
|
398
|
+
continue;
|
|
399
|
+
const bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
400
|
+
const bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
401
|
+
for (const discount of bundleDiscountList) {
|
|
402
|
+
if (!discount || typeof discount !== "object")
|
|
403
|
+
continue;
|
|
404
|
+
const discountMetadata = discount.metadata && typeof discount.metadata === "object" ? discount.metadata : {};
|
|
405
|
+
const discountMapId = discountMetadata.custom_product_bundle_map_id !== void 0 && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== "" ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
406
|
+
submitDiscountList.push({
|
|
407
|
+
...discount,
|
|
408
|
+
...discountMapId !== void 0 ? {
|
|
409
|
+
metadata: {
|
|
410
|
+
...discountMetadata,
|
|
411
|
+
custom_product_bundle_map_id: discountMapId
|
|
412
|
+
}
|
|
413
|
+
} : {}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
418
|
+
}
|
|
379
419
|
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
380
420
|
var _a, _b;
|
|
381
421
|
const metadata = params.metadata || {};
|
|
@@ -671,6 +711,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
671
711
|
return bundle.map((b) => {
|
|
672
712
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
673
713
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
714
|
+
const {
|
|
715
|
+
custom_product_bundle_map_id: _customProductBundleMapId,
|
|
716
|
+
...submitMetadata
|
|
717
|
+
} = existedMetadata;
|
|
674
718
|
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
675
719
|
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
676
720
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
@@ -683,6 +727,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
683
727
|
0
|
|
684
728
|
);
|
|
685
729
|
const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
|
|
730
|
+
const bundleMapId = resolveSubmitBundleMapId(rawBundle);
|
|
731
|
+
const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
686
732
|
return {
|
|
687
733
|
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
688
734
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
@@ -700,7 +746,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
700
746
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
701
747
|
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
702
748
|
metadata: {
|
|
703
|
-
...
|
|
749
|
+
...submitMetadata,
|
|
750
|
+
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
704
751
|
surcharge_fee: surchargeFee,
|
|
705
752
|
relation_surcharge_ids: relationSurchargeIds,
|
|
706
753
|
product_discount_difference: productDiscountDifference
|
|
@@ -765,7 +812,7 @@ function normalizeSubmitProduct(product) {
|
|
|
765
812
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
766
813
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
767
814
|
product_sku: productSku,
|
|
768
|
-
discount_list:
|
|
815
|
+
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
769
816
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
770
817
|
metadata: cleanMetadata,
|
|
771
818
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
@@ -1094,6 +1141,37 @@ function getOrderProductLineUid(product) {
|
|
|
1094
1141
|
return null;
|
|
1095
1142
|
return String(uid);
|
|
1096
1143
|
}
|
|
1144
|
+
function getRuntimeProductOrigin(tempOrder, product) {
|
|
1145
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1146
|
+
const uid = getOrderProductLineUid(product);
|
|
1147
|
+
if (uid && ((_c = (_b = (_a = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _a.productsByUid) == null ? void 0 : _b[uid]) == null ? void 0 : _c.origin)) {
|
|
1148
|
+
return tempOrder._extend.productsByUid[uid].origin;
|
|
1149
|
+
}
|
|
1150
|
+
const matchedProduct = ((tempOrder == null ? void 0 : tempOrder.products) || []).find((item) => item === product || getOrderProductLineUid(item) === uid || String((item == null ? void 0 : item.product_id) ?? (item == null ? void 0 : item.id) ?? "") === String((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id) ?? ""));
|
|
1151
|
+
const matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : "";
|
|
1152
|
+
return matchedUid ? ((_f = (_e = (_d = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[matchedUid]) == null ? void 0 : _f.origin) || null : null;
|
|
1153
|
+
}
|
|
1154
|
+
function isHolderConfigRequired(holderConfig) {
|
|
1155
|
+
if (!holderConfig || typeof holderConfig !== "object")
|
|
1156
|
+
return false;
|
|
1157
|
+
if (holderConfig.status === "disable")
|
|
1158
|
+
return false;
|
|
1159
|
+
return Number(holderConfig.required) === 1;
|
|
1160
|
+
}
|
|
1161
|
+
function productRequiresFormSubject(tempOrder, product) {
|
|
1162
|
+
const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1163
|
+
return isHolderConfigRequired(product == null ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config);
|
|
1164
|
+
}
|
|
1165
|
+
function resolveIsFormSubject(tempOrder, product) {
|
|
1166
|
+
var _a;
|
|
1167
|
+
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1168
|
+
return true;
|
|
1169
|
+
if (product)
|
|
1170
|
+
return productRequiresFormSubject(tempOrder, product);
|
|
1171
|
+
return ((tempOrder == null ? void 0 : tempOrder.products) || []).some(
|
|
1172
|
+
(item) => productRequiresFormSubject(tempOrder, item)
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1097
1175
|
function isEmptyOrderProductDisplayValue(value) {
|
|
1098
1176
|
if (value === void 0 || value === null)
|
|
1099
1177
|
return true;
|
|
@@ -1174,9 +1252,11 @@ function indexOrderProductsByUid(products) {
|
|
|
1174
1252
|
getBundleSignedUnit,
|
|
1175
1253
|
getOrderProductLineUid,
|
|
1176
1254
|
getProductSkuOptions,
|
|
1255
|
+
getRuntimeProductOrigin,
|
|
1177
1256
|
hasAssignedHolderId,
|
|
1178
1257
|
indexOrderProductsByUid,
|
|
1179
1258
|
isEmptyOrderProductDisplayValue,
|
|
1259
|
+
isHolderConfigRequired,
|
|
1180
1260
|
isMarkdownBundle,
|
|
1181
1261
|
isTempOrder,
|
|
1182
1262
|
mapPaymentItemToOrderPayment,
|
|
@@ -1190,7 +1270,9 @@ function indexOrderProductsByUid(products) {
|
|
|
1190
1270
|
normalizeProductSkuOptions,
|
|
1191
1271
|
normalizeSubmitBooking,
|
|
1192
1272
|
normalizeSubmitCollectPaxValue,
|
|
1273
|
+
productRequiresFormSubject,
|
|
1193
1274
|
resolveEffectivePerUnitDiscount,
|
|
1275
|
+
resolveIsFormSubject,
|
|
1194
1276
|
resolveManualDiscountMessage,
|
|
1195
1277
|
resolveManualDiscountOriginTotal,
|
|
1196
1278
|
resolveManualDiscountReasonFromSources,
|
|
@@ -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(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from '../Discount/types';
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
import { WindowPlugin } from '../../plugins';
|
|
@@ -24,7 +24,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
24
24
|
holders: {
|
|
25
25
|
form_record_id: number;
|
|
26
26
|
}[];
|
|
27
|
-
isFormSubject:
|
|
27
|
+
isFormSubject: RulesFormSubject;
|
|
28
28
|
}): {
|
|
29
29
|
isAvailable: boolean;
|
|
30
30
|
discountList: Discount[];
|
|
@@ -43,7 +43,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
43
43
|
holders: {
|
|
44
44
|
form_record_id: number;
|
|
45
45
|
}[];
|
|
46
|
-
isFormSubject:
|
|
46
|
+
isFormSubject: RulesFormSubject;
|
|
47
47
|
orderTotalAmount: number;
|
|
48
48
|
}, options?: {
|
|
49
49
|
isSelected?: boolean;
|
|
@@ -70,7 +70,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
var _a;
|
|
71
71
|
if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
|
|
72
72
|
return true;
|
|
73
|
-
const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
|
|
73
|
+
const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : void 0;
|
|
74
74
|
const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
75
75
|
if (!product.isNeedHolder)
|
|
76
76
|
return true;
|
|
@@ -207,6 +207,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
207
207
|
orderTotalAmount
|
|
208
208
|
}, options) {
|
|
209
209
|
var _a;
|
|
210
|
+
const resolveIsFormSubject = (product) => typeof isFormSubject === "function" ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
210
211
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
211
212
|
const editModeDiscount = [];
|
|
212
213
|
const addModeDiscount = [];
|
|
@@ -596,7 +597,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
596
597
|
const isHolderMatch = this.checkHolderMatch(
|
|
597
598
|
discount,
|
|
598
599
|
{
|
|
599
|
-
isNeedHolder:
|
|
600
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
600
601
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
601
602
|
},
|
|
602
603
|
holders
|
|
@@ -767,7 +768,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
767
768
|
const isHolderMatch = this.checkHolderMatch(
|
|
768
769
|
discount,
|
|
769
770
|
{
|
|
770
|
-
isNeedHolder:
|
|
771
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
771
772
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
772
773
|
},
|
|
773
774
|
holders
|
|
@@ -22,6 +22,7 @@ export interface DiscountResult {
|
|
|
22
22
|
productList: any[];
|
|
23
23
|
discountList: any[];
|
|
24
24
|
}
|
|
25
|
+
export type RulesFormSubject = boolean | ((product: any) => boolean);
|
|
25
26
|
export interface RulesModuleAPI {
|
|
26
27
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
27
28
|
clear: () => Promise<void>;
|
|
@@ -31,7 +32,7 @@ export interface RulesModuleAPI {
|
|
|
31
32
|
holders: {
|
|
32
33
|
form_record_id: number;
|
|
33
34
|
}[];
|
|
34
|
-
isFormSubject:
|
|
35
|
+
isFormSubject: RulesFormSubject;
|
|
35
36
|
orderTotalAmount: number;
|
|
36
37
|
}) => DiscountResult;
|
|
37
38
|
}
|
|
@@ -31,10 +31,10 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
31
31
|
private emitOrdersChanged;
|
|
32
32
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
* 记录信息日志
|
|
35
|
+
* @param title 日志标题
|
|
36
|
+
* @param metadata 日志元数据
|
|
37
|
+
*/
|
|
38
38
|
private logInfo;
|
|
39
39
|
/**
|
|
40
40
|
* 记录错误日志
|
|
@@ -109,10 +109,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
* 记录信息日志
|
|
113
|
+
* @param title 日志标题
|
|
114
|
+
* @param metadata 日志元数据
|
|
115
|
+
*/
|
|
116
116
|
logInfo(title, metadata) {
|
|
117
117
|
try {
|
|
118
118
|
if (this.logger) {
|
|
@@ -195,6 +195,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
195
195
|
payments?: OrderPaymentSource[];
|
|
196
196
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
197
197
|
smallTicketDataFlag?: number;
|
|
198
|
+
confirmPendingVoucherPayments?: boolean;
|
|
198
199
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
199
200
|
}): Promise<T>;
|
|
200
201
|
/**
|
|
@@ -207,12 +208,14 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
207
208
|
payments?: OrderPaymentSource[];
|
|
208
209
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
209
210
|
smallTicketDataFlag?: number;
|
|
211
|
+
confirmPendingVoucherPayments?: boolean;
|
|
210
212
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
211
213
|
}): Promise<T>;
|
|
212
214
|
submitTempOrderAsync<T = any>(params?: {
|
|
213
215
|
payments?: OrderPaymentSource[];
|
|
214
216
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
215
217
|
smallTicketDataFlag?: number;
|
|
218
|
+
confirmPendingVoucherPayments?: boolean;
|
|
216
219
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
217
220
|
}): Promise<T>;
|
|
218
221
|
printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
|
|
@@ -229,7 +232,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
229
232
|
/** 删除当前订单中的指定支付项。 */
|
|
230
233
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
231
234
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
232
|
-
updateVoucherOrderPayments(payments: OrderPaymentSource[]
|
|
235
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
236
|
+
status?: 'paid' | 'payment_pending';
|
|
237
|
+
}): OrderPaymentData[];
|
|
238
|
+
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
239
|
+
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
233
240
|
private getWalletProductList;
|
|
234
241
|
initWalletData(params?: {
|
|
235
242
|
order_wait_pay_amount?: number;
|