@pisell/pisellos 2.3.113 → 2.3.115
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/modules/Order/index.d.ts +14 -4
- package/dist/modules/Order/index.js +316 -248
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +171 -63
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ResourcePlanner/planner.js +9 -5
- package/dist/modules/ResourcePlanner/types.d.ts +2 -1
- package/dist/server/index.js +4 -0
- package/dist/server/modules/order/index.js +6 -0
- package/dist/server/modules/order/types.d.ts +9 -0
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/server/utils/small-ticket.js +108 -4
- package/dist/solution/BaseSales/index.d.ts +8 -0
- package/dist/solution/BaseSales/index.js +1381 -1141
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -1
- package/dist/solution/BookingTicket/index.js +37 -16
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +14 -4
- package/lib/modules/Order/index.js +50 -15
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +101 -0
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ResourcePlanner/planner.js +9 -5
- package/lib/modules/ResourcePlanner/types.d.ts +2 -1
- package/lib/server/index.js +4 -0
- package/lib/server/modules/order/index.js +6 -0
- package/lib/server/modules/order/types.d.ts +9 -0
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/server/utils/small-ticket.js +114 -11
- package/lib/solution/BaseSales/index.d.ts +8 -0
- package/lib/solution/BaseSales/index.js +134 -22
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -1
- package/lib/solution/BookingTicket/index.js +23 -5
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
//
|
|
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
|
|
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;
|
package/lib/server/index.js
CHANGED
|
@@ -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',
|
|
@@ -2017,6 +2017,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2017
2017
|
mergedRecord[field] = (0, _lodashEs.cloneDeep)(incomingRecord[field]);
|
|
2018
2018
|
}
|
|
2019
2019
|
|
|
2020
|
+
// order_meta_list 是一次性生成的完整业务快照。incoming 明确携带时
|
|
2021
|
+
// 必须整体覆盖(包括 null / 空对象 / 空数组);省略时才保留 existing。
|
|
2022
|
+
if (Object.prototype.hasOwnProperty.call(incomingRecord, 'order_meta_list')) {
|
|
2023
|
+
mergedRecord.order_meta_list = (0, _lodashEs.cloneDeep)(incomingRecord.order_meta_list);
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2020
2026
|
// 子项数组遵循完整快照语义:incoming 自有且为数组(包括 [])时权威替换;
|
|
2021
2027
|
// 字段缺席或不是数组时视为稀疏 patch,继续保留 existing。
|
|
2022
2028
|
for (const field of ORDER_AUTHORITATIVE_COLLECTION_FIELDS) {
|
|
@@ -456,6 +456,15 @@ export interface OrderData {
|
|
|
456
456
|
par_value: string;
|
|
457
457
|
used_par_value: string;
|
|
458
458
|
}>;
|
|
459
|
+
virtual_currency_snapshot?: Array<{
|
|
460
|
+
id: number | string;
|
|
461
|
+
tag: 'virtual_currency';
|
|
462
|
+
product_id?: number | string;
|
|
463
|
+
product_name: string;
|
|
464
|
+
par_value: string;
|
|
465
|
+
used_par_value: string;
|
|
466
|
+
name: Record<string, string>;
|
|
467
|
+
}>;
|
|
459
468
|
};
|
|
460
469
|
/**
|
|
461
470
|
* 金额汇总(仅输出)。
|
|
@@ -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
|
|
12
|
-
private
|
|
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
|
-
|
|
19
|
-
private
|
|
27
|
+
private ensureInitialPayMethods;
|
|
28
|
+
private initPaymentDataSource;
|
|
29
|
+
private setupPaymentMethodSync;
|
|
30
|
+
private schedulePaymentMethodRefresh;
|
|
31
|
+
private refreshPayMethodsSingleFlight;
|
|
32
|
+
private performRemoteRefresh;
|
|
20
33
|
private fetchRemotePayMethods;
|
|
21
|
-
private
|
|
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
|
|
41
|
+
private setPayMethodMirror;
|
|
42
|
+
private getErrorMessage;
|
|
25
43
|
private logInfo;
|
|
26
44
|
private logWarning;
|
|
27
45
|
private logError;
|
|
46
|
+
destroy(): void;
|
|
28
47
|
}
|