@pisell/pisellos 2.3.123 → 2.3.124
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/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 +7 -1
- package/dist/modules/Order/index.js +437 -229
- 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/BookingByStep/index.d.ts +1 -1
- 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 +7 -1
- 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/BookingByStep/index.d.ts +1 -1
- 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
|
@@ -9,6 +9,7 @@ var _types = require("./types");
|
|
|
9
9
|
var _utils = require("./utils");
|
|
10
10
|
var _utils2 = require("../Product/utils");
|
|
11
11
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
12
|
+
var _availability = require("../Discount/availability");
|
|
12
13
|
var _osPrivatePayload = require("../../utils/os-private-payload");
|
|
13
14
|
var _salesNotes = require("./salesNotes");
|
|
14
15
|
var _paymentUtils = require("./payment-utils");
|
|
@@ -22,6 +23,7 @@ var _discountProductLineIdentity = require("./utils/discountProductLineIdentity"
|
|
|
22
23
|
var _virtualSettlement = require("./utils/virtualSettlement");
|
|
23
24
|
var _Discount = require("../Discount");
|
|
24
25
|
var _Rules = require("../Rules");
|
|
26
|
+
var _entitlementPass = require("../Discount/entitlementPass");
|
|
25
27
|
var _types2 = require("../Rules/types");
|
|
26
28
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
27
29
|
var _lodashEs = require("lodash-es");
|
|
@@ -41,9 +43,27 @@ function isSameDiscountList(left, right) {
|
|
|
41
43
|
function isManualProductDiscountProduct(product) {
|
|
42
44
|
return (0, _manualProductDiscount.hasManualProductDiscountFlag)(product?.metadata) || (product?.discount_list || []).some(item => item?.type === 'product');
|
|
43
45
|
}
|
|
46
|
+
function syncReducedEntitlementPassUsageCount(discountList, previousQuantity, nextQuantity) {
|
|
47
|
+
if (!Array.isArray(discountList)) return discountList;
|
|
48
|
+
const previousCount = (0, _utils3.getSafeProductNum)(previousQuantity);
|
|
49
|
+
const nextCount = (0, _utils3.getSafeProductNum)(nextQuantity);
|
|
50
|
+
if (nextCount >= previousCount) return discountList;
|
|
51
|
+
return discountList.map(discount => {
|
|
52
|
+
if (!(0, _entitlementPass.isEntitlementPass)(discount)) return discount;
|
|
53
|
+
const rawUsageCount = Number(discount?.metadata?.num ?? previousCount);
|
|
54
|
+
const usageCount = Number.isFinite(rawUsageCount) ? Math.max(Math.floor(rawUsageCount), 0) : previousCount;
|
|
55
|
+
return {
|
|
56
|
+
...discount,
|
|
57
|
+
metadata: {
|
|
58
|
+
...(discount?.metadata || {}),
|
|
59
|
+
num: Math.min(usageCount, nextCount)
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
44
64
|
const ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
45
65
|
const ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
46
|
-
const CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
66
|
+
const CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['entitlement_pass', 'good_pass', 'product_discount_card', 'discount_card']);
|
|
47
67
|
function isCustomerPromotionDiscount(discount) {
|
|
48
68
|
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String(discount?.tag || discount?.type || '').toLowerCase());
|
|
49
69
|
}
|
|
@@ -73,6 +93,28 @@ function getVoucherPaymentLifecycleKey(payment) {
|
|
|
73
93
|
if (!isVoucherPaymentRecord(payment)) return null;
|
|
74
94
|
return `${String(payment.voucher_id)}::${String(payment.status || '')}`;
|
|
75
95
|
}
|
|
96
|
+
function getDiscountIdentityKey(discount) {
|
|
97
|
+
const id = discount?.id;
|
|
98
|
+
if (id === undefined || id === null || id === '') return null;
|
|
99
|
+
return String(id);
|
|
100
|
+
}
|
|
101
|
+
function mergeCommittedEntitlementWithRuntime(committed, runtime) {
|
|
102
|
+
const committedAppliedProductDetails = committed.committedAppliedProductDetails?.length ? committed.committedAppliedProductDetails : committed.appliedProductDetails || [];
|
|
103
|
+
return {
|
|
104
|
+
...committed,
|
|
105
|
+
...runtime,
|
|
106
|
+
id: runtime.id ?? committed.id,
|
|
107
|
+
tag: runtime.tag || committed.tag,
|
|
108
|
+
type: runtime.type || committed.type,
|
|
109
|
+
isEditMode: false,
|
|
110
|
+
isDisabled: runtime.isDisabled ?? false,
|
|
111
|
+
isSelected: runtime.isSelected ?? committed.isSelected,
|
|
112
|
+
isUsed: committed.isUsed || runtime.isUsed,
|
|
113
|
+
committedAppliedProductDetails: [...committedAppliedProductDetails],
|
|
114
|
+
applicableProductDetails: [...(committed.applicableProductDetails || []), ...(runtime.applicableProductDetails || [])],
|
|
115
|
+
appliedProductDetails: [...committedAppliedProductDetails, ...(runtime.appliedProductDetails || [])]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
76
118
|
class OrderModule extends _BaseModule.BaseModule {
|
|
77
119
|
defaultName = 'order';
|
|
78
120
|
defaultVersion = '1.0.0';
|
|
@@ -126,6 +168,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
126
168
|
const key = Number.isFinite(id) ? id : String(resourceId);
|
|
127
169
|
const title = item?.discount?.title ?? {};
|
|
128
170
|
const amount = Number(item?.amount || 0);
|
|
171
|
+
const encoded = item?.metadata?.encoded || item?.encoded || item?.discount?.encoded || '';
|
|
129
172
|
const discountCardType = item?.discount?.discount_card_type;
|
|
130
173
|
const parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? item?.discount?.fixed_amount ?? item?.amount : item?.discount?.percent : '0';
|
|
131
174
|
const detail = {
|
|
@@ -136,11 +179,21 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
136
179
|
original_amount: String(item?.discount?.original_amount ?? item?.amount ?? '0'),
|
|
137
180
|
num: Number(item?.metadata?.num ?? product?.num ?? product?.product_quantity ?? 1) || 1,
|
|
138
181
|
metadata: item?.metadata,
|
|
139
|
-
discount:
|
|
182
|
+
discount: {
|
|
183
|
+
...(item?.discount || {}),
|
|
184
|
+
product_id: item?.discount?.product_id ?? product?.product_id
|
|
185
|
+
},
|
|
140
186
|
_num: Number(item?.metadata?.num ?? product?.num ?? product?.product_quantity ?? 1) || 1
|
|
141
187
|
};
|
|
142
188
|
const existed = discountMap.get(key);
|
|
143
189
|
if (existed) {
|
|
190
|
+
if (!existed.encoded && encoded) {
|
|
191
|
+
existed.encoded = encoded;
|
|
192
|
+
existed.metadata = {
|
|
193
|
+
...existed.metadata,
|
|
194
|
+
encoded
|
|
195
|
+
};
|
|
196
|
+
}
|
|
144
197
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
145
198
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
146
199
|
if (!isDiscountCard) {
|
|
@@ -160,8 +213,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
160
213
|
discountMap.set(key, {
|
|
161
214
|
id: key,
|
|
162
215
|
product_name: '',
|
|
163
|
-
encoded
|
|
164
|
-
code: '',
|
|
216
|
+
encoded,
|
|
217
|
+
code: item?.code || item?.discount?.code || '',
|
|
218
|
+
metadata: {
|
|
219
|
+
encoded
|
|
220
|
+
},
|
|
165
221
|
tag: type,
|
|
166
222
|
product_id: item?.discount?.discount_product_id ?? product?.product_id ?? 0,
|
|
167
223
|
relation_type: '',
|
|
@@ -452,7 +508,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
452
508
|
this.store.rules = rules;
|
|
453
509
|
}
|
|
454
510
|
createDefaultRulesHooks() {
|
|
455
|
-
return (0, _utils.createDefaultOrderRulesHooks)();
|
|
511
|
+
return (0, _utils.createDefaultOrderRulesHooks)(() => this.store.tempOrder?.bookings || []);
|
|
456
512
|
}
|
|
457
513
|
|
|
458
514
|
/**
|
|
@@ -478,6 +534,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
478
534
|
with_wallet_pass_holder: 1,
|
|
479
535
|
with_available_wallet_flag: 1,
|
|
480
536
|
with_available_wallet_pass_flag: 1,
|
|
537
|
+
with_entitlement_pass: 1,
|
|
538
|
+
filter_order_wallet_pass_usage: 0,
|
|
481
539
|
with_virtual_currency: 1,
|
|
482
540
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
483
541
|
...(orderId ? {
|
|
@@ -499,17 +557,61 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
499
557
|
}
|
|
500
558
|
if (discountList) {
|
|
501
559
|
const currentDiscountList = this.store.discount?.getDiscountList() || [];
|
|
502
|
-
const
|
|
560
|
+
const currentCommittedDiscounts = currentDiscountList.filter(discount => discount?.isEditMode || discount?.committedAppliedProductDetails?.length);
|
|
503
561
|
const currentScanDiscounts = currentDiscountList.filter(discount => discount?.isScan);
|
|
504
|
-
const
|
|
562
|
+
const currentScanDiscountById = new Map(currentScanDiscounts.flatMap(discount => {
|
|
563
|
+
const id = getDiscountIdentityKey(discount);
|
|
564
|
+
return id === null ? [] : [[id, discount]];
|
|
565
|
+
}));
|
|
566
|
+
const committedDiscountById = new Map(currentCommittedDiscounts.flatMap(discount => {
|
|
567
|
+
const id = getDiscountIdentityKey(discount);
|
|
568
|
+
return id === null ? [] : [[id, discount]];
|
|
569
|
+
}));
|
|
570
|
+
const mergedCommittedDiscountIds = new Set();
|
|
571
|
+
const refreshedScanDiscountIds = new Set();
|
|
505
572
|
const runtimeDiscountIds = new Set();
|
|
506
|
-
const runtimeDiscounts = discountList.
|
|
507
|
-
|
|
508
|
-
if (
|
|
509
|
-
runtimeDiscountIds.
|
|
510
|
-
|
|
573
|
+
const runtimeDiscounts = discountList.flatMap(discount => {
|
|
574
|
+
const id = getDiscountIdentityKey(discount);
|
|
575
|
+
if (id === null) return [discount];
|
|
576
|
+
if (runtimeDiscountIds.has(id)) return [];
|
|
577
|
+
runtimeDiscountIds.add(id);
|
|
578
|
+
const currentScanDiscount = currentScanDiscountById.get(id);
|
|
579
|
+
if (currentScanDiscount && (!(0, _entitlementPass.isEntitlementPass)(currentScanDiscount) || !(0, _entitlementPass.isEntitlementPass)(discount))) {
|
|
580
|
+
return [];
|
|
581
|
+
}
|
|
582
|
+
const committedDiscount = committedDiscountById.get(id);
|
|
583
|
+
let nextDiscount = discount;
|
|
584
|
+
if (committedDiscount && (0, _entitlementPass.isEntitlementPass)(committedDiscount) && (0, _entitlementPass.isEntitlementPass)(discount)) {
|
|
585
|
+
mergedCommittedDiscountIds.add(id);
|
|
586
|
+
nextDiscount = mergeCommittedEntitlementWithRuntime(committedDiscount, discount);
|
|
587
|
+
}
|
|
588
|
+
if (currentScanDiscount) {
|
|
589
|
+
refreshedScanDiscountIds.add(id);
|
|
590
|
+
nextDiscount = {
|
|
591
|
+
...nextDiscount,
|
|
592
|
+
isScan: true,
|
|
593
|
+
isSelected: currentScanDiscount.isSelected ?? nextDiscount.isSelected,
|
|
594
|
+
isManualSelect: currentScanDiscount.isManualSelect ?? nextDiscount.isManualSelect
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
return [nextDiscount];
|
|
598
|
+
});
|
|
599
|
+
const retainedCommittedDiscounts = currentCommittedDiscounts.filter(discount => {
|
|
600
|
+
const id = getDiscountIdentityKey(discount);
|
|
601
|
+
return id === null || !mergedCommittedDiscountIds.has(id);
|
|
602
|
+
}).map(discount => discount.committedAppliedProductDetails?.length ? {
|
|
603
|
+
...discount,
|
|
604
|
+
isEditMode: true,
|
|
605
|
+
isDisabled: true,
|
|
606
|
+
isSelected: true,
|
|
607
|
+
isUsed: true,
|
|
608
|
+
appliedProductDetails: [...discount.committedAppliedProductDetails]
|
|
609
|
+
} : discount);
|
|
610
|
+
const retainedScanDiscounts = currentScanDiscounts.filter(discount => {
|
|
611
|
+
const id = getDiscountIdentityKey(discount);
|
|
612
|
+
return id === null || !refreshedScanDiscountIds.has(id);
|
|
511
613
|
});
|
|
512
|
-
const mergedDiscountList = [...
|
|
614
|
+
const mergedDiscountList = [...retainedCommittedDiscounts, ...retainedScanDiscounts, ...runtimeDiscounts];
|
|
513
615
|
if (!isCurrentRequest()) return this.getDiscountList();
|
|
514
616
|
await this.store.discount?.setOriginalDiscountList(mergedDiscountList);
|
|
515
617
|
if (!isCurrentRequest()) return this.getDiscountList();
|
|
@@ -630,19 +732,34 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
630
732
|
isAvailable: false,
|
|
631
733
|
discountList: this.getDiscountList()
|
|
632
734
|
};
|
|
633
|
-
const
|
|
735
|
+
const scannedIds = new Set(withScanList.map(discount => String(discount.id)));
|
|
736
|
+
const evaluatedScannedDiscounts = (evaluatedDiscountList || withScanList).filter(discount => scannedIds.has(String(discount.id)) && isCustomerPromotionDiscount(discount) && !(0, _availability.getDiscountLifecycleReason)(discount));
|
|
737
|
+
const shouldRetainForLater = !isAvailable && evaluatedScannedDiscounts.length > 0;
|
|
634
738
|
const normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
635
|
-
const retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
636
739
|
let resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
637
740
|
if (isAvailable && normalizedNewDiscountList) {
|
|
638
741
|
await this.store.discount?.setDiscountList(normalizedNewDiscountList);
|
|
639
|
-
|
|
742
|
+
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
743
|
+
this.applyDiscount({
|
|
744
|
+
preferredEntitlementPassIds: withScanList.filter(discount => (0, _entitlementPass.isEntitlementPass)(discount)).map(discount => discount.id)
|
|
745
|
+
});
|
|
640
746
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
641
747
|
resolvedDiscountList = this.getDiscountList();
|
|
642
|
-
} else if (shouldRetainForLater
|
|
643
|
-
//
|
|
644
|
-
|
|
645
|
-
|
|
748
|
+
} else if (shouldRetainForLater) {
|
|
749
|
+
// 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
|
|
750
|
+
const retainedDiscounts = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
|
|
751
|
+
evaluatedScannedDiscounts.forEach(discount => {
|
|
752
|
+
retainedDiscounts.set(String(discount.id), {
|
|
753
|
+
...discount,
|
|
754
|
+
isScan: true,
|
|
755
|
+
isAvailable: false,
|
|
756
|
+
isSelected: false,
|
|
757
|
+
reasonCode: discount.reasonCode || 'product_not_applicable',
|
|
758
|
+
appliedProductDetails: [],
|
|
759
|
+
savedAmount: 0
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
await this.store.discount?.setDiscountList([...retainedDiscounts.values()]);
|
|
646
763
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
647
764
|
resolvedDiscountList = this.getDiscountList();
|
|
648
765
|
}
|
|
@@ -651,7 +768,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
651
768
|
isAvailable: isAvailable || false,
|
|
652
769
|
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
653
770
|
discountList: resolvedDiscountList,
|
|
654
|
-
scannedDiscountList:
|
|
771
|
+
scannedDiscountList: evaluatedScannedDiscounts,
|
|
655
772
|
unavailableReason
|
|
656
773
|
};
|
|
657
774
|
}
|
|
@@ -683,7 +800,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
683
800
|
isFormSubject: product => (0, _utils.resolveIsFormSubject)(tempOrder, product),
|
|
684
801
|
orderTotalAmount: Number(this.store.summary?.total_amount || 0)
|
|
685
802
|
}, {
|
|
686
|
-
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids
|
|
803
|
+
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
804
|
+
preferredEntitlementPassIds: options?.preferredEntitlementPassIds
|
|
687
805
|
});
|
|
688
806
|
if (result?.productList) {
|
|
689
807
|
const previousProductsByUid = (0, _utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -1576,7 +1694,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1576
1694
|
const sku = product?.product_sku || {};
|
|
1577
1695
|
const metadata = product?.metadata || {};
|
|
1578
1696
|
const discountTypes = (product?.discount_list || []).map(discount => discount?.type ?? discount?.tag);
|
|
1579
|
-
const
|
|
1697
|
+
const fullCoveragePassType = discountTypes.find(type => ['entitlement_pass', 'good_pass'].includes(type));
|
|
1698
|
+
const extensionType = product?.extension_type || fullCoveragePassType || 'normal';
|
|
1580
1699
|
return {
|
|
1581
1700
|
product_id: product?.product_id ?? null,
|
|
1582
1701
|
product_variant_id: product?.product_variant_id ?? null,
|
|
@@ -1629,7 +1748,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1629
1748
|
const sku = product?.product_sku || {};
|
|
1630
1749
|
const metadata = product?.metadata || {};
|
|
1631
1750
|
const discountTypes = (product?.discount_list || []).map(discount => discount?.type ?? discount?.tag);
|
|
1632
|
-
const
|
|
1751
|
+
const fullCoveragePassType = discountTypes.find(type => ['entitlement_pass', 'good_pass'].includes(type));
|
|
1752
|
+
const extensionType = product?.extension_type || fullCoveragePassType || 'normal';
|
|
1633
1753
|
return {
|
|
1634
1754
|
product_id: product?.product_id ?? null,
|
|
1635
1755
|
product_variant_id: product?.product_variant_id ?? null,
|
|
@@ -2644,7 +2764,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2644
2764
|
}
|
|
2645
2765
|
isCustomerBoundDiscount(discount) {
|
|
2646
2766
|
const type = discount?.type ?? discount?.tag;
|
|
2647
|
-
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2767
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2648
2768
|
}
|
|
2649
2769
|
shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2650
2770
|
return Boolean(discount?.isScan || discount?.isEditMode);
|
|
@@ -3267,17 +3387,35 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3267
3387
|
}
|
|
3268
3388
|
normalizedIncoming.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedIncoming.discount_list);
|
|
3269
3389
|
const hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3390
|
+
const hasIncomingEntitlementPass = this.hasEntitlementPassDiscount(normalizedIncoming);
|
|
3391
|
+
const isIncomingEntitlementAppend = this.isRuntimeEntitlementAppend(productToAdd, tempOrder);
|
|
3392
|
+
const isIncomingPersistedEntitlementPass = hasIncomingEntitlementPass && this.isPersistedProductLine(normalizedIncoming);
|
|
3270
3393
|
const hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3271
3394
|
const hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
3272
3395
|
const hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3273
3396
|
const isIncomingCustomItem = productToAdd.metadata?.origin?.isCustomItem === true || productToAdd._origin?.isCustomItem === true;
|
|
3274
|
-
const shouldForceNewLine = disableMerge || !!booking ||
|
|
3275
|
-
const matchedIndex =
|
|
3397
|
+
const shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3398
|
+
const matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(item => {
|
|
3276
3399
|
if (this.hasGoodPassDiscount(item)) return false;
|
|
3277
|
-
|
|
3278
|
-
if (
|
|
3279
|
-
|
|
3280
|
-
|
|
3400
|
+
const isRuntimeEntitlementPass = this.isRuntimeEntitlementAppend(item, tempOrder);
|
|
3401
|
+
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
3402
|
+
return false;
|
|
3403
|
+
}
|
|
3404
|
+
if (isIncomingEntitlementAppend && this.isPersistedProductLine(item)) {
|
|
3405
|
+
return false;
|
|
3406
|
+
}
|
|
3407
|
+
const hasExistingProductNote = this.hasOrderProductLineNote(item);
|
|
3408
|
+
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
3409
|
+
return false;
|
|
3410
|
+
}
|
|
3411
|
+
const hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
3412
|
+
if (isRuntimeEntitlementPass && !this.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
3413
|
+
return false;
|
|
3414
|
+
}
|
|
3415
|
+
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
3416
|
+
return false;
|
|
3417
|
+
}
|
|
3418
|
+
if (this.isPersistedProductLine(item)) return false;
|
|
3281
3419
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3282
3420
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3283
3421
|
const existedFingerprint = (0, _utils3.buildProductLineFingerprint)((0, _utils.getProductSkuOptions)(item), item.product_bundle);
|
|
@@ -3578,17 +3716,51 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3578
3716
|
});
|
|
3579
3717
|
return tempOrder.products;
|
|
3580
3718
|
}
|
|
3581
|
-
|
|
3582
|
-
const
|
|
3583
|
-
if (hasMainGoodPass) return true;
|
|
3584
|
-
const bundleDiscountList = [];
|
|
3719
|
+
getFullCoveragePassDiscounts(product) {
|
|
3720
|
+
const discountList = [...(product.discount_list || [])];
|
|
3585
3721
|
(product.product_bundle || []).forEach(item => {
|
|
3586
|
-
|
|
3722
|
+
discountList.push(...(item?.discount_list || []));
|
|
3587
3723
|
});
|
|
3588
3724
|
(product?._extend?.other?.bundle || []).forEach(item => {
|
|
3589
|
-
|
|
3725
|
+
discountList.push(...(item?.discount_list || []));
|
|
3590
3726
|
});
|
|
3591
|
-
return
|
|
3727
|
+
return discountList.filter(item => (0, _entitlementPass.isFullCoveragePass)(item));
|
|
3728
|
+
}
|
|
3729
|
+
hasEntitlementPassDiscount(product) {
|
|
3730
|
+
return this.getFullCoveragePassDiscounts(product).some(item => (0, _entitlementPass.isEntitlementPass)(item));
|
|
3731
|
+
}
|
|
3732
|
+
hasGoodPassDiscount(product) {
|
|
3733
|
+
return this.getFullCoveragePassDiscounts(product).some(item => !(0, _entitlementPass.isEntitlementPass)(item));
|
|
3734
|
+
}
|
|
3735
|
+
isPersistedProductLine(product) {
|
|
3736
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || product.metadata?.is_edit_for_runtime === true;
|
|
3737
|
+
}
|
|
3738
|
+
isRuntimeEntitlementAppend(product, tempOrder) {
|
|
3739
|
+
if (this.isPersistedProductLine(product)) return false;
|
|
3740
|
+
const uid = product.metadata?.unique_identification_number ?? product.unique_identification_number;
|
|
3741
|
+
const storedOrigin = uid !== undefined && uid !== null && uid !== '' ? tempOrder._extend?.productsByUid?.[String(uid)]?.origin : undefined;
|
|
3742
|
+
return Boolean(product?._origin?.__entitlementPassRuntimeAppend === true || storedOrigin?.__entitlementPassRuntimeAppend === true);
|
|
3743
|
+
}
|
|
3744
|
+
hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
3745
|
+
const buildPriceConfig = product => {
|
|
3746
|
+
const metadata = product.metadata || {};
|
|
3747
|
+
const bundle = (product.product_bundle || []).map(item => ({
|
|
3748
|
+
bundle_id: item.bundle_id ?? item.id ?? null,
|
|
3749
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id ?? item.product_id ?? null,
|
|
3750
|
+
bundle_variant_id: item.bundle_variant_id ?? item.product_variant_id ?? 0,
|
|
3751
|
+
price_type: item.price_type ?? item.custom_price_type ?? '',
|
|
3752
|
+
price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ''
|
|
3753
|
+
})).sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
3754
|
+
return JSON.stringify({
|
|
3755
|
+
original_price: this.normalizeFingerprintMoney(product.original_price),
|
|
3756
|
+
source_product_price: this.normalizeFingerprintMoney(metadata.source_product_price),
|
|
3757
|
+
main_product_original_price: this.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
3758
|
+
price_override: this.normalizeFingerprintMoney(metadata.price_override),
|
|
3759
|
+
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
3760
|
+
bundle
|
|
3761
|
+
});
|
|
3762
|
+
};
|
|
3763
|
+
return buildPriceConfig(incoming) === buildPriceConfig(existing);
|
|
3592
3764
|
}
|
|
3593
3765
|
getBundleRuntimeIdentity(bundle) {
|
|
3594
3766
|
if (!bundle || typeof bundle !== 'object') return '';
|
|
@@ -3777,7 +3949,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3777
3949
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
3778
3950
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
3779
3951
|
let normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils.mergeOrderProductDisplayFields)(nextProduct, (0, _utils3.normalizeOrderProduct)(nextProduct)));
|
|
3780
|
-
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedProduct.discount_list);
|
|
3952
|
+
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
3781
3953
|
const preservedBookingUid = nextProduct.booking_uid || nextProduct.metadata?.booking_uid || targetProduct.booking_uid || targetProduct.metadata?.booking_uid;
|
|
3782
3954
|
if (!booking && preservedBookingUid) {
|
|
3783
3955
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
@@ -3894,6 +4066,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3894
4066
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
3895
4067
|
}
|
|
3896
4068
|
const targetProduct = tempOrder.products[productIndex];
|
|
4069
|
+
const isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3897
4070
|
const normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled((0, _utils3.normalizeOrderProduct)({
|
|
3898
4071
|
...targetProduct,
|
|
3899
4072
|
num: (0, _utils3.getSafeProductNum)(num),
|
|
@@ -3902,7 +4075,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3902
4075
|
unique_identification_number: targetProduct.metadata?.unique_identification_number || unique_identification_number
|
|
3903
4076
|
}
|
|
3904
4077
|
}));
|
|
3905
|
-
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(normalizedProduct.discount_list);
|
|
4078
|
+
normalizedProduct.discount_list = (0, _utils.normalizeOrderProductDiscountList)(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
3906
4079
|
const settlementSnapshot = (0, _virtualSettlement.getSelectedSettlementSnapshot)(normalizedProduct);
|
|
3907
4080
|
if (this.isMultiCurrencySettlementEnabled() && settlementSnapshot?.settlement_type === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1) {
|
|
3908
4081
|
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
|
}
|
|
@@ -161,7 +161,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
|
161
161
|
* // => -4
|
|
162
162
|
*/
|
|
163
163
|
export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
|
|
164
|
-
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
164
|
+
export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
|
|
165
165
|
/**
|
|
166
166
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
167
167
|
* @param {CartItem} cartItem
|
|
@@ -127,6 +127,7 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
130
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
130
131
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
131
132
|
var _utils = require("../Holder/utils");
|
|
132
133
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
@@ -134,6 +135,7 @@ var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
|
134
135
|
var _salesNotes = require("./salesNotes");
|
|
135
136
|
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
136
137
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
138
|
+
_dayjs.default.extend(_customParseFormat.default);
|
|
137
139
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
138
140
|
const VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
139
141
|
function isPlainObject(value) {
|
|
@@ -670,6 +672,24 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
670
672
|
}
|
|
671
673
|
return undefined;
|
|
672
674
|
}
|
|
675
|
+
function ensureSubmitDiscountIdentity(discount) {
|
|
676
|
+
if (!discount || typeof discount !== 'object' || Array.isArray(discount)) {
|
|
677
|
+
return discount;
|
|
678
|
+
}
|
|
679
|
+
const discountRecord = discount;
|
|
680
|
+
const metadata = discountRecord.metadata && typeof discountRecord.metadata === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
681
|
+
const uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
682
|
+
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
683
|
+
return discount;
|
|
684
|
+
}
|
|
685
|
+
return {
|
|
686
|
+
...discountRecord,
|
|
687
|
+
metadata: {
|
|
688
|
+
...metadata,
|
|
689
|
+
unique_identification_number: (0, _orderCollectionIdentity.createUuidV4)()
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
673
693
|
function collectSubmitProductDiscountList(product) {
|
|
674
694
|
const submitDiscountList = Array.isArray(product?.discount_list) ? [...product.discount_list] : [];
|
|
675
695
|
for (const bundle of product?.product_bundle || []) {
|
|
@@ -691,7 +711,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
691
711
|
});
|
|
692
712
|
}
|
|
693
713
|
}
|
|
694
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
714
|
+
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
695
715
|
}
|
|
696
716
|
|
|
697
717
|
/**
|
|
@@ -758,7 +778,23 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
758
778
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
759
779
|
return fromList + (originalPrice - finalPrice);
|
|
760
780
|
}
|
|
761
|
-
function createDefaultOrderRulesHooks() {
|
|
781
|
+
function createDefaultOrderRulesHooks(getBookings) {
|
|
782
|
+
const getProductStartDate = product => {
|
|
783
|
+
const productUid = String(product.metadata?.unique_identification_number ?? product.unique_identification_number ?? '');
|
|
784
|
+
const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
|
|
785
|
+
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
786
|
+
const bookings = getBookings?.() || [];
|
|
787
|
+
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);
|
|
788
|
+
if (booking) {
|
|
789
|
+
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
790
|
+
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);
|
|
791
|
+
}
|
|
792
|
+
if (getBookings && (bookingUid || product.booking_id || product.metadata?.booking_id)) {
|
|
793
|
+
return (0, _dayjs.default)('');
|
|
794
|
+
}
|
|
795
|
+
const legacyStartDate = product.metadata?.start_date || product.metadata?.startDate;
|
|
796
|
+
return legacyStartDate ? (0, _dayjs.default)(legacyStartDate) : undefined;
|
|
797
|
+
};
|
|
762
798
|
const toUnitPriceString = (totalLike, num) => {
|
|
763
799
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
764
800
|
return new _decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
@@ -846,7 +882,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
846
882
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
847
883
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
848
884
|
holder_id: product.metadata?.holder_id,
|
|
849
|
-
startDate: product
|
|
885
|
+
startDate: getProductStartDate(product),
|
|
850
886
|
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,
|
|
851
887
|
inPromotion: metadataAny._promotion?.inPromotion === true,
|
|
852
888
|
_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;
|