@pisell/pisellos 2.2.243 → 2.2.245

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.
Files changed (37) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -1
  2. package/dist/modules/Discount/index.js +10 -4
  3. package/dist/modules/Order/index.d.ts +7 -1
  4. package/dist/modules/Order/index.js +649 -514
  5. package/dist/modules/Order/types.d.ts +7 -0
  6. package/dist/modules/Order/utils.js +5 -2
  7. package/dist/modules/Payment/walletpass.js +33 -24
  8. package/dist/modules/Rules/index.js +4 -1
  9. package/dist/server/index.js +6 -4
  10. package/dist/server/modules/order/index.d.ts +1 -0
  11. package/dist/server/modules/order/index.js +60 -46
  12. package/dist/server/utils/small-ticket.js +39 -29
  13. package/dist/solution/BaseSales/index.d.ts +3 -2
  14. package/dist/solution/BaseSales/index.js +6 -0
  15. package/dist/solution/BaseSales/types.d.ts +6 -0
  16. package/dist/solution/BookingByStep/index.d.ts +1 -1
  17. package/dist/solution/BookingTicket/index.d.ts +1 -1
  18. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +46 -45
  19. package/lib/modules/Discount/index.d.ts +1 -1
  20. package/lib/modules/Discount/index.js +4 -0
  21. package/lib/modules/Order/index.d.ts +7 -1
  22. package/lib/modules/Order/index.js +105 -1
  23. package/lib/modules/Order/types.d.ts +7 -0
  24. package/lib/modules/Order/utils.js +1 -0
  25. package/lib/modules/Payment/walletpass.js +9 -0
  26. package/lib/modules/Rules/index.js +1 -0
  27. package/lib/server/index.js +1 -0
  28. package/lib/server/modules/order/index.d.ts +1 -0
  29. package/lib/server/modules/order/index.js +54 -42
  30. package/lib/server/utils/small-ticket.js +21 -2
  31. package/lib/solution/BaseSales/index.d.ts +3 -2
  32. package/lib/solution/BaseSales/index.js +5 -0
  33. package/lib/solution/BaseSales/types.d.ts +6 -0
  34. package/lib/solution/BookingByStep/index.d.ts +1 -1
  35. package/lib/solution/BookingTicket/index.d.ts +1 -1
  36. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -1
  37. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
- import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
5
+ import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
6
6
  import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
7
7
  import type { Discount } from '../../modules/Discount/types';
8
8
  import { RequestPlugin, WindowPlugin } from '../../plugins';
@@ -143,6 +143,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
143
143
  updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
144
144
  updateRemoteOrderNote(orderId: number | string, note: string): void;
145
145
  updateTempOrderShopDiscount(amount: string | number): string;
146
+ updateTempOrderDepositAmount(amount: string | number): OrderSummary;
146
147
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
147
148
  /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
148
149
  setEnableTempOrderPersist(enabled: boolean): void;
@@ -158,7 +159,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
158
159
  */
159
160
  clearOrderCartLines(): Promise<OrderTempOrder>;
160
161
  getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
161
- getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
162
+ getSummary(): Promise<OrderSummary>;
162
163
  private getHistoricalProductDiscountList;
163
164
  private isPersistedOrderProduct;
164
165
  private mergeHistoricalDiscountList;
@@ -1006,6 +1006,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1006
1006
  if (!this.store.order) throw new Error('order 模块未初始化');
1007
1007
  return this.store.order.updateTempOrderShopDiscount(amount);
1008
1008
  }
