@pisell/pisellos 0.0.559 → 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/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/ProductList/index.js +18 -10
- package/dist/modules/Rules/index.js +10 -1
- package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
- package/dist/modules/Summary/utils.js +42 -21
- 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/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/ProductList/index.js +9 -2
- package/lib/modules/Rules/index.js +6 -1
- package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
- package/lib/modules/Summary/utils.js +23 -3
- 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
|
/**
|
|
@@ -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
|
}
|
|
@@ -91,7 +91,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
91
91
|
key: "loadProducts",
|
|
92
92
|
value: function () {
|
|
93
93
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
|
|
94
|
-
var
|
|
94
|
+
var _this$otherParams, _this$otherParams2;
|
|
95
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, _ref$with_extra, with_extra, userPlugin, customer_id, _userPlugin$get, channelMap, saleChannel, productsData, sortedList;
|
|
95
96
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
96
97
|
while (1) switch (_context3.prev = _context3.next) {
|
|
97
98
|
case 0:
|
|
@@ -115,8 +116,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
115
116
|
} catch (error) {
|
|
116
117
|
console.error(error);
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
channelMap = {
|
|
120
|
+
'online_store': 'online-store',
|
|
121
|
+
'scan_to_order': 'online-store',
|
|
122
|
+
'scan_to_order_2': 'online-store',
|
|
123
|
+
'scan_to_order_3': 'online-store'
|
|
124
|
+
};
|
|
125
|
+
saleChannel = channelMap[(_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel] || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel);
|
|
126
|
+
_context3.prev = 6;
|
|
127
|
+
_context3.next = 9;
|
|
120
128
|
return this.request.post("/product/query", {
|
|
121
129
|
open_quotation: 1,
|
|
122
130
|
open_bundle: 0,
|
|
@@ -136,7 +144,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
136
144
|
schedule_date: schedule_date,
|
|
137
145
|
schedule_datetime: schedule_datetime,
|
|
138
146
|
// application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
|
|
139
|
-
application_code:
|
|
147
|
+
application_code: saleChannel,
|
|
140
148
|
with_schedule: with_schedule,
|
|
141
149
|
is_eject: 1,
|
|
142
150
|
open_deposit: 1
|
|
@@ -147,7 +155,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
155
|
useCache: true,
|
|
148
156
|
customToast: function customToast() {}
|
|
149
157
|
});
|
|
150
|
-
case
|
|
158
|
+
case 9:
|
|
151
159
|
productsData = _context3.sent;
|
|
152
160
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
153
161
|
return Number(b.sort) - Number(a.sort);
|
|
@@ -160,15 +168,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
160
168
|
// }
|
|
161
169
|
this.addProduct(sortedList);
|
|
162
170
|
return _context3.abrupt("return", sortedList);
|
|
163
|
-
case
|
|
164
|
-
_context3.prev =
|
|
165
|
-
_context3.t0 = _context3["catch"](
|
|
171
|
+
case 15:
|
|
172
|
+
_context3.prev = 15;
|
|
173
|
+
_context3.t0 = _context3["catch"](6);
|
|
166
174
|
return _context3.abrupt("return", _context3.t0);
|
|
167
|
-
case
|
|
175
|
+
case 18:
|
|
168
176
|
case "end":
|
|
169
177
|
return _context3.stop();
|
|
170
178
|
}
|
|
171
|
-
}, _callee3, this, [[
|
|
179
|
+
}, _callee3, this, [[6, 15]]);
|
|
172
180
|
}));
|
|
173
181
|
function loadProducts(_x5, _x6) {
|
|
174
182
|
return _loadProducts.apply(this, arguments);
|
|
@@ -605,6 +605,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
605
605
|
}
|
|
606
606
|
});
|
|
607
607
|
}
|
|
608
|
+
// 检查商品是否被排除(全品类)
|
|
609
|
+
var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
|
|
610
|
+
var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
|
|
611
|
+
var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
|
|
612
|
+
return String(id) === String(productId);
|
|
613
|
+
});
|
|
614
|
+
return !isExcluded;
|
|
615
|
+
};
|
|
608
616
|
|
|
609
617
|
/**
|
|
610
618
|
// 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
|
|
@@ -1101,9 +1109,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1101
1109
|
|
|
1102
1110
|
// 判断优惠券是否适用于该商品
|
|
1103
1111
|
if (limitedData.type === 'product_all') {
|
|
1104
|
-
if (limitedData
|
|
1112
|
+
if (!isProductIncludedByLimitedData(limitedData, product.id)) {
|
|
1105
1113
|
return false;
|
|
1106
1114
|
}
|
|
1115
|
+
|
|
1107
1116
|
// 检查 package_sub_item_usage_rules
|
|
1108
1117
|
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
1109
1118
|
return false;
|
|
@@ -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) {
|
|
@@ -616,6 +616,27 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
|
616
616
|
}, new Decimal(0));
|
|
617
617
|
return totalTaxFee;
|
|
618
618
|
};
|
|
619
|
+
var getCartItemDepositData = function getCartItemDepositData(item) {
|
|
620
|
+
var _target$_productOrigi, _target$_origin, _target$_origin2;
|
|
621
|
+
var target = item;
|
|
622
|
+
return (target === null || target === void 0 || (_target$_productOrigi = target._productOrigin) === null || _target$_productOrigi === void 0 ? void 0 : _target$_productOrigi.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin = target._origin) === null || _target$_origin === void 0 ? void 0 : _target$_origin.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin2 = target._origin) === null || _target$_origin2 === void 0 || (_target$_origin2 = _target$_origin2.product) === null || _target$_origin2 === void 0 ? void 0 : _target$_origin2.custom_deposit_data);
|
|
623
|
+
};
|
|
624
|
+
var getCartItemQuantity = function getCartItemQuantity(item) {
|
|
625
|
+
return new Decimal((item === null || item === void 0 ? void 0 : item.num) || 1);
|
|
626
|
+
};
|
|
627
|
+
var calculateCartItemDepositTotal = function calculateCartItemDepositTotal(item) {
|
|
628
|
+
var _item$deposit;
|
|
629
|
+
var depositData = getCartItemDepositData(item);
|
|
630
|
+
if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) == 1 && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_fixed) === 'string' && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_percentage) === 'string') {
|
|
631
|
+
var _ref7, _summaryTotal;
|
|
632
|
+
var lineTotal = new Decimal((_ref7 = (_summaryTotal = item.summaryTotal) !== null && _summaryTotal !== void 0 ? _summaryTotal : item.total) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
633
|
+
var quantity = getCartItemQuantity(item);
|
|
634
|
+
var fixedTotal = new Decimal(depositData.deposit_fixed || 0).times(quantity);
|
|
635
|
+
var percentageTotal = new Decimal(depositData.deposit_percentage || 0).times(lineTotal);
|
|
636
|
+
return fixedTotal.plus(percentageTotal);
|
|
637
|
+
}
|
|
638
|
+
return new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
|
|
639
|
+
};
|
|
619
640
|
|
|
620
641
|
/**
|
|
621
642
|
* @title: 计算定金
|
|
@@ -630,9 +651,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
630
651
|
var hasDeposit = false;
|
|
631
652
|
var total = items.reduce(function (sum, item) {
|
|
632
653
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
633
|
-
var _item$
|
|
654
|
+
var _item$deposit2;
|
|
634
655
|
hasDeposit = true;
|
|
635
|
-
var cartItemTotalPrice =
|
|
656
|
+
var cartItemTotalPrice = calculateCartItemDepositTotal(item);
|
|
636
657
|
// 将协议数据去重合并
|
|
637
658
|
item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
|
|
638
659
|
if (protocols.findIndex(function (p) {
|
|
@@ -669,9 +690,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
669
690
|
* @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
|
|
670
691
|
* @returns 订单附加费金额(number,金额单位与商品价格一致)
|
|
671
692
|
*/
|
|
672
|
-
export var getSurchargeAmount = function getSurchargeAmount(
|
|
673
|
-
var bookingDetail =
|
|
674
|
-
bookingId =
|
|
693
|
+
export var getSurchargeAmount = function getSurchargeAmount(_ref8, surcharge, options) {
|
|
694
|
+
var bookingDetail = _ref8.bookingDetail,
|
|
695
|
+
bookingId = _ref8.bookingId;
|
|
675
696
|
var isEdit = options.isEdit;
|
|
676
697
|
// 订单未变更过
|
|
677
698
|
if (!isEdit) {
|
|
@@ -716,17 +737,17 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
716
737
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
717
738
|
*/
|
|
718
739
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
719
|
-
var
|
|
740
|
+
var _ref9, _ref10, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
|
|
720
741
|
// 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
|
|
721
742
|
// 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
|
|
722
743
|
// 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
|
|
723
|
-
var total = new Decimal((
|
|
744
|
+
var total = new Decimal((_ref9 = (_ref10 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref10 !== void 0 ? _ref10 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
724
745
|
|
|
725
746
|
// 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
|
|
726
747
|
var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
|
|
727
748
|
if (!hasMainProductPrice) {
|
|
728
|
-
var
|
|
729
|
-
total = new Decimal((
|
|
749
|
+
var _ref11, _ref12, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
|
|
750
|
+
total = new Decimal((_ref11 = (_ref12 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0);
|
|
730
751
|
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
|
|
731
752
|
var _item$metadata6;
|
|
732
753
|
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
@@ -747,9 +768,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
747
768
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
748
769
|
var bundleItem = _step4.value;
|
|
749
770
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
750
|
-
var
|
|
771
|
+
var _ref13, _bundleItem$bundle_se2;
|
|
751
772
|
// IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
|
|
752
|
-
var bundleItemTotal = new Decimal((
|
|
773
|
+
var bundleItemTotal = new Decimal((_ref13 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref13 !== void 0 ? _ref13 : 0);
|
|
753
774
|
total = total.add(bundleItemTotal);
|
|
754
775
|
}
|
|
755
776
|
}
|
|
@@ -869,12 +890,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
|
|
|
869
890
|
* @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
|
|
870
891
|
* @returns 附加费列表(仅返回金额 > 0 的项)
|
|
871
892
|
*/
|
|
872
|
-
export var getSurcharge = function getSurcharge(
|
|
893
|
+
export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
873
894
|
var _service$filter;
|
|
874
|
-
var service =
|
|
875
|
-
addons =
|
|
876
|
-
bookingDetail =
|
|
877
|
-
bookingId =
|
|
895
|
+
var service = _ref14.service,
|
|
896
|
+
addons = _ref14.addons,
|
|
897
|
+
bookingDetail = _ref14.bookingDetail,
|
|
898
|
+
bookingId = _ref14.bookingId;
|
|
878
899
|
var isEdit = options.isEdit,
|
|
879
900
|
isInScheduleByDate = options.isInScheduleByDate,
|
|
880
901
|
surcharge_list = options.surcharge_list,
|
|
@@ -996,11 +1017,11 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
996
1017
|
scheduleById: scheduleById || {},
|
|
997
1018
|
isInScheduleByDate: isInScheduleByDate
|
|
998
1019
|
})) {
|
|
999
|
-
var
|
|
1020
|
+
var _ref15, _bundleItem$bundle_se3;
|
|
1000
1021
|
var _mainQuantity = item.num || 1;
|
|
1001
1022
|
matchedItems.push({
|
|
1002
1023
|
isMain: false,
|
|
1003
|
-
total: Number((
|
|
1024
|
+
total: Number((_ref15 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref15 !== void 0 ? _ref15 : 0),
|
|
1004
1025
|
quantity: bundleItem.num || bundleItem.quantity || 1,
|
|
1005
1026
|
item: bundleItem,
|
|
1006
1027
|
mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
|
|
@@ -1216,9 +1237,9 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
1216
1237
|
}
|
|
1217
1238
|
return surchargeWithAmount;
|
|
1218
1239
|
};
|
|
1219
|
-
function resetItemsSurchargeSideEffects(
|
|
1220
|
-
var service =
|
|
1221
|
-
addons =
|
|
1240
|
+
function resetItemsSurchargeSideEffects(_ref16) {
|
|
1241
|
+
var service = _ref16.service,
|
|
1242
|
+
addons = _ref16.addons;
|
|
1222
1243
|
var resetItem = function resetItem(item) {
|
|
1223
1244
|
if (!item) return;
|
|
1224
1245
|
item.surcharge_fee = 0;
|
|
@@ -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 */
|