@pisell/pisellos 2.2.260 → 2.2.262
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/dataVariant/adapter.d.ts +1 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +1 -6
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +23 -13
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +45 -2
- package/dist/modules/Order/index.js +1552 -926
- package/dist/modules/Order/types.d.ts +36 -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/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +8 -3
- package/dist/modules/Order/utils.js +136 -56
- package/dist/modules/Rules/index.d.ts +4 -10
- package/dist/modules/Rules/index.js +63 -12
- package/dist/modules/Rules/types.d.ts +12 -2
- 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 +8 -0
- package/dist/server/index.js +1365 -911
- package/dist/server/modules/order/index.d.ts +32 -7
- package/dist/server/modules/order/index.js +551 -464
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +384 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.d.ts +42 -2
- package/dist/solution/BaseSales/index.js +1416 -775
- package/dist/solution/BaseSales/types.d.ts +7 -1
- package/dist/solution/BaseSales/types.js +3 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +20 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +212 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -2
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +45 -2
- package/lib/modules/Order/index.js +720 -116
- package/lib/modules/Order/types.d.ts +36 -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/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +8 -3
- package/lib/modules/Order/utils.js +104 -18
- package/lib/modules/Rules/index.d.ts +4 -10
- package/lib/modules/Rules/index.js +61 -9
- package/lib/modules/Rules/types.d.ts +12 -2
- 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 +8 -0
- package/lib/server/index.js +336 -11
- package/lib/server/modules/order/index.d.ts +32 -7
- package/lib/server/modules/order/index.js +298 -189
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +21 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.d.ts +42 -2
- package/lib/solution/BaseSales/index.js +535 -108
- package/lib/solution/BaseSales/types.d.ts +7 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +134 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -42,10 +42,12 @@ export var DataVariantAdapter = /*#__PURE__*/function () {
|
|
|
42
42
|
orderType = businessData.orderType,
|
|
43
43
|
businessCode = businessData.businessCode,
|
|
44
44
|
customerId = businessData.customerId,
|
|
45
|
+
availableWalletIds = businessData.availableWalletIds,
|
|
45
46
|
custom = businessData.custom;
|
|
46
47
|
|
|
47
48
|
// customer_id 统一归一化为 number,避免 in 运算符因 string/number 不一致而误判
|
|
48
49
|
var normalizedCustomerId = this.normalizeCustomerId(customerId);
|
|
50
|
+
var normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds !== null && availableWalletIds !== void 0 ? availableWalletIds : custom === null || custom === void 0 ? void 0 : custom.available_wallet_ids);
|
|
49
51
|
var resolvedBusinessCode = businessCode || (custom === null || custom === void 0 ? void 0 : custom.business_code) || (custom === null || custom === void 0 ? void 0 : custom.businessCode) || '';
|
|
50
52
|
return {
|
|
51
53
|
entities: {
|
|
@@ -58,6 +60,8 @@ export var DataVariantAdapter = /*#__PURE__*/function () {
|
|
|
58
60
|
// snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
|
|
59
61
|
customer_id: normalizedCustomerId,
|
|
60
62
|
customerId: normalizedCustomerId,
|
|
63
|
+
available_wallet_ids: normalizedAvailableWalletIds,
|
|
64
|
+
availableWalletIds: normalizedAvailableWalletIds,
|
|
61
65
|
business_code: resolvedBusinessCode
|
|
62
66
|
}),
|
|
63
67
|
metadata: {
|
|
@@ -146,6 +150,17 @@ export var DataVariantAdapter = /*#__PURE__*/function () {
|
|
|
146
150
|
var parsed = Number(value);
|
|
147
151
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
148
152
|
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "normalizeNumberArray",
|
|
155
|
+
value: function normalizeNumberArray(value) {
|
|
156
|
+
if (!Array.isArray(value)) return [];
|
|
157
|
+
var ids = value.map(function (item) {
|
|
158
|
+
return Number(item);
|
|
159
|
+
}).filter(function (item) {
|
|
160
|
+
return Number.isFinite(item) && item > 0;
|
|
161
|
+
});
|
|
162
|
+
return Array.from(new Set(ids));
|
|
163
|
+
}
|
|
149
164
|
}]);
|
|
150
165
|
return DataVariantAdapter;
|
|
151
166
|
}();
|
|
@@ -64,6 +64,7 @@ export declare class DataVariantEvaluator {
|
|
|
64
64
|
private createEngine;
|
|
65
65
|
private evaluateScheduleMatch;
|
|
66
66
|
private evaluateMenuMatch;
|
|
67
|
+
private evaluateArrayIntersects;
|
|
67
68
|
private collectScheduleIdsFromStrategies;
|
|
68
69
|
private extractTimePointsFromSchedules;
|
|
69
70
|
private addDateTimePoint;
|
|
@@ -81,6 +82,7 @@ export declare class DataVariantEvaluator {
|
|
|
81
82
|
private flattenConditionRules;
|
|
82
83
|
private isConditionGroup;
|
|
83
84
|
private normalizeNumberArray;
|
|
85
|
+
private normalizeComparableArray;
|
|
84
86
|
private buildProductKey;
|
|
85
87
|
private toNumber;
|
|
86
88
|
}
|
|
@@ -416,6 +416,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
416
416
|
},
|
|
417
417
|
menu_match: function menu_match(fieldValue, compareValue) {
|
|
418
418
|
return _this3.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap);
|
|
419
|
+
},
|
|
420
|
+
array_intersects: function array_intersects(fieldValue, compareValue) {
|
|
421
|
+
return _this3.evaluateArrayIntersects(fieldValue, compareValue);
|
|
419
422
|
}
|
|
420
423
|
};
|
|
421
424
|
return new StrategyEngine({
|
|
@@ -457,6 +460,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
457
460
|
}
|
|
458
461
|
return false;
|
|
459
462
|
}
|
|
463
|
+
}, {
|
|
464
|
+
key: "evaluateArrayIntersects",
|
|
465
|
+
value: function evaluateArrayIntersects(fieldValue, compareValue) {
|
|
466
|
+
var fieldValues = this.normalizeComparableArray(fieldValue);
|
|
467
|
+
var compareValues = this.normalizeComparableArray(compareValue);
|
|
468
|
+
if (!fieldValues.length || !compareValues.length) return false;
|
|
469
|
+
var compareSet = new Set(compareValues);
|
|
470
|
+
return fieldValues.some(function (item) {
|
|
471
|
+
return compareSet.has(item);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
460
474
|
}, {
|
|
461
475
|
key: "collectScheduleIdsFromStrategies",
|
|
462
476
|
value: function collectScheduleIdsFromStrategies(strategyConfigs) {
|
|
@@ -738,6 +752,17 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
738
752
|
return item > 0;
|
|
739
753
|
});
|
|
740
754
|
}
|
|
755
|
+
}, {
|
|
756
|
+
key: "normalizeComparableArray",
|
|
757
|
+
value: function normalizeComparableArray(value) {
|
|
758
|
+
var list = Array.isArray(value) ? value : value == null || value === '' ? [] : [value];
|
|
759
|
+
var normalized = list.map(function (item) {
|
|
760
|
+
if (item == null || item === '') return '';
|
|
761
|
+
var parsed = Number(item);
|
|
762
|
+
return Number.isFinite(parsed) ? String(parsed) : String(item).trim();
|
|
763
|
+
}).filter(Boolean);
|
|
764
|
+
return Array.from(new Set(normalized));
|
|
765
|
+
}
|
|
741
766
|
}, {
|
|
742
767
|
key: "buildProductKey",
|
|
743
768
|
value: function buildProductKey(productId, variantId) {
|
|
@@ -274,9 +274,4 @@ export function runCustomerScopeDataVariantDemo() {
|
|
|
274
274
|
businessCode: 'venue'
|
|
275
275
|
};
|
|
276
276
|
return evaluator.resolveProducts(businessData);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// @ts-ignore
|
|
280
|
-
window.runDataVariantDemo = runDataVariantDemo;
|
|
281
|
-
// @ts-ignore
|
|
282
|
-
window.runCustomerScopeDataVariantDemo = runCustomerScopeDataVariantDemo;
|
|
277
|
+
}
|
|
@@ -102,6 +102,8 @@ export interface DataVariantBusinessData {
|
|
|
102
102
|
/** 当前业务编码,对应策略条件 field: business_code */
|
|
103
103
|
businessCode?: string;
|
|
104
104
|
customerId?: number | string;
|
|
105
|
+
/** 当前客户可用 wallet/pass id 合并列表,对应策略条件 field: available_wallet_ids */
|
|
106
|
+
availableWalletIds?: Array<number | string>;
|
|
105
107
|
custom?: Record<string, any>;
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
3
|
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); }
|
|
@@ -125,6 +121,10 @@ function resolveProductTitle(product, booking, sourceProduct) {
|
|
|
125
121
|
var metadata = product.metadata || {};
|
|
126
122
|
return (_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.name) !== null && _ref5 !== void 0 ? _ref5 : metadata.product_title) !== null && _ref4 !== void 0 ? _ref4 : metadata.product_name) !== null && _ref3 !== void 0 ? _ref3 : booking === null || booking === void 0 || (_booking$product = booking.product) === null || _booking$product === void 0 ? void 0 : _booking$product.title) !== null && _ref2 !== void 0 ? _ref2 : booking === null || booking === void 0 || (_booking$detail = booking.detail) === null || _booking$detail === void 0 ? void 0 : _booking$detail.product_title) !== null && _ref !== void 0 ? _ref : '';
|
|
127
123
|
}
|
|
124
|
+
function resolveProductCover(product, booking, sourceProduct) {
|
|
125
|
+
var _ref6, _cover;
|
|
126
|
+
return (_ref6 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref6 !== void 0 ? _ref6 : '';
|
|
127
|
+
}
|
|
128
128
|
function resolveMainProductPrice(product, fallback) {
|
|
129
129
|
var _metadata$main_produc;
|
|
130
130
|
var metadata = product.metadata || {};
|
|
@@ -132,6 +132,14 @@ function resolveMainProductPrice(product, fallback) {
|
|
|
132
132
|
var parsed = Number(value);
|
|
133
133
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
134
134
|
}
|
|
135
|
+
function mapOrderBundleToOtherBundle(bundle) {
|
|
136
|
+
return bundle.map(function (item) {
|
|
137
|
+
var _ref7, _item$original_price;
|
|
138
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
139
|
+
original_price: (_ref7 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : item.price
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
135
143
|
|
|
136
144
|
/**
|
|
137
145
|
* catalog 缺 product_resource 时,从 booking.resources 反推最小 product_resource 结构,
|
|
@@ -159,10 +167,10 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
159
167
|
});
|
|
160
168
|
if (relationIdsByForm.size === 0) return undefined;
|
|
161
169
|
return {
|
|
162
|
-
resources: Array.from(relationIdsByForm.entries()).map(function (
|
|
163
|
-
var
|
|
164
|
-
formId =
|
|
165
|
-
relationIds =
|
|
170
|
+
resources: Array.from(relationIdsByForm.entries()).map(function (_ref8) {
|
|
171
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
172
|
+
formId = _ref9[0],
|
|
173
|
+
relationIds = _ref9[1];
|
|
166
174
|
return {
|
|
167
175
|
id: formId,
|
|
168
176
|
status: 1,
|
|
@@ -182,7 +190,7 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
182
190
|
* 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
|
|
183
191
|
*/
|
|
184
192
|
export function buildCacheItemFromOrderLine(input) {
|
|
185
|
-
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num,
|
|
193
|
+
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref12, _booking$id;
|
|
186
194
|
var product = input.product,
|
|
187
195
|
booking = input.booking,
|
|
188
196
|
sourceProduct = input.sourceProduct;
|
|
@@ -198,11 +206,12 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
198
206
|
var capacity = resolveCapacityFromBooking(booking);
|
|
199
207
|
var holderId = (_booking$metadata$hol = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
|
|
200
208
|
var productTitle = resolveProductTitle(product, booking, sourceProduct);
|
|
209
|
+
var productCover = resolveProductCover(product, booking, sourceProduct);
|
|
201
210
|
var productOptionString = buildProductOptionStringFromOrderLine(product);
|
|
202
211
|
var other = {
|
|
203
212
|
product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
|
|
204
213
|
option: getProductSkuOptions(product),
|
|
205
|
-
bundle: Array.isArray(product.product_bundle) ?
|
|
214
|
+
bundle: mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [])
|
|
206
215
|
};
|
|
207
216
|
var extend = _objectSpread({
|
|
208
217
|
start_date: startDate ? dayjs(startDate) : undefined,
|
|
@@ -215,7 +224,8 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
215
224
|
sub_type: booking.sub_type,
|
|
216
225
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
|
|
217
226
|
product_name: productTitle,
|
|
218
|
-
|
|
227
|
+
product_cover: productCover,
|
|
228
|
+
note: (_ref10 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref10 !== void 0 ? _ref10 : '',
|
|
219
229
|
price: mainProductPrice,
|
|
220
230
|
total: selling,
|
|
221
231
|
origin_total: original,
|
|
@@ -250,7 +260,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
250
260
|
var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
251
261
|
id: resolvedId,
|
|
252
262
|
product_id: resolvedId,
|
|
253
|
-
extension_type: (
|
|
263
|
+
extension_type: (_ref11 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
|
|
254
264
|
title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
|
|
255
265
|
price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
|
|
256
266
|
selling_price: product.selling_price,
|
|
@@ -262,7 +272,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
262
272
|
new: 0,
|
|
263
273
|
autoClose: false,
|
|
264
274
|
order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
|
|
265
|
-
booking_id: (
|
|
275
|
+
booking_id: (_ref12 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref12 !== void 0 ? _ref12 : 0
|
|
266
276
|
});
|
|
267
277
|
if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
|
|
268
278
|
base.capacity = sourceProduct.capacity;
|
|
@@ -75,7 +75,7 @@ function mapOrderBundleToOtherBundle(bundle) {
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
export function buildNormalProductCacheItemFromOrderLine(input) {
|
|
78
|
-
var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _price3, _product$order_detail;
|
|
78
|
+
var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _ref7, _cover, _price3, _product$order_detail;
|
|
79
79
|
var product = input.product,
|
|
80
80
|
sourceProduct = input.sourceProduct;
|
|
81
81
|
var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
|
|
@@ -132,6 +132,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
132
132
|
product_id: resolvedId,
|
|
133
133
|
_id: uid,
|
|
134
134
|
title: (_ref6 = (_title2 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title2 !== void 0 ? _title2 : product.product_title) !== null && _ref6 !== void 0 ? _ref6 : '',
|
|
135
|
+
cover: (_ref7 = (_cover = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover) !== null && _cover !== void 0 ? _cover : product.product_cover) !== null && _ref7 !== void 0 ? _ref7 : '',
|
|
135
136
|
price: (_price3 = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price3 !== void 0 ? _price3 : sourcePrice,
|
|
136
137
|
selling_price: product.selling_price,
|
|
137
138
|
original_price: product.original_price
|
|
@@ -48,7 +48,7 @@ export interface BookingResourceInput {
|
|
|
48
48
|
capacity?: number;
|
|
49
49
|
like_status?: string;
|
|
50
50
|
metadata?: Record<string, any>;
|
|
51
|
-
children?:
|
|
51
|
+
children?: BookingResourceInput[];
|
|
52
52
|
}
|
|
53
53
|
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
54
54
|
export interface BookingCapacityMetadataItem {
|
|
@@ -76,6 +76,33 @@ function resolveDurationMinutes(value) {
|
|
|
76
76
|
return Number.isNaN(n) ? undefined : n;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* 将组合资源子项收敛为 checkout resources 协议。
|
|
81
|
+
*
|
|
82
|
+
* resourcesOriginMap 中的子资源是 UI 运行态结构,通常只有 id / main_field / form_id,
|
|
83
|
+
* 不保证携带后端必填的 relation_type。这里不能原样透传,否则会触发
|
|
84
|
+
* `bookings.*.resources.*.children.*.relation_type` 校验错误。
|
|
85
|
+
*/
|
|
86
|
+
function normalizeChildResource(child, parentFormId) {
|
|
87
|
+
var _child$form_id, _child$relation_id;
|
|
88
|
+
var item = {
|
|
89
|
+
form_id: (_child$form_id = child === null || child === void 0 ? void 0 : child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : parentFormId,
|
|
90
|
+
relation_type: (child === null || child === void 0 ? void 0 : child.relation_type) || 'form',
|
|
91
|
+
relation_id: (_child$relation_id = child === null || child === void 0 ? void 0 : child.relation_id) !== null && _child$relation_id !== void 0 ? _child$relation_id : child === null || child === void 0 ? void 0 : child.id,
|
|
92
|
+
capacity: child === null || child === void 0 ? void 0 : child.capacity,
|
|
93
|
+
like_status: (child === null || child === void 0 ? void 0 : child.like_status) || 'common'
|
|
94
|
+
};
|
|
95
|
+
if ((child === null || child === void 0 ? void 0 : child.metadata) !== undefined) {
|
|
96
|
+
item.metadata = _objectSpread({}, child.metadata);
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(child === null || child === void 0 ? void 0 : child.children)) {
|
|
99
|
+
item.children = child.children.map(function (nestedChild) {
|
|
100
|
+
return normalizeChildResource(nestedChild, item.form_id);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return item;
|
|
104
|
+
}
|
|
105
|
+
|
|
79
106
|
/**
|
|
80
107
|
* cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
|
|
81
108
|
* 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
|
|
@@ -101,7 +128,11 @@ function flattenResources(cacheItem) {
|
|
|
101
128
|
// 协议允许 metadata 自由透传;为了与 info2 行为等价,把 form_name / resource_name / combined_resource 一并保留。
|
|
102
129
|
item.metadata = _objectSpread({}, r.metadata);
|
|
103
130
|
}
|
|
104
|
-
if ((r === null || r === void 0 ? void 0 : r.children)
|
|
131
|
+
if (Array.isArray(r === null || r === void 0 ? void 0 : r.children)) {
|
|
132
|
+
item.children = r.children.map(function (child) {
|
|
133
|
+
return normalizeChildResource(child, item.form_id);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
105
136
|
result.push(item);
|
|
106
137
|
});
|
|
107
138
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason, DiscountPrepareConfigResult } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -16,15 +16,18 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
16
16
|
getDiscountList(): Discount[];
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
|
+
private normalizePositiveNumberIds;
|
|
19
20
|
loadPrepareConfig(params: {
|
|
20
21
|
action?: 'create' | 'edit';
|
|
21
22
|
with_good_pass: 0 | 1;
|
|
22
23
|
with_discount_card: 0 | 1;
|
|
23
24
|
customer_id: number;
|
|
24
25
|
with_wallet_pass_holder: 0 | 1;
|
|
26
|
+
with_available_wallet_flag?: 0 | 1;
|
|
27
|
+
with_available_wallet_pass_flag?: 0 | 1;
|
|
25
28
|
request_timezone: string;
|
|
26
29
|
order_id?: number | string;
|
|
27
|
-
}): Promise<
|
|
30
|
+
}): Promise<DiscountPrepareConfigResult>;
|
|
28
31
|
batchSearch(code: string, options?: {
|
|
29
32
|
customerId?: number;
|
|
30
33
|
orderId?: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
4
|
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); }
|
|
7
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
7
|
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; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -151,12 +151,22 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
151
151
|
value: function getOriginalDiscountList() {
|
|
152
152
|
return this.store.originalDiscountList || [];
|
|
153
153
|
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "normalizePositiveNumberIds",
|
|
156
|
+
value: function normalizePositiveNumberIds(values) {
|
|
157
|
+
var ids = values.map(function (value) {
|
|
158
|
+
return Number(value);
|
|
159
|
+
}).filter(function (value) {
|
|
160
|
+
return Number.isFinite(value) && value > 0;
|
|
161
|
+
});
|
|
162
|
+
return Array.from(new Set(ids));
|
|
163
|
+
}
|
|
154
164
|
}, {
|
|
155
165
|
key: "loadPrepareConfig",
|
|
156
166
|
value: function () {
|
|
157
167
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
158
|
-
var _prepareConfig$data, _prepareConfig$data2;
|
|
159
|
-
var prepareConfig, rawDiscountList, goodPassList;
|
|
168
|
+
var _params$with_availabl, _params$with_availabl2, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
|
|
169
|
+
var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, goodPassList;
|
|
160
170
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
161
171
|
while (1) switch (_context4.prev = _context4.next) {
|
|
162
172
|
case 0:
|
|
@@ -164,13 +174,26 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
164
174
|
params.order_id = undefined;
|
|
165
175
|
}
|
|
166
176
|
_context4.next = 3;
|
|
167
|
-
return this.request.post("/order/prepare/config", params)
|
|
177
|
+
return this.request.post("/order/prepare/config", _objectSpread(_objectSpread({}, params), {}, {
|
|
178
|
+
with_available_wallet_flag: (_params$with_availabl = params.with_available_wallet_flag) !== null && _params$with_availabl !== void 0 ? _params$with_availabl : 1,
|
|
179
|
+
with_available_wallet_pass_flag: (_params$with_availabl2 = params.with_available_wallet_pass_flag) !== null && _params$with_availabl2 !== void 0 ? _params$with_availabl2 : 1
|
|
180
|
+
}));
|
|
168
181
|
case 3:
|
|
169
182
|
prepareConfig = _context4.sent;
|
|
170
183
|
rawDiscountList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []));
|
|
184
|
+
availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.available_wallet_list) || []));
|
|
185
|
+
availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_pass_list) || [];
|
|
186
|
+
availableWalletIds = this.normalizePositiveNumberIds([].concat(_toConsumableArray(availableWalletList.map(function (item) {
|
|
187
|
+
return item === null || item === void 0 ? void 0 : item.wallet_id;
|
|
188
|
+
})), _toConsumableArray(availableWalletPassList.map(function (item) {
|
|
189
|
+
return item === null || item === void 0 ? void 0 : item.product_id;
|
|
190
|
+
}))));
|
|
171
191
|
goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
|
|
172
|
-
return _context4.abrupt("return",
|
|
173
|
-
|
|
192
|
+
return _context4.abrupt("return", {
|
|
193
|
+
discountList: goodPassList,
|
|
194
|
+
availableWalletIds: availableWalletIds
|
|
195
|
+
});
|
|
196
|
+
case 10:
|
|
174
197
|
case "end":
|
|
175
198
|
return _context4.stop();
|
|
176
199
|
}
|
|
@@ -68,6 +68,10 @@ export interface DiscountWithReason {
|
|
|
68
68
|
discountList: Discount[];
|
|
69
69
|
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
70
70
|
}
|
|
71
|
+
export interface DiscountPrepareConfigResult {
|
|
72
|
+
discountList: Discount[];
|
|
73
|
+
availableWalletIds: number[];
|
|
74
|
+
}
|
|
71
75
|
interface ExtensionData {
|
|
72
76
|
id: number;
|
|
73
77
|
shop_id: number;
|
|
@@ -75,6 +75,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
75
75
|
apply?: boolean;
|
|
76
76
|
}): Promise<Discount[]>;
|
|
77
77
|
getDiscountList(): Discount[];
|
|
78
|
+
getAvailableWalletIds(): number[];
|
|
79
|
+
private syncScannedDiscountsToOriginalDiscountList;
|
|
78
80
|
private ensureEditDiscountConfigForProductChange;
|
|
79
81
|
scanCode(code: string, customerId?: number): Promise<{
|
|
80
82
|
isAvailable: boolean;
|
|
@@ -84,7 +86,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
84
86
|
unavailableReasonKey?: string | null;
|
|
85
87
|
scannedDiscountList?: Discount[];
|
|
86
88
|
}>;
|
|
87
|
-
applyDiscount(
|
|
89
|
+
applyDiscount(options?: {
|
|
90
|
+
reapplyBookingDiscountProductUids?: string[];
|
|
91
|
+
}): void;
|
|
88
92
|
/**
|
|
89
93
|
* 注入促销评估器。
|
|
90
94
|
*
|
|
@@ -152,12 +156,24 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
152
156
|
private extractOrderIdFromSubmitResult;
|
|
153
157
|
private calculatePaymentEffectiveAmount;
|
|
154
158
|
private calculatePaymentTotal;
|
|
159
|
+
private calculateOrderPaidPaymentTotal;
|
|
155
160
|
private getDepositAmount;
|
|
156
161
|
private normalizeDepositAmount;
|
|
162
|
+
private getLastOrderDepositSnapshot;
|
|
163
|
+
private getLastOrderSubmitSnapshot;
|
|
157
164
|
private applyDepositAmountToSummary;
|
|
165
|
+
private applyLastOrderDepositSnapshot;
|
|
158
166
|
private isDepositOrder;
|
|
159
167
|
private getOrderExpectedAmount;
|
|
160
168
|
private isDepositCovered;
|
|
169
|
+
getPaymentCompletion(payments?: OrderPaymentSource[]): {
|
|
170
|
+
isFullyPaid: boolean;
|
|
171
|
+
isOrderFullyPaid: boolean;
|
|
172
|
+
isDepositFullyPaid: boolean;
|
|
173
|
+
paymentStage: 'deposit' | 'normal';
|
|
174
|
+
depositAmount: string;
|
|
175
|
+
orderExpectedAmount: string;
|
|
176
|
+
};
|
|
161
177
|
private calculateDepositPaidAmount;
|
|
162
178
|
private resolveNextOrderPaymentType;
|
|
163
179
|
private normalizePaymentSource;
|
|
@@ -169,6 +185,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
169
185
|
private calculatePaidPaymentSummary;
|
|
170
186
|
private calculatePaymentServiceFee;
|
|
171
187
|
private calculatePaymentGapAmount;
|
|
188
|
+
private calculatePaymentOrderAmount;
|
|
172
189
|
private calculatePaymentRoundingAmount;
|
|
173
190
|
private formatSummaryMetadataMoney;
|
|
174
191
|
private syncSummaryProductMetadata;
|
|
@@ -186,6 +203,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
186
203
|
private clearManualDepositOverride;
|
|
187
204
|
private getOriginalSalesSnapshot;
|
|
188
205
|
private isSnapshotPayableAmountUnchanged;
|
|
206
|
+
private hasShopDiscountChangedFromSnapshot;
|
|
189
207
|
private restoreOriginalSnapshotIfProductsUnchanged;
|
|
190
208
|
private clearPersistedAmountFieldsForFullRecalc;
|
|
191
209
|
private getPaymentTargetAmount;
|
|
@@ -219,6 +237,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
219
237
|
* const ids = this.collectBookingHolderRecords(booking);
|
|
220
238
|
*/
|
|
221
239
|
private collectBookingHolderRecords;
|
|
240
|
+
private setProductHolderFromBooking;
|
|
241
|
+
private syncLinkedBookingHoldersToProducts;
|
|
222
242
|
/**
|
|
223
243
|
* 按 form_record 顺序读取 booking holder 的主字段名称。
|
|
224
244
|
*
|
|
@@ -260,6 +280,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
260
280
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
261
281
|
private buildTempOrderCustomer;
|
|
262
282
|
private isCustomerBoundDiscount;
|
|
283
|
+
private shouldKeepCustomerBoundDiscountAfterCustomerChange;
|
|
263
284
|
private productHasCustomerBoundDiscount;
|
|
264
285
|
private shouldSkipDiscountCalculation;
|
|
265
286
|
private clearCustomerBoundDiscounts;
|
|
@@ -301,13 +322,27 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
301
322
|
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
|
|
302
323
|
/** 从当前订单支付项中移除指定支付项。 */
|
|
303
324
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
325
|
+
private confirmPendingVoucherPaymentsInList;
|
|
326
|
+
private discardPendingVoucherPaymentsFromList;
|
|
327
|
+
private prepareVoucherPaymentsForSubmit;
|
|
328
|
+
private applyPaymentLifecycleChange;
|
|
329
|
+
confirmPendingVoucherPayments(options?: {
|
|
330
|
+
persist?: boolean;
|
|
331
|
+
recalculateSummary?: boolean;
|
|
332
|
+
}): OrderPaymentData[];
|
|
333
|
+
discardPendingVoucherPayments(options?: {
|
|
334
|
+
persist?: boolean;
|
|
335
|
+
recalculateSummary?: boolean;
|
|
336
|
+
}): OrderPaymentData[];
|
|
304
337
|
/**
|
|
305
338
|
* 覆盖当前订单中的 wallet pass 支付项。
|
|
306
339
|
*
|
|
307
340
|
* 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
|
|
308
341
|
* 视为 wallet pass;其它支付项保持不变。
|
|
309
342
|
*/
|
|
310
|
-
updateVoucherOrderPayments(payments: OrderPaymentSource[]
|
|
343
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
344
|
+
status?: 'paid' | 'payment_pending';
|
|
345
|
+
}): OrderPaymentData[];
|
|
311
346
|
private shouldMergeProductToOrder;
|
|
312
347
|
private hasOrderProductLineNote;
|
|
313
348
|
/**
|
|
@@ -407,6 +442,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
407
442
|
payments?: OrderPaymentSource[];
|
|
408
443
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
409
444
|
smallTicketDataFlag?: number;
|
|
445
|
+
confirmPendingVoucherPayments?: boolean;
|
|
410
446
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
411
447
|
}): Promise<T>;
|
|
412
448
|
submitTempOrderAsync<T = any>(params?: {
|
|
@@ -418,6 +454,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
418
454
|
payments?: OrderPaymentSource[];
|
|
419
455
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
420
456
|
smallTicketDataFlag?: number;
|
|
457
|
+
confirmPendingVoucherPayments?: boolean;
|
|
421
458
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
422
459
|
}): Promise<T>;
|
|
423
460
|
private runSubmitTempOrder;
|
|
@@ -488,6 +525,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
488
525
|
* this.normalizeHydratedBookingHolder({ metadata: { holder: { form_record: [1] } } });
|
|
489
526
|
*/
|
|
490
527
|
private normalizeHydratedBookingHolder;
|
|
528
|
+
/**
|
|
529
|
+
* 匿名 booking 没有服务端行 ID 时,商品侧已有的 booking_uid 就是唯一可用的强引用。
|
|
530
|
+
* 在统一规范化生成 UUID 前先复用它;已落库 booking 仍按 schedule_event_id 派生稳定 UID。
|
|
531
|
+
*/
|
|
532
|
+
private seedAnonymousBookingUidsFromProducts;
|
|
491
533
|
private normalizeTempOrderForRuntime;
|
|
492
534
|
private hydrateLinkedBookingIdentity;
|
|
493
535
|
private pickHydratedDisplayText;
|
|
@@ -497,5 +539,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
497
539
|
private normalizeHydratedOrderProduct;
|
|
498
540
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
499
541
|
getOrderInfo(order_id: number): Promise<any>;
|
|
542
|
+
getVouchers(): any[];
|
|
500
543
|
}
|
|
501
544
|
export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|