@pisell/pisellos 2.2.324 → 2.2.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/walletPass/locales.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- 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.d.ts +3 -0
- package/dist/server/index.js +792 -645
- 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 +1 -1
- package/dist/solution/BookingTicket/index.js +6 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +34 -23
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +9 -0
- package/lib/modules/Order/index.d.ts +1 -1
- 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.d.ts +3 -0
- package/lib/server/index.js +79 -7
- 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 +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- 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 | 2 | 1 | 3 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -630,7 +630,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
630
630
|
value: function () {
|
|
631
631
|
var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
632
632
|
var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
|
|
633
|
-
var idGenerator, openDataConfig, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode, _openDataConfig7, _openDataConfig8, _openDataConfig9;
|
|
633
|
+
var idGenerator, openDataConfig, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode, _openDataConfig7, _openDataConfig8, _openDataConfig9, _openDataConfig10;
|
|
634
634
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
635
635
|
while (1) switch (_context10.prev = _context10.next) {
|
|
636
636
|
case 0:
|
|
@@ -686,12 +686,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
686
686
|
return idGenerator.configure({
|
|
687
687
|
biz: businessCode,
|
|
688
688
|
config: {
|
|
689
|
+
enableShortNumber: ((_openDataConfig7 = openDataConfig) === null || _openDataConfig7 === void 0 ? void 0 : _openDataConfig7['sale.enable_short_number']) !== false,
|
|
689
690
|
prefix: prefix,
|
|
690
691
|
deviceCode: deviceId,
|
|
691
|
-
padReceiptSequence: ((
|
|
692
|
+
padReceiptSequence: ((_openDataConfig8 = openDataConfig) === null || _openDataConfig8 === void 0 ? void 0 : _openDataConfig8['sale.pad_with_leading_zeros']) === true,
|
|
692
693
|
receiptSequenceLength: receiptSequenceLength,
|
|
693
|
-
receiptSequenceMax: this.normalizeShortNumberMaximum((
|
|
694
|
-
randomReceiptSequence: ((
|
|
694
|
+
receiptSequenceMax: this.normalizeShortNumberMaximum((_openDataConfig9 = openDataConfig) === null || _openDataConfig9 === void 0 ? void 0 : _openDataConfig9['sale.maximum_number']),
|
|
695
|
+
randomReceiptSequence: ((_openDataConfig10 = openDataConfig) === null || _openDataConfig10 === void 0 ? void 0 : _openDataConfig10['sale.short_number_random']) === true,
|
|
695
696
|
resetReceiptSequenceDaily: resetReceiptSequenceDaily,
|
|
696
697
|
receiptSequenceResetTime: operatingDayBoundary === null || operatingDayBoundary === void 0 ? void 0 : operatingDayBoundary.time,
|
|
697
698
|
receiptSequenceStart: receiptSequenceStart,
|
|
@@ -3498,7 +3499,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3498
3499
|
_context44.next = 9;
|
|
3499
3500
|
return this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
|
|
3500
3501
|
case 9:
|
|
3501
|
-
if (!((params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined)) {
|
|
3502
|
+
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'))) {
|
|
3502
3503
|
_context44.next = 12;
|
|
3503
3504
|
break;
|
|
3504
3505
|
}
|
|
@@ -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',
|
|
@@ -2507,8 +2507,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2507
2507
|
key: "ensureLocalOrderNumbersForCheckout",
|
|
2508
2508
|
value: (function () {
|
|
2509
2509
|
var _ensureLocalOrderNumbersForCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
2510
|
-
var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
|
|
2511
|
-
var order, tempOrder, biz, idGenerator;
|
|
2510
|
+
var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2, _idGenerator$getConfi;
|
|
2511
|
+
var order, tempOrder, biz, idGenerator, useLongNumber;
|
|
2512
2512
|
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
2513
2513
|
while (1) switch (_context10.prev = _context10.next) {
|
|
2514
2514
|
case 0:
|
|
@@ -2540,56 +2540,67 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2540
2540
|
throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
2541
2541
|
case 11:
|
|
2542
2542
|
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');
|
|
2543
|
-
|
|
2544
|
-
|
|
2543
|
+
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;
|
|
2544
|
+
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')) {
|
|
2545
|
+
_context10.next = 15;
|
|
2545
2546
|
break;
|
|
2546
2547
|
}
|
|
2547
2548
|
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
2548
|
-
case
|
|
2549
|
-
_context10.prev =
|
|
2549
|
+
case 15:
|
|
2550
|
+
_context10.prev = 15;
|
|
2550
2551
|
if (tempOrder.shop_order_number) {
|
|
2551
|
-
_context10.next =
|
|
2552
|
+
_context10.next = 20;
|
|
2552
2553
|
break;
|
|
2553
2554
|
}
|
|
2554
|
-
_context10.next =
|
|
2555
|
+
_context10.next = 19;
|
|
2555
2556
|
return idGenerator.generateShopOrderNumber({
|
|
2556
2557
|
biz: biz
|
|
2557
2558
|
});
|
|
2558
|
-
case 18:
|
|
2559
|
-
tempOrder.shop_order_number = _context10.sent;
|
|
2560
2559
|
case 19:
|
|
2560
|
+
tempOrder.shop_order_number = _context10.sent;
|
|
2561
|
+
case 20:
|
|
2561
2562
|
if (tempOrder.shop_full_order_number) {
|
|
2562
|
-
_context10.next =
|
|
2563
|
+
_context10.next = 29;
|
|
2563
2564
|
break;
|
|
2564
2565
|
}
|
|
2565
|
-
|
|
2566
|
+
if (!useLongNumber) {
|
|
2567
|
+
_context10.next = 25;
|
|
2568
|
+
break;
|
|
2569
|
+
}
|
|
2570
|
+
_context10.t0 = tempOrder.shop_order_number;
|
|
2571
|
+
_context10.next = 28;
|
|
2572
|
+
break;
|
|
2573
|
+
case 25:
|
|
2574
|
+
_context10.next = 27;
|
|
2566
2575
|
return idGenerator.generateReceiptId({
|
|
2567
2576
|
biz: biz
|
|
2568
2577
|
});
|
|
2569
|
-
case
|
|
2570
|
-
|
|
2571
|
-
case
|
|
2578
|
+
case 27:
|
|
2579
|
+
_context10.t0 = _context10.sent;
|
|
2580
|
+
case 28:
|
|
2581
|
+
tempOrder.shop_full_order_number = _context10.t0;
|
|
2582
|
+
case 29:
|
|
2572
2583
|
if (!(order.getTempOrder() !== tempOrder)) {
|
|
2573
|
-
_context10.next =
|
|
2584
|
+
_context10.next = 31;
|
|
2574
2585
|
break;
|
|
2575
2586
|
}
|
|
2576
2587
|
throw new Error('当前订单已切换,请重新发起支付');
|
|
2577
|
-
case
|
|
2588
|
+
case 31:
|
|
2578
2589
|
if (!(!tempOrder.shop_order_number || !tempOrder.shop_full_order_number)) {
|
|
2579
|
-
_context10.next =
|
|
2590
|
+
_context10.next = 33;
|
|
2580
2591
|
break;
|
|
2581
2592
|
}
|
|
2582
2593
|
throw new Error('订单编号生成失败,请重试');
|
|
2583
|
-
case
|
|
2584
|
-
_context10.prev =
|
|
2594
|
+
case 33:
|
|
2595
|
+
_context10.prev = 33;
|
|
2585
2596
|
// 部分生成成功时也保留号码,后续只补仍然缺失的字段。
|
|
2586
2597
|
if (order.getTempOrder() === tempOrder) order.persistTempOrder();
|
|
2587
|
-
return _context10.finish(
|
|
2588
|
-
case
|
|
2598
|
+
return _context10.finish(33);
|
|
2599
|
+
case 36:
|
|
2589
2600
|
case "end":
|
|
2590
2601
|
return _context10.stop();
|
|
2591
2602
|
}
|
|
2592
|
-
}, _callee9, this, [[
|
|
2603
|
+
}, _callee9, this, [[15,, 33, 36]]);
|
|
2593
2604
|
}));
|
|
2594
2605
|
function ensureLocalOrderNumbersForCheckout() {
|
|
2595
2606
|
return _ensureLocalOrderNumbersForCheckout.apply(this, arguments);
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -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
|
};
|
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "virtual" | "appointment_booking";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ declare class Server {
|
|
|
65
65
|
private deviceTaskActionsRegistered;
|
|
66
66
|
private localPaymentUpdateQueues;
|
|
67
67
|
private paymentIdentityRefreshes;
|
|
68
|
+
private receiptFulfillmentConfigInFlight;
|
|
68
69
|
private floorPlanQuerySubscribers;
|
|
69
70
|
private moduleRegistry;
|
|
70
71
|
constructor(core: PisellCore);
|
|
@@ -525,6 +526,8 @@ declare class Server {
|
|
|
525
526
|
private extractInvoiceTemplateSettings;
|
|
526
527
|
private applyCheckoutFulfillmentBuzzer;
|
|
527
528
|
private buildCheckoutResourceIdentifierBuzzer;
|
|
529
|
+
/** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
|
|
530
|
+
private withCurrentReceiptResourceReference;
|
|
528
531
|
private getCheckoutResourceIdentifier;
|
|
529
532
|
private stringifyCheckoutResourceIdentifier;
|
|
530
533
|
private normalizeCheckoutSubmitData;
|
package/lib/server/index.js
CHANGED
|
@@ -125,6 +125,7 @@ class Server {
|
|
|
125
125
|
deviceTaskActionsRegistered = false;
|
|
126
126
|
localPaymentUpdateQueues = new Map();
|
|
127
127
|
paymentIdentityRefreshes = new Map();
|
|
128
|
+
receiptFulfillmentConfigInFlight = new Map();
|
|
128
129
|
floorPlanQuerySubscribers = new Map();
|
|
129
130
|
|
|
130
131
|
// 模块注册表 - 定义所有可用的模块配置
|
|
@@ -3711,6 +3712,69 @@ class Server {
|
|
|
3711
3712
|
});
|
|
3712
3713
|
return values.join(',');
|
|
3713
3714
|
}
|
|
3715
|
+
|
|
3716
|
+
/** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
|
|
3717
|
+
async withCurrentReceiptResourceReference(order) {
|
|
3718
|
+
const resourceReference = this.buildCheckoutResourceIdentifierBuzzer(order.bookings);
|
|
3719
|
+
if (!resourceReference || resourceReference === String(order.buzzer ?? '')) return order;
|
|
3720
|
+
const businessCode = String(order.business_code || '').trim();
|
|
3721
|
+
const channel = String(order.order_sales_channel || '').trim();
|
|
3722
|
+
const shopId = this.getAppData('shop_id');
|
|
3723
|
+
const tenantId = this.getAppData('tenant_id');
|
|
3724
|
+
if (!businessCode || !channel || !shopId || !this.app?.request?.post) return order;
|
|
3725
|
+
|
|
3726
|
+
// A receipt can be printed outside a Sales instance. Read the order's own
|
|
3727
|
+
// business/channel settings rather than borrowing the currently open page.
|
|
3728
|
+
const key = JSON.stringify([String(shopId), String(tenantId ?? ''), businessCode, channel]);
|
|
3729
|
+
let inFlight = this.receiptFulfillmentConfigInFlight.get(key);
|
|
3730
|
+
if (!inFlight) {
|
|
3731
|
+
inFlight = (async () => {
|
|
3732
|
+
const response = await this.app.request.post(`/open/my-pisell/${shopId}/setting`, {
|
|
3733
|
+
scope: 'board',
|
|
3734
|
+
target: `${businessCode}+${channel}`,
|
|
3735
|
+
section_code: ['fulfillment']
|
|
3736
|
+
}, {
|
|
3737
|
+
pisell2: true,
|
|
3738
|
+
isPisell2: true,
|
|
3739
|
+
prefix: false,
|
|
3740
|
+
customToast: () => {},
|
|
3741
|
+
...(tenantId ? {
|
|
3742
|
+
headers: {
|
|
3743
|
+
'Tenant-Id': String(tenantId)
|
|
3744
|
+
}
|
|
3745
|
+
} : {})
|
|
3746
|
+
});
|
|
3747
|
+
if (response?.status === false || response?.code != null && Number(response.code) !== 200) {
|
|
3748
|
+
throw new Error('Receipt fulfillment settings are unavailable');
|
|
3749
|
+
}
|
|
3750
|
+
return response?.data?.['fulfillment.fulfillment_ref_mode'];
|
|
3751
|
+
})();
|
|
3752
|
+
this.receiptFulfillmentConfigInFlight.set(key, inFlight);
|
|
3753
|
+
}
|
|
3754
|
+
try {
|
|
3755
|
+
const mode = await inFlight;
|
|
3756
|
+
if (mode !== 'resource_identifier' || String(this.getAppData('shop_id')) !== String(shopId) || String(this.getAppData('tenant_id') ?? '') !== String(tenantId ?? '')) return order;
|
|
3757
|
+
return {
|
|
3758
|
+
...order,
|
|
3759
|
+
buzzer: resourceReference
|
|
3760
|
+
};
|
|
3761
|
+
} catch (error) {
|
|
3762
|
+
// Offline/manual printing still works. Without a confirmed policy, do not
|
|
3763
|
+
// mistake a manually entered pickup reference for an obsolete table name.
|
|
3764
|
+
this.logWarning('withCurrentReceiptResourceReference: 配置不可用,保留原取单号', {
|
|
3765
|
+
order_id: order.order_id,
|
|
3766
|
+
target: `${businessCode}+${channel}`,
|
|
3767
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3768
|
+
});
|
|
3769
|
+
return order;
|
|
3770
|
+
} finally {
|
|
3771
|
+
// Only coalesce concurrent outputs; settings changes and failures must be
|
|
3772
|
+
// re-read on the next receipt instead of becoming a permanent cache.
|
|
3773
|
+
if (this.receiptFulfillmentConfigInFlight.get(key) === inFlight) {
|
|
3774
|
+
this.receiptFulfillmentConfigInFlight.delete(key);
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3714
3778
|
getCheckoutResourceIdentifier(resource, fallbackName) {
|
|
3715
3779
|
if (!resource || typeof resource !== 'object') return '';
|
|
3716
3780
|
const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, fallbackName, resource.relation_id, resource.id];
|
|
@@ -3833,10 +3897,15 @@ class Server {
|
|
|
3833
3897
|
biz: next.business_code || 'ticket'
|
|
3834
3898
|
});
|
|
3835
3899
|
}
|
|
3836
|
-
if (needsShopFullOrderNumber
|
|
3837
|
-
next.
|
|
3838
|
-
|
|
3839
|
-
|
|
3900
|
+
if (needsShopFullOrderNumber) {
|
|
3901
|
+
const biz = next.business_code || 'ticket';
|
|
3902
|
+
if (idGenerator.getConfig?.(biz)?.enableShortNumber === false) {
|
|
3903
|
+
next.shop_full_order_number = next.shop_order_number;
|
|
3904
|
+
} else if (idGenerator.generateReceiptId) {
|
|
3905
|
+
next.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
3906
|
+
biz
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3840
3909
|
}
|
|
3841
3910
|
this.logInfo(`${title}: checkout 订单号已准备`, {
|
|
3842
3911
|
shop_order_number: next.shop_order_number,
|
|
@@ -3979,7 +4048,8 @@ class Server {
|
|
|
3979
4048
|
const printableOrder = await this.withLocalSmallTicketData(params.order, {
|
|
3980
4049
|
requireFullyPaid: params.requireFullyPaid,
|
|
3981
4050
|
invoiceTemplateSettings: params.invoiceTemplateSettings,
|
|
3982
|
-
applyTemplateVisibility: true
|
|
4051
|
+
applyTemplateVisibility: true,
|
|
4052
|
+
refreshResourceReference: true
|
|
3983
4053
|
});
|
|
3984
4054
|
if (!(0, _smallTicket.hasSmallTicketData)(printableOrder.payment_info?.small_ticket_data)) {
|
|
3985
4055
|
return {
|
|
@@ -4217,7 +4287,8 @@ class Server {
|
|
|
4217
4287
|
locales: this.normalizeRequestedReceiptLocales(input.locales),
|
|
4218
4288
|
invoiceTemplateSettings: input.template_settings === undefined ? undefined : this.normalizePrintInvoiceTemplateSettings(input.template_settings),
|
|
4219
4289
|
applyTemplateVisibility: true,
|
|
4220
|
-
includeReceiptKeys: input.template_settings !== undefined
|
|
4290
|
+
includeReceiptKeys: input.template_settings !== undefined,
|
|
4291
|
+
refreshResourceReference: true
|
|
4221
4292
|
});
|
|
4222
4293
|
const smallTicketData = rebuiltOrder.payment_info?.small_ticket_data;
|
|
4223
4294
|
if (!(0, _smallTicket.hasSmallTicketData)(smallTicketData)) {
|
|
@@ -5139,7 +5210,8 @@ class Server {
|
|
|
5139
5210
|
collapsed_duplicate_counts: collapsedDuplicateCounts
|
|
5140
5211
|
});
|
|
5141
5212
|
}
|
|
5142
|
-
const
|
|
5213
|
+
const receiptOrder = options?.refreshResourceReference ? await this.withCurrentReceiptResourceReference(normalizedOrder) : normalizedOrder;
|
|
5214
|
+
const enrichedOrder = await this.enrichPaymentNamesByCode(receiptOrder);
|
|
5143
5215
|
const productMap = options?.productMap ?? (await this.buildSmallTicketProductMap(enrichedOrder));
|
|
5144
5216
|
const smallTicketData = (0, _smallTicket.buildSmallTicketData)({
|
|
5145
5217
|
order: enrichedOrder,
|
|
@@ -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
|
*/
|