@pisell/pisellos 1.0.59 → 1.0.61

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.
@@ -17,6 +17,23 @@ export declare class DateModule extends BaseModule implements Module, DateModule
17
17
  getDateList(): ITime[];
18
18
  setDateList(dateList: ITime[]): void;
19
19
  fetchResourceDates(params: IGetAvailableTimeListParams): Promise<any>;
20
+ /**
21
+ * 将时间向上取整到下一个10分钟整数
22
+ *
23
+ * @param time dayjs 时间对象
24
+ * @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
25
+ */
26
+ private roundUpToNext10Minutes;
27
+ /**
28
+ * 校正资源时间段数据
29
+ *
30
+ * 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
31
+ * 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
32
+ *
33
+ * @param resourcesData 资源数据数组
34
+ * @returns 校正后的资源数据数组
35
+ */
36
+ private correctResourceTimeSlots;
20
37
  getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
21
38
  clearDateRange(): void;
22
39
  storeChange(): void;
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -21,6 +23,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
21
23
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
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
+ import dayjs from 'dayjs';
24
27
  import { BaseModule } from "../BaseModule";
25
28
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
26
29
  import cloneDeep from 'lodash-es/cloneDeep';
@@ -204,22 +207,107 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
204
207
  });
205
208
  case 6:
206
209
  res = _context3.sent;
210
+ // 校正资源时间段数据
211
+ if (res !== null && res !== void 0 && res.data && Array.isArray(res.data)) {
212
+ res.data = this.correctResourceTimeSlots(res.data);
213
+ }
207
214
  return _context3.abrupt("return", res);
208
- case 10:
209
- _context3.prev = 10;
215
+ case 11:
216
+ _context3.prev = 11;
210
217
  _context3.t0 = _context3["catch"](3);
211
218
  console.error(_context3.t0);
212
- case 13:
219
+ case 14:
213
220
  case "end":
214
221
  return _context3.stop();
215
222
  }
216
- }, _callee3, this, [[3, 10]]);
223
+ }, _callee3, this, [[3, 11]]);
217
224
  }));
218
225
  function fetchResourceDates(_x4) {
219
226
  return _fetchResourceDates.apply(this, arguments);
220
227
  }
221
228
  return fetchResourceDates;
222
229
  }()
