@pisell/pisellos 2.3.113 → 2.3.114

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 | 1 | 6 | 5 | 3 | 4;
329
+ weekNum: 0 | 2 | 3 | 1 | 5 | 6 | 4;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
345
345
  * 获取当前的客户搜索条件
346
346
  * @returns 当前搜索条件
347
347
  */
348
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
348
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
349
349
  /**
350
350
  * 获取客户列表状态(包含滚动加载相关状态)
351
351
  * @returns 客户状态
@@ -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";
@@ -171,11 +171,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
171
171
  * 获取钱包支付方式
172
172
  */
173
173
  getWalletPaymentMethod(): Promise<PaymentMethod | null>;
174
- /**
175
- * 确保支付模块所需的数据库表已创建
176
- */
177
- /** @deprecated */
178
- private ensurePaymentTables;
179
174
  /**
180
175
  * 获取部分支付的订单
181
176
  */
@@ -159,10 +159,6 @@ class PaymentModule extends _BaseModule.BaseModule {
159
159
  this.app = this.appPlugin.getApp();
160
160
  this.dbManager = this.app.dbManager;
161
161
  this.logger = this.app.logger;
162
-
163
- // 确保支付模块所需的对象存储已创建
164
- // await this.ensurePaymentTables();
165
-
166
162
  this.registerNetworkHandlers();
167
163
 
168
164
  // // 预连接数据库
@@ -1111,7 +1107,7 @@ class PaymentModule extends _BaseModule.BaseModule {
1111
1107
  */
1112
1108
  async getCashPaymentMethod() {
1113
1109
  try {
1114
- const payMethods = await this.dbManager.getAll('pay_method');
1110
+ const payMethods = await this.getPayMethodListAsync();
1115
1111
  return payMethods.find(method => method.code === _types.PaymentMethodType.Cash) || null;
1116
1112
  } catch (error) {
1117
1113
  console.error('[PaymentModule] 获取现金支付方式失败', error);
@@ -1124,7 +1120,7 @@ class PaymentModule extends _BaseModule.BaseModule {
1124
1120
  */
1125
1121
  async getEftposPaymentMethod() {
1126
1122
  try {
1127
- const payMethods = await this.dbManager.getAll('pay_method');
1123
+ const payMethods = await this.getPayMethodListAsync();
1128
1124
  return payMethods.find(method => method.code === _types.PaymentMethodType.Eftpos) || null;
1129
1125
  } catch (error) {
1130
1126
  console.error('[PaymentModule] 获取Eftpos支付方式失败', error);
@@ -1137,7 +1133,7 @@ class PaymentModule extends _BaseModule.BaseModule {
1137
1133
  */
1138
1134
  async getWalletPaymentMethod() {
1139
1135
  try {
1140
- const payMethods = await this.dbManager.getAll('pay_method');
1136
+ const payMethods = await this.getPayMethodListAsync();
1141
1137
  return payMethods.find(method => method.code === _types.PaymentMethodType.Wallet) || null;
1142
1138
  } catch (error) {
1143
1139
  console.error('[PaymentModule] 获取钱包支付方式失败', error);
@@ -1145,27 +1141,6 @@ class PaymentModule extends _BaseModule.BaseModule {
1145
1141
  }
1146
1142
  }
1147
1143
 
1148
- /**
1149
- * 确保支付模块所需的数据库表已创建
1150
- */
1151
- /** @deprecated */
1152
- async ensurePaymentTables() {
1153
- try {
1154
- // 尝试访问 pay_method 表,如果不存在会抛出错误
1155
- await this.dbManager.getAll('pay_method');
1156
- } catch (error) {
1157
- console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
1158
- console.warn('{ name: "pay_method", keyPath: "id" }');
1159
- }
1160
- try {
1161
- // 尝试访问 order 表,如果不存在会抛出错误
1162
- await this.dbManager.getAll('order');
1163
- } catch (error) {
1164
- console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
1165
- console.warn('{ name: "order", keyPath: "uuid" }');
1166
- }
1167
- }
1168
-
1169
1144
  /**
1170
1145
  * 获取部分支付的订单
1171
1146
  */
@@ -281,12 +281,14 @@ function evaluateCandidateTimeGate(params) {
281
281
  };
282
282
  }
283
283
  if (policy.type === 'before_start') {
284
- // Flexible-duration candidates and POS fixed-duration anchors start at
285
- // minute precision. Keep that current minute selectable instead of treating
286
- // the freshly generated candidate as already started because the query
287
- // clock still contains seconds.
284
+ // POS fixed-duration candidates use the context's stable opening-minute
285
+ // anchor. Keep that anchored range selectable while it is still active;
286
+ // otherwise a minute refresh turns it into 0 capacity and incorrectly
287
+ // advances a create flow to the next slot. The earlier `past` gate still
288
+ // rejects the anchor once its booking range has ended.
289
+ const isActivePosDurationAnchor = evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration' && !product.isFlexibleDuration && evaluationContext.durationCandidateAnchorAtMs === candidateRange.start;
288
290
  const usesMinutePrecision = product.isFlexibleDuration || evaluationContext.useExactDurationCandidateMinute && product.kind === 'duration';
289
- const hasNotReachedStart = usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start;
291
+ const hasNotReachedStart = isActivePosDurationAnchor || (usesMinutePrecision ? floorToMinute(now) <= candidateRange.start : now < candidateRange.start);
290
292
  if (hasNotReachedStart) return null;
291
293
  return {
292
294
  status: 'unavailable',
@@ -1249,6 +1251,7 @@ function buildAvailabilityCellIndex(projection) {
1249
1251
  }
1250
1252
  function buildEvaluationContext(params) {
1251
1253
  const evaluatedAt = toDateTime(params.evaluatedAt || params.projection.meta.now, params.projection.meta.timezone);
1254
+ const durationCandidateAnchorAt = toDateTime(params.projection.meta.durationCandidateAnchorAt, params.projection.meta.timezone);
1252
1255
  const selectionsByGroupKey = new Map();
1253
1256
  (params.requirementSelections || []).forEach(selection => {
1254
1257
  const key = selection.requirementGroupId || String(selection.formId ?? '');
@@ -1260,6 +1263,7 @@ function buildEvaluationContext(params) {
1260
1263
  resourceIdSet: params.resourceIds?.length ? new Set(params.resourceIds.map(String)) : null,
1261
1264
  selectionsByGroupKey,
1262
1265
  useExactDurationCandidateMinute: params.useExactDurationCandidateMinute === true,
1266
+ durationCandidateAnchorAtMs: Number.isFinite(durationCandidateAnchorAt) ? floorToMinute(durationCandidateAnchorAt) : null,
1263
1267
  allowExcludedScheduleDateOverride: params.allowExcludedScheduleDateOverride === true
1264
1268
  };
1265
1269
  }
@@ -253,7 +253,8 @@ export interface GetProductTimeRangesRuntimeOptions {
253
253
  /**
254
254
  * Internal POS capability: fixed-duration candidates start from the stable
255
255
  * context anchor's current minute instead of rounding up to ten minutes, and
256
- * that minute remains selectable during before-start cutoff evaluation.
256
+ * that anchored range remains selectable while active during before-start
257
+ * cutoff evaluation.
257
258
  * Other callers keep the legacy alignment and strict second-level cutoff.
258
259
  */
259
260
  useExactDurationCandidateMinute?: boolean;
@@ -1296,6 +1296,10 @@ class Server {
1296
1296
  method: 'get',
1297
1297
  path: '/shop/pay/custom-payment/all',
1298
1298
  handler: this.handlePaymentMethods.bind(this)
1299
+ }, {
1300
+ method: 'get',
1301
+ path: '/pay/custom-payment/all',
1302
+ handler: this.handlePaymentMethods.bind(this)
1299
1303
  }, {
1300
1304
  method: 'get',
1301
1305
  path: '/shop/quotation/available',
@@ -7,22 +7,41 @@ export declare class PaymentServerModule extends BaseModule implements Module {
7
7
  private request;
8
8
  private app;
9
9
  private logger;
10
+ private dbManager;
10
11
  private store;
11
- private payMethodMemoryCache;
12
- private payMethodListInFlight;
12
+ private paymentDataSource;
13
+ private initialLoadInFlight;
14
+ private refreshInFlight;
15
+ private hasLoadedPayMethods;
16
+ private hasEmittedLoaded;
17
+ private syncTimer;
18
+ private pendingMessageUuids;
19
+ private queuedTrailingRefresh;
20
+ private trailingMessageUuids;
13
21
  constructor(name?: string, version?: string);
14
22
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
23
+ preload(): Promise<void>;
15
24
  getPayMethodListAsync(options?: {
16
25
  shouldFilter?: boolean;
17
26
  }): Promise<PaymentMethod[]>;
18
- clearPayMethodCache(): void;
19
- private loadPayMethodListAsync;
27
+ private ensureInitialPayMethods;
28
+ private initPaymentDataSource;
29
+ private setupPaymentMethodSync;
30
+ private schedulePaymentMethodRefresh;
31
+ private refreshPayMethodsSingleFlight;
32
+ private performRemoteRefresh;
20
33
  private fetchRemotePayMethods;
21
- private shouldFilterPayMethods;
34
+ private loadPayMethodsFromSQLite;
35
+ private replacePayMethodsInSQLite;
36
+ private resolveCurrentShopScope;
37
+ private stripSnapshotFields;
38
+ private arePayMethodsEqual;
22
39
  private resolvePayMethods;
23
40
  private filterPayMethods;
24
- private setPayMethodCache;
41
+ private setPayMethodMirror;
42
+ private getErrorMessage;
25
43
  private logInfo;
26
44
  private logWarning;
27
45
  private logError;
46
+ destroy(): void;
28
47
  }