@pisell/pisellos 2.2.273 → 2.2.275
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/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +7 -6
- package/dist/modules/Order/index.js +217 -115
- package/dist/modules/Order/types.d.ts +23 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +81 -4
- package/dist/modules/Payment/types.js +18 -3
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +78 -64
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +27 -18
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +16 -0
- package/dist/server/modules/order/index.js +964 -776
- package/dist/server/modules/order/types.d.ts +14 -0
- package/dist/server/modules/order/types.js +6 -0
- package/dist/solution/BaseSales/index.d.ts +80 -15
- package/dist/solution/BaseSales/index.js +1498 -444
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +8 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +12 -3
- package/dist/solution/BookingTicket/types.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +7 -6
- package/lib/modules/Order/index.js +127 -20
- package/lib/modules/Order/types.d.ts +23 -3
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +81 -4
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +24 -14
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +14 -6
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +16 -0
- package/lib/server/modules/order/index.js +140 -4
- package/lib/server/modules/order/types.d.ts +14 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +80 -15
- package/lib/solution/BaseSales/index.js +712 -48
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +8 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/types.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrde
|
|
|
3
3
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
4
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
5
5
|
import type { QuotationCustomerScopeInfo } from '../../modules/Quotation/types';
|
|
6
|
+
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
6
7
|
/**
|
|
7
8
|
* BaseSales 流程 hook 后缀。
|
|
8
9
|
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
@@ -16,11 +17,62 @@ export declare const BaseSalesHookNames: {
|
|
|
16
17
|
readonly onPaymentSyncStart: "onPaymentSyncStart";
|
|
17
18
|
readonly onPaymentSyncEnd: "onPaymentSyncEnd";
|
|
18
19
|
readonly onDepositPaymentSyncEnd: "onDepositPaymentSyncEnd";
|
|
20
|
+
readonly onWalletAssetsStateChanged: "onWalletAssetsStateChanged";
|
|
19
21
|
};
|
|
20
22
|
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
21
23
|
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
22
24
|
export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
23
25
|
export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
|
|
26
|
+
export interface BaseSalesCashPaymentConfig {
|
|
27
|
+
available: boolean;
|
|
28
|
+
paymentMethod?: PaymentMethod;
|
|
29
|
+
amountDue: number;
|
|
30
|
+
recommendedAmounts: number[];
|
|
31
|
+
}
|
|
32
|
+
export interface BaseSalesPayCashParams {
|
|
33
|
+
/** 实际计入订单的现金支付金额(部分支付时小于待付金额)。 */
|
|
34
|
+
amount: number;
|
|
35
|
+
/** 顾客实际交付现金;可大于 amount。 */
|
|
36
|
+
actualPaidAmount?: number;
|
|
37
|
+
changeAmount?: number;
|
|
38
|
+
roundingAmount?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface BaseSalesPayCashResult {
|
|
41
|
+
payment: Record<string, any>;
|
|
42
|
+
payments: Record<string, any>[];
|
|
43
|
+
syncResult: Record<string, any>;
|
|
44
|
+
isOrderFullyPaid: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface BaseSalesCommitPaymentMethodParams {
|
|
47
|
+
/** 支付方式 id;与 paymentMethodCode 至少传一个。 */
|
|
48
|
+
paymentMethodId?: number | string;
|
|
49
|
+
/** 支付方式 code,大小写不敏感。 */
|
|
50
|
+
paymentMethodCode?: string;
|
|
51
|
+
/** 本次计入订单的支付金额。 */
|
|
52
|
+
amount: number;
|
|
53
|
+
/** 支付设备返回的原始金额;缺省时与 amount 相同。 */
|
|
54
|
+
originAmount?: number;
|
|
55
|
+
/** 支付设备返回的实际手续费配置。 */
|
|
56
|
+
serviceCharge?: {
|
|
57
|
+
amount?: string | number;
|
|
58
|
+
percentage?: string | number;
|
|
59
|
+
} | null;
|
|
60
|
+
/** 支付设备返回的唯一流水号等扩展信息。 */
|
|
61
|
+
metadata?: Record<string, any>;
|
|
62
|
+
/** 少数支付方式需要透传的额外 payment 字段。 */
|
|
63
|
+
paymentData?: Record<string, any>;
|
|
64
|
+
}
|
|
65
|
+
export interface BaseSalesCommitPaymentMethodResult {
|
|
66
|
+
payment: Record<string, any>;
|
|
67
|
+
payments: Record<string, any>[];
|
|
68
|
+
syncResult: Record<string, any>;
|
|
69
|
+
isOrderFullyPaid: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface BaseSalesConfirmWalletPaymentResult<T = Record<string, any>> {
|
|
72
|
+
submitResult: T;
|
|
73
|
+
payments: Record<string, any>[];
|
|
74
|
+
isOrderFullyPaid: boolean;
|
|
75
|
+
}
|
|
24
76
|
export interface BaseSalesEntryContext {
|
|
25
77
|
biz: string;
|
|
26
78
|
mode: 'scan' | 'append';
|
|
@@ -387,8 +439,10 @@ export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
|
387
439
|
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
388
440
|
export interface BaseSalesScanCodeResult {
|
|
389
441
|
isAvailable: boolean;
|
|
442
|
+
/** 卡券已加入 Promotion;false 时可能是无效、过期或已使用。 */
|
|
443
|
+
isAccepted?: boolean;
|
|
390
444
|
type?: 'server' | string;
|
|
391
445
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
-
/** batchSearch 原始结果;
|
|
446
|
+
/** batchSearch 原始结果;Holder 补全等流程可从这里读取原始卡券。 */
|
|
393
447
|
scannedDiscountList?: Discount[];
|
|
394
448
|
}
|
|
@@ -10,7 +10,8 @@ export var BaseSalesHookNames = {
|
|
|
10
10
|
onCartValidationChanged: 'onCartValidationChanged',
|
|
11
11
|
onPaymentSyncStart: 'onPaymentSyncStart',
|
|
12
12
|
onPaymentSyncEnd: 'onPaymentSyncEnd',
|
|
13
|
-
onDepositPaymentSyncEnd: 'onDepositPaymentSyncEnd'
|
|
13
|
+
onDepositPaymentSyncEnd: 'onDepositPaymentSyncEnd',
|
|
14
|
+
onWalletAssetsStateChanged: 'onWalletAssetsStateChanged'
|
|
14
15
|
};
|
|
15
16
|
export function createBaseSalesHook(moduleName, hookName) {
|
|
16
17
|
return "".concat(moduleName, ":").concat(hookName);
|
|
@@ -468,11 +468,16 @@ function getProductLineNoteSignature(product) {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
/**
|
|
471
|
-
*
|
|
472
|
-
* 以历史行 uid 作为促销前后的行边界;新增行返回空边界,仍保留原有合并语义。
|
|
471
|
+
* 自定义商品、称重行以及编辑订单历史行都有各自的促销合并边界。
|
|
473
472
|
*/
|
|
474
473
|
function getPromotionLineMergeBoundary(product) {
|
|
475
|
-
var _product$metadata3;
|
|
474
|
+
var _product$product_sku, _product$metadata3;
|
|
475
|
+
if ((product === null || product === void 0 ? void 0 : product.product_id) === undefined || (product === null || product === void 0 ? void 0 : product.product_id) === null) {
|
|
476
|
+
return "custom:".concat(getOrderProductUid(product));
|
|
477
|
+
}
|
|
478
|
+
if (Number((product === null || product === void 0 || (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1) {
|
|
479
|
+
return "weighing:".concat(getOrderProductUid(product));
|
|
480
|
+
}
|
|
476
481
|
if ((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_edit_for_runtime) !== true) return '';
|
|
477
482
|
return "edit:".concat(getOrderProductUid(product));
|
|
478
483
|
}
|
|
@@ -104,7 +104,7 @@ function findVariantById(origin, variantId) {
|
|
|
104
104
|
* 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
|
|
105
105
|
*/
|
|
106
106
|
export function transformBaseProductToOrderProduct(params) {
|
|
107
|
-
var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
|
|
107
|
+
var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _matchedVariant$price, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _ref25, _payload$product_sku$, _payload$product_sku, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref26, _ref27, _origin$base_price, _ref28, _ref29, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref30, _ref31, _payload$tax_fee, _ref32, _ref33, _payload$is_charge_ta;
|
|
108
108
|
var payload = params.payload,
|
|
109
109
|
_params$fallbackProdu = params.fallbackProductId,
|
|
110
110
|
fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
|
|
@@ -116,11 +116,14 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
116
116
|
var callbackOrigin = payload.origin || ((_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.sourceProduct) || ((_payload$_origin2 = payload._origin) === null || _payload$_origin2 === void 0 ? void 0 : _payload$_origin2.sourceItem) || payload._origin || {};
|
|
117
117
|
var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
|
|
118
118
|
var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
|
|
119
|
-
var
|
|
119
|
+
var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
120
|
+
// 手动改价后 payload.price 是分摊后的主商品售价,不能再作为券前 source。
|
|
121
|
+
// 此时优先从商品/variant 快照读取目录价;售价仍由 line_total - bundle 推导。
|
|
122
|
+
var catalogSourcePrice = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
|
|
123
|
+
var sourceProductPrice = toPriceString(hasPriceOverride ? (_ref21 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref21 !== void 0 ? _ref21 : payload.selling_price : (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : catalogSourcePrice, '0.00');
|
|
120
124
|
var explicitLineTotal = (_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total;
|
|
121
125
|
var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
122
126
|
var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
123
|
-
var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
124
127
|
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
|
|
125
128
|
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
|
|
126
129
|
// `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
|
|
@@ -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 | 4 | 3 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -326,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
326
326
|
* 获取当前的客户搜索条件
|
|
327
327
|
* @returns 当前搜索条件
|
|
328
328
|
*/
|
|
329
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
329
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
330
330
|
/**
|
|
331
331
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
332
332
|
* @returns 客户状态
|
|
@@ -602,12 +602,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
602
602
|
tempOrder: tempOrder
|
|
603
603
|
});
|
|
604
604
|
case 18:
|
|
605
|
-
return _context7.abrupt("return", {
|
|
606
|
-
isAvailable: raw.isAvailable
|
|
605
|
+
return _context7.abrupt("return", _objectSpread(_objectSpread({
|
|
606
|
+
isAvailable: raw.isAvailable
|
|
607
|
+
}, raw.isAccepted !== undefined ? {
|
|
608
|
+
isAccepted: raw.isAccepted
|
|
609
|
+
} : {}), {}, {
|
|
607
610
|
type: raw.type,
|
|
608
611
|
unavailableReason: raw.unavailableReason,
|
|
609
612
|
scannedDiscountList: raw.scannedDiscountList
|
|
610
|
-
});
|
|
613
|
+
}));
|
|
611
614
|
case 19:
|
|
612
615
|
case "end":
|
|
613
616
|
return _context7.stop();
|
|
@@ -2437,6 +2440,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2437
2440
|
},
|
|
2438
2441
|
addProductToOrder: function addProductToOrder(product, booking) {
|
|
2439
2442
|
return _this6.addProductToOrder(product, booking);
|
|
2443
|
+
},
|
|
2444
|
+
refreshWalletAssets: function refreshWalletAssets(params) {
|
|
2445
|
+
return _this6.refreshWalletAssets(params);
|
|
2446
|
+
},
|
|
2447
|
+
scanWalletAsset: function scanWalletAsset(scanCode) {
|
|
2448
|
+
return _this6.scanWalletAsset(scanCode);
|
|
2440
2449
|
}
|
|
2441
2450
|
}, formatted, bridge);
|
|
2442
2451
|
case 16:
|
|
@@ -118,12 +118,15 @@ export interface BookingTicketCartBookingView extends ISalesBooking {
|
|
|
118
118
|
canAddTime: boolean;
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
+
export type BookingTicketCartLineView = BookingTicketCartBookingView | BookingTicketCartItemView;
|
|
121
122
|
/**
|
|
122
123
|
* BookingTicket 面向 UI 的购物车视图。
|
|
123
124
|
*/
|
|
124
125
|
export interface BookingTicketCartView {
|
|
125
126
|
bookings: BookingTicketCartBookingView[];
|
|
126
127
|
items: BookingTicketCartItemView[];
|
|
128
|
+
/** 以 tempOrder.products 为唯一顺序真源的统一购物车行(旧到新)。 */
|
|
129
|
+
lines: BookingTicketCartLineView[];
|
|
127
130
|
}
|
|
128
131
|
/**
|
|
129
132
|
* BookingTicket 面向 UI 的客户展示视图。
|
|
@@ -229,6 +232,7 @@ export interface GlobalScanHostBridge {
|
|
|
229
232
|
*/
|
|
230
233
|
applyPromotionCode?: (code: string, customerId?: number) => Promise<{
|
|
231
234
|
isAvailable?: boolean;
|
|
235
|
+
isAccepted?: boolean;
|
|
232
236
|
type?: string;
|
|
233
237
|
unavailableReason?: string;
|
|
234
238
|
}>;
|
|
@@ -108,33 +108,28 @@ export function buildCartView(lines, bookings) {
|
|
|
108
108
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
109
109
|
var productLines = Array.isArray(lines) ? lines : [];
|
|
110
110
|
var bookingList = Array.isArray(bookings) ? bookings : [];
|
|
111
|
+
var childBookings = bookingList.filter(function (booking) {
|
|
112
|
+
return booking.parent_id !== 0;
|
|
113
|
+
});
|
|
114
|
+
var bookingsByProductUid = indexBookingsByProductUid(childBookings);
|
|
111
115
|
var linesByUid = indexProductsByUid(productLines);
|
|
112
116
|
var addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
|
|
113
|
-
var claimedUids = new Set();
|
|
114
117
|
var claimedAddTimeLines = new Set();
|
|
115
|
-
|
|
116
|
-
return booking.parent_id !== 0;
|
|
117
|
-
}).reduce(function (acc, booking) {
|
|
118
|
-
var uid = booking === null || booking === void 0 ? void 0 : booking.product_uid;
|
|
118
|
+
childBookings.forEach(function (booking) {
|
|
119
119
|
var bookingUid = getBookingUid(booking);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!claimedUids.has(key)) {
|
|
124
|
-
var line = linesByUid[key];
|
|
125
|
-
// 赠品预约只作为提交数据保留,不在购物车顶部预约卡片区展示。
|
|
126
|
-
if (isGiftProductLine(line)) return acc;
|
|
127
|
-
if (line) {
|
|
128
|
-
claimedUids.add(key);
|
|
129
|
-
product = line;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
var addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
|
|
134
|
-
addTimeProduct.forEach(function (line) {
|
|
135
|
-
return claimedAddTimeLines.add(line);
|
|
120
|
+
if (!bookingUid) return;
|
|
121
|
+
(addTimeLinesByBookingUid[bookingUid] || []).forEach(function (line) {
|
|
122
|
+
claimedAddTimeLines.add(line);
|
|
136
123
|
});
|
|
137
|
-
|
|
124
|
+
});
|
|
125
|
+
var claimedBookings = new Set();
|
|
126
|
+
var cartBookings = [];
|
|
127
|
+
var items = [];
|
|
128
|
+
var orderedLines = [];
|
|
129
|
+
var buildBookingView = function buildBookingView(booking, product) {
|
|
130
|
+
var bookingUid = getBookingUid(booking);
|
|
131
|
+
var addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
|
|
132
|
+
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
138
133
|
_extend: {
|
|
139
134
|
product: product,
|
|
140
135
|
addTimeProduct: addTimeProduct,
|
|
@@ -147,21 +142,38 @@ export function buildCartView(lines, bookings) {
|
|
|
147
142
|
shopOpeningHours: options.shopOpeningHours
|
|
148
143
|
})
|
|
149
144
|
}
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
var items = productLines.filter(function (line) {
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
productLines.forEach(function (line) {
|
|
154
148
|
var _line$metadata6;
|
|
155
|
-
//
|
|
156
|
-
if (isGiftProductLine(line)) return
|
|
157
|
-
if (claimedAddTimeLines.has(line)) return false;
|
|
149
|
+
// 赠品由主商品 Gift 行展示;加时商品挂在 booking._extend.addTimeProduct。
|
|
150
|
+
if (isGiftProductLine(line) || claimedAddTimeLines.has(line)) return;
|
|
158
151
|
var uid = (_line$metadata6 = line.metadata) === null || _line$metadata6 === void 0 ? void 0 : _line$metadata6.unique_identification_number;
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
var matchedBooking = uid === undefined || uid === null || uid === '' ? undefined : (bookingsByProductUid[String(uid)] || []).find(function (booking) {
|
|
153
|
+
return !claimedBookings.has(booking);
|
|
154
|
+
});
|
|
155
|
+
if (matchedBooking) {
|
|
156
|
+
claimedBookings.add(matchedBooking);
|
|
157
|
+
var bookingView = buildBookingView(matchedBooking, line);
|
|
158
|
+
cartBookings.push(bookingView);
|
|
159
|
+
orderedLines.push(bookingView);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
items.push(line);
|
|
163
|
+
orderedLines.push(line);
|
|
164
|
+
});
|
|
165
|
+
childBookings.forEach(function (booking) {
|
|
166
|
+
if (claimedBookings.has(booking)) return;
|
|
167
|
+
var uid = booking === null || booking === void 0 ? void 0 : booking.product_uid;
|
|
168
|
+
var linkedProduct = uid === undefined || uid === null || uid === '' ? null : linesByUid[String(uid)] || null;
|
|
169
|
+
// 赠品预约只作为提交数据保留,不在购物车预约卡片区展示。
|
|
170
|
+
if (isGiftProductLine(linkedProduct)) return;
|
|
171
|
+
cartBookings.push(buildBookingView(booking, null));
|
|
161
172
|
});
|
|
162
173
|
return {
|
|
163
174
|
bookings: cartBookings,
|
|
164
|
-
items: items
|
|
175
|
+
items: items,
|
|
176
|
+
lines: orderedLines
|
|
165
177
|
};
|
|
166
178
|
}
|
|
167
179
|
export function isWalkInCustomer(customer) {
|
|
@@ -24,6 +24,14 @@ export interface GlobalScanApplyHost {
|
|
|
24
24
|
cacheItem: any;
|
|
25
25
|
};
|
|
26
26
|
addProductToOrder(product: any, booking?: any): Promise<any>;
|
|
27
|
+
refreshWalletAssets?(params?: {
|
|
28
|
+
preserveSelection?: boolean;
|
|
29
|
+
}): Promise<any>;
|
|
30
|
+
scanWalletAsset?(code: string): Promise<{
|
|
31
|
+
type: 'walletCode' | 'normalCode';
|
|
32
|
+
asset?: any;
|
|
33
|
+
selected: boolean;
|
|
34
|
+
}>;
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
37
|
* 应用全局扫码格式化结果:设客户 / 加车 / 开单 / 弹窗链。
|