@pisell/pisellos 0.10.98 → 0.10.99
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/locales.js +9 -0
- package/dist/modules/Order/index.js +7 -0
- package/dist/modules/Order/types.d.ts +6 -0
- package/dist/modules/Payment/utils.d.ts +2 -0
- package/dist/modules/Payment/utils.js +6 -6
- package/dist/modules/Payment/walletpass.d.ts +2 -0
- package/dist/modules/Payment/walletpass.js +75 -34
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.js +26 -13
- package/dist/server/modules/products/index.d.ts +6 -2
- package/dist/server/modules/products/index.js +476 -400
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +6 -5
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +20 -20
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +34 -23
- package/lib/model/strategy/adapter/walletPass/locales.js +9 -0
- package/lib/modules/Order/index.js +5 -0
- package/lib/modules/Order/types.d.ts +6 -0
- package/lib/modules/Payment/utils.d.ts +2 -0
- package/lib/modules/Payment/utils.js +7 -7
- package/lib/modules/Payment/walletpass.d.ts +2 -0
- package/lib/modules/Payment/walletpass.js +42 -11
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.js +9 -4
- package/lib/server/modules/products/index.d.ts +6 -2
- package/lib/server/modules/products/index.js +40 -7
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +20 -20
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export var locales = {
|
|
2
2
|
'zh-CN': {
|
|
3
|
+
'empty_cart': '请先添加商品到购物车',
|
|
3
4
|
'not_meet_the_required_conditions': '未达到使用条件',
|
|
4
5
|
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金额限制',
|
|
5
6
|
'usage_limit_reached': '已达到使用次数上限',
|
|
@@ -11,6 +12,7 @@ export var locales = {
|
|
|
11
12
|
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
12
13
|
},
|
|
13
14
|
'en': {
|
|
15
|
+
'empty_cart': 'Add items to the cart first.',
|
|
14
16
|
'not_meet_the_required_conditions': 'Not meet the required conditions.',
|
|
15
17
|
'exceeds_the_maximum_deduction_limit': 'Exceeds the maximum deduction limit.',
|
|
16
18
|
'usage_limit_reached': 'Usage limit reached.',
|
|
@@ -22,6 +24,7 @@ export var locales = {
|
|
|
22
24
|
'applicable_product_count_not_enough': 'Min. Qty {value}'
|
|
23
25
|
},
|
|
24
26
|
'zh-HK': {
|
|
27
|
+
'empty_cart': '請先添加商品到購物車',
|
|
25
28
|
'not_meet_the_required_conditions': '未達使用條件',
|
|
26
29
|
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金額限制',
|
|
27
30
|
'usage_limit_reached': '已達使用次數上限',
|
|
@@ -31,5 +34,11 @@ export var locales = {
|
|
|
31
34
|
'order_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
32
35
|
'applicable_product_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
33
36
|
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
37
|
+
},
|
|
38
|
+
'ja': {
|
|
39
|
+
'empty_cart': '先に商品をカートに追加してください。'
|
|
40
|
+
},
|
|
41
|
+
'pt': {
|
|
42
|
+
'empty_cart': 'Adicione produtos ao carrinho primeiro.'
|
|
34
43
|
}
|
|
35
44
|
};
|
|
@@ -1633,6 +1633,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1633
1633
|
_context11.prev = 61;
|
|
1634
1634
|
_context11.next = 64;
|
|
1635
1635
|
return this.giftSelectResolver({
|
|
1636
|
+
inventoryReserved: tempOrder.products.map(function (line) {
|
|
1637
|
+
return {
|
|
1638
|
+
product_id: Number(line.product_id),
|
|
1639
|
+
product_variant_id: Number(line.product_variant_id || 0),
|
|
1640
|
+
quantity: Number(line.num) || 0
|
|
1641
|
+
};
|
|
1642
|
+
}),
|
|
1636
1643
|
strategyId: addAction.strategyId,
|
|
1637
1644
|
strategyName: addAction.strategyName,
|
|
1638
1645
|
giftCount: addAction.giftCount,
|
|
@@ -46,6 +46,12 @@ export interface OrderPromotionEvaluator {
|
|
|
46
46
|
}
|
|
47
47
|
/** 赠品解析回调 context(OS → SDK 的请求体) */
|
|
48
48
|
export interface OrderGiftSelectContext {
|
|
49
|
+
/** Inventory already consumed by the pending order, including its triggering product. */
|
|
50
|
+
inventoryReserved?: Array<{
|
|
51
|
+
product_id: number;
|
|
52
|
+
product_variant_id: number;
|
|
53
|
+
quantity: number;
|
|
54
|
+
}>;
|
|
49
55
|
strategyId: string;
|
|
50
56
|
strategyName: string | Record<string, string>;
|
|
51
57
|
giftCount: number;
|
|
@@ -10,6 +10,8 @@ export declare const formatWalletPassList2PreparePayments: (list?: any[]) => {
|
|
|
10
10
|
wallet_pass_usage_unit: any;
|
|
11
11
|
wallet_pass_use_value: any;
|
|
12
12
|
}[];
|
|
13
|
+
/** 这两种不可用原因随订单内容变化,其他服务端错误需保留。 */
|
|
14
|
+
export declare const isWalletOrderAvailabilityError: (code: unknown) => boolean;
|
|
13
15
|
/**
|
|
14
16
|
* 对用户识别码列表进行排序
|
|
15
17
|
* 排序规则:正常数据 -> unified_available_status===1 -> 500601/500602 -> unified_available_status===0
|
|
@@ -26,6 +26,11 @@ export var formatWalletPassList2PreparePayments = function formatWalletPassList2
|
|
|
26
26
|
return formatted;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
/** 这两种不可用原因随订单内容变化,其他服务端错误需保留。 */
|
|
30
|
+
export var isWalletOrderAvailabilityError = function isWalletOrderAvailabilityError(code) {
|
|
31
|
+
return String(code) === '500601' || String(code) === '500602';
|
|
32
|
+
};
|
|
33
|
+
|
|
29
34
|
/**
|
|
30
35
|
* 对用户识别码列表进行排序
|
|
31
36
|
* 排序规则:正常数据 -> unified_available_status===1 -> 500601/500602 -> unified_available_status===0
|
|
@@ -36,9 +41,6 @@ export var sortUserIdentificationCodeList = function sortUserIdentificationCodeL
|
|
|
36
41
|
if (!Array.isArray(list) || list.length === 0) {
|
|
37
42
|
return list;
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
// 定义中等优先级错误码
|
|
41
|
-
var middlePriorityErrorCodes = ['500601', '500602'];
|
|
42
44
|
return list.sort(function (a, b) {
|
|
43
45
|
// 确定每个项目的优先级
|
|
44
46
|
// 0: 正常数据(没有特定错误码且available_status不是1或0)
|
|
@@ -46,12 +48,10 @@ export var sortUserIdentificationCodeList = function sortUserIdentificationCodeL
|
|
|
46
48
|
// 2: 中等优先级错误码(500601、500602) 此订单内不可用 订单没有剩余金额
|
|
47
49
|
// 3: unified_available_status === 0(最后)
|
|
48
50
|
var getPriority = function getPriority(item) {
|
|
49
|
-
var _item$unified_error_c;
|
|
50
|
-
var errorCode = (_item$unified_error_c = item.unified_error_code) === null || _item$unified_error_c === void 0 ? void 0 : _item$unified_error_c.toString();
|
|
51
51
|
var availableStatus = item.unified_available_status;
|
|
52
52
|
|
|
53
53
|
// 中等优先级错误码
|
|
54
|
-
if (
|
|
54
|
+
if (isWalletOrderAvailabilityError(item.unified_error_code)) return 2;
|
|
55
55
|
|
|
56
56
|
// unified_available_status === 0 最后
|
|
57
57
|
if (availableStatus === 0) return 3;
|
|
@@ -23,6 +23,8 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
23
23
|
*/
|
|
24
24
|
private emitEvent;
|
|
25
25
|
private publishWalletAssetsState;
|
|
26
|
+
private get hasEmptyWalletCart();
|
|
27
|
+
private walletAssetForEmptyCart;
|
|
26
28
|
private recalculateWalletAssets;
|
|
27
29
|
/**
|
|
28
30
|
* 搜索接口只返回后端 Wallet Pass 数据,不包含前端策略 config。
|
|
@@ -21,8 +21,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
21
21
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
22
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
23
23
|
import { WalletPassHooks } from "./types";
|
|
24
|
-
import {
|
|
24
|
+
import { locales as walletPassLocales } from "../../model/strategy/adapter/walletPass/locales";
|
|
25
|
+
import { formatWalletPassList2PreparePayments as formatWalletPassList2PreparePaymentsUtils, isWalletOrderAvailabilityError, sortUserIdentificationCodeList } from "./utils";
|
|
25
26
|
var WALLET_PAYMENT_ASSET_TAGS = new Set(['product_voucher', 'gift_card', 'point_card']);
|
|
27
|
+
|
|
28
|
+
// 旧版搜索响应可能只有订单不适用的提示文本,没有 unified_error_code。
|
|
29
|
+
var LEGACY_CART_MESSAGES = new Set(['Voucher not applicable to current cart', 'No eligible items in the cart', walletPassLocales.en.exceeds_the_maximum_deduction_limit]);
|
|
26
30
|
function isWalletPaymentAsset(asset) {
|
|
27
31
|
return WALLET_PAYMENT_ASSET_TAGS.has(String((asset === null || asset === void 0 ? void 0 : asset.tag) || '').toLowerCase());
|
|
28
32
|
}
|
|
@@ -207,10 +211,41 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
207
211
|
});
|
|
208
212
|
return state;
|
|
209
213
|
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "hasEmptyWalletCart",
|
|
216
|
+
get: function get() {
|
|
217
|
+
return this.walletParams !== null && this.walletAssetsCalculationContext.products.length === 0;
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "walletAssetForEmptyCart",
|
|
221
|
+
value: function walletAssetForEmptyCart(asset) {
|
|
222
|
+
var _asset$unified_messag, _this$paymentModule$w, _this$paymentModule$w2, _evaluator$getText;
|
|
223
|
+
var unavailableAsset = _objectSpread(_objectSpread({}, asset), {}, {
|
|
224
|
+
actualDeduction: 0,
|
|
225
|
+
deductionDetails: [],
|
|
226
|
+
_available_max_amount: 0,
|
|
227
|
+
_unified_available_status: 0,
|
|
228
|
+
_wallet_asset_recommended: false
|
|
229
|
+
});
|
|
230
|
+
var errorCode = asset.unified_error_code;
|
|
231
|
+
var reportedReason = ((_asset$unified_messag = asset.unified_messages) === null || _asset$unified_messag === void 0 ? void 0 : _asset$unified_messag.title) || asset.error_msg || asset.disabledReason;
|
|
232
|
+
var reportedUnavailable = Number(asset.unified_available_status) === 0 || asset.available === false || asset.isDisabled === true;
|
|
233
|
+
var hasAssetRestriction = errorCode ? !isWalletOrderAvailabilityError(errorCode) : reportedUnavailable && reportedReason && !LEGACY_CART_MESSAGES.has(reportedReason);
|
|
234
|
+
if (hasAssetRestriction) {
|
|
235
|
+
return unavailableAsset;
|
|
236
|
+
}
|
|
237
|
+
var evaluator = (_this$paymentModule$w = this.paymentModule.window) === null || _this$paymentModule$w === void 0 || (_this$paymentModule$w2 = _this$paymentModule$w.getWalletPassEvaluator) === null || _this$paymentModule$w2 === void 0 ? void 0 : _this$paymentModule$w2.call(_this$paymentModule$w);
|
|
238
|
+
return _objectSpread(_objectSpread({}, unavailableAsset), {}, {
|
|
239
|
+
reasonCode: 'empty_cart',
|
|
240
|
+
reason: (evaluator === null || evaluator === void 0 || (_evaluator$getText = evaluator.getText) === null || _evaluator$getText === void 0 ? void 0 : _evaluator$getText.call(evaluator, 'empty_cart')) || walletPassLocales.en.empty_cart
|
|
241
|
+
});
|
|
242
|
+
}
|
|
210
243
|
}, {
|
|
211
244
|
key: "recalculateWalletAssets",
|
|
212
245
|
value: function recalculateWalletAssets(items, requestedIds, selectionSources) {
|
|
213
|
-
var _this$paymentModule$
|
|
246
|
+
var _this$paymentModule$w3,
|
|
247
|
+
_this$paymentModule$w4,
|
|
248
|
+
_this = this;
|
|
214
249
|
var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
|
|
215
250
|
return String(id);
|
|
216
251
|
}));
|
|
@@ -228,8 +263,13 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
228
263
|
});
|
|
229
264
|
var nextItems = items;
|
|
230
265
|
var selectedItems = requested;
|
|
231
|
-
var evaluator = (_this$paymentModule$
|
|
232
|
-
if (
|
|
266
|
+
var evaluator = (_this$paymentModule$w3 = this.paymentModule.window) === null || _this$paymentModule$w3 === void 0 || (_this$paymentModule$w4 = _this$paymentModule$w3.getWalletPassEvaluator) === null || _this$paymentModule$w4 === void 0 ? void 0 : _this$paymentModule$w4.call(_this$paymentModule$w3);
|
|
267
|
+
if (this.hasEmptyWalletCart) {
|
|
268
|
+
nextItems = items.map(function (asset) {
|
|
269
|
+
return committedKeys.has(getWalletAssetKey(asset)) ? asset : _this.walletAssetForEmptyCart(asset);
|
|
270
|
+
});
|
|
271
|
+
selectedItems = [];
|
|
272
|
+
} else if (evaluator !== null && evaluator !== void 0 && evaluator.recalculateVouchers) {
|
|
233
273
|
try {
|
|
234
274
|
var result = evaluator.recalculateVouchers(items, requested, this.walletAssetsCalculationContext.orderTotalAmount, this.walletAssetsCalculationContext.products);
|
|
235
275
|
nextItems = mergeWalletAssets(items, (result === null || result === void 0 ? void 0 : result.allWithUpdatedStatus) || []);
|
|
@@ -278,10 +318,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
278
318
|
}, {
|
|
279
319
|
key: "formatSearchedWalletPaymentAssets",
|
|
280
320
|
value: function formatSearchedWalletPaymentAssets(assets) {
|
|
281
|
-
var _this$paymentModule$
|
|
321
|
+
var _this$paymentModule$w5, _this$paymentModule$w6, _this$walletParams, _this$walletParams2;
|
|
282
322
|
if (!assets.length) return assets;
|
|
283
323
|
var assetsWithRecalculationBase = assets.map(withWalletAssetRecalculationBaseAmount);
|
|
284
|
-
var evaluator = (_this$paymentModule$
|
|
324
|
+
var evaluator = (_this$paymentModule$w5 = this.paymentModule.window) === null || _this$paymentModule$w5 === void 0 || (_this$paymentModule$w6 = _this$paymentModule$w5.getWalletPassEvaluator) === null || _this$paymentModule$w6 === void 0 ? void 0 : _this$paymentModule$w6.call(_this$paymentModule$w5);
|
|
285
325
|
if (!(evaluator !== null && evaluator !== void 0 && evaluator.searchVoucherFormat)) return assetsWithRecalculationBase;
|
|
286
326
|
var hasCalculationProducts = this.walletAssetsCalculationContext.products.length > 0;
|
|
287
327
|
var products = hasCalculationProducts ? this.walletAssetsCalculationContext.products : ((_this$walletParams = this.walletParams) === null || _this$walletParams === void 0 ? void 0 : _this$walletParams.products) || [];
|
|
@@ -356,27 +396,27 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
356
396
|
}, {
|
|
357
397
|
key: "isPendingAutoSelectAsset",
|
|
358
398
|
value: function isPendingAutoSelectAsset(asset) {
|
|
359
|
-
var
|
|
399
|
+
var _this2 = this;
|
|
360
400
|
return getWalletAssetCodeKeys(asset).some(function (code) {
|
|
361
|
-
return
|
|
401
|
+
return _this2.pendingAutoSelectSearchCodes.has(code);
|
|
362
402
|
});
|
|
363
403
|
}
|
|
364
404
|
}, {
|
|
365
405
|
key: "clearPendingAutoSelectForAsset",
|
|
366
406
|
value: function clearPendingAutoSelectForAsset(asset) {
|
|
367
|
-
var
|
|
407
|
+
var _this3 = this;
|
|
368
408
|
getWalletAssetCodeKeys(asset).forEach(function (code) {
|
|
369
|
-
|
|
409
|
+
_this3.pendingAutoSelectSearchCodes.delete(code);
|
|
370
410
|
});
|
|
371
411
|
}
|
|
372
412
|
}, {
|
|
373
413
|
key: "queuePendingAutoSelectForAssets",
|
|
374
414
|
value: function queuePendingAutoSelectForAssets(assets) {
|
|
375
|
-
var
|
|
415
|
+
var _this4 = this;
|
|
376
416
|
if (!this.walletAssetsBehavior.autoSelectAfterSearch) return;
|
|
377
417
|
assets.forEach(function (asset) {
|
|
378
418
|
getWalletAssetCodeKeys(asset).forEach(function (code) {
|
|
379
|
-
|
|
419
|
+
_this4.pendingAutoSelectSearchCodes.add(code);
|
|
380
420
|
});
|
|
381
421
|
});
|
|
382
422
|
}
|
|
@@ -601,7 +641,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
601
641
|
key: "initializeWalletDataAsync",
|
|
602
642
|
value: (function () {
|
|
603
643
|
var _initializeWalletDataAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(baseParams) {
|
|
604
|
-
var _this$paymentModule$
|
|
644
|
+
var _this$paymentModule$w7, _this$paymentModule$w8, identificationParams, _yield$Promise$all, _yield$Promise$all2, allList, orderBasicDetail, walletPassEvaluator, products, res, recommended, transformList, noApplicableVoucher, recommendedAmount;
|
|
605
645
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
606
646
|
while (1) switch (_context3.prev = _context3.next) {
|
|
607
647
|
case 0:
|
|
@@ -620,7 +660,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
620
660
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
621
661
|
allList = _yield$Promise$all2[0];
|
|
622
662
|
orderBasicDetail = _yield$Promise$all2[1];
|
|
623
|
-
walletPassEvaluator = (_this$paymentModule$
|
|
663
|
+
walletPassEvaluator = (_this$paymentModule$w7 = this.paymentModule.window) === null || _this$paymentModule$w7 === void 0 || (_this$paymentModule$w8 = _this$paymentModule$w7.getWalletPassEvaluator) === null || _this$paymentModule$w8 === void 0 ? void 0 : _this$paymentModule$w8.call(_this$paymentModule$w7);
|
|
624
664
|
if (walletPassEvaluator) {
|
|
625
665
|
_context3.next = 11;
|
|
626
666
|
break;
|
|
@@ -687,7 +727,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
687
727
|
key: "aggregateRecalculateWalletAssetsAsync",
|
|
688
728
|
value: (function () {
|
|
689
729
|
var _aggregateRecalculateWalletAssetsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessData, selectedIds) {
|
|
690
|
-
var _this$paymentModule$
|
|
730
|
+
var _this$paymentModule$w9, _this$paymentModule$w10;
|
|
691
731
|
var walletParams, customerId, requestParams, response, responseData, hasAggregateLists, recalculateList, customerWalletPassList, orderedRecalculateList, allList, walletPassEvaluator, evaluated, returnedSelectedKeys, authoritativeSelectedIds;
|
|
692
732
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
693
733
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -726,7 +766,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
726
766
|
customerWalletPassList = Array.isArray(responseData === null || responseData === void 0 ? void 0 : responseData.customer_wallet_pass_list) ? responseData.customer_wallet_pass_list : [];
|
|
727
767
|
orderedRecalculateList = orderWalletAssetsByIds(recalculateList, selectedIds);
|
|
728
768
|
allList = mergeWalletAssets(orderedRecalculateList, customerWalletPassList);
|
|
729
|
-
walletPassEvaluator = (_this$paymentModule$
|
|
769
|
+
walletPassEvaluator = (_this$paymentModule$w9 = this.paymentModule.window) === null || _this$paymentModule$w9 === void 0 || (_this$paymentModule$w10 = _this$paymentModule$w9.getWalletPassEvaluator) === null || _this$paymentModule$w10 === void 0 ? void 0 : _this$paymentModule$w10.call(_this$paymentModule$w9);
|
|
730
770
|
evaluated = walletPassEvaluator !== null && walletPassEvaluator !== void 0 && walletPassEvaluator.getRecommendedVouchers ? walletPassEvaluator.getRecommendedVouchers({
|
|
731
771
|
orderTotalAmount: walletParams.order_wait_pay_amount,
|
|
732
772
|
products: walletParams.products,
|
|
@@ -1119,7 +1159,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1119
1159
|
value: (function () {
|
|
1120
1160
|
var _refreshWalletAssetsFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(businessData) {
|
|
1121
1161
|
var _businessData$product2,
|
|
1122
|
-
|
|
1162
|
+
_this5 = this;
|
|
1123
1163
|
var options,
|
|
1124
1164
|
requestSequence,
|
|
1125
1165
|
nextCustomerId,
|
|
@@ -1207,13 +1247,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1207
1247
|
this.queuePendingAutoSelectForAssets(scanSelectedAssets);
|
|
1208
1248
|
this.generateWalletParams(businessData);
|
|
1209
1249
|
restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map(function (item) {
|
|
1210
|
-
return
|
|
1211
|
-
actualDeduction: 0,
|
|
1212
|
-
deductionDetails: [],
|
|
1213
|
-
_available_max_amount: 0,
|
|
1214
|
-
_unified_available_status: 0,
|
|
1215
|
-
_wallet_asset_recommended: false
|
|
1216
|
-
});
|
|
1250
|
+
return _this5.walletAssetForEmptyCart(item);
|
|
1217
1251
|
});
|
|
1218
1252
|
this.walletRecommendList = [];
|
|
1219
1253
|
this.userIdentificationCodes = [];
|
|
@@ -1325,7 +1359,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1325
1359
|
latestSelectedIds = preserveSelection ? authoritativeSelectedIds : [];
|
|
1326
1360
|
latestSelectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
|
|
1327
1361
|
pendingAutoSelectAssets = this.walletAssetsBehavior.autoSelectAfterSearch ? items.filter(function (asset) {
|
|
1328
|
-
return
|
|
1362
|
+
return _this5.isPendingAutoSelectAsset(asset) && isWalletAssetAvailable(asset);
|
|
1329
1363
|
}) : [];
|
|
1330
1364
|
requestedKeySet = new Set(latestSelectedIds.map(function (id) {
|
|
1331
1365
|
return String(id);
|
|
@@ -1347,7 +1381,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1347
1381
|
pendingAutoSelectAssets.forEach(function (asset) {
|
|
1348
1382
|
var assetId = getWalletAssetId(asset);
|
|
1349
1383
|
if (assetId !== undefined && assetId !== null && selectedKeySet.has(String(assetId))) {
|
|
1350
|
-
|
|
1384
|
+
_this5.clearPendingAutoSelectForAsset(asset);
|
|
1351
1385
|
}
|
|
1352
1386
|
});
|
|
1353
1387
|
droppedScanSelectedAssets = scanSelectedAssets.filter(function (asset) {
|
|
@@ -1525,7 +1559,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1525
1559
|
key: "scanWalletAssetAsync",
|
|
1526
1560
|
value: function () {
|
|
1527
1561
|
var _scanWalletAssetAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code) {
|
|
1528
|
-
var normalizedCode, selectedAsset, result, paymentAssets, matchedAsset, assetsToApply, asset, _items, assetIds, selectionSources, _selected, items, recalculatedState, assetId, recalculatedAsset, selected, isSelected, selectedStateAsset, resolvedAsset;
|
|
1562
|
+
var normalizedCode, selectedAsset, result, paymentAssets, matchedAsset, assetsToApply, asset, _items, assetIds, selectionSources, _selected, anySelected, firstAssetKey, items, recalculatedState, assetId, recalculatedAsset, selected, isSelected, selectedStateAsset, resolvedAsset;
|
|
1529
1563
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1530
1564
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1531
1565
|
case 0:
|
|
@@ -1595,7 +1629,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1595
1629
|
});
|
|
1596
1630
|
case 19:
|
|
1597
1631
|
if (!(!matchedAsset && assetsToApply.length > 1)) {
|
|
1598
|
-
_context9.next =
|
|
1632
|
+
_context9.next = 29;
|
|
1599
1633
|
break;
|
|
1600
1634
|
}
|
|
1601
1635
|
_items = mergeWalletAssets(this.walletAssetsState.items, assetsToApply);
|
|
@@ -1609,15 +1643,22 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1609
1643
|
selectionSources[String(id)] = 'scan';
|
|
1610
1644
|
});
|
|
1611
1645
|
_selected = this.walletAssetsBehavior.autoSelectAfterSearch ? this.recalculateWalletAssets(_items, Array.from(new Set([].concat(_toConsumableArray(this.walletAssetsState.selectedIds), _toConsumableArray(assetIds)))), selectionSources) : this.recalculateWalletAssets(_items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1646
|
+
anySelected = assetIds.some(function (id) {
|
|
1647
|
+
return _selected.selectedIds.includes(id);
|
|
1648
|
+
});
|
|
1649
|
+
if (this.hasEmptyWalletCart) {
|
|
1650
|
+
this.queuePendingAutoSelectForAssets(assetsToApply);
|
|
1651
|
+
}
|
|
1652
|
+
firstAssetKey = getWalletAssetKey(asset);
|
|
1612
1653
|
return _context9.abrupt("return", {
|
|
1613
1654
|
type: result.type,
|
|
1614
|
-
asset:
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1655
|
+
asset: _selected.items.find(function (item) {
|
|
1656
|
+
return getWalletAssetKey(item) === firstAssetKey;
|
|
1657
|
+
}) || asset,
|
|
1658
|
+
selected: anySelected,
|
|
1618
1659
|
state: _selected
|
|
1619
1660
|
});
|
|
1620
|
-
case
|
|
1661
|
+
case 29:
|
|
1621
1662
|
items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
|
|
1622
1663
|
recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1623
1664
|
assetId = getWalletAssetId(asset);
|
|
@@ -1647,7 +1688,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
1647
1688
|
selected: isSelected,
|
|
1648
1689
|
state: selected
|
|
1649
1690
|
});
|
|
1650
|
-
case
|
|
1691
|
+
case 39:
|
|
1651
1692
|
case "end":
|
|
1652
1693
|
return _context9.stop();
|
|
1653
1694
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "normal" | "session";
|
|
53
53
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -6287,7 +6287,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6287
6287
|
key: "ensureCheckoutOrderNumbers",
|
|
6288
6288
|
value: function () {
|
|
6289
6289
|
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data, title) {
|
|
6290
|
-
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
6290
|
+
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator, _idGenerator$getConfi, _biz;
|
|
6291
6291
|
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6292
6292
|
while (1) switch (_context64.prev = _context64.next) {
|
|
6293
6293
|
case 0:
|
|
@@ -6329,36 +6329,49 @@ var Server = /*#__PURE__*/function () {
|
|
|
6329
6329
|
case 15:
|
|
6330
6330
|
next.shop_order_number = _context64.sent;
|
|
6331
6331
|
case 16:
|
|
6332
|
-
if (!
|
|
6333
|
-
_context64.next =
|
|
6332
|
+
if (!needsShopFullOrderNumber) {
|
|
6333
|
+
_context64.next = 26;
|
|
6334
6334
|
break;
|
|
6335
6335
|
}
|
|
6336
|
-
|
|
6336
|
+
_biz = next.business_code || 'ticket';
|
|
6337
|
+
if (!(((_idGenerator$getConfi = idGenerator.getConfig) === null || _idGenerator$getConfi === void 0 || (_idGenerator$getConfi = _idGenerator$getConfi.call(idGenerator, _biz)) === null || _idGenerator$getConfi === void 0 ? void 0 : _idGenerator$getConfi.enableShortNumber) === false)) {
|
|
6338
|
+
_context64.next = 22;
|
|
6339
|
+
break;
|
|
6340
|
+
}
|
|
6341
|
+
next.shop_full_order_number = next.shop_order_number;
|
|
6342
|
+
_context64.next = 26;
|
|
6343
|
+
break;
|
|
6344
|
+
case 22:
|
|
6345
|
+
if (!idGenerator.generateReceiptId) {
|
|
6346
|
+
_context64.next = 26;
|
|
6347
|
+
break;
|
|
6348
|
+
}
|
|
6349
|
+
_context64.next = 25;
|
|
6337
6350
|
return idGenerator.generateReceiptId({
|
|
6338
|
-
biz:
|
|
6351
|
+
biz: _biz
|
|
6339
6352
|
});
|
|
6340
|
-
case
|
|
6353
|
+
case 25:
|
|
6341
6354
|
next.shop_full_order_number = _context64.sent;
|
|
6342
|
-
case
|
|
6355
|
+
case 26:
|
|
6343
6356
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
6344
6357
|
shop_order_number: next.shop_order_number,
|
|
6345
6358
|
shop_full_order_number: next.shop_full_order_number
|
|
6346
6359
|
});
|
|
6347
|
-
_context64.next =
|
|
6360
|
+
_context64.next = 32;
|
|
6348
6361
|
break;
|
|
6349
|
-
case
|
|
6350
|
-
_context64.prev =
|
|
6362
|
+
case 29:
|
|
6363
|
+
_context64.prev = 29;
|
|
6351
6364
|
_context64.t0 = _context64["catch"](11);
|
|
6352
6365
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
6353
6366
|
error: _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0)
|
|
6354
6367
|
});
|
|
6355
|
-
case
|
|
6368
|
+
case 32:
|
|
6356
6369
|
return _context64.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
6357
|
-
case
|
|
6370
|
+
case 33:
|
|
6358
6371
|
case "end":
|
|
6359
6372
|
return _context64.stop();
|
|
6360
6373
|
}
|
|
6361
|
-
}, _callee64, this, [[11,
|
|
6374
|
+
}, _callee64, this, [[11, 29]]);
|
|
6362
6375
|
}));
|
|
6363
6376
|
function ensureCheckoutOrderNumbers(_x67, _x68) {
|
|
6364
6377
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
@@ -35,8 +35,10 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
35
35
|
private syncTimer?;
|
|
36
36
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
37
37
|
private lastServerFullFetchAtMs;
|
|
38
|
-
/** 最近一次 preload 完成时间(含 IndexDB
|
|
38
|
+
/** 最近一次 preload 完成时间(含 IndexDB 命中,仅用于日志) */
|
|
39
39
|
private lastPreloadCompletedAtMs;
|
|
40
|
+
private serverFullFetchPromise?;
|
|
41
|
+
private silentRefreshPromise?;
|
|
40
42
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
41
43
|
private productIndexDBSaveQueue;
|
|
42
44
|
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
@@ -206,7 +208,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
206
208
|
*/
|
|
207
209
|
loadProductsByServer(options?: {
|
|
208
210
|
trigger?: string;
|
|
209
|
-
}): Promise<
|
|
211
|
+
}): Promise<ProductData[]>;
|
|
212
|
+
private fetchAndPersistProductsByServer;
|
|
210
213
|
/**
|
|
211
214
|
* 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
|
|
212
215
|
* @param params 查询参数
|
|
@@ -358,6 +361,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
358
361
|
silentRefresh(options?: {
|
|
359
362
|
trigger?: string;
|
|
360
363
|
}): Promise<ProductData[]>;
|
|
364
|
+
private runSilentRefresh;
|
|
361
365
|
/**
|
|
362
366
|
* 销毁同步资源(取消 pubsub 订阅、清除定时器)
|
|
363
367
|
*/
|