1009
+ }, {
1010
+ key: "updateTempOrderDepositAmount",
1011
+ value: function updateTempOrderDepositAmount(amount) {
1012
+ if (!this.store.order) throw new Error('order 模块未初始化');
1013
+ return this.store.order.updateTempOrderDepositAmount(amount);
1014
+ }
1009
1015
  }, {
1010
1016
  key: "updateTempOrderContactsInfo",
1011
1017
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -48,6 +48,9 @@ export interface BaseSalesProductSku {
48
48
  option: any[];
49
49
  [key: string]: any;
50
50
  }
51
+ export interface BaseSalesLocalizedText {
52
+ [locale: string]: string | null;
53
+ }
51
54
  export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrderProductIdentity {
52
55
  num: number;
53
56
  }
@@ -78,6 +81,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
78
81
  product_bundle: any[];
79
82
  /** 关联 booking.metadata.unique_identification_number */
80
83
  booking_uid?: string;
84
+ /** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
85
+ product_title?: BaseSalesLocalizedText;
81
86
  /**
82
87
  * 行级扩展 metadata。价格相关的权威字段:
83
88
  *
@@ -132,6 +137,7 @@ export interface BaseSalesSummary {
132
137
  deposit?: {
133
138
  total: string;
134
139
  deposit_policy_ids: number[];
140
+ deposit_policy_data?: any[];
135
141
  hasDeposit: boolean;
136
142
  };
137
143
  expect_amount: string;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 2 | 1 | 5 | 3 | 6 | 4;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -192,7 +192,7 @@ export function applyGlobalScan(_x14, _x15, _x16) {
192
192
  }
193
193
  function _applyGlobalScan() {
194
194
  _applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(host, formatted, bridge) {
195
- var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _bridge$onNotify4, _bridge$onNotify3, snapshot, result, list, _bridge$onNotify5, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify6, _data$order_id, _data$business_code, orderId, _bridge$onNotify7;
195
+ var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _bridge$onNotify4, _bridge$onNotify3, snapshot, scannedCustomerIsWalkIn, result, list, _bridge$onNotify5, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify6, _data$order_id, _data$business_code, orderId, _bridge$onNotify7;
196
196
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
197
197
  while (1) switch (_context4.prev = _context4.next) {
198
198
  case 0:
@@ -219,7 +219,7 @@ function _applyGlobalScan() {
219
219
  });
220
220
  case 8:
221
221
  if (!(searchType === 'walletPass')) {
222
- _context4.next = 25;
222
+ _context4.next = 26;
223
223
  break;
224
224
  }
225
225
  if (data) {
@@ -233,51 +233,52 @@ function _applyGlobalScan() {
233
233
  });
234
234
  case 12:
235
235
  snapshot = host.getOrderCustomerSnapshot();
236
- if (!isWalkInCustomer(snapshot)) {
237
- _context4.next = 22;
236
+ scannedCustomerIsWalkIn = isWalkInCustomer(data);
237
+ if (!(isWalkInCustomer(snapshot) || scannedCustomerIsWalkIn)) {
238
+ _context4.next = 23;
238
239
  break;
239
240
  }
240
241
  if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
241
- _context4.next = 16;
242
+ _context4.next = 17;
242
243
  break;
243
244
  }
244
245
  return _context4.abrupt("return", {
245
246
  status: 'failed',
246
247
  reason: 'no_bridge'
247
248
  });
248
- case 16:
249
- _context4.next = 18;
249
+ case 17:
250
+ _context4.next = 19;
250
251
  return bridge.applyPromotionCode(scanCode);
251
- case 18:
252
+ case 19:
252
253
  result = _context4.sent;
253
254
  if (!(result !== null && result !== void 0 && result.isAvailable)) {
254
- _context4.next = 21;
255
+ _context4.next = 22;
255
256
  break;
256
257
  }
257
258
  return _context4.abrupt("return", {
258
259
  status: 'success',
259
260
  kind: 'promotion'
260
261
  });
261
- case 21:
262
+ case 22:
262
263
  return _context4.abrupt("return", {
263
264
  status: 'failed',
264
265
  reason: 'invalid_data'
265
266
  });
266
- case 22:
267
+ case 23:
267
268
  host.setOrderCustomer(data);
268
269
  bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'success', 'pisell2.text.add-client-success');
269
270
  return _context4.abrupt("return", {
270
271
  status: 'success',
271
272
  kind: 'customer'
272
273
  });
273
- case 25:
274
+ case 26:
274
275
  if (!(searchType === 'product' || searchType === 'local_product')) {
275
- _context4.next = 58;
276
+ _context4.next = 59;
276
277
  break;
277
278
  }
278
279
  list = data === null || data === void 0 ? void 0 : data.list;
279
280
  if (!(!Array.isArray(list) || list.length === 0)) {
280
- _context4.next = 30;
281
+ _context4.next = 31;
281
282
  break;
282
283
  }
283
284
  bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -285,57 +286,57 @@ function _applyGlobalScan() {
285
286
  status: 'failed',
286
287
  reason: 'invalid_data'
287
288
  });
288
- case 30:
289
+ case 31:
289
290
  addedCount = 0;
290
291
  _iterator = _createForOfIteratorHelper(list);
291
- _context4.prev = 32;
292
+ _context4.prev = 33;
292
293
  _iterator.s();
293
- case 34:
294
+ case 35:
294
295
  if ((_step = _iterator.n()).done) {
295
- _context4.next = 46;
296
+ _context4.next = 47;
296
297
  break;
297
298
  }
298
299
  _item = _step.value;
299
- _context4.next = 38;
300
+ _context4.next = 39;
300
301
  return processScannedProductItem(host, _item, scanCode, bridge);
301
- case 38:
302
+ case 39:
302
303
  outcome = _context4.sent;
303
304
  if (outcome === 'added') {
304
305
  addedCount += 1;
305
306
  }
306
307
  if (!(outcome === 'cancelled')) {
307
- _context4.next = 42;
308
+ _context4.next = 43;
308
309
  break;
309
310
  }
310
311
  return _context4.abrupt("return", {
311
312
  status: 'cancelled'
312
313
  });
313
- case 42:
314
+ case 43:
314
315
  if (!(outcome === 'pending')) {
315
- _context4.next = 44;
316
+ _context4.next = 45;
316
317
  break;
317
318
  }
318
319
  return _context4.abrupt("return", {
319
320
  status: 'pending',
320
321
  kind: 'requiresDetail'
321
322
  });
322
- case 44:
323
- _context4.next = 34;
323
+ case 45:
324
+ _context4.next = 35;
324
325
  break;
325
- case 46:
326
- _context4.next = 51;
326
+ case 47:
327
+ _context4.next = 52;
327
328
  break;
328
- case 48:
329
- _context4.prev = 48;
330
- _context4.t0 = _context4["catch"](32);
329
+ case 49:
330
+ _context4.prev = 49;
331
+ _context4.t0 = _context4["catch"](33);
331
332
  _iterator.e(_context4.t0);
332
- case 51:
333
- _context4.prev = 51;
333
+ case 52:
334
+ _context4.prev = 52;
334
335
  _iterator.f();
335
- return _context4.finish(51);
336
- case 54:
336
+ return _context4.finish(52);
337
+ case 55:
337
338
  if (!(addedCount > 0)) {
338
- _context4.next = 57;
339
+ _context4.next = 58;
339
340
  break;
340
341
  }
341
342
  bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'success');
@@ -346,19 +347,19 @@ function _applyGlobalScan() {
346
347
  count: addedCount
347
348
  }
348
349
  });
349
- case 57:
350
+ case 58:
350
351
  return _context4.abrupt("return", {
351
352
  status: 'failed',
352
353
  reason: 'no_bridge'
353
354
  });
354
- case 58:
355
+ case 59:
355
356
  if (!(searchType === 'order')) {
356
- _context4.next = 67;
357
+ _context4.next = 68;
357
358
  break;
358
359
  }
359
360
  orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
360
361
  if (orderId) {
361
- _context4.next = 63;
362
+ _context4.next = 64;
362
363
  break;
363
364
  }
364
365
  bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
@@ -366,16 +367,16 @@ function _applyGlobalScan() {
366
367
  status: 'failed',
367
368
  reason: 'invalid_data'
368
369
  });
369
- case 63:
370
+ case 64:
370
371
  if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
371
- _context4.next = 65;
372
+ _context4.next = 66;
372
373
  break;
373
374
  }
374
375
  return _context4.abrupt("return", {
375
376
  status: 'pending',
376
377
  kind: 'openOrder'
377
378
  });
378
- case 65:
379
+ case 66:
379
380
  bridge.openOrder({
380
381
  order_id: Number(orderId),
381
382
  business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
@@ -384,16 +385,16 @@ function _applyGlobalScan() {
384
385
  status: 'pending',
385
386
  kind: 'openOrder'
386
387
  });
387
- case 67:
388
+ case 68:
388
389
  return _context4.abrupt("return", {
389
390
  status: 'failed',
390
391
  reason: 'invalid_data'
391
392
  });
392
- case 68:
393
+ case 69:
393
394
  case "end":
394
395
  return _context4.stop();
395
396
  }
396
- }, _callee4, null, [[32, 48, 51, 54]]);
397
+ }, _callee4, null, [[33, 49, 52, 55]]);
397
398
  }));
398
399
  return _applyGlobalScan.apply(this, arguments);
399
400
  }
@@ -23,7 +23,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
23
23
  customer_id: number;
24
24
  with_wallet_pass_holder: 0 | 1;
25
25
  request_timezone: string;
26
- order_id?: number;
26
+ order_id?: number | string;
27
27
  }): Promise<Discount[]>;
28
28
  batchSearch(code: string, options?: {
29
29
  customerId?: number;
@@ -93,6 +93,9 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
93
93
  }
94
94
  async loadPrepareConfig(params) {
95
95
  var _a, _b;
96
+ if (typeof params.order_id === "string" && params.order_id.startsWith("LOCAL_")) {
97
+ params.order_id = void 0;
98
+ }
96
99
  const prepareConfig = await this.request.post(
97
100
  `/order/prepare/config`,
98
101
  params
@@ -253,6 +256,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
253
256
  this.core.effects.offByModuleDestroy(this.name);
254
257
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
255
258
  console.log("[Discount] 已销毁");
259
+ super.destroy();
256
260
  }
257
261
  async clear() {
258
262
  this.store.discountList = [];
@@ -44,6 +44,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
44
44
  private applyProductDiscountPrices;
45
45
  constructor(name?: string, version?: string);
46
46
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
47
+ destroy(): Promise<void>;
47
48
  /**
48
49
  * 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
49
50
  *
@@ -150,9 +151,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
150
151
  private calculatePaymentEffectiveAmount;
151
152
  private calculatePaymentTotal;
152
153
  private getDepositAmount;
154
+ private normalizeDepositAmount;
155
+ private applyDepositAmountToSummary;
153
156
  private isDepositOrder;
154
157
  private getOrderExpectedAmount;
155
158
  private isDepositCovered;
159
+ private calculateDepositPaidAmount;
160
+ private resolveNextOrderPaymentType;
156
161
  private normalizePaymentSource;
157
162
  private updateTempOrderPaymentStatus;
158
163
  private shouldKeepPaymentStatusAfterAmountRecalc;
@@ -245,6 +250,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
245
250
  syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
246
251
  getTempOrderNote(): string;
247
252
  updateTempOrderShopDiscount(amount: string | number): string;
253
+ updateTempOrderDepositAmount(amount: string | number): OrderSummary;
248
254
  updateTempOrderBuzzer(buzzer: string): string;
249
255
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
250
256
  private buildTempOrderCustomer;
@@ -416,7 +422,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
416
422
  generateIdempotencyToken(): string;
417
423
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
418
424
  createOrder(params: CommitOrderParams['query']): {
419
- type: "virtual" | "appointment_booking";
425
+ type: "appointment_booking" | "virtual";
420
426
  platform: string;
421
427
  sales_channel: string;
422
428
  order_sales_channel: string;
@@ -249,6 +249,28 @@ var OrderModule = class extends import_BaseModule.BaseModule {
249
249
  this.registerDiscountModules(options);
250
250
  this.logInfo("OrderModule initialized successfully");
251
251
  }
252
+ async destroy() {
253
+ var _a, _b;
254
+ const childModules = [(_a = this.store) == null ? void 0 : _a.discount, (_b = this.store) == null ? void 0 : _b.rules];
255
+ for (const childModule of childModules) {
256
+ if (!childModule || typeof childModule.destroy !== "function")
257
+ continue;
258
+ try {
259
+ await childModule.destroy();
260
+ } catch (error) {
261
+ const errorMessage = error instanceof Error ? error.message : String(error);
262
+ this.logWarning("Destroy child module failed", {
263
+ module: childModule.name,
264
+ error: errorMessage
265
+ });
266
+ }
267
+ }
268
+ if (this.store) {
269
+ this.store.discount = null;
270
+ this.store.rules = null;
271
+ }
272
+ super.destroy();
273
+ }
252
274
  /**
253
275
  * 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
254
276
  *
@@ -762,6 +784,27 @@ var OrderModule = class extends import_BaseModule.BaseModule {
762
784
  getDepositAmount(tempOrder, summary) {
763
785
  return new import_decimal.default(summary.deposit_amount || tempOrder.deposit_amount || "0.00");
764
786
  }
787
+ normalizeDepositAmount(amount) {
788
+ return import_decimal.default.max(new import_decimal.default(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
789
+ }
790
+ applyDepositAmountToSummary(tempOrder, summary, amount) {
791
+ const depositAmount = this.normalizeDepositAmount(amount);
792
+ const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
793
+ const existedDeposit = summary.deposit && typeof summary.deposit === "object" ? summary.deposit : void 0;
794
+ const nextSummary = {
795
+ ...summary,
796
+ deposit_amount: depositAmount,
797
+ deposit: hasDepositAmount ? {
798
+ ...existedDeposit || {},
799
+ total: depositAmount,
800
+ deposit_policy_ids: (existedDeposit == null ? void 0 : existedDeposit.deposit_policy_ids) || [],
801
+ hasDeposit: true
802
+ } : void 0
803
+ };
804
+ tempOrder.deposit_amount = depositAmount;
805
+ tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
806
+ return nextSummary;
807
+ }
765
808
  isDepositOrder(tempOrder, depositAmount) {
766
809
  return tempOrder.is_deposit === 1 || depositAmount.gt(0);
767
810
  }
@@ -776,6 +819,30 @@ var OrderModule = class extends import_BaseModule.BaseModule {
776
819
  return false;
777
820
  return params.paidAmount.gte(depositAmount);
778
821
  }
822
+ calculateDepositPaidAmount(payments) {
823
+ return (payments || []).reduce((sum, payment) => {
824
+ const paymentRecord = payment;
825
+ if ((paymentRecord == null ? void 0 : paymentRecord.status) !== "paid")
826
+ return sum;
827
+ const isDepositPayment = paymentRecord.type === "deposit" || paymentRecord.order_payment_type === "deposit";
828
+ if (!isDepositPayment)
829
+ return sum;
830
+ if (paymentRecord.origin_amount !== void 0 && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== "") {
831
+ return sum.plus(this.calculatePaymentGapAmount(paymentRecord));
832
+ }
833
+ const rounding = new import_decimal.default(paymentRecord.rounding_amount || 0);
834
+ return sum.plus(new import_decimal.default(paymentRecord.amount || 0).minus(rounding));
835
+ }, new import_decimal.default(0));
836
+ }
837
+ resolveNextOrderPaymentType(tempOrder) {
838
+ const depositAmount = new import_decimal.default(tempOrder.deposit_amount || "0.00");
839
+ if (!this.isDepositOrder(tempOrder, depositAmount))
840
+ return "normal";
841
+ if (depositAmount.lte(0))
842
+ return "normal";
843
+ const depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
844
+ return depositPaidAmount.lt(depositAmount) ? "deposit" : "normal";
845
+ }
779
846
  normalizePaymentSource(payment, options) {
780
847
  const paymentRecord = payment;
781
848
  const metadata = paymentRecord.metadata && typeof paymentRecord.metadata === "object" ? { ...paymentRecord.metadata } : {};
@@ -1808,6 +1875,35 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1808
1875
  this.persistTempOrder();
1809
1876
  return tempOrder.shop_discount;
1810
1877
  }
1878
+ updateTempOrderDepositAmount(amount) {
1879
+ const tempOrder = this.ensureTempOrder();
1880
+ const depositAmount = this.normalizeDepositAmount(amount);
1881
+ const previousSummary = this.store.summary || (0, import_utils.createEmptySummary)();
1882
+ const summaryWithDeposit = this.applyDepositAmountToSummary(
1883
+ tempOrder,
1884
+ {
1885
+ ...(0, import_utils.createEmptySummary)(),
1886
+ ...previousSummary
1887
+ },
1888
+ depositAmount
1889
+ );
1890
+ const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
1891
+ const summary = {
1892
+ ...summaryWithDeposit,
1893
+ amount_gap: this.calculateSummaryAmountGap({
1894
+ tempOrder,
1895
+ summary: summaryWithDeposit,
1896
+ orderPaidAmount: paidPaymentSummary.gapPaidAmount
1897
+ })
1898
+ };
1899
+ this.store.summary = summary;
1900
+ this.updateTempOrderPaymentStatus(tempOrder, {
1901
+ previousSummary,
1902
+ summary
1903
+ });
1904
+ this.persistTempOrder();
1905
+ return summary;
1906
+ }
1811
1907
  updateTempOrderBuzzer(buzzer) {
1812
1908
  const tempOrder = this.ensureTempOrder();
1813
1909
  tempOrder.buzzer = String(buzzer || "");
@@ -2030,8 +2126,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2030
2126
  payment
2031
2127
  });
2032
2128
  const tempOrder = this.ensureTempOrder();
2129
+ const orderPaymentType = this.resolveNextOrderPaymentType(tempOrder);
2033
2130
  const mapped = (0, import_utils.mapPaymentItemsToOrderPayments)([
2034
- this.normalizePaymentSource(payment, { defaultPaid: true })
2131
+ this.normalizePaymentSource(
2132
+ {
2133
+ ...payment,
2134
+ type: orderPaymentType,
2135
+ order_payment_type: orderPaymentType
2136
+ },
2137
+ { defaultPaid: true }
2138
+ )
2035
2139
  ]);
2036
2140
  tempOrder.payments = [...tempOrder.payments || [], ...mapped];
2037
2141
  this.persistTempOrder();
@@ -180,6 +180,9 @@ export interface OrderProductSku {
180
180
  option: any[];
181
181
  [key: string]: any;
182
182
  }
183
+ export interface OrderLocalizedText {
184
+ [locale: string]: string | null;
185
+ }
183
186
  export interface OrderProduct extends OrderProductIdentity {
184
187
  order_detail_id: number | null;
185
188
  num: number;
@@ -193,6 +196,7 @@ export interface OrderProduct extends OrderProductIdentity {
193
196
  discount_list: OrderProductDiscountItem[];
194
197
  product_bundle: any[];
195
198
  booking_uid?: string;
199
+ product_title?: OrderLocalizedText;
196
200
  metadata: Record<string, any>;
197
201
  note?: string;
198
202
  }
@@ -212,6 +216,7 @@ export interface OrderSummary {
212
216
  deposit?: {
213
217
  total: string;
214
218
  deposit_policy_ids: number[];
219
+ deposit_policy_data?: any[];
215
220
  hasDeposit: boolean;
216
221
  };
217
222
  expect_amount: string;
@@ -479,6 +484,7 @@ export interface OrderPaymentData {
479
484
  amount: string;
480
485
  code: string;
481
486
  custom_payment_id: number;
487
+ custom_payment_type?: string;
482
488
  name: string;
483
489
  type: string;
484
490
  voucher_id?: string | number;
@@ -648,6 +654,7 @@ export interface OrderModuleAPI {
648
654
  (note: string, sync: boolean): string | Promise<string>;
649
655
  };
650
656
  updateTempOrderShopDiscount: (amount: string | number) => string;
657
+ updateTempOrderDepositAmount: (amount: string | number) => OrderSummary;
651
658
  updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
652
659
  updateTempOrderBuzzer: (buzzer: string) => string;
653
660
  updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
@@ -997,6 +997,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
997
997
  amount: String(item.amount ?? "0.00"),
998
998
  code: String(item.code || ""),
999
999
  custom_payment_id: Number(customPaymentId ?? 0),
1000
+ ...item.custom_payment_type !== void 0 ? { custom_payment_type: String(item.custom_payment_type) } : {},
1000
1001
  name: String(item.name || ""),
1001
1002
  type: String(item.type || ""),
1002
1003
  ...item.voucher_id !== void 0 ? { voucher_id: item.voucher_id } : {},
@@ -264,6 +264,9 @@ var WalletPassPaymentImpl = class {
264
264
  sale_channel: params.sale_channel,
265
265
  payment_order_id: (_a = this.walletParams) == null ? void 0 : _a.payment_order_id
266
266
  });
267
+ if (typeof params.payment_order_id === "string" && params.payment_order_id.startsWith("LOCAL_")) {
268
+ params.payment_order_id = void 0;
269
+ }
267
270
  const response = await this.paymentModule.request.post(
268
271
  "/machinecode/prepare/deduction/recommend",
269
272
  params
@@ -306,6 +309,9 @@ var WalletPassPaymentImpl = class {
306
309
  this.paymentModule.logInfo("[WalletPass] 商品列表为空,跳过获取用户识别码列表");
307
310
  return [];
308
311
  }
312
+ if (typeof newParams.payment_order_id === "string" && newParams.payment_order_id.startsWith("LOCAL_")) {
313
+ newParams.payment_order_id = void 0;
314
+ }
309
315
  this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
310
316
  customer_id: newParams.customer_id,
311
317
  available: newParams.available,
@@ -408,6 +414,9 @@ var WalletPassPaymentImpl = class {
408
414
  multiple: searchParams.multiple,
409
415
  payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
410
416
  });
417
+ if (typeof searchParams.payment_order_id === "string" && searchParams.payment_order_id.startsWith("LOCAL_")) {
418
+ searchParams.payment_order_id = void 0;
419
+ }
411
420
  let response;
412
421
  if (!searchParams.products || ((_a = searchParams.products || []) == null ? void 0 : _a.length) === 0) {
413
422
  response = {
@@ -1727,6 +1727,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1727
1727
  this.core.effects.offByModuleDestroy(this.name);
1728
1728
  await this.core.effects.emit(`${this.name}:onDestroy`, {});
1729
1729
  console.log("[Rules] 已销毁");
1730
+ super.destroy();
1730
1731
  }
1731
1732
  async clear() {
1732
1733
  console.log("[Rules] clear");
@@ -2520,6 +2520,7 @@ var Server = class {
2520
2520
  shop_order_number: next.shop_order_number,
2521
2521
  shop_full_order_number: next.shop_full_order_number
2522
2522
  });
2523
+ delete next.vouchers;
2523
2524
  return next;
2524
2525
  } catch (error) {
2525
2526
  this.logWarning(`${title}: checkout 查找本地订单失败`, {
@@ -73,6 +73,7 @@ export declare class OrderModule extends BaseModule implements Module {
73
73
  * // => { route: 'httpRefresh.batchIds', ... }
74
74
  */
75
75
  private resolveSyncMessageRoute;
76
+ private updateCreateStore;
76
77
  private getOrderSyncThrottleMs;
77
78
  preload(): Promise<void>;
78
79
  getOrders(): OrderData[];