@pisell/pisellos 0.0.233 → 0.0.235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +1 -1
- package/dist/modules/Payment/index.d.ts +3 -3
- package/dist/modules/Payment/index.js +74 -10
- package/dist/modules/Payment/types.d.ts +24 -3
- package/dist/modules/Payment/types.js +9 -1
- package/dist/modules/Payment/utils.js +1 -1
- package/dist/modules/Payment/walletpass.d.ts +5 -2
- package/dist/modules/Payment/walletpass.js +63 -11
- package/dist/solution/BookingByStep/utils/timeslots.js +88 -38
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +27 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
- package/dist/solution/Checkout/index.d.ts +50 -7
- package/dist/solution/Checkout/index.js +890 -474
- package/dist/solution/Checkout/types.d.ts +69 -3
- package/dist/solution/Checkout/types.js +5 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1 -1
- package/lib/modules/Payment/index.d.ts +3 -3
- package/lib/modules/Payment/index.js +30 -5
- package/lib/modules/Payment/types.d.ts +24 -3
- package/lib/modules/Payment/types.js +1 -1
- package/lib/modules/Payment/utils.js +1 -1
- package/lib/modules/Payment/walletpass.d.ts +5 -2
- package/lib/modules/Payment/walletpass.js +30 -2
- package/lib/solution/BookingByStep/utils/timeslots.js +38 -3
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +23 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
- package/lib/solution/Checkout/index.d.ts +50 -7
- package/lib/solution/Checkout/index.js +267 -92
- package/lib/solution/Checkout/types.d.ts +69 -3
- package/lib/solution/Checkout/types.js +1 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
11
11
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
12
12
|
createOrder(params: CommitOrderParams['query']): {
|
|
13
13
|
type: "virtual" | "appointment_booking";
|
|
14
|
-
platform:
|
|
14
|
+
platform: string;
|
|
15
15
|
sales_channel: string;
|
|
16
16
|
order_sales_channel: string;
|
|
17
17
|
bookings: any[];
|
|
@@ -66,7 +66,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
66
66
|
var order = {
|
|
67
67
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
68
68
|
// 要从外面拿,virtual
|
|
69
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform)
|
|
69
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) === 'pc' ? 'PC' : 'H5',
|
|
70
70
|
sales_channel: 'my_pisel',
|
|
71
71
|
order_sales_channel: 'online_store',
|
|
72
72
|
bookings: [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { RequestPlugin } from '../../plugins';
|
|
3
3
|
import { BaseModule } from '../BaseModule';
|
|
4
|
-
import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval } from './types';
|
|
4
|
+
import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export { generateRequestUniqueId };
|
|
7
7
|
/**
|
|
@@ -176,9 +176,9 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
176
176
|
* @param originalAmount 原始金额
|
|
177
177
|
* @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
|
|
178
178
|
* @param rule 舍入规则 (standard, standard_down, always_up, always_down)
|
|
179
|
-
* @returns
|
|
179
|
+
* @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
|
|
180
180
|
*/
|
|
181
|
-
roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<
|
|
181
|
+
roundAmountAsync(originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string): Promise<RoundingResult>;
|
|
182
182
|
/**
|
|
183
183
|
* 标准舍入处理(处理中点情况)
|
|
184
184
|
*
|
|
@@ -506,7 +506,64 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
// 检查关键字段是否有变化
|
|
509
|
-
if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.enabled !== newMethod.enabled) {
|
|
509
|
+
if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
|
|
510
|
+
console.log("[PaymentModule] \u652F\u4ED8\u65B9\u5F0F ".concat(newMethod.id, " (").concat(newMethod.code, ") \u53D1\u751F\u53D8\u5316:"), {
|
|
511
|
+
id: newMethod.id,
|
|
512
|
+
changes: {
|
|
513
|
+
code: oldMethod.code !== newMethod.code ? {
|
|
514
|
+
old: oldMethod.code,
|
|
515
|
+
new: newMethod.code
|
|
516
|
+
} : undefined,
|
|
517
|
+
name: oldMethod.name !== newMethod.name ? {
|
|
518
|
+
old: oldMethod.name,
|
|
519
|
+
new: newMethod.name
|
|
520
|
+
} : undefined,
|
|
521
|
+
type: oldMethod.type !== newMethod.type ? {
|
|
522
|
+
old: oldMethod.type,
|
|
523
|
+
new: newMethod.type
|
|
524
|
+
} : undefined,
|
|
525
|
+
description: oldMethod.description !== newMethod.description ? {
|
|
526
|
+
old: oldMethod.description,
|
|
527
|
+
new: newMethod.description
|
|
528
|
+
} : undefined,
|
|
529
|
+
status: oldMethod.status !== newMethod.status ? {
|
|
530
|
+
old: oldMethod.status,
|
|
531
|
+
new: newMethod.status
|
|
532
|
+
} : undefined,
|
|
533
|
+
disable: oldMethod.disable !== newMethod.disable ? {
|
|
534
|
+
old: oldMethod.disable,
|
|
535
|
+
new: newMethod.disable
|
|
536
|
+
} : undefined,
|
|
537
|
+
is_surcharge: oldMethod.is_surcharge !== newMethod.is_surcharge ? {
|
|
538
|
+
old: oldMethod.is_surcharge,
|
|
539
|
+
new: newMethod.is_surcharge
|
|
540
|
+
} : undefined,
|
|
541
|
+
fixed: oldMethod.fixed !== newMethod.fixed ? {
|
|
542
|
+
old: oldMethod.fixed,
|
|
543
|
+
new: newMethod.fixed
|
|
544
|
+
} : undefined,
|
|
545
|
+
percentage: oldMethod.percentage !== newMethod.percentage ? {
|
|
546
|
+
old: oldMethod.percentage,
|
|
547
|
+
new: newMethod.percentage
|
|
548
|
+
} : undefined,
|
|
549
|
+
enabled: oldMethod.enabled !== newMethod.enabled ? {
|
|
550
|
+
old: oldMethod.enabled,
|
|
551
|
+
new: newMethod.enabled
|
|
552
|
+
} : undefined,
|
|
553
|
+
channel_application: JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) ? {
|
|
554
|
+
old: oldMethod.channel_application,
|
|
555
|
+
new: newMethod.channel_application
|
|
556
|
+
} : undefined,
|
|
557
|
+
companies: JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) ? {
|
|
558
|
+
old: oldMethod.companies,
|
|
559
|
+
new: newMethod.companies
|
|
560
|
+
} : undefined,
|
|
561
|
+
metadata: JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {}) ? {
|
|
562
|
+
old: oldMethod.metadata,
|
|
563
|
+
new: newMethod.metadata
|
|
564
|
+
} : undefined
|
|
565
|
+
}
|
|
566
|
+
});
|
|
510
567
|
return true; // 方法属性有变化
|
|
511
568
|
}
|
|
512
569
|
}
|
|
@@ -1906,14 +1963,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1906
1963
|
* @param originalAmount 原始金额
|
|
1907
1964
|
* @param interval 舍入间隔 (0.05, 0.1, 0.5, 1)
|
|
1908
1965
|
* @param rule 舍入规则 (standard, standard_down, always_up, always_down)
|
|
1909
|
-
* @returns
|
|
1966
|
+
* @returns 舍入结果详情(包含原始金额、舍入后金额和舍入差额)
|
|
1910
1967
|
*/
|
|
1911
1968
|
)
|
|
1912
1969
|
}, {
|
|
1913
1970
|
key: "roundAmountAsync",
|
|
1914
1971
|
value: function () {
|
|
1915
1972
|
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
|
|
1916
|
-
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount,
|
|
1973
|
+
var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, roundedAmountStr, originalAmountStr, roundingDifference, roundingDifferenceStr;
|
|
1917
1974
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1918
1975
|
while (1) switch (_context26.prev = _context26.next) {
|
|
1919
1976
|
case 0:
|
|
@@ -1961,19 +2018,26 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
2018
|
case 22:
|
|
1962
2019
|
// 计算最终金额:roundedValue * interval
|
|
1963
2020
|
finalAmount = roundedValue.mul(roundingInterval);
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2021
|
+
roundedAmountStr = finalAmount.toFixed(2);
|
|
2022
|
+
originalAmountStr = amount.toFixed(2); // 计算舍入差额
|
|
2023
|
+
roundingDifference = finalAmount.sub(amount);
|
|
2024
|
+
roundingDifferenceStr = roundingDifference.toFixed(2);
|
|
2025
|
+
console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
|
|
2026
|
+
return _context26.abrupt("return", {
|
|
2027
|
+
originalAmount: originalAmountStr,
|
|
2028
|
+
roundedAmount: roundedAmountStr,
|
|
2029
|
+
roundingDifference: roundingDifferenceStr
|
|
2030
|
+
});
|
|
2031
|
+
case 31:
|
|
2032
|
+
_context26.prev = 31;
|
|
1969
2033
|
_context26.t1 = _context26["catch"](0);
|
|
1970
2034
|
console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
|
|
1971
2035
|
throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
|
|
1972
|
-
case
|
|
2036
|
+
case 35:
|
|
1973
2037
|
case "end":
|
|
1974
2038
|
return _context26.stop();
|
|
1975
2039
|
}
|
|
1976
|
-
}, _callee26, this, [[0,
|
|
2040
|
+
}, _callee26, this, [[0, 31]]);
|
|
1977
2041
|
}));
|
|
1978
2042
|
function roundAmountAsync(_x28, _x29, _x30) {
|
|
1979
2043
|
return _roundAmountAsync.apply(this, arguments);
|
|
@@ -36,7 +36,7 @@ export declare enum TaskRunStatus {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare enum RoundingRule {
|
|
38
38
|
/** 标准舍入(中点向上) */
|
|
39
|
-
Standard = "
|
|
39
|
+
Standard = "standard_rounding",
|
|
40
40
|
/** 标准舍入(中点向下) */
|
|
41
41
|
StandardDown = "standard_down",
|
|
42
42
|
/** 总是向上舍入 */
|
|
@@ -44,6 +44,17 @@ export declare enum RoundingRule {
|
|
|
44
44
|
/** 总是向下舍入 */
|
|
45
45
|
AlwaysDown = "always_down"
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* 舍入结果
|
|
49
|
+
*/
|
|
50
|
+
export interface RoundingResult {
|
|
51
|
+
/** 原始金额 */
|
|
52
|
+
originalAmount: string;
|
|
53
|
+
/** 舍入后的金额 */
|
|
54
|
+
roundedAmount: string;
|
|
55
|
+
/** 舍入差额(舍入后金额 - 原始金额) */
|
|
56
|
+
roundingDifference: string;
|
|
57
|
+
}
|
|
47
58
|
/**
|
|
48
59
|
* 舍入间隔枚举
|
|
49
60
|
*/
|
|
@@ -306,7 +317,7 @@ export interface WalletPassPayment {
|
|
|
306
317
|
/** 查询用户识别码列表(异步获取并缓存) */
|
|
307
318
|
getUserIdentificationCodeListAsync: (params: UserIdentificationCodeParams) => Promise<UserIdentificationCodeItem[]>;
|
|
308
319
|
/** 搜索识别码信息 */
|
|
309
|
-
searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<
|
|
320
|
+
searchIdentificationCodeAsync: (params: SearchIdentificationCodeParams) => Promise<SearchIdentificationCodeResult>;
|
|
310
321
|
/** 获取缓存的搜索结果列表 */
|
|
311
322
|
getSearchResults: () => SearchIdentificationCodeItem[];
|
|
312
323
|
/** 根据识别码查找搜索结果 */
|
|
@@ -371,7 +382,7 @@ export interface PaymentModuleAPI {
|
|
|
371
382
|
* @param rule 舍入规则 (standard, standard_down, always_up, always_down)
|
|
372
383
|
* @returns 舍入后的金额
|
|
373
384
|
*/
|
|
374
|
-
roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<
|
|
385
|
+
roundAmountAsync: (originalAmount: number | string, interval: RoundingInterval | number, rule: RoundingRule | string) => Promise<RoundingResult>;
|
|
375
386
|
/** 提交支付 */
|
|
376
387
|
submitPayAsync: (orderUuid?: string) => Promise<{
|
|
377
388
|
status: 'success' | 'failed';
|
|
@@ -636,6 +647,16 @@ export interface SearchIdentificationCodeResponse {
|
|
|
636
647
|
/** 响应数据 */
|
|
637
648
|
data?: SearchIdentificationCodeItem[];
|
|
638
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* 搜索识别码结果类型
|
|
652
|
+
*/
|
|
653
|
+
export type SearchIdentificationCodeResult = {
|
|
654
|
+
type: 'walletCode';
|
|
655
|
+
data: SearchIdentificationCodeItem[];
|
|
656
|
+
} | {
|
|
657
|
+
type: 'normalCode';
|
|
658
|
+
data: SearchIdentificationCodeItem[];
|
|
659
|
+
};
|
|
639
660
|
/**
|
|
640
661
|
* 搜索识别码项目
|
|
641
662
|
*/
|
|
@@ -38,13 +38,17 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
|
|
|
38
38
|
* 舍入规则枚举
|
|
39
39
|
*/
|
|
40
40
|
export var RoundingRule = /*#__PURE__*/function (RoundingRule) {
|
|
41
|
-
RoundingRule["Standard"] = "
|
|
41
|
+
RoundingRule["Standard"] = "standard_rounding";
|
|
42
42
|
RoundingRule["StandardDown"] = "standard_down";
|
|
43
43
|
RoundingRule["AlwaysUp"] = "always_up";
|
|
44
44
|
RoundingRule["AlwaysDown"] = "always_down";
|
|
45
45
|
return RoundingRule;
|
|
46
46
|
}({});
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* 舍入结果
|
|
50
|
+
*/
|
|
51
|
+
|
|
48
52
|
/**
|
|
49
53
|
* 舍入间隔枚举
|
|
50
54
|
*/
|
|
@@ -225,6 +229,10 @@ export var PaymentHooks = /*#__PURE__*/function (PaymentHooks) {
|
|
|
225
229
|
* 搜索识别码响应数据
|
|
226
230
|
*/
|
|
227
231
|
|
|
232
|
+
/**
|
|
233
|
+
* 搜索识别码结果类型
|
|
234
|
+
*/
|
|
235
|
+
|
|
228
236
|
/**
|
|
229
237
|
* 搜索识别码项目
|
|
230
238
|
*/
|
|
@@ -11,7 +11,7 @@ export var formatWalletPassList2PreparePayments = function formatWalletPassList2
|
|
|
11
11
|
return (list || []).map(function (item) {
|
|
12
12
|
return {
|
|
13
13
|
voucher_id: item.id || 0,
|
|
14
|
-
amount: Number(getAvailableMaxAmount(item)) || 0,
|
|
14
|
+
amount: Number(item.edit_current_amount || getAvailableMaxAmount(item)) || 0,
|
|
15
15
|
tag: item.tag || ''
|
|
16
16
|
};
|
|
17
17
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, WalletInitBusinessData } from './types';
|
|
1
|
+
import { WalletPassPayment, WalletDeductionRecommendParams, WalletRecommendItem, UserIdentificationCodeParams, UserIdentificationCodeItem, SearchIdentificationCodeParams, SearchIdentificationCodeItem, SearchIdentificationCodeResult, WalletInitBusinessData } from './types';
|
|
2
2
|
import type { PaymentModule } from './index';
|
|
3
3
|
/**
|
|
4
4
|
* 钱包支付实现
|
|
@@ -57,8 +57,11 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
57
57
|
* 搜索识别码信息
|
|
58
58
|
* 通过识别码搜索相关的钱包通行证信息
|
|
59
59
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
60
|
+
* 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
|
|
60
61
|
*/
|
|
61
|
-
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams
|
|
62
|
+
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
63
|
+
noCache?: boolean;
|
|
64
|
+
}): Promise<SearchIdentificationCodeResult>;
|
|
62
65
|
processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
|
|
63
66
|
getWalletBalance(voucherId: string): Promise<number>;
|
|
64
67
|
/**
|
|
@@ -274,16 +274,55 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
274
274
|
* 搜索识别码信息
|
|
275
275
|
* 通过识别码搜索相关的钱包通行证信息
|
|
276
276
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
277
|
+
* 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
|
|
277
278
|
*/
|
|
278
279
|
}, {
|
|
279
280
|
key: "searchIdentificationCodeAsync",
|
|
280
281
|
value: (function () {
|
|
281
282
|
var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
282
|
-
var
|
|
283
|
+
var config,
|
|
284
|
+
code,
|
|
285
|
+
isWalletCode,
|
|
286
|
+
walletDetailParams,
|
|
287
|
+
_response,
|
|
288
|
+
_searchResults,
|
|
289
|
+
baseWalletParams,
|
|
290
|
+
searchParams,
|
|
291
|
+
response,
|
|
292
|
+
searchResults,
|
|
293
|
+
_this$searchResults,
|
|
294
|
+
existingCodes,
|
|
295
|
+
newResults,
|
|
296
|
+
_args5 = arguments;
|
|
283
297
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
284
298
|
while (1) switch (_context5.prev = _context5.next) {
|
|
285
299
|
case 0:
|
|
286
|
-
|
|
300
|
+
config = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
301
|
+
_context5.prev = 1;
|
|
302
|
+
code = params.code; // 检查识别码是否为9位且前3位为"000"
|
|
303
|
+
// const isWalletCode = code.length === 9 && code.startsWith('000');
|
|
304
|
+
// 测试环境先使用 WL
|
|
305
|
+
isWalletCode = code.startsWith('WL');
|
|
306
|
+
if (!isWalletCode) {
|
|
307
|
+
_context5.next = 11;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
// 钱包识别码直接调用专门接口,不缓存,直接返回
|
|
311
|
+
walletDetailParams = {
|
|
312
|
+
code: code,
|
|
313
|
+
with_customer: 1,
|
|
314
|
+
with: ['latestWalletDetail.wallet']
|
|
315
|
+
};
|
|
316
|
+
_context5.next = 8;
|
|
317
|
+
return this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
|
|
318
|
+
case 8:
|
|
319
|
+
_response = _context5.sent;
|
|
320
|
+
_searchResults = (_response === null || _response === void 0 ? void 0 : _response.data) || [];
|
|
321
|
+
return _context5.abrupt("return", {
|
|
322
|
+
type: 'walletCode',
|
|
323
|
+
data: _searchResults
|
|
324
|
+
});
|
|
325
|
+
case 11:
|
|
287
326
|
// 合并钱包参数和搜索参数
|
|
288
327
|
baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
|
|
289
328
|
searchParams = {
|
|
@@ -300,11 +339,21 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
300
339
|
// 搜索特有参数
|
|
301
340
|
code: params.code
|
|
302
341
|
};
|
|
303
|
-
_context5.next =
|
|
342
|
+
_context5.next = 15;
|
|
304
343
|
return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
|
|
305
|
-
case
|
|
344
|
+
case 15:
|
|
306
345
|
response = _context5.sent;
|
|
307
|
-
searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
346
|
+
searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
347
|
+
if (!config.noCache) {
|
|
348
|
+
_context5.next = 19;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return _context5.abrupt("return", {
|
|
352
|
+
type: 'normalCode',
|
|
353
|
+
data: searchResults
|
|
354
|
+
});
|
|
355
|
+
case 19:
|
|
356
|
+
// 将搜索结果存储到缓存数组中
|
|
308
357
|
if (searchResults.length > 0) {
|
|
309
358
|
// 避免重复存储相同的识别码
|
|
310
359
|
existingCodes = new Set(this.searchResults.map(function (item) {
|
|
@@ -323,17 +372,20 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
323
372
|
cachedSearchResults: _toConsumableArray(this.searchResults),
|
|
324
373
|
searchParams: params
|
|
325
374
|
});
|
|
326
|
-
return _context5.abrupt("return",
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
375
|
+
return _context5.abrupt("return", {
|
|
376
|
+
type: 'normalCode',
|
|
377
|
+
data: searchResults
|
|
378
|
+
});
|
|
379
|
+
case 24:
|
|
380
|
+
_context5.prev = 24;
|
|
381
|
+
_context5.t0 = _context5["catch"](1);
|
|
330
382
|
console.error('[WalletPass] 搜索识别码信息失败:', _context5.t0);
|
|
331
383
|
throw _context5.t0;
|
|
332
|
-
case
|
|
384
|
+
case 28:
|
|
333
385
|
case "end":
|
|
334
386
|
return _context5.stop();
|
|
335
387
|
}
|
|
336
|
-
}, _callee5, this, [[
|
|
388
|
+
}, _callee5, this, [[1, 24]]);
|
|
337
389
|
}));
|
|
338
390
|
function searchIdentificationCodeAsync(_x5) {
|
|
339
391
|
return _searchIdentificationCodeAsync.apply(this, arguments);
|
|
@@ -107,29 +107,29 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
107
107
|
_step2;
|
|
108
108
|
try {
|
|
109
109
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
110
|
-
var
|
|
110
|
+
var _resource = _step2.value;
|
|
111
111
|
// 获取资源当天且还在工作时间内的时间段
|
|
112
|
-
var todayTimes =
|
|
112
|
+
var todayTimes = _resource.times.filter(function (time) {
|
|
113
113
|
var isToday = dayjs(time.start_at).isSame(currentTime, 'day');
|
|
114
114
|
var isStillWorking = dayjs(time.end_at).isAfter(currentTime);
|
|
115
115
|
return isToday && isStillWorking;
|
|
116
116
|
});
|
|
117
117
|
if (todayTimes.length === 0) {
|
|
118
|
-
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(
|
|
118
|
+
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, ") \u4ECA\u65E5\u65E0\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
121
|
-
var
|
|
122
|
-
|
|
121
|
+
var _iterator4 = _createForOfIteratorHelper(todayTimes),
|
|
122
|
+
_step4;
|
|
123
123
|
try {
|
|
124
124
|
var _loop = function _loop() {
|
|
125
125
|
var _time$event_list, _time$event_list2;
|
|
126
|
-
var time =
|
|
126
|
+
var time = _step4.value;
|
|
127
127
|
var workStartTime = dayjs(time.start_at);
|
|
128
128
|
var workEndTime = dayjs(time.end_at);
|
|
129
129
|
|
|
130
130
|
// 确定检查的起始时间(当前时间 vs 工作开始时间)
|
|
131
131
|
var nextAvailableTime = currentTime.isBefore(workStartTime) ? workStartTime : currentTime;
|
|
132
|
-
console.log("[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ".concat(
|
|
132
|
+
console.log("[TimeslotUtils] \u68C0\u67E5\u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, "):"), {
|
|
133
133
|
workTime: "".concat(workStartTime.format('HH:mm'), "-").concat(workEndTime.format('HH:mm')),
|
|
134
134
|
checkStartTime: nextAvailableTime.format('HH:mm:ss'),
|
|
135
135
|
eventCount: ((_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.length) || 0
|
|
@@ -148,40 +148,40 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
148
148
|
|
|
149
149
|
// 检查从 nextAvailableTime 开始的可用性
|
|
150
150
|
var finalAvailableTime = nextAvailableTime;
|
|
151
|
-
var
|
|
152
|
-
|
|
151
|
+
var _iterator5 = _createForOfIteratorHelper(relevantEvents),
|
|
152
|
+
_step5;
|
|
153
153
|
try {
|
|
154
|
-
for (
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
var
|
|
154
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
155
|
+
var _event = _step5.value;
|
|
156
|
+
var _eventStart = dayjs(_event.start_at);
|
|
157
|
+
var _eventEnd = dayjs(_event.end_at);
|
|
158
158
|
console.log("[TimeslotUtils] \u68C0\u67E5\u4E8B\u4EF6\u51B2\u7A81:", {
|
|
159
|
-
resourceId:
|
|
160
|
-
eventTime: "".concat(
|
|
159
|
+
resourceId: _resource.id,
|
|
160
|
+
eventTime: "".concat(_eventStart.format('HH:mm'), "-").concat(_eventEnd.format('HH:mm')),
|
|
161
161
|
checkTime: finalAvailableTime.format('HH:mm:ss'),
|
|
162
|
-
pax:
|
|
162
|
+
pax: _event.pax || 1
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
// 检查资源类型和容量
|
|
166
|
-
if (
|
|
166
|
+
if (_resource.resourceType === 'single' || (_resource.capacity || 1) === 1) {
|
|
167
167
|
// 单人预约资源:检查时间冲突
|
|
168
|
-
if (finalAvailableTime.isBefore(
|
|
168
|
+
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
|
|
169
169
|
// 有冲突,使用事件结束时间
|
|
170
|
-
finalAvailableTime =
|
|
170
|
+
finalAvailableTime = _eventEnd;
|
|
171
171
|
console.log("[TimeslotUtils] \u53D1\u73B0\u65F6\u95F4\u51B2\u7A81\uFF0C\u8C03\u6574\u5230: ".concat(finalAvailableTime.format('HH:mm:ss')));
|
|
172
172
|
}
|
|
173
173
|
} else {
|
|
174
174
|
// 多人预约资源:检查容量
|
|
175
|
-
var totalCapacity =
|
|
176
|
-
var currentUsedCapacity = countMap[
|
|
177
|
-
var eventUsedCapacity =
|
|
175
|
+
var totalCapacity = _resource.capacity || 0;
|
|
176
|
+
var currentUsedCapacity = countMap[_resource.id] || 0;
|
|
177
|
+
var eventUsedCapacity = _event.pax || 1;
|
|
178
178
|
|
|
179
179
|
// 如果在事件时间范围内,检查容量是否足够
|
|
180
|
-
if (finalAvailableTime.isBefore(
|
|
180
|
+
if (finalAvailableTime.isBefore(_eventEnd) && _eventStart.isBefore(finalAvailableTime.add(30, 'minute'))) {
|
|
181
181
|
var totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
182
182
|
if (totalRequiredCapacity > totalCapacity) {
|
|
183
183
|
// 容量不足,使用事件结束时间
|
|
184
|
-
finalAvailableTime =
|
|
184
|
+
finalAvailableTime = _eventEnd;
|
|
185
185
|
console.log("[TimeslotUtils] \u5BB9\u91CF\u4E0D\u8DB3\uFF0C\u8C03\u6574\u5230: ".concat(finalAvailableTime.format('HH:mm:ss')));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -190,38 +190,38 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
190
190
|
|
|
191
191
|
// 确保可用时间在工作时间内
|
|
192
192
|
} catch (err) {
|
|
193
|
-
|
|
193
|
+
_iterator5.e(err);
|
|
194
194
|
} finally {
|
|
195
|
-
|
|
195
|
+
_iterator5.f();
|
|
196
196
|
}
|
|
197
197
|
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
198
|
-
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(
|
|
198
|
+
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, " \u53EF\u7528\u65F6\u95F4\u8D85\u51FA\u5DE5\u4F5C\u65F6\u95F4\uFF0C\u8DF3\u8FC7"));
|
|
199
199
|
return 0; // continue
|
|
200
200
|
}
|
|
201
|
-
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(
|
|
201
|
+
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(_resource.id, "(").concat(_resource.main_field, ") \u6700\u5FEB\u53EF\u7528\u65F6\u95F4: ").concat(finalAvailableTime.format('HH:mm:ss')));
|
|
202
202
|
|
|
203
203
|
// 更新最快可用时间和资源
|
|
204
204
|
if (!fastestTime || finalAvailableTime.isBefore(fastestTime)) {
|
|
205
205
|
fastestTime = finalAvailableTime;
|
|
206
|
-
fastestResources = [
|
|
207
|
-
console.log("[TimeslotUtils] \u66F4\u65B0\u6700\u5FEB\u65F6\u95F4: ".concat(fastestTime.format('HH:mm:ss'), ", \u8D44\u6E90: ").concat(
|
|
206
|
+
fastestResources = [_resource];
|
|
207
|
+
console.log("[TimeslotUtils] \u66F4\u65B0\u6700\u5FEB\u65F6\u95F4: ".concat(fastestTime.format('HH:mm:ss'), ", \u8D44\u6E90: ").concat(_resource.main_field));
|
|
208
208
|
} else if (finalAvailableTime.isSame(fastestTime)) {
|
|
209
|
-
fastestResources.push(
|
|
210
|
-
console.log("[TimeslotUtils] \u6DFB\u52A0\u76F8\u540C\u65F6\u95F4\u8D44\u6E90: ".concat(
|
|
209
|
+
fastestResources.push(_resource);
|
|
210
|
+
console.log("[TimeslotUtils] \u6DFB\u52A0\u76F8\u540C\u65F6\u95F4\u8D44\u6E90: ".concat(_resource.main_field));
|
|
211
211
|
}
|
|
212
212
|
return 1; // break
|
|
213
213
|
// 每个资源只需要计算一次
|
|
214
214
|
},
|
|
215
215
|
_ret;
|
|
216
|
-
for (
|
|
216
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
217
217
|
_ret = _loop();
|
|
218
218
|
if (_ret === 0) continue;
|
|
219
219
|
if (_ret === 1) break;
|
|
220
220
|
}
|
|
221
221
|
} catch (err) {
|
|
222
|
-
|
|
222
|
+
_iterator4.e(err);
|
|
223
223
|
} finally {
|
|
224
|
-
|
|
224
|
+
_iterator4.f();
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -243,10 +243,60 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
243
243
|
return fastestResources[0];
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
//
|
|
247
|
-
// 这里简化处理,直接返回第一个
|
|
246
|
+
// 如果有多个最快可用的资源,选择空闲时间最长的资源
|
|
248
247
|
var selectedResource = fastestResources[0];
|
|
249
|
-
|
|
248
|
+
var maxIdleTime = 0;
|
|
249
|
+
console.log("[TimeslotUtils] \u6BD4\u8F83 ".concat(fastestResources.length, " \u4E2A\u8D44\u6E90\u7684\u7A7A\u95F2\u65F6\u95F4:"));
|
|
250
|
+
for (var _i2 = 0, _fastestResources = fastestResources; _i2 < _fastestResources.length; _i2++) {
|
|
251
|
+
var _workingTime$event_li;
|
|
252
|
+
var resource = _fastestResources[_i2];
|
|
253
|
+
// 找到该资源当天且还在工作的时间段
|
|
254
|
+
var workingTime = resource.times.find(function (time) {
|
|
255
|
+
var isToday = dayjs(time.start_at).isSame(fastestTime, 'day');
|
|
256
|
+
var isStillWorking = dayjs(time.end_at).isAfter(fastestTime);
|
|
257
|
+
return isToday && isStillWorking;
|
|
258
|
+
});
|
|
259
|
+
if (!workingTime) continue;
|
|
260
|
+
var workEndTime = dayjs(workingTime.end_at);
|
|
261
|
+
|
|
262
|
+
// 计算从最快可用时间到工作结束时间的空闲时长(分钟)
|
|
263
|
+
var totalIdleTime = workEndTime.diff(fastestTime, 'minute');
|
|
264
|
+
|
|
265
|
+
// 减去已有预约占用的时间
|
|
266
|
+
var relevantEvents = ((_workingTime$event_li = workingTime.event_list) === null || _workingTime$event_li === void 0 ? void 0 : _workingTime$event_li.filter(function (event) {
|
|
267
|
+
var eventStart = dayjs(event.start_at);
|
|
268
|
+
var eventEnd = dayjs(event.end_at);
|
|
269
|
+
// 只计算在最快可用时间之后的预约
|
|
270
|
+
return eventEnd.isAfter(fastestTime) && eventStart.isAfter(fastestTime);
|
|
271
|
+
})) || [];
|
|
272
|
+
var _iterator3 = _createForOfIteratorHelper(relevantEvents),
|
|
273
|
+
_step3;
|
|
274
|
+
try {
|
|
275
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
276
|
+
var event = _step3.value;
|
|
277
|
+
var eventStart = dayjs(event.start_at);
|
|
278
|
+
var eventEnd = dayjs(event.end_at);
|
|
279
|
+
var eventDuration = eventEnd.diff(eventStart, 'minute');
|
|
280
|
+
totalIdleTime -= eventDuration;
|
|
281
|
+
}
|
|
282
|
+
} catch (err) {
|
|
283
|
+
_iterator3.e(err);
|
|
284
|
+
} finally {
|
|
285
|
+
_iterator3.f();
|
|
286
|
+
}
|
|
287
|
+
console.log("[TimeslotUtils] \u8D44\u6E90 ".concat(resource.id, "(").concat(resource.main_field, "):"), {
|
|
288
|
+
工作结束时间: workEndTime.format('HH:mm'),
|
|
289
|
+
总工作时长: workEndTime.diff(fastestTime, 'minute') + '分钟',
|
|
290
|
+
预约占用时长: workEndTime.diff(fastestTime, 'minute') - totalIdleTime + '分钟',
|
|
291
|
+
实际空闲时长: totalIdleTime + '分钟'
|
|
292
|
+
});
|
|
293
|
+
if (totalIdleTime > maxIdleTime) {
|
|
294
|
+
maxIdleTime = totalIdleTime;
|
|
295
|
+
selectedResource = resource;
|
|
296
|
+
console.log("[TimeslotUtils] \u66F4\u65B0\u6700\u4F73\u9009\u62E9: ".concat(resource.main_field, " (\u7A7A\u95F2").concat(totalIdleTime, "\u5206\u949F)"));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
console.log("[TimeslotUtils] \u6700\u7EC8\u9009\u62E9\u8D44\u6E90: ".concat(selectedResource.main_field, " (\u6700\u957F\u7A7A\u95F2").concat(maxIdleTime, "\u5206\u949F)"));
|
|
250
300
|
return selectedResource;
|
|
251
301
|
}
|
|
252
302
|
|
|
@@ -131,6 +131,14 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
131
131
|
scanCustomerListener(callback: (data: IScanResult) => void): {
|
|
132
132
|
remove: () => void;
|
|
133
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* @title 通用扫描监听
|
|
136
|
+
* @description 直接将扫描结果返回给调用方
|
|
137
|
+
* @param callback 回调
|
|
138
|
+
*/
|
|
139
|
+
scanUniversalListener(callback: (data: IScanResult) => void, key: string): {
|
|
140
|
+
remove: () => void;
|
|
141
|
+
};
|
|
134
142
|
/**
|
|
135
143
|
* 调用摄像头
|
|
136
144
|
* @param data 用户自定义数据
|