@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
@@ -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;
@@ -1121,12 +1121,15 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
1121
1121
  var timestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
1122
1122
  var paymentTime = (_item$payment_time = item.payment_time) !== null && _item$payment_time !== void 0 ? _item$payment_time : timestamp;
1123
1123
  var createdAt = (_item$created_at = item.created_at) !== null && _item$created_at !== void 0 ? _item$created_at : timestamp;
1124
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
1124
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
1125
1125
  order_payment_id: item.order_payment_id
1126
1126
  } : {}), {}, {
1127
1127
  amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
1128
1128
  code: String(item.code || ''),
1129
- custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0),
1129
+ custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0)
1130
+ }, item.custom_payment_type !== undefined ? {
1131
+ custom_payment_type: String(item.custom_payment_type)
1132
+ } : {}), {}, {
1130
1133
  name: String(item.name || ''),
1131
1134
  type: String(item.type || '')
1132
1135
  }, item.voucher_id !== undefined ? {
@@ -363,10 +363,13 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
363
363
  sale_channel: params.sale_channel,
364
364
  payment_order_id: (_this$walletParams = this.walletParams) === null || _this$walletParams === void 0 ? void 0 : _this$walletParams.payment_order_id
365
365
  });
366
- _context4.next = 4;
366
+ if (typeof params.payment_order_id === 'string' && params.payment_order_id.startsWith('LOCAL_')) {
367
+ params.payment_order_id = undefined;
368
+ }
369
+ _context4.next = 5;
367
370
  return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
368
371
  );
369
- case 4:
372
+ case 5:
370
373
  response = _context4.sent;
371
374
  this.walletRecommendList = (response === null || response === void 0 ? void 0 : response.data) || [];
372
375
 
@@ -386,8 +389,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
386
389
  })
387
390
  });
388
391
  return _context4.abrupt("return", this.walletRecommendList);
389
- case 11:
390
- _context4.prev = 11;
392
+ case 12:
393
+ _context4.prev = 12;
391
394
  _context4.t0 = _context4["catch"](0);
392
395
  this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context4.t0, {
393
396
  customer_id: params.customer_id,
@@ -396,11 +399,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
396
399
  });
397
400
  // throw error;
398
401
  return _context4.abrupt("return", []);
399
- case 15:
402
+ case 16:
400
403
  case "end":
401
404
  return _context4.stop();
402
405
  }
403
- }, _callee4, this, [[0, 11]]);
406
+ }, _callee4, this, [[0, 12]]);
404
407
  }));
405
408
  function getWalletPassRecommendListAsync(_x4) {
406
409
  return _getWalletPassRecommendListAsync.apply(this, arguments);
@@ -429,6 +432,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
429
432
  this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
430
433
  return _context5.abrupt("return", []);
431
434
  case 5:
435
+ if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
436
+ newParams.payment_order_id = undefined;
437
+ }
432
438
  this.paymentModule.logInfo('[WalletPass] 开始获取用户识别码列表', {
433
439
  customer_id: newParams.customer_id,
434
440
  available: newParams.available,
@@ -436,9 +442,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
436
442
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
437
443
  payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
438
444
  });
439
- _context5.next = 8;
445
+ _context5.next = 9;
440
446
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
441
- case 8:
447
+ case 9:
442
448
  response = _context5.sent;
443
449
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
444
450
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
@@ -459,19 +465,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
459
465
  })
460
466
  });
461
467
  return _context5.abrupt("return", this.userIdentificationCodes);
462
- case 16:
463
- _context5.prev = 16;
468
+ case 17:
469
+ _context5.prev = 17;
464
470
  _context5.t0 = _context5["catch"](0);
465
471
  this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context5.t0, {
466
472
  customer_id: params.customer_id,
467
473
  available: params.available
468
474
  });
469
475
  return _context5.abrupt("return", []);
470
- case 20:
476
+ case 21:
471
477
  case "end":
472
478
  return _context5.stop();
473
479
  }
474
- }, _callee5, this, [[0, 16]]);
480
+ }, _callee5, this, [[0, 17]]);
475
481
  }));
