@pisell/pisellos 0.0.256 → 0.0.258
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/Discount/types.d.ts +3 -0
- package/dist/modules/Order/index.js +10 -4
- package/dist/modules/Payment/index.d.ts +1 -0
- package/dist/modules/Payment/index.js +38 -31
- package/dist/modules/Payment/walletpass.js +1 -1
- package/dist/modules/Rules/index.js +35 -10
- package/dist/modules/Schedule/index.d.ts +1 -1
- package/dist/modules/Schedule/index.js +9 -0
- package/dist/solution/Checkout/index.d.ts +1 -153
- package/dist/solution/Checkout/index.js +1040 -2504
- package/dist/solution/Checkout/types.d.ts +0 -221
- package/dist/solution/Checkout/types.js +0 -49
- package/dist/solution/Checkout/utils/index.d.ts +9 -5
- package/dist/solution/Checkout/utils/index.js +18 -56
- package/dist/solution/ShopDiscount/utils.d.ts +11 -0
- package/dist/solution/ShopDiscount/utils.js +29 -0
- package/lib/modules/Discount/types.d.ts +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 +13 -6
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/modules/Rules/index.js +21 -5
- package/lib/modules/Schedule/index.d.ts +1 -1
- package/lib/modules/Schedule/index.js +9 -0
- package/lib/solution/Checkout/index.d.ts +1 -153
- package/lib/solution/Checkout/index.js +219 -1148
- package/lib/solution/Checkout/types.d.ts +0 -221
- package/lib/solution/Checkout/types.js +2 -27
- package/lib/solution/Checkout/utils/index.d.ts +9 -5
- package/lib/solution/Checkout/utils/index.js +12 -53
- package/lib/solution/ShopDiscount/utils.d.ts +11 -0
- package/lib/solution/ShopDiscount/utils.js +24 -0
- package/package.json +1 -1
|
@@ -70,6 +70,9 @@ export interface Discount {
|
|
|
70
70
|
limited_relation_product_data: Limitedrelationproductdata;
|
|
71
71
|
balance: string;
|
|
72
72
|
format_title: Formattitle;
|
|
73
|
+
metadata?: {
|
|
74
|
+
discount_card_type?: 'fixed_amount' | 'percent';
|
|
75
|
+
};
|
|
73
76
|
product: Product;
|
|
74
77
|
type: "product" | 'good_pass';
|
|
75
78
|
resource_id?: number;
|
|
@@ -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,17 @@ 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
|
-
existingOrder = existingOrders.find(function (order) {
|
|
663
|
-
return String(order.id) === String(params.order_id);
|
|
664
|
-
});
|
|
672
|
+
existingOrder = _context7.sent;
|
|
665
673
|
if (!existingOrder) {
|
|
666
|
-
_context7.next =
|
|
674
|
+
_context7.next = 19;
|
|
667
675
|
break;
|
|
668
676
|
}
|
|
669
677
|
// 如果存在相同 order_id 的订单,更新该订单信息
|
|
670
678
|
console.log("[PaymentModule] \u53D1\u73B0\u91CD\u590D\u8BA2\u5355 ID: ".concat(params.order_id, "\uFF0C\u66F4\u65B0\u73B0\u6709\u652F\u4ED8\u8BA2\u5355"));
|
|
671
|
-
|
|
679
|
+
|
|
680
|
+
// const originalOrder = { ...existingOrder };
|
|
672
681
|
existingOrder.order_info = params.order_info;
|
|
673
682
|
existingOrder.total_amount = params.total_amount;
|
|
674
683
|
existingOrder.is_deposit = params.is_deposit || 0;
|
|
@@ -678,14 +687,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
687
|
this.recalculateOrderAmount(existingOrder);
|
|
679
688
|
|
|
680
689
|
// 更新到数据库
|
|
681
|
-
_context7.next =
|
|
690
|
+
_context7.next = 14;
|
|
682
691
|
return this.dbManager.update('order', existingOrder);
|
|
683
|
-
case
|
|
684
|
-
_context7.next =
|
|
692
|
+
case 14:
|
|
693
|
+
_context7.next = 16;
|
|
685
694
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
|
|
686
|
-
case
|
|
695
|
+
case 16:
|
|
687
696
|
return _context7.abrupt("return", existingOrder);
|
|
688
|
-
case
|
|
697
|
+
case 19:
|
|
689
698
|
// 创建新的支付订单
|
|
690
699
|
newOrder = {
|
|
691
700
|
uuid: getUniqueId('pay_order_'),
|
|
@@ -701,33 +710,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
710
|
is_deposit: params.is_deposit || 0,
|
|
702
711
|
deposit_amount: params.deposit_amount || '0.00'
|
|
703
712
|
};
|
|
704
|
-
_context7.next =
|
|
713
|
+
_context7.next = 22;
|
|
705
714
|
return this.dbManager.add('order', newOrder);
|
|
706
|
-
case
|
|
707
|
-
|
|
708
|
-
return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
709
|
-
case 26:
|
|
715
|
+
case 22:
|
|
716
|
+
this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
710
717
|
this.logInfo('createPaymentOrderAsync completed - new payment order created', {
|
|
711
718
|
orderUuid: newOrder.uuid,
|
|
712
719
|
orderId: newOrder.id
|
|
713
720
|
});
|
|
714
721
|
return _context7.abrupt("return", newOrder);
|
|
715
|
-
case
|
|
716
|
-
_context7.next =
|
|
722
|
+
case 25:
|
|
723
|
+
_context7.next = 32;
|
|
717
724
|
break;
|
|
718
|
-
case
|
|
719
|
-
_context7.prev =
|
|
725
|
+
case 27:
|
|
726
|
+
_context7.prev = 27;
|
|
720
727
|
_context7.t0 = _context7["catch"](1);
|
|
721
728
|
console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
|
|
722
729
|
this.logError('createPaymentOrderAsync failed', _context7.t0, {
|
|
723
730
|
orderId: params.order_id
|
|
724
731
|
});
|
|
725
732
|
throw _context7.t0;
|
|
726
|
-
case
|
|
733
|
+
case 32:
|
|
727
734
|
case "end":
|
|
728
735
|
return _context7.stop();
|
|
729
736
|
}
|
|
730
|
-
}, _callee7, this, [[1,
|
|
737
|
+
}, _callee7, this, [[1, 27]]);
|
|
731
738
|
}));
|
|
732
739
|
function createPaymentOrderAsync(_x6) {
|
|
733
740
|
return _createPaymentOrderAsync.apply(this, arguments);
|
|
@@ -443,7 +443,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
443
443
|
baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
|
|
444
444
|
searchParams = {
|
|
445
445
|
// 基础钱包参数
|
|
446
|
-
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel),
|
|
446
|
+
sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) || "pos",
|
|
447
447
|
customer_id: params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
|
|
448
448
|
order_expect_amount: params.order_expect_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount),
|
|
449
449
|
order_product_amount: params.order_product_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount),
|
|
@@ -25,7 +25,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
25
25
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
27
|
import { RulesHooks } from "./types";
|
|
28
|
-
import { uniqueById } from "../../solution/ShopDiscount/utils";
|
|
28
|
+
import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils";
|
|
29
29
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
30
30
|
import Decimal from 'decimal.js';
|
|
31
31
|
import { isBoolean } from 'lodash-es';
|
|
@@ -189,8 +189,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
// 优惠力度排序,传进来的数据里可能有商品券,也可能有优惠券
|
|
192
|
-
// 商品券(n.tag=good_pass
|
|
193
|
-
//
|
|
192
|
+
// 1. 商品券(n.tag=good_pass)视为最优惠(免费)
|
|
193
|
+
// 2. 折扣券(n.tag=product_discount_card)按照新的优先级排序:
|
|
194
|
+
// - 固定金额优先于百分比(固定金额 > 百分比)
|
|
195
|
+
// - 固定金额内部:金额越大越优先
|
|
196
|
+
// - 百分比内部:折扣越大越优先(par_value越小越优先)
|
|
197
|
+
// 3. 相同类型和金额的情况下,按照过期时间(n.expire_time)排序
|
|
194
198
|
var sortedDiscountList = _toConsumableArray(filteredDiscountList).sort(function (a, b) {
|
|
195
199
|
// 1. 商品券优先级最高
|
|
196
200
|
if (a.tag === 'good_pass' && b.tag !== 'good_pass') return -1;
|
|
@@ -201,13 +205,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
205
|
// 都是商品券,按照过期时间排序
|
|
202
206
|
return compareByExpireTime(a, b);
|
|
203
207
|
} else if (a.tag === 'product_discount_card' && b.tag === 'product_discount_card') {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
var _a$metadata, _b$metadata;
|
|
209
|
+
// 都是折扣券,按照新的优先级排序:固定金额优先于百分比
|
|
210
|
+
var typeA = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 ? void 0 : _a$metadata.discount_card_type) || 'percent'; // 默认为百分比
|
|
211
|
+
var typeB = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : _b$metadata.discount_card_type) || 'percent'; // 默认为百分比
|
|
212
|
+
|
|
213
|
+
// 1. 固定金额优先于百分比
|
|
214
|
+
if (typeA === 'fixed_amount' && typeB === 'percent') return -1;
|
|
215
|
+
if (typeA === 'percent' && typeB === 'fixed_amount') return 1;
|
|
216
|
+
|
|
217
|
+
// 2. 都是固定金额时,金额越大越优先
|
|
218
|
+
if (typeA === 'fixed_amount' && typeB === 'fixed_amount') {
|
|
219
|
+
if (a.par_value !== b.par_value) {
|
|
220
|
+
var valueA = new Decimal(a.par_value || 0);
|
|
221
|
+
var valueB = new Decimal(b.par_value || 0);
|
|
222
|
+
return valueB.minus(valueA).toNumber(); // 金额大的在前
|
|
223
|
+
}
|
|
209
224
|
}
|
|
210
|
-
|
|
225
|
+
|
|
226
|
+
// 3. 都是百分比时,折扣越大越优先(par_value越小越优先)
|
|
227
|
+
if (typeA === 'percent' && typeB === 'percent') {
|
|
228
|
+
if (a.par_value !== b.par_value) {
|
|
229
|
+
var _valueA = new Decimal(100).minus(a.par_value || 0);
|
|
230
|
+
var _valueB = new Decimal(100).minus(b.par_value || 0);
|
|
231
|
+
return _valueB.minus(_valueA).toNumber(); // 折扣大的在前
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 相同类型和金额的情况下,按照过期时间排序
|
|
211
236
|
return compareByExpireTime(a, b);
|
|
212
237
|
}
|
|
213
238
|
|
|
@@ -465,7 +490,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
490
|
}
|
|
466
491
|
|
|
467
492
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
468
|
-
var targetProductTotal = _selectedDiscount
|
|
493
|
+
var targetProductTotal = getDiscountAmount(_selectedDiscount, productOriginTotal, product.price);
|
|
469
494
|
var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
|
|
470
495
|
var discountDetail = {
|
|
471
496
|
amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
@@ -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
|
*
|
|
@@ -251,34 +182,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
251
182
|
* @throws 当前没有活跃订单时抛出错误
|
|
252
183
|
*/
|
|
253
184
|
updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
|
|
254
|
-
/**
|
|
255
|
-
* 更新当前订单的客户信息
|
|
256
|
-
*
|
|
257
|
-
* 更新当前订单关联的客户信息,用于标识订单的所属客户
|
|
258
|
-
*
|
|
259
|
-
* @param customer 客户信息 (customer_id 和/或 customer_name)
|
|
260
|
-
* @throws 当前没有活跃订单时抛出错误
|
|
261
|
-
*/
|
|
262
|
-
updateOrderCustomerAsync(customer: {
|
|
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>;
|
|
282
185
|
/**
|
|
283
186
|
* 手动同步订单到后端
|
|
284
187
|
*
|
|
@@ -335,34 +238,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
335
238
|
orderUuid?: string;
|
|
336
239
|
response?: any;
|
|
337
240
|
}>;
|
|
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
241
|
/**
|
|
353
242
|
* 更新订单备注
|
|
354
243
|
*
|
|
355
244
|
* @param note 订单备注内容
|
|
356
245
|
*/
|
|
357
246
|
updateOrderNoteAsync(note: string): Promise<void>;
|
|
358
|
-
/**
|
|
359
|
-
* 设置状态
|
|
360
|
-
*/
|
|
361
|
-
private setStatus;
|
|
362
|
-
/**
|
|
363
|
-
* 设置步骤
|
|
364
|
-
*/
|
|
365
|
-
private setStep;
|
|
366
247
|
/**
|
|
367
248
|
* 处理错误
|
|
368
249
|
*/
|
|
@@ -386,14 +267,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
386
267
|
* @returns 处理后的支付项(包含找零信息)
|
|
387
268
|
*/
|
|
388
269
|
private processCashPaymentItem;
|
|
389
|
-
/**
|
|
390
|
-
* 判断是否为现金支付
|
|
391
|
-
*
|
|
392
|
-
* @param paymentCode 支付代码
|
|
393
|
-
* @param paymentType 支付类型
|
|
394
|
-
* @returns 是否为现金支付
|
|
395
|
-
*/
|
|
396
|
-
private isCashPayment;
|
|
397
270
|
/**
|
|
398
271
|
* 预加载支付方式(在初始化时调用)
|
|
399
272
|
*/
|
|
@@ -426,11 +299,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
426
299
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
427
300
|
*/
|
|
428
301
|
private checkOrderPaymentCompletion;
|
|
429
|
-
/**
|
|
430
|
-
* 同步订单到后端
|
|
431
|
-
*
|
|
432
|
-
* 调用后端 /order/checkout 接口创建真实订单
|
|
433
|
-
*/
|
|
434
302
|
/**
|
|
435
303
|
* 同步订单到后端并返回真实订单ID
|
|
436
304
|
*
|
|
@@ -439,11 +307,6 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
439
307
|
* @returns 包含订单ID、UUID和完整后端响应的对象
|
|
440
308
|
*/
|
|
441
309
|
private syncOrderToBackendWithReturn;
|
|
442
|
-
private syncOrderToBackend;
|
|
443
|
-
/**
|
|
444
|
-
* 获取状态消息
|
|
445
|
-
*/
|
|
446
|
-
private getStatusMessage;
|
|
447
310
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
448
311
|
cover?: boolean;
|
|
449
312
|
}): Promise<void>;
|
|
@@ -491,19 +354,4 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
491
354
|
* 在创建新订单前调用,确保状态完全干净
|
|
492
355
|
*/
|
|
493
356
|
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
357
|
}
|