@pisell/pisellos 2.3.184 → 2.3.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +509 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Discount/index.js +1 -0
- package/dist/modules/Order/index.d.ts +25 -3
- package/dist/modules/Order/index.js +1770 -1311
- package/dist/modules/Order/types.d.ts +7 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
- package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
- package/dist/modules/Order/utils.js +12 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +5 -0
- package/dist/modules/ProductList/index.js +33 -12
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +29 -21
- package/dist/solution/BaseSales/index.d.ts +18 -1
- package/dist/solution/BaseSales/index.js +1762 -1434
- package/dist/solution/BaseSales/types.d.ts +3 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/dist/solution/BookingTicket/index.js +197 -108
- package/dist/solution/BookingTicket/types.d.ts +14 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +102 -64
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.js +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +287 -0
- package/lib/modules/Discount/index.js +1 -0
- package/lib/modules/Order/index.d.ts +25 -3
- package/lib/modules/Order/index.js +192 -38
- package/lib/modules/Order/types.d.ts +7 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
- package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
- package/lib/modules/Order/utils.js +13 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +5 -0
- package/lib/modules/ProductList/index.js +15 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +6 -0
- package/lib/solution/BaseSales/index.d.ts +18 -1
- package/lib/solution/BaseSales/index.js +214 -50
- package/lib/solution/BaseSales/types.d.ts +3 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/lib/solution/BookingTicket/index.js +37 -2
- package/lib/solution/BookingTicket/types.d.ts +14 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +37 -4
- package/lib/utils/platform.d.ts +2 -0
- package/lib/utils/platform.js +7 -0
- package/package.json +1 -1
|
@@ -457,6 +457,8 @@ export type AddProductBookingInput = Record<string, any>;
|
|
|
457
457
|
* 避免步进器修改数量改变该组展示位置。
|
|
458
458
|
*/
|
|
459
459
|
export interface AddProductToOrderOptions {
|
|
460
|
+
/** Associates a selection with an existing runtime voucher group. */
|
|
461
|
+
productVoucherGroupKey?: string;
|
|
460
462
|
insertAfterProductUid?: string;
|
|
461
463
|
/** 新增商品行插入 products 首位,优先于 insertAfterProductUid。 */
|
|
462
464
|
insertAtStart?: boolean;
|
|
@@ -557,6 +559,11 @@ export interface OrderHooksConfig {
|
|
|
557
559
|
beforeCartIntentCommit?: (context: OrderCartIntentCommitContext) => void;
|
|
558
560
|
/** Captures tenant/business runtime identity for asynchronous cart intents. */
|
|
559
561
|
getCartIntentScope?: () => unknown;
|
|
562
|
+
/** Awaited before a local cart draft is published. Reject to leave the live order unchanged. */
|
|
563
|
+
onBeforeCartCommit?: (context: {
|
|
564
|
+
currentItems: readonly OrderProduct[];
|
|
565
|
+
proposedItems: readonly OrderProduct[];
|
|
566
|
+
}) => void | Promise<void>;
|
|
560
567
|
onBeforeMergeProductToOrder?: (context: OrderProductMergeDecisionContext) => OrderProductMergeDecisionResult | Promise<OrderProductMergeDecisionResult>;
|
|
561
568
|
}
|
|
562
569
|
/**
|
|
@@ -279,7 +279,7 @@ export function consolidateDiscountFreeProductLines(tempOrder) {
|
|
|
279
279
|
_step6;
|
|
280
280
|
try {
|
|
281
281
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
282
|
-
var _product$booking_uid, _product$metadata4, _booking_id, _product$metadata5, _product$order_detail, _holder_id, _product$metadata6, _product$metadata7, _product$metadata8, _product$product_sku2, _product$metadata9, _tempOrder$_extend, _product$selling_pric, _product$original_pri, _custom_price, _product$is_charge_ta, _product$gift_card, _product$bundle_edit, _product$metadata$pri, _product$metadata10, _product$metadata$sou, _product$metadata11, _product$metadata$mai, _product$metadata12, _product$metadata$mai2, _product$metadata13, _product$product_vari;
|
|
282
|
+
var _product$booking_uid, _product$metadata4, _booking_id, _product$metadata5, _product$order_detail, _holder_id, _product$metadata6, _product$metadata7, _product$metadata8, _product$product_sku2, _product$metadata9, _tempOrder$_extend, _product$selling_pric, _product$original_pri, _custom_price, _product$is_charge_ta, _product$gift_card, _product$bundle_edit, _product$metadata$pri, _product$metadata10, _product$metadata$sou, _product$metadata11, _product$metadata$mai, _product$metadata12, _product$metadata$mai2, _product$metadata13, _tempOrder$_extend$pr, _tempOrder$_extend2, _product$product_vari;
|
|
283
283
|
var product = _step6.value;
|
|
284
284
|
var productBundle = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
285
285
|
var hasDiscount = (product.discount_list || []).length > 0 || productBundle.some(function (bundle) {
|
|
@@ -337,7 +337,7 @@ export function consolidateDiscountFreeProductLines(tempOrder) {
|
|
|
337
337
|
};
|
|
338
338
|
})
|
|
339
339
|
});
|
|
340
|
-
var mergeKey = [discountSplitOriginUid, product.product_id, (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0, fingerprint, priceSignature].join('#');
|
|
340
|
+
var mergeKey = [discountSplitOriginUid, productUid ? (_tempOrder$_extend$pr = (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.productsByUid) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2[productUid]) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.productVoucherGroupKey) !== null && _tempOrder$_extend$pr !== void 0 ? _tempOrder$_extend$pr : '' : '', product.product_id, (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0, fingerprint, priceSignature].join('#');
|
|
341
341
|
var matchedIndex = productIndexByKey.get(mergeKey);
|
|
342
342
|
|
|
343
343
|
// 当前拆分来源 + 商品结构组合第一次出现时,保留该行作为回并目标。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Discount } from '../../Discount/types';
|
|
2
|
+
import type { OrderTempOrder } from '../types';
|
|
3
|
+
/** Runtime-only allocation constraints. Never copied into order/product metadata. */
|
|
4
|
+
export interface ProductVoucherGroup {
|
|
5
|
+
key: string;
|
|
6
|
+
discountIds: Array<number | string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function productVoucherGroupKey(order: OrderTempOrder, product: any): string | undefined;
|
|
9
|
+
export declare function isUsableProductVoucher(discount: Discount): boolean;
|
|
10
|
+
export declare function voucherGroupError(): Error & {
|
|
11
|
+
code: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function allowsProductVoucher(order: OrderTempOrder | null | undefined, product: any, discount: Discount): boolean;
|
|
14
|
+
/** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
|
|
15
|
+
export declare function validateProductVoucherGroups(order: OrderTempOrder, discounts: Discount[], previous?: OrderTempOrder, requireCoverage?: boolean): void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
import { getDiscountUsageBlockReason } from "../../Discount/availability";
|
|
5
|
+
import dayjs from 'dayjs';
|
|
6
|
+
import { getDiscountTimeUnavailableReason } from "../../../solution/ShopDiscount/utils";
|
|
7
|
+
|
|
8
|
+
/** Runtime-only allocation constraints. Never copied into order/product metadata. */
|
|
9
|
+
|
|
10
|
+
export function productVoucherGroupKey(order, product) {
|
|
11
|
+
var _product$metadata$uni, _product$metadata, _order$_extend;
|
|
12
|
+
var uid = (_product$metadata$uni = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product === null || product === void 0 ? void 0 : product.unique_identification_number;
|
|
13
|
+
return (_order$_extend = order._extend) === null || _order$_extend === void 0 || (_order$_extend = _order$_extend.productsByUid) === null || _order$_extend === void 0 || (_order$_extend = _order$_extend[String(uid)]) === null || _order$_extend === void 0 ? void 0 : _order$_extend.productVoucherGroupKey;
|
|
14
|
+
}
|
|
15
|
+
export function isUsableProductVoucher(discount) {
|
|
16
|
+
return (discount.tag || discount.type) === 'good_pass' && !discount.isEditMode && !discount.isDisabled && !getDiscountUsageBlockReason(discount) && !getDiscountTimeUnavailableReason(discount, dayjs().format('YYYY-MM-DD HH:mm:ss'));
|
|
17
|
+
}
|
|
18
|
+
export function voucherGroupError() {
|
|
19
|
+
return Object.assign(new Error('The selected items no longer match the available vouchers. Please adjust your selection.'), {
|
|
20
|
+
code: 'PRODUCT_VOUCHER_GROUP_INVALID'
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function allowsProductVoucher(order, product, discount) {
|
|
24
|
+
var _order$_extend2, _groups$find;
|
|
25
|
+
var groups = order === null || order === void 0 || (_order$_extend2 = order._extend) === null || _order$_extend2 === void 0 ? void 0 : _order$_extend2.productVoucherGroups;
|
|
26
|
+
if (!order || !(groups !== null && groups !== void 0 && groups.length)) return true;
|
|
27
|
+
var key = productVoucherGroupKey(order, product);
|
|
28
|
+
if (!key) return !groups.some(function (group) {
|
|
29
|
+
return group.discountIds.some(function (id) {
|
|
30
|
+
return String(id) === String(discount.id);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return (discount.tag || discount.type) === 'good_pass' && Boolean((_groups$find = groups.find(function (group) {
|
|
34
|
+
return group.key === key;
|
|
35
|
+
})) === null || _groups$find === void 0 ? void 0 : _groups$find.discountIds.some(function (id) {
|
|
36
|
+
return String(id) === String(discount.id);
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Reductions stay possible when a voucher expires; checkout always requires full coverage. */
|
|
41
|
+
export function validateProductVoucherGroups(order, discounts, previous) {
|
|
42
|
+
var _order$_extend3;
|
|
43
|
+
var requireCoverage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
44
|
+
var groups = (_order$_extend3 = order._extend) === null || _order$_extend3 === void 0 ? void 0 : _order$_extend3.productVoucherGroups;
|
|
45
|
+
if (!(groups !== null && groups !== void 0 && groups.length)) return;
|
|
46
|
+
var usedIds = new Set();
|
|
47
|
+
var byId = new Map(discounts.filter(isUsableProductVoucher).map(function (discount) {
|
|
48
|
+
return [String(discount.id), discount];
|
|
49
|
+
}));
|
|
50
|
+
var quantity = function quantity(item) {
|
|
51
|
+
var _ref, _item$num;
|
|
52
|
+
return Number((_ref = (_item$num = item.num) !== null && _item$num !== void 0 ? _item$num : item.product_quantity) !== null && _ref !== void 0 ? _ref : 0);
|
|
53
|
+
};
|
|
54
|
+
var _iterator = _createForOfIteratorHelper(groups),
|
|
55
|
+
_step;
|
|
56
|
+
try {
|
|
57
|
+
var _loop = function _loop() {
|
|
58
|
+
var _previous$products$fi;
|
|
59
|
+
var group = _step.value;
|
|
60
|
+
var items = order.products.filter(function (item) {
|
|
61
|
+
return productVoucherGroupKey(order, item) === group.key;
|
|
62
|
+
});
|
|
63
|
+
var selected = items.reduce(function (sum, item) {
|
|
64
|
+
return sum + quantity(item);
|
|
65
|
+
}, 0);
|
|
66
|
+
var before = (_previous$products$fi = previous === null || previous === void 0 ? void 0 : previous.products.filter(function (item) {
|
|
67
|
+
return productVoucherGroupKey(previous, item) === group.key;
|
|
68
|
+
}).reduce(function (sum, item) {
|
|
69
|
+
return sum + quantity(item);
|
|
70
|
+
}, 0)) !== null && _previous$products$fi !== void 0 ? _previous$products$fi : 0;
|
|
71
|
+
if (!requireCoverage && previous && selected <= before) return 0; // continue
|
|
72
|
+
var ids = new Set(group.discountIds.map(String).filter(function (id) {
|
|
73
|
+
return byId.has(id);
|
|
74
|
+
}));
|
|
75
|
+
if (!Number.isInteger(selected) || selected < 0 || selected > ids.size) throw voucherGroupError();
|
|
76
|
+
if (!requireCoverage) return 0; // continue
|
|
77
|
+
var _iterator2 = _createForOfIteratorHelper(items),
|
|
78
|
+
_step2;
|
|
79
|
+
try {
|
|
80
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
81
|
+
var _applied$0$discount$r, _applied$, _voucher$config;
|
|
82
|
+
var item = _step2.value;
|
|
83
|
+
var applied = (item.discount_list || []).filter(function (entry) {
|
|
84
|
+
return (entry.type || entry.tag) === 'good_pass';
|
|
85
|
+
});
|
|
86
|
+
// Rules splits a good_pass allocation into one physical line per instance.
|
|
87
|
+
var id = String((_applied$0$discount$r = (_applied$ = applied[0]) === null || _applied$ === void 0 || (_applied$ = _applied$.discount) === null || _applied$ === void 0 ? void 0 : _applied$.resource_id) !== null && _applied$0$discount$r !== void 0 ? _applied$0$discount$r : '');
|
|
88
|
+
var voucher = byId.get(id);
|
|
89
|
+
if (quantity(item) !== 1 || applied.length !== 1 || !ids.has(id) || !(voucher !== null && voucher !== void 0 && voucher.isAvailable) || ((_voucher$config = voucher.config) === null || _voucher$config === void 0 ? void 0 : _voucher$config.isAvailable) === false || usedIds.has(id)) throw voucherGroupError();
|
|
90
|
+
usedIds.add(id);
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
_iterator2.e(err);
|
|
94
|
+
} finally {
|
|
95
|
+
_iterator2.f();
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
_ret;
|
|
99
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
100
|
+
_ret = _loop();
|
|
101
|
+
if (_ret === 0) continue;
|
|
102
|
+
}
|
|
103
|
+
} catch (err) {
|
|
104
|
+
_iterator.e(err);
|
|
105
|
+
} finally {
|
|
106
|
+
_iterator.f();
|
|
107
|
+
}
|
|
108
|
+
if (order.products.some(function (item) {
|
|
109
|
+
return !groups.some(function (group) {
|
|
110
|
+
return group.key === productVoucherGroupKey(order, item);
|
|
111
|
+
});
|
|
112
|
+
})) {
|
|
113
|
+
throw voucherGroupError();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1219,7 +1219,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1219
1219
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1220
1220
|
*/
|
|
1221
1221
|
function normalizeSubmitProduct(product) {
|
|
1222
|
-
var _ref39, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1222
|
+
var _ref39, _submitProduct$bundle, _rawMetadata$pricing_, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1223
1223
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1224
1224
|
var _ref38 = product,
|
|
1225
1225
|
_runtimeUid = _ref38.unique_identification_number,
|
|
@@ -1253,6 +1253,17 @@ function normalizeSubmitProduct(product) {
|
|
|
1253
1253
|
cleanMetadata[key] = rawMetadata[key];
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
|
+
// Persist only an applied pricing snapshot, so reopening a saved order can
|
|
1257
|
+
// compare it with the latest catalog without reinterpreting legacy duration.
|
|
1258
|
+
var pricingMethod = (_rawMetadata$pricing_ = rawMetadata.pricing_method) === null || _rawMetadata$pricing_ === void 0 ? void 0 : _rawMetadata$pricing_.type;
|
|
1259
|
+
if (pricingMethod === 'duration_based' || pricingMethod === 'fixed_price') {
|
|
1260
|
+
cleanMetadata.pricing_method = {
|
|
1261
|
+
type: pricingMethod
|
|
1262
|
+
};
|
|
1263
|
+
if (pricingMethod === 'duration_based' && rawMetadata.duration) {
|
|
1264
|
+
cleanMetadata.duration = _objectSpread({}, rawMetadata.duration);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1256
1267
|
cleanMetadata.product_discount_difference = (_rawMetadata$product_ = rawMetadata.product_discount_difference) !== null && _rawMetadata$product_ !== void 0 ? _rawMetadata$product_ : '';
|
|
1257
1268
|
if (rawMetadata.price_breakdown) {
|
|
1258
1269
|
cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
|
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -42,6 +42,9 @@ export interface ProductSettlementOption extends Record<string, any> {
|
|
|
42
42
|
available: boolean;
|
|
43
43
|
disabled_reason?: string;
|
|
44
44
|
}
|
|
45
|
+
export interface ProductPricingMethod {
|
|
46
|
+
type: 'fixed_price' | 'duration_based';
|
|
47
|
+
}
|
|
45
48
|
/**
|
|
46
49
|
* 商品基本信息接口
|
|
47
50
|
*/
|
|
@@ -74,6 +77,8 @@ export interface ProductData {
|
|
|
74
77
|
sum_stock: number;
|
|
75
78
|
/** 商品价格 */
|
|
76
79
|
price: string;
|
|
80
|
+
/** POS booking pricing; missing configuration retains existing fixed pricing. */
|
|
81
|
+
pricing_method?: ProductPricingMethod;
|
|
77
82
|
/** 当前上下文解析出的可选结算货币 */
|
|
78
83
|
available_settlement_options?: ProductSettlementOption[];
|
|
79
84
|
/** 商品原价 */
|
|
@@ -99,7 +99,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
99
99
|
}, {
|
|
100
100
|
key: "updateOtherParams",
|
|
101
101
|
value: function updateOtherParams(params) {
|
|
102
|
+
var previousScope = this.otherParams.catalogScopeKey;
|
|
102
103
|
this.otherParams = params || {};
|
|
104
|
+
if (previousScope !== this.otherParams.catalogScopeKey && (previousScope || this.otherParams.catalogScopeKey)) {
|
|
105
|
+
this.store.list = [];
|
|
106
|
+
this.rawProductPriceSources.clear();
|
|
107
|
+
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
}, {
|
|
105
111
|
key: "storeChange",
|
|
@@ -155,12 +161,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
155
161
|
key: "loadProducts",
|
|
156
162
|
value: function () {
|
|
157
163
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
158
|
-
var
|
|
164
|
+
var _this2 = this,
|
|
165
|
+
_this$otherParams,
|
|
159
166
|
_this$otherParams$bus,
|
|
160
167
|
_this$otherParams2,
|
|
161
168
|
_this$otherParams3,
|
|
162
|
-
_this$otherParams4
|
|
163
|
-
_this2 = this;
|
|
169
|
+
_this$otherParams4;
|
|
164
170
|
var _ref,
|
|
165
171
|
_ref$category_ids,
|
|
166
172
|
category_ids,
|
|
@@ -182,6 +188,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
182
188
|
status,
|
|
183
189
|
strategy_context,
|
|
184
190
|
options,
|
|
191
|
+
scope,
|
|
192
|
+
assertScope,
|
|
185
193
|
userPlugin,
|
|
186
194
|
customer_id,
|
|
187
195
|
_userPlugin$get,
|
|
@@ -203,7 +211,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
203
211
|
case 0:
|
|
204
212
|
_ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
|
|
205
213
|
options = _args5.length > 1 ? _args5[1] : undefined;
|
|
206
|
-
|
|
214
|
+
scope = this.otherParams.catalogScopeKey;
|
|
215
|
+
assertScope = function assertScope() {
|
|
216
|
+
if (scope !== _this2.otherParams.catalogScopeKey) throw Object.assign(new Error('Product catalog context changed'), {
|
|
217
|
+
name: 'AbortError'
|
|
218
|
+
});
|
|
219
|
+
}; // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
207
220
|
// if (!schedule_ids?.length) {
|
|
208
221
|
// const schedule_ids_data = this.store.schedule
|
|
209
222
|
// .getScheduleListByIds(schedule_ids)
|
|
@@ -280,14 +293,20 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
280
293
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
281
294
|
while (1) switch (_context4.prev = _context4.next) {
|
|
282
295
|
case 0:
|
|
296
|
+
if (!(scope !== _this2.otherParams.catalogScopeKey)) {
|
|
297
|
+
_context4.next = 2;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
return _context4.abrupt("return");
|
|
301
|
+
case 2:
|
|
283
302
|
callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
|
|
284
303
|
if (Array.isArray(callbackList)) {
|
|
285
|
-
_context4.next =
|
|
304
|
+
_context4.next = 6;
|
|
286
305
|
break;
|
|
287
306
|
}
|
|
288
307
|
originalCallback(result);
|
|
289
308
|
return _context4.abrupt("return");
|
|
290
|
-
case
|
|
309
|
+
case 6:
|
|
291
310
|
if (!handledByOsServer) {
|
|
292
311
|
// Subscription callbacks may contain only changed products. Upsert
|
|
293
312
|
// their raw records without evicting other IDs from the scope.
|
|
@@ -300,15 +319,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
319
|
queryPayload: queryPayload,
|
|
301
320
|
handledByOsServer: handledByOsServer
|
|
302
321
|
});
|
|
303
|
-
|
|
322
|
+
assertScope();
|
|
323
|
+
_context4.next = 11;
|
|
304
324
|
return _this2.addProduct(products);
|
|
305
|
-
case
|
|
325
|
+
case 11:
|
|
306
326
|
originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
|
|
307
327
|
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
308
328
|
list: products
|
|
309
329
|
})
|
|
310
330
|
}));
|
|
311
|
-
case
|
|
331
|
+
case 12:
|
|
312
332
|
case "end":
|
|
313
333
|
return _context4.stop();
|
|
314
334
|
}
|
|
@@ -318,15 +338,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
318
338
|
return _ref2.apply(this, arguments);
|
|
319
339
|
};
|
|
320
340
|
}()) : undefined;
|
|
321
|
-
_context5.next =
|
|
341
|
+
_context5.next = 18;
|
|
322
342
|
return this.request.post("/product/query", queryPayload, {
|
|
323
343
|
osServer: true,
|
|
324
344
|
callback: subscriptionCallback,
|
|
325
345
|
subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
|
|
326
346
|
customToast: function customToast() {}
|
|
327
347
|
});
|
|
328
|
-
case
|
|
348
|
+
case 18:
|
|
329
349
|
productsData = _context5.sent;
|
|
350
|
+
assertScope();
|
|
330
351
|
if (!handledByOsServer && Array.isArray(productsData.data.list)) {
|
|
331
352
|
this.replaceRawProductQueryResult(productsData.data.list, product_ids);
|
|
332
353
|
}
|
|
@@ -348,7 +369,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
348
369
|
// }
|
|
349
370
|
this.addProduct(sortedList);
|
|
350
371
|
return _context5.abrupt("return", sortedList);
|
|
351
|
-
case
|
|
372
|
+
case 25:
|
|
352
373
|
case "end":
|
|
353
374
|
return _context5.stop();
|
|
354
375
|
}
|
|
@@ -9,6 +9,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
9
9
|
private store;
|
|
10
10
|
window: WindowPlugin;
|
|
11
11
|
private hooks;
|
|
12
|
+
private discountScope?;
|
|
13
|
+
setDiscountScope(scope: (product: any, discount: Discount) => boolean): void;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
16
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
@@ -60,10 +60,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
60
60
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
61
61
|
// WindowPlugin 实例
|
|
62
62
|
_defineProperty(_assertThisInitialized(_this), "hooks", void 0);
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "discountScope", void 0);
|
|
63
64
|
_this.hooks = {};
|
|
64
65
|
return _this;
|
|
65
66
|
}
|
|
66
67
|
_createClass(RulesModule, [{
|
|
68
|
+
key: "setDiscountScope",
|
|
69
|
+
value: function setDiscountScope(scope) {
|
|
70
|
+
this.discountScope = scope;
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
67
73
|
key: "initialize",
|
|
68
74
|
value: function () {
|
|
69
75
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -317,7 +323,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
317
323
|
_step;
|
|
318
324
|
try {
|
|
319
325
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
320
|
-
var
|
|
326
|
+
var _discount = _step.value;
|
|
321
327
|
var bookingTimes = productList.length ? productList.map(function (item) {
|
|
322
328
|
var product = _this3.hooks.getProduct(item);
|
|
323
329
|
return ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
@@ -327,7 +333,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
327
333
|
try {
|
|
328
334
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
329
335
|
var bookingTime = _step3.value;
|
|
330
|
-
var filteredList = filterDiscountListByBookingTime([
|
|
336
|
+
var filteredList = filterDiscountListByBookingTime([_discount], bookingTime);
|
|
331
337
|
if (filteredList.length === 0) {
|
|
332
338
|
return UnavailableReason.TimeLimit;
|
|
333
339
|
}
|
|
@@ -349,8 +355,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
349
355
|
_step2;
|
|
350
356
|
try {
|
|
351
357
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
352
|
-
var
|
|
353
|
-
var limitedData =
|
|
358
|
+
var _discount2 = _step2.value;
|
|
359
|
+
var limitedData = _discount2.limited_relation_product_data;
|
|
354
360
|
var hasApplicableProduct = false;
|
|
355
361
|
var _iterator4 = _createForOfIteratorHelper(productList),
|
|
356
362
|
_step4;
|
|
@@ -358,11 +364,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
358
364
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
359
365
|
var _limitedData$product_;
|
|
360
366
|
var item = _step4.value;
|
|
361
|
-
var
|
|
367
|
+
var _product = this.hooks.getProduct(item);
|
|
362
368
|
if (limitedData.type === 'product_all') {
|
|
363
369
|
hasApplicableProduct = true;
|
|
364
370
|
break;
|
|
365
|
-
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(
|
|
371
|
+
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(_product.id)) {
|
|
366
372
|
hasApplicableProduct = true;
|
|
367
373
|
break;
|
|
368
374
|
}
|
|
@@ -450,13 +456,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
450
456
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discountType !== null && discountType !== void 0 ? discountType : '');
|
|
451
457
|
};
|
|
452
458
|
var resolveReapplyBookingDiscountPercent = function resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount) {
|
|
453
|
-
var
|
|
459
|
+
var _discount3;
|
|
454
460
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
455
461
|
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
456
462
|
if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
|
|
457
463
|
return undefined;
|
|
458
464
|
}
|
|
459
|
-
var percent = Number((
|
|
465
|
+
var percent = Number((_discount3 = selectedDiscount.discount) === null || _discount3 === void 0 ? void 0 : _discount3.percent);
|
|
460
466
|
return Number.isFinite(percent) ? percent : undefined;
|
|
461
467
|
};
|
|
462
468
|
var editModeDiscount = [];
|
|
@@ -992,7 +998,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
992
998
|
|
|
993
999
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
994
1000
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
995
|
-
var _discount$config2,
|
|
1001
|
+
var _discount$config2, _product2, _product3, _product4, _flatItem$bundleItem, _flatItem$bundleItem2, _product5;
|
|
1002
|
+
if (_this5.discountScope && !_this5.discountScope(flatItem.originProduct, discount)) return false;
|
|
996
1003
|
if (((_discount$config2 = discount.config) === null || _discount$config2 === void 0 ? void 0 : _discount$config2.isAvailable) === false) return false;
|
|
997
1004
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
998
1005
|
var product;
|
|
@@ -1016,7 +1023,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1016
1023
|
}
|
|
1017
1024
|
|
|
1018
1025
|
// 编辑的商品使用了优惠券不可用
|
|
1019
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
1026
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
1020
1027
|
return d.id && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
1021
1028
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.discount_list) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem2 = flatItem.bundleItem) !== null && _flatItem$bundleItem2 !== void 0 && (_flatItem$bundleItem2 = _flatItem$bundleItem2.discount_list) !== null && _flatItem$bundleItem2 !== void 0 && _flatItem$bundleItem2.every(function (d) {
|
|
1022
1029
|
return d.id;
|
|
@@ -1037,7 +1044,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1037
1044
|
var limitedData = discount.limited_relation_product_data;
|
|
1038
1045
|
|
|
1039
1046
|
// 时间限制检查
|
|
1040
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
1047
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
1041
1048
|
if (!timeLimit) {
|
|
1042
1049
|
return false;
|
|
1043
1050
|
}
|
|
@@ -1267,7 +1274,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1267
1274
|
}
|
|
1268
1275
|
var isItemRewardProductDiscount = _this5.isItemRewardProductDiscount(product);
|
|
1269
1276
|
addModeDiscount.forEach(function (discount) {
|
|
1270
|
-
var
|
|
1277
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config5;
|
|
1271
1278
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
1272
1279
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
1273
1280
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
@@ -1275,14 +1282,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1275
1282
|
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
1276
1283
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
1277
1284
|
}, flatItem.originProduct, holders);
|
|
1278
|
-
var timeReason = getDiscountTimeUnavailableReason(discount, (((
|
|
1285
|
+
var timeReason = getDiscountTimeUnavailableReason(discount, (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss'));
|
|
1279
1286
|
var timeLimit = !timeReason;
|
|
1280
1287
|
// 是符合折扣的商品
|
|
1281
1288
|
var isProductInScope = limitedData.type === 'product_all' && limitedData.filter !== 1 || limitedData.type === 'product_all' && limitedData.filter === 1 && !limitedData.exclude_product_ids.includes(product.id) || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
1282
1289
|
var isLimitedProduct = isProductInScope && isHolderMatch;
|
|
1283
1290
|
|
|
1284
1291
|
// 编辑的商品 使用了优惠券不可用
|
|
1285
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
1292
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
|
|
1286
1293
|
return discount.id && ['entitlement_pass', 'good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
1287
1294
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem3 = flatItem.bundleItem) !== null && _flatItem$bundleItem3 !== void 0 && (_flatItem$bundleItem3 = _flatItem$bundleItem3.discount_list) !== null && _flatItem$bundleItem3 !== void 0 && _flatItem$bundleItem3.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem4 = flatItem.bundleItem) !== null && _flatItem$bundleItem4 !== void 0 && (_flatItem$bundleItem4 = _flatItem$bundleItem4.discount_list) !== null && _flatItem$bundleItem4 !== void 0 && _flatItem$bundleItem4.every(function (discount) {
|
|
1288
1295
|
return discount.id;
|
|
@@ -1402,7 +1409,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1402
1409
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
1403
1410
|
// 🔥 使用扁平化后的列表进行处理
|
|
1404
1411
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
1405
|
-
var
|
|
1412
|
+
var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis3, _product11;
|
|
1406
1413
|
// 获取商品数据
|
|
1407
1414
|
var product, originProduct;
|
|
1408
1415
|
if (flatItem.type === 'main') {
|
|
@@ -1426,8 +1433,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1426
1433
|
};
|
|
1427
1434
|
originProduct = flatItem.originProduct;
|
|
1428
1435
|
}
|
|
1429
|
-
var isPersistedProduct = ((
|
|
1430
|
-
var hasExistingWalletDiscount = ((_product$discount_lis3 = product.discount_list) === null || _product$discount_lis3 === void 0 ? void 0 : _product$discount_lis3.length) && ((
|
|
1436
|
+
var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
|
|
1437
|
+
var hasExistingWalletDiscount = ((_product$discount_lis3 = product.discount_list) === null || _product$discount_lis3 === void 0 ? void 0 : _product$discount_lis3.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
|
|
1431
1438
|
var _discount$id, _discount$discount4;
|
|
1432
1439
|
var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
|
|
1433
1440
|
var discountType = discount.tag || discount.type;
|
|
@@ -1449,6 +1456,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1449
1456
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1450
1457
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
1451
1458
|
var _product$discount_lis4;
|
|
1459
|
+
if (_this5.discountScope && !_this5.discountScope(originProduct, discount)) return false;
|
|
1452
1460
|
if (_this5.isItemRewardProductDiscount(product)) return false;
|
|
1453
1461
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
1454
1462
|
// 🔥 检查策略可用性(针对全额抵扣卡和折扣卡)
|
|
@@ -1567,14 +1575,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1567
1575
|
var isManualDiscount = false;
|
|
1568
1576
|
var isItemRewardProductDiscount = false;
|
|
1569
1577
|
if (flatItem.type === 'main') {
|
|
1570
|
-
var _product$discount_lis5, _product$discount_lis6,
|
|
1578
|
+
var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
|
|
1571
1579
|
// 主商品:判断自身是否手动折扣
|
|
1572
1580
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1573
1581
|
return item.type === 'product';
|
|
1574
1582
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1575
1583
|
var _ref23;
|
|
1576
1584
|
return !((_ref23 = item.discount_list || []) !== null && _ref23 !== void 0 && _ref23.length);
|
|
1577
|
-
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((
|
|
1585
|
+
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1578
1586
|
return item.type === 'product';
|
|
1579
1587
|
})));
|
|
1580
1588
|
isItemRewardProductDiscount = _this5.isItemRewardProductDiscount(product);
|
|
@@ -1683,8 +1691,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1683
1691
|
discount_list: isManualDiscount ? _this5.resolveDiscountListForManualOverride(product.discount_list) : _this5.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1684
1692
|
}))]);
|
|
1685
1693
|
} else {
|
|
1686
|
-
var _ref25, _product$_promotion$f,
|
|
1687
|
-
var total = product.inPromotion ? (_ref25 = (_product$_promotion$f = (
|
|
1694
|
+
var _ref25, _product$_promotion$f, _product13, _product$origin_total;
|
|
1695
|
+
var total = product.inPromotion ? (_ref25 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref25 !== void 0 ? _ref25 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1688
1696
|
var main_product_selling_price = product.price;
|
|
1689
1697
|
if ((product.discount_list || []).some(function (item) {
|
|
1690
1698
|
return item.type === 'promotion';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InventoryController, type CheckoutRuntimeSnapshot } from '../../inventory';
|
|
1
2
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
3
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
4
|
import { type LocalEftposFinalization } from '../../modules/Order/localEftposState';
|
|
@@ -52,6 +53,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
52
53
|
protected appPlugin: AppPlugin;
|
|
53
54
|
protected store: BaseSalesState;
|
|
54
55
|
protected otherParams: Record<string, any>;
|
|
56
|
+
getInventory(): InventoryController | undefined;
|
|
57
|
+
prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
|
|
55
58
|
protected cacheId: string | undefined;
|
|
56
59
|
/**
|
|
57
60
|
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
@@ -66,6 +69,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
66
69
|
request: RequestPlugin;
|
|
67
70
|
protected currentSalesDetail: ISalesDetail | null;
|
|
68
71
|
protected discountConfigCacheKey: string | null;
|
|
72
|
+
private discountConfigPrepareInFlight;
|
|
69
73
|
protected hasManualDiscountSelection: boolean;
|
|
70
74
|
private readonly reusedSharedSubModuleNames;
|
|
71
75
|
private paymentMethodsCache;
|
|
@@ -194,6 +198,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
194
198
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
195
199
|
*/
|
|
196
200
|
protected createSubModule(moduleName: string): Module | null;
|
|
201
|
+
private inventoryOrderHooks?;
|
|
197
202
|
protected getSubModuleHooks(moduleName: string): any;
|
|
198
203
|
/**
|
|
199
204
|
* 构造传给 BaseSales 子模块的完整运行态参数,保证初始化和后续同步语义一致。
|
|
@@ -231,7 +236,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
231
236
|
private isActiveVirtualSettlementOrder;
|
|
232
237
|
private isHistoricalVirtualSettlementOrder;
|
|
233
238
|
private syncAppDataToTempOrder;
|
|
239
|
+
private initialization?;
|
|
240
|
+
/** Hosts can await readiness without changing Core's synchronous registration API. */
|
|
241
|
+
whenInitialized(): Promise<void>;
|
|
234
242
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
243
|
+
private initializeSalesRuntime;
|
|
235
244
|
destroy(): Promise<void>;
|
|
236
245
|
/**
|
|
237
246
|
* 加载销售订单到统一 tempOrder 工作区。
|
|
@@ -340,7 +349,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
340
349
|
discountList: Discount[];
|
|
341
350
|
originalDiscountList?: Discount[];
|
|
342
351
|
}): Promise<void>;
|
|
343
|
-
scanPromotionCode(code: string, customerId?: number
|
|
352
|
+
scanPromotionCode(code: string, customerId?: number, options?: {
|
|
353
|
+
productVouchersOnly?: boolean;
|
|
354
|
+
}): Promise<BaseSalesScanCodeResult>;
|
|
344
355
|
setDiscountSelected(params: {
|
|
345
356
|
discountId: number;
|
|
346
357
|
isSelected: boolean;
|
|
@@ -524,7 +535,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
524
535
|
getQuotationCustomerScopeInfo(): BaseSalesQuotationCustomerScopeInfo;
|
|
525
536
|
private hasSmartPricingStrategies;
|
|
526
537
|
shouldRecalculateProductBookingPricesForContextChange(params: BaseSalesPriceRecalculationContextChange): boolean;
|
|
538
|
+
private resolveProductBookingPriceGroups;
|
|
527
539
|
calculateProductBookingPrices(paramsList: BaseSalesCalculateProductBookingPriceParams[]): Promise<BaseSalesProductBookingPriceResult[]>;
|
|
540
|
+
setProductVoucherGroups(groups: Array<{
|
|
541
|
+
key: string;
|
|
542
|
+
discountIds: Array<number | string>;
|
|
543
|
+
}>): void;
|
|
544
|
+
validateProductVoucherSelection(): void;
|
|
528
545
|
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
529
546
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
530
547
|
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<import("../../modules/Order/types").OrderProduct[]>;
|