@pisell/pisellos 2.3.50 → 2.3.53
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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +6 -8
- package/dist/modules/Order/index.js +165 -140
- package/dist/modules/Order/types.d.ts +21 -12
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +3 -35
- package/dist/modules/Payment/types.d.ts +8 -0
- package/dist/modules/Payment/walletpass.d.ts +7 -1
- package/dist/modules/Payment/walletpass.js +155 -45
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.js +32 -56
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +793 -907
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +16 -0
- package/dist/server/modules/order/index.js +964 -776
- package/dist/server/modules/order/types.d.ts +14 -0
- package/dist/server/modules/order/types.js +6 -0
- package/dist/solution/BaseSales/index.d.ts +18 -13
- package/dist/solution/BaseSales/index.js +202 -178
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -17
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/BookingTicket/index.js +2 -2
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +739 -1142
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +841 -1167
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +6 -8
- package/lib/modules/Order/index.js +89 -38
- package/lib/modules/Order/types.d.ts +21 -12
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +5 -36
- package/lib/modules/Payment/types.d.ts +8 -0
- package/lib/modules/Payment/walletpass.d.ts +7 -1
- package/lib/modules/Payment/walletpass.js +107 -9
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.js +32 -44
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +0 -14
- package/lib/server/index.js +15 -72
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +16 -0
- package/lib/server/modules/order/index.js +140 -4
- package/lib/server/modules/order/types.d.ts +14 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +18 -13
- package/lib/solution/BaseSales/index.js +58 -35
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -17
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/BookingTicket/index.js +2 -10
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +182 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +110 -322
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1891
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1084
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
|
@@ -36,9 +36,8 @@ __export(utils_exports, {
|
|
|
36
36
|
composeLinePrice: () => composeLinePrice,
|
|
37
37
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
38
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
|
-
createEmptySummary: () =>
|
|
39
|
+
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
40
40
|
createUuidV4: () => import_orderCollectionIdentity.createUuidV4,
|
|
41
|
-
ensureCartItemOriginHolder: () => ensureCartItemOriginHolder,
|
|
42
41
|
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
43
42
|
ensureProductSku: () => ensureProductSku,
|
|
44
43
|
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
@@ -86,10 +85,9 @@ __export(utils_exports, {
|
|
|
86
85
|
module.exports = __toCommonJS(utils_exports);
|
|
87
86
|
var import_dayjs = __toESM(require("dayjs"));
|
|
88
87
|
var import_decimal = __toESM(require("decimal.js"));
|
|
89
|
-
var import_utils = require("
|
|
90
|
-
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
88
|
+
var import_utils = require("../../solution/ScanOrder/utils");
|
|
91
89
|
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
92
|
-
var
|
|
90
|
+
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
93
91
|
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
94
92
|
function composeLinePrice(params) {
|
|
95
93
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
@@ -548,7 +546,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
548
546
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
549
547
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
550
548
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
551
|
-
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0,
|
|
549
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
552
550
|
getProductSkuOptions(product),
|
|
553
551
|
product.product_bundle
|
|
554
552
|
)}`,
|
|
@@ -640,34 +638,6 @@ var mergeRelationForms = (relationForms) => {
|
|
|
640
638
|
}, {})
|
|
641
639
|
).filter((item) => item.form_record_ids.length > 0);
|
|
642
640
|
};
|
|
643
|
-
function getCustomerIdFromStorage(window) {
|
|
644
|
-
var _a;
|
|
645
|
-
try {
|
|
646
|
-
const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
|
|
647
|
-
const customerId = Number(customer == null ? void 0 : customer.id);
|
|
648
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
649
|
-
} catch {
|
|
650
|
-
return void 0;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
function ensureCartItemOriginHolder(cartItem, window) {
|
|
654
|
-
var _a;
|
|
655
|
-
if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
const holderConfig = (0, import_utils.getProductHolderConfig)(
|
|
659
|
-
(cartItem == null ? void 0 : cartItem._productInit) ?? (cartItem == null ? void 0 : cartItem._productOrigin)
|
|
660
|
-
);
|
|
661
|
-
const formRecordId = cartItem == null ? void 0 : cartItem.holder_id;
|
|
662
|
-
if (!(holderConfig == null ? void 0 : holderConfig.resource_id) || formRecordId == null) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
cartItem._origin.holder = {
|
|
666
|
-
customer_id: getCustomerIdFromStorage(window),
|
|
667
|
-
form_id: holderConfig.resource_id,
|
|
668
|
-
form_record: [formRecordId]
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
641
|
var getAllDiscountList = (cartItem) => {
|
|
672
642
|
var _a, _b, _c, _d;
|
|
673
643
|
let discountList = ((_b = (_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
@@ -1033,7 +1003,7 @@ function buildSubmitPayload(params) {
|
|
|
1033
1003
|
// contacts: tempOrder.contacts || [],
|
|
1034
1004
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
1035
1005
|
// holder: tempOrder.holder || null,
|
|
1036
|
-
summary: summary || tempOrder.summary || (0,
|
|
1006
|
+
summary: summary || tempOrder.summary || (0, import_utils.createEmptySummary)(),
|
|
1037
1007
|
metadata: (() => {
|
|
1038
1008
|
const {
|
|
1039
1009
|
collect_pax: _collectPax,
|
|
@@ -1282,7 +1252,6 @@ function indexOrderProductsByUid(products) {
|
|
|
1282
1252
|
createDefaultTempOrder,
|
|
1283
1253
|
createEmptySummary,
|
|
1284
1254
|
createUuidV4,
|
|
1285
|
-
ensureCartItemOriginHolder,
|
|
1286
1255
|
ensureManualProductDiscountList,
|
|
1287
1256
|
ensureProductSku,
|
|
1288
1257
|
findManualProductDiscountItem,
|
|
@@ -397,12 +397,18 @@ export interface WalletAssetsState {
|
|
|
397
397
|
export interface WalletAssetsSnapshot {
|
|
398
398
|
state: WalletAssetsState;
|
|
399
399
|
searchResults: SearchIdentificationCodeItem[];
|
|
400
|
+
/** 已搜索但尚未满足订单条件、等待首次可用后自动选中的 Wallet Asset code。 */
|
|
401
|
+
pendingAutoSelectSearchCodes?: string[];
|
|
400
402
|
walletParams: WalletDeductionRecommendParams | null;
|
|
401
403
|
calculationContext: {
|
|
402
404
|
orderTotalAmount: number;
|
|
403
405
|
products: any[];
|
|
404
406
|
};
|
|
405
407
|
}
|
|
408
|
+
export interface WalletAssetsBehaviorOptions {
|
|
409
|
+
/** 搜索到 Wallet Asset 后,当前或后续首次可用时是否自动选中。 */
|
|
410
|
+
autoSelectAfterSearch?: boolean;
|
|
411
|
+
}
|
|
406
412
|
export interface RefreshWalletAssetsOptions {
|
|
407
413
|
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
408
414
|
preserveSelection?: boolean;
|
|
@@ -472,6 +478,8 @@ export interface WalletPassPayment {
|
|
|
472
478
|
refreshWalletAssetsFromBusinessAsync: (businessData: WalletInitBusinessData, options?: RefreshWalletAssetsOptions) => Promise<WalletAssetsState>;
|
|
473
479
|
/** 获取共享钱包资产状态快照。 */
|
|
474
480
|
getWalletAssetsState: () => WalletAssetsState;
|
|
481
|
+
/** 配置仅影响 Wallet Assets 的交互行为。 */
|
|
482
|
+
configureWalletAssetsBehavior: (options: WalletAssetsBehaviorOptions) => void;
|
|
475
483
|
/** 导出供 Shared Checkout 跨运行时传递的 Wallet Assets 快照。 */
|
|
476
484
|
exportWalletAssetsSnapshot: () => WalletAssetsSnapshot;
|
|
477
485
|
/** 恢复 Shared Checkout 传回的 Wallet Assets 快照。 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData, WalletAssetId, WalletAssetsSnapshot, WalletAssetsState, RefreshWalletAssetsOptions, SelectWalletAssetOptions, ScanWalletAssetResult } from './types';
|
|
1
|
+
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData, WalletAssetId, WalletAssetsBehaviorOptions, WalletAssetsSnapshot, WalletAssetsState, RefreshWalletAssetsOptions, SelectWalletAssetOptions, ScanWalletAssetResult } from './types';
|
|
2
2
|
import type { PaymentModule } from './index';
|
|
3
3
|
/**
|
|
4
4
|
* 钱包支付实现
|
|
@@ -12,8 +12,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
12
12
|
private walletInitData;
|
|
13
13
|
private walletAssetsState;
|
|
14
14
|
private walletAssetsRequestSequence;
|
|
15
|
+
private walletAssetsBehavior;
|
|
16
|
+
private pendingAutoSelectSearchCodes;
|
|
15
17
|
private walletAssetsCalculationContext;
|
|
16
18
|
constructor(paymentModule: PaymentModule);
|
|
19
|
+
configureWalletAssetsBehavior(options: WalletAssetsBehaviorOptions): void;
|
|
17
20
|
/**
|
|
18
21
|
* 发送事件的辅助方法
|
|
19
22
|
* 支持使用WalletPassHooks或PaymentHooks
|
|
@@ -28,6 +31,9 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
28
31
|
* 接口暂时缺失某个扫码 code 时继续保留旧值,避免列表闪空。
|
|
29
32
|
*/
|
|
30
33
|
private syncSearchedWalletAssets;
|
|
34
|
+
private isPendingAutoSelectAsset;
|
|
35
|
+
private clearPendingAutoSelectForAsset;
|
|
36
|
+
private queuePendingAutoSelectForAssets;
|
|
31
37
|
/**
|
|
32
38
|
* 生成钱包API默认参数
|
|
33
39
|
* 根据业务数据生成标准的钱包API参数,并存储在模块中
|
|
@@ -46,6 +46,12 @@ function matchesWalletAssetCode(asset, normalizedCode) {
|
|
|
46
46
|
(identifier) => String(identifier ?? "").trim() === normalizedCode
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
+
function normalizeWalletAssetCode(code) {
|
|
50
|
+
return String(code ?? "").trim().toUpperCase();
|
|
51
|
+
}
|
|
52
|
+
function getWalletAssetCodeKeys(asset) {
|
|
53
|
+
return [asset == null ? void 0 : asset.code, asset == null ? void 0 : asset.encoded].map(normalizeWalletAssetCode).filter(Boolean);
|
|
54
|
+
}
|
|
49
55
|
function isWalletAssetAvailable(asset) {
|
|
50
56
|
if (!asset)
|
|
51
57
|
return false;
|
|
@@ -107,11 +113,23 @@ var WalletPassPaymentImpl = class {
|
|
|
107
113
|
this.walletInitData = null;
|
|
108
114
|
this.walletAssetsState = createInitialWalletAssetsState();
|
|
109
115
|
this.walletAssetsRequestSequence = 0;
|
|
116
|
+
this.walletAssetsBehavior = {
|
|
117
|
+
autoSelectAfterSearch: true
|
|
118
|
+
};
|
|
119
|
+
this.pendingAutoSelectSearchCodes = /* @__PURE__ */ new Set();
|
|
110
120
|
this.walletAssetsCalculationContext = {
|
|
111
121
|
orderTotalAmount: 0,
|
|
112
122
|
products: []
|
|
113
123
|
};
|
|
114
124
|
}
|
|
125
|
+
configureWalletAssetsBehavior(options) {
|
|
126
|
+
if (options.autoSelectAfterSearch === void 0)
|
|
127
|
+
return;
|
|
128
|
+
this.walletAssetsBehavior.autoSelectAfterSearch = options.autoSelectAfterSearch;
|
|
129
|
+
if (!options.autoSelectAfterSearch) {
|
|
130
|
+
this.pendingAutoSelectSearchCodes.clear();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
115
133
|
/**
|
|
116
134
|
* 发送事件的辅助方法
|
|
117
135
|
* 支持使用WalletPassHooks或PaymentHooks
|
|
@@ -250,6 +268,25 @@ var WalletPassPaymentImpl = class {
|
|
|
250
268
|
refreshedAssets
|
|
251
269
|
);
|
|
252
270
|
}
|
|
271
|
+
isPendingAutoSelectAsset(asset) {
|
|
272
|
+
return getWalletAssetCodeKeys(asset).some(
|
|
273
|
+
(code) => this.pendingAutoSelectSearchCodes.has(code)
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
clearPendingAutoSelectForAsset(asset) {
|
|
277
|
+
getWalletAssetCodeKeys(asset).forEach((code) => {
|
|
278
|
+
this.pendingAutoSelectSearchCodes.delete(code);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
queuePendingAutoSelectForAssets(assets) {
|
|
282
|
+
if (!this.walletAssetsBehavior.autoSelectAfterSearch)
|
|
283
|
+
return;
|
|
284
|
+
assets.forEach((asset) => {
|
|
285
|
+
getWalletAssetCodeKeys(asset).forEach((code) => {
|
|
286
|
+
this.pendingAutoSelectSearchCodes.add(code);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
253
290
|
/**
|
|
254
291
|
* 生成钱包API默认参数
|
|
255
292
|
* 根据业务数据生成标准的钱包API参数,并存储在模块中
|
|
@@ -777,7 +814,12 @@ var WalletPassPaymentImpl = class {
|
|
|
777
814
|
);
|
|
778
815
|
const selectedIds = preserveSelection ? [...this.walletAssetsState.selectedIds] : [];
|
|
779
816
|
const selectionSources = preserveSelection ? { ...this.walletAssetsState.selectionSources } : {};
|
|
817
|
+
const scanSelectedAssets = preserveSelection ? this.walletAssetsState.selectedItems.filter((asset) => {
|
|
818
|
+
const assetId = getWalletAssetId(asset);
|
|
819
|
+
return assetId !== void 0 && assetId !== null && selectionSources[String(assetId)] === "scan";
|
|
820
|
+
}) : [];
|
|
780
821
|
if (!((_a = businessData.products) == null ? void 0 : _a.length)) {
|
|
822
|
+
this.queuePendingAutoSelectForAssets(scanSelectedAssets);
|
|
781
823
|
this.generateWalletParams(businessData);
|
|
782
824
|
const restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map((item) => ({
|
|
783
825
|
...item,
|
|
@@ -882,11 +924,43 @@ var WalletPassPaymentImpl = class {
|
|
|
882
924
|
}));
|
|
883
925
|
const latestSelectedIds = preserveSelection ? authoritativeSelectedIds : [];
|
|
884
926
|
const latestSelectionSources = preserveSelection ? { ...this.walletAssetsState.selectionSources } : {};
|
|
885
|
-
|
|
927
|
+
const pendingAutoSelectAssets = this.walletAssetsBehavior.autoSelectAfterSearch ? items.filter(
|
|
928
|
+
(asset) => this.isPendingAutoSelectAsset(asset) && isWalletAssetAvailable(asset)
|
|
929
|
+
) : [];
|
|
930
|
+
const requestedKeySet = new Set(
|
|
931
|
+
latestSelectedIds.map((id) => String(id))
|
|
932
|
+
);
|
|
933
|
+
pendingAutoSelectAssets.forEach((asset) => {
|
|
934
|
+
const assetId = getWalletAssetId(asset);
|
|
935
|
+
if (assetId === void 0 || assetId === null)
|
|
936
|
+
return;
|
|
937
|
+
const assetKey = String(assetId);
|
|
938
|
+
if (!requestedKeySet.has(assetKey)) {
|
|
939
|
+
requestedKeySet.add(assetKey);
|
|
940
|
+
latestSelectedIds.push(assetId);
|
|
941
|
+
}
|
|
942
|
+
latestSelectionSources[assetKey] = "scan";
|
|
943
|
+
});
|
|
944
|
+
const nextState = this.recalculateWalletAssets(
|
|
886
945
|
items,
|
|
887
946
|
latestSelectedIds,
|
|
888
947
|
latestSelectionSources
|
|
889
948
|
);
|
|
949
|
+
const selectedKeySet = new Set(
|
|
950
|
+
nextState.selectedIds.map((id) => String(id))
|
|
951
|
+
);
|
|
952
|
+
pendingAutoSelectAssets.forEach((asset) => {
|
|
953
|
+
const assetId = getWalletAssetId(asset);
|
|
954
|
+
if (assetId !== void 0 && assetId !== null && selectedKeySet.has(String(assetId))) {
|
|
955
|
+
this.clearPendingAutoSelectForAsset(asset);
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
const droppedScanSelectedAssets = scanSelectedAssets.filter((asset) => {
|
|
959
|
+
const assetId = getWalletAssetId(asset);
|
|
960
|
+
return assetId !== void 0 && assetId !== null && !selectedKeySet.has(String(assetId));
|
|
961
|
+
});
|
|
962
|
+
this.queuePendingAutoSelectForAssets(droppedScanSelectedAssets);
|
|
963
|
+
return nextState;
|
|
890
964
|
} catch (error) {
|
|
891
965
|
if (requestSequence !== this.walletAssetsRequestSequence) {
|
|
892
966
|
return this.getWalletAssetsState();
|
|
@@ -926,6 +1000,9 @@ var WalletPassPaymentImpl = class {
|
|
|
926
1000
|
return {
|
|
927
1001
|
state: this.getWalletAssetsState(),
|
|
928
1002
|
searchResults: [...this.searchResults],
|
|
1003
|
+
pendingAutoSelectSearchCodes: [
|
|
1004
|
+
...this.pendingAutoSelectSearchCodes
|
|
1005
|
+
],
|
|
929
1006
|
walletParams: this.walletParams ? { ...this.walletParams } : null,
|
|
930
1007
|
calculationContext: {
|
|
931
1008
|
orderTotalAmount: this.walletAssetsCalculationContext.orderTotalAmount,
|
|
@@ -939,6 +1016,9 @@ var WalletPassPaymentImpl = class {
|
|
|
939
1016
|
return this.getWalletAssetsState();
|
|
940
1017
|
this.walletAssetsRequestSequence += 1;
|
|
941
1018
|
this.searchResults = Array.isArray(snapshot.searchResults) ? [...snapshot.searchResults] : [];
|
|
1019
|
+
this.pendingAutoSelectSearchCodes = this.walletAssetsBehavior.autoSelectAfterSearch && Array.isArray(snapshot.pendingAutoSelectSearchCodes) ? new Set(
|
|
1020
|
+
snapshot.pendingAutoSelectSearchCodes.map(normalizeWalletAssetCode).filter(Boolean)
|
|
1021
|
+
) : /* @__PURE__ */ new Set();
|
|
942
1022
|
this.walletParams = snapshot.walletParams ? { ...snapshot.walletParams } : null;
|
|
943
1023
|
this.walletAssetsCalculationContext = {
|
|
944
1024
|
orderTotalAmount: Number(
|
|
@@ -957,6 +1037,9 @@ var WalletPassPaymentImpl = class {
|
|
|
957
1037
|
}
|
|
958
1038
|
selectWalletAsset(assetId, options) {
|
|
959
1039
|
const assetKey = String(assetId);
|
|
1040
|
+
const asset = this.walletAssetsState.items.find(
|
|
1041
|
+
(item) => getWalletAssetKey(item) === assetKey
|
|
1042
|
+
);
|
|
960
1043
|
const committedKeys = new Set(
|
|
961
1044
|
this.walletAssetsState.committedIds.map((id) => String(id))
|
|
962
1045
|
);
|
|
@@ -968,20 +1051,23 @@ var WalletPassPaymentImpl = class {
|
|
|
968
1051
|
const selectionSources = { ...this.walletAssetsState.selectionSources };
|
|
969
1052
|
delete selectionSources[assetKey];
|
|
970
1053
|
if (options.selected) {
|
|
971
|
-
const asset = this.walletAssetsState.items.find(
|
|
972
|
-
(item) => getWalletAssetKey(item) === assetKey
|
|
973
|
-
);
|
|
974
1054
|
if (!asset || !isWalletAssetAvailable(asset)) {
|
|
975
1055
|
return this.getWalletAssetsState();
|
|
976
1056
|
}
|
|
977
1057
|
selectedIds.push(assetId);
|
|
978
1058
|
selectionSources[assetKey] = options.source || "manual";
|
|
1059
|
+
} else if (asset) {
|
|
1060
|
+
this.clearPendingAutoSelectForAsset(asset);
|
|
979
1061
|
}
|
|
980
|
-
|
|
1062
|
+
const nextState = this.recalculateWalletAssets(
|
|
981
1063
|
this.walletAssetsState.items,
|
|
982
1064
|
selectedIds,
|
|
983
1065
|
selectionSources
|
|
984
1066
|
);
|
|
1067
|
+
if (options.selected && asset && nextState.selectedIds.some((id) => String(id) === assetKey)) {
|
|
1068
|
+
this.clearPendingAutoSelectForAsset(asset);
|
|
1069
|
+
}
|
|
1070
|
+
return nextState;
|
|
985
1071
|
}
|
|
986
1072
|
async scanWalletAssetAsync(code) {
|
|
987
1073
|
const normalizedCode = String(code || "").trim();
|
|
@@ -1024,24 +1110,34 @@ var WalletPassPaymentImpl = class {
|
|
|
1024
1110
|
};
|
|
1025
1111
|
}
|
|
1026
1112
|
const items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
|
|
1027
|
-
this.recalculateWalletAssets(
|
|
1113
|
+
const recalculatedState = this.recalculateWalletAssets(
|
|
1028
1114
|
items,
|
|
1029
1115
|
this.walletAssetsState.selectedIds,
|
|
1030
1116
|
this.walletAssetsState.selectionSources
|
|
1031
1117
|
);
|
|
1032
1118
|
const assetId = getWalletAssetId(asset);
|
|
1033
|
-
const selected = assetId !== void 0 && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
|
|
1119
|
+
const selected = this.walletAssetsBehavior.autoSelectAfterSearch && assetId !== void 0 && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
|
|
1034
1120
|
selected: true,
|
|
1035
1121
|
source: "scan"
|
|
1036
|
-
}) :
|
|
1122
|
+
}) : recalculatedState;
|
|
1123
|
+
const isSelected = assetId !== void 0 && selected.selectedIds.some((id) => String(id) === String(assetId));
|
|
1124
|
+
if (isSelected) {
|
|
1125
|
+
this.clearPendingAutoSelectForAsset(asset);
|
|
1126
|
+
} else if (this.walletAssetsBehavior.autoSelectAfterSearch) {
|
|
1127
|
+
this.pendingAutoSelectSearchCodes.add(
|
|
1128
|
+
normalizeWalletAssetCode(normalizedCode)
|
|
1129
|
+
);
|
|
1130
|
+
this.queuePendingAutoSelectForAssets([asset]);
|
|
1131
|
+
}
|
|
1037
1132
|
return {
|
|
1038
1133
|
type: result.type,
|
|
1039
1134
|
asset,
|
|
1040
|
-
selected:
|
|
1135
|
+
selected: isSelected,
|
|
1041
1136
|
state: selected
|
|
1042
1137
|
};
|
|
1043
1138
|
}
|
|
1044
1139
|
clearWalletAssetSelection() {
|
|
1140
|
+
this.pendingAutoSelectSearchCodes.clear();
|
|
1045
1141
|
return this.recalculateWalletAssets(
|
|
1046
1142
|
this.walletAssetsState.items,
|
|
1047
1143
|
[],
|
|
@@ -1156,6 +1252,7 @@ var WalletPassPaymentImpl = class {
|
|
|
1156
1252
|
*/
|
|
1157
1253
|
clearSearchResults() {
|
|
1158
1254
|
this.searchResults = [];
|
|
1255
|
+
this.pendingAutoSelectSearchCodes.clear();
|
|
1159
1256
|
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
1160
1257
|
}
|
|
1161
1258
|
/**
|
|
@@ -1178,6 +1275,7 @@ var WalletPassPaymentImpl = class {
|
|
|
1178
1275
|
this.walletRecommendList = [];
|
|
1179
1276
|
this.userIdentificationCodes = [];
|
|
1180
1277
|
this.searchResults = [];
|
|
1278
|
+
this.pendingAutoSelectSearchCodes.clear();
|
|
1181
1279
|
this.walletParams = null;
|
|
1182
1280
|
this.walletInitData = null;
|
|
1183
1281
|
this.walletAssetsRequestSequence += 1;
|
|
@@ -106,48 +106,39 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
106
106
|
} catch (error) {
|
|
107
107
|
console.error(error);
|
|
108
108
|
}
|
|
109
|
-
const channelMap = {
|
|
110
|
-
online_store: "online-store",
|
|
111
|
-
scan_to_order: "online-store",
|
|
112
|
-
"scan-to-order": "online-store",
|
|
113
|
-
scan_to_order_2: "mobile_order",
|
|
114
|
-
scan_to_order_3: "scantoorder3"
|
|
115
|
-
};
|
|
116
|
-
const rawApplicationCode = (_b = this.otherParams) == null ? void 0 : _b.channel;
|
|
117
|
-
const mappedApplicationCode = typeof rawApplicationCode === "string" ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
118
|
-
const queryPayload = {
|
|
119
|
-
open_quotation: 1,
|
|
120
|
-
open_bundle: 0,
|
|
121
|
-
exclude_extension_type: [
|
|
122
|
-
"product_party",
|
|
123
|
-
"product_event",
|
|
124
|
-
"product_series_event",
|
|
125
|
-
"product_package_ticket",
|
|
126
|
-
"ticket",
|
|
127
|
-
"event_item"
|
|
128
|
-
],
|
|
129
|
-
with: ["category", "collection", "resourceRelation"],
|
|
130
|
-
status,
|
|
131
|
-
num: 500,
|
|
132
|
-
skip: 1,
|
|
133
|
-
customer_id,
|
|
134
|
-
...Array.isArray(category_ids) && category_ids.length ? { category_ids } : {},
|
|
135
|
-
...Array.isArray(product_ids) && product_ids.length ? { ids: product_ids } : {},
|
|
136
|
-
...Array.isArray(collection) && collection.length ? { collection } : {},
|
|
137
|
-
front_end_cache_id: cacheId,
|
|
138
|
-
...Array.isArray(menu_list_ids) && menu_list_ids.length ? { menu_list_ids } : {},
|
|
139
|
-
with_count,
|
|
140
|
-
// client_schedule_ids: schedule_ids,
|
|
141
|
-
schedule_date,
|
|
142
|
-
application_code: mappedApplicationCode,
|
|
143
|
-
is_eject: 1,
|
|
144
|
-
with_schedule,
|
|
145
|
-
schedule_datetime,
|
|
146
|
-
extension_type
|
|
147
|
-
};
|
|
148
109
|
const productsData = await this.request.post(
|
|
149
110
|
`/product/query`,
|
|
150
|
-
|
|
111
|
+
{
|
|
112
|
+
open_quotation: 1,
|
|
113
|
+
open_bundle: 0,
|
|
114
|
+
exclude_extension_type: [
|
|
115
|
+
"product_party",
|
|
116
|
+
"product_event",
|
|
117
|
+
"product_series_event",
|
|
118
|
+
"product_package_ticket",
|
|
119
|
+
"ticket",
|
|
120
|
+
"event_item"
|
|
121
|
+
],
|
|
122
|
+
with: ["category", "collection", "resourceRelation"],
|
|
123
|
+
status,
|
|
124
|
+
num: 500,
|
|
125
|
+
skip: 1,
|
|
126
|
+
customer_id,
|
|
127
|
+
category_ids,
|
|
128
|
+
ids: product_ids,
|
|
129
|
+
collection,
|
|
130
|
+
front_end_cache_id: cacheId,
|
|
131
|
+
menu_list_ids,
|
|
132
|
+
with_count,
|
|
133
|
+
// client_schedule_ids: schedule_ids,
|
|
134
|
+
schedule_date,
|
|
135
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
136
|
+
is_eject: 1,
|
|
137
|
+
with_schedule,
|
|
138
|
+
schedule_datetime,
|
|
139
|
+
extension_type,
|
|
140
|
+
strategy_context
|
|
141
|
+
},
|
|
151
142
|
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
|
|
152
143
|
} }
|
|
153
144
|
);
|
|
@@ -21,7 +21,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
21
21
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
22
22
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
23
23
|
*
|
|
24
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
24
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
25
25
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
26
26
|
* the requested productId wins.
|
|
27
27
|
*/
|
|
@@ -52,7 +52,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
52
52
|
{ useCache: false, osServer: true }
|
|
53
53
|
);
|
|
54
54
|
const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
|
|
55
|
-
list.sort((a, b) =>
|
|
55
|
+
list.sort((a, b) => a.sort - b.sort);
|
|
56
56
|
this.store.list = list;
|
|
57
57
|
}
|
|
58
58
|
getQuotationList() {
|
|
@@ -96,7 +96,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
96
96
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
97
97
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
98
98
|
*
|
|
99
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
99
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
100
100
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
101
101
|
* the requested productId wins.
|
|
102
102
|
*/
|