@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
|
@@ -144,7 +144,7 @@ function buildBaseData(params) {
|
|
|
144
144
|
var _a;
|
|
145
145
|
const { order, shopInfo, locale } = params;
|
|
146
146
|
const orderNumber = stringify(
|
|
147
|
-
order.
|
|
147
|
+
order.buzzer || order.shop_full_order_number
|
|
148
148
|
);
|
|
149
149
|
return {
|
|
150
150
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
@@ -168,21 +168,24 @@ function buildProducts(order, locale, productMap) {
|
|
|
168
168
|
const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
|
|
169
169
|
const sellingPrice = product.selling_price ?? product.payment_price ?? product.price ?? originalPrice;
|
|
170
170
|
const productTitle = resolveProductTitle({ product, productMap, locale });
|
|
171
|
+
const currencySymbol = getCurrencySymbol(order, null);
|
|
172
|
+
const options = normalizeProductOptions({ product, locale, currencySymbol });
|
|
173
|
+
const combinations = normalizeProductCombinations({
|
|
174
|
+
product,
|
|
175
|
+
productMap,
|
|
176
|
+
locale,
|
|
177
|
+
currencySymbol
|
|
178
|
+
});
|
|
171
179
|
return {
|
|
172
180
|
product_title: productTitle,
|
|
173
181
|
product_quantity: quantity,
|
|
174
|
-
selling_price: formatMoney(sellingPrice,
|
|
175
|
-
original_price: formatMoney(originalPrice,
|
|
176
|
-
total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity),
|
|
182
|
+
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
183
|
+
original_price: formatMoney(originalPrice, currencySymbol),
|
|
184
|
+
total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
177
185
|
extension_list: Array.isArray(product.extension_list) ? product.extension_list : [],
|
|
178
|
-
...
|
|
179
|
-
options: product.options.map((option) => ({
|
|
180
|
-
name: getLocalizedValue(option.name || option.title, locale),
|
|
181
|
-
value: getLocalizedValue(option.value || option.option || option.item, locale)
|
|
182
|
-
}))
|
|
183
|
-
} : {},
|
|
186
|
+
...options.length ? { options } : {},
|
|
184
187
|
...product.variant ? { variant: getLocalizedValue(product.variant, locale) } : {},
|
|
185
|
-
...Array.isArray(product.combinations) ? { combinations: product.combinations } : {}
|
|
188
|
+
...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
|
|
186
189
|
};
|
|
187
190
|
});
|
|
188
191
|
}
|
|
@@ -204,6 +207,77 @@ function resolveProductTitle(params) {
|
|
|
204
207
|
locale
|
|
205
208
|
);
|
|
206
209
|
}
|
|
210
|
+
function normalizeProductOptions(params) {
|
|
211
|
+
var _a;
|
|
212
|
+
const { product, locale, currencySymbol } = params;
|
|
213
|
+
const rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_a = product.product_sku) == null ? void 0 : _a.option) ? product.product_sku.option : [];
|
|
214
|
+
return rawOptions.map((option) => {
|
|
215
|
+
const price = option.original_price ?? option.add_price ?? option.price;
|
|
216
|
+
const value = option.value ?? option.option ?? option.item;
|
|
217
|
+
return {
|
|
218
|
+
name: getLocalizedValue(option.name || option.title, locale),
|
|
219
|
+
...option.num !== void 0 || option.quantity !== void 0 ? { num: toNumber(option.num ?? option.quantity, 1) } : {},
|
|
220
|
+
...price !== void 0 && price !== null && price !== "" ? { price: formatMoney(price, currencySymbol) } : {},
|
|
221
|
+
...value !== void 0 && value !== null && value !== "" ? { value: getLocalizedValue(value, locale) } : {}
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function normalizeProductCombinations(params) {
|
|
226
|
+
const { product, productMap, locale, currencySymbol } = params;
|
|
227
|
+
const bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
228
|
+
return bundles.map((bundle) => {
|
|
229
|
+
const combinationsOptions = normalizeProductOptions({
|
|
230
|
+
product: {},
|
|
231
|
+
locale,
|
|
232
|
+
currencySymbol,
|
|
233
|
+
options: Array.isArray(bundle.option) ? bundle.option : []
|
|
234
|
+
});
|
|
235
|
+
const baseTitle = resolveBundleProductTitle({ bundle, productMap, locale });
|
|
236
|
+
const optionTitle = buildOptionTitleSuffix(combinationsOptions);
|
|
237
|
+
return {
|
|
238
|
+
product_title: `${baseTitle}${optionTitle}`,
|
|
239
|
+
product_quantity: toNumber(bundle.num ?? bundle.quantity ?? 1, 1),
|
|
240
|
+
price: formatBundlePrice(bundle, currencySymbol),
|
|
241
|
+
combinations_options: combinationsOptions
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function resolveBundleProductTitle(params) {
|
|
246
|
+
var _a, _b;
|
|
247
|
+
const { bundle, productMap, locale } = params;
|
|
248
|
+
const ownTitle = getLocalizedValue(
|
|
249
|
+
bundle.product_title || bundle.title || bundle.name || ((_a = bundle.product) == null ? void 0 : _a.title),
|
|
250
|
+
locale
|
|
251
|
+
);
|
|
252
|
+
if (ownTitle)
|
|
253
|
+
return ownTitle;
|
|
254
|
+
const productId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? bundle.id;
|
|
255
|
+
const fallbackProduct = productId !== void 0 && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
256
|
+
if (!fallbackProduct)
|
|
257
|
+
return "";
|
|
258
|
+
return getLocalizedValue(
|
|
259
|
+
fallbackProduct.product_title || fallbackProduct.title || fallbackProduct.name || fallbackProduct.format_title || ((_b = fallbackProduct.product) == null ? void 0 : _b.title),
|
|
260
|
+
locale
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
function buildOptionTitleSuffix(options) {
|
|
264
|
+
const text = options.map((option) => {
|
|
265
|
+
const name = stringify(option.name).trim();
|
|
266
|
+
if (!name)
|
|
267
|
+
return "";
|
|
268
|
+
const quantity = option.num ?? 1;
|
|
269
|
+
return `${name} x ${quantity}`;
|
|
270
|
+
}).filter(Boolean).join(", ");
|
|
271
|
+
return text ? `(${text})` : "";
|
|
272
|
+
}
|
|
273
|
+
function formatBundlePrice(bundle, currencySymbol) {
|
|
274
|
+
const value = bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0;
|
|
275
|
+
const amount = new import_decimal.default(toMoneyNumber(value));
|
|
276
|
+
const isNegative = bundle.price_type === "markdown" || bundle.price_type === "markup" && bundle.price_type_ext === "product_price";
|
|
277
|
+
if (isNegative)
|
|
278
|
+
return `-${currencySymbol}${amount.abs().toFixed(2)}`;
|
|
279
|
+
return formatMoney(amount, currencySymbol);
|
|
280
|
+
}
|
|
207
281
|
function buildFees(params) {
|
|
208
282
|
const { order, shopInfo, locale, products, summary, currencySymbol } = params;
|
|
209
283
|
const fees = [];
|
|
@@ -109,7 +109,7 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
109
109
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
110
110
|
if (!currentTempOrder)
|
|
111
111
|
return loadedRecord;
|
|
112
|
-
|
|
112
|
+
const mergedRecord = (0, import_lodash_es.mergeWith)(
|
|
113
113
|
(0, import_lodash_es.cloneDeep)(currentTempOrder),
|
|
114
114
|
(0, import_lodash_es.cloneDeep)(loadedRecord || {}),
|
|
115
115
|
(currentValue, loadedValue, key) => {
|
|
@@ -131,6 +131,8 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
|
131
131
|
return void 0;
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
|
+
delete mergedRecord.request_unique_idempotency_token;
|
|
135
|
+
return mergedRecord;
|
|
134
136
|
}
|
|
135
137
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
136
138
|
constructor(name, version) {
|
|
@@ -1389,9 +1391,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1389
1391
|
if (!metadata.unique_payment_number) {
|
|
1390
1392
|
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
1391
1393
|
}
|
|
1394
|
+
const paymentTime = paymentRecord.payment_time ?? (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
1392
1395
|
const payments = this.store.order.addOrderPayment({
|
|
1393
1396
|
...paymentRecord,
|
|
1394
|
-
metadata
|
|
1397
|
+
metadata,
|
|
1398
|
+
payment_time: paymentTime
|
|
1395
1399
|
});
|
|
1396
1400
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1397
1401
|
const syncState = this.store.order.getOrderSyncState();
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -109,7 +109,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
109
109
|
*
|
|
110
110
|
* @returns loadSalesDetail 的返回值
|
|
111
111
|
*/
|
|
112
|
-
refreshSalesDetail(
|
|
112
|
+
refreshSalesDetail(params?: {
|
|
113
|
+
forceRemote?: boolean;
|
|
114
|
+
}): Promise<ISalesDetail>;
|
|
113
115
|
/**
|
|
114
116
|
* 获取商品列表
|
|
115
117
|
* @param params 包含 schedule_date 的参数
|
|
@@ -310,7 +312,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
310
312
|
* 获取当前的客户搜索条件
|
|
311
313
|
* @returns 当前搜索条件
|
|
312
314
|
*/
|
|
313
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
315
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
314
316
|
/**
|
|
315
317
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
316
318
|
* @returns 客户状态
|
|
@@ -465,7 +465,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
465
465
|
*
|
|
466
466
|
* @returns loadSalesDetail 的返回值
|
|
467
467
|
*/
|
|
468
|
-
async refreshSalesDetail() {
|
|
468
|
+
async refreshSalesDetail(params = {}) {
|
|
469
469
|
var _a, _b;
|
|
470
470
|
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
471
471
|
if (!tempOrder) {
|
|
@@ -477,8 +477,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
477
477
|
}
|
|
478
478
|
return this.loadSalesDetail({
|
|
479
479
|
orderId: Number(orderId),
|
|
480
|
-
merge: true
|
|
481
|
-
|
|
480
|
+
// merge: true
|
|
481
|
+
forceRemote: params.forceRemote
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
484
|
/**
|
|
@@ -80,8 +80,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
80
80
|
currentCustomer: void 0
|
|
81
81
|
};
|
|
82
82
|
await this.initializeSubModules(core, options);
|
|
83
|
-
await this.preloadPaymentMethods();
|
|
84
|
-
await this.cleanupExpiredOrdersAsync();
|
|
85
83
|
console.log("[Checkout] 初始化完成");
|
|
86
84
|
await this.core.effects.emit(`${this.name}:onCheckoutInitialized`, {
|
|
87
85
|
timestamp: Date.now()
|
|
@@ -1900,6 +1898,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1900
1898
|
*
|
|
1901
1899
|
* 删除本地 IndexDB 中超过指定天数且已同步到后端的订单数据
|
|
1902
1900
|
*/
|
|
1901
|
+
/** @deprecated */
|
|
1903
1902
|
async cleanupExpiredOrdersAsync() {
|
|
1904
1903
|
var _a, _b, _c;
|
|
1905
1904
|
try {
|