@pisell/pisellos 2.3.127 → 2.3.128
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 +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
- package/dist/modules/Customer/index.js +3 -6
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +151 -37
- package/dist/modules/Discount/types.d.ts +5 -36
- package/dist/modules/Order/index.d.ts +2 -7
- package/dist/modules/Order/index.js +331 -480
- package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +65 -104
- package/dist/modules/Payment/types.d.ts +1 -21
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +47 -80
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +190 -482
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -3
- package/dist/solution/BaseSales/index.js +77 -44
- package/dist/solution/BaseSales/types.d.ts +7 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -2
- package/dist/solution/BookingTicket/index.js +63 -60
- package/dist/solution/BookingTicket/types.d.ts +1 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +42 -99
- package/dist/solution/ShopDiscount/utils.d.ts +2 -4
- package/dist/solution/ShopDiscount/utils.js +23 -43
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
- package/lib/modules/Customer/index.js +1 -5
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +129 -23
- package/lib/modules/Discount/types.d.ts +5 -36
- package/lib/modules/Order/index.d.ts +2 -7
- package/lib/modules/Order/index.js +109 -222
- package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +6 -41
- package/lib/modules/Payment/types.d.ts +1 -21
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +9 -29
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +114 -359
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -3
- package/lib/solution/BaseSales/index.js +17 -11
- package/lib/solution/BaseSales/types.d.ts +7 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -2
- package/lib/solution/BookingTicket/index.js +33 -36
- package/lib/solution/BookingTicket/types.d.ts +1 -5
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/utils.d.ts +2 -4
- package/lib/solution/ShopDiscount/utils.js +25 -42
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -49
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -43
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -141
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getWeighedProductPriceFingerprint = getWeighedProductPriceFingerprint;
|
|
7
|
+
exports.resolveWeighedSourcePrice = resolveWeighedSourcePrice;
|
|
8
|
+
exports.withOriginalBundleOptionPrices = withOriginalBundleOptionPrices;
|
|
9
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const UNIT_GRAMS = {
|
|
12
|
+
kg: '1000',
|
|
13
|
+
KILOGRAMS: '1000',
|
|
14
|
+
g: '1',
|
|
15
|
+
GRAMS: '1',
|
|
16
|
+
lb: '453.59237',
|
|
17
|
+
POUNDS: '453.59237',
|
|
18
|
+
oz: '28.349523125',
|
|
19
|
+
OUNCES: '28.349523125'
|
|
20
|
+
};
|
|
21
|
+
function nonNegative(value) {
|
|
22
|
+
if (value === null || value === undefined || value === '') return undefined;
|
|
23
|
+
try {
|
|
24
|
+
const result = new _decimal.default(value);
|
|
25
|
+
return result.isFinite() && result.gte(0) ? result : undefined;
|
|
26
|
+
} catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function numericKey(value) {
|
|
31
|
+
return nonNegative(value)?.toString();
|
|
32
|
+
}
|
|
33
|
+
function unitKey(value) {
|
|
34
|
+
return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
|
|
35
|
+
}
|
|
36
|
+
function snapshotKey(snapshot) {
|
|
37
|
+
return [numericKey(snapshot?.price), unitKey(snapshot?.unit), numericKey(snapshot?.unit_value ?? 1)];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
41
|
+
function getWeighedProductPriceFingerprint(sku) {
|
|
42
|
+
if (Number(sku?.open_sold_weight) !== 1) return 'unweighed';
|
|
43
|
+
return JSON.stringify([1, numericKey(sku?.net_weight), unitKey(sku?.unit), numericKey(sku?.unit_price), numericKey(sku?.unit_weight ?? 1), snapshotKey(sku?.unit_data_snapshot)]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
48
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
49
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
50
|
+
*/
|
|
51
|
+
function resolveWeighedSourcePrice(sku, weighing) {
|
|
52
|
+
if (sku?.open_sold_weight != null && Number(sku.open_sold_weight) !== 1) return undefined;
|
|
53
|
+
if (Number(sku?.open_sold_weight) !== 1 && !weighing) return undefined;
|
|
54
|
+
const hasSkuMeasurement = sku?.net_weight !== undefined && sku?.net_weight !== null;
|
|
55
|
+
const measurement = hasSkuMeasurement ? sku : weighing;
|
|
56
|
+
const netWeight = nonNegative(measurement?.net_weight);
|
|
57
|
+
if (netWeight === undefined) return undefined;
|
|
58
|
+
const snapshot = hasSkuMeasurement ? sku?.unit_data_snapshot : weighing?.scalePriceProduct;
|
|
59
|
+
const snapshotPrice = nonNegative(snapshot?.price);
|
|
60
|
+
const snapshotUnits = nonNegative(snapshot?.unit_value ?? 1);
|
|
61
|
+
const sourceGrams = UNIT_GRAMS[String(snapshot?.unit)];
|
|
62
|
+
const targetGrams = UNIT_GRAMS[String(measurement?.unit)];
|
|
63
|
+
if (snapshotPrice && snapshotUnits?.gt(0) && sourceGrams && targetGrams) {
|
|
64
|
+
return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Legacy callers may only retain the native scale's amount. Do not let an old
|
|
68
|
+
// amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
|
|
69
|
+
const runtimeAmount = nonNegative(weighing?.total_amount);
|
|
70
|
+
const runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing?.net_weight) === numericKey(sku?.net_weight) && unitKey(weighing?.unit) === unitKey(sku?.unit) && numericKey(weighing?.unit_price) === numericKey(sku?.unit_price) && numericKey(weighing?.unit_weight ?? 1) === numericKey(sku?.unit_weight ?? 1) && JSON.stringify(snapshotKey(weighing?.scalePriceProduct)) === JSON.stringify(snapshotKey(sku?.unit_data_snapshot));
|
|
71
|
+
if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
|
|
72
|
+
|
|
73
|
+
// Older persisted orders have only a rounded per-scale-unit price.
|
|
74
|
+
const unitPrice = nonNegative(measurement?.unit_price);
|
|
75
|
+
const unitWeight = nonNegative(measurement?.unit_weight ?? 1);
|
|
76
|
+
if (!unitPrice || !unitWeight?.gt(0)) return undefined;
|
|
77
|
+
return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
81
|
+
function withOriginalBundleOptionPrices(bundles) {
|
|
82
|
+
return bundles?.map(bundle => ({
|
|
83
|
+
...bundle,
|
|
84
|
+
option: bundle.option?.map(option => ({
|
|
85
|
+
...option,
|
|
86
|
+
add_price: option.original_price ?? option.add_price ?? option.price
|
|
87
|
+
}))
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
@@ -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(
|
|
174
|
+
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
175
175
|
/**
|
|
176
176
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
177
177
|
* @param {CartItem} cartItem
|
|
@@ -129,15 +129,14 @@ Object.defineProperty(exports, "syncManualProductDiscountProductNum", {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
132
|
-
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
133
132
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
133
|
+
var _weighedProduct = require("./utils/weighedProduct");
|
|
134
|
+
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
134
135
|
var _utils = require("../Holder/utils");
|
|
135
136
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
136
137
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
137
138
|
var _salesNotes = require("./salesNotes");
|
|
138
|
-
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
139
139
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
140
|
-
_dayjs.default.extend(_customParseFormat.default);
|
|
141
140
|
const POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
142
141
|
const VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
143
142
|
function isPlainObject(value) {
|
|
@@ -714,24 +713,6 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
714
713
|
}
|
|
715
714
|
return undefined;
|
|
716
715
|
}
|
|
717
|
-
function ensureSubmitDiscountIdentity(discount) {
|
|
718
|
-
if (!discount || typeof discount !== 'object' || Array.isArray(discount)) {
|
|
719
|
-
return discount;
|
|
720
|
-
}
|
|
721
|
-
const discountRecord = discount;
|
|
722
|
-
const metadata = discountRecord.metadata && typeof discountRecord.metadata === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
723
|
-
const uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
724
|
-
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
725
|
-
return discount;
|
|
726
|
-
}
|
|
727
|
-
return {
|
|
728
|
-
...discountRecord,
|
|
729
|
-
metadata: {
|
|
730
|
-
...metadata,
|
|
731
|
-
unique_identification_number: (0, _orderCollectionIdentity.createUuidV4)()
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
716
|
function collectSubmitProductDiscountList(product) {
|
|
736
717
|
const submitDiscountList = Array.isArray(product?.discount_list) ? [...product.discount_list] : [];
|
|
737
718
|
for (const bundle of product?.product_bundle || []) {
|
|
@@ -753,7 +734,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
753
734
|
});
|
|
754
735
|
}
|
|
755
736
|
}
|
|
756
|
-
return normalizeOrderProductDiscountList(submitDiscountList
|
|
737
|
+
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
757
738
|
}
|
|
758
739
|
|
|
759
740
|
/**
|
|
@@ -820,23 +801,7 @@ function resolveEffectivePerUnitDiscount(product) {
|
|
|
820
801
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
821
802
|
return fromList + (originalPrice - finalPrice);
|
|
822
803
|
}
|
|
823
|
-
function createDefaultOrderRulesHooks(
|
|
824
|
-
const getProductStartDate = product => {
|
|
825
|
-
const productUid = String(product.metadata?.unique_identification_number ?? product.unique_identification_number ?? '');
|
|
826
|
-
const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
|
|
827
|
-
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
828
|
-
const bookings = getBookings?.() || [];
|
|
829
|
-
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);
|
|
830
|
-
if (booking) {
|
|
831
|
-
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
832
|
-
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);
|
|
833
|
-
}
|
|
834
|
-
if (getBookings && (bookingUid || product.booking_id || product.metadata?.booking_id)) {
|
|
835
|
-
return (0, _dayjs.default)('');
|
|
836
|
-
}
|
|
837
|
-
const legacyStartDate = product.metadata?.start_date || product.metadata?.startDate;
|
|
838
|
-
return legacyStartDate ? (0, _dayjs.default)(legacyStartDate) : undefined;
|
|
839
|
-
};
|
|
804
|
+
function createDefaultOrderRulesHooks() {
|
|
840
805
|
const toUnitPriceString = (totalLike, num) => {
|
|
841
806
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
842
807
|
return new _decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
@@ -924,7 +889,7 @@ function createDefaultOrderRulesHooks(getBookings) {
|
|
|
924
889
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
925
890
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
926
891
|
holder_id: product.metadata?.holder_id,
|
|
927
|
-
startDate:
|
|
892
|
+
startDate: product.metadata?.start_date || product.metadata?.startDate,
|
|
928
893
|
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,
|
|
929
894
|
inPromotion: metadataAny._promotion?.inPromotion === true,
|
|
930
895
|
_promotion: metadataAny._promotion
|
|
@@ -956,7 +921,7 @@ function createDefaultOrderRulesHooks(getBookings) {
|
|
|
956
921
|
});
|
|
957
922
|
const composedOriginalPrice = composeLinePrice({
|
|
958
923
|
mainPrice: nextMainOriginalPrice,
|
|
959
|
-
bundle: nextBundle,
|
|
924
|
+
bundle: Number(product.product_sku?.open_sold_weight) === 1 && (0, _manualProductDiscount.hasManualProductDiscountFlag)(metadataAny) ? (0, _weighedProduct.withOriginalBundleOptionPrices)(nextBundle) : nextBundle,
|
|
960
925
|
useOriginalBundle: true
|
|
961
926
|
});
|
|
962
927
|
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -412,8 +412,6 @@ export interface WalletAssetsBehaviorOptions {
|
|
|
412
412
|
export interface RefreshWalletAssetsOptions {
|
|
413
413
|
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
414
414
|
preserveSelection?: boolean;
|
|
415
|
-
/** 客户变化时,仅保留与本次扫码匹配的搜索结果;其他搜索缓存仍会清空。 */
|
|
416
|
-
retainSearchResultCodes?: string[];
|
|
417
415
|
}
|
|
418
416
|
export interface SelectWalletAssetOptions {
|
|
419
417
|
selected: boolean;
|
|
@@ -421,8 +419,6 @@ export interface SelectWalletAssetOptions {
|
|
|
421
419
|
}
|
|
422
420
|
export interface ScanWalletAssetResult {
|
|
423
421
|
type: SearchIdentificationCodeResult['type'];
|
|
424
|
-
/** walletCode 时保留完整 Wallet Detail,供客户解析与客户选择器使用。 */
|
|
425
|
-
data?: WalletDetailSearchData;
|
|
426
422
|
asset?: any;
|
|
427
423
|
selected: boolean;
|
|
428
424
|
state: WalletAssetsState;
|
|
@@ -868,8 +864,6 @@ export interface SearchIdentificationCodeParams extends WalletDeductionRecommend
|
|
|
868
864
|
* 搜索识别码响应数据
|
|
869
865
|
*/
|
|
870
866
|
export interface SearchIdentificationCodeResponse {
|
|
871
|
-
/** 业务是否成功 */
|
|
872
|
-
status?: boolean;
|
|
873
867
|
/** 响应状态码 */
|
|
874
868
|
code?: number;
|
|
875
869
|
/** 响应消息 */
|
|
@@ -877,26 +871,12 @@ export interface SearchIdentificationCodeResponse {
|
|
|
877
871
|
/** 响应数据 */
|
|
878
872
|
data?: SearchIdentificationCodeItem[];
|
|
879
873
|
}
|
|
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
|
-
}
|
|
894
874
|
/**
|
|
895
875
|
* 搜索识别码结果类型
|
|
896
876
|
*/
|
|
897
877
|
export type SearchIdentificationCodeResult = {
|
|
898
878
|
type: 'walletCode';
|
|
899
|
-
data:
|
|
879
|
+
data: SearchIdentificationCodeItem[];
|
|
900
880
|
} | {
|
|
901
881
|
type: 'normalCode';
|
|
902
882
|
data: SearchIdentificationCodeItem[];
|
|
@@ -96,7 +96,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
96
96
|
* 搜索识别码信息
|
|
97
97
|
* 通过识别码搜索相关的钱包通行证信息
|
|
98
98
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
99
|
-
*
|
|
99
|
+
* 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
|
|
100
100
|
*/
|
|
101
101
|
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
102
102
|
noCache?: boolean;
|
|
@@ -705,7 +705,7 @@ class WalletPassPaymentImpl {
|
|
|
705
705
|
* 搜索识别码信息
|
|
706
706
|
* 通过识别码搜索相关的钱包通行证信息
|
|
707
707
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
708
|
-
*
|
|
708
|
+
* 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
|
|
709
709
|
*/
|
|
710
710
|
async searchIdentificationCodeAsync(params, config = {}) {
|
|
711
711
|
try {
|
|
@@ -725,7 +725,6 @@ class WalletPassPaymentImpl {
|
|
|
725
725
|
const walletDetailParams = {
|
|
726
726
|
code: code,
|
|
727
727
|
with_customer: 1,
|
|
728
|
-
with_franchisor_data: 1,
|
|
729
728
|
with: ['wallet']
|
|
730
729
|
};
|
|
731
730
|
this.paymentModule.logInfo('[WalletPass] 搜索钱包识别码', {
|
|
@@ -734,18 +733,15 @@ class WalletPassPaymentImpl {
|
|
|
734
733
|
with: walletDetailParams.with
|
|
735
734
|
});
|
|
736
735
|
const response = await this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
|
|
737
|
-
const
|
|
738
|
-
if (response?.status !== true || response?.code !== 200 || !walletDetail || typeof walletDetail !== 'object' || Array.isArray(walletDetail)) {
|
|
739
|
-
throw new Error(response?.message || 'Wallet detail search failed');
|
|
740
|
-
}
|
|
736
|
+
const searchResults = response?.data || [];
|
|
741
737
|
this.paymentModule.logInfo('[WalletPass] 钱包识别码搜索完成', {
|
|
742
738
|
code: code,
|
|
743
|
-
results_count:
|
|
739
|
+
results_count: searchResults.length,
|
|
744
740
|
type: 'walletCode'
|
|
745
741
|
});
|
|
746
742
|
return {
|
|
747
743
|
type: 'walletCode',
|
|
748
|
-
data:
|
|
744
|
+
data: searchResults
|
|
749
745
|
};
|
|
750
746
|
}
|
|
751
747
|
|
|
@@ -834,16 +830,9 @@ class WalletPassPaymentImpl {
|
|
|
834
830
|
const previousCustomerId = this.walletAssetsState.customerId;
|
|
835
831
|
const customerChanged = String(previousCustomerId ?? '') !== String(nextCustomerId ?? '');
|
|
836
832
|
const preserveSelection = options.preserveSelection !== false && !customerChanged;
|
|
837
|
-
const retainedSearchCodeKeys = new Set((options.retainSearchResultCodes || []).map(normalizeWalletAssetCode).filter(Boolean));
|
|
838
|
-
const retainedSearchResults = customerChanged && retainedSearchCodeKeys.size > 0 ? this.searchResults.filter(item => isWalletPaymentAsset(item) && getWalletAssetCodeKeys(item).some(code => retainedSearchCodeKeys.has(code))) : [];
|
|
839
833
|
if (customerChanged) {
|
|
840
834
|
this.clearSearchResults();
|
|
841
|
-
if (retainedSearchResults.length > 0) {
|
|
842
|
-
this.searchResults = mergeWalletAssets(retainedSearchResults);
|
|
843
|
-
this.queuePendingAutoSelectForAssets(retainedSearchResults);
|
|
844
|
-
}
|
|
845
835
|
}
|
|
846
|
-
const preserveSearchContext = preserveSelection || retainedSearchResults.length > 0;
|
|
847
836
|
const committedKeys = new Set(this.walletAssetsState.committedIds.map(id => String(id)));
|
|
848
837
|
const committedItems = this.walletAssetsState.items.filter(item => committedKeys.has(getWalletAssetKey(item)));
|
|
849
838
|
const selectedIds = preserveSelection ? [...this.walletAssetsState.selectedIds] : [];
|
|
@@ -912,8 +901,8 @@ class WalletPassPaymentImpl {
|
|
|
912
901
|
error: null
|
|
913
902
|
});
|
|
914
903
|
try {
|
|
915
|
-
const searchedWalletAssetCodes =
|
|
916
|
-
const useAggregateRecalculate =
|
|
904
|
+
const searchedWalletAssetCodes = preserveSelection ? this.getSearchedWalletAssetCodes() : [];
|
|
905
|
+
const useAggregateRecalculate = preserveSelection && (selectedIds.length > 0 || searchedWalletAssetCodes.length > 0);
|
|
917
906
|
const aggregateResult = useAggregateRecalculate ? await this.aggregateRecalculateWalletAssetsAsync(businessData, selectedIds) : null;
|
|
918
907
|
const result = aggregateResult || (await this.initializeWalletDataFromBusinessAsync(businessData));
|
|
919
908
|
if (requestSequence !== this.walletAssetsRequestSequence) {
|
|
@@ -931,7 +920,7 @@ class WalletPassPaymentImpl {
|
|
|
931
920
|
this.searchResults = this.searchResults.filter(item => !missingSelectedKeys.has(getWalletAssetKey(item)));
|
|
932
921
|
}
|
|
933
922
|
}
|
|
934
|
-
const searchedWalletAssets =
|
|
923
|
+
const searchedWalletAssets = preserveSelection ? this.syncSearchedWalletAssets([...(result.transformList || []), ...(result.noApplicableVoucher || [])]) : [];
|
|
935
924
|
if (requestSequence !== this.walletAssetsRequestSequence) {
|
|
936
925
|
return this.getWalletAssetsState();
|
|
937
926
|
}
|
|
@@ -1133,23 +1122,14 @@ class WalletPassPaymentImpl {
|
|
|
1133
1122
|
code: normalizedCode,
|
|
1134
1123
|
prepare_payments: this.formatWalletPassList2PreparePayments(this.walletAssetsState.selectedItems)
|
|
1135
1124
|
});
|
|
1136
|
-
if (result.type === 'walletCode') {
|
|
1137
|
-
return {
|
|
1138
|
-
type: 'walletCode',
|
|
1139
|
-
data: result.data,
|
|
1140
|
-
asset: result.data,
|
|
1141
|
-
selected: false,
|
|
1142
|
-
state: this.getWalletAssetsState()
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
1125
|
const paymentAssets = this.formatSearchedWalletPaymentAssets(result.data.filter(isWalletPaymentAsset));
|
|
1146
1126
|
if (paymentAssets.length > 0) {
|
|
1147
1127
|
this.searchResults = mergeWalletAssets(this.searchResults, paymentAssets);
|
|
1148
1128
|
}
|
|
1149
1129
|
const asset = paymentAssets.find(item => String(item?.code || '') === normalizedCode) || paymentAssets[0];
|
|
1150
|
-
if (!asset) {
|
|
1130
|
+
if (!asset || result.type === 'walletCode') {
|
|
1151
1131
|
return {
|
|
1152
|
-
type:
|
|
1132
|
+
type: result.type,
|
|
1153
1133
|
asset,
|
|
1154
1134
|
selected: false,
|
|
1155
1135
|
state: this.getWalletAssetsState()
|
|
@@ -16,8 +16,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
16
16
|
getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
|
|
17
17
|
private normalizeHolderRecordIds;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* 特定 form Holder 卡只授权给绑定同一 Holder Record 的商品行。
|
|
20
|
+
* required/isNeedHolder 仅控制是否强制选择 Holder,不参与优惠资格。
|
|
21
21
|
*/
|
|
22
22
|
private checkHolderMatch;
|
|
23
23
|
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
|