@pisell/pisellos 0.0.560 → 0.0.561
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/type.d.ts +2 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +21 -1
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +16 -4
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.js +16 -15
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +52 -36
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +6 -6
- 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/type.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +11 -1
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.js +3 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +15 -3
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +1 -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) {
|
|
@@ -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
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
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,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;
|
|
@@ -22,9 +22,12 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
|
+
with_available_wallet_flag?: 0 | 1;
|
|
26
|
+
with_available_wallet_pass_flag?: 0 | 1;
|
|
25
27
|
request_timezone: string;
|
|
26
28
|
order_id?: number;
|
|
27
|
-
}): Promise<
|
|
29
|
+
}): Promise<DiscountPrepareConfigResult>;
|
|
30
|
+
private extractAvailableWalletIds;
|
|
28
31
|
batchSearch(code: string, options?: {
|
|
29
32
|
customerId?: number;
|
|
30
33
|
orderId?: number;
|
|
@@ -163,7 +163,10 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
163
163
|
case 2:
|
|
164
164
|
prepareConfig = _context4.sent;
|
|
165
165
|
goodPassList = this.filterEnabledDiscountList([].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) || []))) || []; // this.setDiscountList(goodPassList);
|
|
166
|
-
return _context4.abrupt("return",
|
|
166
|
+
return _context4.abrupt("return", {
|
|
167
|
+
discountList: goodPassList,
|
|
168
|
+
availableWalletIds: this.extractAvailableWalletIds(prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.data)
|
|
169
|
+
});
|
|
167
170
|
case 5:
|
|
168
171
|
case "end":
|
|
169
172
|
return _context4.stop();
|
|
@@ -175,6 +178,23 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
175
178
|
}
|
|
176
179
|
return loadPrepareConfig;
|
|
177
180
|
}()
|
|
181
|
+
}, {
|
|
182
|
+
key: "extractAvailableWalletIds",
|
|
183
|
+
value: function extractAvailableWalletIds(data) {
|
|
184
|
+
var availableWalletList = Array.isArray(data === null || data === void 0 ? void 0 : data.avaiable_wallet_list) ? data.avaiable_wallet_list : Array.isArray(data === null || data === void 0 ? void 0 : data.available_wallet_list) ? data.available_wallet_list : [];
|
|
185
|
+
var availableWalletPassList = Array.isArray(data === null || data === void 0 ? void 0 : data.available_wallet_pass_list) ? data.available_wallet_pass_list : [];
|
|
186
|
+
var walletIds = availableWalletList.map(function (item) {
|
|
187
|
+
return Number(item === null || item === void 0 ? void 0 : item.id);
|
|
188
|
+
}).filter(function (id) {
|
|
189
|
+
return Number.isFinite(id) && id > 0;
|
|
190
|
+
});
|
|
191
|
+
var walletPassProductIds = availableWalletPassList.map(function (item) {
|
|
192
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id);
|
|
193
|
+
}).filter(function (id) {
|
|
194
|
+
return Number.isFinite(id) && id > 0;
|
|
195
|
+
});
|
|
196
|
+
return Array.from(new Set([].concat(_toConsumableArray(walletIds), _toConsumableArray(walletPassProductIds))));
|
|
197
|
+
}
|
|
178
198
|
}, {
|
|
179
199
|
key: "batchSearch",
|
|
180
200
|
value: function () {
|
|
@@ -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;
|
|
@@ -42,6 +42,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
42
42
|
action?: 'create';
|
|
43
43
|
}): Promise<void>;
|
|
44
44
|
getDiscountList(): Discount[];
|
|
45
|
+
getAvailableWalletIds(): number[];
|
|
45
46
|
scanCode(code: string, customerId?: number): Promise<{
|
|
46
47
|
isAvailable: boolean;
|
|
47
48
|
discountList: Discount[];
|
|
@@ -66,6 +66,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
66
66
|
if (!this.store.tempOrder) {
|
|
67
67
|
this.store.tempOrder = null;
|
|
68
68
|
}
|
|
69
|
+
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
70
|
+
this.store.availableWalletIds = [];
|
|
71
|
+
}
|
|
69
72
|
this.request = this.core.getPlugin('request');
|
|
70
73
|
this.window = this.core.getPlugin('window');
|
|
71
74
|
otherParams = options.otherParams || {};
|
|
@@ -81,7 +84,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
84
|
app = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp();
|
|
82
85
|
if (app) this.logger = app.logger;
|
|
83
86
|
this.logInfo('OrderModule initialized successfully');
|
|
84
|
-
case
|
|
87
|
+
case 17:
|
|
85
88
|
case "end":
|
|
86
89
|
return _context.stop();
|
|
87
90
|
}
|
|
@@ -182,7 +185,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
182
185
|
value: function () {
|
|
183
186
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
184
187
|
var _this$store$discount, _this$store$tempOrder;
|
|
185
|
-
var discountList, _this$store$discount2;
|
|
188
|
+
var prepareConfig, discountList, _this$store$discount2;
|
|
186
189
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
187
190
|
while (1) switch (_context2.prev = _context2.next) {
|
|
188
191
|
case 0:
|
|
@@ -193,17 +196,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
193
196
|
with_good_pass: 1,
|
|
194
197
|
with_discount_card: 1,
|
|
195
198
|
with_wallet_pass_holder: 1,
|
|
199
|
+
with_available_wallet_flag: 1,
|
|
200
|
+
with_available_wallet_pass_flag: 1,
|
|
196
201
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
197
202
|
});
|
|
198
203
|
case 2:
|
|
199
|
-
|
|
204
|
+
prepareConfig = _context2.sent;
|
|
205
|
+
discountList = prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.discountList;
|
|
206
|
+
this.store.availableWalletIds = (prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.availableWalletIds) || [];
|
|
200
207
|
if (discountList) {
|
|
201
208
|
(_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
|
|
202
209
|
}
|
|
203
210
|
if ((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.products) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length) {
|
|
204
211
|
this.applyDiscount();
|
|
205
212
|
}
|
|
206
|
-
case
|
|
213
|
+
case 7:
|
|
207
214
|
case "end":
|
|
208
215
|
return _context2.stop();
|
|
209
216
|
}
|
|
@@ -220,6 +227,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
220
227
|
var _this$store$discount3;
|
|
221
228
|
return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
|
|
222
229
|
}
|
|
230
|
+
}, {
|
|
231
|
+
key: "getAvailableWalletIds",
|
|
232
|
+
value: function getAvailableWalletIds() {
|
|
233
|
+
return this.store.availableWalletIds || [];
|
|
234
|
+
}
|
|
223
235
|
}, {
|
|
224
236
|
key: "scanCode",
|
|
225
237
|
value: function () {
|
|
@@ -15,6 +15,7 @@ export interface OrderState {
|
|
|
15
15
|
discountList: any[];
|
|
16
16
|
discount: DiscountModule | null;
|
|
17
17
|
rules: RulesModule | null;
|
|
18
|
+
availableWalletIds?: number[];
|
|
18
19
|
}
|
|
19
20
|
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
|
|
20
21
|
export interface UpdateProductInOrderParams {
|
|
@@ -250,5 +251,6 @@ export interface OrderModuleAPI {
|
|
|
250
251
|
action?: 'create';
|
|
251
252
|
}) => Promise<void>;
|
|
252
253
|
getDiscountList: () => Discount[];
|
|
254
|
+
getAvailableWalletIds: () => number[];
|
|
253
255
|
applyDiscount: () => void;
|
|
254
256
|
}
|
|
@@ -6,6 +6,11 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
6
6
|
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
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
8
|
import dayjs from "dayjs";
|
|
9
|
+
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
|
10
|
+
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
|
11
|
+
dayjs.extend(isSameOrAfter);
|
|
12
|
+
dayjs.extend(isSameOrBefore);
|
|
13
|
+
|
|
9
14
|
// 获取时间是否在日程范围内
|
|
10
15
|
export var getDateIsInSchedule = function getDateIsInSchedule(dateTime, scheduleList) {
|
|
11
16
|
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -800,7 +800,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
800
800
|
key: "loadPrepareConfig",
|
|
801
801
|
value: function () {
|
|
802
802
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
803
|
-
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
803
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, prepareConfig, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
804
804
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
805
805
|
while (1) switch (_context10.prev = _context10.next) {
|
|
806
806
|
case 0:
|
|
@@ -821,47 +821,48 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
821
821
|
order_id: orderId
|
|
822
822
|
} : {}));
|
|
823
823
|
case 5:
|
|
824
|
-
|
|
824
|
+
prepareConfig = _context10.sent;
|
|
825
|
+
goodPassList = (prepareConfig === null || prepareConfig === void 0 ? void 0 : prepareConfig.discountList) || [];
|
|
825
826
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
826
827
|
return item.isScan;
|
|
827
828
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
828
829
|
scanDiscountIds = scanDiscount.map(function (n) {
|
|
829
830
|
return n.id;
|
|
830
831
|
});
|
|
831
|
-
newGoodPassList = goodPassList
|
|
832
|
+
newGoodPassList = goodPassList.filter(function (n) {
|
|
832
833
|
return !scanDiscountIds.includes(n.id);
|
|
833
834
|
});
|
|
834
835
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
835
836
|
this.store.originalDiscountList = newDiscountList;
|
|
836
|
-
_context10.next =
|
|
837
|
+
_context10.next = 14;
|
|
837
838
|
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
838
|
-
case
|
|
839
|
+
case 14:
|
|
839
840
|
// 根据当前预约时间过滤优惠券列表
|
|
840
841
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
841
842
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
842
843
|
this.setDiscountList(filteredDiscountList || []);
|
|
843
844
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
844
|
-
_context10.next =
|
|
845
|
+
_context10.next = 21;
|
|
845
846
|
break;
|
|
846
847
|
}
|
|
847
848
|
_result3 = this.calcDiscount(this.store.productList);
|
|
848
|
-
_context10.next =
|
|
849
|
+
_context10.next = 21;
|
|
849
850
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
850
|
-
case
|
|
851
|
-
_context10.next =
|
|
851
|
+
case 21:
|
|
852
|
+
_context10.next = 23;
|
|
852
853
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
853
|
-
case
|
|
854
|
-
_context10.next =
|
|
854
|
+
case 23:
|
|
855
|
+
_context10.next = 28;
|
|
855
856
|
break;
|
|
856
|
-
case
|
|
857
|
-
_context10.prev =
|
|
857
|
+
case 25:
|
|
858
|
+
_context10.prev = 25;
|
|
858
859
|
_context10.t0 = _context10["catch"](0);
|
|
859
860
|
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
860
|
-
case
|
|
861
|
+
case 28:
|
|
861
862
|
case "end":
|
|
862
863
|
return _context10.stop();
|
|
863
864
|
}
|
|
864
|
-
}, _callee10, this, [[0,
|
|
865
|
+
}, _callee10, this, [[0, 25]]);
|
|
865
866
|
}));
|
|
866
867
|
function loadPrepareConfig(_x10) {
|
|
867
868
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -84,6 +84,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
84
84
|
private clearSlotPriceMapCache;
|
|
85
85
|
/** 读取当前登录 customerId */
|
|
86
86
|
private resolveCustomerIdForSmartPricing;
|
|
87
|
+
private resolveAvailableWalletIdsForSmartPricing;
|
|
87
88
|
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
88
89
|
private getScheduleListForSmartPricing;
|
|
89
90
|
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
@@ -501,32 +501,32 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
501
501
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
502
502
|
while (1) switch (_context5.prev = _context5.next) {
|
|
503
503
|
case 0:
|
|
504
|
+
_context5.next = 2;
|
|
505
|
+
return _this3.store.order.loadDiscountConfig({
|
|
506
|
+
customerId: params.customerId
|
|
507
|
+
});
|
|
508
|
+
case 2:
|
|
504
509
|
_this3.clearSlotPriceMapCache();
|
|
505
510
|
_this3.recalculateOrderPricesFromSmartPricing();
|
|
506
511
|
// 刷新 holder 表单数据
|
|
507
512
|
if (!_this3.store.holder) {
|
|
508
|
-
_context5.next =
|
|
513
|
+
_context5.next = 7;
|
|
509
514
|
break;
|
|
510
515
|
}
|
|
511
|
-
_context5.next =
|
|
516
|
+
_context5.next = 7;
|
|
512
517
|
return _this3.store.holder.refreshAllFormRecords({
|
|
513
518
|
customer_id: params.customerId,
|
|
514
519
|
useCache: false
|
|
515
520
|
});
|
|
516
|
-
case
|
|
521
|
+
case 7:
|
|
517
522
|
if (!_this3.store.quotation) {
|
|
518
|
-
_context5.next =
|
|
523
|
+
_context5.next = 10;
|
|
519
524
|
break;
|
|
520
525
|
}
|
|
521
|
-
_context5.next =
|
|
526
|
+
_context5.next = 10;
|
|
522
527
|
return _this3.store.quotation.loadQuotations({
|
|
523
528
|
channel: (_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.channel
|
|
524
529
|
});
|
|
525
|
-
case 8:
|
|
526
|
-
_context5.next = 10;
|
|
527
|
-
return _this3.store.order.loadDiscountConfig({
|
|
528
|
-
customerId: params.customerId
|
|
529
|
-
});
|
|
530
530
|
case 10:
|
|
531
531
|
_context5.next = 12;
|
|
532
532
|
return _this3.store.order.recalculateSummary({
|
|
@@ -970,6 +970,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
970
970
|
return undefined;
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
+
}, {
|
|
974
|
+
key: "resolveAvailableWalletIdsForSmartPricing",
|
|
975
|
+
value: function resolveAvailableWalletIdsForSmartPricing() {
|
|
976
|
+
var _this$store$order3, _this$store$order3$ge, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
|
|
977
|
+
var orderWalletIds = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getAvailableWalletIds) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
|
|
978
|
+
var fallbackWalletIds = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.available_wallet_ids) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.availableWalletIds) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 || (_this$otherParams11 = _this$otherParams11.strategy_context) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.available_wallet_ids) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12 = _this$otherParams12.strategy_context) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.availableWalletIds);
|
|
979
|
+
var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
980
|
+
if (!Array.isArray(source)) return [];
|
|
981
|
+
var ids = source.map(function (item) {
|
|
982
|
+
return Number(item);
|
|
983
|
+
}).filter(function (item) {
|
|
984
|
+
return Number.isFinite(item) && item > 0;
|
|
985
|
+
});
|
|
986
|
+
return Array.from(new Set(ids));
|
|
987
|
+
}
|
|
973
988
|
|
|
974
989
|
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
975
990
|
}, {
|
|
@@ -985,17 +1000,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
985
1000
|
}, {
|
|
986
1001
|
key: "buildSmartPricingContext",
|
|
987
1002
|
value: function buildSmartPricingContext(customerId) {
|
|
988
|
-
var _this$core5, _this$
|
|
1003
|
+
var _this$core5, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18, _this$otherParams19;
|
|
989
1004
|
var evaluator = (_this$core5 = this.core) === null || _this$core5 === void 0 || (_this$core5 = _this$core5.context) === null || _this$core5 === void 0 ? void 0 : _this$core5.dataVariantEvaluator;
|
|
990
1005
|
return {
|
|
991
1006
|
evaluator: evaluator,
|
|
992
1007
|
scheduleList: this.getScheduleListForSmartPricing(),
|
|
993
|
-
menuList: ((_this$
|
|
1008
|
+
menuList: ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.menuList) || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 || (_this$otherParams14 = _this$otherParams14.openData) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.menuList) || [],
|
|
994
1009
|
customerId: customerId !== null && customerId !== void 0 ? customerId : this.resolveCustomerIdForSmartPricing(),
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1010
|
+
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
1011
|
+
channel: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.channel,
|
|
1012
|
+
businessCode: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode,
|
|
1013
|
+
orderType: ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.orderType) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type),
|
|
1014
|
+
strategy_context: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.strategy_context
|
|
999
1015
|
};
|
|
1000
1016
|
}
|
|
1001
1017
|
|
|
@@ -1014,7 +1030,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1014
1030
|
key: "getSlotPriceMapCacheKey",
|
|
1015
1031
|
value: function getSlotPriceMapCacheKey(date, context) {
|
|
1016
1032
|
var _context$customerId, _context$channel, _context$businessCode;
|
|
1017
|
-
return [date, (_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '', (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : '', (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : ''].join('|');
|
|
1033
|
+
return [date, (_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '', (context.availableWalletIds || []).join(','), (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : '', (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : ''].join('|');
|
|
1018
1034
|
}
|
|
1019
1035
|
|
|
1020
1036
|
/**
|
|
@@ -1074,7 +1090,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1074
1090
|
key: "_doLoadAllProducts",
|
|
1075
1091
|
value: function () {
|
|
1076
1092
|
var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1077
|
-
var _this$
|
|
1093
|
+
var _this$otherParams20, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore, _this$store$order4, _this$store$order4$ge, products;
|
|
1078
1094
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1079
1095
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1080
1096
|
case 0:
|
|
@@ -1095,7 +1111,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
1111
|
_context12.next = 8;
|
|
1096
1112
|
return this.loadOpenDataConfig();
|
|
1097
1113
|
case 8:
|
|
1098
|
-
associatedMenus = ((_this$
|
|
1114
|
+
associatedMenus = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 || (_this$otherParams20 = _this$otherParams20.openData) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20['menu.associated_menus']) || [];
|
|
1099
1115
|
if (associatedMenus.length) {
|
|
1100
1116
|
_context12.next = 12;
|
|
1101
1117
|
break;
|
|
@@ -1141,7 +1157,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1141
1157
|
_context12.next = 31;
|
|
1142
1158
|
break;
|
|
1143
1159
|
}
|
|
1144
|
-
products = ((_this$store$
|
|
1160
|
+
products = ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getOrderProducts) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4)) || [];
|
|
1145
1161
|
_context12.next = 31;
|
|
1146
1162
|
return this.preloadHolderForms(products);
|
|
1147
1163
|
case 31:
|
|
@@ -1605,8 +1621,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1605
1621
|
}, {
|
|
1606
1622
|
key: "getSelectedSlotsForResource",
|
|
1607
1623
|
value: function getSelectedSlotsForResource(resourceId, productId) {
|
|
1608
|
-
var _this$store$
|
|
1609
|
-
var tempOrder = (_this$store$
|
|
1624
|
+
var _this$store$order5;
|
|
1625
|
+
var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
|
|
1610
1626
|
if (!tempOrder) return [];
|
|
1611
1627
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1612
1628
|
var _p$metadata, _p$metadata2;
|
|
@@ -1767,9 +1783,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1767
1783
|
}, {
|
|
1768
1784
|
key: "getAllSelectedSlots",
|
|
1769
1785
|
value: function getAllSelectedSlots() {
|
|
1770
|
-
var _this$store$
|
|
1786
|
+
var _this$store$order6;
|
|
1771
1787
|
var result = new Map();
|
|
1772
|
-
var tempOrder = (_this$store$
|
|
1788
|
+
var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
|
|
1773
1789
|
if (!tempOrder) return result;
|
|
1774
1790
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1775
1791
|
var _p$metadata3;
|
|
@@ -1829,7 +1845,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1829
1845
|
key: "reconcileOrderForResourceProduct",
|
|
1830
1846
|
value: (function () {
|
|
1831
1847
|
var _reconcileOrderForResourceProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(resourceId, productId, slots) {
|
|
1832
|
-
var _this$store$
|
|
1848
|
+
var _this$store$order7, _this$store$order7$ge;
|
|
1833
1849
|
var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, group, identityKey, bookingUuid, startMoment, endMoment, duration, customDepositData, resourceEntry, booking, products;
|
|
1834
1850
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1835
1851
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -1997,7 +2013,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2013
|
}
|
|
1998
2014
|
|
|
1999
2015
|
// 获取表单信息
|
|
2000
|
-
products = ((_this$store$
|
|
2016
|
+
products = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderProducts) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7)) || [];
|
|
2001
2017
|
_context18.next = 25;
|
|
2002
2018
|
return this.preloadHolderForms(products);
|
|
2003
2019
|
case 25:
|
|
@@ -2112,8 +2128,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2112
2128
|
}, {
|
|
2113
2129
|
key: "getTempOrder",
|
|
2114
2130
|
value: function getTempOrder() {
|
|
2115
|
-
var _this$store$
|
|
2116
|
-
var result = ((_this$store$
|
|
2131
|
+
var _this$store$order8;
|
|
2132
|
+
var result = ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder()) || null;
|
|
2117
2133
|
return result;
|
|
2118
2134
|
}
|
|
2119
2135
|
}, {
|
|
@@ -2589,7 +2605,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2589
2605
|
key: "submitOrder",
|
|
2590
2606
|
value: function () {
|
|
2591
2607
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2592
|
-
var _this$
|
|
2608
|
+
var _this$otherParams21, _this$otherParams22, _this$otherParams23, _this$otherParams24, _tempOrder$products2, result, tempOrder;
|
|
2593
2609
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2594
2610
|
while (1) switch (_context25.prev = _context25.next) {
|
|
2595
2611
|
case 0:
|
|
@@ -2607,10 +2623,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2607
2623
|
_context25.next = 8;
|
|
2608
2624
|
return this.store.order.submitTempOrder({
|
|
2609
2625
|
cacheId: this.cacheId,
|
|
2610
|
-
platform: (_this$
|
|
2611
|
-
businessCode: (_this$
|
|
2612
|
-
channel: (_this$
|
|
2613
|
-
type: (_this$
|
|
2626
|
+
platform: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform,
|
|
2627
|
+
businessCode: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode,
|
|
2628
|
+
channel: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.channel,
|
|
2629
|
+
type: (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.type
|
|
2614
2630
|
});
|
|
2615
2631
|
case 8:
|
|
2616
2632
|
result = _context25.sent;
|
|
@@ -2750,7 +2766,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2750
2766
|
key: "removeProductFromOrder",
|
|
2751
2767
|
value: function () {
|
|
2752
2768
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
2753
|
-
var _this$store$order$get3, _this$store$
|
|
2769
|
+
var _this$store$order$get3, _this$store$order9, _this$store$order$ens, _this$store$order10, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator17, _step17, _product$metadata7, _product$metadata8, product, beforeBookingCount, _this$store$order$per, _this$store$order11;
|
|
2754
2770
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2755
2771
|
while (1) switch (_context28.prev = _context28.next) {
|
|
2756
2772
|
case 0:
|
|
@@ -2765,7 +2781,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2765
2781
|
}
|
|
2766
2782
|
throw new Error('order 模块未初始化');
|
|
2767
2783
|
case 4:
|
|
2768
|
-
tempOrder = ((_this$store$order$get3 = (_this$store$
|
|
2784
|
+
tempOrder = ((_this$store$order$get3 = (_this$store$order9 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order9)) || ((_this$store$order$ens = (_this$store$order10 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order10));
|
|
2769
2785
|
_context28.next = 7;
|
|
2770
2786
|
return this.store.order.removeProductFromOrder(identity);
|
|
2771
2787
|
case 7:
|
|
@@ -2822,7 +2838,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2822
2838
|
return true;
|
|
2823
2839
|
});
|
|
2824
2840
|
if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
|
|
2825
|
-
(_this$store$order$per = (_this$store$
|
|
2841
|
+
(_this$store$order$per = (_this$store$order11 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order11);
|
|
2826
2842
|
}
|
|
2827
2843
|
case 33:
|
|
2828
2844
|
_context28.next = 35;
|
|
@@ -10,6 +10,7 @@ export interface VenueBookingSmartPricingContext {
|
|
|
10
10
|
scheduleList?: ScheduleItem[];
|
|
11
11
|
menuList?: DataVariantMenu[];
|
|
12
12
|
customerId?: number | string;
|
|
13
|
+
availableWalletIds?: Array<number | string>;
|
|
13
14
|
channel?: string;
|
|
14
15
|
businessCode?: string;
|
|
15
16
|
orderType?: string;
|
|
@@ -16,7 +16,7 @@ export function extractProductPrice(product) {
|
|
|
16
16
|
|
|
17
17
|
/** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
|
|
18
18
|
export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
19
|
-
var _context$channel,
|
|
19
|
+
var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
|
|
20
20
|
var strategyContext = context.strategy_context || {};
|
|
21
21
|
return {
|
|
22
22
|
products: products,
|
|
@@ -25,9 +25,10 @@ export function buildDataVariantBusinessData(products, context, scheduleDateTime
|
|
|
25
25
|
scheduleList: context.scheduleList || [],
|
|
26
26
|
menuList: context.menuList || [],
|
|
27
27
|
customerId: context.customerId,
|
|
28
|
+
availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
|
|
28
29
|
channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
|
|
29
|
-
orderType: (
|
|
30
|
-
businessCode: (
|
|
30
|
+
orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
|
|
31
|
+
businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
|
|
31
32
|
custom: strategyContext
|
|
32
33
|
};
|
|
33
34
|
}
|
|
@@ -44,7 +45,6 @@ export function formatProductsWithDataVariant(products, context, scheduleDateTim
|
|
|
44
45
|
}
|
|
45
46
|
var resolvedAt = scheduleDateTime || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
46
47
|
var businessData = buildDataVariantBusinessData(products, context, resolvedAt);
|
|
47
|
-
console.log(businessData, 'businessData');
|
|
48
48
|
var result = evaluator.resolveProducts(businessData);
|
|
49
49
|
return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
|
|
50
50
|
}
|
|
@@ -207,7 +207,7 @@ export function buildSlotPriceMapByScheduleSegments(params) {
|
|
|
207
207
|
* 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
|
|
208
208
|
*/
|
|
209
209
|
export function getPriceForProductAtDatetime(params) {
|
|
210
|
-
var
|
|
210
|
+
var _ref4, _extractProductPrice;
|
|
211
211
|
var products = params.products,
|
|
212
212
|
context = params.context,
|
|
213
213
|
productId = params.productId,
|
|
@@ -217,7 +217,7 @@ export function getPriceForProductAtDatetime(params) {
|
|
|
217
217
|
var product = resolved.find(function (item) {
|
|
218
218
|
return Number(item.id) === Number(productId);
|
|
219
219
|
});
|
|
220
|
-
return (
|
|
220
|
+
return (_ref4 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref4 !== void 0 ? _ref4 : '0.00';
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
|
|
@@ -47,9 +47,11 @@ var DataVariantAdapter = class {
|
|
|
47
47
|
orderType,
|
|
48
48
|
businessCode,
|
|
49
49
|
customerId,
|
|
50
|
+
availableWalletIds,
|
|
50
51
|
custom
|
|
51
52
|
} = businessData;
|
|
52
53
|
const normalizedCustomerId = this.normalizeCustomerId(customerId);
|
|
54
|
+
const normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds ?? (custom == null ? void 0 : custom.available_wallet_ids));
|
|
53
55
|
const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
|
|
54
56
|
return {
|
|
55
57
|
entities: {
|
|
@@ -63,6 +65,8 @@ var DataVariantAdapter = class {
|
|
|
63
65
|
// snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
|
|
64
66
|
customer_id: normalizedCustomerId,
|
|
65
67
|
customerId: normalizedCustomerId,
|
|
68
|
+
available_wallet_ids: normalizedAvailableWalletIds,
|
|
69
|
+
availableWalletIds: normalizedAvailableWalletIds,
|
|
66
70
|
business_code: resolvedBusinessCode
|
|
67
71
|
},
|
|
68
72
|
metadata: {
|
|
@@ -131,6 +135,12 @@ var DataVariantAdapter = class {
|
|
|
131
135
|
const parsed = Number(value);
|
|
132
136
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
133
137
|
}
|
|
138
|
+
normalizeNumberArray(value) {
|
|
139
|
+
if (!Array.isArray(value))
|
|
140
|
+
return [];
|
|
141
|
+
const ids = value.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
|
|
142
|
+
return Array.from(new Set(ids));
|
|
143
|
+
}
|
|
134
144
|
};
|
|
135
145
|
var adapter_default = DataVariantAdapter;
|
|
136
146
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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
|
}
|
|
@@ -346,7 +346,8 @@ var DataVariantEvaluator = class {
|
|
|
346
346
|
compareValue,
|
|
347
347
|
businessData.scheduleList || []
|
|
348
348
|
),
|
|
349
|
-
menu_match: (fieldValue, compareValue) => this.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap)
|
|
349
|
+
menu_match: (fieldValue, compareValue) => this.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap),
|
|
350
|
+
array_intersects: (fieldValue, compareValue) => this.evaluateArrayIntersects(fieldValue, compareValue)
|
|
350
351
|
};
|
|
351
352
|
return new import_engine.StrategyEngine({
|
|
352
353
|
debug: false,
|
|
@@ -379,6 +380,14 @@ var DataVariantEvaluator = class {
|
|
|
379
380
|
}
|
|
380
381
|
return false;
|
|
381
382
|
}
|
|
383
|
+
evaluateArrayIntersects(fieldValue, compareValue) {
|
|
384
|
+
const fieldValues = this.normalizeComparableArray(fieldValue);
|
|
385
|
+
const compareValues = this.normalizeComparableArray(compareValue);
|
|
386
|
+
if (!fieldValues.length || !compareValues.length)
|
|
387
|
+
return false;
|
|
388
|
+
const compareSet = new Set(compareValues);
|
|
389
|
+
return fieldValues.some((item) => compareSet.has(item));
|
|
390
|
+
}
|
|
382
391
|
collectScheduleIdsFromStrategies(strategyConfigs) {
|
|
383
392
|
const scheduleIds = /* @__PURE__ */ new Set();
|
|
384
393
|
for (const config of strategyConfigs) {
|
|
@@ -549,6 +558,16 @@ var DataVariantEvaluator = class {
|
|
|
549
558
|
return [];
|
|
550
559
|
return value.map((item) => this.toNumber(item)).filter((item) => item > 0);
|
|
551
560
|
}
|
|
561
|
+
normalizeComparableArray(value) {
|
|
562
|
+
const list = Array.isArray(value) ? value : value == null || value === "" ? [] : [value];
|
|
563
|
+
const normalized = list.map((item) => {
|
|
564
|
+
if (item == null || item === "")
|
|
565
|
+
return "";
|
|
566
|
+
const parsed = Number(item);
|
|
567
|
+
return Number.isFinite(parsed) ? String(parsed) : String(item).trim();
|
|
568
|
+
}).filter(Boolean);
|
|
569
|
+
return Array.from(new Set(normalized));
|
|
570
|
+
}
|
|
552
571
|
buildProductKey(productId, variantId) {
|
|
553
572
|
return `${productId}:${variantId}`;
|
|
554
573
|
}
|
|
@@ -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,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -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;
|
|
@@ -22,9 +22,12 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
|
+
with_available_wallet_flag?: 0 | 1;
|
|
26
|
+
with_available_wallet_pass_flag?: 0 | 1;
|
|
25
27
|
request_timezone: string;
|
|
26
28
|
order_id?: number;
|
|
27
|
-
}): Promise<
|
|
29
|
+
}): Promise<DiscountPrepareConfigResult>;
|
|
30
|
+
private extractAvailableWalletIds;
|
|
28
31
|
batchSearch(code: string, options?: {
|
|
29
32
|
customerId?: number;
|
|
30
33
|
orderId?: number;
|
|
@@ -100,7 +100,17 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
100
100
|
const goodPassList = this.filterEnabledDiscountList(
|
|
101
101
|
[...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
|
|
102
102
|
) || [];
|
|
103
|
-
return
|
|
103
|
+
return {
|
|
104
|
+
discountList: goodPassList,
|
|
105
|
+
availableWalletIds: this.extractAvailableWalletIds(prepareConfig == null ? void 0 : prepareConfig.data)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
extractAvailableWalletIds(data) {
|
|
109
|
+
const availableWalletList = Array.isArray(data == null ? void 0 : data.avaiable_wallet_list) ? data.avaiable_wallet_list : Array.isArray(data == null ? void 0 : data.available_wallet_list) ? data.available_wallet_list : [];
|
|
110
|
+
const availableWalletPassList = Array.isArray(data == null ? void 0 : data.available_wallet_pass_list) ? data.available_wallet_pass_list : [];
|
|
111
|
+
const walletIds = availableWalletList.map((item) => Number(item == null ? void 0 : item.id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
112
|
+
const walletPassProductIds = availableWalletPassList.map((item) => Number(item == null ? void 0 : item.product_id)).filter((id) => Number.isFinite(id) && id > 0);
|
|
113
|
+
return Array.from(/* @__PURE__ */ new Set([...walletIds, ...walletPassProductIds]));
|
|
104
114
|
}
|
|
105
115
|
async batchSearch(code, options) {
|
|
106
116
|
const { customerId, orderId } = options || {};
|
|
@@ -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;
|
|
@@ -42,6 +42,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
42
42
|
action?: 'create';
|
|
43
43
|
}): Promise<void>;
|
|
44
44
|
getDiscountList(): Discount[];
|
|
45
|
+
getAvailableWalletIds(): number[];
|
|
45
46
|
scanCode(code: string, customerId?: number): Promise<{
|
|
46
47
|
isAvailable: boolean;
|
|
47
48
|
discountList: Discount[];
|
|
@@ -76,6 +76,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
76
76
|
if (!this.store.tempOrder) {
|
|
77
77
|
this.store.tempOrder = null;
|
|
78
78
|
}
|
|
79
|
+
if (!Array.isArray(this.store.availableWalletIds)) {
|
|
80
|
+
this.store.availableWalletIds = [];
|
|
81
|
+
}
|
|
79
82
|
this.request = this.core.getPlugin("request");
|
|
80
83
|
this.window = this.core.getPlugin("window");
|
|
81
84
|
const otherParams = options.otherParams || {};
|
|
@@ -164,14 +167,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
164
167
|
// ─── Discount: 公共 API ───
|
|
165
168
|
async loadDiscountConfig(params) {
|
|
166
169
|
var _a, _b, _c, _d;
|
|
167
|
-
const
|
|
170
|
+
const prepareConfig = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
|
|
168
171
|
customer_id: params.customerId,
|
|
169
172
|
action: params.action || "create",
|
|
170
173
|
with_good_pass: 1,
|
|
171
174
|
with_discount_card: 1,
|
|
172
175
|
with_wallet_pass_holder: 1,
|
|
176
|
+
with_available_wallet_flag: 1,
|
|
177
|
+
with_available_wallet_pass_flag: 1,
|
|
173
178
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
174
179
|
}));
|
|
180
|
+
const discountList = prepareConfig == null ? void 0 : prepareConfig.discountList;
|
|
181
|
+
this.store.availableWalletIds = (prepareConfig == null ? void 0 : prepareConfig.availableWalletIds) || [];
|
|
175
182
|
if (discountList) {
|
|
176
183
|
(_b = this.store.discount) == null ? void 0 : _b.setDiscountList(discountList);
|
|
177
184
|
}
|
|
@@ -183,6 +190,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
183
190
|
var _a;
|
|
184
191
|
return ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
|
|
185
192
|
}
|
|
193
|
+
getAvailableWalletIds() {
|
|
194
|
+
return this.store.availableWalletIds || [];
|
|
195
|
+
}
|
|
186
196
|
async scanCode(code, customerId) {
|
|
187
197
|
var _a, _b, _c, _d, _e;
|
|
188
198
|
const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
|
|
@@ -15,6 +15,7 @@ export interface OrderState {
|
|
|
15
15
|
discountList: any[];
|
|
16
16
|
discount: DiscountModule | null;
|
|
17
17
|
rules: RulesModule | null;
|
|
18
|
+
availableWalletIds?: number[];
|
|
18
19
|
}
|
|
19
20
|
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
|
|
20
21
|
export interface UpdateProductInOrderParams {
|
|
@@ -250,5 +251,6 @@ export interface OrderModuleAPI {
|
|
|
250
251
|
action?: 'create';
|
|
251
252
|
}) => Promise<void>;
|
|
252
253
|
getDiscountList: () => Discount[];
|
|
254
|
+
getAvailableWalletIds: () => number[];
|
|
253
255
|
applyDiscount: () => void;
|
|
254
256
|
}
|
|
@@ -34,6 +34,10 @@ __export(getDateIsInSchedule_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(getDateIsInSchedule_exports);
|
|
36
36
|
var import_dayjs = __toESM(require("dayjs"));
|
|
37
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
38
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
39
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
40
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
37
41
|
var getDateIsInSchedule = (dateTime, scheduleList) => {
|
|
38
42
|
if (!dateTime || !scheduleList || scheduleList.length === 0) {
|
|
39
43
|
return false;
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -527,7 +527,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
527
527
|
try {
|
|
528
528
|
const orderId = this.store.orderId;
|
|
529
529
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
530
|
-
const
|
|
530
|
+
const prepareConfig = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
531
531
|
customer_id: customerId,
|
|
532
532
|
action: orderId ? "edit" : "create",
|
|
533
533
|
with_good_pass: 1,
|
|
@@ -536,11 +536,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
536
536
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
537
537
|
...orderId ? { order_id: orderId } : {}
|
|
538
538
|
}));
|
|
539
|
+
const goodPassList = (prepareConfig == null ? void 0 : prepareConfig.discountList) || [];
|
|
539
540
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
540
541
|
(item) => item.isScan
|
|
541
542
|
);
|
|
542
543
|
const scanDiscountIds = scanDiscount.map((n) => n.id);
|
|
543
|
-
const newGoodPassList = goodPassList
|
|
544
|
+
const newGoodPassList = goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
544
545
|
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
545
546
|
this.store.originalDiscountList = newDiscountList;
|
|
546
547
|
await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
|
|
@@ -84,6 +84,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
84
84
|
private clearSlotPriceMapCache;
|
|
85
85
|
/** 读取当前登录 customerId */
|
|
86
86
|
private resolveCustomerIdForSmartPricing;
|
|
87
|
+
private resolveAvailableWalletIdsForSmartPricing;
|
|
87
88
|
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
88
89
|
private getScheduleListForSmartPricing;
|
|
89
90
|
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
@@ -342,6 +342,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
342
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
343
343
|
const refreshTask = (async () => {
|
|
344
344
|
var _a;
|
|
345
|
+
await this.store.order.loadDiscountConfig({
|
|
346
|
+
customerId: params.customerId
|
|
347
|
+
});
|
|
345
348
|
this.clearSlotPriceMapCache();
|
|
346
349
|
this.recalculateOrderPricesFromSmartPricing();
|
|
347
350
|
if (this.store.holder) {
|
|
@@ -355,9 +358,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
355
358
|
channel: (_a = this.otherParams) == null ? void 0 : _a.channel
|
|
356
359
|
});
|
|
357
360
|
}
|
|
358
|
-
await this.store.order.loadDiscountConfig({
|
|
359
|
-
customerId: params.customerId
|
|
360
|
-
});
|
|
361
361
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
362
362
|
this.store.order.persistTempOrder();
|
|
363
363
|
await this.refreshItemRuleQuantityLimits();
|
|
@@ -624,6 +624,16 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
624
624
|
return void 0;
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
+
resolveAvailableWalletIdsForSmartPricing() {
|
|
628
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
629
|
+
const orderWalletIds = (_b = (_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds) == null ? void 0 : _b.call(_a);
|
|
630
|
+
const fallbackWalletIds = ((_c = this.otherParams) == null ? void 0 : _c.available_wallet_ids) || ((_d = this.otherParams) == null ? void 0 : _d.availableWalletIds) || ((_f = (_e = this.otherParams) == null ? void 0 : _e.strategy_context) == null ? void 0 : _f.available_wallet_ids) || ((_h = (_g = this.otherParams) == null ? void 0 : _g.strategy_context) == null ? void 0 : _h.availableWalletIds);
|
|
631
|
+
const source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
632
|
+
if (!Array.isArray(source))
|
|
633
|
+
return [];
|
|
634
|
+
const ids = source.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
|
|
635
|
+
return Array.from(new Set(ids));
|
|
636
|
+
}
|
|
627
637
|
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
628
638
|
getScheduleListForSmartPricing() {
|
|
629
639
|
var _a;
|
|
@@ -640,6 +650,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
640
650
|
scheduleList: this.getScheduleListForSmartPricing(),
|
|
641
651
|
menuList: ((_c = this.otherParams) == null ? void 0 : _c.menuList) || ((_e = (_d = this.otherParams) == null ? void 0 : _d.openData) == null ? void 0 : _e.menuList) || [],
|
|
642
652
|
customerId: customerId ?? this.resolveCustomerIdForSmartPricing(),
|
|
653
|
+
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
643
654
|
channel: (_f = this.otherParams) == null ? void 0 : _f.channel,
|
|
644
655
|
businessCode: (_g = this.otherParams) == null ? void 0 : _g.businessCode,
|
|
645
656
|
orderType: ((_h = this.otherParams) == null ? void 0 : _h.orderType) || ((_i = this.otherParams) == null ? void 0 : _i.type),
|
|
@@ -659,6 +670,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
659
670
|
return [
|
|
660
671
|
date,
|
|
661
672
|
context.customerId ?? "",
|
|
673
|
+
(context.availableWalletIds || []).join(","),
|
|
662
674
|
context.channel ?? "",
|
|
663
675
|
context.businessCode ?? ""
|
|
664
676
|
].join("|");
|
|
@@ -10,6 +10,7 @@ export interface VenueBookingSmartPricingContext {
|
|
|
10
10
|
scheduleList?: ScheduleItem[];
|
|
11
11
|
menuList?: DataVariantMenu[];
|
|
12
12
|
customerId?: number | string;
|
|
13
|
+
availableWalletIds?: Array<number | string>;
|
|
13
14
|
channel?: string;
|
|
14
15
|
businessCode?: string;
|
|
15
16
|
orderType?: string;
|
|
@@ -57,6 +57,7 @@ function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
|
57
57
|
scheduleList: context.scheduleList || [],
|
|
58
58
|
menuList: context.menuList || [],
|
|
59
59
|
customerId: context.customerId,
|
|
60
|
+
availableWalletIds: context.availableWalletIds ?? strategyContext.available_wallet_ids ?? strategyContext.availableWalletIds,
|
|
60
61
|
channel: context.channel ?? strategyContext.channel,
|
|
61
62
|
orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
|
|
62
63
|
businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
|
|
@@ -71,7 +72,6 @@ function formatProductsWithDataVariant(products, context, scheduleDateTime) {
|
|
|
71
72
|
}
|
|
72
73
|
const resolvedAt = scheduleDateTime || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
73
74
|
const businessData = buildDataVariantBusinessData(products, context, resolvedAt);
|
|
74
|
-
console.log(businessData, "businessData");
|
|
75
75
|
const result = evaluator.resolveProducts(businessData);
|
|
76
76
|
return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
|
|
77
77
|
}
|