@pisell/pisellos 2.3.62 → 2.3.63
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/core/index.d.ts +0 -7
- package/dist/core/index.js +66 -109
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Quotation/index.d.ts +0 -6
- package/dist/modules/Quotation/index.js +19 -75
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +2 -6
- package/dist/server/index.js +91 -132
- package/dist/server/modules/floor-plan/index.d.ts +0 -4
- package/dist/server/modules/floor-plan/index.js +98 -240
- package/dist/server/modules/menu/index.js +23 -48
- package/dist/server/modules/order/index.d.ts +7 -12
- package/dist/server/modules/order/index.js +96 -248
- package/dist/server/modules/products/index.d.ts +2 -8
- package/dist/server/modules/products/index.js +75 -167
- package/dist/server/modules/resource/index.js +13 -21
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/core/index.d.ts +0 -7
- package/lib/core/index.js +3 -20
- package/lib/modules/Quotation/index.d.ts +0 -6
- package/lib/modules/Quotation/index.js +5 -49
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +2 -6
- package/lib/server/index.js +11 -33
- package/lib/server/modules/floor-plan/index.d.ts +0 -4
- package/lib/server/modules/floor-plan/index.js +6 -54
- package/lib/server/modules/menu/index.js +5 -31
- package/lib/server/modules/order/index.d.ts +7 -12
- package/lib/server/modules/order/index.js +28 -143
- package/lib/server/modules/products/index.d.ts +2 -8
- package/lib/server/modules/products/index.js +24 -97
- package/lib/server/modules/resource/index.js +2 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -12,15 +12,8 @@ declare class PisellOSCore implements PisellCore {
|
|
|
12
12
|
context: BusinessContext;
|
|
13
13
|
server: any;
|
|
14
14
|
serverOptions?: ServerOptions;
|
|
15
|
-
private serverModulePromise?;
|
|
16
15
|
constructor(options?: PisellOSOptions);
|
|
17
16
|
private initialize;
|
|
18
|
-
/**
|
|
19
|
-
* 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
|
|
20
|
-
* 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
|
|
21
|
-
*/
|
|
22
|
-
preloadServerModule(): Promise<void>;
|
|
23
|
-
private loadServerModule;
|
|
24
17
|
/**
|
|
25
18
|
* 初始化 Server(公开方法,需要外部显式调用并等待)
|
|
26
19
|
* Server 配置从构造函数传入的 options.server 中获取
|
package/dist/core/index.js
CHANGED
|
@@ -24,6 +24,8 @@ import { EffectsManager } from "../effects";
|
|
|
24
24
|
* pisell OS 核心实现
|
|
25
25
|
*/
|
|
26
26
|
var PisellOSCore = /*#__PURE__*/function () {
|
|
27
|
+
// 保存 Server 配置
|
|
28
|
+
|
|
27
29
|
function PisellOSCore(options) {
|
|
28
30
|
_classCallCheck(this, PisellOSCore);
|
|
29
31
|
_defineProperty(this, "plugins", new Map());
|
|
@@ -35,8 +37,6 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
35
37
|
_defineProperty(this, "server", void 0);
|
|
36
38
|
// Server 实例
|
|
37
39
|
_defineProperty(this, "serverOptions", void 0);
|
|
38
|
-
// 保存 Server 配置
|
|
39
|
-
_defineProperty(this, "serverModulePromise", void 0);
|
|
40
40
|
this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
|
|
41
41
|
this.context = (options === null || options === void 0 ? void 0 : options.context) || {};
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
45
45
|
this.serverOptions = options.server;
|
|
46
46
|
}
|
|
47
47
|
this.initialize(options);
|
|
48
|
-
console.log('
|
|
48
|
+
console.log('constructor1234');
|
|
49
49
|
}
|
|
50
50
|
_createClass(PisellOSCore, [{
|
|
51
51
|
key: "initialize",
|
|
@@ -64,49 +64,6 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
64
64
|
this.log('[PisellOS] 核心初始化完成');
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
* 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
|
|
69
|
-
* 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
|
|
70
|
-
*/
|
|
71
|
-
}, {
|
|
72
|
-
key: "preloadServerModule",
|
|
73
|
-
value: (function () {
|
|
74
|
-
var _preloadServerModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
75
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
76
|
-
while (1) switch (_context.prev = _context.next) {
|
|
77
|
-
case 0:
|
|
78
|
-
if (!(this.server || !this.serverOptions)) {
|
|
79
|
-
_context.next = 2;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
return _context.abrupt("return");
|
|
83
|
-
case 2:
|
|
84
|
-
_context.next = 4;
|
|
85
|
-
return this.loadServerModule();
|
|
86
|
-
case 4:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context.stop();
|
|
89
|
-
}
|
|
90
|
-
}, _callee, this);
|
|
91
|
-
}));
|
|
92
|
-
function preloadServerModule() {
|
|
93
|
-
return _preloadServerModule.apply(this, arguments);
|
|
94
|
-
}
|
|
95
|
-
return preloadServerModule;
|
|
96
|
-
}())
|
|
97
|
-
}, {
|
|
98
|
-
key: "loadServerModule",
|
|
99
|
-
value: function loadServerModule() {
|
|
100
|
-
var _this2 = this;
|
|
101
|
-
if (!this.serverModulePromise) {
|
|
102
|
-
this.serverModulePromise = import("../server").catch(function (error) {
|
|
103
|
-
_this2.serverModulePromise = undefined;
|
|
104
|
-
throw error;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return this.serverModulePromise;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
67
|
/**
|
|
111
68
|
* 初始化 Server(公开方法,需要外部显式调用并等待)
|
|
112
69
|
* Server 配置从构造函数传入的 options.server 中获取
|
|
@@ -114,57 +71,57 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
114
71
|
}, {
|
|
115
72
|
key: "initializeServer",
|
|
116
73
|
value: (function () {
|
|
117
|
-
var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
74
|
+
var _initializeServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
118
75
|
var ServerModule, Server;
|
|
119
|
-
return _regeneratorRuntime().wrap(function
|
|
120
|
-
while (1) switch (
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
121
78
|
case 0:
|
|
122
79
|
if (!this.server) {
|
|
123
|
-
|
|
80
|
+
_context.next = 3;
|
|
124
81
|
break;
|
|
125
82
|
}
|
|
126
83
|
this.log('Server 已经初始化,跳过重复初始化', 'warn');
|
|
127
|
-
return
|
|
84
|
+
return _context.abrupt("return");
|
|
128
85
|
case 3:
|
|
129
86
|
if (this.serverOptions) {
|
|
130
|
-
|
|
87
|
+
_context.next = 6;
|
|
131
88
|
break;
|
|
132
89
|
}
|
|
133
90
|
this.log('未提供 Server 配置,无法初始化', 'warn');
|
|
134
|
-
return
|
|
91
|
+
return _context.abrupt("return");
|
|
135
92
|
case 6:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return
|
|
93
|
+
_context.prev = 6;
|
|
94
|
+
_context.next = 9;
|
|
95
|
+
return import("../server");
|
|
139
96
|
case 9:
|
|
140
|
-
ServerModule =
|
|
97
|
+
ServerModule = _context.sent;
|
|
141
98
|
Server = ServerModule.default; // 创建 Server 实例
|
|
142
99
|
this.server = new Server(this);
|
|
143
100
|
this.log('Server 实例已创建');
|
|
144
101
|
|
|
145
102
|
// 初始化模块并预加载数据
|
|
146
103
|
if (!this.serverOptions.modules) {
|
|
147
|
-
|
|
104
|
+
_context.next = 16;
|
|
148
105
|
break;
|
|
149
106
|
}
|
|
150
|
-
|
|
107
|
+
_context.next = 16;
|
|
151
108
|
return this.server.initialize(this.serverOptions.modules, this.serverOptions.autoInitData !== false, options);
|
|
152
109
|
case 16:
|
|
153
110
|
console.log('[PisellOS] ✅ Server 初始化完成,所有数据已预加载');
|
|
154
111
|
this.log('[PisellOS] Server 初始化完成');
|
|
155
|
-
|
|
112
|
+
_context.next = 25;
|
|
156
113
|
break;
|
|
157
114
|
case 20:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
console.error('[PisellOS] ❌ Server 初始化失败:',
|
|
161
|
-
this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(
|
|
162
|
-
throw
|
|
115
|
+
_context.prev = 20;
|
|
116
|
+
_context.t0 = _context["catch"](6);
|
|
117
|
+
console.error('[PisellOS] ❌ Server 初始化失败:', _context.t0);
|
|
118
|
+
this.log("Server \u521D\u59CB\u5316\u5931\u8D25: ".concat(_context.t0), 'error');
|
|
119
|
+
throw _context.t0;
|
|
163
120
|
case 25:
|
|
164
121
|
case "end":
|
|
165
|
-
return
|
|
122
|
+
return _context.stop();
|
|
166
123
|
}
|
|
167
|
-
},
|
|
124
|
+
}, _callee, this, [[6, 20]]);
|
|
168
125
|
}));
|
|
169
126
|
function initializeServer(_x) {
|
|
170
127
|
return _initializeServer.apply(this, arguments);
|
|
@@ -197,7 +154,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
197
154
|
}, {
|
|
198
155
|
key: "registerPlugin",
|
|
199
156
|
value: function registerPlugin(plugin, options) {
|
|
200
|
-
var
|
|
157
|
+
var _this2 = this;
|
|
201
158
|
if (this.plugins.has(plugin.name)) {
|
|
202
159
|
this.log("\u63D2\u4EF6 ".concat(plugin.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
|
|
203
160
|
}
|
|
@@ -225,7 +182,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
225
182
|
var result = plugin.initialize();
|
|
226
183
|
if (result instanceof Promise) {
|
|
227
184
|
result.catch(function (err) {
|
|
228
|
-
|
|
185
|
+
_this2.log("\u63D2\u4EF6 ".concat(plugin.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
|
|
229
186
|
throw err;
|
|
230
187
|
});
|
|
231
188
|
}
|
|
@@ -251,7 +208,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
251
208
|
}, {
|
|
252
209
|
key: "registerModule",
|
|
253
210
|
value: function registerModule(module, options) {
|
|
254
|
-
var
|
|
211
|
+
var _this3 = this;
|
|
255
212
|
if (this.modules.has(module.name)) {
|
|
256
213
|
this.log("\u6A21\u5757 ".concat(module.name, " \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6"), 'warn');
|
|
257
214
|
}
|
|
@@ -294,7 +251,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
294
251
|
// 预先给模块初始化值系统
|
|
295
252
|
var _createStore = createStore((options === null || options === void 0 ? void 0 : options.initialState) || {}, module.name, function (path, value) {
|
|
296
253
|
console.log('core 检测到模块值更新', module.name, path, value);
|
|
297
|
-
|
|
254
|
+
_this3.effects.emit("".concat(module.name, ":changed"), {
|
|
298
255
|
path: path,
|
|
299
256
|
value: value
|
|
300
257
|
});
|
|
@@ -309,7 +266,7 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
309
266
|
}, options));
|
|
310
267
|
if (result instanceof Promise) {
|
|
311
268
|
result.catch(function (err) {
|
|
312
|
-
|
|
269
|
+
_this3.log("\u6A21\u5757 ".concat(module.name, " \u521D\u59CB\u5316\u5931\u8D25: ").concat(err.message), 'error');
|
|
313
270
|
throw err;
|
|
314
271
|
});
|
|
315
272
|
}
|
|
@@ -354,100 +311,100 @@ var PisellOSCore = /*#__PURE__*/function () {
|
|
|
354
311
|
}, {
|
|
355
312
|
key: "destroy",
|
|
356
313
|
value: function () {
|
|
357
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
314
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
358
315
|
var _iterator4, _step4, _step4$value, name, module, _iterator5, _step5, _step5$value, _name, plugin;
|
|
359
|
-
return _regeneratorRuntime().wrap(function
|
|
360
|
-
while (1) switch (
|
|
316
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
317
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
361
318
|
case 0:
|
|
362
319
|
// 先销毁模块
|
|
363
320
|
_iterator4 = _createForOfIteratorHelper(this.modules.entries());
|
|
364
|
-
|
|
321
|
+
_context2.prev = 1;
|
|
365
322
|
_iterator4.s();
|
|
366
323
|
case 3:
|
|
367
324
|
if ((_step4 = _iterator4.n()).done) {
|
|
368
|
-
|
|
325
|
+
_context2.next = 17;
|
|
369
326
|
break;
|
|
370
327
|
}
|
|
371
328
|
_step4$value = _slicedToArray(_step4.value, 2), name = _step4$value[0], module = _step4$value[1];
|
|
372
329
|
if (!module.destroy) {
|
|
373
|
-
|
|
330
|
+
_context2.next = 15;
|
|
374
331
|
break;
|
|
375
332
|
}
|
|
376
|
-
|
|
377
|
-
|
|
333
|
+
_context2.prev = 6;
|
|
334
|
+
_context2.next = 9;
|
|
378
335
|
return Promise.resolve(module.destroy());
|
|
379
336
|
case 9:
|
|
380
337
|
this.log("\u6A21\u5757 ".concat(name, " \u5DF2\u9500\u6BC1"));
|
|
381
|
-
|
|
338
|
+
_context2.next = 15;
|
|
382
339
|
break;
|
|
383
340
|
case 12:
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(
|
|
341
|
+
_context2.prev = 12;
|
|
342
|
+
_context2.t0 = _context2["catch"](6);
|
|
343
|
+
this.log("\u9500\u6BC1\u6A21\u5757 ".concat(name, " \u65F6\u51FA\u9519: ").concat(_context2.t0), 'error');
|
|
387
344
|
case 15:
|
|
388
|
-
|
|
345
|
+
_context2.next = 3;
|
|
389
346
|
break;
|
|
390
347
|
case 17:
|
|
391
|
-
|
|
348
|
+
_context2.next = 22;
|
|
392
349
|
break;
|
|
393
350
|
case 19:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
_iterator4.e(
|
|
351
|
+
_context2.prev = 19;
|
|
352
|
+
_context2.t1 = _context2["catch"](1);
|
|
353
|
+
_iterator4.e(_context2.t1);
|
|
397
354
|
case 22:
|
|
398
|
-
|
|
355
|
+
_context2.prev = 22;
|
|
399
356
|
_iterator4.f();
|
|
400
|
-
return
|
|
357
|
+
return _context2.finish(22);
|
|
401
358
|
case 25:
|
|
402
359
|
this.modules.clear();
|
|
403
360
|
|
|
404
361
|
// 再销毁插件
|
|
405
362
|
_iterator5 = _createForOfIteratorHelper(this.plugins.entries());
|
|
406
|
-
|
|
363
|
+
_context2.prev = 27;
|
|
407
364
|
_iterator5.s();
|
|
408
365
|
case 29:
|
|
409
366
|
if ((_step5 = _iterator5.n()).done) {
|
|
410
|
-
|
|
367
|
+
_context2.next = 43;
|
|
411
368
|
break;
|
|
412
369
|
}
|
|
413
370
|
_step5$value = _slicedToArray(_step5.value, 2), _name = _step5$value[0], plugin = _step5$value[1];
|
|
414
371
|
if (!plugin.destroy) {
|
|
415
|
-
|
|
372
|
+
_context2.next = 41;
|
|
416
373
|
break;
|
|
417
374
|
}
|
|
418
|
-
|
|
419
|
-
|
|
375
|
+
_context2.prev = 32;
|
|
376
|
+
_context2.next = 35;
|
|
420
377
|
return Promise.resolve(plugin.destroy());
|
|
421
378
|
case 35:
|
|
422
379
|
this.log("\u63D2\u4EF6 ".concat(_name, " \u5DF2\u9500\u6BC1"));
|
|
423
|
-
|
|
380
|
+
_context2.next = 41;
|
|
424
381
|
break;
|
|
425
382
|
case 38:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(
|
|
383
|
+
_context2.prev = 38;
|
|
384
|
+
_context2.t2 = _context2["catch"](32);
|
|
385
|
+
this.log("\u9500\u6BC1\u63D2\u4EF6 ".concat(_name, " \u65F6\u51FA\u9519: ").concat(_context2.t2), 'error');
|
|
429
386
|
case 41:
|
|
430
|
-
|
|
387
|
+
_context2.next = 29;
|
|
431
388
|
break;
|
|
432
389
|
case 43:
|
|
433
|
-
|
|
390
|
+
_context2.next = 48;
|
|
434
391
|
break;
|
|
435
392
|
case 45:
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
_iterator5.e(
|
|
393
|
+
_context2.prev = 45;
|
|
394
|
+
_context2.t3 = _context2["catch"](27);
|
|
395
|
+
_iterator5.e(_context2.t3);
|
|
439
396
|
case 48:
|
|
440
|
-
|
|
397
|
+
_context2.prev = 48;
|
|
441
398
|
_iterator5.f();
|
|
442
|
-
return
|
|
399
|
+
return _context2.finish(48);
|
|
443
400
|
case 51:
|
|
444
401
|
this.plugins.clear();
|
|
445
402
|
this.log('PisellOS 核心已销毁');
|
|
446
403
|
case 53:
|
|
447
404
|
case "end":
|
|
448
|
-
return
|
|
405
|
+
return _context2.stop();
|
|
449
406
|
}
|
|
450
|
-
},
|
|
407
|
+
}, _callee2, this, [[1, 19, 22, 25], [6, 12], [27, 45, 48, 51], [32, 38]]);
|
|
451
408
|
}));
|
|
452
409
|
function destroy() {
|
|
453
410
|
return _destroy.apply(this, arguments);
|
|
@@ -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, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -9,8 +9,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
9
9
|
private request;
|
|
10
10
|
private store;
|
|
11
11
|
private scheduleResolver?;
|
|
12
|
-
private app;
|
|
13
|
-
private quotationListUpdatedListener?;
|
|
14
12
|
constructor(name?: string, version?: string);
|
|
15
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
14
|
loadQuotations(params?: {
|
|
@@ -18,7 +16,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
18
16
|
customer_id?: number | string;
|
|
19
17
|
}): Promise<void>;
|
|
20
18
|
getQuotationList(): QuotationItem[];
|
|
21
|
-
setQuotationListUpdatedListener(listener?: () => void): void;
|
|
22
19
|
getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
|
|
23
20
|
/**
|
|
24
21
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
@@ -63,9 +60,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
63
60
|
customer_id?: number | string;
|
|
64
61
|
}): Map<string, string | null>;
|
|
65
62
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
66
|
-
private applyQuotationResponse;
|
|
67
|
-
private notifyQuotationListUpdated;
|
|
68
|
-
private getQuotationCacheKeyData;
|
|
69
63
|
private isQuotationVisibleForCustomer;
|
|
70
64
|
private hasValidCustomerId;
|
|
71
65
|
private normalizeCustomerId;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
4
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
9
5
|
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); }
|
|
10
6
|
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; }
|
|
@@ -40,15 +36,12 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
40
36
|
list: []
|
|
41
37
|
});
|
|
42
38
|
_defineProperty(_assertThisInitialized(_this), "scheduleResolver", void 0);
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "app", void 0);
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "quotationListUpdatedListener", void 0);
|
|
45
39
|
return _this;
|
|
46
40
|
}
|
|
47
41
|
_createClass(QuotationModule, [{
|
|
48
42
|
key: "initialize",
|
|
49
43
|
value: function () {
|
|
50
44
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
51
|
-
var _core$getPlugin, _core$getPlugin$getAp;
|
|
52
45
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
53
46
|
while (1) switch (_context.prev = _context.next) {
|
|
54
47
|
case 0:
|
|
@@ -60,11 +53,10 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
60
53
|
}
|
|
61
54
|
throw new Error('QuotationModule 需要 request 插件支持');
|
|
62
55
|
case 4:
|
|
63
|
-
this.app = (_core$getPlugin = core.getPlugin('app')) === null || _core$getPlugin === void 0 || (_core$getPlugin$getAp = _core$getPlugin.getApp) === null || _core$getPlugin$getAp === void 0 ? void 0 : _core$getPlugin$getAp.call(_core$getPlugin);
|
|
64
56
|
this.store = {
|
|
65
57
|
list: []
|
|
66
58
|
};
|
|
67
|
-
case
|
|
59
|
+
case 5:
|
|
68
60
|
case "end":
|
|
69
61
|
return _context.stop();
|
|
70
62
|
}
|
|
@@ -79,8 +71,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
79
71
|
key: "loadQuotations",
|
|
80
72
|
value: function () {
|
|
81
73
|
var _loadQuotations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
82
|
-
var
|
|
83
|
-
var query,
|
|
74
|
+
var _data;
|
|
75
|
+
var query, res, list;
|
|
84
76
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
85
77
|
while (1) switch (_context2.prev = _context2.next) {
|
|
86
78
|
case 0:
|
|
@@ -89,27 +81,19 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
89
81
|
if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
|
|
90
82
|
query.channel = 'online-store';
|
|
91
83
|
}
|
|
92
|
-
|
|
93
|
-
applyRemoteUpdate = function applyRemoteUpdate(response) {
|
|
94
|
-
_this2.applyQuotationResponse(response);
|
|
95
|
-
if (initialResultApplied) {
|
|
96
|
-
_this2.notifyQuotationListUpdated();
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
_context2.next = 7;
|
|
84
|
+
_context2.next = 5;
|
|
100
85
|
return this.request.get('/quotation/available', query, {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
updateCache: true,
|
|
104
|
-
cacheKeyData: this.getQuotationCacheKeyData(query)
|
|
105
|
-
},
|
|
106
|
-
cacheUpdateChange: applyRemoteUpdate
|
|
86
|
+
useCache: false,
|
|
87
|
+
osServer: true
|
|
107
88
|
});
|
|
108
|
-
case
|
|
89
|
+
case 5:
|
|
109
90
|
res = _context2.sent;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
|
|
92
|
+
list.sort(function (a, b) {
|
|
93
|
+
return b.sort - a.sort;
|
|
94
|
+
});
|
|
95
|
+
this.store.list = list;
|
|
96
|
+
case 9:
|
|
113
97
|
case "end":
|
|
114
98
|
return _context2.stop();
|
|
115
99
|
}
|
|
@@ -125,15 +109,10 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
125
109
|
value: function getQuotationList() {
|
|
126
110
|
return this.store.list;
|
|
127
111
|
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "setQuotationListUpdatedListener",
|
|
130
|
-
value: function setQuotationListUpdatedListener(listener) {
|
|
131
|
-
this.quotationListUpdatedListener = listener;
|
|
132
|
-
}
|
|
133
112
|
}, {
|
|
134
113
|
key: "getQuotationCustomerScopeInfo",
|
|
135
114
|
value: function getQuotationCustomerScopeInfo() {
|
|
136
|
-
var
|
|
115
|
+
var _this2 = this;
|
|
137
116
|
var customerById = new Map();
|
|
138
117
|
var quotationScopes = this.store.list.filter(function (quotation) {
|
|
139
118
|
return Array.isArray(quotation.customer) && quotation.customer.length > 0;
|
|
@@ -143,7 +122,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
143
122
|
var localSeen = new Set();
|
|
144
123
|
var quotationCustomers = quotation.customer || [];
|
|
145
124
|
quotationCustomers.forEach(function (customer) {
|
|
146
|
-
var customerId =
|
|
125
|
+
var customerId = _this2.normalizeCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
147
126
|
if (!customerId || localSeen.has(customerId)) return;
|
|
148
127
|
localSeen.add(customerId);
|
|
149
128
|
customerIds.push(customerId);
|
|
@@ -268,41 +247,6 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
268
247
|
value: function setScheduleResolver(resolver) {
|
|
269
248
|
this.scheduleResolver = resolver;
|
|
270
249
|
}
|
|
271
|
-
}, {
|
|
272
|
-
key: "applyQuotationResponse",
|
|
273
|
-
value: function applyQuotationResponse(response) {
|
|
274
|
-
var _data;
|
|
275
|
-
var source = (response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
276
|
-
this.store.list = _toConsumableArray(source).sort(function (a, b) {
|
|
277
|
-
return Number(b.sort || 0) - Number(a.sort || 0);
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}, {
|
|
281
|
-
key: "notifyQuotationListUpdated",
|
|
282
|
-
value: function notifyQuotationListUpdated() {
|
|
283
|
-
try {
|
|
284
|
-
var _this$quotationListUp;
|
|
285
|
-
(_this$quotationListUp = this.quotationListUpdatedListener) === null || _this$quotationListUp === void 0 || _this$quotationListUp.call(this);
|
|
286
|
-
} catch (error) {
|
|
287
|
-
console.warn('[QuotationModule] 报价单后台更新回调失败', error);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}, {
|
|
291
|
-
key: "getQuotationCacheKeyData",
|
|
292
|
-
value: function getQuotationCacheKeyData(query) {
|
|
293
|
-
var shopId = '';
|
|
294
|
-
try {
|
|
295
|
-
var _this$app, _this$app$getStorage;
|
|
296
|
-
var storedCore = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.storage) === null || _this$app === void 0 || (_this$app$getStorage = _this$app.getStorage) === null || _this$app$getStorage === void 0 ? void 0 : _this$app$getStorage.call(_this$app, 'core');
|
|
297
|
-
var coreInfo = typeof storedCore === 'string' ? JSON.parse(storedCore || '{}') : storedCore || {};
|
|
298
|
-
shopId = String((coreInfo === null || coreInfo === void 0 ? void 0 : coreInfo.id) || '');
|
|
299
|
-
} catch (_unused) {
|
|
300
|
-
// 缓存隔离信息读取失败时仍按请求参数缓存。
|
|
301
|
-
}
|
|
302
|
-
return _objectSpread(_objectSpread({}, query), {}, {
|
|
303
|
-
shop_id: shopId
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
250
|
}, {
|
|
307
251
|
key: "isQuotationVisibleForCustomer",
|
|
308
252
|
value: function isQuotationVisibleForCustomer(quotation, customerId) {
|
|
@@ -329,17 +273,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
273
|
key: "isQuotationActiveAt",
|
|
330
274
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
331
275
|
var _quotation$schedule,
|
|
332
|
-
|
|
276
|
+
_this3 = this;
|
|
333
277
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
334
278
|
var scheduleItems = [];
|
|
335
279
|
quotation.schedule.forEach(function (s) {
|
|
336
|
-
var
|
|
337
|
-
var full = (
|
|
280
|
+
var _this3$scheduleResolv;
|
|
281
|
+
var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
|
|
338
282
|
if (full) {
|
|
339
283
|
scheduleItems.push(full);
|
|
340
284
|
return;
|
|
341
285
|
}
|
|
342
|
-
if (
|
|
286
|
+
if (_this3.scheduleResolver) {
|
|
343
287
|
return;
|
|
344
288
|
}
|
|
345
289
|
var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -157,17 +157,13 @@ declare class Server {
|
|
|
157
157
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
|
|
158
158
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
159
159
|
*/
|
|
160
|
-
refreshProductsInBackground(
|
|
161
|
-
trigger?: string;
|
|
162
|
-
}): Promise<void>;
|
|
160
|
+
refreshProductsInBackground(): Promise<void>;
|
|
163
161
|
/**
|
|
164
162
|
* 后台静默刷新订单数据
|
|
165
163
|
* 重新拉取全量 SSE 接口,更新本地数据后触发 onOrdersSyncCompleted
|
|
166
164
|
* 不影响当前界面展示,适用于切回前台、定时刷新等场景
|
|
167
165
|
*/
|
|
168
|
-
refreshOrdersInBackground(
|
|
169
|
-
trigger?: string;
|
|
170
|
-
}): Promise<void>;
|
|
166
|
+
refreshOrdersInBackground(): Promise<void>;
|
|
171
167
|
/**
|
|
172
168
|
* 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
|
|
173
169
|
* 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,
|