@pisell/pisellos 0.10.7 → 0.10.9
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/core/index.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +32 -6
- package/dist/modules/Order/index.js +1165 -819
- package/dist/modules/Order/types.d.ts +32 -4
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +28 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +894 -781
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +41 -7
- package/dist/solution/BaseSales/index.js +1405 -974
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +221 -162
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.js +25 -64
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +32 -6
- package/lib/modules/Order/index.js +518 -148
- package/lib/modules/Order/types.d.ts +32 -4
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +30 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +105 -14
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +41 -7
- package/lib/solution/BaseSales/index.js +325 -39
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +31 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.js +17 -54
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -96,7 +96,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
96
96
|
return Array.from(new Set(ids));
|
|
97
97
|
}
|
|
98
98
|
async loadPrepareConfig(params) {
|
|
99
|
-
var _a, _b, _c, _d, _e;
|
|
99
|
+
var _a, _b, _c, _d, _e, _f;
|
|
100
100
|
if (typeof params.order_id === "string" && params.order_id.startsWith("LOCAL_")) {
|
|
101
101
|
params.order_id = void 0;
|
|
102
102
|
}
|
|
@@ -105,7 +105,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
105
105
|
{
|
|
106
106
|
...params,
|
|
107
107
|
with_available_wallet_flag: params.with_available_wallet_flag ?? 1,
|
|
108
|
-
with_available_wallet_pass_flag: params.with_available_wallet_pass_flag ?? 1
|
|
108
|
+
with_available_wallet_pass_flag: params.with_available_wallet_pass_flag ?? 1,
|
|
109
|
+
with_virtual_currency: params.with_virtual_currency ?? 1
|
|
109
110
|
}
|
|
110
111
|
);
|
|
111
112
|
const rawDiscountList = [
|
|
@@ -121,14 +122,47 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
121
122
|
...availableWalletList.map((item) => item == null ? void 0 : item.wallet_id),
|
|
122
123
|
...availableWalletPassList.map((item) => item == null ? void 0 : item.product_id)
|
|
123
124
|
]);
|
|
125
|
+
const virtualCurrencyList = this.normalizeVirtualCurrencyList(
|
|
126
|
+
(_f = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _f.virtual_currency_list
|
|
127
|
+
);
|
|
124
128
|
const goodPassList = this.filterEnabledDiscountList(
|
|
125
129
|
rawDiscountList
|
|
126
130
|
) || [];
|
|
127
131
|
return {
|
|
128
132
|
discountList: goodPassList,
|
|
129
|
-
availableWalletIds
|
|
133
|
+
availableWalletIds,
|
|
134
|
+
virtualCurrencyList
|
|
130
135
|
};
|
|
131
136
|
}
|
|
137
|
+
normalizeVirtualCurrencyList(value) {
|
|
138
|
+
if (!Array.isArray(value))
|
|
139
|
+
return [];
|
|
140
|
+
return value.flatMap((item) => {
|
|
141
|
+
const id = Number(item == null ? void 0 : item.id);
|
|
142
|
+
const productId = Number(item == null ? void 0 : item.product_id);
|
|
143
|
+
if (!Number.isFinite(id) || id <= 0 || !Number.isFinite(productId) || productId <= 0) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
const displayExtension = Array.isArray(item == null ? void 0 : item.extension_data) ? item.extension_data.find(
|
|
147
|
+
(extension) => (extension == null ? void 0 : extension.field_key) === "virtual_currency_display"
|
|
148
|
+
) : void 0;
|
|
149
|
+
let display = displayExtension == null ? void 0 : displayExtension.value;
|
|
150
|
+
if (typeof display === "string") {
|
|
151
|
+
try {
|
|
152
|
+
display = JSON.parse(display);
|
|
153
|
+
} catch {
|
|
154
|
+
display = {};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [{
|
|
158
|
+
...item,
|
|
159
|
+
id,
|
|
160
|
+
product_id: productId,
|
|
161
|
+
balance: String((item == null ? void 0 : item.balance) ?? "0"),
|
|
162
|
+
virtual_currency_display: display && typeof display === "object" && !Array.isArray(display) ? display : {}
|
|
163
|
+
}];
|
|
164
|
+
});
|
|
165
|
+
}
|
|
132
166
|
async batchSearch(code, options) {
|
|
133
167
|
const { customerId, orderId } = options || {};
|
|
134
168
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
@@ -71,6 +71,17 @@ export interface DiscountWithReason {
|
|
|
71
71
|
export interface DiscountPrepareConfigResult {
|
|
72
72
|
discountList: Discount[];
|
|
73
73
|
availableWalletIds: number[];
|
|
74
|
+
virtualCurrencyList?: VirtualCurrencyAsset[];
|
|
75
|
+
}
|
|
76
|
+
export interface VirtualCurrencyAsset extends Record<string, any> {
|
|
77
|
+
id: number;
|
|
78
|
+
product_id: number;
|
|
79
|
+
balance: string;
|
|
80
|
+
product_name?: string;
|
|
81
|
+
format_title?: Record<string, any>;
|
|
82
|
+
code?: string;
|
|
83
|
+
encoded?: string;
|
|
84
|
+
virtual_currency_display?: Record<string, any>;
|
|
74
85
|
}
|
|
75
86
|
interface ExtensionData {
|
|
76
87
|
id: number;
|
|
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
9
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -82,6 +82,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
82
82
|
}): Promise<Discount[]>;
|
|
83
83
|
getDiscountList(): Discount[];
|
|
84
84
|
getAvailableWalletIds(): number[];
|
|
85
|
+
getVirtualCurrencyList(): import("../Discount/types").VirtualCurrencyAsset[];
|
|
85
86
|
private syncScannedDiscountsToOriginalDiscountList;
|
|
86
87
|
private ensureEditDiscountConfigForProductChange;
|
|
87
88
|
scanCode(code: string, customerId?: number): Promise<{
|
|
@@ -156,6 +157,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
156
157
|
* sessionStorage 的 cacheId 分桶。写入失败由 BaseModule 静默降级。
|
|
157
158
|
*/
|
|
158
159
|
persistTempOrder(): void;
|
|
160
|
+
/**
|
|
161
|
+
* 终止当前模块实例的 sessionStorage 订单恢复会话。
|
|
162
|
+
*
|
|
163
|
+
* 支付跳转等终态场景需要同时删除当前 cacheId 的 tempOrder 快照,并关闭
|
|
164
|
+
* 本实例后续异步任务的再次写入;新模块实例初始化时会按 otherParams 重新启用。
|
|
165
|
+
*/
|
|
166
|
+
clearSessionStoragePersistedTempOrder(): void;
|
|
159
167
|
consumeSessionStorageRestore(): Record<string, any> | null;
|
|
160
168
|
notifyTempOrderChanged(): void;
|
|
161
169
|
private createDefaultTempOrderInstance;
|
|
@@ -188,6 +196,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
188
196
|
orderExpectedAmount: string;
|
|
189
197
|
};
|
|
190
198
|
private calculateDepositPaidAmount;
|
|
199
|
+
private hasPaidNormalPayment;
|
|
191
200
|
private resolveNextOrderPaymentType;
|
|
192
201
|
private getPaymentNumberAppData;
|
|
193
202
|
private getPaymentNumberDevicePrefixSync;
|
|
@@ -365,6 +374,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
365
374
|
updateVoucherOrderPaymentsAsync(payments: OrderPaymentSource[], options?: {
|
|
366
375
|
status?: 'paid' | 'payment_pending';
|
|
367
376
|
}): Promise<OrderPaymentData[]>;
|
|
377
|
+
private normalizeShouldMergeProductResult;
|
|
368
378
|
private shouldMergeProductToOrder;
|
|
369
379
|
private hasOrderProductLineNote;
|
|
370
380
|
/**
|
|
@@ -374,6 +384,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
374
384
|
* this.hasLinkedBookingUid({ metadata: { booking_uid: 'booking-1' } });
|
|
375
385
|
*/
|
|
376
386
|
private hasLinkedBookingUid;
|
|
387
|
+
private isMultiCurrencySettlementEnabled;
|
|
388
|
+
private isActiveVirtualSettlementOrder;
|
|
389
|
+
private shouldUseVirtualSettlementSummary;
|
|
390
|
+
private normalizeVirtualSettlementProductIfEnabled;
|
|
391
|
+
private assertAndLockProductSettlement;
|
|
392
|
+
private syncTempOrderSettlementState;
|
|
393
|
+
private prepareVirtualSettlementTempOrder;
|
|
377
394
|
/**
|
|
378
395
|
* 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
|
|
379
396
|
*
|
|
@@ -386,7 +403,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
386
403
|
* 带 booking 且 num>1 时由 `addProductToOrder` 拆成多次本方法调用(每次 num=1)。
|
|
387
404
|
*
|
|
388
405
|
* @example
|
|
389
|
-
*
|
|
406
|
+
* const pending = this.appendProductLineToTempOrder(
|
|
407
|
+
* tempOrder,
|
|
408
|
+
* { product_id: 1, num: 1 },
|
|
409
|
+
* booking,
|
|
410
|
+
* );
|
|
411
|
+
* if (pending) await pending;
|
|
390
412
|
*/
|
|
391
413
|
private appendProductLineToTempOrder;
|
|
392
414
|
/**
|
|
@@ -396,7 +418,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
396
418
|
* await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
|
|
397
419
|
* // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
|
|
398
420
|
*/
|
|
399
|
-
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
421
|
+
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
|
|
400
422
|
/**
|
|
401
423
|
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
402
424
|
*
|
|
@@ -434,13 +456,17 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
434
456
|
* @example
|
|
435
457
|
* await order.removeProductsFromOrder([identityA, identityB]);
|
|
436
458
|
*/
|
|
437
|
-
removeProductsFromOrder(identities: OrderProductIdentity[]): Promise<OrderProduct[]>;
|
|
438
|
-
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
459
|
+
removeProductsFromOrder(identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
460
|
+
removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
439
461
|
/**
|
|
440
462
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
441
463
|
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
442
464
|
*/
|
|
443
465
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
466
|
+
/**
|
|
467
|
+
* 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
|
|
468
|
+
*/
|
|
469
|
+
clearOrderForSettlementSwitch(): Promise<OrderTempOrder>;
|
|
444
470
|
buildCurrentSubmitPayloadForLocalPrint(params?: {
|
|
445
471
|
cacheId?: string;
|
|
446
472
|
platform?: string;
|
|
@@ -575,4 +601,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
575
601
|
getOrderInfo(order_id: number): Promise<any>;
|
|
576
602
|
getVouchers(): any[];
|
|
577
603
|
}
|
|
578
|
-
export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
604
|
+
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|