476
482
  function getUserIdentificationCodeListAsync(_x5) {
477
483
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
@@ -572,31 +578,34 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
572
578
  multiple: searchParams.multiple,
573
579
  payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
574
580
  });
581
+ if (typeof searchParams.payment_order_id === 'string' && searchParams.payment_order_id.startsWith('LOCAL_')) {
582
+ searchParams.payment_order_id = undefined;
583
+ }
575
584
  if (!(!searchParams.products || ((_ref = searchParams.products || []) === null || _ref === void 0 ? void 0 : _ref.length) === 0)) {
576
- _context6.next = 21;
585
+ _context6.next = 22;
577
586
  break;
578
587
  }
579
588
  response = {
580
589
  data: []
581
590
  };
582
- _context6.next = 24;
591
+ _context6.next = 25;
583
592
  break;
584
- case 21:
585
- _context6.next = 23;
593
+ case 22:
594
+ _context6.next = 24;
586
595
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
587
- case 23:
588
- response = _context6.sent;
589
596
  case 24:
597
+ response = _context6.sent;
598
+ case 25:
590
599
  searchResults = ((_response2 = response) === null || _response2 === void 0 ? void 0 : _response2.data) || [];
591
600
  if (!config.noCache) {
592
- _context6.next = 27;
601
+ _context6.next = 28;
593
602
  break;
594
603
  }
595
604
  return _context6.abrupt("return", {
596
605
  type: 'normalCode',
597
606
  data: searchResults
598
607
  });
599
- case 27:
608
+ case 28:
600
609
  // 将搜索结果存储到缓存数组中
601
610
  if (searchResults.length > 0) {
602
611
  // 避免重复存储相同的识别码
@@ -626,8 +635,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
626
635
  type: 'normalCode',
627
636
  data: searchResults
628
637
  });
629
- case 33:
630
- _context6.prev = 33;
638
+ case 34:
639
+ _context6.prev = 34;
631
640
  _context6.t0 = _context6["catch"](1);
632
641
  this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context6.t0, {
633
642
  code: params.code,
@@ -635,11 +644,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
635
644
  order_expect_amount: params.order_expect_amount
636
645
  });
637
646
  throw _context6.t0;
638
- case 37:
647
+ case 38:
639
648
  case "end":
640
649
  return _context6.stop();
641
650
  }
642
- }, _callee6, this, [[1, 33]]);
651
+ }, _callee6, this, [[1, 34]]);
643
652
  }));
644
653
  function searchIdentificationCodeAsync(_x6) {
645
654
  return _searchIdentificationCodeAsync.apply(this, arguments);
@@ -18,6 +18,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
18
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
19
19
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
20
20
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
22
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
21
23
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
22
24
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
23
25
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -2266,7 +2268,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2266
2268
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
2267
2269
  case 3:
2268
2270
  console.log('[Rules] 已销毁');
2269
- case 4:
2271
+ _get(_getPrototypeOf(RulesModule.prototype), "destroy", this).call(this);
2272
+ case 5:
2270
2273
  case "end":
2271
2274
  return _context3.stop();
2272
2275
  }
@@ -3994,9 +3994,11 @@ var Server = /*#__PURE__*/function () {
3994
3994
  shop_order_number: next.shop_order_number,
3995
3995
  shop_full_order_number: next.shop_full_order_number
3996
3996
  });
3997
+ // 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
3998
+ delete next.vouchers;
3997
3999
  return _context42.abrupt("return", next);
3998
- case 27:
3999
- _context42.prev = 27;
4000
+ case 28:
4001
+ _context42.prev = 28;
4000
4002
  _context42.t0 = _context42["catch"](16);
4001
4003
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
4002
4004
  external_sale_number: externalSaleNumber,
@@ -4004,11 +4006,11 @@ var Server = /*#__PURE__*/function () {
4004
4006
  error_detail: this.normalizeUnknownError(_context42.t0)
4005
4007
  });
4006
4008
  return _context42.abrupt("return", next);
4007
- case 31:
4009
+ case 32:
4008
4010
  case "end":
