@pisell/pisellos 2.2.264 → 2.2.266
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/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +41 -10
- package/dist/modules/Order/index.js +1379 -810
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +49 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +61 -64
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +26 -24
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -8
- package/dist/modules/Rules/index.js +55 -9
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +71 -0
- package/dist/server/index.js +2504 -1187
- package/dist/server/modules/order/index.d.ts +56 -5
- package/dist/server/modules/order/index.js +1718 -834
- package/dist/server/modules/order/types.d.ts +15 -3
- package/dist/server/modules/order/types.js +1 -1
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +67 -4
- package/dist/solution/BaseSales/index.js +1476 -792
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +94 -54
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +10 -2
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +41 -10
- package/lib/modules/Order/index.js +514 -122
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +49 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +26 -20
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +26 -24
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -8
- package/lib/modules/Rules/index.js +57 -6
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +71 -0
- package/lib/server/index.js +1002 -52
- package/lib/server/modules/order/index.d.ts +56 -5
- package/lib/server/modules/order/index.js +798 -148
- package/lib/server/modules/order/types.d.ts +15 -3
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +67 -4
- package/lib/solution/BaseSales/index.js +496 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +39 -11
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +5 -3
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Discount } from '../../modules/Discount/types';
|
|
1
2
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
3
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
@@ -85,6 +86,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
85
86
|
booking_uid?: string;
|
|
86
87
|
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
87
88
|
product_title?: BaseSalesLocalizedText;
|
|
89
|
+
/** 商品封面图快照,随 tempOrder 提交到 checkout。 */
|
|
90
|
+
product_cover?: string;
|
|
88
91
|
/**
|
|
89
92
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
90
93
|
*
|
|
@@ -381,9 +384,11 @@ export interface BaseSalesLoggerRuntimeConfig {
|
|
|
381
384
|
}
|
|
382
385
|
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
383
386
|
}
|
|
384
|
-
/** BaseSales.scanPromotionCode
|
|
387
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
385
388
|
export interface BaseSalesScanCodeResult {
|
|
386
389
|
isAvailable: boolean;
|
|
387
390
|
type?: 'server' | string;
|
|
388
391
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
+
/** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
|
|
393
|
+
scannedDiscountList?: Discount[];
|
|
389
394
|
}
|
|
@@ -214,6 +214,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
214
214
|
promotion.finalPrice ?? ((_c = line.metadata) == null ? void 0 : _c.main_product_selling_price) ?? ""
|
|
215
215
|
);
|
|
216
216
|
const noteSignature = getProductLineNoteSignature(line);
|
|
217
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
217
218
|
const bookingUid = (line == null ? void 0 : line.booking_uid) ?? ((_d = line == null ? void 0 : line.metadata) == null ? void 0 : _d.booking_uid);
|
|
218
219
|
const orderDetailId = (line == null ? void 0 : line.order_detail_id) ?? (line == null ? void 0 : line.orderDetailId);
|
|
219
220
|
const mergeKey = [
|
|
@@ -221,6 +222,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
221
222
|
line.product_variant_id ?? 0,
|
|
222
223
|
fingerprint,
|
|
223
224
|
noteSignature,
|
|
225
|
+
lineMergeBoundary,
|
|
224
226
|
bookingUid ? String(bookingUid) : "",
|
|
225
227
|
orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "" ? String(orderDetailId) : "",
|
|
226
228
|
promotion.strategyId,
|
|
@@ -364,6 +366,12 @@ function getProductLineNoteSignature(product) {
|
|
|
364
366
|
const uid = getOrderProductUid(product);
|
|
365
367
|
return uid ? `note:${uid}` : `note:${normalizedNote}`;
|
|
366
368
|
}
|
|
369
|
+
function getPromotionLineMergeBoundary(product) {
|
|
370
|
+
var _a;
|
|
371
|
+
if (((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_edit_for_runtime) !== true)
|
|
372
|
+
return "";
|
|
373
|
+
return `edit:${getOrderProductUid(product)}`;
|
|
374
|
+
}
|
|
367
375
|
function isPersistedGeneratedVoucher(product) {
|
|
368
376
|
const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
|
|
369
377
|
if (orderDetailId === void 0 || orderDetailId === null || orderDetailId === "") {
|
|
@@ -391,6 +399,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
391
399
|
item.product_bundle
|
|
392
400
|
);
|
|
393
401
|
const noteSignature = getProductLineNoteSignature(item);
|
|
402
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(item);
|
|
394
403
|
const bookingUid = (item == null ? void 0 : item.booking_uid) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid);
|
|
395
404
|
const orderDetailId = (item == null ? void 0 : item.order_detail_id) ?? (item == null ? void 0 : item.orderDetailId);
|
|
396
405
|
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
@@ -399,6 +408,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
399
408
|
item.product_variant_id ?? 0,
|
|
400
409
|
fingerprint,
|
|
401
410
|
noteSignature,
|
|
411
|
+
lineMergeBoundary,
|
|
402
412
|
String(orderDetailId)
|
|
403
413
|
].join("#");
|
|
404
414
|
}
|
|
@@ -408,6 +418,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
408
418
|
item.product_variant_id ?? 0,
|
|
409
419
|
fingerprint,
|
|
410
420
|
noteSignature,
|
|
421
|
+
lineMergeBoundary,
|
|
411
422
|
String(bookingUid)
|
|
412
423
|
].join("#");
|
|
413
424
|
}
|
|
@@ -415,7 +426,8 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
415
426
|
item.product_id,
|
|
416
427
|
item.product_variant_id ?? 0,
|
|
417
428
|
fingerprint,
|
|
418
|
-
noteSignature
|
|
429
|
+
noteSignature,
|
|
430
|
+
lineMergeBoundary
|
|
419
431
|
].join("#");
|
|
420
432
|
}
|
|
421
433
|
function consolidateMainProductsForPromotion(entries) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
|
|
3
3
|
*
|
|
4
4
|
* - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
|
|
5
|
-
* - products 保留 tempOrder /
|
|
5
|
+
* - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
|
|
6
6
|
* - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
|
|
7
7
|
* - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
|
|
8
8
|
*
|
|
@@ -82,8 +82,13 @@ export interface ISalesBooking {
|
|
|
82
82
|
metadata?: Record<string, any> | null;
|
|
83
83
|
[key: string]: any;
|
|
84
84
|
}
|
|
85
|
+
export interface ISalesPaymentMetadata extends Record<string, any> {
|
|
86
|
+
/** 刷卡机设备快照;OS 不解析内部字段 */
|
|
87
|
+
card_reader_snapshot?: Record<string, unknown>;
|
|
88
|
+
}
|
|
85
89
|
export interface ISalesPayment {
|
|
86
90
|
order_payment_id?: number | null;
|
|
91
|
+
payment_number?: string;
|
|
87
92
|
custom_payment_id?: number;
|
|
88
93
|
code?: string;
|
|
89
94
|
name?: string;
|
|
@@ -95,7 +100,7 @@ export interface ISalesPayment {
|
|
|
95
100
|
status?: string;
|
|
96
101
|
payment_time?: string | null;
|
|
97
102
|
service_charge?: Record<string, any> | null;
|
|
98
|
-
metadata?:
|
|
103
|
+
metadata?: ISalesPaymentMetadata | null;
|
|
99
104
|
[key: string]: any;
|
|
100
105
|
}
|
|
101
106
|
export interface ISalesSurcharge {
|
|
@@ -130,7 +135,7 @@ export interface ISalesDetail {
|
|
|
130
135
|
customer: ISalesDetailCustomer | null;
|
|
131
136
|
/** 服务端 summary(仅输出) */
|
|
132
137
|
summary: Record<string, any>;
|
|
133
|
-
/**
|
|
138
|
+
/** 规范化后的响应快照,方便 UI 兜底使用 */
|
|
134
139
|
raw: Record<string, any>;
|
|
135
140
|
}
|
|
136
141
|
/**
|
|
@@ -138,7 +143,7 @@ export interface ISalesDetail {
|
|
|
138
143
|
*
|
|
139
144
|
* 注意:
|
|
140
145
|
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
141
|
-
* - products
|
|
146
|
+
* - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
|
|
142
147
|
* - 不做远程请求;不修改入参;返回新对象。
|
|
143
148
|
*/
|
|
144
149
|
export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
|
|
@@ -22,6 +22,7 @@ __export(parseSalesResponse_exports, {
|
|
|
22
22
|
parseSalesResponse: () => parseSalesResponse
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(parseSalesResponse_exports);
|
|
25
|
+
var import_orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
|
|
25
26
|
var HEADER_KEYS = [
|
|
26
27
|
"order_id",
|
|
27
28
|
"order_number",
|
|
@@ -121,14 +122,12 @@ function indexBookingsByProductUid(bookings) {
|
|
|
121
122
|
return result;
|
|
122
123
|
}
|
|
123
124
|
function parseSalesResponse(input) {
|
|
124
|
-
const
|
|
125
|
+
const sourceRaw = input && typeof input === "object" && input.data && input.order_id == null ? input.data : input || {};
|
|
126
|
+
const raw = (0, import_orderCollectionIdentity.normalizeOrderCollections)(sourceRaw).order;
|
|
125
127
|
const productsRaw = Array.isArray(raw == null ? void 0 : raw.products) ? raw.products : [];
|
|
126
|
-
const products = productsRaw.map((p
|
|
128
|
+
const products = productsRaw.map((p) => {
|
|
127
129
|
const row = { ...p || {} };
|
|
128
130
|
const metadata = row.metadata && typeof row.metadata === "object" ? { ...row.metadata } : {};
|
|
129
|
-
if (!metadata.unique_identification_number) {
|
|
130
|
-
metadata.unique_identification_number = `sales-product-${row.product_id ?? "unknown"}-${row.product_variant_id ?? 0}-${index}`;
|
|
131
|
-
}
|
|
132
131
|
delete metadata.price_schema_version;
|
|
133
132
|
delete row.identity_key;
|
|
134
133
|
return { ...row, metadata };
|
|
@@ -50,6 +50,12 @@ function toPriceString(value, fallback = "0.00") {
|
|
|
50
50
|
return fallback;
|
|
51
51
|
return parsedValue.toFixed(2);
|
|
52
52
|
}
|
|
53
|
+
function isBlankValue(value) {
|
|
54
|
+
return value === void 0 || value === null || typeof value === "string" && value.trim() === "";
|
|
55
|
+
}
|
|
56
|
+
function firstNonBlank(...values) {
|
|
57
|
+
return values.find((value) => !isBlankValue(value));
|
|
58
|
+
}
|
|
53
59
|
function normalizeOptionItems(optionItems) {
|
|
54
60
|
if (!Array.isArray(optionItems))
|
|
55
61
|
return [];
|
|
@@ -198,6 +204,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
198
204
|
main_product_selling_price: mainProductSellingPrice,
|
|
199
205
|
main_product_original_price: mainProductOriginalPrice,
|
|
200
206
|
price_schema_version: 2,
|
|
207
|
+
holder_config: sourceProduct == null ? void 0 : sourceProduct.holder_config,
|
|
201
208
|
...hasPriceOverride ? {
|
|
202
209
|
price_override: String(payload.price_override),
|
|
203
210
|
is_manual_discount: 1
|
|
@@ -236,6 +243,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
236
243
|
metadata,
|
|
237
244
|
note: payload.note != null ? String(payload.note) : "",
|
|
238
245
|
product_title: productTitle,
|
|
246
|
+
product_cover: firstNonBlank(matchedVariant == null ? void 0 : matchedVariant.cover, sourceProduct == null ? void 0 : sourceProduct.cover),
|
|
239
247
|
_origin: {
|
|
240
248
|
...sourceProduct || {},
|
|
241
249
|
callbackData: payload
|
|
@@ -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 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -233,6 +233,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
233
233
|
return String(this.getAppData("device_id") || 0).slice(-2);
|
|
234
234
|
}
|
|
235
235
|
async configureIdGeneratorFromOpenData() {
|
|
236
|
+
this.setPaymentNumberDevicePrefix(null);
|
|
236
237
|
let openDataConfig = null;
|
|
237
238
|
try {
|
|
238
239
|
openDataConfig = await this.loadOpenDataConfig();
|
|
@@ -264,6 +265,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
264
265
|
const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
|
|
265
266
|
const operatingDayBoundary = this.getAppData("operating_day_boundary");
|
|
266
267
|
const deviceId = await this.getShortNumberOrDeviceId();
|
|
268
|
+
this.setPaymentNumberDevicePrefix(deviceId);
|
|
267
269
|
const businessCode = this.getBookingTicketBusinessCode();
|
|
268
270
|
if (!businessCode) {
|
|
269
271
|
console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
|
|
@@ -341,15 +343,28 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
341
343
|
if (!this.store.order)
|
|
342
344
|
throw new Error("order 模块未初始化");
|
|
343
345
|
const raw = await this.store.order.scanCode(code, customerId);
|
|
346
|
+
const scannedList = raw.scannedDiscountList || [];
|
|
347
|
+
const extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
348
|
+
const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
349
|
+
if (!hasOrderCustomer && extractedCustomerId) {
|
|
350
|
+
await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
351
|
+
}
|
|
344
352
|
if (raw.isAvailable) {
|
|
345
|
-
await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
|
|
346
353
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
347
354
|
this.store.order.persistTempOrder();
|
|
355
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
356
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
357
|
+
productList: tempOrder.products || [],
|
|
358
|
+
discountList: this.store.order.getDiscountList(),
|
|
359
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
360
|
+
tempOrder
|
|
361
|
+
});
|
|
348
362
|
}
|
|
349
363
|
return {
|
|
350
364
|
isAvailable: raw.isAvailable,
|
|
351
365
|
type: raw.type,
|
|
352
|
-
unavailableReason: raw.unavailableReason
|
|
366
|
+
unavailableReason: raw.unavailableReason,
|
|
367
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
353
368
|
};
|
|
354
369
|
}
|
|
355
370
|
async hydrateOrderCustomerFromScanDiscounts(discounts) {
|
|
@@ -366,11 +381,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
366
381
|
this.setOrderCustomer(customer);
|
|
367
382
|
}
|
|
368
383
|
getDiscountCustomerId(discounts) {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
384
|
+
for (const item of discounts) {
|
|
385
|
+
const topLevelId = Number(item.customer_id);
|
|
386
|
+
if (Number.isFinite(topLevelId) && topLevelId > 0) {
|
|
387
|
+
return topLevelId;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
374
391
|
}
|
|
375
392
|
async resolveCustomerByDiscountCustomerId(customerId) {
|
|
376
393
|
var _a;
|
|
@@ -862,7 +879,17 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
862
879
|
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
863
880
|
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
864
881
|
this.store.order.applyDiscount();
|
|
865
|
-
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() =>
|
|
882
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => {
|
|
883
|
+
var _a2;
|
|
884
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
885
|
+
this.store.order.persistTempOrder();
|
|
886
|
+
return this.effectsEmit("onDiscountApplied", {
|
|
887
|
+
productList: tempOrder.products || [],
|
|
888
|
+
discountList: ((_a2 = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _a2.call(discountModule)) || [],
|
|
889
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
890
|
+
tempOrder
|
|
891
|
+
});
|
|
892
|
+
}).catch((error) => {
|
|
866
893
|
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
867
894
|
});
|
|
868
895
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
@@ -1128,7 +1155,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1128
1155
|
}
|
|
1129
1156
|
/** 读取当前 booking config。 */
|
|
1130
1157
|
getBookingConfig() {
|
|
1131
|
-
|
|
1158
|
+
var _a;
|
|
1159
|
+
return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
|
|
1132
1160
|
}
|
|
1133
1161
|
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1134
1162
|
setResources(resources) {
|
|
@@ -1501,8 +1529,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1501
1529
|
return result;
|
|
1502
1530
|
}
|
|
1503
1531
|
async setOtherParams(params, { cover = false } = {}) {
|
|
1504
|
-
super.setOtherParams(params, { cover });
|
|
1505
|
-
if (params == null ? void 0 : params.businessCode) {
|
|
1532
|
+
await super.setOtherParams(params, { cover });
|
|
1533
|
+
if ((params == null ? void 0 : params.businessCode) !== void 0 || (params == null ? void 0 : params.business_code) !== void 0) {
|
|
1506
1534
|
await this.configureIdGeneratorFromOpenData();
|
|
1507
1535
|
}
|
|
1508
1536
|
}
|
|
@@ -83,6 +83,7 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private isBookingIncludedInStats;
|
|
85
85
|
private getBookingOrderPaymentStatus;
|
|
86
|
+
private isUnpaidBooking;
|
|
86
87
|
private countBookingOrders;
|
|
87
88
|
private countCompletedBookings;
|
|
88
89
|
private groupBookingsByResource;
|
|
@@ -39,6 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
40
40
|
var import_types = require("./types");
|
|
41
41
|
__reExport(Sales_exports, require("./types"), module.exports);
|
|
42
|
+
var UNPAID_PAYMENT_STATUSES = /* @__PURE__ */ new Set(["unpaid", "partially_paid", "payment_processing"]);
|
|
42
43
|
var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
43
44
|
// LoggerManager 实例
|
|
44
45
|
constructor(name, version) {
|
|
@@ -258,6 +259,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
258
259
|
var _a;
|
|
259
260
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
260
261
|
}
|
|
262
|
+
isUnpaidBooking(booking) {
|
|
263
|
+
return UNPAID_PAYMENT_STATUSES.has(this.getBookingOrderPaymentStatus(booking));
|
|
264
|
+
}
|
|
261
265
|
countBookingOrders(bookings) {
|
|
262
266
|
const orderIds = /* @__PURE__ */ new Set();
|
|
263
267
|
bookings.forEach((booking) => {
|
|
@@ -631,9 +635,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
631
635
|
const completedBookingList = matchedBookingList.filter(
|
|
632
636
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
637
|
);
|
|
634
|
-
const unpaidBookingList = matchedBookingList.filter(
|
|
635
|
-
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
|
-
);
|
|
638
|
+
const unpaidBookingList = matchedBookingList.filter((booking) => this.isUnpaidBooking(booking));
|
|
637
639
|
const bookings = this.pickBookingsForCurrentPoint(
|
|
638
640
|
current,
|
|
639
641
|
this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList)
|
|
@@ -505,7 +505,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
505
505
|
try {
|
|
506
506
|
const orderId = this.store.orderId;
|
|
507
507
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
508
|
-
const
|
|
508
|
+
const prepareConfigResult = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
509
509
|
customer_id: customerId,
|
|
510
510
|
action: orderId ? "edit" : "create",
|
|
511
511
|
with_good_pass: 1,
|
|
@@ -514,6 +514,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
514
514
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
515
515
|
...orderId ? { order_id: orderId } : {}
|
|
516
516
|
}));
|
|
517
|
+
const goodPassList = (prepareConfigResult == null ? void 0 : prepareConfigResult.discountList) || [];
|
|
517
518
|
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
518
519
|
(item) => item.isScan
|
|
519
520
|
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PaymentNumberAppDataGetter = (key: string) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the synchronous fallback without caching runtime device data.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the latest device segment when a new payment number is generated.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/payment-number.ts
|
|
20
|
+
var payment_number_exports = {};
|
|
21
|
+
__export(payment_number_exports, {
|
|
22
|
+
resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
|
|
23
|
+
resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(payment_number_exports);
|
|
26
|
+
function normalizeNonEmptyString(value) {
|
|
27
|
+
if (value === void 0 || value === null)
|
|
28
|
+
return null;
|
|
29
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
30
|
+
return null;
|
|
31
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
32
|
+
return null;
|
|
33
|
+
const normalized = String(value).trim();
|
|
34
|
+
return normalized || null;
|
|
35
|
+
}
|
|
36
|
+
function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
|
|
37
|
+
try {
|
|
38
|
+
const deviceId = normalizeNonEmptyString(getAppData("device_id"));
|
|
39
|
+
if (deviceId && deviceId !== "0")
|
|
40
|
+
return deviceId.slice(-2);
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
return "LOCAL";
|
|
44
|
+
}
|
|
45
|
+
async function resolvePaymentNumberDevicePrefix(getAppData) {
|
|
46
|
+
try {
|
|
47
|
+
const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
|
|
48
|
+
if (typeof getAsyncIotDeviceInfo === "function") {
|
|
49
|
+
const info = await getAsyncIotDeviceInfo();
|
|
50
|
+
const shortNumber = normalizeNonEmptyString(
|
|
51
|
+
info == null ? void 0 : info.short_number
|
|
52
|
+
);
|
|
53
|
+
if (shortNumber && shortNumber !== "0")
|
|
54
|
+
return shortNumber;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
resolvePaymentNumberDevicePrefix,
|
|
63
|
+
resolvePaymentNumberDevicePrefixFromDeviceId
|
|
64
|
+
});
|