@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
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"
|
|
392
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
366
366
|
* 获取当前的客户搜索条件
|
|
367
367
|
* @returns 当前搜索条件
|
|
368
368
|
*/
|
|
369
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
369
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
370
370
|
/**
|
|
371
371
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
372
372
|
* @returns 客户状态
|
|
@@ -633,7 +633,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
633
633
|
value: function () {
|
|
634
634
|
var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
635
635
|
var _this$otherParams5, _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
|
|
636
|
-
var idGenerator, openDataConfig, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode, _openDataConfig7, _openDataConfig8, _openDataConfig9;
|
|
636
|
+
var idGenerator, openDataConfig, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode, _openDataConfig7, _openDataConfig8, _openDataConfig9, _openDataConfig10;
|
|
637
637
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
638
638
|
while (1) switch (_context10.prev = _context10.next) {
|
|
639
639
|
case 0:
|
|
@@ -694,12 +694,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
694
694
|
return idGenerator.configure({
|
|
695
695
|
biz: businessCode,
|
|
696
696
|
config: {
|
|
697
|
+
enableShortNumber: ((_openDataConfig7 = openDataConfig) === null || _openDataConfig7 === void 0 ? void 0 : _openDataConfig7['sale.enable_short_number']) !== false,
|
|
697
698
|
prefix: prefix,
|
|
698
699
|
deviceCode: deviceId,
|
|
699
|
-
padReceiptSequence: ((
|
|
700
|
+
padReceiptSequence: ((_openDataConfig8 = openDataConfig) === null || _openDataConfig8 === void 0 ? void 0 : _openDataConfig8['sale.pad_with_leading_zeros']) === true,
|
|
700
701
|
receiptSequenceLength: receiptSequenceLength,
|
|
701
|
-
receiptSequenceMax: this.normalizeShortNumberMaximum((
|
|
702
|
-
randomReceiptSequence: ((
|
|
702
|
+
receiptSequenceMax: this.normalizeShortNumberMaximum((_openDataConfig9 = openDataConfig) === null || _openDataConfig9 === void 0 ? void 0 : _openDataConfig9['sale.maximum_number']),
|
|
703
|
+
randomReceiptSequence: ((_openDataConfig10 = openDataConfig) === null || _openDataConfig10 === void 0 ? void 0 : _openDataConfig10['sale.short_number_random']) === true,
|
|
703
704
|
resetReceiptSequenceDaily: resetReceiptSequenceDaily,
|
|
704
705
|
receiptSequenceResetTime: operatingDayBoundary === null || operatingDayBoundary === void 0 ? void 0 : operatingDayBoundary.time,
|
|
705
706
|
receiptSequenceStart: receiptSequenceStart,
|
|
@@ -3506,7 +3507,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3506
3507
|
_context44.next = 9;
|
|
3507
3508
|
return this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
|
|
3508
3509
|
case 9:
|
|
3509
|
-
if (!((params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined)) {
|
|
3510
|
+
if (!((params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined || Object.prototype.hasOwnProperty.call(params !== null && params !== void 0 ? params : {}, 'openData'))) {
|
|
3510
3511
|
_context44.next = 12;
|
|
3511
3512
|
break;
|
|
3512
3513
|
}
|
|
@@ -24,23 +24,28 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
24
24
|
products: import("../../../modules/Order/types").OrderSubmitProduct[];
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
status: string;
|
|
28
|
+
metadata: Record<string, any>;
|
|
29
|
+
business_code?: string | undefined;
|
|
30
30
|
customer_id: number | null;
|
|
31
|
+
type: string;
|
|
32
|
+
holder: Record<string, any> | null;
|
|
33
|
+
email: string;
|
|
34
|
+
phone: string;
|
|
35
|
+
note: string;
|
|
36
|
+
relation_forms: any[];
|
|
37
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
38
|
+
country_calling_code: string;
|
|
39
|
+
contacts_info: Record<string, any> | null;
|
|
31
40
|
order_id: number | null;
|
|
41
|
+
external_sale_number: string;
|
|
32
42
|
order_number: string | null;
|
|
33
43
|
shop_order_number: string | null;
|
|
34
|
-
|
|
35
|
-
business_code?: string | undefined;
|
|
44
|
+
shop_full_order_number: string | null;
|
|
36
45
|
sales_channel: string;
|
|
37
46
|
order_sales_channel: string;
|
|
38
|
-
status: string;
|
|
39
47
|
shipping_status: string;
|
|
40
48
|
customer_name: string;
|
|
41
|
-
country_calling_code: string;
|
|
42
|
-
phone: string;
|
|
43
|
-
email: string;
|
|
44
49
|
is_price_include_tax: number;
|
|
45
50
|
tax_title: string;
|
|
46
51
|
tax_country_code: string;
|
|
@@ -51,21 +56,16 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
51
56
|
deposit_amount: string;
|
|
52
57
|
shop_discount: string;
|
|
53
58
|
surcharge_fee: string;
|
|
54
|
-
|
|
59
|
+
buzzer?: string | undefined;
|
|
60
|
+
delivery_type?: string | undefined;
|
|
61
|
+
table_number?: Record<string, any> | undefined;
|
|
55
62
|
schedule_date: string;
|
|
63
|
+
bookings: any[];
|
|
64
|
+
payments: any[];
|
|
65
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
56
66
|
refunds?: any[] | undefined;
|
|
57
67
|
surcharges: any[];
|
|
58
|
-
relation_forms: any[];
|
|
59
68
|
contacts: any[];
|
|
60
|
-
contacts_info: Record<string, any> | null;
|
|
61
|
-
holder: Record<string, any> | null;
|
|
62
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
63
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
64
|
-
metadata: Record<string, any>;
|
|
65
|
-
buzzer?: string | undefined;
|
|
66
|
-
shop_full_order_number: string | null;
|
|
67
|
-
delivery_type?: string | undefined;
|
|
68
|
-
table_number?: Record<string, any> | undefined;
|
|
69
69
|
};
|
|
70
70
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
71
71
|
schedule_event_id: any;
|
|
@@ -474,7 +474,7 @@ function _applyGlobalScan() {
|
|
|
474
474
|
case 15:
|
|
475
475
|
// 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
|
|
476
476
|
if (!bindResult.resolveFailed) {
|
|
477
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify11 = bridge.onNotify) === null || _bridge$onNotify11 === void 0 || _bridge$onNotify11.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
|
|
477
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify11 = bridge.onNotify) === null || _bridge$onNotify11 === void 0 || _bridge$onNotify11.call(bridge, 'fail', walletResult.asset.reasonCode === 'empty_cart' ? 'pisell2.sale-detail.promotion-panel.add-items-first' : 'pisell2.text.goodpass.code-invalid-cart');
|
|
478
478
|
}
|
|
479
479
|
return _context5.abrupt("return", {
|
|
480
480
|
status: 'failed',
|
|
@@ -2573,8 +2573,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2573
2573
|
key: "ensureLocalOrderNumbersForCheckout",
|
|
2574
2574
|
value: (function () {
|
|
2575
2575
|
var _ensureLocalOrderNumbersForCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2576
|
-
var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
|
|
2577
|
-
var order, tempOrder, biz, idGenerator;
|
|
2576
|
+
var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2, _idGenerator$getConfi;
|
|
2577
|
+
var order, tempOrder, biz, idGenerator, useLongNumber;
|
|
2578
2578
|
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
2579
2579
|
while (1) switch (_context10.prev = _context10.next) {
|
|
2580
2580
|
case 0:
|
|
@@ -2606,56 +2606,67 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2606
2606
|
throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
2607
2607
|
case 11:
|
|
2608
2608
|
idGenerator = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getAp = _this$appPlugin.getApp) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp = _this$appPlugin$getAp.call(_this$appPlugin)) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp2 = _this$appPlugin$getAp.getPlugin) === null || _this$appPlugin$getAp2 === void 0 ? void 0 : _this$appPlugin$getAp2.call(_this$appPlugin$getAp, 'idGenerator');
|
|
2609
|
-
|
|
2610
|
-
|
|
2609
|
+
useLongNumber = (idGenerator === null || idGenerator === void 0 || (_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;
|
|
2610
|
+
if (!(!tempOrder.shop_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateShopOrderNumber) !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateReceiptId) !== 'function')) {
|
|
2611
|
+
_context10.next = 15;
|
|
2611
2612
|
break;
|
|
2612
2613
|
}
|
|
2613
2614
|
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
2614
|
-
case
|
|
2615
|
-
_context10.prev =
|
|
2615
|
+
case 15:
|
|
2616
|
+
_context10.prev = 15;
|
|
2616
2617
|
if (tempOrder.shop_order_number) {
|
|
2617
|
-
_context10.next =
|
|
2618
|
+
_context10.next = 20;
|
|
2618
2619
|
break;
|
|
2619
2620
|
}
|
|
2620
|
-
_context10.next =
|
|
2621
|
+
_context10.next = 19;
|
|
2621
2622
|
return idGenerator.generateShopOrderNumber({
|
|
2622
2623
|
biz: biz
|
|
2623
2624
|
});
|
|
2624
|
-
case 18:
|
|
2625
|
-
tempOrder.shop_order_number = _context10.sent;
|
|
2626
2625
|
case 19:
|
|
2626
|
+
tempOrder.shop_order_number = _context10.sent;
|
|
2627
|
+
case 20:
|
|
2627
2628
|
if (tempOrder.shop_full_order_number) {
|
|
2628
|
-
_context10.next =
|
|
2629
|
+
_context10.next = 29;
|
|
2629
2630
|
break;
|
|
2630
2631
|
}
|
|
2631
|
-
|
|
2632
|
+
if (!useLongNumber) {
|
|
2633
|
+
_context10.next = 25;
|
|
2634
|
+
break;
|
|
2635
|
+
}
|
|
2636
|
+
_context10.t0 = tempOrder.shop_order_number;
|
|
2637
|
+
_context10.next = 28;
|
|
2638
|
+
break;
|
|
2639
|
+
case 25:
|
|
2640
|
+
_context10.next = 27;
|
|
2632
2641
|
return idGenerator.generateReceiptId({
|
|
2633
2642
|
biz: biz
|
|
2634
2643
|
});
|
|
2635
|
-
case
|
|
2636
|
-
|
|
2637
|
-
case
|
|
2644
|
+
case 27:
|
|
2645
|
+
_context10.t0 = _context10.sent;
|
|
2646
|
+
case 28:
|
|
2647
|
+
tempOrder.shop_full_order_number = _context10.t0;
|
|
2648
|
+
case 29:
|
|
2638
2649
|
if (!(order.getTempOrder() !== tempOrder)) {
|
|
2639
|
-
_context10.next =
|
|
2650
|
+
_context10.next = 31;
|
|
2640
2651
|
break;
|
|
2641
2652
|
}
|
|
2642
2653
|
throw new Error('当前订单已切换,请重新发起支付');
|
|
2643
|
-
case
|
|
2654
|
+
case 31:
|
|
2644
2655
|
if (!(!tempOrder.shop_order_number || !tempOrder.shop_full_order_number)) {
|
|
2645
|
-
_context10.next =
|
|
2656
|
+
_context10.next = 33;
|
|
2646
2657
|
break;
|
|
2647
2658
|
}
|
|
2648
2659
|
throw new Error('订单编号生成失败,请重试');
|
|
2649
|
-
case
|
|
2650
|
-
_context10.prev =
|
|
2660
|
+
case 33:
|
|
2661
|
+
_context10.prev = 33;
|
|
2651
2662
|
// 部分生成成功时也保留号码,后续只补仍然缺失的字段。
|
|
2652
2663
|
if (order.getTempOrder() === tempOrder) order.persistTempOrder();
|
|
2653
|
-
return _context10.finish(
|
|
2654
|
-
case
|
|
2664
|
+
return _context10.finish(33);
|
|
2665
|
+
case 36:
|
|
2655
2666
|
case "end":
|
|
2656
2667
|
return _context10.stop();
|
|
2657
2668
|
}
|
|
2658
|
-
}, _callee9, this, [[
|
|
2669
|
+
}, _callee9, this, [[15,, 33, 36]]);
|
|
2659
2670
|
}));
|
|
2660
2671
|
function ensureLocalOrderNumbersForCheckout() {
|
|
2661
2672
|
return _ensureLocalOrderNumbersForCheckout.apply(this, arguments);
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.locales = void 0;
|
|
7
7
|
const locales = exports.locales = {
|
|
8
8
|
'zh-CN': {
|
|
9
|
+
'empty_cart': '请先添加商品到购物车',
|
|
9
10
|
'not_meet_the_required_conditions': '未达到使用条件',
|
|
10
11
|
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金额限制',
|
|
11
12
|
'usage_limit_reached': '已达到使用次数上限',
|
|
@@ -17,6 +18,7 @@ const locales = exports.locales = {
|
|
|
17
18
|
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
18
19
|
},
|
|
19
20
|
'en': {
|
|
21
|
+
'empty_cart': 'Add items to the cart first.',
|
|
20
22
|
'not_meet_the_required_conditions': 'Not meet the required conditions.',
|
|
21
23
|
'exceeds_the_maximum_deduction_limit': 'Exceeds the maximum deduction limit.',
|
|
22
24
|
'usage_limit_reached': 'Usage limit reached.',
|
|
@@ -28,6 +30,7 @@ const locales = exports.locales = {
|
|
|
28
30
|
'applicable_product_count_not_enough': 'Min. Qty {value}'
|
|
29
31
|
},
|
|
30
32
|
'zh-HK': {
|
|
33
|
+
'empty_cart': '請先添加商品到購物車',
|
|
31
34
|
'not_meet_the_required_conditions': '未達使用條件',
|
|
32
35
|
'exceeds_the_maximum_deduction_limit': '超出最大抵扣金額限制',
|
|
33
36
|
'usage_limit_reached': '已達使用次數上限',
|
|
@@ -37,5 +40,11 @@ const locales = exports.locales = {
|
|
|
37
40
|
'order_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
38
41
|
'applicable_product_total_amount_not_enough': '滿 {currency}{value} 可用',
|
|
39
42
|
'applicable_product_count_not_enough': '至少 {value} 件'
|
|
43
|
+
},
|
|
44
|
+
'ja': {
|
|
45
|
+
'empty_cart': '先に商品をカートに追加してください。'
|
|
46
|
+
},
|
|
47
|
+
'pt': {
|
|
48
|
+
'empty_cart': 'Adicione produtos ao carrinho primeiro.'
|
|
40
49
|
}
|
|
41
50
|
};
|
|
@@ -1090,6 +1090,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1090
1090
|
}) : null;
|
|
1091
1091
|
try {
|
|
1092
1092
|
const giftResult = await this.giftSelectResolver({
|
|
1093
|
+
inventoryReserved: tempOrder.products.map(line => ({
|
|
1094
|
+
product_id: Number(line.product_id),
|
|
1095
|
+
product_variant_id: Number(line.product_variant_id || 0),
|
|
1096
|
+
quantity: Number(line.num) || 0
|
|
1097
|
+
})),
|
|
1093
1098
|
strategyId: addAction.strategyId,
|
|
1094
1099
|
strategyName: addAction.strategyName,
|
|
1095
1100
|
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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sortUserIdentificationCodeList = exports.getAvailableMaxAmount = exports.formatWalletPassList2PreparePayments = void 0;
|
|
6
|
+
exports.sortUserIdentificationCodeList = exports.isWalletOrderAvailabilityError = exports.getAvailableMaxAmount = exports.formatWalletPassList2PreparePayments = void 0;
|
|
7
7
|
// 获取walletPass可用最大金额
|
|
8
8
|
const getAvailableMaxAmount = data => {
|
|
9
9
|
if (typeof data._available_max_amount === 'number') {
|
|
@@ -32,20 +32,21 @@ const formatWalletPassList2PreparePayments = list => {
|
|
|
32
32
|
return formatted;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
/** 这两种不可用原因随订单内容变化,其他服务端错误需保留。 */
|
|
36
|
+
exports.formatWalletPassList2PreparePayments = formatWalletPassList2PreparePayments;
|
|
37
|
+
const isWalletOrderAvailabilityError = code => String(code) === '500601' || String(code) === '500602';
|
|
38
|
+
|
|
35
39
|
/**
|
|
36
40
|
* 对用户识别码列表进行排序
|
|
37
41
|
* 排序规则:正常数据 -> unified_available_status===1 -> 500601/500602 -> unified_available_status===0
|
|
38
42
|
* @param list 用户识别码列表
|
|
39
43
|
* @returns 排序后的列表
|
|
40
44
|
*/
|
|
41
|
-
exports.
|
|
45
|
+
exports.isWalletOrderAvailabilityError = isWalletOrderAvailabilityError;
|
|
42
46
|
const sortUserIdentificationCodeList = list => {
|
|
43
47
|
if (!Array.isArray(list) || list.length === 0) {
|
|
44
48
|
return list;
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
// 定义中等优先级错误码
|
|
48
|
-
const middlePriorityErrorCodes = ['500601', '500602'];
|
|
49
50
|
return list.sort((a, b) => {
|
|
50
51
|
// 确定每个项目的优先级
|
|
51
52
|
// 0: 正常数据(没有特定错误码且available_status不是1或0)
|
|
@@ -53,11 +54,10 @@ const sortUserIdentificationCodeList = list => {
|
|
|
53
54
|
// 2: 中等优先级错误码(500601、500602) 此订单内不可用 订单没有剩余金额
|
|
54
55
|
// 3: unified_available_status === 0(最后)
|
|
55
56
|
const getPriority = item => {
|
|
56
|
-
const errorCode = item.unified_error_code?.toString();
|
|
57
57
|
const availableStatus = item.unified_available_status;
|
|
58
58
|
|
|
59
59
|
// 中等优先级错误码
|
|
60
|
-
if (
|
|
60
|
+
if (isWalletOrderAvailabilityError(item.unified_error_code)) return 2;
|
|
61
61
|
|
|
62
62
|
// unified_available_status === 0 最后
|
|
63
63
|
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。
|
|
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.WalletPassPaymentImpl = void 0;
|
|
7
7
|
var _types = require("./types");
|
|
8
|
+
var _locales = require("../../model/strategy/adapter/walletPass/locales");
|
|
8
9
|
var _utils = require("./utils");
|
|
9
10
|
const WALLET_PAYMENT_ASSET_TAGS = new Set(['product_voucher', 'gift_card', 'point_card']);
|
|
11
|
+
|
|
12
|
+
// 旧版搜索响应可能只有订单不适用的提示文本,没有 unified_error_code。
|
|
13
|
+
const LEGACY_CART_MESSAGES = new Set(['Voucher not applicable to current cart', 'No eligible items in the cart', _locales.locales.en.exceeds_the_maximum_deduction_limit]);
|
|
10
14
|
function isWalletPaymentAsset(asset) {
|
|
11
15
|
return WALLET_PAYMENT_ASSET_TAGS.has(String(asset?.tag || '').toLowerCase());
|
|
12
16
|
}
|
|
@@ -174,6 +178,32 @@ class WalletPassPaymentImpl {
|
|
|
174
178
|
});
|
|
175
179
|
return state;
|
|
176
180
|
}
|
|
181
|
+
get hasEmptyWalletCart() {
|
|
182
|
+
return this.walletParams !== null && this.walletAssetsCalculationContext.products.length === 0;
|
|
183
|
+
}
|
|
184
|
+
walletAssetForEmptyCart(asset) {
|
|
185
|
+
const unavailableAsset = {
|
|
186
|
+
...asset,
|
|
187
|
+
actualDeduction: 0,
|
|
188
|
+
deductionDetails: [],
|
|
189
|
+
_available_max_amount: 0,
|
|
190
|
+
_unified_available_status: 0,
|
|
191
|
+
_wallet_asset_recommended: false
|
|
192
|
+
};
|
|
193
|
+
const errorCode = asset.unified_error_code;
|
|
194
|
+
const reportedReason = asset.unified_messages?.title || asset.error_msg || asset.disabledReason;
|
|
195
|
+
const reportedUnavailable = Number(asset.unified_available_status) === 0 || asset.available === false || asset.isDisabled === true;
|
|
196
|
+
const hasAssetRestriction = errorCode ? !(0, _utils.isWalletOrderAvailabilityError)(errorCode) : reportedUnavailable && reportedReason && !LEGACY_CART_MESSAGES.has(reportedReason);
|
|
197
|
+
if (hasAssetRestriction) {
|
|
198
|
+
return unavailableAsset;
|
|
199
|
+
}
|
|
200
|
+
const evaluator = this.paymentModule.window?.getWalletPassEvaluator?.();
|
|
201
|
+
return {
|
|
202
|
+
...unavailableAsset,
|
|
203
|
+
reasonCode: 'empty_cart',
|
|
204
|
+
reason: evaluator?.getText?.('empty_cart') || _locales.locales.en.empty_cart
|
|
205
|
+
};
|
|
206
|
+
}
|
|
177
207
|
recalculateWalletAssets(items, requestedIds, selectionSources) {
|
|
178
208
|
const committedKeys = new Set(this.walletAssetsState.committedIds.map(id => String(id)));
|
|
179
209
|
const itemsByKey = new Map(items.map(item => [getWalletAssetKey(item), item]));
|
|
@@ -181,7 +211,10 @@ class WalletPassPaymentImpl {
|
|
|
181
211
|
let nextItems = items;
|
|
182
212
|
let selectedItems = requested;
|
|
183
213
|
const evaluator = this.paymentModule.window?.getWalletPassEvaluator?.();
|
|
184
|
-
if (
|
|
214
|
+
if (this.hasEmptyWalletCart) {
|
|
215
|
+
nextItems = items.map(asset => committedKeys.has(getWalletAssetKey(asset)) ? asset : this.walletAssetForEmptyCart(asset));
|
|
216
|
+
selectedItems = [];
|
|
217
|
+
} else if (evaluator?.recalculateVouchers) {
|
|
185
218
|
try {
|
|
186
219
|
const result = evaluator.recalculateVouchers(items, requested, this.walletAssetsCalculationContext.orderTotalAmount, this.walletAssetsCalculationContext.products);
|
|
187
220
|
nextItems = mergeWalletAssets(items, result?.allWithUpdatedStatus || []);
|
|
@@ -868,14 +901,7 @@ class WalletPassPaymentImpl {
|
|
|
868
901
|
if (!businessData.products?.length) {
|
|
869
902
|
this.queuePendingAutoSelectForAssets(scanSelectedAssets);
|
|
870
903
|
this.generateWalletParams(businessData);
|
|
871
|
-
const restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map(item => (
|
|
872
|
-
...item,
|
|
873
|
-
actualDeduction: 0,
|
|
874
|
-
deductionDetails: [],
|
|
875
|
-
_available_max_amount: 0,
|
|
876
|
-
_unified_available_status: 0,
|
|
877
|
-
_wallet_asset_recommended: false
|
|
878
|
-
}));
|
|
904
|
+
const restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map(item => this.walletAssetForEmptyCart(item));
|
|
879
905
|
this.walletRecommendList = [];
|
|
880
906
|
this.userIdentificationCodes = [];
|
|
881
907
|
this.walletInitData = {
|
|
@@ -1170,10 +1196,15 @@ class WalletPassPaymentImpl {
|
|
|
1170
1196
|
selectionSources[String(id)] = 'scan';
|
|
1171
1197
|
});
|
|
1172
1198
|
const selected = this.walletAssetsBehavior.autoSelectAfterSearch ? this.recalculateWalletAssets(items, Array.from(new Set([...this.walletAssetsState.selectedIds, ...assetIds])), selectionSources) : this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
|
|
1199
|
+
const anySelected = assetIds.some(id => selected.selectedIds.includes(id));
|
|
1200
|
+
if (this.hasEmptyWalletCart) {
|
|
1201
|
+
this.queuePendingAutoSelectForAssets(assetsToApply);
|
|
1202
|
+
}
|
|
1203
|
+
const firstAssetKey = getWalletAssetKey(asset);
|
|
1173
1204
|
return {
|
|
1174
1205
|
type: result.type,
|
|
1175
|
-
asset,
|
|
1176
|
-
selected:
|
|
1206
|
+
asset: selected.items.find(item => getWalletAssetKey(item) === firstAssetKey) || asset,
|
|
1207
|
+
selected: anySelected,
|
|
1177
1208
|
state: selected
|
|
1178
1209
|
};
|
|
1179
1210
|
}
|
|
@@ -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/lib/server/index.js
CHANGED
|
@@ -3947,10 +3947,15 @@ class Server {
|
|
|
3947
3947
|
biz: next.business_code || 'ticket'
|
|
3948
3948
|
});
|
|
3949
3949
|
}
|
|
3950
|
-
if (needsShopFullOrderNumber
|
|
3951
|
-
next.
|
|
3952
|
-
|
|
3953
|
-
|
|
3950
|
+
if (needsShopFullOrderNumber) {
|
|
3951
|
+
const biz = next.business_code || 'ticket';
|
|
3952
|
+
if (idGenerator.getConfig?.(biz)?.enableShortNumber === false) {
|
|
3953
|
+
next.shop_full_order_number = next.shop_order_number;
|
|
3954
|
+
} else if (idGenerator.generateReceiptId) {
|
|
3955
|
+
next.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
3956
|
+
biz
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3954
3959
|
}
|
|
3955
3960
|
this.logInfo(`${title}: checkout 订单号已准备`, {
|
|
3956
3961
|
shop_order_number: next.shop_order_number,
|
|
@@ -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
|
*/
|
|
@@ -16,7 +16,7 @@ var _replication = require("./replication");
|
|
|
16
16
|
const INDEXDB_STORE_NAME = 'products';
|
|
17
17
|
/** 商品同步防抖时间(毫秒) */
|
|
18
18
|
const PRODUCT_SYNC_DEBOUNCE_MS = 10_000;
|
|
19
|
-
/** silentRefresh
|
|
19
|
+
/** silentRefresh 最小间隔,仅从成功的服务器全量刷新计时 */
|
|
20
20
|
const PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS = 30_000;
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -63,8 +63,10 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
63
63
|
syncTimer;
|
|
64
64
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
65
65
|
lastServerFullFetchAtMs = 0;
|
|
66
|
-
/** 最近一次 preload 完成时间(含 IndexDB
|
|
66
|
+
/** 最近一次 preload 完成时间(含 IndexDB 命中,仅用于日志) */
|
|
67
67
|
lastPreloadCompletedAtMs = 0;
|
|
68
|
+
serverFullFetchPromise;
|
|
69
|
+
silentRefreshPromise;
|
|
68
70
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
69
71
|
productIndexDBSaveQueue = Promise.resolve();
|
|
70
72
|
|
|
@@ -961,11 +963,20 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
961
963
|
*/
|
|
962
964
|
async loadProductsByServer(options = {}) {
|
|
963
965
|
if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'loadProductsByServer');
|
|
966
|
+
if (this.serverFullFetchPromise) return this.serverFullFetchPromise;
|
|
967
|
+
const fetchPromise = this.fetchAndPersistProductsByServer(options.trigger || 'unknown');
|
|
968
|
+
this.serverFullFetchPromise = fetchPromise;
|
|
969
|
+
try {
|
|
970
|
+
return await fetchPromise;
|
|
971
|
+
} finally {
|
|
972
|
+
if (this.serverFullFetchPromise === fetchPromise) this.serverFullFetchPromise = undefined;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async fetchAndPersistProductsByServer(trigger) {
|
|
964
976
|
if (!this.productDataSource) {
|
|
965
977
|
this.logWarning('loadProductsByServer: ProductDataSource 不可用');
|
|
966
978
|
return [];
|
|
967
979
|
}
|
|
968
|
-
const trigger = options.trigger || 'unknown';
|
|
969
980
|
this.logInfo('开始通过 DataSource SSE 加载商品列表', {
|
|
970
981
|
trigger
|
|
971
982
|
});
|
|
@@ -1415,6 +1426,8 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1415
1426
|
await this.refreshFromReplica('preload');
|
|
1416
1427
|
return;
|
|
1417
1428
|
}
|
|
1429
|
+
const productsBeforePreload = this.store.list;
|
|
1430
|
+
const fullFetchBeforePreload = this.lastServerFullFetchAtMs;
|
|
1418
1431
|
const tTotal = performance.now();
|
|
1419
1432
|
this.logInfo('开始预加载数据');
|
|
1420
1433
|
try {
|
|
@@ -1423,6 +1436,11 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1423
1436
|
(0, _product.perfMark)('preload.loadFromIndexDB', performance.now() - tIndexDB, {
|
|
1424
1437
|
count: cachedData?.length ?? 0
|
|
1425
1438
|
});
|
|
1439
|
+
|
|
1440
|
+
// PIN 刷新若先完成,不用随后读出的旧缓存覆盖服务器列表。
|
|
1441
|
+
if (this.lastServerFullFetchAtMs !== fullFetchBeforePreload && this.store.list !== productsBeforePreload) {
|
|
1442
|
+
return;
|
|
1443
|
+
}
|
|
1426
1444
|
if (cachedData && cachedData.length > 0) {
|
|
1427
1445
|
// IndexDB 反序列化的数据已经是全新的,无需 cloneDeep
|
|
1428
1446
|
this.store.list = cachedData;
|
|
@@ -1915,13 +1933,18 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1915
1933
|
* @returns 刷新后的商品列表
|
|
1916
1934
|
*/
|
|
1917
1935
|
async silentRefresh(options = {}) {
|
|
1918
|
-
if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'background');
|
|
1919
|
-
const t0 = performance.now();
|
|
1920
|
-
const now = Date.now();
|
|
1921
1936
|
const trigger = options.trigger || 'background';
|
|
1937
|
+
if (this.isMemoryReplica()) return this.refreshFromReplica(trigger);
|
|
1938
|
+
if (this.silentRefreshPromise) {
|
|
1939
|
+
this.logInfo('silentRefresh 复用进行中的全量刷新', {
|
|
1940
|
+
trigger
|
|
1941
|
+
});
|
|
1942
|
+
return this.silentRefreshPromise;
|
|
1943
|
+
}
|
|
1944
|
+
const now = Date.now();
|
|
1922
1945
|
const elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
|
|
1923
1946
|
const elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
|
|
1924
|
-
if (this.
|
|
1947
|
+
if (!this.serverFullFetchPromise && this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
|
|
1925
1948
|
this.logInfo('silentRefresh 跳过全量 SSE', {
|
|
1926
1949
|
trigger,
|
|
1927
1950
|
reason: 'within_min_interval',
|
|
@@ -1938,6 +1961,16 @@ class ProductsModule extends _BaseModule.BaseModule {
|
|
|
1938
1961
|
elapsedSinceFullFetchMs,
|
|
1939
1962
|
productCount: this.store.list.length
|
|
1940
1963
|
});
|
|
1964
|
+
const refreshPromise = this.runSilentRefresh(trigger);
|
|
1965
|
+
this.silentRefreshPromise = refreshPromise;
|
|
1966
|
+
try {
|
|
1967
|
+
return await refreshPromise;
|
|
1968
|
+
} finally {
|
|
1969
|
+
if (this.silentRefreshPromise === refreshPromise) this.silentRefreshPromise = undefined;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
async runSilentRefresh(trigger) {
|
|
1973
|
+
const t0 = performance.now();
|
|
1941
1974
|
try {
|
|
1942
1975
|
const products = await this.loadProductsByServer({
|
|
1943
1976
|
trigger
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"
|
|
392
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|