@pisell/pisellos 0.0.285 → 0.0.286
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/Cart/index.d.ts +1 -0
- package/dist/modules/Cart/index.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +2 -2
- package/dist/modules/Order/index.js +8 -13
- package/dist/modules/Payment/index.js +5 -3
- package/dist/modules/Payment/types.d.ts +17 -0
- package/dist/modules/Payment/walletpass.js +14 -8
- package/dist/solution/Checkout/index.d.ts +8 -1
- package/dist/solution/Checkout/index.js +866 -648
- package/dist/solution/Checkout/types.d.ts +17 -0
- package/dist/solution/Checkout/types.js +4 -0
- package/lib/modules/Cart/index.d.ts +1 -0
- package/lib/modules/Cart/index.js +4 -1
- package/lib/modules/Cart/utils/cartResource.js +0 -2
- package/lib/modules/Order/index.js +1 -4
- package/lib/modules/Payment/index.js +3 -2
- package/lib/modules/Payment/types.d.ts +17 -0
- package/lib/modules/Payment/walletpass.js +13 -7
- package/lib/solution/Checkout/index.d.ts +8 -1
- package/lib/solution/Checkout/index.js +128 -2
- package/lib/solution/Checkout/types.d.ts +17 -0
- package/package.json +1 -1
|
@@ -91,6 +91,19 @@ export interface CreateLocalOrderParams {
|
|
|
91
91
|
autoPayment?: boolean;
|
|
92
92
|
totalInfo: any;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* 本地订单更新参数
|
|
96
|
+
*/
|
|
97
|
+
export interface UpdateLocalOrderParams {
|
|
98
|
+
/** 要更新的后端订单ID(已同步过后端的订单) */
|
|
99
|
+
orderId: string;
|
|
100
|
+
/** 更新后的订单数据(结构与创建时一致,允许部分字段变化) */
|
|
101
|
+
orderData: LocalOrderData;
|
|
102
|
+
/** 更新后的购物车小计数据 */
|
|
103
|
+
cartSummary: CartSummaryItem[];
|
|
104
|
+
/** total 信息(用于拆解金额) */
|
|
105
|
+
totalInfo: any;
|
|
106
|
+
}
|
|
94
107
|
/**
|
|
95
108
|
* 本地订单数据结构 (基于 appointmentDemo.json)
|
|
96
109
|
*/
|
|
@@ -373,6 +386,10 @@ export interface CheckoutModuleAPI extends Module {
|
|
|
373
386
|
* 创建本地订单 (前端模拟下单流程)
|
|
374
387
|
*/
|
|
375
388
|
createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
|
|
389
|
+
/**
|
|
390
|
+
* 更新本地订单(基于已同步后的真实 orderId)并设置为当前订单
|
|
391
|
+
*/
|
|
392
|
+
updateLocalOrderAsync(params: UpdateLocalOrderParams): Promise<PaymentOrder>;
|
|
376
393
|
/**
|
|
377
394
|
* 完成结账
|
|
378
395
|
*/
|
|
@@ -3,6 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
import { Account } from '../Account';
|
|
5
5
|
export * from './types';
|
|
6
|
+
export { getProductDeposit } from './utils';
|
|
6
7
|
/**
|
|
7
8
|
* 购物车模块实现
|
|
8
9
|
*/
|
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/modules/Cart/index.ts
|
|
21
21
|
var Cart_exports = {};
|
|
22
22
|
__export(Cart_exports, {
|
|
23
|
-
CartModule: () => CartModule
|
|
23
|
+
CartModule: () => CartModule,
|
|
24
|
+
getProductDeposit: () => import_utils3.getProductDeposit
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(Cart_exports);
|
|
26
27
|
var import_BaseModule = require("../BaseModule");
|
|
@@ -29,6 +30,7 @@ var import_utils = require("./utils");
|
|
|
29
30
|
var import_lodash_es = require("lodash-es");
|
|
30
31
|
var import_utils2 = require("../Product/utils");
|
|
31
32
|
__reExport(Cart_exports, require("./types"), module.exports);
|
|
33
|
+
var import_utils3 = require("./utils");
|
|
32
34
|
var CartModule = class extends import_BaseModule.BaseModule {
|
|
33
35
|
constructor(name, version) {
|
|
34
36
|
super(name || "cart", version || "1.0.0");
|
|
@@ -361,5 +363,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
361
363
|
// Annotate the CommonJS export names for ESM import in node:
|
|
362
364
|
0 && (module.exports = {
|
|
363
365
|
CartModule,
|
|
366
|
+
getProductDeposit,
|
|
364
367
|
...require("./types")
|
|
365
368
|
});
|
|
@@ -226,16 +226,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
226
226
|
relation_products: [],
|
|
227
227
|
relation_forms: [],
|
|
228
228
|
payments: [],
|
|
229
|
+
is_full_overwrite_flag: 1,
|
|
229
230
|
...params
|
|
230
231
|
// 使用传入的参数覆盖默认值
|
|
231
232
|
};
|
|
232
233
|
if ((_h = orderData.payments) == null ? void 0 : _h.length) {
|
|
233
234
|
orderData.small_ticket_data_flag = 1;
|
|
234
235
|
}
|
|
235
|
-
if (params.order_id) {
|
|
236
|
-
orderData.bookings = [];
|
|
237
|
-
orderData.relation_products = [];
|
|
238
|
-
}
|
|
239
236
|
if (!params.order_id && !orderData.schedule_date) {
|
|
240
237
|
orderData.schedule_date = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
241
238
|
}
|
|
@@ -671,7 +671,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
671
671
|
throw new Error(`订单不存在: ${orderUuid}`);
|
|
672
672
|
}
|
|
673
673
|
const existingVoucherItems = order.payment.filter(
|
|
674
|
-
(payment) => payment.voucher_id && payment.status !== "voided"
|
|
674
|
+
(payment) => payment.voucher_id && payment.status !== "voided" && !payment.isSynced
|
|
675
675
|
);
|
|
676
676
|
console.log("[PaymentModule] 发现现有代金券支付项:", {
|
|
677
677
|
orderUuid,
|
|
@@ -680,7 +680,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
680
680
|
uuid: item.uuid,
|
|
681
681
|
code: item.code,
|
|
682
682
|
amount: item.amount,
|
|
683
|
-
voucher_id: item.voucher_id
|
|
683
|
+
voucher_id: item.voucher_id,
|
|
684
|
+
isSynced: item.isSynced
|
|
684
685
|
}))
|
|
685
686
|
});
|
|
686
687
|
for (const voucherItem of existingVoucherItems) {
|
|
@@ -129,6 +129,15 @@ export interface PaymentItem {
|
|
|
129
129
|
origin_amount?: string;
|
|
130
130
|
/** 订单支付类型 */
|
|
131
131
|
order_payment_type?: 'normal' | 'deposit';
|
|
132
|
+
/** 本支付项是否已成功同步到后端 */
|
|
133
|
+
isSynced?: boolean;
|
|
134
|
+
/** 最近一次同步失败信息(存在则代表同步失败过) */
|
|
135
|
+
syncError?: {
|
|
136
|
+
error: string;
|
|
137
|
+
errorCode?: string;
|
|
138
|
+
statusCode?: number;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
};
|
|
132
141
|
}
|
|
133
142
|
/**
|
|
134
143
|
* 订单信息
|
|
@@ -614,6 +623,8 @@ export interface WalletDeductionRecommendParams {
|
|
|
614
623
|
amount: number;
|
|
615
624
|
tag: string;
|
|
616
625
|
}[];
|
|
626
|
+
/** 订单ID */
|
|
627
|
+
payment_order_id?: string;
|
|
617
628
|
}
|
|
618
629
|
/**
|
|
619
630
|
* 钱包初始化业务数据接口
|
|
@@ -635,6 +646,8 @@ export interface WalletInitBusinessData {
|
|
|
635
646
|
selling_price: number;
|
|
636
647
|
}[];
|
|
637
648
|
order_wait_pay_amount?: number;
|
|
649
|
+
/** 订单ID */
|
|
650
|
+
payment_order_id?: string;
|
|
638
651
|
}
|
|
639
652
|
/**
|
|
640
653
|
* 查询用户识别码列表请求参数
|
|
@@ -652,6 +665,8 @@ export interface UserIdentificationCodeParams extends WalletDeductionRecommendPa
|
|
|
652
665
|
amount: number;
|
|
653
666
|
tag: string;
|
|
654
667
|
}[];
|
|
668
|
+
/** 订单ID */
|
|
669
|
+
payment_order_id?: string;
|
|
655
670
|
}
|
|
656
671
|
/**
|
|
657
672
|
* 钱包推荐扣款响应数据
|
|
@@ -703,6 +718,8 @@ export interface UserIdentificationCodeItem {
|
|
|
703
718
|
export interface SearchIdentificationCodeParams extends WalletDeductionRecommendParams {
|
|
704
719
|
/** 识别码 */
|
|
705
720
|
code: string;
|
|
721
|
+
/** 订单ID */
|
|
722
|
+
payment_order_id?: string;
|
|
706
723
|
}
|
|
707
724
|
/**
|
|
708
725
|
* 搜索识别码响应数据
|
|
@@ -49,7 +49,7 @@ var WalletPassPaymentImpl = class {
|
|
|
49
49
|
*/
|
|
50
50
|
generateWalletParams(businessData) {
|
|
51
51
|
var _a;
|
|
52
|
-
const { customer_id, amountInfo, products, order_wait_pay_amount } = businessData;
|
|
52
|
+
const { customer_id, amountInfo, products, order_wait_pay_amount, payment_order_id } = businessData;
|
|
53
53
|
const totalAmount = Number(amountInfo.totalAmount);
|
|
54
54
|
const subTotal = Number(amountInfo.subTotal);
|
|
55
55
|
const walletParams = {
|
|
@@ -63,7 +63,8 @@ var WalletPassPaymentImpl = class {
|
|
|
63
63
|
order_wait_pay_amount: order_wait_pay_amount || totalAmount,
|
|
64
64
|
// order_behavior_count_customer_id: 1,
|
|
65
65
|
products,
|
|
66
|
-
prepare_payments: []
|
|
66
|
+
prepare_payments: [],
|
|
67
|
+
payment_order_id
|
|
67
68
|
};
|
|
68
69
|
this.walletParams = walletParams;
|
|
69
70
|
this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
|
|
@@ -178,11 +179,13 @@ var WalletPassPaymentImpl = class {
|
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
async getWalletPassRecommendListAsync(params) {
|
|
182
|
+
var _a;
|
|
181
183
|
try {
|
|
182
184
|
this.paymentModule.logInfo("[WalletPass] 开始获取钱包推荐列表", {
|
|
183
185
|
customer_id: params.customer_id,
|
|
184
186
|
order_expect_amount: params.order_expect_amount,
|
|
185
|
-
sale_channel: params.sale_channel
|
|
187
|
+
sale_channel: params.sale_channel,
|
|
188
|
+
payment_order_id: (_a = this.walletParams) == null ? void 0 : _a.payment_order_id
|
|
186
189
|
});
|
|
187
190
|
const response = await this.paymentModule.request.post(
|
|
188
191
|
"/machinecode/prepare/deduction/recommend",
|
|
@@ -216,7 +219,7 @@ var WalletPassPaymentImpl = class {
|
|
|
216
219
|
return (0, import_utils.formatWalletPassList2PreparePayments)(list);
|
|
217
220
|
}
|
|
218
221
|
async getUserIdentificationCodeListAsync(params) {
|
|
219
|
-
var _a;
|
|
222
|
+
var _a, _b;
|
|
220
223
|
try {
|
|
221
224
|
const newParams = {
|
|
222
225
|
...this.walletParams,
|
|
@@ -226,7 +229,8 @@ var WalletPassPaymentImpl = class {
|
|
|
226
229
|
customer_id: newParams.customer_id,
|
|
227
230
|
available: newParams.available,
|
|
228
231
|
prepare_payments_count: ((_a = newParams.prepare_payments) == null ? void 0 : _a.length) || 0,
|
|
229
|
-
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass
|
|
232
|
+
filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
|
|
233
|
+
payment_order_id: (_b = this.walletParams) == null ? void 0 : _b.payment_order_id
|
|
230
234
|
});
|
|
231
235
|
const response = await this.paymentModule.request.post(
|
|
232
236
|
"/machinecode/prepare/deduction",
|
|
@@ -308,13 +312,15 @@ var WalletPassPaymentImpl = class {
|
|
|
308
312
|
prepare_payments: params.prepare_payments || (baseWalletParams == null ? void 0 : baseWalletParams.prepare_payments),
|
|
309
313
|
multiple: 1,
|
|
310
314
|
// 搜索特有参数
|
|
311
|
-
code: params.code
|
|
315
|
+
code: params.code,
|
|
316
|
+
payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
|
|
312
317
|
};
|
|
313
318
|
this.paymentModule.logInfo("[WalletPass] 搜索普通识别码", {
|
|
314
319
|
code: searchParams.code,
|
|
315
320
|
customer_id: searchParams.customer_id,
|
|
316
321
|
order_expect_amount: searchParams.order_expect_amount,
|
|
317
|
-
multiple: searchParams.multiple
|
|
322
|
+
multiple: searchParams.multiple,
|
|
323
|
+
payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
|
|
318
324
|
});
|
|
319
325
|
const response = await this.paymentModule.request.post(
|
|
320
326
|
"/machinecode/prepare/deduction/search",
|
|
@@ -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, CheckoutInitParams, CreateLocalOrderParams, CurrentOrderInfo, CartSummaryItem, SendCustomerPayLinkParams } from './types';
|
|
5
|
+
import { CheckoutModuleAPI, CheckoutInitParams, CreateLocalOrderParams, UpdateLocalOrderParams, CurrentOrderInfo, CartSummaryItem, SendCustomerPayLinkParams } from './types';
|
|
6
6
|
import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
|
|
7
7
|
export * from './types';
|
|
8
8
|
/**
|
|
@@ -64,6 +64,13 @@ 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
|
+
* 通过传入真实的 orderId,对已缓存的订单数据进行更新,
|
|
71
|
+
* 会覆盖 order_info 与金额等字段,并重新计算待付金额,最后设置为 currentOrder。
|
|
72
|
+
*/
|
|
73
|
+
updateLocalOrderAsync(params: UpdateLocalOrderParams): Promise<PaymentOrder>;
|
|
67
74
|
/**
|
|
68
75
|
* 完成结账
|
|
69
76
|
*/
|
|
@@ -221,7 +221,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
221
221
|
return [...productList, ...relationProducts];
|
|
222
222
|
}
|
|
223
223
|
async initWalletData(params) {
|
|
224
|
-
var _a, _b, _c, _d;
|
|
224
|
+
var _a, _b, _c, _d, _e;
|
|
225
225
|
this.logInfo("initWalletData called", {
|
|
226
226
|
params
|
|
227
227
|
});
|
|
@@ -241,6 +241,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
241
241
|
products: this.getProductListByOrder(),
|
|
242
242
|
...params
|
|
243
243
|
};
|
|
244
|
+
if (this.store.isOrderSynced) {
|
|
245
|
+
walletBusinessData.payment_order_id = (_d = this.store.currentOrder) == null ? void 0 : _d.order_id;
|
|
246
|
+
}
|
|
244
247
|
this.logInfo("开始拉取:initializeWalletDataFromBusinessAsync", {
|
|
245
248
|
walletBusinessData
|
|
246
249
|
});
|
|
@@ -257,7 +260,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
257
260
|
currentOrder: this.store.currentOrder
|
|
258
261
|
});
|
|
259
262
|
await this.core.effects.emit(import_types.CheckoutHooks.OnWalletDataInitialized, {
|
|
260
|
-
orderUuid: (
|
|
263
|
+
orderUuid: (_e = this.store.currentOrder) == null ? void 0 : _e.uuid,
|
|
261
264
|
customerId: walletBusinessData.customer_id,
|
|
262
265
|
walletBusinessData: {
|
|
263
266
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -363,6 +366,117 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
363
366
|
throw error;
|
|
364
367
|
}
|
|
365
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* 更新本地订单(已同步后端的订单)并设置为当前订单
|
|
371
|
+
*
|
|
372
|
+
* 通过传入真实的 orderId,对已缓存的订单数据进行更新,
|
|
373
|
+
* 会覆盖 order_info 与金额等字段,并重新计算待付金额,最后设置为 currentOrder。
|
|
374
|
+
*/
|
|
375
|
+
async updateLocalOrderAsync(params) {
|
|
376
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
377
|
+
this.logInfo("updateLocalOrderAsync called", {
|
|
378
|
+
orderId: params.orderId,
|
|
379
|
+
orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
|
|
380
|
+
bookingsCount: ((_c = (_b = params.orderData) == null ? void 0 : _b.bookings) == null ? void 0 : _c.length) || 0,
|
|
381
|
+
cartSummaryCount: ((_d = params.cartSummary) == null ? void 0 : _d.length) || 0,
|
|
382
|
+
totalInfoKeys: params.totalInfo ? Object.keys(params.totalInfo) : []
|
|
383
|
+
});
|
|
384
|
+
const validation = (0, import_utils.validateLocalOrderData)(params.orderData);
|
|
385
|
+
if (!validation.valid) {
|
|
386
|
+
throw (0, import_utils.createCheckoutError)(
|
|
387
|
+
import_types.CheckoutErrorType.ValidationFailed,
|
|
388
|
+
`订单数据验证失败: ${validation.errors.join(", ")}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
const amountInfo = (0, import_utils.extractAmountFromCartSummary)(params.cartSummary);
|
|
392
|
+
params.orderData.created_at = (0, import_utils.formatDateTime)(/* @__PURE__ */ new Date());
|
|
393
|
+
params.orderData.platform = "pos";
|
|
394
|
+
params.orderData.surcharge_fee = (_f = (_e = params.totalInfo) == null ? void 0 : _e.total) == null ? void 0 : _f.otherAmount;
|
|
395
|
+
params.orderData.surcharges = (_h = (_g = params.totalInfo) == null ? void 0 : _g.total) == null ? void 0 : _h.surcharge;
|
|
396
|
+
params.orderData.shop_discount = (_j = (_i = params.totalInfo) == null ? void 0 : _i.total) == null ? void 0 : _j.shopDiscount;
|
|
397
|
+
params.orderData.tax_fee = (_l = (_k = params.totalInfo) == null ? void 0 : _k.total) == null ? void 0 : _l.tax;
|
|
398
|
+
this.store.localOrderData = params.orderData;
|
|
399
|
+
this.store.cartSummary = params.cartSummary;
|
|
400
|
+
const customerInfo = {
|
|
401
|
+
customer_id: params.orderData.customer_id,
|
|
402
|
+
customer_name: params.orderData.customer_name
|
|
403
|
+
};
|
|
404
|
+
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
405
|
+
this.store.currentCustomer = customerInfo;
|
|
406
|
+
} else {
|
|
407
|
+
this.store.currentCustomer = void 0;
|
|
408
|
+
}
|
|
409
|
+
const allOrders = await this.payment.getOrderListAsync();
|
|
410
|
+
const existingOrder = allOrders.find(
|
|
411
|
+
(o) => String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId)
|
|
412
|
+
);
|
|
413
|
+
if (existingOrder) {
|
|
414
|
+
const totalAmount = new import_decimal.default(amountInfo.totalAmount || "0");
|
|
415
|
+
const activePayments = (existingOrder.payment || []).filter((p) => p.status !== "voided");
|
|
416
|
+
const paidAmount = activePayments.reduce((sum, p) => {
|
|
417
|
+
const amt = new import_decimal.default(p.amount || "0");
|
|
418
|
+
const rounding = new import_decimal.default(p.rounding_amount || "0").abs();
|
|
419
|
+
return sum.plus(amt).plus(rounding);
|
|
420
|
+
}, new import_decimal.default(0));
|
|
421
|
+
const remaining = import_decimal.default.max(0, totalAmount.minus(paidAmount)).toFixed(2);
|
|
422
|
+
await this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
423
|
+
total_amount: amountInfo.totalAmount,
|
|
424
|
+
is_deposit: params.orderData.is_deposit || 0,
|
|
425
|
+
deposit_amount: amountInfo.depositAmount || "0.00",
|
|
426
|
+
expect_amount: remaining,
|
|
427
|
+
order_info: {
|
|
428
|
+
original_order_data: params.orderData,
|
|
429
|
+
cart_summary: params.cartSummary,
|
|
430
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
431
|
+
platform: params.orderData.platform,
|
|
432
|
+
type: params.orderData.type,
|
|
433
|
+
schedule_date: params.orderData.schedule_date,
|
|
434
|
+
shop_note: params.orderData.shop_note,
|
|
435
|
+
amount_breakdown: amountInfo
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
const updated = await this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
439
|
+
if (!updated)
|
|
440
|
+
throw (0, import_utils.createCheckoutError)(import_types.CheckoutErrorType.UnknownError, "订单更新失败");
|
|
441
|
+
this.store.currentOrder = updated;
|
|
442
|
+
await this.updateStateAmountToRemaining();
|
|
443
|
+
this.logInfo("本地订单更新成功(保留支付项):", {
|
|
444
|
+
orderId: params.orderId,
|
|
445
|
+
uuid: updated.uuid,
|
|
446
|
+
payments: ((_m = updated.payment) == null ? void 0 : _m.length) || 0,
|
|
447
|
+
totalAmount: updated.total_amount,
|
|
448
|
+
expectAmount: updated.expect_amount
|
|
449
|
+
});
|
|
450
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreated, {
|
|
451
|
+
order: updated,
|
|
452
|
+
timestamp: Date.now()
|
|
453
|
+
});
|
|
454
|
+
this.initWalletData({
|
|
455
|
+
order_wait_pay_amount: Number(updated.expect_amount)
|
|
456
|
+
});
|
|
457
|
+
return updated;
|
|
458
|
+
}
|
|
459
|
+
const created = await this.payment.createPaymentOrderAsync({
|
|
460
|
+
order_id: String(params.orderId),
|
|
461
|
+
total_amount: amountInfo.totalAmount,
|
|
462
|
+
is_deposit: params.orderData.is_deposit || 0,
|
|
463
|
+
deposit_amount: amountInfo.depositAmount || "0.00",
|
|
464
|
+
order_info: {
|
|
465
|
+
original_order_data: params.orderData,
|
|
466
|
+
cart_summary: params.cartSummary,
|
|
467
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
468
|
+
platform: params.orderData.platform,
|
|
469
|
+
type: params.orderData.type,
|
|
470
|
+
schedule_date: params.orderData.schedule_date,
|
|
471
|
+
shop_note: params.orderData.shop_note,
|
|
472
|
+
amount_breakdown: amountInfo
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
this.store.currentOrder = created;
|
|
476
|
+
await this.updateStateAmountToRemaining();
|
|
477
|
+
this.initWalletData();
|
|
478
|
+
return created;
|
|
479
|
+
}
|
|
366
480
|
/**
|
|
367
481
|
* 完成结账
|
|
368
482
|
*/
|
|
@@ -1979,6 +2093,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1979
2093
|
this.logInfo("错误恢复:手动设置订单ID:", realOrderId);
|
|
1980
2094
|
}
|
|
1981
2095
|
}
|
|
2096
|
+
try {
|
|
2097
|
+
const syncedPaymentUuids = processedPaymentItems.filter((item) => item.status !== "voided").map((item) => item.uuid).filter(Boolean);
|
|
2098
|
+
for (const paymentUuid of syncedPaymentUuids) {
|
|
2099
|
+
await this.payment.updatePaymentAsync(
|
|
2100
|
+
this.store.currentOrder.uuid,
|
|
2101
|
+
paymentUuid,
|
|
2102
|
+
{ isSynced: true, syncError: void 0 }
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
} catch (e) {
|
|
2106
|
+
this.logWarning("标记支付项已同步失败(不阻塞主流程)", { error: e });
|
|
2107
|
+
}
|
|
1982
2108
|
this.store.isOrderSynced = true;
|
|
1983
2109
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSynced, {
|
|
1984
2110
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -91,6 +91,19 @@ export interface CreateLocalOrderParams {
|
|
|
91
91
|
autoPayment?: boolean;
|
|
92
92
|
totalInfo: any;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* 本地订单更新参数
|
|
96
|
+
*/
|
|
97
|
+
export interface UpdateLocalOrderParams {
|
|
98
|
+
/** 要更新的后端订单ID(已同步过后端的订单) */
|
|
99
|
+
orderId: string;
|
|
100
|
+
/** 更新后的订单数据(结构与创建时一致,允许部分字段变化) */
|
|
101
|
+
orderData: LocalOrderData;
|
|
102
|
+
/** 更新后的购物车小计数据 */
|
|
103
|
+
cartSummary: CartSummaryItem[];
|
|
104
|
+
/** total 信息(用于拆解金额) */
|
|
105
|
+
totalInfo: any;
|
|
106
|
+
}
|
|
94
107
|
/**
|
|
95
108
|
* 本地订单数据结构 (基于 appointmentDemo.json)
|
|
96
109
|
*/
|
|
@@ -373,6 +386,10 @@ export interface CheckoutModuleAPI extends Module {
|
|
|
373
386
|
* 创建本地订单 (前端模拟下单流程)
|
|
374
387
|
*/
|
|
375
388
|
createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
|
|
389
|
+
/**
|
|
390
|
+
* 更新本地订单(基于已同步后的真实 orderId)并设置为当前订单
|
|
391
|
+
*/
|
|
392
|
+
updateLocalOrderAsync(params: UpdateLocalOrderParams): Promise<PaymentOrder>;
|
|
376
393
|
/**
|
|
377
394
|
* 完成结账
|
|
378
395
|
*/
|