@pisell/pisellos 2.2.260 → 2.2.261
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/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +33 -2
- package/dist/modules/Order/index.js +615 -288
- package/dist/modules/Order/types.d.ts +20 -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 +116 -29
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +4 -3
- package/dist/modules/Rules/index.js +42 -17
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +3 -50
- package/dist/server/index.js +1075 -1040
- package/dist/server/modules/order/index.d.ts +22 -3
- package/dist/server/modules/order/index.js +398 -316
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -166
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +22 -2
- package/dist/solution/BaseSales/index.js +995 -701
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -1
- package/dist/solution/BookingTicket/index.js +153 -6
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +33 -2
- package/lib/modules/Order/index.js +402 -64
- package/lib/modules/Order/types.d.ts +20 -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 +90 -3
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +4 -3
- package/lib/modules/Rules/index.js +27 -7
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +3 -50
- package/lib/server/index.js +244 -215
- package/lib/server/modules/order/index.d.ts +22 -3
- package/lib/server/modules/order/index.js +103 -53
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -113
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +22 -2
- package/lib/solution/BaseSales/index.js +246 -60
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -1
- package/lib/solution/BookingTicket/index.js +101 -0
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -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,9 +537,15 @@ 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;
|
|
544
|
+
isOrderFullyPaid: boolean;
|
|
545
|
+
isDepositFullyPaid: boolean;
|
|
546
|
+
paymentStage: 'deposit' | 'normal';
|
|
547
|
+
depositAmount: string;
|
|
548
|
+
orderExpectedAmount: string;
|
|
543
549
|
submitResult?: T;
|
|
544
550
|
}
|
|
545
551
|
export interface OrderIdentitySnapshot {
|
|
@@ -691,6 +697,7 @@ export interface OrderModuleAPI {
|
|
|
691
697
|
payments?: OrderPaymentSource[];
|
|
692
698
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
693
699
|
smallTicketDataFlag?: number;
|
|
700
|
+
confirmPendingVoucherPayments?: boolean;
|
|
694
701
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
695
702
|
}) => Promise<T>;
|
|
696
703
|
submitTempOrderAsync: <T = any>(params?: {
|
|
@@ -702,6 +709,7 @@ export interface OrderModuleAPI {
|
|
|
702
709
|
payments?: OrderPaymentSource[];
|
|
703
710
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
704
711
|
smallTicketDataFlag?: number;
|
|
712
|
+
confirmPendingVoucherPayments?: boolean;
|
|
705
713
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
706
714
|
}) => Promise<T>;
|
|
707
715
|
getOrderPayments: () => OrderPaymentData[];
|
|
@@ -709,7 +717,17 @@ export interface OrderModuleAPI {
|
|
|
709
717
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
710
718
|
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
|
|
711
719
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
712
|
-
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[];
|
|
713
731
|
sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
|
|
714
732
|
saveDraft: () => Promise<void>;
|
|
715
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 || {};
|
|
@@ -406,7 +446,12 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
406
446
|
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
407
447
|
0
|
|
408
448
|
);
|
|
409
|
-
const hasPromoDiscountItem = discountList.some(
|
|
449
|
+
const hasPromoDiscountItem = discountList.some(
|
|
450
|
+
(item) => {
|
|
451
|
+
var _a, _b;
|
|
452
|
+
return (item == null ? void 0 : item.type) === "promotion" || (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
453
|
+
}
|
|
454
|
+
);
|
|
410
455
|
if (hasPromoDiscountItem)
|
|
411
456
|
return fromList;
|
|
412
457
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
@@ -671,6 +716,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
671
716
|
return bundle.map((b) => {
|
|
672
717
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
673
718
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
719
|
+
const {
|
|
720
|
+
custom_product_bundle_map_id: _customProductBundleMapId,
|
|
721
|
+
...submitMetadata
|
|
722
|
+
} = existedMetadata;
|
|
674
723
|
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
675
724
|
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
676
725
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
@@ -683,6 +732,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
683
732
|
0
|
|
684
733
|
);
|
|
685
734
|
const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
|
|
735
|
+
const bundleMapId = resolveSubmitBundleMapId(rawBundle);
|
|
736
|
+
const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
686
737
|
return {
|
|
687
738
|
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
688
739
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
@@ -700,7 +751,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
700
751
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
701
752
|
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
702
753
|
metadata: {
|
|
703
|
-
...
|
|
754
|
+
...submitMetadata,
|
|
755
|
+
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
704
756
|
surcharge_fee: surchargeFee,
|
|
705
757
|
relation_surcharge_ids: relationSurchargeIds,
|
|
706
758
|
product_discount_difference: productDiscountDifference
|
|
@@ -765,7 +817,7 @@ function normalizeSubmitProduct(product) {
|
|
|
765
817
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
766
818
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
767
819
|
product_sku: productSku,
|
|
768
|
-
discount_list:
|
|
820
|
+
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
769
821
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
770
822
|
metadata: cleanMetadata,
|
|
771
823
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
@@ -1094,6 +1146,37 @@ function getOrderProductLineUid(product) {
|
|
|
1094
1146
|
return null;
|
|
1095
1147
|
return String(uid);
|
|
1096
1148
|
}
|
|
1149
|
+
function getRuntimeProductOrigin(tempOrder, product) {
|
|
1150
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1151
|
+
const uid = getOrderProductLineUid(product);
|
|
1152
|
+
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)) {
|
|
1153
|
+
return tempOrder._extend.productsByUid[uid].origin;
|
|
1154
|
+
}
|
|
1155
|
+
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) ?? ""));
|
|
1156
|
+
const matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : "";
|
|
1157
|
+
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;
|
|
1158
|
+
}
|
|
1159
|
+
function isHolderConfigRequired(holderConfig) {
|
|
1160
|
+
if (!holderConfig || typeof holderConfig !== "object")
|
|
1161
|
+
return false;
|
|
1162
|
+
if (holderConfig.status === "disable")
|
|
1163
|
+
return false;
|
|
1164
|
+
return Number(holderConfig.required) === 1;
|
|
1165
|
+
}
|
|
1166
|
+
function productRequiresFormSubject(tempOrder, product) {
|
|
1167
|
+
const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1168
|
+
return isHolderConfigRequired(product == null ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config);
|
|
1169
|
+
}
|
|
1170
|
+
function resolveIsFormSubject(tempOrder, product) {
|
|
1171
|
+
var _a;
|
|
1172
|
+
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1173
|
+
return true;
|
|
1174
|
+
if (product)
|
|
1175
|
+
return productRequiresFormSubject(tempOrder, product);
|
|
1176
|
+
return ((tempOrder == null ? void 0 : tempOrder.products) || []).some(
|
|
1177
|
+
(item) => productRequiresFormSubject(tempOrder, item)
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1097
1180
|
function isEmptyOrderProductDisplayValue(value) {
|
|
1098
1181
|
if (value === void 0 || value === null)
|
|
1099
1182
|
return true;
|
|
@@ -1174,9 +1257,11 @@ function indexOrderProductsByUid(products) {
|
|
|
1174
1257
|
getBundleSignedUnit,
|
|
1175
1258
|
getOrderProductLineUid,
|
|
1176
1259
|
getProductSkuOptions,
|
|
1260
|
+
getRuntimeProductOrigin,
|
|
1177
1261
|
hasAssignedHolderId,
|
|
1178
1262
|
indexOrderProductsByUid,
|
|
1179
1263
|
isEmptyOrderProductDisplayValue,
|
|
1264
|
+
isHolderConfigRequired,
|
|
1180
1265
|
isMarkdownBundle,
|
|
1181
1266
|
isTempOrder,
|
|
1182
1267
|
mapPaymentItemToOrderPayment,
|
|
@@ -1190,7 +1275,9 @@ function indexOrderProductsByUid(products) {
|
|
|
1190
1275
|
normalizeProductSkuOptions,
|
|
1191
1276
|
normalizeSubmitBooking,
|
|
1192
1277
|
normalizeSubmitCollectPaxValue,
|
|
1278
|
+
productRequiresFormSubject,
|
|
1193
1279
|
resolveEffectivePerUnitDiscount,
|
|
1280
|
+
resolveIsFormSubject,
|
|
1194
1281
|
resolveManualDiscountMessage,
|
|
1195
1282
|
resolveManualDiscountOriginTotal,
|
|
1196
1283
|
resolveManualDiscountReasonFromSources,
|
|
@@ -9,26 +9,6 @@ export interface ProductCollection {
|
|
|
9
9
|
/** 商品集合封面 */
|
|
10
10
|
cover: string;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* 商品 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
14
|
-
*/
|
|
15
|
-
export interface ProductDataVariant {
|
|
16
|
-
/** 变体记录 id */
|
|
17
|
-
id: number;
|
|
18
|
-
/** 店铺 id */
|
|
19
|
-
shop_id: number;
|
|
20
|
-
/** 所属模块,商品场景固定为 product */
|
|
21
|
-
module: string;
|
|
22
|
-
/** 模块数据 id,商品场景对应 product.id */
|
|
23
|
-
module_data_id: number;
|
|
24
|
-
/** 关联 data_variant_rule.id */
|
|
25
|
-
data_variant_rule_id: number;
|
|
26
|
-
/** 命中策略后覆盖到商品上的字段 */
|
|
27
|
-
data: Record<string, any>;
|
|
28
|
-
created_at: string | null;
|
|
29
|
-
updated_at: string | null;
|
|
30
|
-
deleted_at: string | null;
|
|
31
|
-
}
|
|
32
12
|
/**
|
|
33
13
|
* 商品基本信息接口
|
|
34
14
|
*/
|
|
@@ -234,8 +214,6 @@ export interface ProductData {
|
|
|
234
214
|
bundle_group_count: number;
|
|
235
215
|
/** 选项组数量 */
|
|
236
216
|
option_group_count: number;
|
|
237
|
-
/** 智能定价变体列表,/product/query with dataVariants 返回 */
|
|
238
|
-
data_variants?: ProductDataVariant[];
|
|
239
217
|
/** 服务时长 */
|
|
240
218
|
service_times?: any;
|
|
241
219
|
}
|
|
@@ -26,7 +26,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
26
26
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
27
|
*/
|
|
28
28
|
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
|
|
29
|
-
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status,
|
|
29
|
+
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
|
|
30
30
|
callback?: (result: any) => void;
|
|
31
31
|
subscriberId?: string;
|
|
32
32
|
}): Promise<any>;
|
|
@@ -95,8 +95,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
cacheId,
|
|
96
96
|
with_schedule,
|
|
97
97
|
extension_type,
|
|
98
|
-
status = "published"
|
|
99
|
-
strategy_context
|
|
98
|
+
status = "published"
|
|
100
99
|
} = {}, options) {
|
|
101
100
|
var _a, _b;
|
|
102
101
|
let userPlugin = this.core.getPlugin("user");
|
|
@@ -136,8 +135,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
136
135
|
is_eject: 1,
|
|
137
136
|
with_schedule,
|
|
138
137
|
schedule_datetime,
|
|
139
|
-
extension_type
|
|
140
|
-
strategy_context
|
|
138
|
+
extension_type
|
|
141
139
|
},
|
|
142
140
|
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
|
|
143
141
|
} }
|
|
@@ -12,8 +12,6 @@ export interface ProductListLoadProductsParams {
|
|
|
12
12
|
with_schedule?: number;
|
|
13
13
|
extension_type?: string[];
|
|
14
14
|
status?: string;
|
|
15
|
-
/** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
|
|
16
|
-
strategy_context?: Record<string, any>;
|
|
17
15
|
}
|
|
18
16
|
export interface ProductListData {
|
|
19
17
|
list: ProductData[];
|
|
@@ -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[];
|
|
@@ -36,6 +36,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
36
36
|
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
37
37
|
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
38
38
|
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
39
|
+
private isItemRewardProductDiscount;
|
|
39
40
|
private getUnavailableReason;
|
|
40
41
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
41
42
|
discountList: Discount[];
|
|
@@ -43,7 +44,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
43
44
|
holders: {
|
|
44
45
|
form_record_id: number;
|
|
45
46
|
}[];
|
|
46
|
-
isFormSubject:
|
|
47
|
+
isFormSubject: RulesFormSubject;
|
|
47
48
|
orderTotalAmount: number;
|
|
48
49
|
}, options?: {
|
|
49
50
|
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;
|
|
@@ -167,6 +167,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
167
167
|
resolveDiscountListForManualOverride(discountList) {
|
|
168
168
|
return this.excludeDiscountListByType(discountList, "promotion");
|
|
169
169
|
}
|
|
170
|
+
isItemRewardProductDiscount(product) {
|
|
171
|
+
var _a;
|
|
172
|
+
const discountList = Array.isArray(product == null ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
173
|
+
return ((_a = product == null ? void 0 : product._promotion) == null ? void 0 : _a.actionType) === "ITEM_REWARD" && discountList.some(
|
|
174
|
+
(item) => {
|
|
175
|
+
var _a2, _b;
|
|
176
|
+
return (item == null ? void 0 : item.type) === "product" && ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
170
180
|
// 获取券不可用的原因
|
|
171
181
|
getUnavailableReason(discountList, productList) {
|
|
172
182
|
var _a;
|
|
@@ -207,6 +217,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
207
217
|
orderTotalAmount
|
|
208
218
|
}, options) {
|
|
209
219
|
var _a;
|
|
220
|
+
const resolveIsFormSubject = (product) => typeof isFormSubject === "function" ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
210
221
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
211
222
|
const editModeDiscount = [];
|
|
212
223
|
const addModeDiscount = [];
|
|
@@ -464,6 +475,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
464
475
|
startDate: (_a2 = flatItem.parentProduct) == null ? void 0 : _a2.startDate
|
|
465
476
|
};
|
|
466
477
|
}
|
|
478
|
+
if (this.isItemRewardProductDiscount(product)) {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
467
481
|
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.length) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.every((d) => d.id && ["good_pass", "discount_card", "product_discount_card"].includes(d.tag || d.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_e = (_d = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _d.discount_list) == null ? void 0 : _e.length) && ((_g = (_f = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _f.discount_list) == null ? void 0 : _g.every((d) => d.id)));
|
|
468
482
|
if (!isAvailableProduct) {
|
|
469
483
|
return false;
|
|
@@ -589,6 +603,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
589
603
|
};
|
|
590
604
|
originProduct = flatItem.originProduct;
|
|
591
605
|
}
|
|
606
|
+
const isItemRewardProductDiscount = this.isItemRewardProductDiscount(product);
|
|
592
607
|
addModeDiscount.forEach((discount) => {
|
|
593
608
|
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
594
609
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
@@ -596,7 +611,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
596
611
|
const isHolderMatch = this.checkHolderMatch(
|
|
597
612
|
discount,
|
|
598
613
|
{
|
|
599
|
-
isNeedHolder:
|
|
614
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
600
615
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
601
616
|
},
|
|
602
617
|
holders
|
|
@@ -612,7 +627,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
612
627
|
].includes(discount2.tag || discount2.type)
|
|
613
628
|
))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) == null ? void 0 : _d.length) && ((_f = (_e = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.every((discount2) => discount2.id)));
|
|
614
629
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
615
|
-
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && ((_g = discount.config) == null ? void 0 : _g.isAvailable)) {
|
|
630
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && ((_g = discount.config) == null ? void 0 : _g.isAvailable)) {
|
|
616
631
|
(_h = discountApplicability.get(discount.id)) == null ? void 0 : _h.push(product.id);
|
|
617
632
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
618
633
|
const discountType = discount.tag || discount.type;
|
|
@@ -735,6 +750,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
735
750
|
}
|
|
736
751
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
737
752
|
var _a3, _b2, _c2, _d2;
|
|
753
|
+
if (this.isItemRewardProductDiscount(product))
|
|
754
|
+
return false;
|
|
738
755
|
const discountType = discount.tag || discount.type;
|
|
739
756
|
if (["good_pass", "discount_card", "product_discount_card"].includes(
|
|
740
757
|
discountType
|
|
@@ -767,7 +784,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
767
784
|
const isHolderMatch = this.checkHolderMatch(
|
|
768
785
|
discount,
|
|
769
786
|
{
|
|
770
|
-
isNeedHolder:
|
|
787
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
771
788
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
772
789
|
},
|
|
773
790
|
holders
|
|
@@ -800,6 +817,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
800
817
|
);
|
|
801
818
|
const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
802
819
|
let isManualDiscount = false;
|
|
820
|
+
let isItemRewardProductDiscount = false;
|
|
803
821
|
if (flatItem.type === "main") {
|
|
804
822
|
isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : ((_g = product.discount_list) == null ? void 0 : _g.some((item) => item.type === "product")) || product.total != product.origin_total && (product.bundle || []).every(
|
|
805
823
|
(item) => {
|
|
@@ -810,7 +828,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
810
828
|
_i,
|
|
811
829
|
(item) => item.type === "product"
|
|
812
830
|
)));
|
|
813
|
-
|
|
831
|
+
isItemRewardProductDiscount = this.isItemRewardProductDiscount(product);
|
|
832
|
+
if (product.inPromotion && !isItemRewardProductDiscount) {
|
|
814
833
|
isManualDiscount = false;
|
|
815
834
|
}
|
|
816
835
|
} else {
|
|
@@ -924,7 +943,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
924
943
|
} else {
|
|
925
944
|
let total = product.inPromotion ? ((_w = product == null ? void 0 : product._promotion) == null ? void 0 : _w.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
|
|
926
945
|
let main_product_selling_price = product.price;
|
|
927
|
-
if ((product.discount_list || []).some((item) => item.type === "promotion") || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
946
|
+
if ((product.discount_list || []).some((item) => item.type === "promotion") || isItemRewardProductDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
928
947
|
total = product.total ?? product.origin_total;
|
|
929
948
|
main_product_selling_price = product.main_product_selling_price ?? main_product_selling_price;
|
|
930
949
|
}
|
|
@@ -932,7 +951,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
932
951
|
this.hooks.setProduct(originProduct, {
|
|
933
952
|
...isManualDiscount ? {
|
|
934
953
|
price: product.price,
|
|
935
|
-
main_product_selling_price: product.price
|
|
954
|
+
main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price,
|
|
955
|
+
...isItemRewardProductDiscount ? { total } : {}
|
|
936
956
|
} : {
|
|
937
957
|
_id: product._id.split("___")[0] + "___" + index,
|
|
938
958
|
total,
|
|
@@ -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
|
}
|