@pisell/pisellos 0.0.235 → 0.0.237
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/Payment/types.d.ts +46 -1
- package/dist/modules/Payment/types.js +15 -0
- package/dist/modules/Payment/walletpass.js +37 -12
- package/dist/solution/Checkout/index.d.ts +23 -1
- package/dist/solution/Checkout/index.js +1092 -885
- package/dist/solution/Checkout/types.d.ts +11 -1
- package/dist/solution/Checkout/types.js +1 -0
- package/lib/modules/Payment/types.d.ts +46 -1
- package/lib/modules/Payment/types.js +3 -0
- package/lib/modules/Payment/walletpass.js +28 -3
- package/lib/solution/Checkout/index.d.ts +23 -1
- package/lib/solution/Checkout/index.js +334 -121
- package/lib/solution/Checkout/types.d.ts +11 -1
- package/lib/solution/Checkout/types.js +1 -0
- package/package.json +1 -1
|
@@ -391,7 +391,9 @@ export declare enum CheckoutHooks {
|
|
|
391
391
|
/** 商店折扣变更 */
|
|
392
392
|
OnShopDiscountChanged = "checkout:onShopDiscountChanged",
|
|
393
393
|
/** 订单取消 */
|
|
394
|
-
OnOrderCancelled = "checkout:onOrderCancelled"
|
|
394
|
+
OnOrderCancelled = "checkout:onOrderCancelled",
|
|
395
|
+
/** 订单状态已清理 */
|
|
396
|
+
OnOrderCleared = "checkout:onOrderCleared"
|
|
395
397
|
}
|
|
396
398
|
/**
|
|
397
399
|
* 结账状态数据
|
|
@@ -814,4 +816,12 @@ export interface CheckoutEventData {
|
|
|
814
816
|
wasSynced: boolean;
|
|
815
817
|
timestamp: number;
|
|
816
818
|
};
|
|
819
|
+
/** 订单状态清理事件 */
|
|
820
|
+
orderCleared: {
|
|
821
|
+
previousOrder?: {
|
|
822
|
+
uuid: string;
|
|
823
|
+
orderId: string;
|
|
824
|
+
} | null;
|
|
825
|
+
timestamp: number;
|
|
826
|
+
};
|
|
817
827
|
}
|
|
@@ -118,6 +118,7 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
|
|
|
118
118
|
CheckoutHooks["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
|
|
119
119
|
CheckoutHooks["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
|
|
120
120
|
CheckoutHooks["OnOrderCancelled"] = "checkout:onOrderCancelled";
|
|
121
|
+
CheckoutHooks["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
121
122
|
return CheckoutHooks;
|
|
122
123
|
}({});
|
|
123
124
|
|
|
@@ -476,6 +476,48 @@ export interface OnSearchIdentificationCodeCompletedEventData {
|
|
|
476
476
|
/** 搜索参数 */
|
|
477
477
|
searchParams: SearchIdentificationCodeParams;
|
|
478
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* 钱包初始化开始事件数据
|
|
481
|
+
*/
|
|
482
|
+
export interface OnWalletInitializationStartedEventData {
|
|
483
|
+
/** 业务数据 */
|
|
484
|
+
businessData: WalletInitBusinessData;
|
|
485
|
+
/** 开始时间 */
|
|
486
|
+
startTime: number;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* 钱包初始化完成事件数据
|
|
490
|
+
*/
|
|
491
|
+
export interface OnWalletInitializationCompletedEventData {
|
|
492
|
+
/** 业务数据 */
|
|
493
|
+
businessData: WalletInitBusinessData;
|
|
494
|
+
/** 初始化结果 */
|
|
495
|
+
result: {
|
|
496
|
+
walletRecommendList: WalletRecommendItem[];
|
|
497
|
+
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
498
|
+
};
|
|
499
|
+
/** 开始时间 */
|
|
500
|
+
startTime: number;
|
|
501
|
+
/** 结束时间 */
|
|
502
|
+
endTime: number;
|
|
503
|
+
/** 执行时长(毫秒) */
|
|
504
|
+
duration: number;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* 钱包初始化失败事件数据
|
|
508
|
+
*/
|
|
509
|
+
export interface OnWalletInitializationFailedEventData {
|
|
510
|
+
/** 业务数据 */
|
|
511
|
+
businessData: WalletInitBusinessData;
|
|
512
|
+
/** 错误信息 */
|
|
513
|
+
error: Error;
|
|
514
|
+
/** 开始时间 */
|
|
515
|
+
startTime: number;
|
|
516
|
+
/** 结束时间 */
|
|
517
|
+
endTime: number;
|
|
518
|
+
/** 执行时长(毫秒) */
|
|
519
|
+
duration: number;
|
|
520
|
+
}
|
|
479
521
|
/**
|
|
480
522
|
* 钱包支付事件枚举
|
|
481
523
|
*/
|
|
@@ -485,7 +527,10 @@ export declare enum WalletPassHooks {
|
|
|
485
527
|
OnUserIdentificationCodesUpdated = "wallet:onUserIdentificationCodesUpdated",
|
|
486
528
|
OnUserIdentificationCodesCleared = "wallet:onUserIdentificationCodesCleared",
|
|
487
529
|
OnWalletCacheCleared = "wallet:onWalletCacheCleared",
|
|
488
|
-
OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted"
|
|
530
|
+
OnSearchIdentificationCodeCompleted = "wallet:onSearchIdentificationCodeCompleted",
|
|
531
|
+
OnWalletInitializationStarted = "wallet:onWalletInitializationStarted",
|
|
532
|
+
OnWalletInitializationCompleted = "wallet:onWalletInitializationCompleted",
|
|
533
|
+
OnWalletInitializationFailed = "wallet:onWalletInitializationFailed"
|
|
489
534
|
}
|
|
490
535
|
/**
|
|
491
536
|
* 支付钩子事件(统一接口)
|
|
@@ -69,6 +69,9 @@ var WalletPassHooks = /* @__PURE__ */ ((WalletPassHooks2) => {
|
|
|
69
69
|
WalletPassHooks2["OnUserIdentificationCodesCleared"] = "wallet:onUserIdentificationCodesCleared";
|
|
70
70
|
WalletPassHooks2["OnWalletCacheCleared"] = "wallet:onWalletCacheCleared";
|
|
71
71
|
WalletPassHooks2["OnSearchIdentificationCodeCompleted"] = "wallet:onSearchIdentificationCodeCompleted";
|
|
72
|
+
WalletPassHooks2["OnWalletInitializationStarted"] = "wallet:onWalletInitializationStarted";
|
|
73
|
+
WalletPassHooks2["OnWalletInitializationCompleted"] = "wallet:onWalletInitializationCompleted";
|
|
74
|
+
WalletPassHooks2["OnWalletInitializationFailed"] = "wallet:onWalletInitializationFailed";
|
|
72
75
|
return WalletPassHooks2;
|
|
73
76
|
})(WalletPassHooks || {});
|
|
74
77
|
var PaymentHooks = /* @__PURE__ */ ((PaymentHooks2) => {
|
|
@@ -88,11 +88,36 @@ var WalletPassPaymentImpl = class {
|
|
|
88
88
|
* 内部生成参数,然后调用标准的初始化流程
|
|
89
89
|
*/
|
|
90
90
|
async initializeWalletDataFromBusinessAsync(businessData) {
|
|
91
|
+
const startTime = Date.now();
|
|
92
|
+
this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationStarted, {
|
|
93
|
+
businessData,
|
|
94
|
+
startTime
|
|
95
|
+
});
|
|
91
96
|
try {
|
|
92
97
|
const walletParams = this.generateWalletParams(businessData);
|
|
93
|
-
|
|
98
|
+
const result = await this.initializeWalletDataAsync(walletParams);
|
|
99
|
+
const endTime = Date.now();
|
|
100
|
+
const duration = endTime - startTime;
|
|
101
|
+
this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationCompleted, {
|
|
102
|
+
businessData,
|
|
103
|
+
result,
|
|
104
|
+
startTime,
|
|
105
|
+
endTime,
|
|
106
|
+
duration
|
|
107
|
+
});
|
|
108
|
+
console.log(`[WalletPass] 从业务数据初始化钱包数据成功,耗时: ${duration}ms`);
|
|
109
|
+
return result;
|
|
94
110
|
} catch (error) {
|
|
95
|
-
|
|
111
|
+
const endTime = Date.now();
|
|
112
|
+
const duration = endTime - startTime;
|
|
113
|
+
this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationFailed, {
|
|
114
|
+
businessData,
|
|
115
|
+
error,
|
|
116
|
+
startTime,
|
|
117
|
+
endTime,
|
|
118
|
+
duration
|
|
119
|
+
});
|
|
120
|
+
console.error(`[WalletPass] 从业务数据初始化钱包数据失败,耗时: ${duration}ms`, error);
|
|
96
121
|
throw error;
|
|
97
122
|
}
|
|
98
123
|
}
|
|
@@ -185,7 +210,7 @@ var WalletPassPaymentImpl = class {
|
|
|
185
210
|
const walletDetailParams = {
|
|
186
211
|
code,
|
|
187
212
|
with_customer: 1,
|
|
188
|
-
with: ["
|
|
213
|
+
with: ["wallet"]
|
|
189
214
|
};
|
|
190
215
|
const response2 = await this.paymentModule.request.post(
|
|
191
216
|
"/wallet/detail/search",
|
|
@@ -185,7 +185,8 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
185
185
|
/**
|
|
186
186
|
* 获取支付方式列表
|
|
187
187
|
*
|
|
188
|
-
*
|
|
188
|
+
* 优先使用 store 中的缓存数据,避免重复接口调用。
|
|
189
|
+
* 如果 store 中没有数据,则调用 Payment 模块的方法获取。
|
|
189
190
|
*
|
|
190
191
|
* @returns 支付方式列表
|
|
191
192
|
*/
|
|
@@ -476,4 +477,25 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
|
|
|
476
477
|
roundingDifference: string;
|
|
477
478
|
}>;
|
|
478
479
|
destroy(): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* 重置 store 状态
|
|
482
|
+
*
|
|
483
|
+
* 在创建新订单前调用,确保状态完全干净
|
|
484
|
+
*/
|
|
485
|
+
private resetStoreStateAsync;
|
|
486
|
+
/**
|
|
487
|
+
* 手动清理已完成的订单状态(公开方法)
|
|
488
|
+
*
|
|
489
|
+
* 供UI层调用的公开方法,用于手动清理订单状态
|
|
490
|
+
*
|
|
491
|
+
* @returns 清理结果
|
|
492
|
+
*/
|
|
493
|
+
clearCompletedOrderAsync(): Promise<{
|
|
494
|
+
success: boolean;
|
|
495
|
+
message?: string;
|
|
496
|
+
clearedOrder?: {
|
|
497
|
+
uuid: string;
|
|
498
|
+
orderId: string;
|
|
499
|
+
} | null;
|
|
500
|
+
}>;
|
|
479
501
|
}
|