@pisell/pisellos 2.2.305 → 2.2.307

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.
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -105,6 +105,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
105
105
  private groupBookingsByResource;
106
106
  private isBookingMatchedResource;
107
107
  private sortMatchedBookings;
108
+ /** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
109
+ private sortCompletedBookings;
108
110
  /** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
109
111
  private sortUnpaidBookings;
110
112
  /**
@@ -760,6 +760,20 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
760
760
  });
761
761
  }
762
762
 
763
+ /** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
764
+ }, {
765
+ key: "sortCompletedBookings",
766
+ value: function sortCompletedBookings(bookings) {
767
+ var createdAt = function createdAt(booking) {
768
+ var _booking$order3;
769
+ var timestamp = dayjs(((_booking$order3 = booking.order) === null || _booking$order3 === void 0 ? void 0 : _booking$order3.created_at) || '').valueOf();
770
+ return Number.isFinite(timestamp) ? timestamp : 0;
771
+ };
772
+ return _toConsumableArray(bookings).sort(function (left, right) {
773
+ return createdAt(right) - createdAt(left);
774
+ });
775
+ }
776
+
763
777
  /** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
764
778
  }, {
765
779
  key: "sortUnpaidBookings",
@@ -1260,7 +1274,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1260
1274
  bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList), {
1261
1275
  includeAllFuture: true
1262
1276
  });
1263
- completedBookings = completedBookingList.map(function (booking) {
1277
+ completedBookings = this.sortCompletedBookings(completedBookingList).map(function (booking) {
1264
1278
  return _objectSpread(_objectSpread({}, booking), {}, {
1265
1279
  status: 'compelete',
1266
1280
  isTimeout: false,
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -24,6 +24,7 @@ export declare class OrderModule extends BaseModule implements Module {
24
24
  private lastRecentSqliteWriteCleanupAtMs;
25
25
  /** 最近一次 SSE 全量拉取完成时间 */
26
26
  private lastServerFullFetchAtMs;
27
+ private businessDayRefreshPromise;
27
28
  constructor(name?: string, version?: string);
28
29
  /**
29
30
  * 广播订单变更事件,兼容全量列表订阅并额外携带本次变更订单。
@@ -130,6 +131,13 @@ export declare class OrderModule extends BaseModule implements Module {
130
131
  loadOrdersByServer(options?: {
131
132
  trigger?: string;
132
133
  }): Promise<OrderData[]>;
134
+ /**
135
+ * 供展示屏按需补齐当前营业日的订单快照;成功标记复用全量拉取落库逻辑。
136
+ * 拉取或落库失败时不记录已刷新,下一次调用仍可重试。
137
+ */
138
+ refreshOrdersForCurrentBusinessDay(options?: {
139
+ trigger?: string;
140
+ }): Promise<void>;
133
141
  /**
134
142
  * 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
135
143
  * 拿到完整数据后一次性替换 store,触发订单变更与同步完成事件
@@ -61,6 +61,7 @@ class OrderModule extends _BaseModule.BaseModule {
61
61
  lastRecentSqliteWriteCleanupAtMs = 0;
62
62
  /** 最近一次 SSE 全量拉取完成时间 */
63
63
  lastServerFullFetchAtMs = 0;
64
+ businessDayRefreshPromise = null;
64
65
  constructor(name, version) {
65
66
  super(name, version);
66
67
  }
@@ -864,6 +865,24 @@ class OrderModule extends _BaseModule.BaseModule {
864
865
  return memoryOrders;
865
866
  }
866
867
 
868
+ /**
869
+ * 供展示屏按需补齐当前营业日的订单快照;成功标记复用全量拉取落库逻辑。
870
+ * 拉取或落库失败时不记录已刷新,下一次调用仍可重试。
871
+ */
872
+ async refreshOrdersForCurrentBusinessDay(options = {}) {
873
+ if (this.businessDayRefreshPromise) return this.businessDayRefreshPromise;
874
+ if (!this.orderDataSource || !this.getCurrentShopId() || this.hasPulledOrdersToday()) return;
875
+ const refreshPromise = this.silentRefresh({
876
+ trigger: options.trigger || 'business_day_rollover'
877
+ }).then(() => undefined);
878
+ this.businessDayRefreshPromise = refreshPromise;
879
+ try {
880
+ await refreshPromise;
881
+ } finally {
882
+ this.businessDayRefreshPromise = null;
883
+ }
884
+ }
885
+
867
886
  /**
868
887
  * 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
869
888
  * 拿到完整数据后一次性替换 store,触发订单变更与同步完成事件
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -105,6 +105,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
105
105
  private groupBookingsByResource;
106
106
  private isBookingMatchedResource;
107
107
  private sortMatchedBookings;
108
+ /** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
109
+ private sortCompletedBookings;
108
110
  /** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
109
111
  private sortUnpaidBookings;
110
112
  /**
@@ -507,6 +507,15 @@ class SalesImpl extends _BaseModule.BaseModule {
507
507
  });
508
508
  }
509
509
 
510
+ /** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
511
+ sortCompletedBookings(bookings) {
512
+ const createdAt = booking => {
513
+ const timestamp = (0, _dayjs.default)(booking.order?.created_at || '').valueOf();
514
+ return Number.isFinite(timestamp) ? timestamp : 0;
515
+ };
516
+ return [...bookings].sort((left, right) => createdAt(right) - createdAt(left));
517
+ }
518
+
510
519
  /** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
511
520
  sortUnpaidBookings(bookings, currentBookings) {
512
521
  const currentOrderIndexes = new Map(currentBookings.map((booking, index) => [String(booking.order.order_id), index]));
@@ -881,7 +890,7 @@ class SalesImpl extends _BaseModule.BaseModule {
881
890
  const bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList), {
882
891
  includeAllFuture: true
883
892
  });
884
- const completedBookings = completedBookingList.map(booking => {
893
+ const completedBookings = this.sortCompletedBookings(completedBookingList).map(booking => {
885
894
  return {
886
895
  ...booking,
887
896
  status: 'compelete',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.305",
4
+ "version": "2.2.307",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",