4009
4011
  return _context42.stop();
4010
4012
  }
4011
- }, _callee42, this, [[16, 27]]);
4013
+ }, _callee42, this, [[16, 28]]);
4012
4014
  }));
4013
4015
  function normalizeCheckoutSubmitData(_x44, _x45) {
4014
4016
  return _normalizeCheckoutSubmitData.apply(this, arguments);
@@ -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[];
@@ -128,7 +128,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
128
128
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(core, options) {
129
129
  var _options$initialState,
130
130
  _this3 = this;
131
- var appPlugin, app, _this$store$createdAt, coreData, today, operatingDayBoundary, boundaryTime, boundaryStart, isAfterBoundary, queryStart, queryEnd;
131
+ var appPlugin, app;
132
132
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
133
133
  while (1) switch (_context2.prev = _context2.next) {
134
134
  case 0:
@@ -141,39 +141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
141
141
  this.dbManager = app.sqlite;
142
142
  this.logger = app.logger;
143
143
  this.storage = app.storage;
144
- coreData = app.data.store.getStore().getDataByModel('core');
145
- if (!((_this$store$createdAt = this.store.createdAtQuery) !== null && _this$store$createdAt !== void 0 && _this$store$createdAt.sales_time_between) && coreData !== null && coreData !== void 0 && coreData.core) {
146
- today = dayjs();
147
- if (coreData !== null && coreData !== void 0 && coreData.core.operating_day_boundary) {
148
- operatingDayBoundary = coreData.core.operating_day_boundary;
149
- if (operatingDayBoundary.type === 'start_time') {
150
- boundaryTime = String(operatingDayBoundary.time || '').trim();
151
- boundaryStart = dayjs("".concat(today.format('YYYY-MM-DD'), " ").concat(boundaryTime));
152
- if (boundaryStart.isValid()) {
153
- isAfterBoundary = today.isAfter(boundaryStart);
154
- queryStart = isAfterBoundary ? today.startOf('day') : today.subtract(1, 'day').startOf('day');
155
- queryEnd = isAfterBoundary ? today.add(1, 'day').endOf('day') : today.endOf('day');
156
- this.store.createdAtQuery = {
157
- sales_time_between: [queryStart.format('YYYY-MM-DD HH:mm:ss'), queryEnd.format('YYYY-MM-DD HH:mm:ss')]
158
- };
159
- } else {
160
- // 边界时间异常时回退到自然日,避免 createdAtQuery 为空导致后续查询异常
161
- this.store.createdAtQuery = {
162
- sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
163
- };
164
- }
165
- } else {
166
- this.store.createdAtQuery = {
167
- sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
168
- };
169
- }
170
- } else {
171
- // TODO: 这里后续可能需要使用店铺营业时间查询
172
- this.store.createdAtQuery = {
173
- sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
174
- };
175
- }
176
- }
144
+ this.updateCreateStore();
177
145
  }
178
146
  if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
179
147
  this.store.list = options.initialState.list.map(function (order) {
@@ -469,6 +437,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
469
437
  bodyOrderId: (_normalizedBody$order5 = normalizedBody === null || normalizedBody === void 0 ? void 0 : normalizedBody.order_id) !== null && _normalizedBody$order5 !== void 0 ? _normalizedBody$order5 : null
470
438
  };
471
439
  }
440
+ }, {
441
+ key: "updateCreateStore",
442
+ value: function updateCreateStore() {
443
+ var appPlugin = this.core.getPlugin('app');
444
+ var app = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp();
445
+ if (app) {
446
+ var _this$store$createdAt;
447
+ var coreData = app.data.store.getStore().getDataByModel('core');
448
+ if (!((_this$store$createdAt = this.store.createdAtQuery) !== null && _this$store$createdAt !== void 0 && _this$store$createdAt.sales_time_between) && coreData !== null && coreData !== void 0 && coreData.core) {
449
+ var today = dayjs();
450
+ if (coreData !== null && coreData !== void 0 && coreData.core.operating_day_boundary) {
451
+ var operatingDayBoundary = coreData.core.operating_day_boundary;
452
+ if (operatingDayBoundary.type === 'start_time') {
453
+ var boundaryTime = String(operatingDayBoundary.time || '').trim();
454
+ var boundaryStart = dayjs("".concat(today.format('YYYY-MM-DD'), " ").concat(boundaryTime));
455
+ if (boundaryStart.isValid()) {
456
+ var isAfterBoundary = today.isAfter(boundaryStart);
457
+ var queryStart = isAfterBoundary ? today.startOf('day') : today.subtract(1, 'day').startOf('day');
458
+ var queryEnd = isAfterBoundary ? today.add(1, 'day').endOf('day') : today.endOf('day');
459
+ this.store.createdAtQuery = {
460
+ sales_time_between: [queryStart.format('YYYY-MM-DD HH:mm:ss'), queryEnd.format('YYYY-MM-DD HH:mm:ss')]
461
+ };
462
+ } else {
463
+ // 边界时间异常时回退到自然日,避免 createdAtQuery 为空导致后续查询异常
464
+ this.store.createdAtQuery = {
465
+ sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
466
+ };
467
+ }
468
+ } else {
469
+ this.store.createdAtQuery = {
470
+ sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
471
+ };
472
+ }
473
+ } else {
474
+ // TODO: 这里后续可能需要使用店铺营业时间查询
475
+ this.store.createdAtQuery = {
476
+ sales_time_between: [today.startOf('day').format('YYYY-MM-DD HH:mm:ss'), today.endOf('day').format('YYYY-MM-DD HH:mm:ss')]
477
+ };
478
+ }
479
+ }
480
+ }
481
+ }
472
482
  }, {
473
483
  key: "getOrderSyncThrottleMs",
474
484
  value: function getOrderSyncThrottleMs() {
@@ -718,32 +728,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
718
728
  case 4:
719
729
  this.logInfo('silentRefresh 开始');
720
730
  _context7.prev = 5;
721
- _context7.next = 8;
731
+ // 刷新前,需要更新当前营业日边界(store.createdAtQuery)
732
+ this.updateCreateStore();
733
+ _context7.next = 9;
722
734
  return this.loadOrdersByServer();
723
- case 8:
735
+ case 9:
724
736
  orders = _context7.sent;
725
737
  if (!(orders.length > 0)) {
726
- _context7.next = 18;
738
+ _context7.next = 19;
727
739
  break;
728
740
  }
729
741
  this.store.list = cloneDeep(orders);
730
742
  this.syncOrdersMap();
731
743
  this.emitOrdersChanged([], 'silentRefresh');
732
- _context7.next = 15;
744
+ _context7.next = 16;
733
745
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
734
- case 15:
746
+ case 16:
735
747
  this.logInfo('silentRefresh 完成', {
736
748
  orderCount: orders.length,
737
749
  duration: "".concat(Date.now() - startTime, "ms")
738
750
  });
739
- _context7.next = 19;
751
+ _context7.next = 20;
740
752
  break;
741
- case 18:
742
- this.logInfo('silentRefresh: 服务器未返回数据');
743
753
  case 19:
754
+ this.logInfo('silentRefresh: 服务器未返回数据');
755
+ case 20:
744
756
  return _context7.abrupt("return", this.store.list);
745
- case 22:
746
- _context7.prev = 22;
757
+ case 23:
758
+ _context7.prev = 23;
747
759
  _context7.t0 = _context7["catch"](5);
748
760
  errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
749
761
  this.logError('silentRefresh 失败', {
@@ -751,11 +763,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
751
763
  error: errorMessage
752
764
  });
753
765
  return _context7.abrupt("return", this.store.list);
754
- case 27:
766
+ case 28:
755
767
  case "end":
756
768
  return _context7.stop();
757
769
  }
758
- }, _callee7, this, [[5, 22]]);
770
+ }, _callee7, this, [[5, 23]]);
759
771
  }));
