@pisell/pisellos 2.2.111 → 2.2.113
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.
|
@@ -24,6 +24,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
24
24
|
protected options: ModuleOptions;
|
|
25
25
|
protected otherParams: Record<string, any>;
|
|
26
26
|
protected request: RequestPlugin;
|
|
27
|
+
private logger;
|
|
27
28
|
constructor(name?: string, version?: string);
|
|
28
29
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
29
30
|
/** 获取当前 store 快照 */
|
|
@@ -43,6 +43,8 @@ export * from "./types";
|
|
|
43
43
|
export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
44
44
|
_inherits(SalesImpl, _BaseModule);
|
|
45
45
|
var _super = _createSuper(SalesImpl);
|
|
46
|
+
// LoggerManager 实例
|
|
47
|
+
|
|
46
48
|
function SalesImpl(name, version) {
|
|
47
49
|
var _this;
|
|
48
50
|
_classCallCheck(this, SalesImpl);
|
|
@@ -55,6 +57,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
55
57
|
_defineProperty(_assertThisInitialized(_this), "options", {});
|
|
56
58
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
57
59
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
58
61
|
return _this;
|
|
59
62
|
}
|
|
60
63
|
_createClass(SalesImpl, [{
|
|
@@ -87,9 +90,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
87
90
|
|
|
88
91
|
// TODO(Rolo): 等领导提供 reservationList 的目标结构后,
|
|
89
92
|
// 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
|
|
90
|
-
|
|
93
|
+
|
|
94
|
+
this.logger = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp().logger;
|
|
95
|
+
_context.next = 12;
|
|
91
96
|
return this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
92
|
-
case
|
|
97
|
+
case 12:
|
|
93
98
|
case "end":
|
|
94
99
|
return _context.stop();
|
|
95
100
|
}
|
|
@@ -510,6 +515,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
510
515
|
resourceList,
|
|
511
516
|
normalizedBookings,
|
|
512
517
|
bookingMap,
|
|
518
|
+
list,
|
|
513
519
|
_args3 = arguments;
|
|
514
520
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
515
521
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -555,13 +561,16 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
555
561
|
return _this3.normalizeMatchedBooking(current, deviceCurrent, booking);
|
|
556
562
|
}).filter(function (booking) {
|
|
557
563
|
return Boolean(booking);
|
|
558
|
-
}).filter(function (booking) {
|
|
559
|
-
return !booking.status;
|
|
560
564
|
}).sort(function (left, right) {
|
|
561
565
|
var leftStartAt = _this3.toBookingDateTime(left.start_date, left.start_time).valueOf();
|
|
562
566
|
var rightStartAt = _this3.toBookingDateTime(right.start_date, right.start_time).valueOf();
|
|
563
567
|
return leftStartAt - rightStartAt;
|
|
564
|
-
}); //
|
|
568
|
+
}); // 过滤掉没有 status 的 booking
|
|
569
|
+
normalizedBookings = normalizedBookings.filter(function (booking) {
|
|
570
|
+
return !booking.status;
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// 建立 resourceId -> bookings[] 倒排索引,加速资源匹配
|
|
565
574
|
bookingMap = new Map();
|
|
566
575
|
normalizedBookings.forEach(function (booking) {
|
|
567
576
|
if (!Array.isArray(booking.resources)) return;
|
|
@@ -576,7 +585,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
576
585
|
});
|
|
577
586
|
|
|
578
587
|
// 输出:每个资源都返回;bookings 可能是 0 / 1 / 多条(并发场景)
|
|
579
|
-
|
|
588
|
+
list = resourceList.map(function (resource) {
|
|
580
589
|
var resourceId = _this3.getResourceId(resource);
|
|
581
590
|
var matchedBookings = bookingMap.get(String(resourceId)) || [];
|
|
582
591
|
var bookings = _this3.pickBookingsForCurrentPoint(current, matchedBookings);
|
|
@@ -584,8 +593,15 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
584
593
|
resource_id: resourceId,
|
|
585
594
|
bookings: bookings
|
|
586
595
|
});
|
|
587
|
-
})
|
|
588
|
-
|
|
596
|
+
});
|
|
597
|
+
this.logger.info('getResourceBookingList', {
|
|
598
|
+
currentTime: currentTime,
|
|
599
|
+
bookingList: bookingList,
|
|
600
|
+
deviceTime: deviceTime,
|
|
601
|
+
list: list
|
|
602
|
+
});
|
|
603
|
+
return _context3.abrupt("return", list);
|
|
604
|
+
case 21:
|
|
589
605
|
case "end":
|
|
590
606
|
return _context3.stop();
|
|
591
607
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -24,6 +24,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
24
24
|
protected options: ModuleOptions;
|
|
25
25
|
protected otherParams: Record<string, any>;
|
|
26
26
|
protected request: RequestPlugin;
|
|
27
|
+
private logger;
|
|
27
28
|
constructor(name?: string, version?: string);
|
|
28
29
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
29
30
|
/** 获取当前 store 快照 */
|
|
@@ -40,6 +40,7 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
42
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
|
+
// LoggerManager 实例
|
|
43
44
|
constructor(name, version) {
|
|
44
45
|
super(name, version);
|
|
45
46
|
this.defaultName = "sales";
|
|
@@ -62,6 +63,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
62
63
|
currentDay: (0, import_dayjs.default)().startOf("day"),
|
|
63
64
|
reservationList: []
|
|
64
65
|
};
|
|
66
|
+
this.logger = appPlugin == null ? void 0 : appPlugin.getApp().logger;
|
|
65
67
|
await this.core.effects.emit(`${this.name}:onInited`, {});
|
|
66
68
|
}
|
|
67
69
|
// -------------------------------------------------------------------------
|
|
@@ -407,11 +409,12 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
407
409
|
const resourceList = ((_a = resourceResponse == null ? void 0 : resourceResponse.data) == null ? void 0 : _a.list) ?? [];
|
|
408
410
|
if (!Array.isArray(resourceList) || resourceList.length === 0)
|
|
409
411
|
return [];
|
|
410
|
-
|
|
412
|
+
let normalizedBookings = bookingList.map((booking) => this.normalizeMatchedBooking(current, deviceCurrent, booking)).filter((booking) => Boolean(booking)).sort((left, right) => {
|
|
411
413
|
const leftStartAt = this.toBookingDateTime(left.start_date, left.start_time).valueOf();
|
|
412
414
|
const rightStartAt = this.toBookingDateTime(right.start_date, right.start_time).valueOf();
|
|
413
415
|
return leftStartAt - rightStartAt;
|
|
414
416
|
});
|
|
417
|
+
normalizedBookings = normalizedBookings.filter((booking) => !booking.status);
|
|
415
418
|
const bookingMap = /* @__PURE__ */ new Map();
|
|
416
419
|
normalizedBookings.forEach((booking) => {
|
|
417
420
|
if (!Array.isArray(booking.resources))
|
|
@@ -421,12 +424,12 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
421
424
|
if (relationId === void 0 || relationId === null)
|
|
422
425
|
return;
|
|
423
426
|
const key = String(relationId);
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
bookingMap.set(key,
|
|
427
|
+
const list2 = bookingMap.get(key) || [];
|
|
428
|
+
list2.push(booking);
|
|
429
|
+
bookingMap.set(key, list2);
|
|
427
430
|
});
|
|
428
431
|
});
|
|
429
|
-
|
|
432
|
+
const list = resourceList.map((resource) => {
|
|
430
433
|
const resourceId = this.getResourceId(resource);
|
|
431
434
|
const matchedBookings = bookingMap.get(String(resourceId)) || [];
|
|
432
435
|
const bookings = this.pickBookingsForCurrentPoint(current, matchedBookings);
|
|
@@ -436,6 +439,13 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
436
439
|
bookings
|
|
437
440
|
};
|
|
438
441
|
});
|
|
442
|
+
this.logger.info("getResourceBookingList", {
|
|
443
|
+
currentTime,
|
|
444
|
+
bookingList,
|
|
445
|
+
deviceTime,
|
|
446
|
+
list
|
|
447
|
+
});
|
|
448
|
+
return list;
|
|
439
449
|
}
|
|
440
450
|
};
|
|
441
451
|
var Sales_default = SalesImpl;
|