@pisell/pisellos 2.3.36 → 2.3.38
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.d.ts +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.js +21 -14
- package/dist/modules/Order/utils.js +2 -1
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +73 -4
- package/dist/modules/Payment/types.js +18 -3
- package/dist/modules/Payment/walletpass.d.ts +25 -1
- package/dist/modules/Payment/walletpass.js +707 -157
- package/dist/modules/Rules/index.d.ts +1 -0
- package/dist/modules/Rules/index.js +75 -49
- package/dist/server/index.js +28 -24
- package/dist/server/modules/order/index.d.ts +5 -0
- package/dist/server/modules/order/index.js +52 -31
- package/dist/solution/BaseSales/index.d.ts +77 -11
- package/dist/solution/BaseSales/index.js +1476 -434
- package/dist/solution/BaseSales/types.d.ts +52 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +7 -3
- package/dist/solution/BookingTicket/index.js +130 -48
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/dist/types/index.d.ts +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.js +10 -4
- package/lib/modules/Order/utils.js +6 -1
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +73 -4
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +25 -1
- package/lib/modules/Payment/walletpass.js +470 -21
- package/lib/modules/Rules/index.d.ts +1 -0
- package/lib/modules/Rules/index.js +30 -7
- package/lib/server/index.js +11 -8
- package/lib/server/modules/order/index.d.ts +5 -0
- package/lib/server/modules/order/index.js +24 -2
- package/lib/solution/BaseSales/index.d.ts +77 -11
- package/lib/solution/BaseSales/index.js +699 -41
- package/lib/solution/BaseSales/types.d.ts +52 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +7 -3
- package/lib/solution/BookingTicket/index.js +60 -8
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -12,6 +12,8 @@ export declare const PROMOTION_ACTION_TYPES: {
|
|
|
12
12
|
readonly X_ITEMS_FOR_Y_PRICE: "X_ITEMS_FOR_Y_PRICE";
|
|
13
13
|
/** 买X送Y(买X件送Y件,可累计) */
|
|
14
14
|
readonly BUY_X_GET_Y_FREE: "BUY_X_GET_Y_FREE";
|
|
15
|
+
/** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
|
|
16
|
+
readonly ITEM_REWARD: "ITEM_REWARD";
|
|
15
17
|
/** 固定折扣 */
|
|
16
18
|
readonly DISCOUNT_RATE: "DISCOUNT_RATE";
|
|
17
19
|
/** 固定减价 */
|
|
@@ -66,6 +68,59 @@ export interface BuyXGetYFreeConfig {
|
|
|
66
68
|
/** 可选的赠品列表 */
|
|
67
69
|
giftProducts?: ProductIdentifier[];
|
|
68
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* 商品奖励优惠方式
|
|
73
|
+
*
|
|
74
|
+
* - free: 目标商品最终价为 0
|
|
75
|
+
* - percent_off: 目标商品按百分比折扣,rewardValue 为 0-100
|
|
76
|
+
* - amount_off: 每个目标商品固定减免 rewardValue
|
|
77
|
+
* - fixed_price: 目标商品改为固定价 rewardValue
|
|
78
|
+
*/
|
|
79
|
+
export type ItemRewardMethod = 'free' | 'percent_off' | 'amount_off' | 'fixed_price';
|
|
80
|
+
/**
|
|
81
|
+
* 商品奖励数量规则
|
|
82
|
+
*
|
|
83
|
+
* - per_condition_quantity: 每满足 N 个条件商品,奖励 Y 个目标商品
|
|
84
|
+
* - all_targets: 满足条件后奖励全部目标商品
|
|
85
|
+
* - max_per_order: 满足条件后每单最多奖励固定数量目标商品
|
|
86
|
+
*/
|
|
87
|
+
export type ItemRewardQuantityRule = 'per_condition_quantity' | 'all_targets' | 'max_per_order';
|
|
88
|
+
/** 商品奖励目标选择规则 */
|
|
89
|
+
export type ItemRewardTargetSelection = 'consumer_best';
|
|
90
|
+
/**
|
|
91
|
+
* 商品奖励 - Action Value
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* value: {
|
|
95
|
+
* rewardMethod: 'free',
|
|
96
|
+
* quantityRule: 'per_condition_quantity',
|
|
97
|
+
* triggerQuantity: 1,
|
|
98
|
+
* rewardQuantity: 1,
|
|
99
|
+
* }
|
|
100
|
+
*/
|
|
101
|
+
export interface ItemRewardValue {
|
|
102
|
+
/** 奖励方式 */
|
|
103
|
+
rewardMethod: ItemRewardMethod;
|
|
104
|
+
/** 奖励值:percent_off/amount_off/fixed_price 使用,free 可省略 */
|
|
105
|
+
rewardValue?: number;
|
|
106
|
+
/** 奖励数量规则 */
|
|
107
|
+
quantityRule: ItemRewardQuantityRule;
|
|
108
|
+
/** 每满足 N 个条件商品;默认 1 */
|
|
109
|
+
triggerQuantity?: number;
|
|
110
|
+
/** 奖励 Y 个目标商品;默认 1 */
|
|
111
|
+
rewardQuantity?: number;
|
|
112
|
+
/** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
|
|
113
|
+
maxRewardQuantity?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 商品奖励 - Action Config
|
|
117
|
+
*/
|
|
118
|
+
export interface ItemRewardConfig {
|
|
119
|
+
/** 奖励对象,本期支持指定商品/变体;product_variant_id=0 表示任意变体 */
|
|
120
|
+
rewardTargets?: ProductIdentifier[];
|
|
121
|
+
/** 目标商品超额时的选择规则;本期支持 consumer_best */
|
|
122
|
+
targetSelection?: ItemRewardTargetSelection;
|
|
123
|
+
}
|
|
69
124
|
/**
|
|
70
125
|
* 商品标识
|
|
71
126
|
*
|
|
@@ -102,10 +157,19 @@ export interface BuyXGetYFreeAction extends Omit<ActionEffect, 'type' | 'value'
|
|
|
102
157
|
valueType: 'object';
|
|
103
158
|
config?: BuyXGetYFreeConfig;
|
|
104
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* 商品奖励 Action
|
|
162
|
+
*/
|
|
163
|
+
export interface ItemRewardAction extends Omit<ActionEffect, 'type' | 'value' | 'config'> {
|
|
164
|
+
type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
|
|
165
|
+
value: ItemRewardValue;
|
|
166
|
+
valueType: 'object';
|
|
167
|
+
config?: ItemRewardConfig;
|
|
168
|
+
}
|
|
105
169
|
/**
|
|
106
170
|
* 促销活动 Action 联合类型
|
|
107
171
|
*/
|
|
108
|
-
export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction;
|
|
172
|
+
export type PromotionAction = XItemsForYPriceAction | BuyXGetYFreeAction | ItemRewardAction;
|
|
109
173
|
/**
|
|
110
174
|
* 促销相关运算符
|
|
111
175
|
*/
|
|
@@ -170,6 +234,8 @@ export interface PromotionProduct {
|
|
|
170
234
|
quantity: number;
|
|
171
235
|
/** 原价 */
|
|
172
236
|
original_price?: number;
|
|
237
|
+
/** 内部字段:编辑态订单行只允许参与 ITEM_REWARD,避免旧促销误算历史行 */
|
|
238
|
+
_promotionOnlyForItemReward?: boolean;
|
|
173
239
|
}
|
|
174
240
|
/**
|
|
175
241
|
* 促销活动适配器转换结果
|
|
@@ -195,7 +261,7 @@ export interface PromotionTransformResult {
|
|
|
195
261
|
/**
|
|
196
262
|
* Action 详情联合类型
|
|
197
263
|
*/
|
|
198
|
-
export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail;
|
|
264
|
+
export type PromotionActionDetail = XItemsForYPriceActionDetail | BuyXGetYFreeActionDetail | ItemRewardActionDetail;
|
|
199
265
|
/**
|
|
200
266
|
* X件Y元 Action 详情
|
|
201
267
|
*/
|
|
@@ -226,6 +292,28 @@ export interface BuyXGetYFreeActionDetail {
|
|
|
226
292
|
/** 可选的赠品列表 */
|
|
227
293
|
giftProducts: ProductIdentifier[];
|
|
228
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* 商品奖励 Action 详情
|
|
297
|
+
*/
|
|
298
|
+
export interface ItemRewardActionDetail {
|
|
299
|
+
type: typeof PROMOTION_ACTION_TYPES.ITEM_REWARD;
|
|
300
|
+
/** 奖励方式 */
|
|
301
|
+
rewardMethod: ItemRewardMethod;
|
|
302
|
+
/** 奖励值:percent_off/amount_off/fixed_price 使用,free 为 0 */
|
|
303
|
+
rewardValue: number;
|
|
304
|
+
/** 奖励数量规则 */
|
|
305
|
+
quantityRule: ItemRewardQuantityRule;
|
|
306
|
+
/** 每满足 N 个条件商品;默认 1 */
|
|
307
|
+
triggerQuantity: number;
|
|
308
|
+
/** 奖励 Y 个目标商品;默认 1 */
|
|
309
|
+
rewardQuantity: number;
|
|
310
|
+
/** 每单最多奖励 Y 个目标商品;max_per_order 使用 */
|
|
311
|
+
maxRewardQuantity?: number;
|
|
312
|
+
/** 奖励对象,本期支持指定商品/变体 */
|
|
313
|
+
rewardTargets: ProductIdentifier[];
|
|
314
|
+
/** 目标商品超额时的选择规则 */
|
|
315
|
+
targetSelection: ItemRewardTargetSelection;
|
|
316
|
+
}
|
|
229
317
|
/**
|
|
230
318
|
* X件Y元 - 业务层计算结果
|
|
231
319
|
*
|
|
@@ -28,6 +28,8 @@ var PROMOTION_ACTION_TYPES = {
|
|
|
28
28
|
X_ITEMS_FOR_Y_PRICE: "X_ITEMS_FOR_Y_PRICE",
|
|
29
29
|
/** 买X送Y(买X件送Y件,可累计) */
|
|
30
30
|
BUY_X_GET_Y_FREE: "BUY_X_GET_Y_FREE",
|
|
31
|
+
/** 商品奖励(满足条件后,订单内指定目标商品享优惠) */
|
|
32
|
+
ITEM_REWARD: "ITEM_REWARD",
|
|
31
33
|
/** 固定折扣 */
|
|
32
34
|
DISCOUNT_RATE: "DISCOUNT_RATE",
|
|
33
35
|
/** 固定减价 */
|
|
@@ -184,7 +184,7 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
function buildCacheItemFromOrderLine(input) {
|
|
187
|
-
var _a, _b, _c, _d, _e, _f;
|
|
187
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
188
188
|
const { product, booking, sourceProduct } = input;
|
|
189
189
|
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
190
190
|
const selling = Number(product.selling_price ?? 0);
|
|
@@ -259,6 +259,7 @@ function buildCacheItemFromOrderLine(input) {
|
|
|
259
259
|
price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? selling,
|
|
260
260
|
selling_price: product.selling_price,
|
|
261
261
|
original_price: product.original_price,
|
|
262
|
+
...Number(((_g = product.product_sku) == null ? void 0 : _g.open_sold_weight) || 0) === 1 ? { product_sku: JSON.parse(JSON.stringify(product.product_sku)) } : {},
|
|
262
263
|
...productOptionString ? { product_option_string: productOptionString } : {},
|
|
263
264
|
_extend: extend,
|
|
264
265
|
new: 0,
|
|
@@ -78,7 +78,7 @@ function mapOrderBundleToOtherBundle(bundle) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function buildNormalProductCacheItemFromOrderLine(input) {
|
|
81
|
-
var _a, _b, _c, _d, _e;
|
|
81
|
+
var _a, _b, _c, _d, _e, _f;
|
|
82
82
|
const { product, sourceProduct } = input;
|
|
83
83
|
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
84
84
|
const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
|
|
@@ -144,6 +144,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
144
144
|
note: product.note,
|
|
145
145
|
order_detail_id: product.order_detail_id ?? null,
|
|
146
146
|
discount_list: discountList,
|
|
147
|
+
...Number(((_f = product.product_sku) == null ? void 0 : _f.open_sold_weight) || 0) === 1 ? { product_sku: JSON.parse(JSON.stringify(product.product_sku)) } : {},
|
|
147
148
|
new: 0,
|
|
148
149
|
autoClose: true,
|
|
149
150
|
_extend: extend
|
|
@@ -27,6 +27,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
27
27
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
28
28
|
getOpenData(): OpenDataConfig | null;
|
|
29
29
|
getLastFetchedAt(): number | null;
|
|
30
|
+
/** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
|
|
31
|
+
clearCache(): void;
|
|
30
32
|
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
31
33
|
storeChange(): void;
|
|
32
34
|
}
|
|
@@ -104,6 +104,11 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
|
|
|
104
104
|
getLastFetchedAt() {
|
|
105
105
|
return this.store.lastFetchedAt ?? null;
|
|
106
106
|
}
|
|
107
|
+
/** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
|
|
108
|
+
clearCache() {
|
|
109
|
+
this.store.data = null;
|
|
110
|
+
this.store.lastFetchedAt = null;
|
|
111
|
+
}
|
|
107
112
|
checkAvailability(scheduleModule) {
|
|
108
113
|
var _a;
|
|
109
114
|
const scheduleList = scheduleModule ? scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(
|
|
@@ -85,6 +85,11 @@ function isPaidPaymentRecord(payment) {
|
|
|
85
85
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
86
86
|
return isVoucherPaymentRecord(payment) && (payment == null ? void 0 : payment.status) !== "voided" && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
87
87
|
}
|
|
88
|
+
function getVoucherPaymentLifecycleKey(payment) {
|
|
89
|
+
if (!isVoucherPaymentRecord(payment))
|
|
90
|
+
return null;
|
|
91
|
+
return `${String(payment.voucher_id)}::${String(payment.status || "")}`;
|
|
92
|
+
}
|
|
88
93
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
89
94
|
constructor(name, version) {
|
|
90
95
|
super(name || "order", version);
|
|
@@ -2746,14 +2751,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2746
2751
|
const committedVoucherPaymentIds = new Set(
|
|
2747
2752
|
committedVoucherPayments.filter((payment) => hasSyncedOrderPaymentRecord(payment)).map((payment) => String(payment.order_payment_id))
|
|
2748
2753
|
);
|
|
2749
|
-
const
|
|
2750
|
-
committedVoucherPayments.map((payment) =>
|
|
2754
|
+
const committedVoucherLifecycleKeys = new Set(
|
|
2755
|
+
committedVoucherPayments.map((payment) => getVoucherPaymentLifecycleKey(payment)).filter((key) => key !== null)
|
|
2751
2756
|
);
|
|
2752
2757
|
const replaceableVouchers = mappedVouchers.filter((payment) => {
|
|
2753
2758
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
2754
2759
|
return false;
|
|
2755
2760
|
}
|
|
2756
|
-
|
|
2761
|
+
const lifecycleKey = getVoucherPaymentLifecycleKey(payment);
|
|
2762
|
+
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
2757
2763
|
return false;
|
|
2758
2764
|
}
|
|
2759
2765
|
return true;
|
|
@@ -3623,7 +3629,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3623
3629
|
tempOrder,
|
|
3624
3630
|
cacheId: (params == null ? void 0 : params.cacheId) ?? this.cacheId,
|
|
3625
3631
|
platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
|
|
3626
|
-
businessCode: (params == null ? void 0 : params.businessCode)
|
|
3632
|
+
businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code) || tempOrder.business_code,
|
|
3627
3633
|
channel: params == null ? void 0 : params.channel,
|
|
3628
3634
|
type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
|
|
3629
3635
|
summary: latestSummary,
|
|
@@ -444,7 +444,12 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
444
444
|
(sum, discount) => sum + Number((discount == null ? void 0 : discount.amount) || 0),
|
|
445
445
|
0
|
|
446
446
|
);
|
|
447
|
-
const hasPromoDiscountItem = discountList.some(
|
|
447
|
+
const hasPromoDiscountItem = discountList.some(
|
|
448
|
+
(item) => {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
return (item == null ? void 0 : item.type) === "promotion" || (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
451
|
+
}
|
|
452
|
+
);
|
|
448
453
|
if (hasPromoDiscountItem)
|
|
449
454
|
return fromList;
|
|
450
455
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
@@ -1088,7 +1088,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1088
1088
|
roundedValue = this.standardRound(baseValue, true);
|
|
1089
1089
|
break;
|
|
1090
1090
|
case import_types.RoundingRule.StandardDown:
|
|
1091
|
-
case "
|
|
1091
|
+
case "standard_rounding_midpoint_down":
|
|
1092
1092
|
roundedValue = this.standardRound(baseValue, false);
|
|
1093
1093
|
break;
|
|
1094
1094
|
case import_types.RoundingRule.AlwaysUp:
|
|
@@ -40,11 +40,11 @@ export declare enum RoundingRule {
|
|
|
40
40
|
/** 标准舍入(中点向上) */
|
|
41
41
|
Standard = "standard_rounding",
|
|
42
42
|
/** 标准舍入(中点向下) */
|
|
43
|
-
StandardDown = "
|
|
43
|
+
StandardDown = "standard_rounding_midpoint_down",
|
|
44
44
|
/** 总是向上舍入 */
|
|
45
|
-
AlwaysUp = "
|
|
45
|
+
AlwaysUp = "round_up",
|
|
46
46
|
/** 总是向下舍入 */
|
|
47
|
-
AlwaysDown = "
|
|
47
|
+
AlwaysDown = "round_down"
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* 舍入结果
|
|
@@ -340,6 +340,8 @@ export interface CashPayment {
|
|
|
340
340
|
processCashPayment: (amount: number, orderUuid: string) => Promise<void>;
|
|
341
341
|
/** 获取现金余额 */
|
|
342
342
|
getCashBalance: () => Promise<number>;
|
|
343
|
+
/** 根据币种面额生成现金快捷金额。 */
|
|
344
|
+
getRecommendedAmount: (money: number, currency: string) => number[];
|
|
343
345
|
}
|
|
344
346
|
/**
|
|
345
347
|
* Eftpos支付接口
|
|
@@ -365,6 +367,56 @@ export interface WalletStoredInitData {
|
|
|
365
367
|
noApplicableVoucher: any[];
|
|
366
368
|
products: any[];
|
|
367
369
|
}
|
|
370
|
+
export type WalletAssetId = string | number;
|
|
371
|
+
export type WalletAssetSelectionSource = 'manual' | 'scan';
|
|
372
|
+
export type WalletAssetsStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
373
|
+
/**
|
|
374
|
+
* 购物车与结账共享的钱包资产状态。
|
|
375
|
+
*
|
|
376
|
+
* 原始券字段完整保留在 items / selectedItems 中,Payment 只补充统一的
|
|
377
|
+
* 可用性、选择和加载状态,不在此层引入 UI ViewModel。
|
|
378
|
+
*/
|
|
379
|
+
export interface WalletAssetsState {
|
|
380
|
+
status: WalletAssetsStatus;
|
|
381
|
+
items: any[];
|
|
382
|
+
selectedIds: WalletAssetId[];
|
|
383
|
+
selectedItems: any[];
|
|
384
|
+
committedIds: WalletAssetId[];
|
|
385
|
+
selectionSources: Record<string, WalletAssetSelectionSource>;
|
|
386
|
+
totalSelectedAmount: number;
|
|
387
|
+
customerId?: string | number;
|
|
388
|
+
error: string | null;
|
|
389
|
+
revision: number;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Shared Wallet Assets 的可序列化运行时快照。
|
|
393
|
+
*
|
|
394
|
+
* state 供购物车 / Checkout 直接恢复展示与选择;searchResults 和
|
|
395
|
+
* calculationContext 用于商品变化后继续重验扫码搜索过的 Wallet。
|
|
396
|
+
*/
|
|
397
|
+
export interface WalletAssetsSnapshot {
|
|
398
|
+
state: WalletAssetsState;
|
|
399
|
+
searchResults: SearchIdentificationCodeItem[];
|
|
400
|
+
walletParams: WalletDeductionRecommendParams | null;
|
|
401
|
+
calculationContext: {
|
|
402
|
+
orderTotalAmount: number;
|
|
403
|
+
products: any[];
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
export interface RefreshWalletAssetsOptions {
|
|
407
|
+
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
408
|
+
preserveSelection?: boolean;
|
|
409
|
+
}
|
|
410
|
+
export interface SelectWalletAssetOptions {
|
|
411
|
+
selected: boolean;
|
|
412
|
+
source?: WalletAssetSelectionSource;
|
|
413
|
+
}
|
|
414
|
+
export interface ScanWalletAssetResult {
|
|
415
|
+
type: SearchIdentificationCodeResult['type'];
|
|
416
|
+
asset?: any;
|
|
417
|
+
selected: boolean;
|
|
418
|
+
state: WalletAssetsState;
|
|
419
|
+
}
|
|
368
420
|
export interface WalletPassPayment {
|
|
369
421
|
/** 生成钱包API默认参数 */
|
|
370
422
|
generateWalletParams: (businessData: WalletInitBusinessData) => WalletDeductionRecommendParams;
|
|
@@ -416,6 +468,22 @@ export interface WalletPassPayment {
|
|
|
416
468
|
processWalletPayment: (amount: number, orderUuid: string, voucherId?: string) => Promise<void>;
|
|
417
469
|
/** 获取钱包余额 */
|
|
418
470
|
getWalletBalance: (voucherId: string) => Promise<number>;
|
|
471
|
+
/** 刷新购物车/结账共享的钱包资产,刷新本身不会默认选券。 */
|
|
472
|
+
refreshWalletAssetsFromBusinessAsync: (businessData: WalletInitBusinessData, options?: RefreshWalletAssetsOptions) => Promise<WalletAssetsState>;
|
|
473
|
+
/** 获取共享钱包资产状态快照。 */
|
|
474
|
+
getWalletAssetsState: () => WalletAssetsState;
|
|
475
|
+
/** 导出供 Shared Checkout 跨运行时传递的 Wallet Assets 快照。 */
|
|
476
|
+
exportWalletAssetsSnapshot: () => WalletAssetsSnapshot;
|
|
477
|
+
/** 恢复 Shared Checkout 传回的 Wallet Assets 快照。 */
|
|
478
|
+
importWalletAssetsSnapshot: (snapshot: WalletAssetsSnapshot) => WalletAssetsState;
|
|
479
|
+
/** 设置单张钱包资产的选择状态并重新计算其实际抵扣额。 */
|
|
480
|
+
selectWalletAsset: (assetId: WalletAssetId, options: SelectWalletAssetOptions) => WalletAssetsState;
|
|
481
|
+
/** 精确搜索钱包资产;仅当前券可用时自动选择。 */
|
|
482
|
+
scanWalletAssetAsync: (code: string) => Promise<ScanWalletAssetResult>;
|
|
483
|
+
/** 清空未确认的钱包资产选择。 */
|
|
484
|
+
clearWalletAssetSelection: () => WalletAssetsState;
|
|
485
|
+
/** 同步订单中已经支付、不可撤销的钱包资产。 */
|
|
486
|
+
setCommittedWalletAssets: (committedIds: WalletAssetId[], committedAssets?: any[]) => WalletAssetsState;
|
|
419
487
|
}
|
|
420
488
|
/**
|
|
421
489
|
* 支付模块API接口
|
|
@@ -608,7 +676,8 @@ export declare enum WalletPassHooks {
|
|
|
608
676
|
OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted",
|
|
609
677
|
OnWalletInitializationStarted = "wallet:onWalletInitializationStarted",
|
|
610
678
|
OnWalletInitializationCompleted = "wallet:onWalletInitializationCompleted",
|
|
611
|
-
OnWalletInitializationFailed = "wallet:onWalletInitializationFailed"
|
|
679
|
+
OnWalletInitializationFailed = "wallet:onWalletInitializationFailed",
|
|
680
|
+
OnWalletAssetsStateChanged = "wallet:onWalletAssetsStateChanged"
|
|
612
681
|
}
|
|
613
682
|
/**
|
|
614
683
|
* 支付钩子事件(统一接口)
|
|
@@ -51,9 +51,9 @@ var TaskRunStatus = /* @__PURE__ */ ((TaskRunStatus2) => {
|
|
|
51
51
|
})(TaskRunStatus || {});
|
|
52
52
|
var RoundingRule = /* @__PURE__ */ ((RoundingRule2) => {
|
|
53
53
|
RoundingRule2["Standard"] = "standard_rounding";
|
|
54
|
-
RoundingRule2["StandardDown"] = "
|
|
55
|
-
RoundingRule2["AlwaysUp"] = "
|
|
56
|
-
RoundingRule2["AlwaysDown"] = "
|
|
54
|
+
RoundingRule2["StandardDown"] = "standard_rounding_midpoint_down";
|
|
55
|
+
RoundingRule2["AlwaysUp"] = "round_up";
|
|
56
|
+
RoundingRule2["AlwaysDown"] = "round_down";
|
|
57
57
|
return RoundingRule2;
|
|
58
58
|
})(RoundingRule || {});
|
|
59
59
|
var RoundingInterval = /* @__PURE__ */ ((RoundingInterval2) => {
|
|
@@ -73,6 +73,7 @@ var WalletPassHooks = /* @__PURE__ */ ((WalletPassHooks2) => {
|
|
|
73
73
|
WalletPassHooks2["OnWalletInitializationStarted"] = "wallet:onWalletInitializationStarted";
|
|
74
74
|
WalletPassHooks2["OnWalletInitializationCompleted"] = "wallet:onWalletInitializationCompleted";
|
|
75
75
|
WalletPassHooks2["OnWalletInitializationFailed"] = "wallet:onWalletInitializationFailed";
|
|
76
|
+
WalletPassHooks2["OnWalletAssetsStateChanged"] = "wallet:onWalletAssetsStateChanged";
|
|
76
77
|
return WalletPassHooks2;
|
|
77
78
|
})(WalletPassHooks || {});
|
|
78
79
|
var PaymentHooks = /* @__PURE__ */ ((PaymentHooks2) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData } from './types';
|
|
1
|
+
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData, WalletAssetId, WalletAssetsSnapshot, WalletAssetsState, RefreshWalletAssetsOptions, SelectWalletAssetOptions, ScanWalletAssetResult } from './types';
|
|
2
2
|
import type { PaymentModule } from './index';
|
|
3
3
|
/**
|
|
4
4
|
* 钱包支付实现
|
|
@@ -10,12 +10,22 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
10
10
|
private searchResults;
|
|
11
11
|
private walletParams;
|
|
12
12
|
private walletInitData;
|
|
13
|
+
private walletAssetsState;
|
|
14
|
+
private walletAssetsRequestSequence;
|
|
15
|
+
private walletAssetsCalculationContext;
|
|
13
16
|
constructor(paymentModule: PaymentModule);
|
|
14
17
|
/**
|
|
15
18
|
* 发送事件的辅助方法
|
|
16
19
|
* 支持使用WalletPassHooks或PaymentHooks
|
|
17
20
|
*/
|
|
18
21
|
private emitEvent;
|
|
22
|
+
private publishWalletAssetsState;
|
|
23
|
+
private recalculateWalletAssets;
|
|
24
|
+
/**
|
|
25
|
+
* 使用最新订单参数重验扫码搜索过的支付类 Wallet 资产。
|
|
26
|
+
* 请求失败或暂时无匹配结果时保留旧资产,避免商品变化造成列表闪空。
|
|
27
|
+
*/
|
|
28
|
+
private revalidateSearchedWalletAssets;
|
|
19
29
|
/**
|
|
20
30
|
* 生成钱包API默认参数
|
|
21
31
|
* 根据业务数据生成标准的钱包API参数,并存储在模块中
|
|
@@ -73,6 +83,20 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
73
83
|
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
74
84
|
noCache?: boolean;
|
|
75
85
|
}): Promise<SearchIdentificationCodeResult>;
|
|
86
|
+
/**
|
|
87
|
+
* 刷新购物车与结账共享的钱包资产。
|
|
88
|
+
*
|
|
89
|
+
* 与 legacy initializeWalletDataFromBusinessAsync 不同,这里维护选择状态;
|
|
90
|
+
* 推荐结果只作为可用性/金额计算输入,不会自动成为 selectedIds。
|
|
91
|
+
*/
|
|
92
|
+
refreshWalletAssetsFromBusinessAsync(businessData: WalletInitBusinessData, options?: RefreshWalletAssetsOptions): Promise<WalletAssetsState>;
|
|
93
|
+
getWalletAssetsState(): WalletAssetsState;
|
|
94
|
+
exportWalletAssetsSnapshot(): WalletAssetsSnapshot;
|
|
95
|
+
importWalletAssetsSnapshot(snapshot: WalletAssetsSnapshot): WalletAssetsState;
|
|
96
|
+
selectWalletAsset(assetId: WalletAssetId, options: SelectWalletAssetOptions): WalletAssetsState;
|
|
97
|
+
scanWalletAssetAsync(code: string): Promise<ScanWalletAssetResult>;
|
|
98
|
+
clearWalletAssetSelection(): WalletAssetsState;
|
|
99
|
+
setCommittedWalletAssets(committedIds: WalletAssetId[], committedAssets?: any[]): WalletAssetsState;
|
|
76
100
|
processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
|
|
77
101
|
getWalletBalance(voucherId: string): Promise<number>;
|
|
78
102
|
/**
|