@pisell/pisellos 1.0.66 → 1.0.67
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/Date/index.js +4 -0
- package/dist/modules/Order/index.js +10 -4
- package/dist/modules/Payment/index.d.ts +1 -0
- package/dist/modules/Payment/index.js +75 -41
- package/dist/modules/Payment/walletpass.js +3 -4
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +9 -0
- package/dist/solution/Checkout/index.d.ts +6 -148
- package/dist/solution/Checkout/index.js +1188 -2434
- package/dist/solution/Checkout/types.d.ts +7 -220
- package/dist/solution/Checkout/types.js +1 -49
- package/dist/solution/Checkout/utils/index.d.ts +9 -5
- package/dist/solution/Checkout/utils/index.js +18 -56
- package/lib/modules/Date/index.js +3 -0
- package/lib/modules/Order/index.js +6 -0
- package/lib/modules/Payment/index.d.ts +1 -0
- package/lib/modules/Payment/index.js +35 -8
- package/lib/modules/Payment/walletpass.js +2 -2
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +9 -0
- package/lib/solution/Checkout/index.d.ts +6 -148
- package/lib/solution/Checkout/index.js +337 -1115
- package/lib/solution/Checkout/types.d.ts +7 -220
- package/lib/solution/Checkout/types.js +3 -27
- package/lib/solution/Checkout/utils/index.d.ts +9 -5
- package/lib/solution/Checkout/utils/index.js +12 -53
- package/package.json +1 -1
|
@@ -267,6 +267,10 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
267
267
|
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
268
268
|
return resource;
|
|
269
269
|
}
|
|
270
|
+
// 如果resource.advanced 为 null 或者 resource.advanced.unit 为 0,则不进行修正
|
|
271
|
+
if (!resource.advanced || resource.advanced.unit === 0) {
|
|
272
|
+
return resource;
|
|
273
|
+
}
|
|
270
274
|
var resourceStartTime = dayjs(resource.start_time);
|
|
271
275
|
|
|
272
276
|
// 过滤和修正时间段
|
|
@@ -354,21 +354,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
354
354
|
return this.request.post('/order/checkout', orderData);
|
|
355
355
|
case 11:
|
|
356
356
|
response = _context3.sent;
|
|
357
|
+
this.logInfo('Order API called successfully', {
|
|
358
|
+
response: response
|
|
359
|
+
});
|
|
357
360
|
console.log('[Order] 订单创建成功,后端响应:', {
|
|
358
361
|
success: !!response,
|
|
359
362
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
360
363
|
});
|
|
361
364
|
return _context3.abrupt("return", response);
|
|
362
|
-
case
|
|
363
|
-
_context3.prev =
|
|
365
|
+
case 17:
|
|
366
|
+
_context3.prev = 17;
|
|
364
367
|
_context3.t0 = _context3["catch"](2);
|
|
365
368
|
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
369
|
+
this.logInfo('Order API called failed', {
|
|
370
|
+
error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
|
|
371
|
+
});
|
|
366
372
|
throw _context3.t0;
|
|
367
|
-
case
|
|
373
|
+
case 22:
|
|
368
374
|
case "end":
|
|
369
375
|
return _context3.stop();
|
|
370
376
|
}
|
|
371
|
-
}, _callee3, this, [[2,
|
|
377
|
+
}, _callee3, this, [[2, 17]]);
|
|
372
378
|
}));
|
|
373
379
|
function createOrderByCheckout(_x4) {
|
|
374
380
|
return _createOrderByCheckout.apply(this, arguments);
|
|
@@ -85,6 +85,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
// IndexDBManager 实例
|
|
86
86
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
87
87
|
// LoggerManager 实例
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
88
89
|
// 支付方式实例
|
|
89
90
|
_defineProperty(_assertThisInitialized(_this), "cash", void 0);
|
|
90
91
|
_defineProperty(_assertThisInitialized(_this), "eftpos", void 0);
|
|
@@ -104,34 +105,35 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
104
105
|
case 0:
|
|
105
106
|
this.core = core;
|
|
106
107
|
this.store = options.store;
|
|
108
|
+
this.otherParams = options.otherParams || {};
|
|
107
109
|
|
|
108
110
|
// 获取依赖的插件
|
|
109
111
|
this.request = core.getPlugin('request');
|
|
110
112
|
appPlugin = core.getPlugin('app');
|
|
111
113
|
if (this.request) {
|
|
112
|
-
_context.next =
|
|
114
|
+
_context.next = 7;
|
|
113
115
|
break;
|
|
114
116
|
}
|
|
115
117
|
throw new Error('支付模块需要 request 插件支持');
|
|
116
|
-
case
|
|
118
|
+
case 7:
|
|
117
119
|
if (appPlugin) {
|
|
118
|
-
_context.next =
|
|
120
|
+
_context.next = 9;
|
|
119
121
|
break;
|
|
120
122
|
}
|
|
121
123
|
throw new Error('支付模块需要 app 插件支持');
|
|
122
|
-
case
|
|
124
|
+
case 9:
|
|
123
125
|
this.app = appPlugin.getApp();
|
|
124
126
|
this.dbManager = this.app.dbManager;
|
|
125
127
|
this.logger = this.app.logger;
|
|
126
128
|
|
|
127
129
|
// 确保支付模块所需的对象存储已创建
|
|
128
|
-
_context.next =
|
|
130
|
+
_context.next = 14;
|
|
129
131
|
return this.ensurePaymentTables();
|
|
130
|
-
case
|
|
132
|
+
case 14:
|
|
131
133
|
this.registerNetworkHandlers();
|
|
132
134
|
console.log('[PaymentModule] 初始化完成');
|
|
133
135
|
this.logInfo('PaymentModule initialized successfully');
|
|
134
|
-
case
|
|
136
|
+
case 17:
|
|
135
137
|
case "end":
|
|
136
138
|
return _context.stop();
|
|
137
139
|
}
|
|
@@ -148,6 +150,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
150
|
}, {
|
|
149
151
|
key: "logInfo",
|
|
150
152
|
value: function logInfo(title, metadata) {
|
|
153
|
+
var _this$otherParams;
|
|
154
|
+
if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.fatherModule) {
|
|
155
|
+
var _this$otherParams2;
|
|
156
|
+
var fatherModule = this.core.getModule((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule);
|
|
157
|
+
if (fatherModule) {
|
|
158
|
+
fatherModule.logInfo("".concat(title), metadata);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
151
162
|
if (this.logger) {
|
|
152
163
|
this.logger.addLog({
|
|
153
164
|
type: 'info',
|
|
@@ -646,7 +657,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
646
657
|
key: "createPaymentOrderAsync",
|
|
647
658
|
value: (function () {
|
|
648
659
|
var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
649
|
-
var
|
|
660
|
+
var existingOrder, newOrder;
|
|
650
661
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
651
662
|
while (1) switch (_context7.prev = _context7.next) {
|
|
652
663
|
case 0:
|
|
@@ -656,19 +667,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
656
667
|
});
|
|
657
668
|
_context7.prev = 1;
|
|
658
669
|
_context7.next = 4;
|
|
659
|
-
return this.dbManager.
|
|
670
|
+
return this.dbManager.get('order', params.order_id);
|
|
660
671
|
case 4:
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
672
|
+
existingOrder = _context7.sent;
|
|
673
|
+
this.logInfo('createPaymentOrderAsync existingOrder', {
|
|
674
|
+
existingOrder: existingOrder
|
|
664
675
|
});
|
|
676
|
+
// const existingOrder = existingOrders.find(
|
|
677
|
+
// (order: PaymentOrder) => String(order.id) === String(params.order_id),
|
|
678
|
+
// );
|
|
665
679
|
if (!existingOrder) {
|
|
666
|
-
_context7.next =
|
|
680
|
+
_context7.next = 20;
|
|
667
681
|
break;
|
|
668
682
|
}
|
|
669
683
|
// 如果存在相同 order_id 的订单,更新该订单信息
|
|
670
|
-
|
|
671
|
-
|
|
684
|
+
this.logInfo("createPaymentOrderAsync found duplicate order ID: ".concat(params.order_id, ", updating existing payment order"));
|
|
685
|
+
|
|
686
|
+
// const originalOrder = { ...existingOrder };
|
|
672
687
|
existingOrder.order_info = params.order_info;
|
|
673
688
|
existingOrder.total_amount = params.total_amount;
|
|
674
689
|
existingOrder.is_deposit = params.is_deposit || 0;
|
|
@@ -678,14 +693,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
693
|
this.recalculateOrderAmount(existingOrder);
|
|
679
694
|
|
|
680
695
|
// 更新到数据库
|
|
681
|
-
_context7.next =
|
|
696
|
+
_context7.next = 15;
|
|
682
697
|
return this.dbManager.update('order', existingOrder);
|
|
683
|
-
case
|
|
684
|
-
_context7.next =
|
|
698
|
+
case 15:
|
|
699
|
+
_context7.next = 17;
|
|
685
700
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
|
|
686
|
-
case
|
|
701
|
+
case 17:
|
|
687
702
|
return _context7.abrupt("return", existingOrder);
|
|
688
|
-
case
|
|
703
|
+
case 20:
|
|
689
704
|
// 创建新的支付订单
|
|
690
705
|
newOrder = {
|
|
691
706
|
uuid: getUniqueId('pay_order_'),
|
|
@@ -701,33 +716,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
716
|
is_deposit: params.is_deposit || 0,
|
|
702
717
|
deposit_amount: params.deposit_amount || '0.00'
|
|
703
718
|
};
|
|
704
|
-
_context7.next =
|
|
719
|
+
_context7.next = 23;
|
|
705
720
|
return this.dbManager.add('order', newOrder);
|
|
706
|
-
case
|
|
707
|
-
|
|
708
|
-
return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
709
|
-
case 26:
|
|
721
|
+
case 23:
|
|
722
|
+
this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
710
723
|
this.logInfo('createPaymentOrderAsync completed - new payment order created', {
|
|
711
724
|
orderUuid: newOrder.uuid,
|
|
712
725
|
orderId: newOrder.id
|
|
713
726
|
});
|
|
714
727
|
return _context7.abrupt("return", newOrder);
|
|
715
|
-
case
|
|
716
|
-
_context7.next =
|
|
728
|
+
case 26:
|
|
729
|
+
_context7.next = 33;
|
|
717
730
|
break;
|
|
718
|
-
case
|
|
719
|
-
_context7.prev =
|
|
731
|
+
case 28:
|
|
732
|
+
_context7.prev = 28;
|
|
720
733
|
_context7.t0 = _context7["catch"](1);
|
|
721
734
|
console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
|
|
722
735
|
this.logError('createPaymentOrderAsync failed', _context7.t0, {
|
|
723
736
|
orderId: params.order_id
|
|
724
737
|
});
|
|
725
738
|
throw _context7.t0;
|
|
726
|
-
case
|
|
739
|
+
case 33:
|
|
727
740
|
case "end":
|
|
728
741
|
return _context7.stop();
|
|
729
742
|
}
|
|
730
|
-
}, _callee7, this, [[1,
|
|
743
|
+
}, _callee7, this, [[1, 28]]);
|
|
731
744
|
}));
|
|
732
745
|
function createPaymentOrderAsync(_x6) {
|
|
733
746
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
@@ -1030,7 +1043,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1030
1043
|
key: "addPaymentItemAsync",
|
|
1031
1044
|
value: (function () {
|
|
1032
1045
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
|
|
1033
|
-
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, paymentUuid, newPaymentItem;
|
|
1046
|
+
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1034
1047
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1035
1048
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1036
1049
|
case 0:
|
|
@@ -1051,6 +1064,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1051
1064
|
}
|
|
1052
1065
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
1053
1066
|
case 7:
|
|
1067
|
+
// 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
|
|
1068
|
+
expectAmount = new Decimal(order.expect_amount);
|
|
1069
|
+
if (!expectAmount.lte(0)) {
|
|
1070
|
+
_context13.next = 13;
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
1074
|
+
console.warn('[PaymentModule] Payment lock triggered:', {
|
|
1075
|
+
orderUuid: orderUuid,
|
|
1076
|
+
expectAmount: order.expect_amount,
|
|
1077
|
+
attemptedPaymentAmount: paymentItem.amount,
|
|
1078
|
+
attemptedPaymentCode: paymentItem.code,
|
|
1079
|
+
reason: 'Order already fully paid'
|
|
1080
|
+
});
|
|
1081
|
+
this.logError('addPaymentItemAsync blocked by payment lock', new Error(warningMessage), {
|
|
1082
|
+
orderUuid: orderUuid,
|
|
1083
|
+
expectAmount: order.expect_amount,
|
|
1084
|
+
paymentItem: paymentItem
|
|
1085
|
+
});
|
|
1086
|
+
throw new Error(warningMessage);
|
|
1087
|
+
case 13:
|
|
1054
1088
|
paymentUuid = getUniqueId('payment_');
|
|
1055
1089
|
newPaymentItem = {
|
|
1056
1090
|
uuid: paymentUuid,
|
|
@@ -1073,15 +1107,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1107
|
};
|
|
1074
1108
|
order.payment.push(newPaymentItem);
|
|
1075
1109
|
this.recalculateOrderAmount(order);
|
|
1076
|
-
_context13.next =
|
|
1110
|
+
_context13.next = 19;
|
|
1077
1111
|
return this.dbManager.update('order', order);
|
|
1078
|
-
case
|
|
1079
|
-
_context13.next =
|
|
1112
|
+
case 19:
|
|
1113
|
+
_context13.next = 21;
|
|
1080
1114
|
return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
1081
1115
|
orderUuid: orderUuid,
|
|
1082
1116
|
payment: newPaymentItem
|
|
1083
1117
|
});
|
|
1084
|
-
case
|
|
1118
|
+
case 21:
|
|
1085
1119
|
this.logInfo('addPaymentItemAsync completed successfully', {
|
|
1086
1120
|
orderUuid: orderUuid,
|
|
1087
1121
|
paymentUuid: newPaymentItem.uuid,
|
|
@@ -1095,10 +1129,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
1129
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1096
1130
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1097
1131
|
});
|
|
1098
|
-
_context13.next =
|
|
1132
|
+
_context13.next = 29;
|
|
1099
1133
|
break;
|
|
1100
|
-
case
|
|
1101
|
-
_context13.prev =
|
|
1134
|
+
case 24:
|
|
1135
|
+
_context13.prev = 24;
|
|
1102
1136
|
_context13.t0 = _context13["catch"](1);
|
|
1103
1137
|
console.error('[PaymentModule] 添加支付项失败', _context13.t0);
|
|
1104
1138
|
this.logError('addPaymentItemAsync failed', _context13.t0, {
|
|
@@ -1106,11 +1140,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1106
1140
|
paymentItem: paymentItem
|
|
1107
1141
|
});
|
|
1108
1142
|
throw _context13.t0;
|
|
1109
|
-
case
|
|
1143
|
+
case 29:
|
|
1110
1144
|
case "end":
|
|
1111
1145
|
return _context13.stop();
|
|
1112
1146
|
}
|
|
1113
|
-
}, _callee13, this, [[1,
|
|
1147
|
+
}, _callee13, this, [[1, 24]]);
|
|
1114
1148
|
}));
|
|
1115
1149
|
function addPaymentItemAsync(_x14, _x15) {
|
|
1116
1150
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -406,9 +406,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// 检查识别码是否为9位且前3位为"000"
|
|
409
|
-
|
|
410
|
-
//
|
|
411
|
-
isWalletCode = code.startsWith('WL');
|
|
409
|
+
isWalletCode = code.length === 9 && code.startsWith('000'); // 测试环境先使用 WL
|
|
410
|
+
// const isWalletCode = code.startsWith('WL');
|
|
412
411
|
if (!isWalletCode) {
|
|
413
412
|
_context5.next = 14;
|
|
414
413
|
break;
|
|
@@ -443,7 +442,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
443
442
|
baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
|
|
444
443
|
searchParams = {
|
|
445
444
|
// 基础钱包参数
|
|
446
|
-
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel),
|
|
445
|
+
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) || "pos",
|
|
447
446
|
customer_id: params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
|
|
448
447
|
order_expect_amount: params.order_expect_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount),
|
|
449
448
|
order_product_amount: params.order_product_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount),
|
|
@@ -254,6 +254,15 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
254
|
var _schedule$repeat_rule, _schedule$repeat_rule2;
|
|
255
255
|
var date = _ref2.date,
|
|
256
256
|
schedule = _ref2.schedule;
|
|
257
|
+
if (schedule.start_time && schedule.end_time) {
|
|
258
|
+
var isBeforeStartTime = dayjs(date).isBefore(dayjs(schedule.start_time));
|
|
259
|
+
var isAfterEndTime = dayjs(date).isAfter(dayjs(schedule.end_time));
|
|
260
|
+
// 如果不在 schedule 日期区间内直接返回false
|
|
261
|
+
if (isBeforeStartTime || isAfterEndTime) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
257
266
|
// 节约性能, 强制将schedule的时间范围改为前后一天,避免大量计算.
|
|
258
267
|
var _schedule = _objectSpread(_objectSpread({}, schedule), {}, {
|
|
259
268
|
// 开始时间向前推一天
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { OrderModule } from '../../modules/Order';
|
|
4
4
|
import { PaymentModule } from '../../modules/Payment';
|
|
5
|
-
import { CheckoutModuleAPI,
|
|
5
|
+
import { CheckoutModuleAPI, CheckoutInitParams, CreateLocalOrderParams, CurrentOrderInfo, CartSummaryItem, SendCustomerPayLinkParams } from './types';
|
|
6
6
|
import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
|
|
7
7
|
export * from './types';
|
|
8
8
|
/**
|
|
@@ -64,24 +64,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
64
64
|
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
65
65
|
*/
|
|
66
66
|
createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
|
|
67
|
-
/**
|
|
68
|
-
* 手动下单 (根据虚拟订单生成实际订单)
|
|
69
|
-
*
|
|
70
|
-
* 使用当前存储的本地订单数据调用 Order 模块创建真实订单
|
|
71
|
-
*/
|
|
72
|
-
placeOrderAsync(params?: PlaceOrderParams): Promise<{
|
|
73
|
-
success: boolean;
|
|
74
|
-
orderId?: string;
|
|
75
|
-
error?: string;
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* 创建订单
|
|
79
|
-
*/
|
|
80
|
-
createOrderAsync(params: CreateOrderParams): Promise<PaymentOrder>;
|
|
81
|
-
/**
|
|
82
|
-
* 处理支付
|
|
83
|
-
*/
|
|
84
|
-
processPaymentAsync(params: ProcessPaymentParams): Promise<void>;
|
|
85
67
|
/**
|
|
86
68
|
* 完成结账
|
|
87
69
|
*/
|
|
@@ -89,28 +71,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
89
71
|
success: boolean;
|
|
90
72
|
orderId?: string;
|
|
91
73
|
}>;
|
|
92
|
-
/**
|
|
93
|
-
* 取消结账
|
|
94
|
-
*/
|
|
95
|
-
cancelCheckoutAsync(): Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* 获取结账状态
|
|
98
|
-
*/
|
|
99
|
-
getCheckoutStatus(): CheckoutStatusInfo;
|
|
100
|
-
/**
|
|
101
|
-
* 获取结账摘要
|
|
102
|
-
*/
|
|
103
|
-
getCheckoutSummaryAsync(): Promise<CheckoutSummary>;
|
|
104
|
-
/**
|
|
105
|
-
* 获取可用支付方式
|
|
106
|
-
*/
|
|
107
|
-
getAvailablePaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
108
|
-
/**
|
|
109
|
-
* 刷新支付方式缓存
|
|
110
|
-
*
|
|
111
|
-
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
112
|
-
*/
|
|
113
|
-
refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
114
74
|
/**
|
|
115
75
|
* 获取订单原始数据
|
|
116
76
|
*/
|
|
@@ -127,21 +87,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
127
87
|
* 返回当前订单的所有支付项,包括活跃和已撤销的支付项
|
|
128
88
|
*/
|
|
129
89
|
getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
|
|
130
|
-
/**
|
|
131
|
-
* 验证结账前置条件
|
|
132
|
-
*/
|
|
133
|
-
validateCheckoutAsync(): Promise<{
|
|
134
|
-
valid: boolean;
|
|
135
|
-
errors: string[];
|
|
136
|
-
}>;
|
|
137
|
-
/**
|
|
138
|
-
* 重试失败的操作
|
|
139
|
-
*/
|
|
140
|
-
retryFailedOperationAsync(): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* 设置当前步骤
|
|
143
|
-
*/
|
|
144
|
-
setCurrentStep(step: CheckoutStep): void;
|
|
145
90
|
/**
|
|
146
91
|
* 获取订单模块
|
|
147
92
|
*/
|
|
@@ -181,12 +126,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
181
126
|
* @returns 当前系统计算的待付金额
|
|
182
127
|
*/
|
|
183
128
|
getBalanceDueAmount(): string;
|
|
184
|
-
/**
|
|
185
|
-
* 刷新 stateAmount 为当前剩余未支付金额
|
|
186
|
-
*
|
|
187
|
-
* UI 可以调用此方法来主动刷新支付金额状态
|
|
188
|
-
*/
|
|
189
|
-
refreshStateAmountAsync(): Promise<void>;
|
|
190
129
|
/**
|
|
191
130
|
* 获取购物车小计数据
|
|
192
131
|
*
|
|
@@ -195,14 +134,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
195
134
|
* @returns 购物车小计数据数组,如果没有则返回 null
|
|
196
135
|
*/
|
|
197
136
|
getCartSummary(): CartSummaryItem[] | null;
|
|
198
|
-
/**
|
|
199
|
-
* 获取提取的金额详细信息
|
|
200
|
-
*
|
|
201
|
-
* 从当前的购物车小计数据中提取结构化的金额信息
|
|
202
|
-
*
|
|
203
|
-
* @returns 提取的金额信息对象,如果没有小计数据则返回 null
|
|
204
|
-
*/
|
|
205
|
-
getExtractedAmountInfo(): ExtractedAmountInfo | null;
|
|
206
137
|
/**
|
|
207
138
|
* 获取支付方式列表
|
|
208
139
|
*
|
|
@@ -252,33 +183,15 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
252
183
|
*/
|
|
253
184
|
updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
|
|
254
185
|
/**
|
|
255
|
-
*
|
|
186
|
+
* 手动设置当前订单的定金金额
|
|
256
187
|
*
|
|
257
|
-
*
|
|
188
|
+
* 允许手动设置订单的定金金额,通常用于用户自定义定金支付场景
|
|
258
189
|
*
|
|
259
|
-
* @param
|
|
190
|
+
* @param depositAmount 定金金额,必须是有效的数字字符串,且不能超过订单总额
|
|
260
191
|
* @throws 当前没有活跃订单时抛出错误
|
|
192
|
+
* @throws 定金金额格式无效或超过订单总额时抛出错误
|
|
261
193
|
*/
|
|
262
|
-
|
|
263
|
-
customer_id?: string;
|
|
264
|
-
customer_name?: string;
|
|
265
|
-
}): Promise<void>;
|
|
266
|
-
/**
|
|
267
|
-
* 获取当前订单的客户信息
|
|
268
|
-
*
|
|
269
|
-
* @returns 当前客户信息,如果没有则返回 null
|
|
270
|
-
*/
|
|
271
|
-
getCurrentCustomer(): {
|
|
272
|
-
customer_id?: string;
|
|
273
|
-
customer_name?: string;
|
|
274
|
-
} | null;
|
|
275
|
-
/**
|
|
276
|
-
* 检查订单是否需要手动同步(异步版本)
|
|
277
|
-
*
|
|
278
|
-
* 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
|
|
279
|
-
* 从 Payment 模块获取最新的支付项数据
|
|
280
|
-
*/
|
|
281
|
-
needsManualSyncAsync(): Promise<boolean>;
|
|
194
|
+
setDepositAmountAsync(depositAmount: string): Promise<void>;
|
|
282
195
|
/**
|
|
283
196
|
* 手动同步订单到后端
|
|
284
197
|
*
|
|
@@ -335,34 +248,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
335
248
|
orderUuid?: string;
|
|
336
249
|
response?: any;
|
|
337
250
|
}>;
|
|
338
|
-
/**
|
|
339
|
-
* 获取当前商店折扣金额
|
|
340
|
-
*
|
|
341
|
-
* @returns 当前的商店折扣金额,如果没有则返回0
|
|
342
|
-
*/
|
|
343
|
-
getShopDiscount(): number;
|
|
344
|
-
/**
|
|
345
|
-
* 更新订单商店折扣
|
|
346
|
-
*
|
|
347
|
-
* 同时更新cartSummary和localOrderData中的shop_discount值
|
|
348
|
-
*
|
|
349
|
-
* @param discountAmount 商店折扣金额
|
|
350
|
-
*/
|
|
351
|
-
updateShopDiscountAsync(discountAmount: number): Promise<void>;
|
|
352
251
|
/**
|
|
353
252
|
* 更新订单备注
|
|
354
253
|
*
|
|
355
254
|
* @param note 订单备注内容
|
|
356
255
|
*/
|
|
357
256
|
updateOrderNoteAsync(note: string): Promise<void>;
|
|
358
|
-
/**
|
|
359
|
-
* 设置状态
|
|
360
|
-
*/
|
|
361
|
-
private setStatus;
|
|
362
|
-
/**
|
|
363
|
-
* 设置步骤
|
|
364
|
-
*/
|
|
365
|
-
private setStep;
|
|
366
257
|
/**
|
|
367
258
|
* 处理错误
|
|
368
259
|
*/
|
|
@@ -386,14 +277,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
386
277
|
* @returns 处理后的支付项(包含找零信息)
|
|
387
278
|
*/
|
|
388
279
|
private processCashPaymentItem;
|
|
389
|
-
/**
|
|
390
|
-
* 判断是否为现金支付
|
|
391
|
-
*
|
|
392
|
-
* @param paymentCode 支付代码
|
|
393
|
-
* @param paymentType 支付类型
|
|
394
|
-
* @returns 是否为现金支付
|
|
395
|
-
*/
|
|
396
|
-
private isCashPayment;
|
|
397
280
|
/**
|
|
398
281
|
* 预加载支付方式(在初始化时调用)
|
|
399
282
|
*/
|
|
@@ -426,11 +309,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
426
309
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
427
310
|
*/
|
|
428
311
|
private checkOrderPaymentCompletion;
|
|
429
|
-
/**
|
|
430
|
-
* 同步订单到后端
|
|
431
|
-
*
|
|
432
|
-
* 调用后端 /order/checkout 接口创建真实订单
|
|
433
|
-
*/
|
|
434
312
|
/**
|
|
435
313
|
* 同步订单到后端并返回真实订单ID
|
|
436
314
|
*
|
|
@@ -439,11 +317,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
439
317
|
* @returns 包含订单ID、UUID和完整后端响应的对象
|
|
440
318
|
*/
|
|
441
319
|
private syncOrderToBackendWithReturn;
|
|
442
|
-
private syncOrderToBackend;
|
|
443
|
-
/**
|
|
444
|
-
* 获取状态消息
|
|
445
|
-
*/
|
|
446
|
-
private getStatusMessage;
|
|
447
320
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
448
321
|
cover?: boolean;
|
|
449
322
|
}): Promise<void>;
|
|
@@ -491,19 +364,4 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
491
364
|
* 在创建新订单前调用,确保状态完全干净
|
|
492
365
|
*/
|
|
493
366
|
private resetStoreStateAsync;
|
|
494
|
-
/**
|
|
495
|
-
* 手动清理已完成的订单状态(公开方法)
|
|
496
|
-
*
|
|
497
|
-
* 供UI层调用的公开方法,用于手动清理订单状态
|
|
498
|
-
*
|
|
499
|
-
* @returns 清理结果
|
|
500
|
-
*/
|
|
501
|
-
clearCompletedOrderAsync(): Promise<{
|
|
502
|
-
success: boolean;
|
|
503
|
-
message?: string;
|
|
504
|
-
clearedOrder?: {
|
|
505
|
-
uuid: string;
|
|
506
|
-
orderId: string;
|
|
507
|
-
} | null;
|
|
508
|
-
}>;
|
|
509
367
|
}
|