@pisell/pisellos 2.2.264 → 2.2.265
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/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- 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 +1370 -808
- 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 +62 -66
- 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 -9
- package/dist/modules/Rules/index.js +69 -43
- 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 +54 -4
- package/dist/solution/BaseSales/index.js +1448 -788
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +50 -97
- 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 +61 -26
- 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/ScanOrder/index.js +20 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/solution/VenueBooking/index.js +19 -30
- 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/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -2
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -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 +505 -119
- 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 +27 -26
- 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 -9
- package/lib/modules/Rules/index.js +61 -29
- 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 +54 -4
- package/lib/solution/BaseSales/index.js +475 -50
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +25 -64
- 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 +35 -9
- 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/ScanOrder/index.js +0 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- 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
|
}
|
|
@@ -78,7 +78,6 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
-
getStrategyConfigs?: () => unknown[];
|
|
82
81
|
}
|
|
83
82
|
/** 单个赠品减量项 */
|
|
84
83
|
export interface GiftReduceItem {
|
|
@@ -268,8 +267,7 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
268
267
|
* 处理购物车的促销计算与赠品差异化。
|
|
269
268
|
*
|
|
270
269
|
* 流程:
|
|
271
|
-
* 1. 分离 main / gift / edit-product
|
|
272
|
-
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
270
|
+
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
273
271
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
274
272
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
275
273
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|
|
@@ -77,43 +77,19 @@ function getOrderProductOriginalPriceForPromotion(product) {
|
|
|
77
77
|
}
|
|
78
78
|
return getOrderProductBasePrice(product);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
var ITEM_REWARD = "ITEM_REWARD";
|
|
82
|
-
function isItemRewardPromotionDiscountItem(item) {
|
|
83
|
-
var _a, _b;
|
|
84
|
-
return (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;
|
|
85
|
-
}
|
|
86
|
-
function isManagedPromotionDiscountItem(item) {
|
|
87
|
-
if ((item == null ? void 0 : item.type) === "promotion")
|
|
88
|
-
return true;
|
|
89
|
-
return isItemRewardPromotionDiscountItem(item);
|
|
90
|
-
}
|
|
91
|
-
function wasInPromotionBeforeEvaluation(item) {
|
|
92
|
-
var _a, _b;
|
|
93
|
-
if (((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true)
|
|
94
|
-
return true;
|
|
95
|
-
return Array.isArray(item == null ? void 0 : item.discount_list) && item.discount_list.some(isItemRewardPromotionDiscountItem);
|
|
96
|
-
}
|
|
97
|
-
function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
80
|
+
function updatePromotionDiscountList(item, promotionDiscount) {
|
|
98
81
|
let discountList = Array.isArray(item.discount_list) ? [...item.discount_list] : [];
|
|
99
|
-
discountList = discountList.filter((d) =>
|
|
82
|
+
discountList = discountList.filter((d) => (d == null ? void 0 : d.type) !== "promotion");
|
|
100
83
|
if (promotionDiscount) {
|
|
101
|
-
const discountType = (options == null ? void 0 : options.discountType) || "promotion";
|
|
102
84
|
discountList.push({
|
|
103
|
-
type:
|
|
85
|
+
type: "promotion",
|
|
104
86
|
amount: promotionDiscount.amount,
|
|
105
87
|
discount: {
|
|
106
88
|
original_amount: promotionDiscount.original_amount,
|
|
107
89
|
fixed_amount: promotionDiscount.fixed_amount,
|
|
108
90
|
title: promotionDiscount.title,
|
|
109
91
|
resource_id: ""
|
|
110
|
-
}
|
|
111
|
-
...discountType === "product" ? {
|
|
112
|
-
metadata: {
|
|
113
|
-
source: "promotion",
|
|
114
|
-
actionType: (options == null ? void 0 : options.actionType) || ITEM_REWARD
|
|
115
|
-
}
|
|
116
|
-
} : {}
|
|
92
|
+
}
|
|
117
93
|
});
|
|
118
94
|
}
|
|
119
95
|
if (discountList.length > 0) {
|
|
@@ -122,15 +98,7 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
|
122
98
|
delete item.discount_list;
|
|
123
99
|
}
|
|
124
100
|
}
|
|
125
|
-
|
|
126
|
-
var _a;
|
|
127
|
-
const configs = (_a = evaluator == null ? void 0 : evaluator.getStrategyConfigs) == null ? void 0 : _a.call(evaluator);
|
|
128
|
-
if (!Array.isArray(configs))
|
|
129
|
-
return false;
|
|
130
|
-
return configs.some(
|
|
131
|
-
(config) => ((config == null ? void 0 : config.actions) || []).some((action) => (action == null ? void 0 : action.type) === actionType)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
101
|
+
var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
|
|
134
102
|
function applyPromoUnitPriceToLine(item, input) {
|
|
135
103
|
const metadata = item.metadata || (item.metadata = {});
|
|
136
104
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(item)).toNumber();
|
|
@@ -157,9 +125,6 @@ function applyPromoUnitPriceToLine(item, input) {
|
|
|
157
125
|
amount: discountAmount,
|
|
158
126
|
original_amount: catalogSource,
|
|
159
127
|
fixed_amount: discountAmount
|
|
160
|
-
}, {
|
|
161
|
-
actionType: input.actionType,
|
|
162
|
-
discountType: input.actionType === ITEM_REWARD ? "product" : "promotion"
|
|
163
128
|
});
|
|
164
129
|
} else {
|
|
165
130
|
updatePromotionDiscountList(item, null);
|
|
@@ -214,6 +179,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
214
179
|
promotion.finalPrice ?? ((_c = line.metadata) == null ? void 0 : _c.main_product_selling_price) ?? ""
|
|
215
180
|
);
|
|
216
181
|
const noteSignature = getProductLineNoteSignature(line);
|
|
182
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
217
183
|
const bookingUid = (line == null ? void 0 : line.booking_uid) ?? ((_d = line == null ? void 0 : line.metadata) == null ? void 0 : _d.booking_uid);
|
|
218
184
|
const orderDetailId = (line == null ? void 0 : line.order_detail_id) ?? (line == null ? void 0 : line.orderDetailId);
|
|
219
185
|
const mergeKey = [
|
|
@@ -221,6 +187,7 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
221
187
|
line.product_variant_id ?? 0,
|
|
222
188
|
fingerprint,
|
|
223
189
|
noteSignature,
|
|
190
|
+
lineMergeBoundary,
|
|
224
191
|
bookingUid ? String(bookingUid) : "",
|
|
225
192
|
orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "" ? String(orderDetailId) : "",
|
|
226
193
|
promotion.strategyId,
|
|
@@ -364,6 +331,12 @@ function getProductLineNoteSignature(product) {
|
|
|
364
331
|
const uid = getOrderProductUid(product);
|
|
365
332
|
return uid ? `note:${uid}` : `note:${normalizedNote}`;
|
|
366
333
|
}
|
|
334
|
+
function getPromotionLineMergeBoundary(product) {
|
|
335
|
+
var _a;
|
|
336
|
+
if (((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_edit_for_runtime) !== true)
|
|
337
|
+
return "";
|
|
338
|
+
return `edit:${getOrderProductUid(product)}`;
|
|
339
|
+
}
|
|
367
340
|
function isPersistedGeneratedVoucher(product) {
|
|
368
341
|
const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
|
|
369
342
|
if (orderDetailId === void 0 || orderDetailId === null || orderDetailId === "") {
|
|
@@ -391,6 +364,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
391
364
|
item.product_bundle
|
|
392
365
|
);
|
|
393
366
|
const noteSignature = getProductLineNoteSignature(item);
|
|
367
|
+
const lineMergeBoundary = getPromotionLineMergeBoundary(item);
|
|
394
368
|
const bookingUid = (item == null ? void 0 : item.booking_uid) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid);
|
|
395
369
|
const orderDetailId = (item == null ? void 0 : item.order_detail_id) ?? (item == null ? void 0 : item.orderDetailId);
|
|
396
370
|
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
@@ -399,6 +373,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
399
373
|
item.product_variant_id ?? 0,
|
|
400
374
|
fingerprint,
|
|
401
375
|
noteSignature,
|
|
376
|
+
lineMergeBoundary,
|
|
402
377
|
String(orderDetailId)
|
|
403
378
|
].join("#");
|
|
404
379
|
}
|
|
@@ -408,6 +383,7 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
408
383
|
item.product_variant_id ?? 0,
|
|
409
384
|
fingerprint,
|
|
410
385
|
noteSignature,
|
|
386
|
+
lineMergeBoundary,
|
|
411
387
|
String(bookingUid)
|
|
412
388
|
].join("#");
|
|
413
389
|
}
|
|
@@ -415,17 +391,19 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
415
391
|
item.product_id,
|
|
416
392
|
item.product_variant_id ?? 0,
|
|
417
393
|
fingerprint,
|
|
418
|
-
noteSignature
|
|
394
|
+
noteSignature,
|
|
395
|
+
lineMergeBoundary
|
|
419
396
|
].join("#");
|
|
420
397
|
}
|
|
421
398
|
function consolidateMainProductsForPromotion(entries) {
|
|
399
|
+
var _a, _b;
|
|
422
400
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
423
401
|
return [...entries || []];
|
|
424
402
|
}
|
|
425
403
|
const groups = /* @__PURE__ */ new Map();
|
|
426
404
|
for (const { item, originalListIndex } of entries) {
|
|
427
405
|
const key = buildConsolidateKeyForPromotion(item);
|
|
428
|
-
const wasInPromotion =
|
|
406
|
+
const wasInPromotion = ((_b = (_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a._promotion) == null ? void 0 : _b.inPromotion) === true;
|
|
429
407
|
const existing = groups.get(key);
|
|
430
408
|
if (!existing) {
|
|
431
409
|
const mergedItem = (0, import_lodash_es.cloneDeep)(item);
|
|
@@ -491,9 +469,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
|
|
|
491
469
|
function generateNumericId() {
|
|
492
470
|
return Math.floor(Math.random() * 1e9) + Date.now();
|
|
493
471
|
}
|
|
494
|
-
function isBookingEditProductLine(product) {
|
|
495
|
-
return (product == null ? void 0 : product.booking_id) !== void 0 && (product == null ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== "0";
|
|
496
|
-
}
|
|
497
472
|
function convertToPromotionProduct(product, index) {
|
|
498
473
|
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
499
474
|
const numericId = generateNumericId();
|
|
@@ -506,7 +481,6 @@ function convertToPromotionProduct(product, index) {
|
|
|
506
481
|
price: getOrderProductOriginalPriceForPromotion(product),
|
|
507
482
|
quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
|
|
508
483
|
bundle: getProductBundleForEvaluator(product),
|
|
509
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(product),
|
|
510
484
|
_originalItem: originalItem,
|
|
511
485
|
_originalId: getOrderProductUid(product),
|
|
512
486
|
_originalIndex: index
|
|
@@ -608,9 +582,6 @@ function resolveStrategyRequiredQuantity(matched) {
|
|
|
608
582
|
if (matched.actionType === "BUY_X_GET_Y_FREE") {
|
|
609
583
|
return Number(detail.buyQuantity) || 1;
|
|
610
584
|
}
|
|
611
|
-
if (matched.actionType === "ITEM_REWARD") {
|
|
612
|
-
return Number(detail.triggerQuantity) || 1;
|
|
613
|
-
}
|
|
614
585
|
return 1;
|
|
615
586
|
}
|
|
616
587
|
function resolveStrategyEligibleProducts(matched) {
|
|
@@ -721,10 +692,6 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
721
692
|
};
|
|
722
693
|
if (!list || list.length === 0 || !evaluator)
|
|
723
694
|
return empty;
|
|
724
|
-
const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
|
|
725
|
-
evaluator,
|
|
726
|
-
ITEM_REWARD
|
|
727
|
-
);
|
|
728
695
|
const mainProductsWithIndex = [];
|
|
729
696
|
const existingGiftsWithIndex = [];
|
|
730
697
|
const editProductsWithIndex = [];
|
|
@@ -735,12 +702,8 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
735
702
|
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
736
703
|
} else if (giftInfo) {
|
|
737
704
|
existingGiftsWithIndex.push({ item, originalListIndex: i });
|
|
738
|
-
} else if (
|
|
739
|
-
|
|
740
|
-
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
741
|
-
} else {
|
|
742
|
-
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
743
|
-
}
|
|
705
|
+
} else if ((item == null ? void 0 : item.booking_id) !== void 0 && (item == null ? void 0 : item.booking_id) !== null && item.booking_id !== 0 && item.booking_id !== "0") {
|
|
706
|
+
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
744
707
|
} else {
|
|
745
708
|
mainProductsWithIndex.push({ item, originalListIndex: i });
|
|
746
709
|
}
|
|
@@ -783,8 +746,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
783
746
|
name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
|
|
784
747
|
price: getOrderProductBasePrice(item),
|
|
785
748
|
quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
|
|
786
|
-
bundle: getProductBundleForEvaluator(item)
|
|
787
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(item)
|
|
749
|
+
bundle: getProductBundleForEvaluator(item)
|
|
788
750
|
};
|
|
789
751
|
});
|
|
790
752
|
for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
|
|
@@ -853,7 +815,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
853
815
|
const metadata = newItem.metadata || {};
|
|
854
816
|
const sourceCartNum = (0, import_utils2.getSafeProductNum)(originalItem.num);
|
|
855
817
|
newItem._sourceCartNum = sourceCartNum;
|
|
856
|
-
const wasInPromotion =
|
|
818
|
+
const wasInPromotion = ((_a = metadata._promotion) == null ? void 0 : _a.inPromotion) === true || originalItem._wasInPromotionBeforeConsolidate === true;
|
|
857
819
|
delete metadata._promotion;
|
|
858
820
|
if (Array.isArray(newItem.product_bundle)) {
|
|
859
821
|
for (const b of newItem.product_bundle) {
|
|
@@ -870,8 +832,7 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
870
832
|
applyPromoUnitPriceToLine(newItem, {
|
|
871
833
|
promoUnitPrice,
|
|
872
834
|
originalBasePrice,
|
|
873
|
-
strategyTitle: (
|
|
874
|
-
actionType: priced.strategyId ? (_b = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _b.actionType : void 0
|
|
835
|
+
strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
|
|
875
836
|
});
|
|
876
837
|
} else {
|
|
877
838
|
const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(newItem)).toNumber();
|
|
@@ -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;
|
|
@@ -341,15 +341,28 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
341
341
|
if (!this.store.order)
|
|
342
342
|
throw new Error("order 模块未初始化");
|
|
343
343
|
const raw = await this.store.order.scanCode(code, customerId);
|
|
344
|
+
const scannedList = raw.scannedDiscountList || [];
|
|
345
|
+
const extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
346
|
+
const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
347
|
+
if (!hasOrderCustomer && extractedCustomerId) {
|
|
348
|
+
await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
349
|
+
}
|
|
344
350
|
if (raw.isAvailable) {
|
|
345
|
-
await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
|
|
346
351
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
347
352
|
this.store.order.persistTempOrder();
|
|
353
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
354
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
355
|
+
productList: tempOrder.products || [],
|
|
356
|
+
discountList: this.store.order.getDiscountList(),
|
|
357
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
358
|
+
tempOrder
|
|
359
|
+
});
|
|
348
360
|
}
|
|
349
361
|
return {
|
|
350
362
|
isAvailable: raw.isAvailable,
|
|
351
363
|
type: raw.type,
|
|
352
|
-
unavailableReason: raw.unavailableReason
|
|
364
|
+
unavailableReason: raw.unavailableReason,
|
|
365
|
+
scannedDiscountList: raw.scannedDiscountList
|
|
353
366
|
};
|
|
354
367
|
}
|
|
355
368
|
async hydrateOrderCustomerFromScanDiscounts(discounts) {
|
|
@@ -366,11 +379,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
366
379
|
this.setOrderCustomer(customer);
|
|
367
380
|
}
|
|
368
381
|
getDiscountCustomerId(discounts) {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
382
|
+
for (const item of discounts) {
|
|
383
|
+
const topLevelId = Number(item.customer_id);
|
|
384
|
+
if (Number.isFinite(topLevelId) && topLevelId > 0) {
|
|
385
|
+
return topLevelId;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
374
389
|
}
|
|
375
390
|
async resolveCustomerByDiscountCustomerId(customerId) {
|
|
376
391
|
var _a;
|
|
@@ -862,7 +877,17 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
862
877
|
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
863
878
|
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
864
879
|
this.store.order.applyDiscount();
|
|
865
|
-
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() =>
|
|
880
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => {
|
|
881
|
+
var _a2;
|
|
882
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
883
|
+
this.store.order.persistTempOrder();
|
|
884
|
+
return this.effectsEmit("onDiscountApplied", {
|
|
885
|
+
productList: tempOrder.products || [],
|
|
886
|
+
discountList: ((_a2 = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _a2.call(discountModule)) || [],
|
|
887
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
888
|
+
tempOrder
|
|
889
|
+
});
|
|
890
|
+
}).catch((error) => {
|
|
866
891
|
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
867
892
|
});
|
|
868
893
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
@@ -1128,7 +1153,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1128
1153
|
}
|
|
1129
1154
|
/** 读取当前 booking config。 */
|
|
1130
1155
|
getBookingConfig() {
|
|
1131
|
-
|
|
1156
|
+
var _a;
|
|
1157
|
+
return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
|
|
1132
1158
|
}
|
|
1133
1159
|
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1134
1160
|
setResources(resources) {
|
|
@@ -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)
|
|
@@ -48,10 +48,6 @@ var import_utils2 = require("../../modules/Order/utils");
|
|
|
48
48
|
var import_dayjs = __toESM(require("dayjs"));
|
|
49
49
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
50
50
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
51
|
-
function isItemRewardProductDiscount(discount) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
54
|
-
}
|
|
55
51
|
var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
56
52
|
constructor(name, version) {
|
|
57
53
|
super(name, version);
|
|
@@ -746,10 +742,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
746
742
|
for (const product of tempOrder.products) {
|
|
747
743
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
748
744
|
continue;
|
|
749
|
-
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
750
|
-
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
745
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
754
746
|
var _a2;
|
|
755
747
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -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
|
);
|
|
@@ -65,10 +65,6 @@ var OPEN_DATA_SECTION_CODES = [
|
|
|
65
65
|
"workflow",
|
|
66
66
|
"checkout"
|
|
67
67
|
];
|
|
68
|
-
function isItemRewardProductDiscount(discount) {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
|
|
71
|
-
}
|
|
72
68
|
function cloneCustomDepositData(customDepositData) {
|
|
73
69
|
if (!customDepositData || typeof customDepositData !== "object")
|
|
74
70
|
return void 0;
|
|
@@ -1343,10 +1339,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1343
1339
|
for (const product of tempOrder.products) {
|
|
1344
1340
|
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1345
1341
|
continue;
|
|
1346
|
-
if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
|
|
1347
|
-
product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
|
|
1348
|
-
continue;
|
|
1349
|
-
}
|
|
1350
1342
|
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1351
1343
|
var _a2;
|
|
1352
1344
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
@@ -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
|
+
});
|