230
+ /**
231
+ * 将时间向上取整到下一个10分钟整数
232
+ *
233
+ * @param time dayjs 时间对象
234
+ * @returns 向上取整后的时间字符串 (YYYY-MM-DD HH:mm 格式)
235
+ */
236
+ }, {
237
+ key: "roundUpToNext10Minutes",
238
+ value: function roundUpToNext10Minutes(time) {
239
+ var minutes = time.minute();
240
+ var remainder = minutes % 10;
241
+ if (remainder === 0) {
242
+ // 如果已经是10分钟的整数,保持不变
243
+ return time.format('YYYY-MM-DD HH:mm');
244
+ } else {
245
+ // 向上取整到下一个10分钟
246
+ var minutesToAdd = 10 - remainder;
247
+ var roundedTime = time.add(minutesToAdd, 'minute');
248
+ return roundedTime.format('YYYY-MM-DD HH:mm');
249
+ }
250
+ }
251
+
252
+ /**
253
+ * 校正资源时间段数据
254
+ *
255
+ * 如果时间段的 start_at 早于资源的 start_time,将其同步为 start_time 的下一个10分钟整数
256
+ * 如果修正后 end_at 也早于修正后的 start_time,则删除该时间段
257
+ *
258
+ * @param resourcesData 资源数据数组
259
+ * @returns 校正后的资源数据数组
260
+ */
261
+ }, {
262
+ key: "correctResourceTimeSlots",
263
+ value: function correctResourceTimeSlots(resourcesData) {
264
+ var _this2 = this;
265
+ return resourcesData.map(function (resource) {
266
+ // 检查资源是否有 times 数组和 start_time
267
+ if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
268
+ return resource;
269
+ }
270
+ var resourceStartTime = dayjs(resource.start_time);
271
+
272
+ // 过滤和修正时间段
273
+ var correctedTimes = resource.times.map(function (timeSlot) {
274
+ if (!timeSlot.start_at || !timeSlot.end_at) {
275
+ return timeSlot;
276
+ }
277
+ var startAt = dayjs(timeSlot.start_at);
278
+ var endAt = dayjs(timeSlot.end_at);
279
+
280
+ // 如果 start_at 早于资源的 start_time,需要修正
281
+ if (startAt.isBefore(resourceStartTime)) {
282
+ // 将 start_time 向上取整到下一个10分钟整数
283
+ var roundedStartTime = _this2.roundUpToNext10Minutes(resourceStartTime);
284
+ var roundedStartTimeDayjs = dayjs(roundedStartTime);
285
+ console.log("[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ".concat(timeSlot.start_at, " -> ").concat(roundedStartTime, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u539F\u59CBstart_time: ").concat(resource.start_time, ")"));
286
+
287
+ // 将 start_at 修正为向上取整后的时间
288
+ var correctedTimeSlot = _objectSpread(_objectSpread({}, timeSlot), {}, {
289
+ start_at: roundedStartTime
290
+ });
291
+
292
+ // 检查修正后的 end_at 是否也早于修正后的 start_time
293
+ if (endAt.isBefore(roundedStartTimeDayjs)) {
294
+ console.log("[DateModule] \u65F6\u95F4\u6BB5\u65E0\u6548\uFF0C\u5C06\u88AB\u5220\u9664: ".concat(timeSlot.start_at, " - ").concat(timeSlot.end_at, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u4FEE\u6B63\u540Estart_time: ").concat(roundedStartTime, ")"));
295
+ return null; // 标记为删除
296
+ }
297
+ return correctedTimeSlot;
298
+ }
299
+
300
+ // 不需要修正的时间段直接返回
301
+ return timeSlot;
302
+ }).filter(function (timeSlot) {
303
+ return timeSlot !== null;
304
+ }); // 过滤掉被删除的时间段
305
+
306
+ return _objectSpread(_objectSpread({}, resource), {}, {
307
+ times: correctedTimes
308
+ });
309
+ });
310
+ }
223
311
  }, {
224
312
  key: "getResourceAvailableTimeList",
225
313
  value: function () {
@@ -7,8 +7,21 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
7
7
  protected defaultVersion: string;
8
8
  private store;
9
9
  private request;
10
+ private logger;
10
11
  constructor(name?: string, version?: string);
11
12
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
13
+ /**
14
+ * 记录信息日志
15
+ */
16
+ private logInfo;
17
+ /**
18
+ * 记录警告日志
19
+ */
20
+ private logWarning;
21
+ /**
22
+ * 记录错误日志
23
+ */
24
+ private logError;
12
25
  createOrder(params: CommitOrderParams['query']): {
13
26
  type: "virtual" | "appointment_booking";
14
27
  platform: string;
@@ -30,6 +30,8 @@ import dayjs from 'dayjs';
30
30
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
31
31
  _inherits(OrderModule, _BaseModule);
32
32
  var _super = _createSuper(OrderModule);
33
+ // LoggerManager 实例
34
+
33
35
  function OrderModule(name, version) {
34
36
  var _this;
35
37
  _classCallCheck(this, OrderModule);
@@ -38,19 +40,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
38
40
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
39
41
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
40
42
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
43
+ _defineProperty(_assertThisInitialized(_this), "logger", void 0);
41
44
  return _this;
42
45
  }
43
46
  _createClass(OrderModule, [{
44
47
  key: "initialize",
45
48
  value: function () {
46
49
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
50
+ var appPlugin, app;
47
51
  return _regeneratorRuntime().wrap(function _callee$(_context) {
48
52
  while (1) switch (_context.prev = _context.next) {
49
53
  case 0:
50
54
  this.core = core;
51
55
  this.store = options.store;
52
56
  this.request = this.core.getPlugin('request');
53
- case 3:
57
+ appPlugin = this.core.getPlugin('app');
58
+ if (appPlugin) {
59
+ _context.next = 6;
60
+ break;
61
+ }
62
+ throw new Error('Order 模块需要 app 插件支持');
63
+ case 6:
64
+ app = appPlugin.getApp();
65
+ this.logger = app.logger;
66
+ this.logInfo('OrderModule initialized successfully');
67
+ case 9:
54
68
  case "end":
55
69
  return _context.stop();
56
70
  }
@@ -61,6 +75,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
61
75
  }
62
76
  return initialize;
63
77
  }()
78
+ /**
79
+ * 记录信息日志
80
+ */
81
+ }, {
82
+ key: "logInfo",
83
+ value: function logInfo(title, metadata) {
84
+ if (this.logger) {
85
+ this.logger.addLog({
86
+ type: 'info',
87
+ title: "[OrderModule] ".concat(title),
88
+ metadata: metadata || {}
89
+ });
90
+ }
91
+ }
92
+
93
+ /**
94
+ * 记录警告日志
95
+ */
96
+ }, {
97
+ key: "logWarning",
98
+ value: function logWarning(title, metadata) {
99
+ if (this.logger) {
100
+ this.logger.addLog({
101
+ type: 'warning',
102
+ title: "[OrderModule] ".concat(title),
103
+ metadata: metadata || {}
104
+ });
105
+ }
106
+ }
107
+
108
+ /**
109
+ * 记录错误日志
110
+ */
111
+ }, {
112
+ key: "logError",
113
+ value: function logError(title, metadata) {
114
+ if (this.logger) {
115
+ this.logger.addLog({
116
+ type: 'error',
117
+ title: "[OrderModule] ".concat(title),
118
+ metadata: metadata || {}
119
+ });
120
+ }
121
+ }
64
122
  }, {
65
123
  key: "createOrder",
66
124
  value: function createOrder(params) {
@@ -120,6 +178,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
120
178
  }, {
121
179
  key: "checkBeforeSubmitOrder",
122
180
  value: function checkBeforeSubmitOrder(params) {
181
+ var _params$cartItems;
182
+ this.logInfo('checkBeforeSubmitOrder called', {
183
+ cartItemsCount: ((_params$cartItems = params.cartItems) === null || _params$cartItems === void 0 ? void 0 : _params$cartItems.length) || 0,
184
+ type: params.type
185
+ });
123
186
  var cartItems = params.cartItems,
124
187
  type = params.type;
125
188
  if (type === 'holder') {
@@ -137,15 +200,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
137
200
  key: "submitOrder",
138
201
  value: function () {
139
202
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
203
+ var _order$query$cartItem, _params$bookings, _params$relation_prod;
140
204
  var url, query, fetchUrl, params;
141
205
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
142
206
  while (1) switch (_context2.prev = _context2.next) {
143
207
  case 0:
208
+ this.logInfo('submitOrder called', {
209
+ url: order.url,
210
+ orderType: order.query.type,
211
+ platform: order.query.platform,
212
+ cartItemsCount: ((_order$query$cartItem = order.query.cartItems) === null || _order$query$cartItem === void 0 ? void 0 : _order$query$cartItem.length) || 0
213
+ });
144
214
  url = order.url, query = order.query;
145
215
  fetchUrl = url || '/order/appointment';
146
216
  params = this.createOrder(query);
217
+ this.logInfo('Calling backend order API', {
218
+ url: fetchUrl,
219
+ orderType: params.type,
220
+ platform: params.platform,
221
+ isDeposit: params.is_deposit,
222
+ bookingsCount: ((_params$bookings = params.bookings) === null || _params$bookings === void 0 ? void 0 : _params$bookings.length) || 0,
223
+ relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
224
+ scheduleDate: params.schedule_date
225
+ });
147
226
  return _context2.abrupt("return", this.request.post(fetchUrl, params));
148
- case 4:
227
+ case 6:
149
228
  case "end":
150
229
  return _context2.stop();
151
230
  }
@@ -170,21 +249,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
170
249
  key: "createOrderByCheckout",
171
250
  value: (function () {
172
251
  var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
173
- var _params$bookings, _params$relation_prod, _params$payments;
174
- var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _response$data, orderData, response;
252
+ var _params$bookings2, _params$relation_prod2, _params$payments, _params$payments2, _params$bookings3, _params$relation_prod3, _params$payments3;
253
+ var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
175
254
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
176
255
  while (1) switch (_context3.prev = _context3.next) {
177
256
  case 0:
257
+ this.logInfo('createOrderByCheckout called', {
258
+ type: params.type,
259
+ platform: params.platform,
260
+ is_deposit: params.is_deposit,
261
+ customer_id: params.customer_id,
262
+ bookingsCount: ((_params$bookings2 = params.bookings) === null || _params$bookings2 === void 0 ? void 0 : _params$bookings2.length) || 0,
263
+ relationProductsCount: ((_params$relation_prod2 = params.relation_products) === null || _params$relation_prod2 === void 0 ? void 0 : _params$relation_prod2.length) || 0,
264
+ paymentsCount: ((_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.length) || 0,
265
+ depositAmount: params.deposit_amount,
266
+ productTaxFee: params.product_tax_fee,
267
+ note: params.note,
268
+ scheduleDate: params.schedule_date,
269
+ hasOrderId: !!params.order_id,
270
+ orderIdIncluded: params.order_id,
271
+ paymentMethods: ((_params$payments2 = params.payments) === null || _params$payments2 === void 0 ? void 0 : _params$payments2.map(function (p) {
272
+ return p.code;
273
+ })) || []
274
+ });
178
275
  console.log('[Order] createOrderByCheckout 开始创建订单:', {
179
276
  type: params.type,
180
277
  platform: params.platform,
181
278
  is_deposit: params.is_deposit,
182
279
  customer_id: params.customer_id,
183
- bookingsCount: ((_params$bookings = params.bookings) === null || _params$bookings === void 0 ? void 0 : _params$bookings.length) || 0,
184
- relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
185
- paymentsCount: ((_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.length) || 0
280
+ bookingsCount: ((_params$bookings3 = params.bookings) === null || _params$bookings3 === void 0 ? void 0 : _params$bookings3.length) || 0,
281
+ relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
282
+ paymentsCount: ((_params$payments3 = params.payments) === null || _params$payments3 === void 0 ? void 0 : _params$payments3.length) || 0
186
283
  });
187
- _context3.prev = 1;
284
+ _context3.prev = 2;
188
285
  // 构建订单数据,设置默认值并允许 params 覆盖
189
286
  orderData = _objectSpread({
190
287
  sales_channel: 'my_pisel',
@@ -225,26 +322,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
225
322
  })) || []
226
323
  });
227
324
 
325
+ // 记录接口调用详情
326
+ this.logInfo('Calling backend checkout API', {
327
+ url: '/order/checkout',
328
+ orderType: orderData.type,
329
+ platform: orderData.platform,
330
+ isDeposit: orderData.is_deposit,
331
+ customerId: orderData.customer_id,
332
+ depositAmount: orderData.deposit_amount,
333
+ bookingsCount: ((_orderData$bookings2 = orderData.bookings) === null || _orderData$bookings2 === void 0 ? void 0 : _orderData$bookings2.length) || 0,
334
+ relationProductsCount: ((_orderData$relation_p2 = orderData.relation_products) === null || _orderData$relation_p2 === void 0 ? void 0 : _orderData$relation_p2.length) || 0,
335
+ paymentsCount: ((_orderData$payments4 = orderData.payments) === null || _orderData$payments4 === void 0 ? void 0 : _orderData$payments4.length) || 0,
336
+ paymentMethods: ((_orderData$payments5 = orderData.payments) === null || _orderData$payments5 === void 0 ? void 0 : _orderData$payments5.map(function (p) {
337
+ return {
338
+ code: p.code,
339
+ amount: p.amount,
340
+ type: p.type,
341
+ hasVoucherId: !!p.voucher_id,
342
+ orderPaymentType: p.order_payment_type
343
+ };
344
+ })) || [],
345
+ productTaxFee: orderData.product_tax_fee,
346
+ note: orderData.note,
347
+ scheduleDate: orderData.schedule_date,
348
+ hasOrderId: !!orderData.order_id,
349
+ smallTicketDataFlag: orderData.small_ticket_data_flag
350
+ });
351
+
228
352
  // 调用后端接口
229
- _context3.next = 9;
353
+ _context3.next = 11;
230
354
  return this.request.post('/order/checkout', orderData);
231
- case 9:
355
+ case 11:
232
356
  response = _context3.sent;
233
357
  console.log('[Order] 订单创建成功,后端响应:', {
234
358
  success: !!response,
235
359
  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)
236
360
  });
237
361
  return _context3.abrupt("return", response);
238
- case 14:
239
- _context3.prev = 14;
240
- _context3.t0 = _context3["catch"](1);
362
+ case 16:
363
+ _context3.prev = 16;
364
+ _context3.t0 = _context3["catch"](2);
241
365
  console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
242
366
  throw _context3.t0;
243
- case 18:
367
+ case 20:
244
368
  case "end":
245
369
  return _context3.stop();
246
370
  }
247
- }, _callee3, this, [[1, 14]]);
371
+ }, _callee3, this, [[2, 16]]);
248
372
  }));
249
373
  function createOrderByCheckout(_x4) {
250
374
  return _createOrderByCheckout.apply(this, arguments);
@@ -1030,7 +1030,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1030
1030
  key: "addPaymentItemAsync",
1031
1031
  value: (function () {
1032
1032
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
1033
- var _newPaymentItem$metad, order, paymentUuid, newPaymentItem;
1033
+ var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, paymentUuid, newPaymentItem;
1034
1034
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1035
1035
  while (1) switch (_context13.prev = _context13.next) {
1036
1036
  case 0:
@@ -1066,9 +1066,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1066
1066
  // 新支付项默认为活跃状态
1067
1067
  order_payment_type: paymentItem.order_payment_type || 'normal',
1068
1068
  // 默认为正常支付
1069
- metadata: {
1069
+ metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
1070
+ // 保留传入的所有 metadata 字段
1070
1071
  unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
1071
- }
1072
+ })
1072
1073
  };
1073
1074
  order.payment.push(newPaymentItem);
1074
1075
  this.recalculateOrderAmount(order);
@@ -1085,7 +1086,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1085
1086
  orderUuid: orderUuid,
1086
1087
  paymentUuid: newPaymentItem.uuid,
1087
1088
  uniquePaymentNumber: (_newPaymentItem$metad = newPaymentItem.metadata) === null || _newPaymentItem$metad === void 0 ? void 0 : _newPaymentItem$metad.unique_payment_number,
1088
- newExpectAmount: order.expect_amount
1089
+ newExpectAmount: order.expect_amount,
1090
+ paymentAmount: newPaymentItem.amount,
1091
+ paymentCode: newPaymentItem.code,
1092
+ orderPaymentType: newPaymentItem.order_payment_type,
1093
+ metadataFields: Object.keys(newPaymentItem.metadata || {}),
1094
+ // 现金支付找零信息
1095
+ actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1096
+ changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1089
1097
  });
1090
1098
  _context13.next = 23;
1091
1099
  break;
@@ -111,6 +111,10 @@ export interface PaymentItem {
111
111
  unique_payment_number?: string;
112
112
  /** rouding规则 */
113
113
  rounding_rule?: any;
114
+ /** 实付金额(现金支付时的实际给出金额) */
115
+ actual_paid_amount?: number;
116
+ /** 找零金额(现金支付时的找零金额) */
117
+ change_given_amount?: number;
114
118
  };
115
119
  /** rouding金额 */
116
120
  rounding_amount?: string;
@@ -230,6 +234,10 @@ export interface PaymentItemInput {
230
234
  unique_payment_number?: string;
231
235
  /** rounding规则 */
232
236
  rounding_rule?: any;
237
+ /** 实付金额(现金支付时的实际给出金额) */
238
+ actual_paid_amount?: number;
239
+ /** 找零金额(现金支付时的找零金额) */
240
+ change_given_amount?: number;
233
241
  };
234
242
  }
235
243
  /**
@@ -116,23 +116,22 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
116
116
  while (1) switch (_context.prev = _context.next) {
117
117
  case 0:
118
118
  startTime = Date.now();
119
- if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) <= 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) <= 0)) {
120
- _context.next = 3;
119
+ walletParams = this.generateWalletParams(businessData);
120
+ if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0)) {
121
+ _context.next = 4;
121
122
  break;
122
123
  }
123
124
  return _context.abrupt("return", {
124
125
  walletRecommendList: [],
125
126
  userIdentificationCodes: []
126
127
  });
127
- case 3:
128
+ case 4:
128
129
  // 发送初始化开始事件
129
130
  this.emitEvent(WalletPassHooks.OnWalletInitializationStarted, {
130
131
  businessData: businessData,
131
132
  startTime: startTime
132
133
  });
133
- _context.prev = 4;
134
- // 生成钱包API参数
135
- walletParams = this.generateWalletParams(businessData); // 调用标准的初始化流程
134
+ _context.prev = 5;
136
135
  _context.next = 8;
137
136
  return this.initializeWalletDataAsync(walletParams);
138
137
  case 8:
@@ -150,7 +149,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
150
149
  return _context.abrupt("return", result);
151
150
  case 16:
152
151
  _context.prev = 16;
153
- _context.t0 = _context["catch"](4);
152
+ _context.t0 = _context["catch"](5);
154
153
  _endTime = Date.now();
155
154
  _duration = _endTime - startTime; // 发送初始化失败事件
156
155
  this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
@@ -166,7 +165,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
166
165
  case "end":
167
166
  return _context.stop();
168
167
  }
169
- }, _callee, this, [[4, 16]]);
168
+ }, _callee, this, [[5, 16]]);
170
169
  }));
171
170
  function initializeWalletDataFromBusinessAsync(_x) {
172
171
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -18,10 +18,23 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
18
18
  private request;
19
19
  private store;
20
20
  private otherParams;
21
+ private logger;
21
22
  order: OrderModule;
22
23
  payment: PaymentModule;
23
24
  constructor(name?: string, version?: string);
24
25
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
26
+ /**
27
+ * 记录信息日志
28
+ */
29
+ private logInfo;
30
+ /**
31
+ * 记录警告日志
32
+ */
33
+ private logWarning;
34
+ /**
35
+ * 记录错误日志
36
+ */
37
+ private logError;
25
38
  /**
26
39
  * 初始化子模块
27
40
  */
@@ -366,10 +379,31 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
366
379
  * 验证结账参数
367
380
  */
368
381
  private validateCheckoutParams;
382
+ /**
383
+ * 处理现金支付项的找零逻辑
384
+ *
385
+ * @param paymentItem 原始支付项
386
+ * @returns 处理后的支付项(包含找零信息)
387
+ */
388
+ private processCashPaymentItem;
389
+ /**
390
+ * 判断是否为现金支付
391
+ *
392
+ * @param paymentCode 支付代码
393
+ * @param paymentType 支付类型
394
+ * @returns 是否为现金支付
395
+ */
396
+ private isCashPayment;
369
397
  /**
370
398
  * 预加载支付方式(在初始化时调用)
371
399
  */
372
400
  private preloadPaymentMethods;
401
+ /**
402
+ * 清理过期的已同步订单数据
403
+ *
404
+ * 删除本地 IndexDB 中超过指定天数且已同步到后端的订单数据
405
+ */
406
+ private cleanupExpiredOrdersAsync;
373
407
  /**
374
408
  * 计算已支付金额(从 Payment 模块获取最新数据)
375
409
  */