760
772
  function silentRefresh() {
761
773
  return _silentRefresh.apply(this, arguments);
@@ -1894,6 +1906,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1894
1906
  if (!this.isBlankIdentityValue(metadataUid)) return "uid:".concat(String(metadataUid));
1895
1907
  var topLevelUid = record.unique_identification_number;
1896
1908
  if (!this.isBlankIdentityValue(topLevelUid)) return "uid:".concat(String(topLevelUid));
1909
+ var orderDetailId = record.order_detail_id;
1910
+ if (!this.isBlankIdentityValue(orderDetailId)) return "detail:".concat(String(orderDetailId));
1897
1911
  var bookingUid = record.booking_uid;
1898
1912
  if (!this.isBlankIdentityValue(bookingUid)) return "booking:".concat(String(bookingUid));
1899
1913
  return '';
@@ -221,8 +221,7 @@ function resolveProductTitle(params) {
221
221
  productMap = params.productMap,
222
222
  locale = params.locale;
223
223
  var ownTitle = getProductTitleSource(product, locale);
224
- // if (ownTitle) return ownTitle;
225
-
224
+ if (ownTitle) return ownTitle;
226
225
  var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
227
226
  var fallbackProduct = resolveProductFromMap(productId, productMap);
228
227
  if (!fallbackProduct) return ownTitle || '';
@@ -389,12 +388,12 @@ function getProductTitleSource(source, locale) {
389
388
  return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
390
389
  }
391
390
  function resolveTitleValue(value, locale) {
392
- var _ref15, _ref16, _value$locale;
391
+ var _ref15, _ref16, _ref17, _ref18, _value$locale;
393
392
  if (value === undefined || value === null) return '';
394
393
  if (_typeof(value) !== 'object') return stringify(value);
395
394
  var dashedLocale = locale.replace('_', '-');
396
395
  var underscoredLocale = locale.replace('-', '_');
397
- return stringify((_ref15 = (_ref16 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref16 !== void 0 ? _ref16 : value[underscoredLocale]) !== null && _ref15 !== void 0 ? _ref15 : '');
396
+ return stringify((_ref15 = (_ref16 = (_ref17 = (_ref18 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref18 !== void 0 ? _ref18 : value[underscoredLocale]) !== null && _ref17 !== void 0 ? _ref17 : value.original) !== null && _ref16 !== void 0 ? _ref16 : value.auto) !== null && _ref15 !== void 0 ? _ref15 : '');
398
397
  }
399
398
  function resolveOptionTitleFromParentProduct(params) {
400
399
  var option = params.option,
@@ -412,17 +411,17 @@ function flattenOptionItems(parentProduct) {
412
411
  return optionGroups.flatMap(function (group) {
413
412
  var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
414
413
  return items.map(function (item) {
415
- var _ref17, _item$option_group_id;
414
+ var _ref19, _item$option_group_id;
416
415
  return _objectSpread(_objectSpread({}, item), {}, {
417
- option_group_id: (_ref17 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref17 !== void 0 ? _ref17 : group.option_group_id
416
+ option_group_id: (_ref19 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref19 !== void 0 ? _ref19 : group.option_group_id
418
417
  });
419
418
  });
420
419
  });
421
420
  }
422
421
  function isOptionItemMatch(option, item) {
423
- var _ref18, _option$option_group_, _ref19, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
424
- var optionItemId = (_ref18 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref18 !== void 0 ? _ref18 : option.id;
425
- var itemId = (_ref19 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref19 !== void 0 ? _ref19 : item.id;
422
+ var _ref20, _option$option_group_, _ref21, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
423
+ var optionItemId = (_ref20 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref20 !== void 0 ? _ref20 : option.id;
424
+ var itemId = (_ref21 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref21 !== void 0 ? _ref21 : item.id;
426
425
  if (!isSameId(optionItemId, itemId)) return false;
427
426
  var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
428
427
  var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
@@ -432,16 +431,16 @@ function isOptionItemMatch(option, item) {
432
431
  return true;
433
432
  }
434
433
  function resolveBundleItemFromParentProduct(params) {
435
- var _ref20, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref22, _bundle$bundle_produc2;
434
+ var _ref22, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref24, _bundle$bundle_produc2;
436
435
  var bundle = params.bundle,
437
436
  parentProduct = params.parentProduct;
438
437
  if (!parentProduct) return null;
439
438
  var bundleItems = flattenBundleItems(parentProduct);
440
- var bundleVariantId = (_ref20 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_variant_id;
439
+ var bundleVariantId = (_ref22 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_variant_id;
441
440
  if (isNonZeroId(bundleVariantId)) {
442
441
  var matchedByVariant = bundleItems.find(function (item) {
443
- var _ref21, _item$bundle_variant_;
444
- return isSameId((_ref21 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref21 !== void 0 ? _ref21 : item.product_variant_id, bundleVariantId);
442
+ var _ref23, _item$bundle_variant_;
443
+ return isSameId((_ref23 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref23 !== void 0 ? _ref23 : item.product_variant_id, bundleVariantId);
445
444
  });
446
445
  if (matchedByVariant) return matchedByVariant;
447
446
  }
@@ -454,18 +453,18 @@ function resolveBundleItemFromParentProduct(params) {
454
453
  if (matchedByBundleId) return matchedByBundleId;
455
454
  }
456
455
  var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
457
- var bundleProductId = (_ref22 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_id;
456
+ var bundleProductId = (_ref24 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle.product_id;
458
457
  if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
459
458
  var matchedByGroupAndProduct = bundleItems.find(function (item) {
460
- var _item$group_id, _ref23, _item$bundle_product_;
461
- return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref23 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : item.product_id, bundleProductId);
459
+ var _item$group_id, _ref25, _item$bundle_product_;
460
+ return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref25 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref25 !== void 0 ? _ref25 : item.product_id, bundleProductId);
462
461
  });
463
462
  if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
464
463
  }
465
464
  if (isPresentId(bundleProductId)) {
466
465
  return bundleItems.find(function (item) {
467
- var _ref24, _item$bundle_product_2;
468
- return isSameId((_ref24 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : item.product_id, bundleProductId);
466
+ var _ref26, _item$bundle_product_2;
467
+ return isSameId((_ref26 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref26 !== void 0 ? _ref26 : item.product_id, bundleProductId);
469
468
  }) || null;
470
469
  }
471
470
  return null;
@@ -475,9 +474,9 @@ function flattenBundleItems(parentProduct) {
475
474
  return bundleGroups.flatMap(function (group) {
476
475
  var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
477
476
  return items.map(function (item) {
478
- var _ref25, _item$group_id2;
477
+ var _ref27, _item$group_id2;
479
478
  return _objectSpread(_objectSpread({}, item), {}, {
480
- group_id: (_ref25 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref25 !== void 0 ? _ref25 : group.group_id
479
+ group_id: (_ref27 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref27 !== void 0 ? _ref27 : group.group_id
481
480
  });
482
481
  });
483
482
  });
@@ -503,8 +502,8 @@ function buildOptionTitleSuffix(options) {
503
502
  return text ? "(".concat(text, ")") : '';
504
503
  }
505
504
  function formatBundlePrice(bundle, currencySymbol) {
506
- var _ref26, _ref27, _bundle$bundle_sellin;
507
- var value = (_ref26 = (_ref27 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref27 !== void 0 ? _ref27 : bundle.price) !== null && _ref26 !== void 0 ? _ref26 : 0;
505
+ var _ref28, _ref29, _bundle$bundle_sellin;
506
+ var value = (_ref28 = (_ref29 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref29 !== void 0 ? _ref29 : bundle.price) !== null && _ref28 !== void 0 ? _ref28 : 0;
508
507
  var amount = new Decimal(toMoneyNumber(value));
509
508
  var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
510
509
  if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
@@ -519,9 +518,9 @@ function buildFees(params) {
519
518
  currencySymbol = params.currencySymbol;
520
519
  var fees = [];
521
520
  for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
522
- var _ref28, _surcharge$amount;
521
+ var _ref30, _surcharge$amount;
523
522
  var surcharge = _normalizeArray[_i];
524
- var value = (_ref28 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref28 !== void 0 ? _ref28 : surcharge.total_amount;
523
+ var value = (_ref30 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref30 !== void 0 ? _ref30 : surcharge.total_amount;
525
524
  if (!isNonZero(value)) continue;
526
525
  fees.push({
527
526
  item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
@@ -565,7 +564,7 @@ function buildFees(params) {
565
564
  product_quantity: toNumber(summary.product_quantity || products.reduce(function (sum, product) {
566
565
  return sum + product.product_quantity;
567
566
  }, 0), 0),
568
- has_pay: formatMoney(sumPayments(order.payments), currencySymbol),
567
+ has_pay: formatMoney(calculateReceiptPaidAmount(order, summary), currencySymbol),
569
568
  payment_method: '',
570
569
  tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
571
570
  total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol)
@@ -656,8 +655,8 @@ function buildPaymentData(params) {
656
655
  currencySymbol: params.currencySymbol
657
656
  })));
658
657
  } else {
659
- var _ref29, _payment$remaining_am, _payment$metadata;
660
- var remainingAmount = (_ref29 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref29 !== void 0 ? _ref29 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
658
+ var _ref31, _payment$remaining_am, _payment$metadata;
659
+ var remainingAmount = (_ref31 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref31 !== void 0 ? _ref31 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
661
660
  if (remainingAmount !== undefined && remainingAmount !== null) {
662
661
  items.push({
663
662
  item: label(params.locale, 'remainingAmount'),
@@ -765,11 +764,11 @@ function label(locale, key) {
765
764
  return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
766
765
  }
767
766
  function getLocalizedValue(value, locale) {
768
- var _ref30, _ref31, _ref32, _value$locale2;
767
+ var _ref32, _ref33, _ref34, _value$locale2;
769
768
  if (value === undefined || value === null) return '';
770
769
  if (_typeof(value) !== 'object') return stringify(value);
771
770
  var dashedLocale = locale.replace('_', '-');
772
- return stringify((_ref30 = (_ref31 = (_ref32 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref32 !== void 0 ? _ref32 : value.default) !== null && _ref31 !== void 0 ? _ref31 : value.en) !== null && _ref30 !== void 0 ? _ref30 : '');
771
+ return stringify((_ref32 = (_ref33 = (_ref34 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref34 !== void 0 ? _ref34 : value.default) !== null && _ref33 !== void 0 ? _ref33 : value.en) !== null && _ref32 !== void 0 ? _ref32 : '');
773
772
  }
774
773
  function serviceTypeToLabelKey(serviceType) {
775
774
  var normalized = serviceType.toLowerCase();
@@ -794,6 +793,17 @@ function formatMoney(value, currencySymbol) {
794
793
  var amount = new Decimal(toMoneyNumber(value));
795
794
  return "".concat(currencySymbol).concat(amount.toFixed(2));
796
795
  }
796
+ function calculateReceiptPaidAmount(order, summary) {
797
+ var _summary$pay_service_, _summary$total_amount;
798
+ var paidAmount = sumPayments(order.payments);
799
+ var payProcessingFee = new Decimal(toMoneyNumber((_summary$pay_service_ = summary.pay_service_charge_amount) !== null && _summary$pay_service_ !== void 0 ? _summary$pay_service_ : order.pay_service_charge_amount));
800
+ if (payProcessingFee.lte(0)) return paidAmount;
801
+ var totalAmount = new Decimal(toMoneyNumber((_summary$total_amount = summary.total_amount) !== null && _summary$total_amount !== void 0 ? _summary$total_amount : order.total_amount));
802
+ if (totalAmount.gt(0) && paidAmount.gte(totalAmount)) return paidAmount;
803
+ var paidAmountWithFee = paidAmount.plus(payProcessingFee);
804
+ if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount)) return totalAmount;
805
+ return paidAmountWithFee;
806
+ }
797
807
  function sumPayments(payments) {
798
808
  return normalizeArray(payments).filter(function (payment) {
799
809
  return isPrintablePayment(payment);