@pisell/pisellos 2.2.243 → 2.2.245
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/Discount/index.d.ts +1 -1
- package/dist/modules/Discount/index.js +10 -4
- package/dist/modules/Order/index.d.ts +7 -1
- package/dist/modules/Order/index.js +649 -514
- package/dist/modules/Order/types.d.ts +7 -0
- package/dist/modules/Order/utils.js +5 -2
- package/dist/modules/Payment/walletpass.js +33 -24
- package/dist/modules/Rules/index.js +4 -1
- package/dist/server/index.js +6 -4
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +60 -46
- package/dist/server/utils/small-ticket.js +39 -29
- package/dist/solution/BaseSales/index.d.ts +3 -2
- package/dist/solution/BaseSales/index.js +6 -0
- package/dist/solution/BaseSales/types.d.ts +6 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +46 -45
- package/lib/modules/Discount/index.d.ts +1 -1
- package/lib/modules/Discount/index.js +4 -0
- package/lib/modules/Order/index.d.ts +7 -1
- package/lib/modules/Order/index.js +105 -1
- package/lib/modules/Order/types.d.ts +7 -0
- package/lib/modules/Order/utils.js +1 -0
- package/lib/modules/Payment/walletpass.js +9 -0
- package/lib/modules/Rules/index.js +1 -0
- package/lib/server/index.js +1 -0
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +54 -42
- package/lib/server/utils/small-ticket.js +21 -2
- package/lib/solution/BaseSales/index.d.ts +3 -2
- package/lib/solution/BaseSales/index.js +5 -0
- package/lib/solution/BaseSales/types.d.ts +6 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -1
- package/package.json +1 -1
|
@@ -80,7 +80,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
80
80
|
await this.core.effects.emit(import_types.OrderHooks.onOrdersChanged, payload);
|
|
81
81
|
}
|
|
82
82
|
async initialize(core, options) {
|
|
83
|
-
var _a
|
|
83
|
+
var _a;
|
|
84
84
|
this.core = core;
|
|
85
85
|
this.store = options == null ? void 0 : options.store;
|
|
86
86
|
if (!this.store.map)
|
|
@@ -91,48 +91,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
91
91
|
this.dbManager = app.sqlite;
|
|
92
92
|
this.logger = app.logger;
|
|
93
93
|
this.storage = app.storage;
|
|
94
|
-
|
|
95
|
-
if (!((_a = this.store.createdAtQuery) == null ? void 0 : _a.sales_time_between) && (coreData == null ? void 0 : coreData.core)) {
|
|
96
|
-
const today = (0, import_dayjs.default)();
|
|
97
|
-
if (coreData == null ? void 0 : coreData.core.operating_day_boundary) {
|
|
98
|
-
const operatingDayBoundary = coreData.core.operating_day_boundary;
|
|
99
|
-
if (operatingDayBoundary.type === "start_time") {
|
|
100
|
-
const boundaryTime = String(operatingDayBoundary.time || "").trim();
|
|
101
|
-
const boundaryStart = (0, import_dayjs.default)(`${today.format("YYYY-MM-DD")} ${boundaryTime}`);
|
|
102
|
-
if (boundaryStart.isValid()) {
|
|
103
|
-
const isAfterBoundary = today.isAfter(boundaryStart);
|
|
104
|
-
const queryStart = isAfterBoundary ? today.startOf("day") : today.subtract(1, "day").startOf("day");
|
|
105
|
-
const queryEnd = isAfterBoundary ? today.add(1, "day").endOf("day") : today.endOf("day");
|
|
106
|
-
this.store.createdAtQuery = {
|
|
107
|
-
sales_time_between: [
|
|
108
|
-
queryStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
109
|
-
queryEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
110
|
-
]
|
|
111
|
-
};
|
|
112
|
-
} else {
|
|
113
|
-
this.store.createdAtQuery = {
|
|
114
|
-
sales_time_between: [
|
|
115
|
-
today.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
116
|
-
today.endOf("day").format("YYYY-MM-DD HH:mm:ss")
|
|
117
|
-
]
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
this.store.createdAtQuery = {
|
|
122
|
-
sales_time_between: [
|
|
123
|
-
today.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
124
|
-
today.endOf("day").format("YYYY-MM-DD HH:mm:ss")
|
|
125
|
-
]
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
this.store.createdAtQuery = {
|
|
130
|
-
sales_time_between: [today.startOf("day").format("YYYY-MM-DD HH:mm:ss"), today.endOf("day").format("YYYY-MM-DD HH:mm:ss")]
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
94
|
+
this.updateCreateStore();
|
|
134
95
|
}
|
|
135
|
-
if (Array.isArray((
|
|
96
|
+
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.list)) {
|
|
136
97
|
this.store.list = options.initialState.list.map((order) => this.normalizeOrderForMemoryList(order));
|
|
137
98
|
this.syncOrdersMap();
|
|
138
99
|
this.emitOrdersChanged([], "initialState");
|
|
@@ -347,6 +308,53 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
347
308
|
bodyOrderId: (normalizedBody == null ? void 0 : normalizedBody.order_id) ?? null
|
|
348
309
|
};
|
|
349
310
|
}
|
|
311
|
+
updateCreateStore() {
|
|
312
|
+
var _a;
|
|
313
|
+
const appPlugin = this.core.getPlugin("app");
|
|
314
|
+
const app = appPlugin == null ? void 0 : appPlugin.getApp();
|
|
315
|
+
if (app) {
|
|
316
|
+
const coreData = app.data.store.getStore().getDataByModel("core");
|
|
317
|
+
if (!((_a = this.store.createdAtQuery) == null ? void 0 : _a.sales_time_between) && (coreData == null ? void 0 : coreData.core)) {
|
|
318
|
+
const today = (0, import_dayjs.default)();
|
|
319
|
+
if (coreData == null ? void 0 : coreData.core.operating_day_boundary) {
|
|
320
|
+
const operatingDayBoundary = coreData.core.operating_day_boundary;
|
|
321
|
+
if (operatingDayBoundary.type === "start_time") {
|
|
322
|
+
const boundaryTime = String(operatingDayBoundary.time || "").trim();
|
|
323
|
+
const boundaryStart = (0, import_dayjs.default)(`${today.format("YYYY-MM-DD")} ${boundaryTime}`);
|
|
324
|
+
if (boundaryStart.isValid()) {
|
|
325
|
+
const isAfterBoundary = today.isAfter(boundaryStart);
|
|
326
|
+
const queryStart = isAfterBoundary ? today.startOf("day") : today.subtract(1, "day").startOf("day");
|
|
327
|
+
const queryEnd = isAfterBoundary ? today.add(1, "day").endOf("day") : today.endOf("day");
|
|
328
|
+
this.store.createdAtQuery = {
|
|
329
|
+
sales_time_between: [
|
|
330
|
+
queryStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
331
|
+
queryEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
332
|
+
]
|
|
333
|
+
};
|
|
334
|
+
} else {
|
|
335
|
+
this.store.createdAtQuery = {
|
|
336
|
+
sales_time_between: [
|
|
337
|
+
today.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
338
|
+
today.endOf("day").format("YYYY-MM-DD HH:mm:ss")
|
|
339
|
+
]
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
this.store.createdAtQuery = {
|
|
344
|
+
sales_time_between: [
|
|
345
|
+
today.startOf("day").format("YYYY-MM-DD HH:mm:ss"),
|
|
346
|
+
today.endOf("day").format("YYYY-MM-DD HH:mm:ss")
|
|
347
|
+
]
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
this.store.createdAtQuery = {
|
|
352
|
+
sales_time_between: [today.startOf("day").format("YYYY-MM-DD HH:mm:ss"), today.endOf("day").format("YYYY-MM-DD HH:mm:ss")]
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
350
358
|
getOrderSyncThrottleMs() {
|
|
351
359
|
const raw = localStorage.getItem(ORDER_SYNC_THROTTLE_MS_STORAGE_KEY);
|
|
352
360
|
if (raw !== null) {
|
|
@@ -449,6 +457,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
449
457
|
}
|
|
450
458
|
this.logInfo("silentRefresh 开始");
|
|
451
459
|
try {
|
|
460
|
+
this.updateCreateStore();
|
|
452
461
|
const orders = await this.loadOrdersByServer();
|
|
453
462
|
if (orders.length > 0) {
|
|
454
463
|
this.store.list = (0, import_lodash_es.cloneDeep)(orders);
|
|
@@ -1141,6 +1150,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1141
1150
|
const topLevelUid = record.unique_identification_number;
|
|
1142
1151
|
if (!this.isBlankIdentityValue(topLevelUid))
|
|
1143
1152
|
return `uid:${String(topLevelUid)}`;
|
|
1153
|
+
const orderDetailId = record.order_detail_id;
|
|
1154
|
+
if (!this.isBlankIdentityValue(orderDetailId))
|
|
1155
|
+
return `detail:${String(orderDetailId)}`;
|
|
1144
1156
|
const bookingUid = record.booking_uid;
|
|
1145
1157
|
if (!this.isBlankIdentityValue(bookingUid))
|
|
1146
1158
|
return `booking:${String(bookingUid)}`;
|
|
@@ -200,6 +200,8 @@ function buildProducts(order, locale, productMap) {
|
|
|
200
200
|
function resolveProductTitle(params) {
|
|
201
201
|
const { product, productMap, locale } = params;
|
|
202
202
|
const ownTitle = getProductTitleSource(product, locale);
|
|
203
|
+
if (ownTitle)
|
|
204
|
+
return ownTitle;
|
|
203
205
|
const productId = product.product_id ?? product.id;
|
|
204
206
|
const fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
205
207
|
if (!fallbackProduct)
|
|
@@ -356,7 +358,9 @@ function resolveTitleValue(value, locale) {
|
|
|
356
358
|
return stringify(value);
|
|
357
359
|
const dashedLocale = locale.replace("_", "-");
|
|
358
360
|
const underscoredLocale = locale.replace("-", "_");
|
|
359
|
-
return stringify(
|
|
361
|
+
return stringify(
|
|
362
|
+
value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? ""
|
|
363
|
+
);
|
|
360
364
|
}
|
|
361
365
|
function resolveOptionTitleFromParentProduct(params) {
|
|
362
366
|
const { option, parentProduct, locale } = params;
|
|
@@ -517,7 +521,7 @@ function buildFees(params) {
|
|
|
517
521
|
summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0),
|
|
518
522
|
0
|
|
519
523
|
),
|
|
520
|
-
has_pay: formatMoney(
|
|
524
|
+
has_pay: formatMoney(calculateReceiptPaidAmount(order, summary), currencySymbol),
|
|
521
525
|
payment_method: "",
|
|
522
526
|
tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
|
|
523
527
|
total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol),
|
|
@@ -738,6 +742,21 @@ function formatMoney(value, currencySymbol) {
|
|
|
738
742
|
const amount = new import_decimal.default(toMoneyNumber(value));
|
|
739
743
|
return `${currencySymbol}${amount.toFixed(2)}`;
|
|
740
744
|
}
|
|
745
|
+
function calculateReceiptPaidAmount(order, summary) {
|
|
746
|
+
const paidAmount = sumPayments(order.payments);
|
|
747
|
+
const payProcessingFee = new import_decimal.default(
|
|
748
|
+
toMoneyNumber(summary.pay_service_charge_amount ?? order.pay_service_charge_amount)
|
|
749
|
+
);
|
|
750
|
+
if (payProcessingFee.lte(0))
|
|
751
|
+
return paidAmount;
|
|
752
|
+
const totalAmount = new import_decimal.default(toMoneyNumber(summary.total_amount ?? order.total_amount));
|
|
753
|
+
if (totalAmount.gt(0) && paidAmount.gte(totalAmount))
|
|
754
|
+
return paidAmount;
|
|
755
|
+
const paidAmountWithFee = paidAmount.plus(payProcessingFee);
|
|
756
|
+
if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount))
|
|
757
|
+
return totalAmount;
|
|
758
|
+
return paidAmountWithFee;
|
|
759
|
+
}
|
|
741
760
|
function sumPayments(payments) {
|
|
742
761
|
return normalizeArray(payments).filter((payment) => isPrintablePayment(payment)).reduce((sum, payment) => {
|
|
743
762
|
return sum.plus(toMoneyNumber(payment.amount ?? payment.origin_amount));
|
|
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
5
|
+
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -143,6 +143,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
143
143
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
144
144
|
updateRemoteOrderNote(orderId: number | string, note: string): void;
|
|
145
145
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
146
|
+
updateTempOrderDepositAmount(amount: string | number): OrderSummary;
|
|
146
147
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
147
148
|
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
148
149
|
setEnableTempOrderPersist(enabled: boolean): void;
|
|
@@ -158,7 +159,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
158
159
|
*/
|
|
159
160
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
160
161
|
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
161
|
-
getSummary(): Promise<
|
|
162
|
+
getSummary(): Promise<OrderSummary>;
|
|
162
163
|
private getHistoricalProductDiscountList;
|
|
163
164
|
private isPersistedOrderProduct;
|
|
164
165
|
private mergeHistoricalDiscountList;
|
|
@@ -718,6 +718,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
718
718
|
throw new Error("order 模块未初始化");
|
|
719
719
|
return this.store.order.updateTempOrderShopDiscount(amount);
|
|
720
720
|
}
|
|
721
|
+
updateTempOrderDepositAmount(amount) {
|
|
722
|
+
if (!this.store.order)
|
|
723
|
+
throw new Error("order 模块未初始化");
|
|
724
|
+
return this.store.order.updateTempOrderDepositAmount(amount);
|
|
725
|
+
}
|
|
721
726
|
updateTempOrderContactsInfo(contactsInfo) {
|
|
722
727
|
if (!this.store.order)
|
|
723
728
|
throw new Error("order 模块未初始化");
|
|
@@ -48,6 +48,9 @@ export interface BaseSalesProductSku {
|
|
|
48
48
|
option: any[];
|
|
49
49
|
[key: string]: any;
|
|
50
50
|
}
|
|
51
|
+
export interface BaseSalesLocalizedText {
|
|
52
|
+
[locale: string]: string | null;
|
|
53
|
+
}
|
|
51
54
|
export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrderProductIdentity {
|
|
52
55
|
num: number;
|
|
53
56
|
}
|
|
@@ -78,6 +81,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
78
81
|
product_bundle: any[];
|
|
79
82
|
/** 关联 booking.metadata.unique_identification_number */
|
|
80
83
|
booking_uid?: string;
|
|
84
|
+
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
85
|
+
product_title?: BaseSalesLocalizedText;
|
|
81
86
|
/**
|
|
82
87
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
83
88
|
*
|
|
@@ -132,6 +137,7 @@ export interface BaseSalesSummary {
|
|
|
132
137
|
deposit?: {
|
|
133
138
|
total: string;
|
|
134
139
|
deposit_policy_ids: number[];
|
|
140
|
+
deposit_policy_data?: any[];
|
|
135
141
|
hasDeposit: boolean;
|
|
136
142
|
};
|
|
137
143
|
expect_amount: string;
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 6 | 4;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|
|
@@ -106,7 +106,8 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
106
106
|
return { status: "failed", reason: "invalid_data" };
|
|
107
107
|
}
|
|
108
108
|
const snapshot = host.getOrderCustomerSnapshot();
|
|
109
|
-
|
|
109
|
+
const scannedCustomerIsWalkIn = (0, import_cartView.isWalkInCustomer)(data);
|
|
110
|
+
if ((0, import_cartView.isWalkInCustomer)(snapshot) || scannedCustomerIsWalkIn) {
|
|
110
111
|
if (!(bridge == null ? void 0 : bridge.applyPromotionCode)) {
|
|
111
112
|
return { status: "failed", reason: "no_bridge" };
|
|
112
113
|
}
|