@pisell/pisellos 2.2.220 → 2.2.222
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Customer/index.d.ts +7 -0
- package/dist/modules/Customer/index.js +27 -0
- package/dist/modules/Order/index.js +17 -11
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/utils.js +6 -5
- package/dist/modules/Payment/index.d.ts +3 -0
- package/dist/modules/Payment/index.js +6 -4
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Schedule/index.js +3 -1
- package/dist/modules/Summary/index.js +2 -2
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +48 -18
- package/dist/server/modules/order/index.js +14 -7
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/modules/order/utils/filterBookings.js +1 -1
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +99 -83
- package/dist/server/utils/small-ticket.d.ts +3 -1
- package/dist/server/utils/small-ticket.js +106 -18
- package/dist/solution/BaseSales/index.js +7 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -2
- package/dist/solution/BookingTicket/index.js +12 -8
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +10 -9
- package/lib/modules/Customer/index.d.ts +7 -0
- package/lib/modules/Customer/index.js +26 -0
- package/lib/modules/Order/index.js +7 -3
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/utils.js +2 -1
- package/lib/modules/Payment/index.d.ts +3 -0
- package/lib/modules/Payment/index.js +3 -1
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/Summary/index.js +3 -3
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +37 -7
- package/lib/server/modules/order/index.js +8 -1
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/modules/order/utils/filterBookings.js +7 -3
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +45 -39
- package/lib/server/utils/small-ticket.d.ts +3 -1
- package/lib/server/utils/small-ticket.js +85 -11
- package/lib/solution/BaseSales/index.js +6 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -2
- package/lib/solution/BookingTicket/index.js +3 -3
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +1 -2
- package/package.json +1 -1
|
@@ -117,20 +117,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
117
|
_context.next = 15;
|
|
118
118
|
return this.initializeSubModules(core, options);
|
|
119
119
|
case 15:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
// 预加载支付方式(利用缓存机制)
|
|
121
|
+
// await this.preloadPaymentMethods();
|
|
122
|
+
|
|
123
|
+
// 清理过期的已同步订单数据
|
|
124
|
+
// await this.cleanupExpiredOrdersAsync();
|
|
125
|
+
|
|
126
126
|
console.log('[Checkout] 初始化完成');
|
|
127
|
-
_context.next =
|
|
127
|
+
_context.next = 18;
|
|
128
128
|
return this.core.effects.emit("".concat(this.name, ":onCheckoutInitialized"), {
|
|
129
129
|
timestamp: Date.now()
|
|
130
130
|
});
|
|
131
|
-
case
|
|
131
|
+
case 18:
|
|
132
132
|
this.logInfo('CheckoutModule initialized successfully');
|
|
133
|
-
case
|
|
133
|
+
case 19:
|
|
134
134
|
case "end":
|
|
135
135
|
return _context.stop();
|
|
136
136
|
}
|
|
@@ -2868,6 +2868,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2868
2868
|
*
|
|
2869
2869
|
* 删除本地 IndexDB 中超过指定天数且已同步到后端的订单数据
|
|
2870
2870
|
*/
|
|
2871
|
+
/** @deprecated */
|
|
2871
2872
|
)
|
|
2872
2873
|
}, {
|
|
2873
2874
|
key: "cleanupExpiredOrdersAsync",
|
|
@@ -7,6 +7,13 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
7
7
|
private store;
|
|
8
8
|
private request;
|
|
9
9
|
private cacheId;
|
|
10
|
+
/**
|
|
11
|
+
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
15
|
+
*/
|
|
16
|
+
private isSameSelectedCustomer;
|
|
10
17
|
private openCache;
|
|
11
18
|
private fatherModule;
|
|
12
19
|
private otherParams;
|
|
@@ -48,6 +48,29 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
48
48
|
this.openCache = false;
|
|
49
49
|
this.otherParams = {};
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
56
|
+
*/
|
|
57
|
+
isSameSelectedCustomer(current, next) {
|
|
58
|
+
const normalizedNext = !next ? import_constants.DEFAULT_CUSTOMER : next;
|
|
59
|
+
const normalizedCurrent = current || null;
|
|
60
|
+
if (!normalizedCurrent)
|
|
61
|
+
return false;
|
|
62
|
+
if (String((normalizedCurrent == null ? void 0 : normalizedCurrent.id) ?? "") === "1" && String((normalizedNext == null ? void 0 : normalizedNext.id) ?? "") === "1") {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const keys = [
|
|
66
|
+
"id",
|
|
67
|
+
"name",
|
|
68
|
+
"phone",
|
|
69
|
+
"email",
|
|
70
|
+
"country_calling_code"
|
|
71
|
+
];
|
|
72
|
+
return keys.every((key) => String((normalizedCurrent == null ? void 0 : normalizedCurrent[key]) ?? "") === String((normalizedNext == null ? void 0 : normalizedNext[key]) ?? ""));
|
|
73
|
+
}
|
|
51
74
|
async initialize(core, options) {
|
|
52
75
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
53
76
|
this.core = core;
|
|
@@ -225,6 +248,9 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
225
248
|
* @param customer 选择的客户
|
|
226
249
|
*/
|
|
227
250
|
setSelectedCustomer(customer) {
|
|
251
|
+
if (this.isSameSelectedCustomer(this.store.selectedCustomer, customer)) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
228
254
|
this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
|
|
229
255
|
this.core.effects.emit(
|
|
230
256
|
`${this.name}:onCustomerSelected`,
|
|
@@ -3050,7 +3050,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3050
3050
|
* 例如数组字段、商品行唯一值、价格 metadata、summary 派生状态和 _extend。
|
|
3051
3051
|
*/
|
|
3052
3052
|
async hydrateTempOrderFromRecord(record, options) {
|
|
3053
|
-
var _a, _b;
|
|
3053
|
+
var _a, _b, _c;
|
|
3054
3054
|
const raw = record && typeof record === "object" && record.data && record.order_id == null ? record.data : record || {};
|
|
3055
3055
|
const nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
3056
3056
|
const rawSummary = raw.summary && typeof raw.summary === "object" ? raw.summary : {};
|
|
@@ -3073,8 +3073,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3073
3073
|
};
|
|
3074
3074
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
3075
3075
|
const hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
3076
|
-
|
|
3077
|
-
|
|
3076
|
+
const currentDiscounts = typeof ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList) === "function" ? this.store.discount.getDiscountList() || [] : [];
|
|
3077
|
+
const shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
3078
|
+
if (!shouldSkipEmptyDiscountSync) {
|
|
3079
|
+
await ((_b = this.store.discount) == null ? void 0 : _b.setOriginalDiscountList(hydratedEditDiscounts));
|
|
3080
|
+
await ((_c = this.store.discount) == null ? void 0 : _c.setDiscountList(hydratedEditDiscounts));
|
|
3081
|
+
}
|
|
3078
3082
|
if (options == null ? void 0 : options.recalcOnHydrate) {
|
|
3079
3083
|
await this.recalculateSummary({ createIfMissing: false });
|
|
3080
3084
|
}
|
|
@@ -434,6 +434,8 @@ export interface PaymentItemData {
|
|
|
434
434
|
name: string;
|
|
435
435
|
/** 支付类型 */
|
|
436
436
|
type: string;
|
|
437
|
+
/** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
438
|
+
payment_time?: string;
|
|
437
439
|
/** @deprecated BaseSales/Sales 协议不提交该字段;旧 Checkout/Payment 内部仍可能使用 */
|
|
438
440
|
isSynced?: boolean;
|
|
439
441
|
}
|
|
@@ -456,6 +458,7 @@ export interface OrderPaymentData {
|
|
|
456
458
|
origin_amount?: string;
|
|
457
459
|
service_fee?: string;
|
|
458
460
|
status?: 'active' | 'voided' | string;
|
|
461
|
+
/** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
459
462
|
payment_time?: string;
|
|
460
463
|
wallet_pass_usage_unit?: unknown;
|
|
461
464
|
wallet_pass_use_value?: string | number | null;
|
|
@@ -818,6 +818,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
818
818
|
metadata[key] = item[key];
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
|
+
const paymentTime = item.payment_time ?? (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
821
822
|
return {
|
|
822
823
|
...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
|
|
823
824
|
amount: String(item.amount ?? "0.00"),
|
|
@@ -829,7 +830,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
829
830
|
...item.origin_amount !== void 0 ? { origin_amount: String(item.origin_amount) } : {},
|
|
830
831
|
...item.service_fee !== void 0 ? { service_fee: String(item.service_fee) } : {},
|
|
831
832
|
...item.status !== void 0 ? { status: item.status } : {},
|
|
832
|
-
|
|
833
|
+
payment_time: paymentTime,
|
|
833
834
|
...item.wallet_pass_usage_unit !== void 0 ? { wallet_pass_usage_unit: item.wallet_pass_usage_unit } : {},
|
|
834
835
|
...item.wallet_pass_use_value !== void 0 ? { wallet_pass_use_value: item.wallet_pass_use_value } : {},
|
|
835
836
|
...item.fund_record && typeof item.fund_record === "object" && !Array.isArray(item.fund_record) ? { fund_record: { ...item.fund_record } } : {},
|
|
@@ -61,6 +61,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
61
61
|
/**
|
|
62
62
|
* 获取订单列表
|
|
63
63
|
*/
|
|
64
|
+
/** @deprecated */
|
|
64
65
|
getOrderListAsync(): Promise<PaymentOrder[]>;
|
|
65
66
|
/**
|
|
66
67
|
* 根据订单UUID获取支付订单(新方法)
|
|
@@ -160,10 +161,12 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
160
161
|
/**
|
|
161
162
|
* 确保支付模块所需的数据库表已创建
|
|
162
163
|
*/
|
|
164
|
+
/** @deprecated */
|
|
163
165
|
private ensurePaymentTables;
|
|
164
166
|
/**
|
|
165
167
|
* 获取部分支付的订单
|
|
166
168
|
*/
|
|
169
|
+
/** @deprecated */
|
|
167
170
|
getPartiallyPaidOrdersAsync(): Promise<PaymentOrder[]>;
|
|
168
171
|
/**
|
|
169
172
|
* 智能金额舍入
|
|
@@ -123,7 +123,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
123
123
|
this.app = appPlugin.getApp();
|
|
124
124
|
this.dbManager = this.app.dbManager;
|
|
125
125
|
this.logger = this.app.logger;
|
|
126
|
-
await this.ensurePaymentTables();
|
|
127
126
|
this.registerNetworkHandlers();
|
|
128
127
|
console.log("[PaymentModule] 初始化完成");
|
|
129
128
|
this.logInfo("PaymentModule initialized successfully");
|
|
@@ -235,6 +234,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
235
234
|
/**
|
|
236
235
|
* 获取订单列表
|
|
237
236
|
*/
|
|
237
|
+
/** @deprecated */
|
|
238
238
|
async getOrderListAsync() {
|
|
239
239
|
try {
|
|
240
240
|
return await this.dbManager.getAll("order");
|
|
@@ -992,6 +992,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
992
992
|
/**
|
|
993
993
|
* 确保支付模块所需的数据库表已创建
|
|
994
994
|
*/
|
|
995
|
+
/** @deprecated */
|
|
995
996
|
async ensurePaymentTables() {
|
|
996
997
|
try {
|
|
997
998
|
await this.dbManager.getAll("pay_method");
|
|
@@ -1013,6 +1014,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1013
1014
|
/**
|
|
1014
1015
|
* 获取部分支付的订单
|
|
1015
1016
|
*/
|
|
1017
|
+
/** @deprecated */
|
|
1016
1018
|
async getPartiallyPaidOrdersAsync() {
|
|
1017
1019
|
try {
|
|
1018
1020
|
const allOrders = await this.dbManager.getAll("order");
|
|
@@ -135,6 +135,8 @@ export interface PaymentItem {
|
|
|
135
135
|
origin_amount?: string;
|
|
136
136
|
/** 订单支付类型 */
|
|
137
137
|
order_payment_type?: 'normal' | 'deposit';
|
|
138
|
+
/** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
139
|
+
payment_time?: string;
|
|
138
140
|
/** 本支付项是否已成功同步到后端 */
|
|
139
141
|
isSynced?: boolean;
|
|
140
142
|
/** 最近一次同步失败信息(存在则代表同步失败过) */
|
|
@@ -135,8 +135,10 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
135
135
|
return dates;
|
|
136
136
|
}
|
|
137
137
|
getScheduleListByIds(ids) {
|
|
138
|
+
var _a;
|
|
138
139
|
const idSet = new Set(ids.map((id) => String(id)));
|
|
139
|
-
|
|
140
|
+
console.log("getScheduleListByIds", this.store.scheduleList);
|
|
141
|
+
const list = (_a = this.store.scheduleList) == null ? void 0 : _a.filter((n) => idSet.has(String(n.id)));
|
|
140
142
|
return list;
|
|
141
143
|
}
|
|
142
144
|
setAvailabilityScheduleDateList(list) {
|
|
@@ -74,10 +74,10 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
74
74
|
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
75
75
|
}
|
|
76
76
|
async getSummary(cartItems) {
|
|
77
|
-
var _a, _b, _c;
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
78
|
const shopInfo = ((_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.shop) || {};
|
|
79
79
|
const scheduleModule = this.core.getModule("appointmentBooking_schedule");
|
|
80
|
-
const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
|
|
80
|
+
const needScheduleIds = (_c = this.store.surchargeList) == null ? void 0 : _c.map((item) => item.available_schedule_ids).flat();
|
|
81
81
|
const scheduleList = scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
|
|
82
82
|
const scheduleById = {};
|
|
83
83
|
if (Array.isArray(scheduleList)) {
|
|
@@ -85,7 +85,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
85
85
|
scheduleById[item.id] = item;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
const summary = (0, import_utils.calculatePriceDetails)(shopInfo, cartItems, (
|
|
88
|
+
const summary = (0, import_utils.calculatePriceDetails)(shopInfo, cartItems, (_d = import_Schedule.ScheduleModule) == null ? void 0 : _d.isInScheduleByDate, this.store.surchargeList, scheduleById);
|
|
89
89
|
this.store.summary = summary;
|
|
90
90
|
return this.store.summary;
|
|
91
91
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -412,6 +412,8 @@ declare class Server {
|
|
|
412
412
|
private getProductTitleSnapshotCurrentLocale;
|
|
413
413
|
private normalizeProductTitleSnapshotLocale;
|
|
414
414
|
private resolveProductTitleValue;
|
|
415
|
+
private canAssignStringProductTitleToLocale;
|
|
416
|
+
private hasCjkText;
|
|
415
417
|
private resolveFirstProductTitleValue;
|
|
416
418
|
private withLocalSmallTicketData;
|
|
417
419
|
private handleOrderSalesDetail;
|
package/lib/server/index.js
CHANGED
|
@@ -2611,6 +2611,7 @@ var Server = class {
|
|
|
2611
2611
|
total_amount: (_d = pendingOrder == null ? void 0 : pendingOrder.summary) == null ? void 0 : _d.total_amount,
|
|
2612
2612
|
payment_status: pendingOrder == null ? void 0 : pendingOrder.payment_status,
|
|
2613
2613
|
payment_info: {
|
|
2614
|
+
...(pendingOrder == null ? void 0 : pendingOrder.payment_info) || {},
|
|
2614
2615
|
current_change_given_amount: changeGivenAmount
|
|
2615
2616
|
}
|
|
2616
2617
|
}
|
|
@@ -2705,11 +2706,22 @@ var Server = class {
|
|
|
2705
2706
|
async buildSmallTicketProductMap(order) {
|
|
2706
2707
|
var _a;
|
|
2707
2708
|
const products = Array.isArray(order == null ? void 0 : order.products) ? order.products : [];
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
)
|
|
2712
|
-
|
|
2709
|
+
const productIdSet = /* @__PURE__ */ new Set();
|
|
2710
|
+
products.forEach((product) => {
|
|
2711
|
+
const productId = (product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id);
|
|
2712
|
+
if (productId !== void 0 && productId !== null && productId !== "") {
|
|
2713
|
+
productIdSet.add(productId);
|
|
2714
|
+
}
|
|
2715
|
+
if (Array.isArray(product == null ? void 0 : product.product_bundle)) {
|
|
2716
|
+
product.product_bundle.forEach((bundle) => {
|
|
2717
|
+
const bundleProductId = (bundle == null ? void 0 : bundle.bundle_product_id) ?? (bundle == null ? void 0 : bundle._bundle_product_id) ?? (bundle == null ? void 0 : bundle.product_id);
|
|
2718
|
+
if (bundleProductId !== void 0 && bundleProductId !== null && bundleProductId !== "") {
|
|
2719
|
+
productIdSet.add(bundleProductId);
|
|
2720
|
+
}
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
});
|
|
2724
|
+
const productIds = Array.from(productIdSet);
|
|
2713
2725
|
if (!productIds.length || typeof ((_a = this.products) == null ? void 0 : _a.getProductById) !== "function")
|
|
2714
2726
|
return {};
|
|
2715
2727
|
const entries = await Promise.all(
|
|
@@ -2777,8 +2789,11 @@ var Server = class {
|
|
|
2777
2789
|
if (value === void 0 || value === null || value === "")
|
|
2778
2790
|
return null;
|
|
2779
2791
|
if (typeof value !== "object") {
|
|
2780
|
-
|
|
2781
|
-
|
|
2792
|
+
const title = String(value);
|
|
2793
|
+
if (key === "auto" || key === "original")
|
|
2794
|
+
return title;
|
|
2795
|
+
if (key === currentLocale && this.canAssignStringProductTitleToLocale(title, currentLocale))
|
|
2796
|
+
return title;
|
|
2782
2797
|
return null;
|
|
2783
2798
|
}
|
|
2784
2799
|
const normalizedKey = key.replace("-", "_");
|
|
@@ -2790,6 +2805,21 @@ var Server = class {
|
|
|
2790
2805
|
return this.resolveFirstProductTitleValue(rawValue);
|
|
2791
2806
|
return String(rawValue);
|
|
2792
2807
|
}
|
|
2808
|
+
canAssignStringProductTitleToLocale(title, locale) {
|
|
2809
|
+
if (!locale)
|
|
2810
|
+
return false;
|
|
2811
|
+
if (locale === "zh-CN" || locale === "zh-HK" || locale === "kitchen") {
|
|
2812
|
+
return this.hasCjkText(title);
|
|
2813
|
+
}
|
|
2814
|
+
if (locale === "ja")
|
|
2815
|
+
return /[\u3040-\u30ff]/.test(title) || this.hasCjkText(title);
|
|
2816
|
+
if (locale === "en" || locale === "pt")
|
|
2817
|
+
return !this.hasCjkText(title);
|
|
2818
|
+
return false;
|
|
2819
|
+
}
|
|
2820
|
+
hasCjkText(value) {
|
|
2821
|
+
return /[\u3400-\u9fff]/.test(value);
|
|
2822
|
+
}
|
|
2793
2823
|
resolveFirstProductTitleValue(value) {
|
|
2794
2824
|
if (value === void 0 || value === null || value === "")
|
|
2795
2825
|
return null;
|
|
@@ -71,6 +71,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
71
71
|
* await this.emitOrdersChanged([freshOrder], 'pubsub.bodyUpsert')
|
|
72
72
|
*/
|
|
73
73
|
async emitOrdersChanged(changedOrders = [], source) {
|
|
74
|
+
console.log("触发emitOrdersChanged");
|
|
74
75
|
const payload = {
|
|
75
76
|
list: this.store.list,
|
|
76
77
|
changedOrders: changedOrders.map((order) => this.normalizeOrderForMemoryList(order)),
|
|
@@ -953,7 +954,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
953
954
|
async mergeOrdersToStore(freshOrders, source) {
|
|
954
955
|
this.logInfo("mergeOrdersToStore-开始", {
|
|
955
956
|
freshOrderCount: freshOrders.length,
|
|
956
|
-
storeOrderCountBefore: this.store.list.length
|
|
957
|
+
storeOrderCountBefore: this.store.list.length,
|
|
958
|
+
source
|
|
957
959
|
});
|
|
958
960
|
this.logDuplicateOrders(`${source}.beforeMerge`, this.store.list);
|
|
959
961
|
const normalizedFreshOrders = [];
|
|
@@ -990,6 +992,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
990
992
|
}
|
|
991
993
|
const insertCount = Object.values(mergeActions).filter((v) => v === "insert").length;
|
|
992
994
|
const updateCount = Object.values(mergeActions).filter((v) => v === "update").length;
|
|
995
|
+
this.logInfo("mergeOrdersToStore-合并完成", {
|
|
996
|
+
insertCount,
|
|
997
|
+
updateCount,
|
|
998
|
+
storeOrderCountAfter: this.store.list.length
|
|
999
|
+
});
|
|
993
1000
|
this.store.list = this.compactOrderListByIdentity(updatedList, `${source}.store`).list;
|
|
994
1001
|
this.syncOrdersMap();
|
|
995
1002
|
await this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
|
|
@@ -239,7 +239,7 @@ export interface OrderPaymentItem {
|
|
|
239
239
|
rounding_amount?: OrderMoneyString;
|
|
240
240
|
/** 支付状态:paid / voided / payment_pending 等 */
|
|
241
241
|
status?: OrderPaymentRecordStatus;
|
|
242
|
-
/**
|
|
242
|
+
/** 支付时间(输入/输出均保留)。来源:OrderPayment.payment_time */
|
|
243
243
|
payment_time?: string | null;
|
|
244
244
|
/** 手续费配置。来源:OrderPayment.service_charge */
|
|
245
245
|
service_charge?: Record<string, unknown> | null;
|
|
@@ -168,9 +168,13 @@ function matchOrder(order, ctx) {
|
|
|
168
168
|
return true;
|
|
169
169
|
}
|
|
170
170
|
function matchBooking(booking, orderInfo, ctx) {
|
|
171
|
-
if (ctx.enableChildBookingFilter) {
|
|
172
|
-
const parentId = Number(
|
|
173
|
-
|
|
171
|
+
if (ctx.enableChildBookingFilter && booking.booking_id) {
|
|
172
|
+
const parentId = Number(
|
|
173
|
+
booking.parent_id ?? 0
|
|
174
|
+
);
|
|
175
|
+
const itemType = String(
|
|
176
|
+
booking.item_type ?? ""
|
|
177
|
+
);
|
|
174
178
|
const isMatched = parentId !== 0 && itemType !== "recurring_booking" || parentId === 0 && itemType === "recurring_booking";
|
|
175
179
|
if (!isMatched)
|
|
176
180
|
return false;
|
|
@@ -64,15 +64,15 @@ export declare class ScheduleModuleEx extends BaseModule implements Module, Sche
|
|
|
64
64
|
*/
|
|
65
65
|
getDateIsInSchedule(date: string, scheduleList: (ScheduleItem | number)[]): boolean;
|
|
66
66
|
/**
|
|
67
|
-
* 从
|
|
67
|
+
* 从 SQLite 加载日程数据
|
|
68
68
|
* @private
|
|
69
69
|
*/
|
|
70
|
-
private
|
|
70
|
+
private loadScheduleFromSQLite;
|
|
71
71
|
/**
|
|
72
|
-
* 保存日程数据到
|
|
72
|
+
* 保存日程数据到 SQLite
|
|
73
73
|
* @private
|
|
74
74
|
*/
|
|
75
|
-
private
|
|
75
|
+
private saveScheduleToSQLite;
|
|
76
76
|
/**
|
|
77
77
|
* 预加载模块数据(统一接口)
|
|
78
78
|
* 在模块注册后自动调用
|
|
@@ -40,7 +40,7 @@ var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
|
40
40
|
var import_utils = require("../../../solution/ShopDiscount/utils");
|
|
41
41
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
42
42
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
43
|
-
var
|
|
43
|
+
var SCHEDULE_STORE_NAME = "schedule";
|
|
44
44
|
var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
45
45
|
// LoggerManager 实例
|
|
46
46
|
constructor(name, version) {
|
|
@@ -117,12 +117,12 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
117
117
|
const appPlugin = core.getPlugin("app");
|
|
118
118
|
if (appPlugin) {
|
|
119
119
|
const app = appPlugin.getApp();
|
|
120
|
-
this.dbManager = app.
|
|
120
|
+
this.dbManager = app.sqlite;
|
|
121
121
|
this.logger = app.logger;
|
|
122
122
|
if (this.dbManager) {
|
|
123
|
-
console.log("[Schedule]
|
|
123
|
+
console.log("[Schedule] SQLite 已初始化");
|
|
124
124
|
} else {
|
|
125
|
-
console.warn("[Schedule]
|
|
125
|
+
console.warn("[Schedule] SQLite 未找到");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
this.logInfo("模块初始化完成", {
|
|
@@ -150,7 +150,7 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
150
150
|
scheduleCount: list.length,
|
|
151
151
|
duration: `${duration}ms`
|
|
152
152
|
});
|
|
153
|
-
await this.
|
|
153
|
+
await this.saveScheduleToSQLite(list);
|
|
154
154
|
this.setScheduleList(list);
|
|
155
155
|
return list;
|
|
156
156
|
} catch (error) {
|
|
@@ -220,13 +220,13 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
220
220
|
this.store.map.clear();
|
|
221
221
|
if (this.dbManager) {
|
|
222
222
|
try {
|
|
223
|
-
await this.dbManager.clear(
|
|
224
|
-
console.log("[Schedule]
|
|
225
|
-
this.logInfo("
|
|
223
|
+
await this.dbManager.clear(SCHEDULE_STORE_NAME);
|
|
224
|
+
console.log("[Schedule] SQLite 缓存已清空");
|
|
225
|
+
this.logInfo("SQLite 缓存已清空");
|
|
226
226
|
} catch (error) {
|
|
227
227
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
228
|
-
console.error("[Schedule] 清空
|
|
229
|
-
this.logError("清空
|
|
228
|
+
console.error("[Schedule] 清空 SQLite 缓存失败:", error);
|
|
229
|
+
this.logError("清空 SQLite 缓存失败", { error: errorMessage });
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
this.logInfo("缓存清空完成");
|
|
@@ -255,51 +255,58 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
255
255
|
return result;
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
|
-
* 从
|
|
258
|
+
* 从 SQLite 加载日程数据
|
|
259
259
|
* @private
|
|
260
260
|
*/
|
|
261
|
-
async
|
|
261
|
+
async loadScheduleFromSQLite() {
|
|
262
262
|
if (!this.dbManager) {
|
|
263
|
-
this.logWarning("
|
|
263
|
+
this.logWarning("loadScheduleFromSQLite: SQLite 不可用");
|
|
264
264
|
return [];
|
|
265
265
|
}
|
|
266
266
|
try {
|
|
267
|
-
const scheduleList = await this.dbManager.getAll(
|
|
268
|
-
this.logInfo("从
|
|
267
|
+
const scheduleList = await this.dbManager.getAll(SCHEDULE_STORE_NAME);
|
|
268
|
+
this.logInfo("从 SQLite 加载日程数据", {
|
|
269
269
|
scheduleCount: (scheduleList == null ? void 0 : scheduleList.length) ?? 0
|
|
270
270
|
});
|
|
271
271
|
return scheduleList || [];
|
|
272
272
|
} catch (error) {
|
|
273
273
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
274
|
-
console.error("[Schedule] 从
|
|
275
|
-
this.logError("从
|
|
274
|
+
console.error("[Schedule] 从 SQLite 读取数据失败:", error);
|
|
275
|
+
this.logError("从 SQLite 读取数据失败", { error: errorMessage });
|
|
276
276
|
return [];
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
280
|
-
* 保存日程数据到
|
|
280
|
+
* 保存日程数据到 SQLite
|
|
281
281
|
* @private
|
|
282
282
|
*/
|
|
283
|
-
async
|
|
283
|
+
async saveScheduleToSQLite(scheduleList) {
|
|
284
284
|
if (!this.dbManager) {
|
|
285
|
-
this.logWarning("
|
|
285
|
+
this.logWarning("saveScheduleToSQLite: SQLite 不可用");
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
this.logInfo("开始保存日程数据到
|
|
288
|
+
this.logInfo("开始保存日程数据到 SQLite", { scheduleCount: scheduleList.length });
|
|
289
289
|
try {
|
|
290
|
-
await this.dbManager.clear(
|
|
291
|
-
|
|
292
|
-
(
|
|
293
|
-
|
|
294
|
-
|
|
290
|
+
await this.dbManager.clear(SCHEDULE_STORE_NAME);
|
|
291
|
+
if (scheduleList.length > 0) {
|
|
292
|
+
if (typeof this.dbManager.bulkAdd === "function") {
|
|
293
|
+
await this.dbManager.bulkAdd(SCHEDULE_STORE_NAME, scheduleList);
|
|
294
|
+
} else if (typeof this.dbManager.bulkUpdate === "function") {
|
|
295
|
+
await this.dbManager.bulkUpdate(SCHEDULE_STORE_NAME, scheduleList);
|
|
296
|
+
} else {
|
|
297
|
+
await Promise.all(scheduleList.map(
|
|
298
|
+
(schedule) => this.dbManager.add(SCHEDULE_STORE_NAME, schedule)
|
|
299
|
+
));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
295
302
|
console.log(
|
|
296
|
-
`[Schedule] 已将 ${scheduleList.length} 条日程数据保存到
|
|
303
|
+
`[Schedule] 已将 ${scheduleList.length} 条日程数据保存到 SQLite`
|
|
297
304
|
);
|
|
298
|
-
this.logInfo("日程数据已保存到
|
|
305
|
+
this.logInfo("日程数据已保存到 SQLite", { scheduleCount: scheduleList.length });
|
|
299
306
|
} catch (error) {
|
|
300
307
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
301
|
-
console.error("[Schedule] 保存数据到
|
|
302
|
-
this.logError("保存数据到
|
|
308
|
+
console.error("[Schedule] 保存数据到 SQLite 失败:", error);
|
|
309
|
+
this.logError("保存数据到 SQLite 失败", {
|
|
303
310
|
scheduleCount: scheduleList.length,
|
|
304
311
|
error: errorMessage
|
|
305
312
|
});
|
|
@@ -314,31 +321,30 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
314
321
|
const startTime = Date.now();
|
|
315
322
|
this.logInfo("开始预加载数据");
|
|
316
323
|
try {
|
|
317
|
-
const cachedData = await this.
|
|
324
|
+
const cachedData = await this.loadScheduleFromSQLite();
|
|
318
325
|
if (cachedData && cachedData.length > 0) {
|
|
319
326
|
console.log(
|
|
320
|
-
`[Schedule] 从
|
|
327
|
+
`[Schedule] 从 SQLite 加载了 ${cachedData.length} 条日程数据`
|
|
321
328
|
);
|
|
322
329
|
this.store.scheduleList = (0, import_lodash_es.cloneDeep)(cachedData);
|
|
323
330
|
this.syncScheduleMap();
|
|
324
331
|
const duration = Date.now() - startTime;
|
|
325
|
-
this.logInfo("预加载完成(从
|
|
332
|
+
this.logInfo("预加载完成(从 SQLite)", {
|
|
326
333
|
scheduleCount: cachedData.length,
|
|
327
334
|
duration: `${duration}ms`,
|
|
328
|
-
source: "
|
|
335
|
+
source: "SQLite"
|
|
329
336
|
});
|
|
330
337
|
return;
|
|
331
338
|
}
|
|
332
|
-
console.log("[Schedule]
|
|
333
|
-
this.logInfo("
|
|
339
|
+
console.log("[Schedule] SQLite 中没有缓存数据,从服务器加载...");
|
|
340
|
+
this.logInfo("SQLite 中没有缓存数据,准备从服务器加载");
|
|
334
341
|
} catch (error) {
|
|
335
342
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
336
|
-
console.warn("[Schedule] 从
|
|
337
|
-
this.logWarning("从
|
|
343
|
+
console.warn("[Schedule] 从 SQLite 加载数据失败:", error);
|
|
344
|
+
this.logWarning("从 SQLite 加载数据失败,准备从服务器加载", { error: errorMessage });
|
|
338
345
|
}
|
|
339
346
|
const scheduleList = await this.loadAllSchedule();
|
|
340
347
|
if (scheduleList && scheduleList.length > 0) {
|
|
341
|
-
await this.saveScheduleToIndexDB(scheduleList);
|
|
342
348
|
this.store.scheduleList = (0, import_lodash_es.cloneDeep)(scheduleList);
|
|
343
349
|
this.syncScheduleMap();
|
|
344
350
|
const duration = Date.now() - startTime;
|