@pisell/pisellos 0.0.236 → 0.0.238

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.
@@ -30,3 +30,4 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
30
30
  clear(): Promise<void>;
31
31
  storeChange(): void;
32
32
  }
33
+ export type { Discount } from './types';
@@ -10,7 +10,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
10
10
  constructor(name?: string, version?: string);
11
11
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
12
12
  createOrder(params: CommitOrderParams['query']): {
13
- type: "appointment_booking" | "virtual";
13
+ type: "virtual" | "appointment_booking";
14
14
  platform: string;
15
15
  sales_channel: string;
16
16
  order_sales_channel: string;
@@ -26,6 +26,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
26
26
  import { BaseModule } from "../BaseModule";
27
27
  import { generateDuration, mergeRelationForms } from "./utils";
28
28
  import { isNormalProduct } from "../Product/utils";
29
+ import dayjs from 'dayjs';
29
30
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
30
31
  _inherits(OrderModule, _BaseModule);
31
32
  var _super = _createSuper(OrderModule);
@@ -205,6 +206,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
205
206
  orderData.bookings = [];
206
207
  orderData.relation_products = [];
207
208
  }
209
+
210
+ // 兜底策略,如果是第一次下单,没有 order_id,且没有 schedule_date,则设置为当前时间
211
+ if (!params.order_id && !orderData.schedule_date) {
212
+ orderData.schedule_date = dayjs().format('YYYY-MM-DD HH:mm:ss');
213
+ }
208
214
  console.log('[Order] 调用后端接口创建订单:', {
209
215
  url: '/order/checkout',
210
216
  orderType: orderData.type,
@@ -220,25 +226,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
220
226
  });
221
227
 
222
228
  // 调用后端接口
223
- _context3.next = 8;
229
+ _context3.next = 9;
224
230
  return this.request.post('/order/checkout', orderData);
225
- case 8:
231
+ case 9:
226
232
  response = _context3.sent;
227
233
  console.log('[Order] 订单创建成功,后端响应:', {
228
234
  success: !!response,
229
235
  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)
230
236
  });
231
237
  return _context3.abrupt("return", response);
232
- case 13:
233
- _context3.prev = 13;
238
+ case 14:
239
+ _context3.prev = 14;
234
240
  _context3.t0 = _context3["catch"](1);
235
241
  console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
236
242
  throw _context3.t0;
237
- case 17:
243
+ case 18:
238
244
  case "end":
239
245
  return _context3.stop();
240
246
  }
241
- }, _callee3, this, [[1, 13]]);
247
+ }, _callee3, this, [[1, 14]]);
242
248
  }));
243
249
  function createOrderByCheckout(_x4) {
244
250
  return _createOrderByCheckout.apply(this, arguments);
@@ -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
  * 支付钩子事件(统一接口)
@@ -156,6 +156,18 @@ export var RoundingInterval = /*#__PURE__*/function (RoundingInterval) {
156
156
  * 搜索识别码完成事件数据
157
157
  */
158
158
 
159
+ /**
160
+ * 钱包初始化开始事件数据
161
+ */
162
+
163
+ /**
164
+ * 钱包初始化完成事件数据
165
+ */
166
+
167
+ /**
168
+ * 钱包初始化失败事件数据
169
+ */
170
+
159
171
  /**
160
172
  * 钱包支付事件枚举
161
173
  */
@@ -166,6 +178,9 @@ export var WalletPassHooks = /*#__PURE__*/function (WalletPassHooks) {
166
178
  WalletPassHooks["OnUserIdentificationCodesCleared"] = "wallet:onUserIdentificationCodesCleared";
167
179
  WalletPassHooks["OnWalletCacheCleared"] = "wallet:onWalletCacheCleared";
168
180
  WalletPassHooks["OnSearchIdentificationCodeCompleted"] = "wallet:onSearchIdentificationCodeCompleted";
181
+ WalletPassHooks["OnWalletInitializationStarted"] = "wallet:onWalletInitializationStarted";
182
+ WalletPassHooks["OnWalletInitializationCompleted"] = "wallet:onWalletInitializationCompleted";
183
+ WalletPassHooks["OnWalletInitializationFailed"] = "wallet:onWalletInitializationFailed";
169
184
  return WalletPassHooks;
170
185
  }({});
171
186
 
@@ -110,27 +110,52 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
110
110
  key: "initializeWalletDataFromBusinessAsync",
111
111
  value: (function () {
112
112
  var _initializeWalletDataFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(businessData) {
113
- var walletParams;
113
+ var startTime, walletParams, result, endTime, duration, _endTime, _duration;
114
114
  return _regeneratorRuntime().wrap(function _callee$(_context) {
115
115
  while (1) switch (_context.prev = _context.next) {
116
116
  case 0:
117
- _context.prev = 0;
117
+ startTime = Date.now(); // 发送初始化开始事件
118
+ this.emitEvent(WalletPassHooks.OnWalletInitializationStarted, {
119
+ businessData: businessData,
120
+ startTime: startTime
121
+ });
122
+ _context.prev = 2;
118
123
  // 生成钱包API参数
119
124
  walletParams = this.generateWalletParams(businessData); // 调用标准的初始化流程
120
- _context.next = 4;
125
+ _context.next = 6;
121
126
  return this.initializeWalletDataAsync(walletParams);
122
- case 4:
123
- return _context.abrupt("return", _context.sent);
124
- case 7:
125
- _context.prev = 7;
126
- _context.t0 = _context["catch"](0);
127
- console.error('[WalletPass] 从业务数据初始化钱包数据失败:', _context.t0);
127
+ case 6:
128
+ result = _context.sent;
129
+ endTime = Date.now();
130
+ duration = endTime - startTime; // 发送初始化完成事件
131
+ this.emitEvent(WalletPassHooks.OnWalletInitializationCompleted, {
132
+ businessData: businessData,
133
+ result: result,
134
+ startTime: startTime,
135
+ endTime: endTime,
136
+ duration: duration
137
+ });
138
+ console.log("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u6210\u529F\uFF0C\u8017\u65F6: ".concat(duration, "ms"));
139
+ return _context.abrupt("return", result);
140
+ case 14:
141
+ _context.prev = 14;
142
+ _context.t0 = _context["catch"](2);
143
+ _endTime = Date.now();
144
+ _duration = _endTime - startTime; // 发送初始化失败事件
145
+ this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
146
+ businessData: businessData,
147
+ error: _context.t0,
148
+ startTime: startTime,
149
+ endTime: _endTime,
150
+ duration: _duration
151
+ });
152
+ console.error("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25\uFF0C\u8017\u65F6: ".concat(_duration, "ms"), _context.t0);
128
153
  throw _context.t0;
129
- case 11:
154
+ case 21:
130
155
  case "end":
131
156
  return _context.stop();
132
157
  }
133
- }, _callee, this, [[0, 7]]);
158
+ }, _callee, this, [[2, 14]]);
134
159
  }));
135
160
  function initializeWalletDataFromBusinessAsync(_x) {
136
161
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态