@pisell/pisellos 2.2.259 → 2.2.260
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 +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +1 -32
- package/dist/modules/Order/index.js +288 -615
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/modules/SalesSummary/index.d.ts +3 -7
- package/dist/modules/SalesSummary/index.js +39 -67
- package/dist/modules/SalesSummary/types.d.ts +0 -1
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/SurchargeList/index.d.ts +4 -6
- package/dist/modules/SurchargeList/index.js +39 -62
- package/dist/modules/SurchargeList/types.d.ts +2 -6
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +1040 -1075
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +316 -398
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -22
- package/dist/solution/BaseSales/index.js +701 -995
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -8
- package/dist/solution/BookingTicket/index.js +6 -153
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +1 -32
- package/lib/modules/Order/index.js +64 -402
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/modules/SalesSummary/index.d.ts +3 -7
- package/lib/modules/SalesSummary/index.js +11 -28
- package/lib/modules/SalesSummary/types.d.ts +0 -1
- package/lib/modules/SalesSummary/utils.js +0 -2
- package/lib/modules/SurchargeList/index.d.ts +4 -6
- package/lib/modules/SurchargeList/index.js +21 -41
- package/lib/modules/SurchargeList/types.d.ts +2 -6
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -244
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +53 -103
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -22
- package/lib/solution/BaseSales/index.js +60 -246
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +0 -8
- package/lib/solution/BookingTicket/index.js +0 -101
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
|
@@ -30,7 +30,6 @@ var salesSummaryDataKeys = {
|
|
|
30
30
|
taxTitle: 'tax_title',
|
|
31
31
|
taxCountryCode: 'tax_country_code'
|
|
32
32
|
};
|
|
33
|
-
var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
|
|
34
33
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
35
34
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
36
35
|
var _super = _createSuper(SalesSummaryModule);
|
|
@@ -44,15 +43,13 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
44
43
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
45
44
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
46
45
|
_defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
|
|
49
46
|
return _this;
|
|
50
47
|
}
|
|
51
48
|
_createClass(SalesSummaryModule, [{
|
|
52
49
|
key: "initialize",
|
|
53
50
|
value: function () {
|
|
54
51
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
55
|
-
var _options$initialState, _options$initialState2,
|
|
52
|
+
var _options$initialState, _options$initialState2, _options$otherParams;
|
|
56
53
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
54
|
while (1) switch (_context.prev = _context.next) {
|
|
58
55
|
case 0:
|
|
@@ -60,25 +57,24 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
60
57
|
this.store = options.store;
|
|
61
58
|
this.appPlugin = this.core.getPlugin('app');
|
|
62
59
|
this.request = this.core.getPlugin('request');
|
|
63
|
-
this.otherParams = options.otherParams || {};
|
|
64
60
|
this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
|
|
65
61
|
this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
|
|
66
|
-
this.surchargeListModuleName = ((
|
|
62
|
+
this.surchargeListModuleName = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.surchargeListModuleName) || 'surchargeList';
|
|
67
63
|
if (this.appPlugin) {
|
|
68
|
-
_context.next =
|
|
64
|
+
_context.next = 9;
|
|
69
65
|
break;
|
|
70
66
|
}
|
|
71
67
|
throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
72
|
-
case
|
|
68
|
+
case 9:
|
|
73
69
|
if (this.request) {
|
|
74
|
-
_context.next =
|
|
70
|
+
_context.next = 11;
|
|
75
71
|
break;
|
|
76
72
|
}
|
|
77
73
|
throw new Error('SalesSummaryModule 需要 request 插件支持');
|
|
78
|
-
case
|
|
79
|
-
_context.next =
|
|
74
|
+
case 11:
|
|
75
|
+
_context.next = 13;
|
|
80
76
|
return this.getSurchargeList();
|
|
81
|
-
case
|
|
77
|
+
case 13:
|
|
82
78
|
case "end":
|
|
83
79
|
return _context.stop();
|
|
84
80
|
}
|
|
@@ -90,32 +86,30 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
86
|
return initialize;
|
|
91
87
|
}()
|
|
92
88
|
/**
|
|
93
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
89
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
|
|
94
90
|
*
|
|
95
91
|
* @example
|
|
96
|
-
* await salesSummaryModule.updateOtherParams({
|
|
92
|
+
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
97
93
|
*/
|
|
98
94
|
}, {
|
|
99
95
|
key: "updateOtherParams",
|
|
100
96
|
value: (function () {
|
|
101
97
|
var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
102
|
-
var
|
|
98
|
+
var nextSurchargeListModuleName;
|
|
103
99
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
100
|
while (1) switch (_context2.prev = _context2.next) {
|
|
105
101
|
case 0:
|
|
106
|
-
previousChannel = this.resolveChannel();
|
|
107
102
|
nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.otherParams = params || {};
|
|
111
|
-
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
112
|
-
if (!shouldReload) {
|
|
113
|
-
_context2.next = 9;
|
|
103
|
+
if (!(nextSurchargeListModuleName === this.surchargeListModuleName)) {
|
|
104
|
+
_context2.next = 3;
|
|
114
105
|
break;
|
|
115
106
|
}
|
|
116
|
-
_context2.
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
return _context2.abrupt("return");
|
|
108
|
+
case 3:
|
|
109
|
+
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
110
|
+
_context2.next = 6;
|
|
111
|
+
return this.getSurchargeList();
|
|
112
|
+
case 6:
|
|
119
113
|
case "end":
|
|
120
114
|
return _context2.stop();
|
|
121
115
|
}
|
|
@@ -126,63 +120,49 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
126
120
|
}
|
|
127
121
|
return updateOtherParams;
|
|
128
122
|
}())
|
|
129
|
-
}, {
|
|
130
|
-
key: "resolveChannel",
|
|
131
|
-
value: function resolveChannel() {
|
|
132
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams;
|
|
133
|
-
return (params === null || params === void 0 ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
134
|
-
}
|
|
135
123
|
}, {
|
|
136
124
|
key: "getSurchargeList",
|
|
137
125
|
value: function () {
|
|
138
126
|
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
139
|
-
var
|
|
140
|
-
surchargeListModule,
|
|
141
|
-
surchargeList,
|
|
142
|
-
_args3 = arguments;
|
|
127
|
+
var surchargeListModule, surchargeList;
|
|
143
128
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
144
129
|
while (1) switch (_context3.prev = _context3.next) {
|
|
145
130
|
case 0:
|
|
146
|
-
|
|
147
|
-
_context3.prev = 1;
|
|
131
|
+
_context3.prev = 0;
|
|
148
132
|
surchargeListModule = this.core.getModule(this.surchargeListModuleName);
|
|
149
133
|
if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
|
|
150
|
-
_context3.next =
|
|
134
|
+
_context3.next = 7;
|
|
151
135
|
break;
|
|
152
136
|
}
|
|
153
|
-
_context3.next =
|
|
154
|
-
return surchargeListModule.getSurchargeList(
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
case 6:
|
|
137
|
+
_context3.next = 5;
|
|
138
|
+
return surchargeListModule.getSurchargeList();
|
|
139
|
+
case 5:
|
|
158
140
|
this.store.surchargeList = _context3.sent;
|
|
159
|
-
this.surchargeListChannel = channel;
|
|
160
141
|
return _context3.abrupt("return");
|
|
161
|
-
case
|
|
162
|
-
_context3.next =
|
|
142
|
+
case 7:
|
|
143
|
+
_context3.next = 9;
|
|
163
144
|
return this.request.get('/order/custom-surcharge/available/v2', {
|
|
164
|
-
|
|
145
|
+
// TODO 真实的渠道
|
|
146
|
+
channel: 'online-store',
|
|
165
147
|
is_assemble_product_data: 1,
|
|
166
148
|
is_assemble_schedule_data: 1,
|
|
167
149
|
with: ['relationSchedule']
|
|
168
150
|
});
|
|
169
|
-
case
|
|
151
|
+
case 9:
|
|
170
152
|
surchargeList = _context3.sent;
|
|
171
153
|
this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
|
|
172
|
-
|
|
173
|
-
_context3.next = 21;
|
|
154
|
+
_context3.next = 17;
|
|
174
155
|
break;
|
|
175
|
-
case
|
|
176
|
-
_context3.prev =
|
|
177
|
-
_context3.t0 = _context3["catch"](
|
|
156
|
+
case 13:
|
|
157
|
+
_context3.prev = 13;
|
|
158
|
+
_context3.t0 = _context3["catch"](0);
|
|
178
159
|
console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
|
|
179
160
|
this.store.surchargeList = [];
|
|
180
|
-
|
|
181
|
-
case 21:
|
|
161
|
+
case 17:
|
|
182
162
|
case "end":
|
|
183
163
|
return _context3.stop();
|
|
184
164
|
}
|
|
185
|
-
}, _callee3, this, [[
|
|
165
|
+
}, _callee3, this, [[0, 13]]);
|
|
186
166
|
}));
|
|
187
167
|
function getSurchargeList() {
|
|
188
168
|
return _getSurchargeList.apply(this, arguments);
|
|
@@ -214,19 +194,11 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
194
|
value: function () {
|
|
215
195
|
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
216
196
|
var _this$store$surcharge, _ref;
|
|
217
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount,
|
|
197
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
218
198
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
219
199
|
while (1) switch (_context4.prev = _context4.next) {
|
|
220
200
|
case 0:
|
|
221
|
-
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount
|
|
222
|
-
summaryChannel = channel || this.resolveChannel();
|
|
223
|
-
if (!(summaryChannel !== this.surchargeListChannel)) {
|
|
224
|
-
_context4.next = 5;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
_context4.next = 5;
|
|
228
|
-
return this.getSurchargeList(summaryChannel);
|
|
229
|
-
case 5:
|
|
201
|
+
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount;
|
|
230
202
|
taxConfig = this.getTaxConfig();
|
|
231
203
|
summarySchedule = this.core.getModule("".concat(this.name.split('_')[0], "_schedule"));
|
|
232
204
|
needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
|
|
@@ -265,7 +237,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
265
237
|
});
|
|
266
238
|
this.store.summary = summaryWithTaxMeta;
|
|
267
239
|
return _context4.abrupt("return", summaryWithTaxMeta);
|
|
268
|
-
case
|
|
240
|
+
case 11:
|
|
269
241
|
case "end":
|
|
270
242
|
return _context4.stop();
|
|
271
243
|
}
|
|
@@ -329,12 +329,11 @@ function buildSurchargeQuantityTotals(nodes) {
|
|
|
329
329
|
}
|
|
330
330
|
function getFallbackAllProductSurchargeIds(surchargeList) {
|
|
331
331
|
return (surchargeList || []).reduce(function (ids, config) {
|
|
332
|
-
var _config$open_product, _config$is_all
|
|
332
|
+
var _config$open_product, _config$is_all;
|
|
333
333
|
var id = getSurchargeConfigId(config);
|
|
334
334
|
if (id === undefined) return ids;
|
|
335
335
|
if (Number((_config$open_product = config.open_product) !== null && _config$open_product !== void 0 ? _config$open_product : 0) === 0) return ids;
|
|
336
336
|
if (Number((_config$is_all = config.is_all) !== null && _config$is_all !== void 0 ? _config$is_all : 0) !== 1) return ids;
|
|
337
|
-
if (Number((_config$open_schedule = config.open_schedule) !== null && _config$open_schedule !== void 0 ? _config$open_schedule : 0) === 1 && config.schedule_type !== 'all') return ids;
|
|
338
337
|
ids.push(id);
|
|
339
338
|
return ids;
|
|
340
339
|
}, []);
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { SurchargeListItem, SurchargeListModuleAPI
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private request;
|
|
9
9
|
private store;
|
|
10
|
-
private
|
|
11
|
-
private requestVersion;
|
|
10
|
+
private loadingPromise;
|
|
12
11
|
constructor(name?: string, version?: string);
|
|
13
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
13
|
+
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
17
15
|
private loadSurchargeList;
|
|
18
16
|
}
|
|
@@ -17,7 +17,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
18
|
import { BaseModule } from "../BaseModule";
|
|
19
19
|
export * from "./types";
|
|
20
|
-
var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
|
|
21
20
|
export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
22
21
|
_inherits(SurchargeListModule, _BaseModule);
|
|
23
22
|
var _super = _createSuper(SurchargeListModule);
|
|
@@ -29,15 +28,14 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
29
28
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
30
29
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
31
30
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
32
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
33
|
-
_defineProperty(_assertThisInitialized(_this), "requestVersion", 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "loadingPromise", null);
|
|
34
32
|
return _this;
|
|
35
33
|
}
|
|
36
34
|
_createClass(SurchargeListModule, [{
|
|
37
35
|
key: "initialize",
|
|
38
36
|
value: function () {
|
|
39
37
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
40
|
-
var _options$initialState, _options$initialState2, _options$initialState3
|
|
38
|
+
var _options$initialState, _options$initialState2, _options$initialState3;
|
|
41
39
|
var hasInitialSurchargeList;
|
|
42
40
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
41
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -47,14 +45,13 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
47
45
|
this.request = this.core.getPlugin('request');
|
|
48
46
|
hasInitialSurchargeList = Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList);
|
|
49
47
|
this.store.surchargeList = hasInitialSurchargeList ? (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.surchargeList : [];
|
|
50
|
-
this.store.
|
|
51
|
-
this.store.isLoaded = Boolean((_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.isLoaded) || hasInitialSurchargeList;
|
|
48
|
+
this.store.isLoaded = Boolean((_options$initialState3 = options.initialState) === null || _options$initialState3 === void 0 ? void 0 : _options$initialState3.isLoaded) || hasInitialSurchargeList;
|
|
52
49
|
if (this.request) {
|
|
53
|
-
_context.next =
|
|
50
|
+
_context.next = 8;
|
|
54
51
|
break;
|
|
55
52
|
}
|
|
56
53
|
throw new Error('SurchargeListModule 需要 request 插件支持');
|
|
57
|
-
case
|
|
54
|
+
case 8:
|
|
58
55
|
case "end":
|
|
59
56
|
return _context.stop();
|
|
60
57
|
}
|
|
@@ -65,43 +62,34 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
65
62
|
}
|
|
66
63
|
return initialize;
|
|
67
64
|
}()
|
|
68
|
-
}, {
|
|
69
|
-
key: "resolveChannel",
|
|
70
|
-
value: function resolveChannel(query) {
|
|
71
|
-
return (query === null || query === void 0 ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
72
|
-
}
|
|
73
65
|
}, {
|
|
74
66
|
key: "getSurchargeList",
|
|
75
67
|
value: function () {
|
|
76
|
-
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
77
|
-
var channel, loadingPromise, nextPromise;
|
|
68
|
+
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
78
69
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
79
70
|
while (1) switch (_context2.prev = _context2.next) {
|
|
80
71
|
case 0:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
_context2.next = 3;
|
|
72
|
+
if (!this.store.isLoaded) {
|
|
73
|
+
_context2.next = 2;
|
|
84
74
|
break;
|
|
85
75
|
}
|
|
86
76
|
return _context2.abrupt("return", this.store.surchargeList);
|
|
87
|
-
case
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_context2.next = 6;
|
|
77
|
+
case 2:
|
|
78
|
+
if (!this.loadingPromise) {
|
|
79
|
+
_context2.next = 4;
|
|
91
80
|
break;
|
|
92
81
|
}
|
|
93
|
-
return _context2.abrupt("return", loadingPromise);
|
|
82
|
+
return _context2.abrupt("return", this.loadingPromise);
|
|
83
|
+
case 4:
|
|
84
|
+
this.loadingPromise = this.loadSurchargeList();
|
|
85
|
+
return _context2.abrupt("return", this.loadingPromise);
|
|
94
86
|
case 6:
|
|
95
|
-
nextPromise = this.loadSurchargeList(channel);
|
|
96
|
-
this.loadingPromises.set(channel, nextPromise);
|
|
97
|
-
return _context2.abrupt("return", nextPromise);
|
|
98
|
-
case 9:
|
|
99
87
|
case "end":
|
|
100
88
|
return _context2.stop();
|
|
101
89
|
}
|
|
102
90
|
}, _callee2, this);
|
|
103
91
|
}));
|
|
104
|
-
function getSurchargeList(
|
|
92
|
+
function getSurchargeList() {
|
|
105
93
|
return _getSurchargeList.apply(this, arguments);
|
|
106
94
|
}
|
|
107
95
|
return getSurchargeList;
|
|
@@ -109,22 +97,19 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
97
|
}, {
|
|
110
98
|
key: "refreshSurchargeList",
|
|
111
99
|
value: function () {
|
|
112
|
-
var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(
|
|
113
|
-
var channel, nextPromise;
|
|
100
|
+
var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
114
101
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
115
102
|
while (1) switch (_context3.prev = _context3.next) {
|
|
116
103
|
case 0:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return _context3.abrupt("return", nextPromise);
|
|
121
|
-
case 4:
|
|
104
|
+
this.loadingPromise = this.loadSurchargeList();
|
|
105
|
+
return _context3.abrupt("return", this.loadingPromise);
|
|
106
|
+
case 2:
|
|
122
107
|
case "end":
|
|
123
108
|
return _context3.stop();
|
|
124
109
|
}
|
|
125
110
|
}, _callee3, this);
|
|
126
111
|
}));
|
|
127
|
-
function refreshSurchargeList(
|
|
112
|
+
function refreshSurchargeList() {
|
|
128
113
|
return _refreshSurchargeList.apply(this, arguments);
|
|
129
114
|
}
|
|
130
115
|
return refreshSurchargeList;
|
|
@@ -132,50 +117,42 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
117
|
}, {
|
|
133
118
|
key: "loadSurchargeList",
|
|
134
119
|
value: function () {
|
|
135
|
-
var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(
|
|
136
|
-
var
|
|
120
|
+
var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
121
|
+
var surchargeList;
|
|
137
122
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
138
123
|
while (1) switch (_context4.prev = _context4.next) {
|
|
139
124
|
case 0:
|
|
140
|
-
|
|
141
|
-
_context4.
|
|
142
|
-
_context4.next = 4;
|
|
125
|
+
_context4.prev = 0;
|
|
126
|
+
_context4.next = 3;
|
|
143
127
|
return this.request.get('/order/custom-surcharge/available/v2', {
|
|
144
|
-
channel:
|
|
128
|
+
channel: 'online-store',
|
|
145
129
|
is_assemble_product_data: 1,
|
|
146
130
|
is_assemble_schedule_data: 1,
|
|
147
131
|
with: ['relationSchedule']
|
|
148
132
|
});
|
|
149
|
-
case
|
|
133
|
+
case 3:
|
|
150
134
|
surchargeList = _context4.sent;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return _context4.abrupt("return", nextSurchargeList);
|
|
158
|
-
case 10:
|
|
159
|
-
_context4.prev = 10;
|
|
160
|
-
_context4.t0 = _context4["catch"](1);
|
|
135
|
+
this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
|
|
136
|
+
this.store.isLoaded = true;
|
|
137
|
+
return _context4.abrupt("return", this.store.surchargeList);
|
|
138
|
+
case 9:
|
|
139
|
+
_context4.prev = 9;
|
|
140
|
+
_context4.t0 = _context4["catch"](0);
|
|
161
141
|
console.warn('[SurchargeListModule] 加载附加费配置失败', _context4.t0);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.store.isLoaded = true;
|
|
166
|
-
}
|
|
167
|
-
return _context4.abrupt("return", []);
|
|
142
|
+
this.store.surchargeList = [];
|
|
143
|
+
this.store.isLoaded = true;
|
|
144
|
+
return _context4.abrupt("return", this.store.surchargeList);
|
|
168
145
|
case 15:
|
|
169
146
|
_context4.prev = 15;
|
|
170
|
-
this.
|
|
147
|
+
this.loadingPromise = null;
|
|
171
148
|
return _context4.finish(15);
|
|
172
149
|
case 18:
|
|
173
150
|
case "end":
|
|
174
151
|
return _context4.stop();
|
|
175
152
|
}
|
|
176
|
-
}, _callee4, this, [[
|
|
153
|
+
}, _callee4, this, [[0, 9, 15, 18]]);
|
|
177
154
|
}));
|
|
178
|
-
function loadSurchargeList(
|
|
155
|
+
function loadSurchargeList() {
|
|
179
156
|
return _loadSurchargeList.apply(this, arguments);
|
|
180
157
|
}
|
|
181
158
|
return loadSurchargeList;
|
|
@@ -4,12 +4,8 @@ export interface SurchargeListItem {
|
|
|
4
4
|
export interface SurchargeListState {
|
|
5
5
|
surchargeList: SurchargeListItem[];
|
|
6
6
|
isLoaded: boolean;
|
|
7
|
-
channel?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface SurchargeListQuery {
|
|
10
|
-
channel?: string;
|
|
11
7
|
}
|
|
12
8
|
export interface SurchargeListModuleAPI {
|
|
13
|
-
getSurchargeList(
|
|
14
|
-
refreshSurchargeList(
|
|
9
|
+
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
10
|
+
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
15
11
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ declare class Server {
|
|
|
47
47
|
private prefixRouterGet;
|
|
48
48
|
router: Router;
|
|
49
49
|
private productQuerySubscribers;
|
|
50
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
|
+
private productQueryScheduleTimers;
|
|
50
52
|
private orderQuerySubscribers;
|
|
51
53
|
private bookingQuerySubscribers;
|
|
52
54
|
private bookingRemoteQuerySubscribers;
|
|
@@ -210,6 +212,48 @@ declare class Server {
|
|
|
210
212
|
* 根据 subscriberId 移除商品查询订阅者
|
|
211
213
|
*/
|
|
212
214
|
removeProductQuerySubscriber(subscriberId?: string): void;
|
|
215
|
+
/**
|
|
216
|
+
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
217
|
+
*/
|
|
218
|
+
private buildProductQueryResultPayload;
|
|
219
|
+
/**
|
|
220
|
+
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
221
|
+
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
222
|
+
*/
|
|
223
|
+
private shouldScheduleProductQueryReload;
|
|
224
|
+
/**
|
|
225
|
+
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
226
|
+
*/
|
|
227
|
+
private clearSubscriberScheduleTimers;
|
|
228
|
+
/**
|
|
229
|
+
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
230
|
+
*/
|
|
231
|
+
private removeScheduleTimerRef;
|
|
232
|
+
/**
|
|
233
|
+
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
234
|
+
*/
|
|
235
|
+
private computeScheduleTimePointDelayMs;
|
|
236
|
+
/**
|
|
237
|
+
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
238
|
+
*/
|
|
239
|
+
private refreshSubscriberScheduleAtExecution;
|
|
240
|
+
/**
|
|
241
|
+
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
242
|
+
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
243
|
+
*/
|
|
244
|
+
private scheduleSubscriberTimePointReloads;
|
|
245
|
+
/**
|
|
246
|
+
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
247
|
+
*/
|
|
248
|
+
private onScheduleTimePointTimerFire;
|
|
249
|
+
/**
|
|
250
|
+
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
251
|
+
*/
|
|
252
|
+
private recomputeAndNotifySubscriber;
|
|
253
|
+
/**
|
|
254
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
255
|
+
*/
|
|
256
|
+
private syncProductQueryScheduleTimers;
|
|
213
257
|
/**
|
|
214
258
|
* 处理商品查询请求
|
|
215
259
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -431,9 +475,6 @@ declare class Server {
|
|
|
431
475
|
private shouldLookupLocalPrintOrder;
|
|
432
476
|
private getLocalPrintOrderLookup;
|
|
433
477
|
private handleLocalPrintOrder;
|
|
434
|
-
private handleMachinecodeBatchMeta;
|
|
435
|
-
private resolveMachinecodeBatchMetadataLookup;
|
|
436
|
-
private syncMachinecodeRedeemStatusToLocalOrder;
|
|
437
478
|
private handleOrderCheckoutSubmit;
|
|
438
479
|
private handleSyncCheckoutSubmit;
|
|
439
480
|
private handlePendingSyncCheckoutOrder;
|
|
@@ -565,6 +606,12 @@ declare class Server {
|
|
|
565
606
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
566
607
|
*/
|
|
567
608
|
private computeProductQueryResult;
|
|
609
|
+
/**
|
|
610
|
+
* 构建商品格式化上下文。
|
|
611
|
+
*
|
|
612
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
613
|
+
*/
|
|
614
|
+
private buildProductFormatterContext;
|
|
568
615
|
/**
|
|
569
616
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
570
617
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|