@pisell/pisellos 2.3.128 → 2.3.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Customer/index.js +6 -3
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +49 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +37 -151
- package/dist/modules/Discount/types.d.ts +36 -5
- package/dist/modules/Order/index.d.ts +6 -0
- package/dist/modules/Order/index.js +443 -235
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +101 -60
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +480 -186
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +5 -2
- package/dist/solution/BaseSales/types.d.ts +2 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BookingTicket/index.d.ts +1 -2
- package/dist/solution/BookingTicket/index.js +60 -63
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +99 -42
- package/dist/solution/ShopDiscount/utils.d.ts +4 -2
- package/dist/solution/ShopDiscount/utils.js +43 -23
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Customer/index.js +5 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +43 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +141 -0
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +23 -129
- package/lib/modules/Discount/types.d.ts +36 -5
- package/lib/modules/Order/index.d.ts +6 -0
- package/lib/modules/Order/index.js +213 -40
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +39 -3
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +357 -110
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +5 -2
- package/lib/solution/BaseSales/types.d.ts +2 -2
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -2
- package/lib/solution/BookingTicket/index.js +36 -33
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/utils.d.ts +4 -2
- package/lib/solution/ShopDiscount/utils.js +42 -25
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ var _utils = require("./utils");
|
|
|
10
10
|
var _utils2 = require("../Product/utils");
|
|
11
11
|
var _weighedProduct = require("./utils/weighedProduct");
|
|
12
12
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
13
|
+
var _availability = require("../Discount/availability");
|
|
13
14
|
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
14
15
|
var _salesNotes = require("./salesNotes");
|
|
15
16
|
var _paymentUtils = require("./payment-utils");
|
|
@@ -23,6 +24,7 @@ var _discountProductLineIdentity = require("./utils/discountProductLineIdentity"
|
|
|
23
24
|
var _virtualSettlement = require("./utils/virtualSettlement");
|
|
24
25
|
var _Discount = require("../Discount");
|
|
25
26
|
var _Rules = require("../Rules");
|
|
27
|
+
var _entitlementPass = require("../Discount/entitlementPass");
|
|
26
28
|
var _types2 = require("../Rules/types");
|
|
27
29
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
28
30
|
var _lodashEs = require("lodash-es");
|
|
@@ -42,9 +44,27 @@ function isSameDiscountList(left, right) {
|
|
|
42
44
|
function isManualProductDiscountProduct(product) {
|
|
43
45
|
return (0, _manualProductDiscount.hasManualProductDiscountFlag)(product?.metadata) || (product?.discount_list || []).some(item => item?.type === 'product');
|
|
44
46
|
}
|
|
47
|
+
function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
|
|
48
|
+
if (!Array.isArray(discountList)) return discountList;
|
|
49
|
+
const previousCount = (0, _utils3.getSafeProductNum)(previousQuantity);
|
|
50
|
+
const nextCount = (0, _utils3.getSafeProductNum)(nextQuantity);
|
|
51
|
+
if (nextCount >= previousCount) return discountList;
|
|
52
|
+
return discountList.map(discount => {
|
|
53
|
+
if (!(0, _entitlementPass.isEntitlementPass)(discount)) return discount;
|
|
54
|
+
const rawUsageCount = Number(discount?.metadata?.num ?? previousCount);
|
|
55
|
+
const usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
|
|
56
|
+
return {
|
|
57
|
+
...discount,
|
|
58
|
+
metadata: {
|
|
59
|
+
...(discount?.metadata || {}),
|
|
60
|
+
num: Math.min(usageCount, nextCount)
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
45
65
|
const ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
46
66
|
const ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
47
|
-
const CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
67
|
+
const CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
|
|
48
68
|
function isCustomerPromotionDiscount(discount) {
|
|
49
69
|
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String(discount?.tag || discount?.type || '').toLowerCase());
|
|
50
70
|
}
|
|
@@ -74,6 +94,28 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
74
94
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
75
95
|
return `${String(payment.voucher_id)}::${String(payment.status || '')}`;
|
|
76
96
|
}
|
|
97
|
+
function getDiscountIdentityKey(discount) {
|
|
98
|
+
const id = discount?.id;
|
|
99
|
+
if (id === undefined || id === null || id === '') return null;
|
|
100
|
+
return String(id);
|
|
101
|
+
}
|
|
102
|
+
function mergeCommittedEntitlementWithRuntime(committed, runtime) {
|
|
103
|
+
const committedAppliedProductDetails = committed.committedAppliedProductDetails?.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
|
|
104
|
+
return {
|
|
105
|
+
...committed,
|
|
106
|
+
...runtime,
|
|
107
|
+
id: runtime.id ?? committed.id,
|
|
108
|
+
tag: runtime.tag || committed.tag,
|
|
109
|
+
type: runtime.type || committed.type,
|
|
110
|
+
isEditMode: false,
|
|
111
|
+
isDisabled: runtime.isDisabled ?? false,
|
|
112
|
+
isSelected: runtime.isSelected ?? committed.isSelected,
|
|
113
|
+
isUsed: committed.isUsed || runtime.isUsed,
|
|
114
|
+
committedAppliedProductDetails: [...committedAppliedProductDetails],
|
|
115
|
+
applicableProductDetails: [...(committed.applicableProductDetails || []), ...(runtime.applicableProductDetails || [])],
|
|
116
|
+
appliedProductDetails: [...committedAppliedProductDetails, ...(runtime.appliedProductDetails || [])]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
77
119
|
class OrderModule extends _BaseModule.BaseModule {
|
|
78
120
|
defaultName = 'order';
|
|
79
121
|
defaultVersion = '1.0.0';
|
|
@@ -129,6 +171,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
129
171
|
const key = Number.isFinite(id) ? id : String(resourceId);
|
|
130
172
|
const title = item?.discount?.title ?? {};
|
|
131
173
|
const amount = Number(item?.amount || 0);
|
|
174
|
+
const encoded = item?.metadata?.encoded || item?.encoded || item?.discount?.encoded || '';
|
|
132
175
|
const discountCardType = item?.discount?.discount_card_type;
|
|
133
176
|
const parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? item?.discount?.fixed_amount ?? item?.amount : item?.discount?.percent : '0';
|
|
134
177
|
const detail = {
|
|
@@ -139,11 +182,21 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
139
182
|
original_amount: String(item?.discount?.original_amount ?? item?.amount ?? '0'),
|
|
140
183
|
num: Number(item?.metadata?.num ?? product?.num ?? product?.product_quantity ?? 1) || 1,
|
|
141
184
|
metadata: item?.metadata,
|
|
142
|
-
discount:
|
|
185
|
+
discount: {
|
|
186
|
+
...(item?.discount || {}),
|
|
187
|
+
product_id: item?.discount?.product_id ?? product?.product_id
|
|
188
|
+
},
|
|
143
189
|
_num: Number(item?.metadata?.num ?? product?.num ?? product?.product_quantity ?? 1) || 1
|
|
144
190
|
};
|
|
145
191
|
const existed = discountMap.get(key);
|
|
146
192
|
if (existed) {
|
|
193
|
+
if (!existed.encoded && encoded) {
|
|
194
|
+
existed.encoded = encoded;
|
|
195
|
+
existed.metadata = {
|
|
196
|
+
...existed.metadata,
|
|
197
|
+
encoded
|
|
198
|
+
};
|
|
199
|
+
}
|
|
147
200
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
148
201
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
149
202
|
if (!isDiscountCard) {
|
|
@@ -163,8 +216,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
163
216
|
discountMap.set(key, {
|
|
164
217
|
id: key,
|
|
165
218
|
product_name: '',
|
|
166
|
-
encoded
|
|
167
|
-
code: '',
|
|
219
|
+
encoded,
|
|
220
|
+
code: item?.code || item?.discount?.code || '',
|
|
221
|
+
metadata: {
|
|
222
|
+
encoded
|
|
223
|
+
},
|
|
168
224
|
tag: type,
|
|
169
225
|
product_id: item?.discount?.discount_product_id ?? product?.product_id ?? 0,
|
|
170
226
|
relation_type: '',
|
|
@@ -455,7 +511,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
455
511
|
this.store.rules = rules;
|
|
456
512
|
}
|
|
457
513
|
createDefaultRulesHooks() {
|
|
458
|
-
return (0, _utils.createDefaultOrderRulesHooks)();
|
|
514
|
+
return (0, _utils.createDefaultOrderRulesHooks)(() => this.store.tempOrder?.bookings || []);
|
|
459
515
|
}
|
|
460
516
|
|
|
461
517
|
/**
|
|
@@ -481,6 +537,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
481
537
|
with_wallet_pass_holder: 1,
|
|
482
538
|
with_available_wallet_flag: 1,
|
|
483
539
|
with_available_wallet_pass_flag: 1,
|
|
540
|
+
with_entitlement_pass: 1,
|
|
541
|
+
filter_order_wallet_pass_usage: 0,
|
|
484
542
|
with_virtual_currency: 1,
|
|
485
543
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
486
544
|
...(orderId ? {
|
|
@@ -502,17 +560,61 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
502
560
|
}
|
|
503
561
|
if (discountList) {
|
|
504
562
|
const currentDiscountList = this.store.discount?.getDiscountList() || [];
|
|
505
|
-
const
|
|
563
|
+
const currentCommittedDiscounts = currentDiscountList.filter(discount => discount?.isEditMode || discount?.committedAppliedProductDetails?.length);
|
|
506
564
|
const currentScanDiscounts = currentDiscountList.filter(discount => discount?.isScan);
|
|
507
|
-
const
|
|
565
|
+
const currentScanDiscountById = new Map(currentScanDiscounts.flatMap(discount => {
|
|
566
|
+
const id = getDiscountIdentityKey(discount);
|
|
567
|
+
return id === null ? [] : [[id, discount]];
|
|
568
|
+
}));
|
|
569
|
+
const committedDiscountById = new Map(currentCommittedDiscounts.flatMap(discount => {
|
|
570
|
+
const id = getDiscountIdentityKey(discount);
|
|
571
|
+
return id === null ? [] : [[id, discount]];
|
|
572
|
+
}));
|
|
573
|
+
const mergedCommittedDiscountIds = new Set();
|
|
574
|
+
const refreshedScanDiscountIds = new Set();
|
|
508
575
|
const runtimeDiscountIds = new Set();
|
|
509
|
-
const runtimeDiscounts = discountList.
|
|
510
|
-
|
|
511
|
-
if (
|
|
512
|
-
runtimeDiscountIds.
|
|
513
|
-
|
|
576
|
+
const runtimeDiscounts = discountList.flatMap(discount => {
|
|
577
|
+
const id = getDiscountIdentityKey(discount);
|
|
578
|
+
if (id === null) return [discount];
|
|
579
|
+
if (runtimeDiscountIds.has(id)) return [];
|
|
580
|
+
runtimeDiscountIds.add(id);
|
|
581
|
+
const currentScanDiscount = currentScanDiscountById.get(id);
|
|
582
|
+
if (currentScanDiscount && (!(0, _entitlementPass.isEntitlementPass)(currentScanDiscount) || !(0, _entitlementPass.isEntitlementPass)(discount))) {
|
|
583
|
+
return [];
|
|
584
|
+
}
|
|
585
|
+
const committedDiscount = committedDiscountById.get(id);
|
|
586
|
+
let nextDiscount = discount;
|
|
587
|
+
if (committedDiscount && (0, _entitlementPass.isEntitlementPass)(committedDiscount) && (0, _entitlementPass.isEntitlementPass)(discount)) {
|
|
588
|
+
mergedCommittedDiscountIds.add(id);
|
|
589
|
+
nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
|
|
590
|
+
}
|
|
591
|
+
if (currentScanDiscount) {
|
|
592
|
+
refreshedScanDiscountIds.add(id);
|
|
593
|
+
nextDiscount = {
|
|
594
|
+
...nextDiscount,
|
|
595
|
+
isScan: true,
|
|
596
|
+
isSelected: currentScanDiscount.isSelected ?? nextDiscount.isSelected,
|
|
597
|
+
isManualSelect: currentScanDiscount.isManualSelect ?? nextDiscount.isManualSelect
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
return [nextDiscount];
|
|
601
|
+
});
|
|
602
|
+
const retainedCommittedDiscounts = currentCommittedDiscounts.filter(discount => {
|
|
603
|
+
const id = getDiscountIdentityKey(discount);
|
|
604
|
+
return id === null || !mergedCommittedDiscountIds.has(id);
|
|
605
|
+
}).map(discount => discount.committedAppliedProductDetails?.length ? {
|
|
606
|
+
...discount,
|
|
607
|
+
isEditMode: true,
|
|
608
|
+
isDisabled: true,
|
|
609
|
+
isSelected: true,
|
|
610
|
+
isUsed: true,
|
|
611
|
+
appliedProductDetails: [...discount.committedAppliedProductDetails]
|
|
612
|
+
} : discount);
|
|
613
|
+
const retainedScanDiscounts = currentScanDiscounts.filter(discount => {
|
|
614
|
+
const id = getDiscountIdentityKey(discount);
|
|
615
|
+
return id === null || !refreshedScanDiscountIds.has(id);
|
|
514
616
|
});
|
|
515
|
-
const mergedDiscountList = [...
|
|
617
|
+
const mergedDiscountList = [...retainedCommittedDiscounts, ...retainedScanDiscounts, ...runtimeDiscounts];
|
|
516
618
|
if (!isCurrentRequest()) return this.getDiscountList();
|
|
517
619
|
await this.store.discount?.setOriginalDiscountList(mergedDiscountList);
|
|
518
620
|
if (!isCurrentRequest()) return this.getDiscountList();
|
|
@@ -633,19 +735,34 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
633
735
|
isAvailable: false,
|
|
634
736
|
discountList: this.getDiscountList()
|
|
635
737
|
};
|
|
636
|
-
const
|
|
738
|
+
const scannedIds = new Set(withScanList.map(discount => String(discount.id)));
|
|
739
|
+
const evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(discount => scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !(0, _availability.getDiscountLifecycleReason)(discount));
|
|
740
|
+
const shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
|
|
637
741
|
const normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
638
|
-
const retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
639
742
|
let resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
640
743
|
if (isAvailable && normalizedNewDiscountList) {
|
|
641
744
|
await this.store.discount?.setDiscountList(normalizedNewDiscountList);
|
|
642
|
-
|
|
745
|
+
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
746
|
+
this.applyDiscount({
|
|
747
|
+
preferredEntitlementPassIds: withScanList.filter(discount => (0, _entitlementPass.isEntitlementPass)(discount)).map(discount => discount.id)
|
|
748
|
+
});
|
|
643
749
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
644
750
|
resolvedDiscountList = this.getDiscountList();
|
|
645
|
-
} else if (shouldRetainForLater
|
|
646
|
-
//
|
|
647
|
-
|
|
648
|
-
|
|
751
|
+
} else if (shouldRetainForLater) {
|
|
752
|
+
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
753
|
+
const retainedDiscounts = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
|
|
754
|
+
evaluatedScannedDiscounts.forEach(discount => {
|
|
755
|
+
retainedDiscounts.set(String(discount.id), {
|
|
756
|
+
...discount,
|
|
757
|
+
isScan: true,
|
|
758
|
+
isAvailable: false,
|
|
759
|
+
isSelected: false,
|
|
760
|
+
reasonCode: discount.reasonCode || 'product_not_applicable',
|
|
761
|
+
appliedProductDetails: [],
|
|
762
|
+
savedAmount: 0
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
await this.store.discount?.setDiscountList([...retainedDiscounts.values()]);
|
|
649
766
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
650
767
|
resolvedDiscountList = this.getDiscountList();
|
|
651
768
|
}
|
|
@@ -654,7 +771,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
654
771
|
isAvailable: isAvailable || false,
|
|
655
772
|
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
656
773
|
discountList: resolvedDiscountList,
|
|
657
|
-
scannedDiscountList:
|
|
774
|
+
scannedDiscountList: evaluatedScannedDiscounts,
|
|
658
775
|
unavailableReason
|
|
659
776
|
};
|
|
660
777
|
}
|
|
@@ -687,7 +804,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
687
804
|
orderTotalAmount: Number(this.store.summary?.total_amount || 0)
|
|
688
805
|
}, {
|
|
689
806
|
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
690
|
-
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids
|
|
807
|
+
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids,
|
|
808
|
+
preferredEntitlementPassIds: options?.preferredEntitlementPassIds
|
|
691
809
|
});
|
|
692
810
|
if (result?.productList) {
|
|
693
811
|
const previousProductsByUid = (0, _utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -1643,7 +1761,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1643
1761
|
const sku = product?.product_sku || {};
|
|
1644
1762
|
const metadata = product?.metadata || {};
|
|
1645
1763
|
const discountTypes = (product?.discount_list || []).map(discount => discount?.type ?? discount?.tag);
|
|
1646
|
-
const
|
|
1764
|
+
const fullCoveragePassType = discountTypes.find(type => ['entitlement_pass', 'good_pass'].includes(type));
|
|
1765
|
+
const extensionType = product?.extension_type || fullCoveragePassType || 'normal';
|
|
1647
1766
|
return {
|
|
1648
1767
|
product_id: product?.product_id ?? null,
|
|
1649
1768
|
product_variant_id: product?.product_variant_id ?? null,
|
|
@@ -1696,7 +1815,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1696
1815
|
const sku = product?.product_sku || {};
|
|
1697
1816
|
const metadata = product?.metadata || {};
|
|
1698
1817
|
const discountTypes = (product?.discount_list || []).map(discount => discount?.type ?? discount?.tag);
|
|
1699
|
-
const
|
|
1818
|
+
const fullCoveragePassType = discountTypes.find(type => ['entitlement_pass', 'good_pass'].includes(type));
|
|
1819
|
+
const extensionType = product?.extension_type || fullCoveragePassType || 'normal';
|
|
1700
1820
|
return {
|
|
1701
1821
|
product_id: product?.product_id ?? null,
|
|
1702
1822
|
product_variant_id: product?.product_variant_id ?? null,
|
|
@@ -2711,7 +2831,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2711
2831
|
}
|
|
2712
2832
|
isCustomerBoundDiscount(discount) {
|
|
2713
2833
|
const type = discount?.type ?? discount?.tag;
|
|
2714
|
-
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2834
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2715
2835
|
}
|
|
2716
2836
|
shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2717
2837
|
return Boolean(discount?.isScan || discount?.isEditMode);
|
|
@@ -3334,17 +3454,35 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3334
3454
|
}
|
|
3335
3455
|
normalizedIncoming.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedIncoming.discount_list);
|
|
3336
3456
|
const hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3457
|
+
const hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
|
|
3458
|
+
const isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
|
|
3459
|
+
const isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
|
|
3337
3460
|
const hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3338
3461
|
const hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
3339
3462
|
const hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3340
3463
|
const isIncomingCustomItem = productToAdd.metadata?.origin?.isCustomItem === true || productToAdd._origin?.isCustomItem === true;
|
|
3341
|
-
const shouldForceNewLine = disableMerge || !!booking ||
|
|
3342
|
-
const matchedIndex =
|
|
3464
|
+
const shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3465
|
+
const matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(item => {
|
|
3343
3466
|
if (this.hasGoodPassDiscount(item)) return false;
|
|
3344
|
-
|
|
3345
|
-
if (
|
|
3346
|
-
|
|
3347
|
-
|
|
3467
|
+
const isRuntimeEntitlementPass = this.isRuntimeEntitlementAppend(item, tempOrder);
|
|
3468
|
+
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
3469
|
+
return false;
|
|
3470
|
+
}
|
|
3471
|
+
if (isIncomingEntitlementAppend && this.isPersistedProductLine(item)) {
|
|
3472
|
+
return false;
|
|
3473
|
+
}
|
|
3474
|
+
const hasExistingProductNote = this.hasOrderProductLineNote(item);
|
|
3475
|
+
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
3476
|
+
return false;
|
|
3477
|
+
}
|
|
3478
|
+
const hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
3479
|
+
if (isRuntimeEntitlementPass && !this.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
3480
|
+
return false;
|
|
3481
|
+
}
|
|
3482
|
+
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
3483
|
+
return false;
|
|
3484
|
+
}
|
|
3485
|
+
if (this.isPersistedProductLine(item)) return false;
|
|
3348
3486
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3349
3487
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3350
3488
|
const existedFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(item), item.product_bundle);
|
|
@@ -3645,17 +3783,51 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3645
3783
|
});
|
|
3646
3784
|
return tempOrder.products;
|
|
3647
3785
|
}
|
|
3648
|
-
|
|
3649
|
-
const
|
|
3650
|
-
if (hasMainGoodPass) return true;
|
|
3651
|
-
const bundleDiscountList = [];
|
|
3786
|
+
getFullCoveragePassDiscounts(product) {
|
|
3787
|
+
const discountList = [...(product.discount_list || [])];
|
|
3652
3788
|
(product.product_bundle || []).forEach(item => {
|
|
3653
|
-
|
|
3789
|
+
discountList.push(...(item?.discount_list || []));
|
|
3654
3790
|
});
|
|
3655
3791
|
(product?._extend?.other?.bundle || []).forEach(item => {
|
|
3656
|
-
|
|
3792
|
+
discountList.push(...(item?.discount_list || []));
|
|
3657
3793
|
});
|
|
3658
|
-
return
|
|
3794
|
+
return discountList.filter(item => (0, _entitlementPass.isFullCoveragePass)(item));
|
|
3795
|
+
}
|
|
3796
|
+
hasEntitlementPassDiscount(product) {
|
|
3797
|
+
return this.getFullCoveragePassDiscounts(product).some(item => (0, _entitlementPass.isEntitlementPass)(item));
|
|
3798
|
+
}
|
|
3799
|
+
hasGoodPassDiscount(product) {
|
|
3800
|
+
return this.getFullCoveragePassDiscounts(product).some(item => !(0, _entitlementPass.isEntitlementPass)(item));
|
|
3801
|
+
}
|
|
3802
|
+
isPersistedProductLine(product) {
|
|
3803
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || product.metadata?.is_edit_for_runtime === true;
|
|
3804
|
+
}
|
|
3805
|
+
isRuntimeEntitlementAppend(product, tempOrder) {
|
|
3806
|
+
if (this.isPersistedProductLine(product)) return false;
|
|
3807
|
+
const uid = product.metadata?.unique_identification_number ?? product.unique_identification_number;
|
|
3808
|
+
const storedOrigin = uid !== undefined && uid !== null && uid !== '' ? tempOrder._extend?.productsByUid?.[String(uid)]?.origin : undefined;
|
|
3809
|
+
return Boolean(product?._origin?.__entitlementPassRuntimeAppend === true || storedOrigin?.__entitlementPassRuntimeAppend === true);
|
|
3810
|
+
}
|
|
3811
|
+
hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
3812
|
+
const buildPriceConfig = product => {
|
|
3813
|
+
const metadata = product.metadata || {};
|
|
3814
|
+
const bundle = (product.product_bundle || []).map(item => ({
|
|
3815
|
+
bundle_id: item.bundle_id ?? item.id ?? null,
|
|
3816
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id ?? item.product_id ?? null,
|
|
3817
|
+
bundle_variant_id: item.bundle_variant_id ?? item.product_variant_id ?? 0,
|
|
3818
|
+
price_type: item.price_type ?? item.custom_price_type ?? '',
|
|
3819
|
+
price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ''
|
|
3820
|
+
})).sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
3821
|
+
return JSON.stringify({
|
|
3822
|
+
original_price: this.normalizeFingerprintMoney(product.original_price),
|
|
3823
|
+
source_product_price: this.normalizeFingerprintMoney(metadata.source_product_price),
|
|
3824
|
+
main_product_original_price: this.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
3825
|
+
price_override: this.normalizeFingerprintMoney(metadata.price_override),
|
|
3826
|
+
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
3827
|
+
bundle
|
|
3828
|
+
});
|
|
3829
|
+
};
|
|
3830
|
+
return buildPriceConfig(incoming) === buildPriceConfig(existing);
|
|
3659
3831
|
}
|
|
3660
3832
|
getBundleRuntimeIdentity(bundle) {
|
|
3661
3833
|
if (!bundle || typeof bundle !== 'object') return '';
|
|
@@ -3893,7 +4065,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3893
4065
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
3894
4066
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
3895
4067
|
let normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(nextProduct, (0, _utils3.normalizeOrderProduct)(nextProduct)));
|
|
3896
|
-
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedProduct.discount_list);
|
|
4068
|
+
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
3897
4069
|
const preservedBookingUid = nextProduct.booking_uid || nextProduct.metadata?.booking_uid || targetProduct.booking_uid || targetProduct.metadata?.booking_uid;
|
|
3898
4070
|
if (!booking && preservedBookingUid) {
|
|
3899
4071
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
@@ -4018,6 +4190,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4018
4190
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
4019
4191
|
}
|
|
4020
4192
|
const targetProduct = tempOrder.products[productIndex];
|
|
4193
|
+
const isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
4021
4194
|
const normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils3.normalizeOrderProduct)({
|
|
4022
4195
|
...targetProduct,
|
|
4023
4196
|
num: (0, _utils3.getSafeProductNum)(num),
|
|
@@ -4026,7 +4199,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4026
4199
|
unique_identification_number: targetProduct.metadata?.unique_identification_number || unique_identification_number
|
|
4027
4200
|
}
|
|
4028
4201
|
}));
|
|
4029
|
-
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedProduct.discount_list);
|
|
4202
|
+
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
4030
4203
|
const settlementSnapshot = (0, _virtualSettlement.getSelectedSettlementSnapshot)(normalizedProduct);
|
|
4031
4204
|
if (this.isMultiCurrencySettlementEnabled() && settlementSnapshot?.settlement_type === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1) {
|
|
4032
4205
|
const currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -17,6 +17,7 @@ exports.normalizeOrderCollections = normalizeOrderCollections;
|
|
|
17
17
|
exports.repairDuplicateProductLineIdentities = repairDuplicateProductLineIdentities;
|
|
18
18
|
exports.setOrderCollectionUid = setOrderCollectionUid;
|
|
19
19
|
var _lodashEs = require("lodash-es");
|
|
20
|
+
var _entitlementPass = require("../../Discount/entitlementPass");
|
|
20
21
|
const IDENTITY_CONFIG = {
|
|
21
22
|
product: {
|
|
22
23
|
persistentIdField: 'order_detail_id',
|
|
@@ -81,20 +82,22 @@ function setOrderCollectionUid(kind, item, uid) {
|
|
|
81
82
|
delete record[uidField];
|
|
82
83
|
return record;
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
function getFullCoveragePassIdentity(product) {
|
|
86
|
+
const pass = (product.discount_list || []).find(item => (0, _entitlementPass.isFullCoveragePass)(item));
|
|
87
|
+
if (!pass) return null;
|
|
88
|
+
const resourceId = pass.discount?.resource_id ?? pass.resource_id ?? pass.discount_id ?? pass.id;
|
|
89
|
+
if (isBlankOrderCollectionIdentity(resourceId)) return null;
|
|
90
|
+
return {
|
|
91
|
+
type: String(pass.type || pass.tag),
|
|
92
|
+
resourceId: String(resourceId)
|
|
93
|
+
};
|
|
92
94
|
}
|
|
93
95
|
function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
|
|
94
96
|
const encodedOriginalUid = encodeURIComponent(originalUid);
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
97
|
+
const passIdentity = getFullCoveragePassIdentity(product);
|
|
98
|
+
if (passIdentity) {
|
|
99
|
+
const passType = passIdentity.type === 'good_pass' ? 'good-pass' : 'entitlement-pass';
|
|
100
|
+
return `os-split:product:${encodedOriginalUid}:${passType}:${encodeURIComponent(passIdentity.resourceId)}:${duplicateOrdinal}`;
|
|
98
101
|
}
|
|
99
102
|
return `os-split:product:${encodedOriginalUid}:duplicate:${duplicateOrdinal}`;
|
|
100
103
|
}
|
|
@@ -171,7 +171,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
|
171
171
|
* // => -4
|
|
172
172
|
*/
|
|
173
173
|
export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
|
|
174
|
-
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
174
|
+
export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
|
|
175
175
|
/**
|
|
176
176
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
177
177
|
* @param {CartItem} cartItem
|
|
@@ -129,6 +129,7 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
132
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
132
133
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
133
134
|
var _weighedProduct = require("./utils/weighedProduct");
|
|
134
135
|
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
@@ -137,6 +138,7 @@ var _utils2 = require("../../solution/ScanOrder/utils");
|
|
|
137
138
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
138
139
|
var _salesNotes = require("./salesNotes");
|
|
139
140
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
141
|
+
_dayjs.default.extend(_customParseFormat.default);
|
|
140
142
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
141
143
|
const VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
142
144
|
function isPlainObject(value) {
|
|
@@ -713,6 +715,24 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
713
715
|
}
|
|
714
716
|
return undefined;
|
|
715
717
|
}
|
|
718
|
+
function ensureSubmitDiscountIdentity(discount) {
|
|
719
|
+
if (!discount || typeof discount !== 'object' || Array.isArray(discount)) {
|
|
720
|
+
return discount;
|
|
721
|
+
}
|
|
722
|
+
const discountRecord = discount;
|
|
723
|
+
const metadata = discountRecord.metadata && typeof discountRecord.metadata === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
724
|
+
const uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
725
|
+
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
726
|
+
return discount;
|
|
727
|
+
}
|
|
728
|
+
return {
|
|
729
|
+
...discountRecord,
|
|
730
|
+
metadata: {
|
|
731
|
+
...metadata,
|
|
732
|
+
unique_identification_number: (0, _orderCollectionIdentity.createUuidV4)()
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
716
736
|
function collectSubmitProductDiscountList(product) {
|
|
717
737
|
const submitDiscountList = Array.isArray(product?.discount_list) ? [...product.discount_list] : [];
|
|
718
738
|
for (const bundle of product?.product_bundle || []) {
|
|
@@ -734,7 +754,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
734
754
|
});
|
|
735
755
|
}
|
|
736
756
|
}
|
|
737
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
757
|
+
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
738
758
|
}
|
|
739
759
|
|
|
740
760
|
/**
|
|
@@ -801,7 +821,23 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
801
821
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
802
822
|
return fromList + (originalPrice - finalPrice);
|
|
803
823
|
}
|
|
804
|
-
function createDefaultOrderRulesHooks() {
|
|
824
|
+
function createDefaultOrderRulesHooks(getBookings) {
|
|
825
|
+
const getProductStartDate = product => {
|
|
826
|
+
const productUid = String(product.metadata?.unique_identification_number ?? product.unique_identification_number ?? '');
|
|
827
|
+
const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
|
|
828
|
+
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
829
|
+
const bookings = getBookings?.() || [];
|
|
830
|
+
const booking = bookings.find(item => productUid && String(item?.product_uid ?? item?.metadata?.product_uid ?? '') === productUid) || bookings.find(item => bookingUid && String(item?.metadata?.unique_identification_number ?? item?.booking_uid ?? '') === bookingUid);
|
|
831
|
+
if (booking) {
|
|
832
|
+
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
833
|
+
return (0, _dayjs.default)(`${booking.start_date} ${booking.start_time}`, ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD H:mm', 'YYYY-MM-DD H:mm:ss'], true);
|
|
834
|
+
}
|
|
835
|
+
if (getBookings && (bookingUid || product.booking_id || product.metadata?.booking_id)) {
|
|
836
|
+
return (0, _dayjs.default)('');
|
|
837
|
+
}
|
|
838
|
+
const legacyStartDate = product.metadata?.start_date || product.metadata?.startDate;
|
|
839
|
+
return legacyStartDate ? (0, _dayjs.default)(legacyStartDate) : undefined;
|
|
840
|
+
};
|
|
805
841
|
const toUnitPriceString = (totalLike, num) => {
|
|
806
842
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
807
843
|
return new _decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
@@ -889,7 +925,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
889
925
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
890
926
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
891
927
|
holder_id: product.metadata?.holder_id,
|
|
892
|
-
startDate: product
|
|
928
|
+
startDate: getProductStartDate(product),
|
|
893
929
|
main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new _decimal.default(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
|
|
894
930
|
inPromotion: metadataAny._promotion?.inPromotion === true,
|
|
895
931
|
_promotion: metadataAny._promotion
|
|
@@ -412,6 +412,8 @@ export interface WalletAssetsBehaviorOptions {
|
|
|
412
412
|
export interface RefreshWalletAssetsOptions {
|
|
413
413
|
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
414
414
|
preserveSelection?: boolean;
|
|
415
|
+
/** 客户变化时,仅保留与本次扫码匹配的搜索结果;其他搜索缓存仍会清空。 */
|
|
416
|
+
retainSearchResultCodes?: string[];
|
|
415
417
|
}
|
|
416
418
|
export interface SelectWalletAssetOptions {
|
|
417
419
|
selected: boolean;
|
|
@@ -419,6 +421,8 @@ export interface SelectWalletAssetOptions {
|
|
|
419
421
|
}
|
|
420
422
|
export interface ScanWalletAssetResult {
|
|
421
423
|
type: SearchIdentificationCodeResult['type'];
|
|
424
|
+
/** walletCode 时保留完整 Wallet Detail,供客户解析与客户选择器使用。 */
|
|
425
|
+
data?: WalletDetailSearchData;
|
|
422
426
|
asset?: any;
|
|
423
427
|
selected: boolean;
|
|
424
428
|
state: WalletAssetsState;
|
|
@@ -864,6 +868,8 @@ export interface SearchIdentificationCodeParams extends WalletDeductionRecommend
|
|
|
864
868
|
* 搜索识别码响应数据
|
|
865
869
|
*/
|
|
866
870
|
export interface SearchIdentificationCodeResponse {
|
|
871
|
+
/** 业务是否成功 */
|
|
872
|
+
status?: boolean;
|
|
867
873
|
/** 响应状态码 */
|
|
868
874
|
code?: number;
|
|
869
875
|
/** 响应消息 */
|
|
@@ -871,12 +877,26 @@ export interface SearchIdentificationCodeResponse {
|
|
|
871
877
|
/** 响应数据 */
|
|
872
878
|
data?: SearchIdentificationCodeItem[];
|
|
873
879
|
}
|
|
880
|
+
/** Wallet code 精确搜索返回的 Wallet Detail。 */
|
|
881
|
+
export interface WalletDetailSearchData {
|
|
882
|
+
id?: string | number;
|
|
883
|
+
customer_id?: string | number;
|
|
884
|
+
customer?: Record<string, any> | null;
|
|
885
|
+
is_cross_shop_wallet?: boolean | 0 | 1;
|
|
886
|
+
[key: string]: any;
|
|
887
|
+
}
|
|
888
|
+
export interface WalletDetailSearchResponse {
|
|
889
|
+
status?: boolean;
|
|
890
|
+
code?: number;
|
|
891
|
+
message?: string;
|
|
892
|
+
data?: WalletDetailSearchData | null;
|
|
893
|
+
}
|
|
874
894
|
/**
|
|
875
895
|
* 搜索识别码结果类型
|
|
876
896
|
*/
|
|
877
897
|
export type SearchIdentificationCodeResult = {
|
|
878
898
|
type: 'walletCode';
|
|
879
|
-
data:
|
|
899
|
+
data: WalletDetailSearchData;
|
|
880
900
|
} | {
|
|
881
901
|
type: 'normalCode';
|
|
882
902
|
data: SearchIdentificationCodeItem[];
|
|
@@ -96,7 +96,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
96
96
|
* 搜索识别码信息
|
|
97
97
|
* 通过识别码搜索相关的钱包通行证信息
|
|
98
98
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
99
|
-
*
|
|
99
|
+
* 特殊逻辑:WL 或指定 200 格式的 Wallet Code 调用 /wallet/detail/search 接口。
|
|
100
100
|
*/
|
|
101
101
|
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
102
102
|
noCache?: boolean;
|