@pisell/pisellos 2.2.174 → 2.2.176
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/Order/index.d.ts +52 -1
- package/dist/modules/Order/index.js +730 -348
- package/dist/modules/Order/types.d.ts +140 -1
- package/dist/modules/Order/types.js +29 -0
- package/dist/modules/Order/utils.d.ts +11 -0
- package/dist/modules/Order/utils.js +43 -2
- package/dist/modules/SalesSummary/utils.js +3 -3
- package/dist/server/index.js +77 -23
- package/dist/solution/BaseSales/index.d.ts +37 -1
- package/dist/solution/BaseSales/index.js +751 -457
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
- package/dist/solution/BookingTicket/index.js +4 -0
- package/dist/solution/BookingTicket/utils/cartView.js +4 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +52 -1
- package/lib/modules/Order/index.js +195 -6
- package/lib/modules/Order/types.d.ts +140 -1
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +11 -0
- package/lib/modules/Order/utils.js +34 -2
- package/lib/modules/SalesSummary/utils.js +3 -3
- package/lib/server/index.js +39 -4
- package/lib/solution/BaseSales/index.d.ts +37 -1
- package/lib/solution/BaseSales/index.js +207 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
- package/lib/solution/BookingTicket/index.js +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +4 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } 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, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderScanCodeResult, ReplaceTempOrderOptions } from './types';
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderScanCodeResult, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
9
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
@@ -19,6 +19,16 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
19
19
|
private rulesHooksOverride?;
|
|
20
20
|
private orderHooks?;
|
|
21
21
|
private otherParams?;
|
|
22
|
+
/** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
|
|
23
|
+
private promotionEvaluator;
|
|
24
|
+
/** 赠品选择 resolver;由 SDK host bridge 注入 */
|
|
25
|
+
private giftSelectResolver;
|
|
26
|
+
/** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
|
|
27
|
+
private isApplyingPromotion;
|
|
28
|
+
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
29
|
+
private lastUnfulfilledPromotions;
|
|
30
|
+
/** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
|
|
31
|
+
private lastGiftActions;
|
|
22
32
|
/**
|
|
23
33
|
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
24
34
|
* Only selected discounts get a non-zero value.
|
|
@@ -50,6 +60,46 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
50
60
|
getDiscountList(): Discount[];
|
|
51
61
|
scanCode(code: string, customerId?: number): Promise<OrderScanCodeResult>;
|
|
52
62
|
applyDiscount(): void;
|
|
63
|
+
/**
|
|
64
|
+
* 注入促销评估器。
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* order.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
|
|
68
|
+
*/
|
|
69
|
+
setPromotionEvaluator(evaluator: OrderPromotionEvaluator | null): void;
|
|
70
|
+
/**
|
|
71
|
+
* 注入赠品选择 resolver。OS 需要补赠品时会 await 调用 resolver;缺省时跳过新增并 console.warn。
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* order.setGiftSelectResolver(async (ctx) => {
|
|
75
|
+
* // SDK 内部决定弹窗 or 自动选第一项,返回完整 OrderProduct[]
|
|
76
|
+
* return giftSelectBridge.request(ctx);
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
setGiftSelectResolver(resolver: OrderGiftSelectResolver | null): void;
|
|
80
|
+
/**
|
|
81
|
+
* 为商品目录追加促销标签,供上层 Sales 门面复用。
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const products = order.appendPromotionTags(catalogProducts);
|
|
85
|
+
*/
|
|
86
|
+
appendPromotionTags<T extends Record<string, any>>(products: T[]): T[];
|
|
87
|
+
/**
|
|
88
|
+
* 应用购物车促销:计算 → 差异化赠品 → 写回 tempOrder.products → emit onPromotionApplied。
|
|
89
|
+
*
|
|
90
|
+
* 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
|
|
91
|
+
*
|
|
92
|
+
* 关键约束:
|
|
93
|
+
* - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
|
|
94
|
+
* - 用 `isApplyingPromotion` 防递归;
|
|
95
|
+
* - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
|
|
96
|
+
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进。
|
|
97
|
+
*/
|
|
98
|
+
applyPromotion(): Promise<void>;
|
|
99
|
+
/** 最近一次 applyPromotion 输出的未满足促销列表 */
|
|
100
|
+
getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
|
|
101
|
+
/** 最近一次 applyPromotion 输出的赠品操作 diff */
|
|
102
|
+
getLastGiftActions(): OrderLastGiftActions | null;
|
|
53
103
|
initTempOrder(params: {
|
|
54
104
|
cacheId?: string;
|
|
55
105
|
salesSummaryModuleName?: string;
|
|
@@ -64,6 +114,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
64
114
|
private createExternalSaleNumber;
|
|
65
115
|
private ensureExternalSaleNumber;
|
|
66
116
|
private ensureRequestUniqueIdempotencyToken;
|
|
117
|
+
private buildPaymentSyncIdempotencyToken;
|
|
67
118
|
hasLocalDatabase(): boolean;
|
|
68
119
|
private buildLocalOrderRecord;
|
|
69
120
|
getLocalOrderByOrderId(orderId: number | string): Promise<Record<string, any> | null>;
|