@pisell/pisellos 2.3.37 → 2.3.39

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 (169) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +40 -11
  3. package/dist/modules/Discount/types.d.ts +1 -0
  4. package/dist/modules/Holder/index.d.ts +48 -0
  5. package/dist/modules/Holder/index.js +640 -0
  6. package/dist/modules/Holder/types.d.ts +123 -0
  7. package/dist/modules/Holder/types.js +1 -0
  8. package/dist/modules/Holder/utils.d.ts +13 -0
  9. package/dist/modules/Holder/utils.js +34 -0
  10. package/dist/modules/OpenData/index.js +2 -2
  11. package/dist/modules/Order/index.d.ts +11 -28
  12. package/dist/modules/Order/index.js +513 -747
  13. package/dist/modules/Order/types.d.ts +10 -33
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  15. package/dist/modules/Order/utils.d.ts +10 -0
  16. package/dist/modules/Order/utils.js +40 -11
  17. package/dist/modules/Payment/index.d.ts +0 -2
  18. package/dist/modules/Payment/index.js +49 -78
  19. package/dist/modules/Payment/types.d.ts +24 -26
  20. package/dist/modules/Payment/types.js +0 -2
  21. package/dist/modules/Product/types.d.ts +1 -0
  22. package/dist/modules/ProductList/index.js +33 -14
  23. package/dist/modules/Quotation/index.d.ts +1 -1
  24. package/dist/modules/Quotation/index.js +2 -2
  25. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  26. package/dist/modules/ResourcePlanner/index.js +181 -0
  27. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  28. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  29. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  30. package/dist/modules/ResourcePlanner/types.js +1 -0
  31. package/dist/modules/Rules/index.js +48 -15
  32. package/dist/modules/SalesSummary/index.js +12 -13
  33. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  34. package/dist/modules/ScanOrderLogger/index.js +15 -2
  35. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  36. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  37. package/dist/modules/Schedule/index.d.ts +3 -1
  38. package/dist/modules/Schedule/index.js +21 -16
  39. package/dist/modules/Summary/utils.js +38 -13
  40. package/dist/modules/index.d.ts +2 -0
  41. package/dist/modules/index.js +3 -1
  42. package/dist/plugins/window.d.ts +1 -0
  43. package/dist/server/index.d.ts +14 -16
  44. package/dist/server/index.js +1162 -1943
  45. package/dist/server/modules/order/index.d.ts +4 -49
  46. package/dist/server/modules/order/index.js +695 -1574
  47. package/dist/server/modules/order/types.d.ts +3 -11
  48. package/dist/server/modules/order/types.js +1 -1
  49. package/dist/solution/BaseSales/index.d.ts +10 -33
  50. package/dist/solution/BaseSales/index.js +385 -676
  51. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  52. package/dist/solution/BookingByStep/index.d.ts +17 -2
  53. package/dist/solution/BookingByStep/index.js +294 -215
  54. package/dist/solution/BookingByStep/types.d.ts +2 -1
  55. package/dist/solution/BookingByStep/types.js +3 -1
  56. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  57. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  58. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  59. package/dist/solution/BookingTicket/index.js +1 -2
  60. package/dist/solution/Sales/index.d.ts +0 -1
  61. package/dist/solution/Sales/index.js +2 -10
  62. package/dist/solution/ScanOrder/index.d.ts +26 -14
  63. package/dist/solution/ScanOrder/index.js +1140 -737
  64. package/dist/solution/ScanOrder/types.d.ts +21 -1
  65. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  66. package/dist/solution/ScanOrder/utils.js +66 -25
  67. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  68. package/dist/solution/ShopDiscount/index.js +125 -87
  69. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  70. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  71. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  72. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  73. package/dist/solution/VenueBooking/index.d.ts +39 -11
  74. package/dist/solution/VenueBooking/index.js +1177 -850
  75. package/dist/solution/VenueBooking/types.d.ts +3 -0
  76. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  77. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  78. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  79. package/dist/solution/index.d.ts +1 -0
  80. package/dist/solution/index.js +2 -1
  81. package/dist/types/index.d.ts +1 -0
  82. package/lib/modules/Discount/index.d.ts +1 -0
  83. package/lib/modules/Discount/index.js +9 -0
  84. package/lib/modules/Discount/types.d.ts +1 -0
  85. package/lib/modules/Holder/index.d.ts +48 -0
  86. package/lib/modules/Holder/index.js +402 -0
  87. package/lib/modules/Holder/types.d.ts +123 -0
  88. package/lib/modules/Holder/types.js +17 -0
  89. package/lib/modules/Holder/utils.d.ts +13 -0
  90. package/lib/modules/Holder/utils.js +71 -0
  91. package/lib/modules/OpenData/index.js +1 -1
  92. package/lib/modules/Order/index.d.ts +11 -28
  93. package/lib/modules/Order/index.js +83 -187
  94. package/lib/modules/Order/types.d.ts +10 -33
  95. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  96. package/lib/modules/Order/utils.d.ts +10 -0
  97. package/lib/modules/Order/utils.js +39 -10
  98. package/lib/modules/Payment/index.d.ts +0 -2
  99. package/lib/modules/Payment/index.js +12 -33
  100. package/lib/modules/Payment/types.d.ts +24 -26
  101. package/lib/modules/Product/types.d.ts +1 -0
  102. package/lib/modules/ProductList/index.js +40 -31
  103. package/lib/modules/Quotation/index.d.ts +1 -1
  104. package/lib/modules/Quotation/index.js +2 -2
  105. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  106. package/lib/modules/ResourcePlanner/index.js +148 -0
  107. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  108. package/lib/modules/ResourcePlanner/planner.js +933 -0
  109. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  110. package/lib/modules/ResourcePlanner/types.js +17 -0
  111. package/lib/modules/Rules/index.js +34 -18
  112. package/lib/modules/SalesSummary/index.js +6 -7
  113. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  114. package/lib/modules/ScanOrderLogger/index.js +13 -1
  115. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  116. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  117. package/lib/modules/Schedule/index.d.ts +3 -1
  118. package/lib/modules/Schedule/index.js +10 -8
  119. package/lib/modules/Summary/utils.js +21 -1
  120. package/lib/modules/index.d.ts +2 -0
  121. package/lib/modules/index.js +5 -1
  122. package/lib/plugins/window.d.ts +1 -0
  123. package/lib/server/index.d.ts +14 -16
  124. package/lib/server/index.js +88 -678
  125. package/lib/server/modules/order/index.d.ts +4 -49
  126. package/lib/server/modules/order/index.js +66 -657
  127. package/lib/server/modules/order/types.d.ts +3 -11
  128. package/lib/solution/BaseSales/index.d.ts +10 -33
  129. package/lib/solution/BaseSales/index.js +33 -201
  130. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  131. package/lib/solution/BookingByStep/index.d.ts +17 -2
  132. package/lib/solution/BookingByStep/index.js +60 -18
  133. package/lib/solution/BookingByStep/types.d.ts +2 -1
  134. package/lib/solution/BookingByStep/types.js +5 -0
  135. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  136. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  137. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  138. package/lib/solution/BookingTicket/index.js +1 -2
  139. package/lib/solution/Sales/index.d.ts +0 -1
  140. package/lib/solution/Sales/index.js +3 -5
  141. package/lib/solution/ScanOrder/index.d.ts +26 -14
  142. package/lib/solution/ScanOrder/index.js +449 -182
  143. package/lib/solution/ScanOrder/types.d.ts +21 -1
  144. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  145. package/lib/solution/ScanOrder/utils.js +31 -0
  146. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  147. package/lib/solution/ShopDiscount/index.js +14 -0
  148. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  149. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  150. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  151. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  152. package/lib/solution/VenueBooking/index.d.ts +39 -11
  153. package/lib/solution/VenueBooking/index.js +328 -115
  154. package/lib/solution/VenueBooking/types.d.ts +3 -0
  155. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  156. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  157. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  158. package/lib/solution/index.d.ts +1 -0
  159. package/lib/solution/index.js +3 -1
  160. package/lib/types/index.d.ts +1 -0
  161. package/package.json +2 -2
  162. package/dist/modules/Order/payment-utils.d.ts +0 -26
  163. package/dist/modules/Order/payment-utils.js +0 -225
  164. package/dist/utils/payment-number.d.ts +0 -9
  165. package/dist/utils/payment-number.js +0 -69
  166. package/lib/modules/Order/payment-utils.d.ts +0 -26
  167. package/lib/modules/Order/payment-utils.js +0 -224
  168. package/lib/utils/payment-number.d.ts +0 -9
  169. package/lib/utils/payment-number.js +0 -64
@@ -32,11 +32,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
32
32
  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); }
33
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
35
+ import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
- import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
39
- import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
40
38
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
41
39
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
42
40
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
@@ -99,7 +97,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
99
97
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
100
98
  // LoggerManager 实例
101
99
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
102
- _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
103
100
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
104
101
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
105
102
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
@@ -286,8 +283,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
286
283
  key: "initialize",
287
284
  value: function () {
288
285
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
289
- var _otherParams$rules, _otherParams$order, _otherParams$hooks;
290
- var app, otherParams;
286
+ var _appPlugin$getApp, _otherParams$rules, _otherParams$order, _otherParams$hooks;
287
+ var appPlugin, app, otherParams;
291
288
  return _regeneratorRuntime().wrap(function _callee$(_context) {
292
289
  while (1) switch (_context.prev = _context.next) {
293
290
  case 0:
@@ -303,15 +300,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
303
300
  this.store.availableWalletIds = [];
304
301
  }
305
302
  this.request = this.core.getPlugin('request');
306
- this.appPlugin = this.core.getPlugin('app');
307
- if (this.appPlugin) {
308
- _context.next = 9;
309
- break;
303
+ appPlugin = this.core.getPlugin('app');
304
+ if (!appPlugin) {
305
+ console.error('Order 模块需要 app 插件支持');
310
306
  }
311
- throw new Error('Order 模块需要 app 插件支持');
312
- case 9:
313
- app = this.appPlugin.getApp();
314
- this.logger = app.logger;
307
+ app = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
308
+ this.logger = app === null || app === void 0 ? void 0 : app.logger;
315
309
  this.window = this.core.getPlugin('window');
316
310
  otherParams = options.otherParams || {};
317
311
  this.cacheId = otherParams.cacheId;
@@ -322,7 +316,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
322
316
  this.otherParams = otherParams;
323
317
  this.registerDiscountModules(options);
324
318
  this.logInfo('OrderModule initialized successfully');
325
- case 21:
319
+ case 20:
326
320
  case "end":
327
321
  return _context.stop();
328
322
  }
@@ -1227,6 +1221,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1227
1221
  value: function persistTempOrder() {
1228
1222
  // no-op: OrderModule 的刷新恢复不再依赖 localStorage。
1229
1223
  }
1224
+ }, {
1225
+ key: "notifyTempOrderChanged",
1226
+ value: function notifyTempOrderChanged() {
1227
+ if (!this.store.tempOrder) return;
1228
+ this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
1229
+ products: _toConsumableArray(this.store.tempOrder.products),
1230
+ bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
1231
+ });
1232
+ this.persistTempOrder();
1233
+ }
1230
1234
 
1231
1235
  // ─── TempOrder: 创建 & 获取 ───
1232
1236
  }, {
@@ -1513,44 +1517,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1513
1517
  var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
1514
1518
  return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
1515
1519
  }
1516
- }, {
1517
- key: "getPaymentNumberAppData",
1518
- value: function getPaymentNumberAppData(key) {
1519
- var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
1520
- var appPlugin = this.appPlugin;
1521
- if (!appPlugin) return undefined;
1522
- var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
1523
- if (typeof getData === 'function') return getData(key);
1524
- var app = appPlugin.getApp();
1525
- var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
1526
- return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1527
- }
1528
- }, {
1529
- key: "getPaymentNumberDevicePrefixSync",
1530
- value: function getPaymentNumberDevicePrefixSync() {
1531
- var _this7 = this;
1532
- return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1533
- return _this7.getPaymentNumberAppData(key);
1534
- });
1535
- }
1536
- }, {
1537
- key: "getPaymentNumberDevicePrefixAsync",
1538
- value: function getPaymentNumberDevicePrefixAsync() {
1539
- var _this8 = this;
1540
- return resolvePaymentNumberDevicePrefix(function (key) {
1541
- return _this8.getPaymentNumberAppData(key);
1542
- });
1543
- }
1544
1520
  }, {
1545
1521
  key: "normalizePaymentSource",
1546
1522
  value: function normalizePaymentSource(payment, options) {
1547
1523
  var _ref19, _paymentRecord$origin;
1548
1524
  var paymentRecord = payment;
1549
1525
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1550
- var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1526
+ if (!metadata.unique_payment_number) {
1527
+ metadata.unique_payment_number = createUuidV4();
1528
+ }
1529
+ var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1551
1530
  metadata: metadata,
1552
1531
  origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
1553
- }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1532
+ });
1554
1533
  if (paymentRecord.status !== undefined) {
1555
1534
  normalized.status = paymentRecord.status;
1556
1535
  } else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
@@ -1668,16 +1647,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1668
1647
  }, {
1669
1648
  key: "calculatePaidPaymentSummary",
1670
1649
  value: function calculatePaidPaymentSummary(payments) {
1671
- var _this9 = this;
1650
+ var _this7 = this;
1672
1651
  return (payments || []).reduce(function (summary, payment) {
1673
1652
  var paymentRecord = payment;
1674
1653
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1675
1654
  return {
1676
1655
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1677
- orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
1678
- gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
1679
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
1680
- roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
1656
+ orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1657
+ gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1658
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1659
+ roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1681
1660
  };
1682
1661
  }, {
1683
1662
  customerPaidAmount: new Decimal(0),
@@ -1879,15 +1858,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1879
1858
  }, {
1880
1859
  key: "normalizeFingerprintValue",
1881
1860
  value: function normalizeFingerprintValue(value) {
1882
- var _this10 = this;
1861
+ var _this8 = this;
1883
1862
  if (Array.isArray(value)) {
1884
1863
  return value.map(function (item) {
1885
- return _this10.normalizeFingerprintValue(item);
1864
+ return _this8.normalizeFingerprintValue(item);
1886
1865
  });
1887
1866
  }
1888
1867
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1889
1868
  return Object.keys(value).sort().reduce(function (result, key) {
1890
- result[key] = _this10.normalizeFingerprintValue(value[key]);
1869
+ result[key] = _this8.normalizeFingerprintValue(value[key]);
1891
1870
  return result;
1892
1871
  }, {});
1893
1872
  }
@@ -1902,7 +1881,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1902
1881
  _sku$barcode,
1903
1882
  _ref20,
1904
1883
  _sku$variant_id,
1905
- _this11 = this;
1884
+ _this9 = this;
1906
1885
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1907
1886
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1908
1887
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1936,7 +1915,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1936
1915
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1937
1916
  option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1938
1917
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1939
- add_price: _this11.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1918
+ add_price: _this9.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1940
1919
  };
1941
1920
  })
1942
1921
  }),
@@ -1946,8 +1925,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1946
1925
  bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
1947
1926
  bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
1948
1927
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1949
- price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1950
- bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1928
+ price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1929
+ bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1951
1930
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1952
1931
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1953
1932
  };
@@ -1957,7 +1936,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1957
1936
  return {
1958
1937
  type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
1959
1938
  discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
1960
- amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1939
+ amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1961
1940
  };
1962
1941
  }))
1963
1942
  };
@@ -1965,9 +1944,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1965
1944
  }, {
1966
1945
  key: "buildOrderProductsFingerprint",
1967
1946
  value: function buildOrderProductsFingerprint(products) {
1968
- var _this12 = this;
1947
+ var _this10 = this;
1969
1948
  var items = (products || []).map(function (product) {
1970
- return _this12.buildProductFingerprintItem(product);
1949
+ return _this10.buildProductFingerprintItem(product);
1971
1950
  });
1972
1951
  items.sort(function (left, right) {
1973
1952
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1989,7 +1968,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1989
1968
  _sku$barcode2,
1990
1969
  _ref30,
1991
1970
  _sku$variant_id2,
1992
- _this13 = this;
1971
+ _this11 = this;
1993
1972
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1994
1973
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1995
1974
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2020,7 +1999,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2020
1999
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
2021
2000
  option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2022
2001
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2023
- add_price: _this13.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2002
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2024
2003
  };
2025
2004
  })
2026
2005
  }),
@@ -2034,14 +2013,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2034
2013
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2035
2014
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2036
2015
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
2037
- option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2016
+ option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2038
2017
  var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
2039
2018
  return {
2040
2019
  id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
2041
2020
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
2042
2021
  option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2043
2022
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2044
- add_price: _this13.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2023
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2045
2024
  };
2046
2025
  }))
2047
2026
  };
@@ -2051,7 +2030,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2051
2030
  return {
2052
2031
  type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
2053
2032
  discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2054
- amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2033
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2055
2034
  };
2056
2035
  }))
2057
2036
  };
@@ -2059,9 +2038,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2059
2038
  }, {
2060
2039
  key: "buildOrderProductsStructuralFingerprint",
2061
2040
  value: function buildOrderProductsStructuralFingerprint(products) {
2062
- var _this14 = this;
2041
+ var _this12 = this;
2063
2042
  var items = (products || []).map(function (product) {
2064
- return _this14.buildProductStructuralFingerprintItem(product);
2043
+ return _this12.buildProductStructuralFingerprintItem(product);
2065
2044
  });
2066
2045
  items.sort(function (left, right) {
2067
2046
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2489,9 +2468,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2489
2468
  }, {
2490
2469
  key: "sanitizeTempOrderProducts",
2491
2470
  value: function sanitizeTempOrderProducts(tempOrder) {
2492
- var _this15 = this;
2471
+ var _this13 = this;
2493
2472
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2494
- return _this15.sanitizeOrderProductForTempOrder(product);
2473
+ return _this13.sanitizeOrderProductForTempOrder(product);
2495
2474
  });
2496
2475
  }
2497
2476
  }, {
@@ -2594,7 +2573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2594
2573
  }, {
2595
2574
  key: "syncLinkedBookingHoldersToProducts",
2596
2575
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2597
- var _this16 = this;
2576
+ var _this14 = this;
2598
2577
  var bookings = tempOrder.bookings || [];
2599
2578
  var products = tempOrder.products || [];
2600
2579
  if (!bookings.length || !products.length) return;
@@ -2619,7 +2598,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2619
2598
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2620
2599
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2621
2600
  if (linkedBooking) {
2622
- _this16.setProductHolderFromBooking(product, linkedBooking);
2601
+ _this14.setProductHolderFromBooking(product, linkedBooking);
2623
2602
  }
2624
2603
  });
2625
2604
  }
@@ -2747,9 +2726,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2747
2726
  }, {
2748
2727
  key: "findBookingIndexByUniqueIdentificationNumber",
2749
2728
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2750
- var _this17 = this;
2729
+ var _this15 = this;
2751
2730
  return (tempOrder.bookings || []).findIndex(function (booking) {
2752
- return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2731
+ return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2753
2732
  });
2754
2733
  }
2755
2734
  }, {
@@ -2757,12 +2736,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2757
2736
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2758
2737
  var _product$metadata7,
2759
2738
  _product$metadata8,
2760
- _this18 = this;
2739
+ _this16 = this;
2761
2740
  var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2762
2741
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2763
2742
  if (!productUid && !bookingUid) return;
2764
2743
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2765
- var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
2744
+ var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2766
2745
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2767
2746
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2768
2747
  return true;
@@ -3095,15 +3074,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3095
3074
  }, {
3096
3075
  key: "productHasCustomerBoundDiscount",
3097
3076
  value: function productHasCustomerBoundDiscount(product) {
3098
- var _this19 = this;
3077
+ var _this17 = this;
3099
3078
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3100
- return _this19.isCustomerBoundDiscount(discount);
3079
+ return _this17.isCustomerBoundDiscount(discount);
3101
3080
  })) {
3102
3081
  return true;
3103
3082
  }
3104
3083
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3105
3084
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3106
- return _this19.isCustomerBoundDiscount(discount);
3085
+ return _this17.isCustomerBoundDiscount(discount);
3107
3086
  });
3108
3087
  });
3109
3088
  }
@@ -3112,18 +3091,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3112
3091
  value: function shouldSkipDiscountCalculation(tempOrder) {
3113
3092
  var _this$store$discount17,
3114
3093
  _this$store$discount18,
3115
- _this20 = this;
3094
+ _this18 = this;
3116
3095
  if (this.hasActiveCustomerBoundDiscount) return false;
3117
3096
  var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3118
3097
  if (discountList.length > 0) return false;
3119
3098
  return !(tempOrder.products || []).some(function (product) {
3120
- return _this20.productHasCustomerBoundDiscount(product);
3099
+ return _this18.productHasCustomerBoundDiscount(product);
3121
3100
  });
3122
3101
  }
3123
3102
  }, {
3124
3103
  key: "clearCustomerBoundDiscounts",
3125
3104
  value: function clearCustomerBoundDiscounts(tempOrder) {
3126
- var _this21 = this,
3105
+ var _this19 = this,
3127
3106
  _discountModule$getDi,
3128
3107
  _discountModule$getOr,
3129
3108
  _discountModule$setDi,
@@ -3132,7 +3111,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3132
3111
  var filterDiscountList = function filterDiscountList(discountList) {
3133
3112
  if (!Array.isArray(discountList)) return [];
3134
3113
  return discountList.filter(function (discount) {
3135
- var shouldRemove = _this21.isCustomerBoundDiscount(discount);
3114
+ var shouldRemove = _this19.isCustomerBoundDiscount(discount);
3136
3115
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3137
3116
  return !shouldRemove;
3138
3117
  });
@@ -3159,12 +3138,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3159
3138
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3160
3139
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3161
3140
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3162
- if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3163
- return !_this21.isCustomerBoundDiscount(discount);
3141
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3142
+ return !_this19.isCustomerBoundDiscount(discount);
3164
3143
  });
3165
3144
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3166
- if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3167
- return !_this21.isCustomerBoundDiscount(discount);
3145
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3146
+ return !_this19.isCustomerBoundDiscount(discount);
3168
3147
  });
3169
3148
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3170
3149
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3318,71 +3297,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3318
3297
  * 用一组支付来源覆盖当前订单支付项。
3319
3298
  *
3320
3299
  * 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
3321
- * 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
3300
+ * uuid -> metadata.unique_payment_number,id -> custom_payment_id,
3322
3301
  * isSynced 等运行态字段不会进入 tempOrder.payments。
3323
3302
  */
3324
3303
  }, {
3325
3304
  key: "setOrderPayments",
3326
3305
  value: function setOrderPayments(payments) {
3327
- var _this22 = this;
3328
3306
  var tempOrder = this.ensureTempOrder();
3329
- tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
3330
- return _this22.normalizePaymentSource(payment, {
3331
- defaultPaid: false
3332
- });
3333
- }));
3307
+ tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
3334
3308
  this.persistTempOrder();
3335
3309
  return tempOrder.payments;
3336
3310
  }
3337
3311
 
3338
- /** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
3312
+ /** 追加单个支付项,并立即持久化当前 tempOrder。 */
3339
3313
  }, {
3340
3314
  key: "addOrderPayment",
3341
3315
  value: function addOrderPayment(payment) {
3342
- var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3343
- return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3344
- }
3345
-
3346
- /** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
3347
- }, {
3348
- key: "addOrderPaymentAsync",
3349
- value: (function () {
3350
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
3351
- var hasPaymentNumber, devicePrefix;
3352
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3353
- while (1) switch (_context17.prev = _context17.next) {
3354
- case 0:
3355
- hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3356
- if (!hasPaymentNumber) {
3357
- _context17.next = 5;
3358
- break;
3359
- }
3360
- _context17.t0 = 'LOCAL';
3361
- _context17.next = 8;
3362
- break;
3363
- case 5:
3364
- _context17.next = 7;
3365
- return this.getPaymentNumberDevicePrefixAsync();
3366
- case 7:
3367
- _context17.t0 = _context17.sent;
3368
- case 8:
3369
- devicePrefix = _context17.t0;
3370
- return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3371
- case 10:
3372
- case "end":
3373
- return _context17.stop();
3374
- }
3375
- }, _callee15, this);
3376
- }));
3377
- function addOrderPaymentAsync(_x14) {
3378
- return _addOrderPaymentAsync.apply(this, arguments);
3379
- }
3380
- return addOrderPaymentAsync;
3381
- }())
3382
- }, {
3383
- key: "addOrderPaymentWithDevicePrefix",
3384
- value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3385
- var _this23 = this;
3316
+ var _this20 = this;
3386
3317
  this.logInfo('addOrderPayment', {
3387
3318
  payment: payment
3388
3319
  });
@@ -3392,15 +3323,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3392
3323
  type: orderPaymentType,
3393
3324
  order_payment_type: orderPaymentType
3394
3325
  }), {
3395
- defaultPaid: true,
3396
- devicePrefix: devicePrefix
3326
+ defaultPaid: true
3397
3327
  })]);
3398
3328
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
3399
3329
  this.persistTempOrder();
3400
3330
  void this.recalculateSummary({
3401
3331
  createIfMissing: true
3402
3332
  }).catch(function (error) {
3403
- _this23.logError('recalculate summary after addOrderPayment failed', {
3333
+ _this20.logError('recalculate summary after addOrderPayment failed', {
3404
3334
  error: error instanceof Error ? error.message : String(error)
3405
3335
  });
3406
3336
  });
@@ -3408,80 +3338,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3408
3338
  }
3409
3339
 
3410
3340
  /**
3411
- * 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
3412
- * metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
3341
+ * 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
3342
+ *
3343
+ * 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
3344
+ * 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
3413
3345
  */
3414
3346
  }, {
3415
3347
  key: "updateOrderPayment",
3416
- value: (function () {
3417
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
3418
- var options,
3419
- tempOrder,
3420
- identity,
3421
- matchMode,
3422
- matchedPayment,
3423
- updatedPayment,
3424
- summary,
3425
- payments,
3426
- _args18 = arguments;
3427
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3428
- while (1) switch (_context18.prev = _context18.next) {
3429
- case 0:
3430
- options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
3431
- tempOrder = this.ensureTempOrder();
3432
- identity = String(paymentIdentity);
3433
- matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3434
- matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
3435
- if (matchedPayment) {
3436
- _context18.next = 7;
3437
- break;
3438
- }
3439
- throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
3440
- case 7:
3441
- updatedPayment = null;
3442
- tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
3443
- if (index !== matchedPayment.index) return payment;
3444
- var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
3445
- updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
3446
- }));
3447
- updatedPayment = nextPayment;
3448
- return nextPayment;
3449
- });
3450
- this.persistTempOrder();
3451
- _context18.next = 12;
3452
- return this.recalculateSummary({
3453
- createIfMissing: true
3454
- });
3455
- case 12:
3456
- summary = _context18.sent;
3457
- this.persistTempOrder();
3458
- payments = tempOrder.payments;
3459
- return _context18.abrupt("return", {
3460
- updated: true,
3461
- payment: payments[matchedPayment.index] || updatedPayment,
3462
- payments: payments,
3463
- summary: summary
3464
- });
3465
- case 16:
3466
- case "end":
3467
- return _context18.stop();
3468
- }
3469
- }, _callee16, this);
3470
- }));
3471
- function updateOrderPayment(_x15, _x16) {
3472
- return _updateOrderPayment.apply(this, arguments);
3473
- }
3474
- return updateOrderPayment;
3475
- }() /** 从当前订单支付项中移除指定支付项。 */)
3348
+ value: function updateOrderPayment(paymentIdentity, updates) {
3349
+ var tempOrder = this.ensureTempOrder();
3350
+ var identity = String(paymentIdentity);
3351
+ tempOrder.payments = (tempOrder.payments || []).map(function (payment) {
3352
+ var _payment$metadata;
3353
+ var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
3354
+ var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3355
+ var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3356
+ var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3357
+ var matched = [uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3358
+ return value !== undefined && String(value) === identity;
3359
+ });
3360
+ if (!matched) return payment;
3361
+ return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
3362
+ metadata: _objectSpread(_objectSpread({}, payment.metadata || {}), updates.metadata || {})
3363
+ });
3364
+ });
3365
+ this.persistTempOrder();
3366
+ return tempOrder.payments;
3367
+ }
3368
+
3369
+ /** 从当前订单支付项中移除指定支付项。 */
3476
3370
  }, {
3477
3371
  key: "deleteOrderPayment",
3478
3372
  value: function deleteOrderPayment(paymentIdentity) {
3479
3373
  var tempOrder = this.ensureTempOrder();
3480
3374
  var identity = String(paymentIdentity);
3481
- var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
3482
- if (!matchedPayment) return tempOrder.payments;
3483
- tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
3484
- return index !== matchedPayment.index;
3375
+ tempOrder.payments = (tempOrder.payments || []).filter(function (payment) {
3376
+ var _payment$metadata2;
3377
+ var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.unique_payment_number;
3378
+ var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3379
+ var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3380
+ var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3381
+ return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3382
+ return value !== undefined && String(value) === identity;
3383
+ });
3485
3384
  });
3486
3385
  this.persistTempOrder();
3487
3386
  return tempOrder.payments;
@@ -3513,7 +3412,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3513
3412
  }, {
3514
3413
  key: "applyPaymentLifecycleChange",
3515
3414
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3516
- var _this24 = this;
3415
+ var _this21 = this;
3517
3416
  this.updateTempOrderPaymentStatus(tempOrder);
3518
3417
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3519
3418
  this.persistTempOrder();
@@ -3523,7 +3422,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3523
3422
  void this.recalculateSummary({
3524
3423
  createIfMissing: true
3525
3424
  }).catch(function (error) {
3526
- _this24.logError("recalculate summary after ".concat(logContext, " failed"), {
3425
+ _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3527
3426
  error: error instanceof Error ? error.message : String(error)
3528
3427
  });
3529
3428
  });
@@ -3567,7 +3466,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3567
3466
  }, {
3568
3467
  key: "updateVoucherOrderPayments",
3569
3468
  value: function updateVoucherOrderPayments(payments, options) {
3570
- var _this25 = this;
3469
+ var _this22 = this;
3571
3470
  var tempOrder = this.ensureTempOrder();
3572
3471
  var isOrderPaymentType = function isOrderPaymentType(value) {
3573
3472
  return value === 'normal' || value === 'deposit';
@@ -3602,9 +3501,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3602
3501
  });
3603
3502
  };
3604
3503
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3605
- return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3606
- defaultPaid: false,
3607
- devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
3504
+ return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3505
+ defaultPaid: false
3608
3506
  });
3609
3507
  })).filter(function (payment) {
3610
3508
  return isVoucherPaymentRecord(payment);
@@ -3652,93 +3550,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3652
3550
  void this.recalculateSummary({
3653
3551
  createIfMissing: true
3654
3552
  }).catch(function (error) {
3655
- _this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
3553
+ _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3656
3554
  error: error instanceof Error ? error.message : String(error)
3657
3555
  });
3658
3556
  });
3659
3557
  return tempOrder.payments;
3660
3558
  }
3661
- }, {
3662
- key: "updateVoucherOrderPaymentsAsync",
3663
- value: function () {
3664
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
3665
- var needsPaymentNumber, devicePrefix;
3666
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3667
- while (1) switch (_context19.prev = _context19.next) {
3668
- case 0:
3669
- needsPaymentNumber = (payments || []).some(function (payment) {
3670
- return String(payment.payment_number || '').trim() === '';
3671
- });
3672
- if (!needsPaymentNumber) {
3673
- _context19.next = 7;
3674
- break;
3675
- }
3676
- _context19.next = 4;
3677
- return this.getPaymentNumberDevicePrefixAsync();
3678
- case 4:
3679
- _context19.t0 = _context19.sent;
3680
- _context19.next = 8;
3681
- break;
3682
- case 7:
3683
- _context19.t0 = 'LOCAL';
3684
- case 8:
3685
- devicePrefix = _context19.t0;
3686
- return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
3687
- devicePrefix: devicePrefix
3688
- })));
3689
- case 10:
3690
- case "end":
3691
- return _context19.stop();
3692
- }
3693
- }, _callee17, this);
3694
- }));
3695
- function updateVoucherOrderPaymentsAsync(_x17, _x18) {
3696
- return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3697
- }
3698
- return updateVoucherOrderPaymentsAsync;
3699
- }()
3700
3559
  }, {
3701
3560
  key: "shouldMergeProductToOrder",
3702
3561
  value: function () {
3703
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
3562
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3704
3563
  var _this$orderHooks;
3705
3564
  var onBeforeMergeProductToOrder, result;
3706
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3707
- while (1) switch (_context20.prev = _context20.next) {
3565
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3566
+ while (1) switch (_context17.prev = _context17.next) {
3708
3567
  case 0:
3709
3568
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3710
3569
  if (onBeforeMergeProductToOrder) {
3711
- _context20.next = 3;
3570
+ _context17.next = 3;
3712
3571
  break;
3713
3572
  }
3714
- return _context20.abrupt("return", true);
3573
+ return _context17.abrupt("return", true);
3715
3574
  case 3:
3716
- _context20.next = 5;
3575
+ _context17.next = 5;
3717
3576
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3718
3577
  defaultShouldMerge: true
3719
3578
  }));
3720
3579
  case 5:
3721
- result = _context20.sent;
3580
+ result = _context17.sent;
3722
3581
  if (!(typeof result === 'boolean')) {
3723
- _context20.next = 8;
3582
+ _context17.next = 8;
3724
3583
  break;
3725
3584
  }
3726
- return _context20.abrupt("return", result);
3585
+ return _context17.abrupt("return", result);
3727
3586
  case 8:
3728
3587
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3729
- _context20.next = 10;
3588
+ _context17.next = 10;
3730
3589
  break;
3731
3590
  }
3732
- return _context20.abrupt("return", result.shouldMerge);
3591
+ return _context17.abrupt("return", result.shouldMerge);
3733
3592
  case 10:
3734
- return _context20.abrupt("return", true);
3593
+ return _context17.abrupt("return", true);
3735
3594
  case 11:
3736
3595
  case "end":
3737
- return _context20.stop();
3596
+ return _context17.stop();
3738
3597
  }
3739
- }, _callee18, this);
3598
+ }, _callee15, this);
3740
3599
  }));
3741
- function shouldMergeProductToOrder(_x19) {
3600
+ function shouldMergeProductToOrder(_x14) {
3742
3601
  return _shouldMergeProductToOrder.apply(this, arguments);
3743
3602
  }
3744
3603
  return shouldMergeProductToOrder;
@@ -3774,30 +3633,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3774
3633
  }, {
3775
3634
  key: "finalizeProductOrderMutation",
3776
3635
  value: function () {
3777
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
3778
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3779
- while (1) switch (_context21.prev = _context21.next) {
3636
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3637
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3638
+ while (1) switch (_context18.prev = _context18.next) {
3780
3639
  case 0:
3781
3640
  this.syncTempOrderHolderFromBookings(tempOrder);
3782
3641
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3783
- _context21.next = 4;
3642
+ _context18.next = 4;
3784
3643
  break;
3785
3644
  }
3786
- _context21.next = 4;
3645
+ _context18.next = 4;
3787
3646
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3788
3647
  case 4:
3789
3648
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3790
- _context21.next = 7;
3649
+ _context18.next = 7;
3791
3650
  break;
3792
3651
  }
3793
- _context21.next = 7;
3652
+ _context18.next = 7;
3794
3653
  return this.applyPromotion();
3795
3654
  case 7:
3796
3655
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3797
3656
  this.applyDiscount();
3798
3657
  }
3799
3658
  this.sanitizeTempOrderProducts(tempOrder);
3800
- _context21.next = 11;
3659
+ _context18.next = 11;
3801
3660
  return this.recalculateSummary({
3802
3661
  createIfMissing: true
3803
3662
  });
@@ -3805,11 +3664,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3805
3664
  this.persistTempOrder();
3806
3665
  case 12:
3807
3666
  case "end":
3808
- return _context21.stop();
3667
+ return _context18.stop();
3809
3668
  }
3810
- }, _callee19, this);
3669
+ }, _callee16, this);
3811
3670
  }));
3812
- function finalizeProductOrderMutation(_x20, _x21) {
3671
+ function finalizeProductOrderMutation(_x15, _x16) {
3813
3672
  return _finalizeProductOrderMutation.apply(this, arguments);
3814
3673
  }
3815
3674
  return finalizeProductOrderMutation;
@@ -3824,13 +3683,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3824
3683
  }, {
3825
3684
  key: "appendProductLineToTempOrder",
3826
3685
  value: (function () {
3827
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
3686
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3828
3687
  var _booking_uid,
3829
3688
  _metadata,
3830
- _this26 = this;
3689
+ _this23 = this;
3831
3690
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3832
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3833
- while (1) switch (_context22.prev = _context22.next) {
3691
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3692
+ while (1) switch (_context19.prev = _context19.next) {
3834
3693
  case 0:
3835
3694
  linked = booking ? this.createLinkedProductAndBooking({
3836
3695
  product: product,
@@ -3853,8 +3712,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3853
3712
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3854
3713
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3855
3714
  var _item$metadata3;
3856
- if (_this26.hasGoodPassDiscount(item)) return false;
3857
- if (_this26.hasOrderProductLineNote(item)) return false;
3715
+ if (_this23.hasGoodPassDiscount(item)) return false;
3716
+ if (_this23.hasOrderProductLineNote(item)) return false;
3858
3717
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3859
3718
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3860
3719
  if (item.product_id !== productToAdd.product_id) return false;
@@ -3865,10 +3724,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3865
3724
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3866
3725
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3867
3726
  if (!matchedProduct) {
3868
- _context22.next = 20;
3727
+ _context19.next = 20;
3869
3728
  break;
3870
3729
  }
3871
- _context22.next = 17;
3730
+ _context19.next = 17;
3872
3731
  return this.shouldMergeProductToOrder({
3873
3732
  incomingProduct: productToAdd,
3874
3733
  normalizedIncoming: normalizedIncoming,
@@ -3880,13 +3739,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3880
3739
  booking: booking
3881
3740
  });
3882
3741
  case 17:
3883
- _context22.t0 = _context22.sent;
3884
- _context22.next = 21;
3742
+ _context19.t0 = _context19.sent;
3743
+ _context19.next = 21;
3885
3744
  break;
3886
3745
  case 20:
3887
- _context22.t0 = false;
3746
+ _context19.t0 = false;
3888
3747
  case 21:
3889
- shouldMerge = _context22.t0;
3748
+ shouldMerge = _context19.t0;
3890
3749
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3891
3750
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3892
3751
  if (linked) {
@@ -3940,11 +3799,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3940
3799
  }
3941
3800
  case 24:
3942
3801
  case "end":
3943
- return _context22.stop();
3802
+ return _context19.stop();
3944
3803
  }
3945
- }, _callee20, this);
3804
+ }, _callee17, this);
3946
3805
  }));
3947
- function appendProductLineToTempOrder(_x22, _x23, _x24) {
3806
+ function appendProductLineToTempOrder(_x17, _x18, _x19) {
3948
3807
  return _appendProductLineToTempOrder.apply(this, arguments);
3949
3808
  }
3950
3809
  return appendProductLineToTempOrder;
@@ -3960,61 +3819,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3960
3819
  }, {
3961
3820
  key: "addProductToOrder",
3962
3821
  value: (function () {
3963
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
3822
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3964
3823
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3965
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3966
- while (1) switch (_context23.prev = _context23.next) {
3824
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3825
+ while (1) switch (_context20.prev = _context20.next) {
3967
3826
  case 0:
3968
3827
  tempOrder = this.ensureTempOrder();
3969
3828
  if (!booking) {
3970
- _context23.next = 18;
3829
+ _context20.next = 18;
3971
3830
  break;
3972
3831
  }
3973
3832
  productRecord = product;
3974
3833
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3975
3834
  if (!(splitCount > 1)) {
3976
- _context23.next = 18;
3835
+ _context20.next = 18;
3977
3836
  break;
3978
3837
  }
3979
3838
  i = 0;
3980
3839
  case 6:
3981
3840
  if (!(i < splitCount)) {
3982
- _context23.next = 15;
3841
+ _context20.next = 15;
3983
3842
  break;
3984
3843
  }
3985
3844
  singleLine = cloneDeep(productRecord);
3986
3845
  singleLine.num = 1;
3987
3846
  delete singleLine.product_quantity;
3988
- _context23.next = 12;
3847
+ _context20.next = 12;
3989
3848
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3990
3849
  case 12:
3991
3850
  i += 1;
3992
- _context23.next = 6;
3851
+ _context20.next = 6;
3993
3852
  break;
3994
3853
  case 15:
3995
- _context23.next = 17;
3854
+ _context20.next = 17;
3996
3855
  return this.finalizeProductOrderMutation(tempOrder);
3997
3856
  case 17:
3998
- return _context23.abrupt("return", tempOrder.products);
3857
+ return _context20.abrupt("return", tempOrder.products);
3999
3858
  case 18:
4000
- _context23.next = 20;
3859
+ _context20.next = 20;
4001
3860
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
4002
3861
  case 20:
4003
- _context23.next = 22;
3862
+ _context20.next = 22;
4004
3863
  return this.finalizeProductOrderMutation(tempOrder);
4005
3864
  case 22:
4006
3865
  this.logInfo('addProductToOrder success', {
4007
3866
  product_id: product.product_id,
4008
3867
  with_booking: !!booking
4009
3868
  });
4010
- return _context23.abrupt("return", tempOrder.products);
3869
+ return _context20.abrupt("return", tempOrder.products);
4011
3870
  case 24:
4012
3871
  case "end":
4013
- return _context23.stop();
3872
+ return _context20.stop();
4014
3873
  }
4015
- }, _callee21, this);
3874
+ }, _callee18, this);
4016
3875
  }));
4017
- function addProductToOrder(_x25, _x26) {
3876
+ function addProductToOrder(_x20, _x21) {
4018
3877
  return _addProductToOrder.apply(this, arguments);
4019
3878
  }
4020
3879
  return addProductToOrder;
@@ -4032,93 +3891,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4032
3891
  }, {
4033
3892
  key: "addProductsToOrder",
4034
3893
  value: (function () {
4035
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
3894
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
4036
3895
  var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
4037
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4038
- while (1) switch (_context24.prev = _context24.next) {
3896
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3897
+ while (1) switch (_context21.prev = _context21.next) {
4039
3898
  case 0:
4040
3899
  tempOrder = this.ensureTempOrder();
4041
3900
  if (!(!Array.isArray(items) || items.length === 0)) {
4042
- _context24.next = 3;
3901
+ _context21.next = 3;
4043
3902
  break;
4044
3903
  }
4045
- return _context24.abrupt("return", tempOrder.products);
3904
+ return _context21.abrupt("return", tempOrder.products);
4046
3905
  case 3:
4047
3906
  _iterator20 = _createForOfIteratorHelper(items || []);
4048
- _context24.prev = 4;
3907
+ _context21.prev = 4;
4049
3908
  _iterator20.s();
4050
3909
  case 6:
4051
3910
  if ((_step20 = _iterator20.n()).done) {
4052
- _context24.next = 30;
3911
+ _context21.next = 30;
4053
3912
  break;
4054
3913
  }
4055
3914
  item = _step20.value;
4056
3915
  product = item.product, booking = item.booking;
4057
3916
  if (product) {
4058
- _context24.next = 11;
3917
+ _context21.next = 11;
4059
3918
  break;
4060
3919
  }
4061
- return _context24.abrupt("continue", 28);
3920
+ return _context21.abrupt("continue", 28);
4062
3921
  case 11:
4063
3922
  if (!booking) {
4064
- _context24.next = 26;
3923
+ _context21.next = 26;
4065
3924
  break;
4066
3925
  }
4067
3926
  productRecord = product;
4068
3927
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
4069
3928
  if (!(splitCount > 1)) {
4070
- _context24.next = 26;
3929
+ _context21.next = 26;
4071
3930
  break;
4072
3931
  }
4073
3932
  i = 0;
4074
3933
  case 16:
4075
3934
  if (!(i < splitCount)) {
4076
- _context24.next = 25;
3935
+ _context21.next = 25;
4077
3936
  break;
4078
3937
  }
4079
3938
  singleLine = cloneDeep(productRecord);
4080
3939
  singleLine.num = 1;
4081
3940
  delete singleLine.product_quantity;
4082
- _context24.next = 22;
3941
+ _context21.next = 22;
4083
3942
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4084
3943
  case 22:
4085
3944
  i += 1;
4086
- _context24.next = 16;
3945
+ _context21.next = 16;
4087
3946
  break;
4088
3947
  case 25:
4089
- return _context24.abrupt("continue", 28);
3948
+ return _context21.abrupt("continue", 28);
4090
3949
  case 26:
4091
- _context24.next = 28;
3950
+ _context21.next = 28;
4092
3951
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
4093
3952
  case 28:
4094
- _context24.next = 6;
3953
+ _context21.next = 6;
4095
3954
  break;
4096
3955
  case 30:
4097
- _context24.next = 35;
3956
+ _context21.next = 35;
4098
3957
  break;
4099
3958
  case 32:
4100
- _context24.prev = 32;
4101
- _context24.t0 = _context24["catch"](4);
4102
- _iterator20.e(_context24.t0);
3959
+ _context21.prev = 32;
3960
+ _context21.t0 = _context21["catch"](4);
3961
+ _iterator20.e(_context21.t0);
4103
3962
  case 35:
4104
- _context24.prev = 35;
3963
+ _context21.prev = 35;
4105
3964
  _iterator20.f();
4106
- return _context24.finish(35);
3965
+ return _context21.finish(35);
4107
3966
  case 38:
4108
- _context24.next = 40;
3967
+ _context21.next = 40;
4109
3968
  return this.finalizeProductOrderMutation(tempOrder, options);
4110
3969
  case 40:
4111
3970
  this.logInfo('addProductsToOrder success', {
4112
3971
  itemsCount: items.length
4113
3972
  });
4114
- return _context24.abrupt("return", tempOrder.products);
3973
+ return _context21.abrupt("return", tempOrder.products);
4115
3974
  case 42:
4116
3975
  case "end":
4117
- return _context24.stop();
3976
+ return _context21.stop();
4118
3977
  }
4119
- }, _callee22, this, [[4, 32, 35, 38]]);
3978
+ }, _callee19, this, [[4, 32, 35, 38]]);
4120
3979
  }));
4121
- function addProductsToOrder(_x27, _x28) {
3980
+ function addProductsToOrder(_x22, _x23) {
4122
3981
  return _addProductsToOrder.apply(this, arguments);
4123
3982
  }
4124
3983
  return addProductsToOrder;
@@ -4152,17 +4011,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4152
4011
  }, {
4153
4012
  key: "preservePersistedBundlePriceFields",
4154
4013
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4155
- var _this27 = this;
4014
+ var _this24 = this;
4156
4015
  if (!Array.isArray(nextBundles)) return nextBundles;
4157
4016
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4158
4017
  var previousByIdentity = new Map();
4159
4018
  previousBundles.forEach(function (bundle) {
4160
- var identity = _this27.getBundleRuntimeIdentity(bundle);
4019
+ var identity = _this24.getBundleRuntimeIdentity(bundle);
4161
4020
  if (identity) previousByIdentity.set(identity, bundle);
4162
4021
  });
4163
4022
  return nextBundles.map(function (bundle, index) {
4164
4023
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4165
- var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4024
+ var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4166
4025
  if (!previous || _typeof(previous) !== 'object') return bundle;
4167
4026
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4168
4027
  cover: previous.cover
@@ -4363,21 +4222,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4363
4222
  }, {
4364
4223
  key: "updateOrderProduct",
4365
4224
  value: function () {
4366
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4225
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4367
4226
  var tempOrder, updatedProductUid;
4368
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4369
- while (1) switch (_context25.prev = _context25.next) {
4227
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4228
+ while (1) switch (_context22.prev = _context22.next) {
4370
4229
  case 0:
4371
4230
  tempOrder = this.ensureTempOrder();
4372
4231
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4373
- _context25.next = 4;
4232
+ _context22.next = 4;
4374
4233
  return this.applyPromotion();
4375
4234
  case 4:
4376
4235
  this.applyDiscount({
4377
4236
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4378
4237
  });
4379
4238
  this.sanitizeTempOrderProducts(tempOrder);
4380
- _context25.next = 8;
4239
+ _context22.next = 8;
4381
4240
  return this.recalculateSummary({
4382
4241
  createIfMissing: true
4383
4242
  });
@@ -4386,14 +4245,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4386
4245
  this.logInfo('updateOrderProduct success', {
4387
4246
  params: params
4388
4247
  });
4389
- return _context25.abrupt("return", tempOrder.products);
4248
+ return _context22.abrupt("return", tempOrder.products);
4390
4249
  case 11:
4391
4250
  case "end":
4392
- return _context25.stop();
4251
+ return _context22.stop();
4393
4252
  }
4394
- }, _callee23, this);
4253
+ }, _callee20, this);
4395
4254
  }));
4396
- function updateOrderProduct(_x29) {
4255
+ function updateOrderProduct(_x24) {
4397
4256
  return _updateOrderProduct.apply(this, arguments);
4398
4257
  }
4399
4258
  return updateOrderProduct;
@@ -4401,28 +4260,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4401
4260
  }, {
4402
4261
  key: "updateOrderProducts",
4403
4262
  value: function () {
4404
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
4405
- var _this28 = this;
4263
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4264
+ var _this25 = this;
4406
4265
  var tempOrder, reapplyBookingDiscountProductUids;
4407
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4408
- while (1) switch (_context26.prev = _context26.next) {
4266
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4267
+ while (1) switch (_context23.prev = _context23.next) {
4409
4268
  case 0:
4410
4269
  tempOrder = this.ensureTempOrder();
4411
4270
  if (paramsList.length) {
4412
- _context26.next = 3;
4271
+ _context23.next = 3;
4413
4272
  break;
4414
4273
  }
4415
- return _context26.abrupt("return", tempOrder.products);
4274
+ return _context23.abrupt("return", tempOrder.products);
4416
4275
  case 3:
4417
4276
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4418
- var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
4277
+ var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4419
4278
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4420
4279
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4421
4280
  acc.push(String(updatedProductUid));
4422
4281
  }
4423
4282
  return acc;
4424
4283
  }, []);
4425
- _context26.next = 6;
4284
+ _context23.next = 6;
4426
4285
  return this.finalizeAfterProductsMutation(tempOrder, {
4427
4286
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4428
4287
  });
@@ -4430,14 +4289,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4430
4289
  this.logInfo('updateOrderProduct success', {
4431
4290
  paramsList: paramsList
4432
4291
  });
4433
- return _context26.abrupt("return", tempOrder.products);
4292
+ return _context23.abrupt("return", tempOrder.products);
4434
4293
  case 8:
4435
4294
  case "end":
4436
- return _context26.stop();
4295
+ return _context23.stop();
4437
4296
  }
4438
- }, _callee24, this);
4297
+ }, _callee21, this);
4439
4298
  }));
4440
- function updateOrderProducts(_x30) {
4299
+ function updateOrderProducts(_x25) {
4441
4300
  return _updateOrderProducts.apply(this, arguments);
4442
4301
  }
4443
4302
  return updateOrderProducts;
@@ -4445,11 +4304,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4445
4304
  }, {
4446
4305
  key: "updateOrderProductQuantity",
4447
4306
  value: function () {
4448
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4307
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4449
4308
  var _targetProduct$metada17;
4450
4309
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4451
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
4452
- while (1) switch (_context27.prev = _context27.next) {
4310
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4311
+ while (1) switch (_context24.prev = _context24.next) {
4453
4312
  case 0:
4454
4313
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4455
4314
  tempOrder = this.ensureTempOrder();
@@ -4478,7 +4337,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4478
4337
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4479
4338
  }
4480
4339
  if (!(productIndex === -1)) {
4481
- _context27.next = 12;
4340
+ _context24.next = 12;
4482
4341
  break;
4483
4342
  }
4484
4343
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4492,12 +4351,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4492
4351
  }));
4493
4352
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4494
4353
  tempOrder.products[productIndex] = normalizedProduct;
4495
- _context27.next = 18;
4354
+ _context24.next = 18;
4496
4355
  return this.applyPromotion();
4497
4356
  case 18:
4498
4357
  this.applyDiscount();
4499
4358
  this.sanitizeTempOrderProducts(tempOrder);
4500
- _context27.next = 22;
4359
+ _context24.next = 22;
4501
4360
  return this.recalculateSummary({
4502
4361
  createIfMissing: true
4503
4362
  });
@@ -4506,14 +4365,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4506
4365
  this.logInfo('updateOrderProductQuantity success', {
4507
4366
  params: params
4508
4367
  });
4509
- return _context27.abrupt("return", tempOrder.products);
4368
+ return _context24.abrupt("return", tempOrder.products);
4510
4369
  case 25:
4511
4370
  case "end":
4512
- return _context27.stop();
4371
+ return _context24.stop();
4513
4372
  }
4514
- }, _callee25, this);
4373
+ }, _callee22, this);
4515
4374
  }));
4516
- function updateOrderProductQuantity(_x31) {
4375
+ function updateOrderProductQuantity(_x26) {
4517
4376
  return _updateOrderProductQuantity.apply(this, arguments);
4518
4377
  }
4519
4378
  return updateOrderProductQuantity;
@@ -4554,19 +4413,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4554
4413
  }, {
4555
4414
  key: "finalizeAfterProductsMutation",
4556
4415
  value: (function () {
4557
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
4558
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4559
- while (1) switch (_context28.prev = _context28.next) {
4416
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4417
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4418
+ while (1) switch (_context25.prev = _context25.next) {
4560
4419
  case 0:
4561
4420
  this.syncTempOrderHolderFromBookings(tempOrder);
4562
- _context28.next = 3;
4421
+ _context25.next = 3;
4563
4422
  return this.applyPromotion();
4564
4423
  case 3:
4565
4424
  this.applyDiscount({
4566
4425
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4567
4426
  });
4568
4427
  this.sanitizeTempOrderProducts(tempOrder);
4569
- _context28.next = 7;
4428
+ _context25.next = 7;
4570
4429
  return this.recalculateSummary({
4571
4430
  createIfMissing: true
4572
4431
  });
@@ -4574,11 +4433,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4574
4433
  this.persistTempOrder();
4575
4434
  case 8:
4576
4435
  case "end":
4577
- return _context28.stop();
4436
+ return _context25.stop();
4578
4437
  }
4579
- }, _callee26, this);
4438
+ }, _callee23, this);
4580
4439
  }));
4581
- function finalizeAfterProductsMutation(_x32, _x33) {
4440
+ function finalizeAfterProductsMutation(_x27, _x28) {
4582
4441
  return _finalizeAfterProductsMutation.apply(this, arguments);
4583
4442
  }
4584
4443
  return finalizeAfterProductsMutation;
@@ -4593,18 +4452,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4593
4452
  }, {
4594
4453
  key: "removeProductsFromOrder",
4595
4454
  value: (function () {
4596
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
4597
- var _this29 = this;
4455
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4456
+ var _this26 = this;
4598
4457
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4599
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4600
- while (1) switch (_context30.prev = _context30.next) {
4458
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4459
+ while (1) switch (_context27.prev = _context27.next) {
4601
4460
  case 0:
4602
4461
  tempOrder = this.ensureTempOrder();
4603
4462
  if (identities.length) {
4604
- _context30.next = 3;
4463
+ _context27.next = 3;
4605
4464
  break;
4606
4465
  }
4607
- return _context30.abrupt("return", tempOrder.products);
4466
+ return _context27.abrupt("return", tempOrder.products);
4608
4467
  case 3:
4609
4468
  productsBeforeRemove = tempOrder.products || [];
4610
4469
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4627,29 +4486,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4627
4486
  }
4628
4487
  linkedBookingUidsToRemove = new Set();
4629
4488
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4630
- _context30.prev = 11;
4489
+ _context27.prev = 11;
4631
4490
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4632
4491
  var _metadata11, _metadata12, _metadata13, _metadata14;
4633
4492
  var product, productUid, productBookingUid, isAddTimeProduct;
4634
- return _regeneratorRuntime().wrap(function _loop3$(_context29) {
4635
- while (1) switch (_context29.prev = _context29.next) {
4493
+ return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4494
+ while (1) switch (_context26.prev = _context26.next) {
4636
4495
  case 0:
4637
4496
  product = _step21.value;
4638
4497
  productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4639
4498
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
4640
4499
  isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
4641
4500
  if (!isAddTimeProduct) {
4642
- _context29.next = 6;
4501
+ _context26.next = 6;
4643
4502
  break;
4644
4503
  }
4645
- return _context29.abrupt("return", 1);
4504
+ return _context26.abrupt("return", 1);
4646
4505
  case 6:
4647
4506
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4648
4507
  linkedBookingUidsToRemove.add(String(productBookingUid));
4649
4508
  }
4650
4509
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4651
4510
  bookingsBeforeRemove.forEach(function (booking) {
4652
- var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
4511
+ var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4653
4512
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4654
4513
  linkedBookingUidsToRemove.add(bookingUid);
4655
4514
  }
@@ -4657,37 +4516,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4657
4516
  }
4658
4517
  case 8:
4659
4518
  case "end":
4660
- return _context29.stop();
4519
+ return _context26.stop();
4661
4520
  }
4662
4521
  }, _loop3);
4663
4522
  });
4664
4523
  _iterator21.s();
4665
4524
  case 14:
4666
4525
  if ((_step21 = _iterator21.n()).done) {
4667
- _context30.next = 20;
4526
+ _context27.next = 20;
4668
4527
  break;
4669
4528
  }
4670
- return _context30.delegateYield(_loop3(), "t0", 16);
4529
+ return _context27.delegateYield(_loop3(), "t0", 16);
4671
4530
  case 16:
4672
- if (!_context30.t0) {
4673
- _context30.next = 18;
4531
+ if (!_context27.t0) {
4532
+ _context27.next = 18;
4674
4533
  break;
4675
4534
  }
4676
- return _context30.abrupt("continue", 18);
4535
+ return _context27.abrupt("continue", 18);
4677
4536
  case 18:
4678
- _context30.next = 14;
4537
+ _context27.next = 14;
4679
4538
  break;
4680
4539
  case 20:
4681
- _context30.next = 25;
4540
+ _context27.next = 25;
4682
4541
  break;
4683
4542
  case 22:
4684
- _context30.prev = 22;
4685
- _context30.t1 = _context30["catch"](11);
4686
- _iterator21.e(_context30.t1);
4543
+ _context27.prev = 22;
4544
+ _context27.t1 = _context27["catch"](11);
4545
+ _iterator21.e(_context27.t1);
4687
4546
  case 25:
4688
- _context30.prev = 25;
4547
+ _context27.prev = 25;
4689
4548
  _iterator21.f();
4690
- return _context30.finish(25);
4549
+ return _context27.finish(25);
4691
4550
  case 28:
4692
4551
  if (linkedBookingUidsToRemove.size > 0) {
4693
4552
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4698,20 +4557,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4698
4557
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4699
4558
  });
4700
4559
  }
4701
- _context30.next = 31;
4560
+ _context27.next = 31;
4702
4561
  return this.finalizeAfterProductsMutation(tempOrder);
4703
4562
  case 31:
4704
4563
  this.logInfo('removeProductsFromOrder success', {
4705
4564
  identities: identities
4706
4565
  });
4707
- return _context30.abrupt("return", tempOrder.products);
4566
+ return _context27.abrupt("return", tempOrder.products);
4708
4567
  case 33:
4709
4568
  case "end":
4710
- return _context30.stop();
4569
+ return _context27.stop();
4711
4570
  }
4712
- }, _callee27, this, [[11, 22, 25, 28]]);
4571
+ }, _callee24, this, [[11, 22, 25, 28]]);
4713
4572
  }));
4714
- function removeProductsFromOrder(_x34) {
4573
+ function removeProductsFromOrder(_x29) {
4715
4574
  return _removeProductsFromOrder.apply(this, arguments);
4716
4575
  }
4717
4576
  return removeProductsFromOrder;
@@ -4719,18 +4578,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4719
4578
  }, {
4720
4579
  key: "removeProductFromOrder",
4721
4580
  value: function () {
4722
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
4723
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4724
- while (1) switch (_context31.prev = _context31.next) {
4581
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4582
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4583
+ while (1) switch (_context28.prev = _context28.next) {
4725
4584
  case 0:
4726
- return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
4585
+ return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4727
4586
  case 1:
4728
4587
  case "end":
4729
- return _context31.stop();
4588
+ return _context28.stop();
4730
4589
  }
4731
- }, _callee28, this);
4590
+ }, _callee25, this);
4732
4591
  }));
4733
- function removeProductFromOrder(_x35) {
4592
+ function removeProductFromOrder(_x30) {
4734
4593
  return _removeProductFromOrder.apply(this, arguments);
4735
4594
  }
4736
4595
  return removeProductFromOrder;
@@ -4742,10 +4601,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4742
4601
  }, {
4743
4602
  key: "clearOrderCartLines",
4744
4603
  value: (function () {
4745
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
4604
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4746
4605
  var tempOrder;
4747
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4748
- while (1) switch (_context32.prev = _context32.next) {
4606
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4607
+ while (1) switch (_context29.prev = _context29.next) {
4749
4608
  case 0:
4750
4609
  tempOrder = this.ensureTempOrder();
4751
4610
  tempOrder.products = [];
@@ -4756,24 +4615,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4756
4615
  productsByUid: {}
4757
4616
  });
4758
4617
  }
4759
- _context32.next = 7;
4618
+ _context29.next = 7;
4760
4619
  return this.applyPromotion();
4761
4620
  case 7:
4762
4621
  this.applyDiscount();
4763
4622
  this.sanitizeTempOrderProducts(tempOrder);
4764
- _context32.next = 11;
4623
+ _context29.next = 11;
4765
4624
  return this.recalculateSummary({
4766
4625
  createIfMissing: true
4767
4626
  });
4768
4627
  case 11:
4769
4628
  this.persistTempOrder();
4770
4629
  this.logInfo('clearOrderCartLines success', {});
4771
- return _context32.abrupt("return", tempOrder);
4630
+ return _context29.abrupt("return", tempOrder);
4772
4631
  case 14:
4773
4632
  case "end":
4774
- return _context32.stop();
4633
+ return _context29.stop();
4775
4634
  }
4776
- }, _callee29, this);
4635
+ }, _callee26, this);
4777
4636
  }));
4778
4637
  function clearOrderCartLines() {
4779
4638
  return _clearOrderCartLines.apply(this, arguments);
@@ -4811,17 +4670,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4811
4670
  }, {
4812
4671
  key: "applyLocalPrintOrderNumbers",
4813
4672
  value: function () {
4814
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
4673
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4815
4674
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4816
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4817
- while (1) switch (_context33.prev = _context33.next) {
4675
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4676
+ while (1) switch (_context30.prev = _context30.next) {
4818
4677
  case 0:
4819
4678
  tempOrder = this.ensureTempOrder();
4820
4679
  if (!(!order || _typeof(order) !== 'object')) {
4821
- _context33.next = 3;
4680
+ _context30.next = 3;
4822
4681
  break;
4823
4682
  }
4824
- return _context33.abrupt("return", tempOrder);
4683
+ return _context30.abrupt("return", tempOrder);
4825
4684
  case 3:
4826
4685
  shopOrderNumber = order.shop_order_number;
4827
4686
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4832,88 +4691,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4832
4691
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4833
4692
  }
4834
4693
  this.persistTempOrder();
4835
- _context33.next = 10;
4694
+ _context30.next = 10;
4836
4695
  return this.saveDraft();
4837
4696
  case 10:
4838
- return _context33.abrupt("return", tempOrder);
4697
+ return _context30.abrupt("return", tempOrder);
4839
4698
  case 11:
4840
4699
  case "end":
4841
- return _context33.stop();
4700
+ return _context30.stop();
4842
4701
  }
4843
- }, _callee30, this);
4702
+ }, _callee27, this);
4844
4703
  }));
4845
- function applyLocalPrintOrderNumbers(_x36) {
4704
+ function applyLocalPrintOrderNumbers(_x31) {
4846
4705
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4847
4706
  }
4848
4707
  return applyLocalPrintOrderNumbers;
4849
4708
  }()
4850
- }, {
4851
- key: "saveTempOrderAsDraft",
4852
- value: function () {
4853
- var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4854
- var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4855
- var tempOrder, latestSummary, payload;
4856
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4857
- while (1) switch (_context34.prev = _context34.next) {
4858
- case 0:
4859
- tempOrder = this.ensureTempOrder();
4860
- this.ensureExternalSaleNumber(tempOrder);
4861
- this.persistTempOrder();
4862
- _context34.next = 5;
4863
- return this.recalculateSummary({
4864
- createIfMissing: true
4865
- });
4866
- case 5:
4867
- _context34.t1 = _context34.sent;
4868
- if (_context34.t1) {
4869
- _context34.next = 8;
4870
- break;
4871
- }
4872
- _context34.t1 = this.store.summary;
4873
- case 8:
4874
- _context34.t0 = _context34.t1;
4875
- if (_context34.t0) {
4876
- _context34.next = 11;
4877
- break;
4878
- }
4879
- _context34.t0 = createEmptySummary();
4880
- case 11:
4881
- latestSummary = _context34.t0;
4882
- payload = buildSubmitPayload({
4883
- tempOrder: tempOrder,
4884
- cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
4885
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4886
- businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4887
- channel: params === null || params === void 0 ? void 0 : params.channel,
4888
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
4889
- summary: latestSummary,
4890
- enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
4891
- });
4892
- if (!payload.created_at) {
4893
- payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4894
- }
4895
- payload.need_sync = 0;
4896
- payload.is_draft_order = 1;
4897
- this.logInfo('saveTempOrderAsDraft calling sales draft', {
4898
- orderId: payload.order_id,
4899
- externalSaleNumber: payload.external_sale_number,
4900
- productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
4901
- });
4902
- return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
4903
- osServer: true,
4904
- customToast: function customToast() {}
4905
- }));
4906
- case 18:
4907
- case "end":
4908
- return _context34.stop();
4909
- }
4910
- }, _callee31, this);
4911
- }));
4912
- function saveTempOrderAsDraft(_x37) {
4913
- return _saveTempOrderAsDraft.apply(this, arguments);
4914
- }
4915
- return saveTempOrderAsDraft;
4916
- }()
4917
4709
  /**
4918
4710
  * 提交当前 Sales tempOrder。
4919
4711
  *
@@ -4923,18 +4715,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4923
4715
  }, {
4924
4716
  key: "submitTempOrder",
4925
4717
  value: (function () {
4926
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4927
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4928
- while (1) switch (_context35.prev = _context35.next) {
4718
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4719
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4720
+ while (1) switch (_context31.prev = _context31.next) {
4929
4721
  case 0:
4930
- return _context35.abrupt("return", this.runSubmitTempOrder(params));
4722
+ return _context31.abrupt("return", this.runSubmitTempOrder(params));
4931
4723
  case 1:
4932
4724
  case "end":
4933
- return _context35.stop();
4725
+ return _context31.stop();
4934
4726
  }
4935
- }, _callee32, this);
4727
+ }, _callee28, this);
4936
4728
  }));
4937
- function submitTempOrder(_x38) {
4729
+ function submitTempOrder(_x32) {
4938
4730
  return _submitTempOrder.apply(this, arguments);
4939
4731
  }
4940
4732
  return submitTempOrder;
@@ -4942,20 +4734,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4942
4734
  }, {
4943
4735
  key: "submitTempOrderAsync",
4944
4736
  value: function () {
4945
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4946
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
4947
- while (1) switch (_context36.prev = _context36.next) {
4737
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4738
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4739
+ while (1) switch (_context32.prev = _context32.next) {
4948
4740
  case 0:
4949
- return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4741
+ return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4950
4742
  syncMode: true
4951
4743
  })));
4952
4744
  case 1:
4953
4745
  case "end":
4954
- return _context36.stop();
4746
+ return _context32.stop();
4955
4747
  }
4956
- }, _callee33, this);
4748
+ }, _callee29, this);
4957
4749
  }));
4958
- function submitTempOrderAsync(_x39) {
4750
+ function submitTempOrderAsync(_x33) {
4959
4751
  return _submitTempOrderAsync.apply(this, arguments);
4960
4752
  }
4961
4753
  return submitTempOrderAsync;
@@ -4963,11 +4755,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4963
4755
  }, {
4964
4756
  key: "runSubmitTempOrder",
4965
4757
  value: function () {
4966
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4967
- var _params$cacheId3, _this$otherParams10, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4758
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4759
+ var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4968
4760
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4969
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4970
- while (1) switch (_context37.prev = _context37.next) {
4761
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4762
+ while (1) switch (_context33.prev = _context33.next) {
4971
4763
  case 0:
4972
4764
  tempOrder = this.ensureTempOrder();
4973
4765
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4987,27 +4779,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4987
4779
  }
4988
4780
  }
4989
4781
  this.persistTempOrder();
4990
- _context37.next = 8;
4782
+ _context33.next = 8;
4991
4783
  return this.recalculateSummary({
4992
4784
  createIfMissing: true
4993
4785
  });
4994
4786
  case 8:
4995
- _context37.t1 = _context37.sent;
4996
- if (_context37.t1) {
4997
- _context37.next = 11;
4787
+ _context33.t1 = _context33.sent;
4788
+ if (_context33.t1) {
4789
+ _context33.next = 11;
4998
4790
  break;
4999
4791
  }
5000
- _context37.t1 = this.store.summary;
4792
+ _context33.t1 = this.store.summary;
5001
4793
  case 11:
5002
- _context37.t0 = _context37.t1;
5003
- if (_context37.t0) {
5004
- _context37.next = 14;
4794
+ _context33.t0 = _context33.t1;
4795
+ if (_context33.t0) {
4796
+ _context33.next = 14;
5005
4797
  break;
5006
4798
  }
5007
- _context37.t0 = createEmptySummary();
4799
+ _context33.t0 = createEmptySummary();
5008
4800
  case 14:
5009
- latestSummary = _context37.t0;
5010
- effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
4801
+ latestSummary = _context33.t0;
4802
+ effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
5011
4803
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
5012
4804
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
5013
4805
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
@@ -5025,8 +4817,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5025
4817
  payload = buildSubmitPayload({
5026
4818
  tempOrder: tempOrder,
5027
4819
  cacheId: effectiveCacheId,
5028
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5029
- businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
4820
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4821
+ businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
5030
4822
  channel: params === null || params === void 0 ? void 0 : params.channel,
5031
4823
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
5032
4824
  summary: latestSummary,
@@ -5041,10 +4833,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5041
4833
  if (!payload.created_at) {
5042
4834
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5043
4835
  }
5044
- _context37.next = 26;
4836
+ _context33.next = 26;
5045
4837
  return this.saveDraft();
5046
4838
  case 26:
5047
- _context37.prev = 26;
4839
+ _context33.prev = 26;
5048
4840
  this.logInfo('submitTempOrder calling sales checkout', {
5049
4841
  orderId: payload.order_id,
5050
4842
  externalSaleNumber: payload.external_sale_number,
@@ -5054,43 +4846,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5054
4846
  smallTicketDataFlag: payload.small_ticket_data_flag,
5055
4847
  syncMode: payload.sync_mode
5056
4848
  });
5057
- _context37.next = 30;
4849
+ _context33.next = 30;
5058
4850
  return this.submitSalesOrder({
5059
4851
  query: payload
5060
4852
  });
5061
4853
  case 30:
5062
- result = _context37.sent;
5063
- _context37.next = 43;
4854
+ result = _context33.sent;
4855
+ _context33.next = 43;
5064
4856
  break;
5065
4857
  case 33:
5066
- _context37.prev = 33;
5067
- _context37.t2 = _context37["catch"](26);
5068
- backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
4858
+ _context33.prev = 33;
4859
+ _context33.t2 = _context33["catch"](26);
4860
+ backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
5069
4861
  if (!backendErrorResponse) {
5070
- _context37.next = 40;
4862
+ _context33.next = 40;
5071
4863
  break;
5072
4864
  }
5073
4865
  this.store.syncState = 'failed';
5074
4866
  this.logSubmitBackendRejected(backendErrorResponse, payload);
5075
- return _context37.abrupt("return", backendErrorResponse);
4867
+ return _context33.abrupt("return", backendErrorResponse);
5076
4868
  case 40:
5077
4869
  this.store.syncState = 'failed';
5078
4870
  this.logError('submitTempOrder failed', {
5079
- error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
4871
+ error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
5080
4872
  orderId: payload.order_id,
5081
4873
  externalSaleNumber: payload.external_sale_number,
5082
4874
  paymentStatus: payload.payment_status,
5083
4875
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
5084
4876
  });
5085
- throw _context37.t2;
4877
+ throw _context33.t2;
5086
4878
  case 43:
5087
4879
  if (!this.isSubmitResponseRejected(result)) {
5088
- _context37.next = 47;
4880
+ _context33.next = 47;
5089
4881
  break;
5090
4882
  }
5091
4883
  this.store.syncState = 'failed';
5092
4884
  this.logSubmitBackendRejected(result, payload);
5093
- return _context37.abrupt("return", result);
4885
+ return _context33.abrupt("return", result);
5094
4886
  case 47:
5095
4887
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
5096
4888
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -5101,15 +4893,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5101
4893
  })
5102
4894
  });
5103
4895
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
5104
- _context37.next = 56;
4896
+ _context33.next = 56;
5105
4897
  break;
5106
4898
  }
5107
4899
  tempOrder.order_id = submittedOrderId;
5108
4900
  resultRecord = result;
5109
- _context37.next = 54;
4901
+ _context33.next = 54;
5110
4902
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
5111
4903
  case 54:
5112
- _context37.next = 57;
4904
+ _context33.next = 57;
5113
4905
  break;
5114
4906
  case 56:
5115
4907
  if (this.isLocalPendingSubmitResult(result)) {
@@ -5118,14 +4910,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5118
4910
  this.store.syncState = 'submitted';
5119
4911
  }
5120
4912
  case 57:
5121
- return _context37.abrupt("return", result);
4913
+ return _context33.abrupt("return", result);
5122
4914
  case 58:
5123
4915
  case "end":
5124
- return _context37.stop();
4916
+ return _context33.stop();
5125
4917
  }
5126
- }, _callee34, this, [[26, 33]]);
4918
+ }, _callee30, this, [[26, 33]]);
5127
4919
  }));
5128
- function runSubmitTempOrder(_x40) {
4920
+ function runSubmitTempOrder(_x34) {
5129
4921
  return _runSubmitTempOrder.apply(this, arguments);
5130
4922
  }
5131
4923
  return runSubmitTempOrder;
@@ -5133,10 +4925,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5133
4925
  }, {
5134
4926
  key: "markLocalOrderSynced",
5135
4927
  value: function () {
5136
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
4928
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
5137
4929
  var tempOrder;
5138
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5139
- while (1) switch (_context38.prev = _context38.next) {
4930
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4931
+ while (1) switch (_context34.prev = _context34.next) {
5140
4932
  case 0:
5141
4933
  tempOrder = this.ensureTempOrder();
5142
4934
  tempOrder.order_id = orderId;
@@ -5144,15 +4936,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5144
4936
  this.store.lastOrderInfo = remoteOrder;
5145
4937
  this.store.syncState = 'submitted';
5146
4938
  this.persistTempOrder();
5147
- _context38.next = 8;
4939
+ _context34.next = 8;
5148
4940
  return this.saveDraft();
5149
4941
  case 8:
5150
4942
  case "end":
5151
- return _context38.stop();
4943
+ return _context34.stop();
5152
4944
  }
5153
- }, _callee35, this);
4945
+ }, _callee31, this);
5154
4946
  }));
5155
- function markLocalOrderSynced(_x41, _x42) {
4947
+ function markLocalOrderSynced(_x35, _x36) {
5156
4948
  return _markLocalOrderSynced.apply(this, arguments);
5157
4949
  }
5158
4950
  return markLocalOrderSynced;
@@ -5195,10 +4987,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5195
4987
  value: function extractSubmitErrorResponse(error) {
5196
4988
  var _error$response,
5197
4989
  _error$response2,
5198
- _this30 = this;
4990
+ _this27 = this;
5199
4991
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
5200
4992
  return candidates.find(function (candidate) {
5201
- return _this30.isSubmitErrorResponse(candidate);
4993
+ return _this27.isSubmitErrorResponse(candidate);
5202
4994
  }) || null;
5203
4995
  }
5204
4996
  }, {
@@ -5225,37 +5017,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5225
5017
  }, {
5226
5018
  key: "syncPaymentsToOrder",
5227
5019
  value: function () {
5228
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5229
- var _this31 = this,
5230
- _params$confirmPendin;
5231
- var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
5232
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5233
- while (1) switch (_context39.prev = _context39.next) {
5020
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5021
+ var _params$confirmPendin;
5022
+ var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitParams, submitResult;
5023
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5024
+ while (1) switch (_context35.prev = _context35.next) {
5234
5025
  case 0:
5235
5026
  tempOrder = this.ensureTempOrder();
5236
- needsPaymentNumber = (params.payments || []).some(function (payment) {
5237
- return String(payment.payment_number || '').trim() === '';
5238
- });
5239
- if (!needsPaymentNumber) {
5240
- _context39.next = 8;
5241
- break;
5242
- }
5243
- _context39.next = 5;
5244
- return this.getPaymentNumberDevicePrefixAsync();
5245
- case 5:
5246
- _context39.t0 = _context39.sent;
5247
- _context39.next = 9;
5248
- break;
5249
- case 8:
5250
- _context39.t0 = 'LOCAL';
5251
- case 9:
5252
- devicePrefix = _context39.t0;
5253
- mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5254
- return _this31.normalizePaymentSource(payment, {
5255
- defaultPaid: false,
5256
- devicePrefix: devicePrefix
5257
- });
5258
- }));
5027
+ mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
5259
5028
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
5260
5029
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
5261
5030
  completion = this.getPaymentCompletion(effectivePayments);
@@ -5264,25 +5033,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5264
5033
  tempOrder.payments = effectivePayments;
5265
5034
  tempOrder.payment_status = paymentStatus;
5266
5035
  this.persistTempOrder();
5267
- _context39.next = 21;
5036
+ _context35.next = 12;
5268
5037
  return this.saveDraft();
5269
- case 21:
5038
+ case 12:
5270
5039
  if (params.submitWhenPaid) {
5271
- _context39.next = 23;
5040
+ _context35.next = 14;
5272
5041
  break;
5273
5042
  }
5274
- return _context39.abrupt("return", completion);
5275
- case 23:
5043
+ return _context35.abrupt("return", completion);
5044
+ case 14:
5276
5045
  if (!(this.store.syncState === 'submitting')) {
5277
- _context39.next = 25;
5046
+ _context35.next = 16;
5278
5047
  break;
5279
5048
  }
5280
- return _context39.abrupt("return", completion);
5281
- case 25:
5049
+ return _context35.abrupt("return", completion);
5050
+ case 16:
5282
5051
  this.store.syncState = 'submitting';
5283
5052
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
5284
- _context39.next = 29;
5285
- return this.submitTempOrder({
5053
+ submitParams = {
5286
5054
  payments: effectivePayments,
5287
5055
  paymentStatus: paymentStatus,
5288
5056
  smallTicketDataFlag: params.smallTicketDataFlag,
@@ -5295,19 +5063,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5295
5063
  });
5296
5064
  return nextPayload;
5297
5065
  }
5298
- });
5299
- case 29:
5300
- submitResult = _context39.sent;
5301
- return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5066
+ };
5067
+ if (!(params.checkoutSyncTaskEnabled === false)) {
5068
+ _context35.next = 25;
5069
+ break;
5070
+ }
5071
+ _context35.next = 22;
5072
+ return this.submitTempOrderAsync(submitParams);
5073
+ case 22:
5074
+ _context35.t0 = _context35.sent;
5075
+ _context35.next = 28;
5076
+ break;
5077
+ case 25:
5078
+ _context35.next = 27;
5079
+ return this.submitTempOrder(submitParams);
5080
+ case 27:
5081
+ _context35.t0 = _context35.sent;
5082
+ case 28:
5083
+ submitResult = _context35.t0;
5084
+ return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5302
5085
  submitResult: submitResult
5303
5086
  }));
5304
- case 31:
5087
+ case 30:
5305
5088
  case "end":
5306
- return _context39.stop();
5089
+ return _context35.stop();
5307
5090
  }
5308
- }, _callee36, this);
5091
+ }, _callee32, this);
5309
5092
  }));
5310
- function syncPaymentsToOrder(_x43) {
5093
+ function syncPaymentsToOrder(_x37) {
5311
5094
  return _syncPaymentsToOrder.apply(this, arguments);
5312
5095
  }
5313
5096
  return syncPaymentsToOrder;
@@ -5315,6 +5098,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5315
5098
  }, {
5316
5099
  key: "createOrder",
5317
5100
  value: function createOrder(params) {
5101
+ var _this28 = this;
5318
5102
  var order = _objectSpread({
5319
5103
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
5320
5104
  // 要从外面拿,virtual
@@ -5326,11 +5110,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5326
5110
  schedule_date: '',
5327
5111
  is_deposit: 0,
5328
5112
  relation_products: [],
5329
- relation_forms: []
5113
+ relation_forms: [],
5114
+ business_code: params === null || params === void 0 ? void 0 : params.business_code
5330
5115
  }, (params === null || params === void 0 ? void 0 : params.extraData) || {});
5331
5116
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
5332
5117
  if (params.cartItems.length > 0) {
5333
5118
  params.cartItems.forEach(function (item) {
5119
+ var _params$extraData;
5334
5120
  if (!item._origin.duration) {
5335
5121
  var _generateDuration = generateDuration(item),
5336
5122
  duration = _generateDuration.duration,
@@ -5342,6 +5128,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5342
5128
  var discountList = getAllDiscountList(item);
5343
5129
  item._origin.product.discount_list = discountList;
5344
5130
 
5131
+ // 为预约补齐 holder 信息
5132
+ if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
5133
+ ensureCartItemOriginHolder(item, _this28.window);
5134
+ }
5135
+
5345
5136
  // 购物车是否为普通商品
5346
5137
  if (isNormalProduct(item._origin)) {
5347
5138
  var _order$relation_forms;
@@ -5396,11 +5187,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5396
5187
  }, {
5397
5188
  key: "submitOrder",
5398
5189
  value: function () {
5399
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
5190
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5400
5191
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5401
5192
  var url, query, fetchUrl, params;
5402
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5403
- while (1) switch (_context40.prev = _context40.next) {
5193
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5194
+ while (1) switch (_context36.prev = _context36.next) {
5404
5195
  case 0:
5405
5196
  this.logInfo('submitOrder called', {
5406
5197
  url: order.url,
@@ -5420,14 +5211,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5420
5211
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5421
5212
  scheduleDate: params.schedule_date
5422
5213
  });
5423
- return _context40.abrupt("return", this.request.post(fetchUrl, params));
5214
+ return _context36.abrupt("return", this.request.post(fetchUrl, params));
5424
5215
  case 6:
5425
5216
  case "end":
5426
- return _context40.stop();
5217
+ return _context36.stop();
5427
5218
  }
5428
- }, _callee37, this);
5219
+ }, _callee33, this);
5429
5220
  }));
5430
- function submitOrder(_x44) {
5221
+ function submitOrder(_x38) {
5431
5222
  return _submitOrder.apply(this, arguments);
5432
5223
  }
5433
5224
  return submitOrder;
@@ -5435,13 +5226,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5435
5226
  }, {
5436
5227
  key: "cancelOrder",
5437
5228
  value: function () {
5438
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5229
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5439
5230
  var payload;
5440
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5441
- while (1) switch (_context41.prev = _context41.next) {
5231
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5232
+ while (1) switch (_context37.prev = _context37.next) {
5442
5233
  case 0:
5443
5234
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5444
- _context41.next = 2;
5235
+ _context37.next = 2;
5445
5236
  break;
5446
5237
  }
5447
5238
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5457,16 +5248,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5457
5248
  method: 'PUT',
5458
5249
  orderIdsCount: params.order_ids.length
5459
5250
  });
5460
- return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
5251
+ return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5461
5252
  isShopApi: true
5462
5253
  }));
5463
5254
  case 5:
5464
5255
  case "end":
5465
- return _context41.stop();
5256
+ return _context37.stop();
5466
5257
  }
5467
- }, _callee38, this);
5258
+ }, _callee34, this);
5468
5259
  }));
5469
- function cancelOrder(_x45) {
5260
+ function cancelOrder(_x39) {
5470
5261
  return _cancelOrder.apply(this, arguments);
5471
5262
  }
5472
5263
  return cancelOrder;
@@ -5474,19 +5265,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5474
5265
  }, {
5475
5266
  key: "changeBookingStatus",
5476
5267
  value: function () {
5477
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5268
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5478
5269
  var url, payload;
5479
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5480
- while (1) switch (_context42.prev = _context42.next) {
5270
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5271
+ while (1) switch (_context38.prev = _context38.next) {
5481
5272
  case 0:
5482
5273
  if (params.booking_id) {
5483
- _context42.next = 2;
5274
+ _context38.next = 2;
5484
5275
  break;
5485
5276
  }
5486
5277
  throw new Error('变更预约状态失败:booking_id 不能为空');
5487
5278
  case 2:
5488
5279
  if (params.appointment_status) {
5489
- _context42.next = 4;
5280
+ _context38.next = 4;
5490
5281
  break;
5491
5282
  }
5492
5283
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5501,16 +5292,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5501
5292
  bookingId: params.booking_id,
5502
5293
  appointmentStatus: params.appointment_status
5503
5294
  });
5504
- return _context42.abrupt("return", this.request.put(url, payload, {
5295
+ return _context38.abrupt("return", this.request.put(url, payload, {
5505
5296
  isShopApi: true
5506
5297
  }));
5507
5298
  case 8:
5508
5299
  case "end":
5509
- return _context42.stop();
5300
+ return _context38.stop();
5510
5301
  }
5511
- }, _callee39, this);
5302
+ }, _callee35, this);
5512
5303
  }));
5513
- function changeBookingStatus(_x46) {
5304
+ function changeBookingStatus(_x40) {
5514
5305
  return _changeBookingStatus.apply(this, arguments);
5515
5306
  }
5516
5307
  return changeBookingStatus;
@@ -5528,11 +5319,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5528
5319
  }, {
5529
5320
  key: "createOrderByCheckout",
5530
5321
  value: (function () {
5531
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5322
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5532
5323
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5533
5324
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
5534
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5535
- while (1) switch (_context43.prev = _context43.next) {
5325
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5326
+ while (1) switch (_context39.prev = _context39.next) {
5536
5327
  case 0:
5537
5328
  // 过滤掉由在线店铺下单的 payment 支付数据
5538
5329
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5566,7 +5357,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5566
5357
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5567
5358
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5568
5359
  });
5569
- _context43.prev = 4;
5360
+ _context39.prev = 4;
5570
5361
  // 构建订单数据,设置默认值并允许 params 覆盖
5571
5362
  orderData = _objectSpread({
5572
5363
  sales_channel: 'my_pisel',
@@ -5628,13 +5419,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5628
5419
  hasOrderId: !!orderData.order_id,
5629
5420
  smallTicketDataFlag: orderData.small_ticket_data_flag
5630
5421
  });
5631
- _context43.next = 12;
5422
+ _context39.next = 12;
5632
5423
  return this.request.post('/order/checkout', orderData, {
5633
5424
  osServer: true,
5634
5425
  customToast: function customToast() {}
5635
5426
  });
5636
5427
  case 12:
5637
- response = _context43.sent;
5428
+ response = _context39.sent;
5638
5429
  this.logInfo('Order API called successfully', {
5639
5430
  response: response
5640
5431
  });
@@ -5642,22 +5433,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5642
5433
  success: !!response,
5643
5434
  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)
5644
5435
  });
5645
- return _context43.abrupt("return", response);
5436
+ return _context39.abrupt("return", response);
5646
5437
  case 18:
5647
- _context43.prev = 18;
5648
- _context43.t0 = _context43["catch"](4);
5649
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
5438
+ _context39.prev = 18;
5439
+ _context39.t0 = _context39["catch"](4);
5440
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5650
5441
  this.logInfo('Order API called failed', {
5651
- error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
5442
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5652
5443
  });
5653
- throw _context43.t0;
5444
+ throw _context39.t0;
5654
5445
  case 23:
5655
5446
  case "end":
5656
- return _context43.stop();
5447
+ return _context39.stop();
5657
5448
  }
5658
- }, _callee40, this, [[4, 18]]);
5449
+ }, _callee36, this, [[4, 18]]);
5659
5450
  }));
5660
- function createOrderByCheckout(_x47) {
5451
+ function createOrderByCheckout(_x41) {
5661
5452
  return _createOrderByCheckout.apply(this, arguments);
5662
5453
  }
5663
5454
  return createOrderByCheckout;
@@ -5665,24 +5456,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5665
5456
  }, {
5666
5457
  key: "submitSalesOrder",
5667
5458
  value: function () {
5668
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5459
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5669
5460
  var url, query, fetchUrl;
5670
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5671
- while (1) switch (_context44.prev = _context44.next) {
5461
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5462
+ while (1) switch (_context40.prev = _context40.next) {
5672
5463
  case 0:
5673
5464
  url = params.url, query = params.query;
5674
5465
  fetchUrl = url || '/order/sales/checkout';
5675
- return _context44.abrupt("return", this.request.post(fetchUrl, query, {
5466
+ return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5676
5467
  osServer: true,
5677
5468
  customToast: function customToast() {}
5678
5469
  }));
5679
5470
  case 3:
5680
5471
  case "end":
5681
- return _context44.stop();
5472
+ return _context40.stop();
5682
5473
  }
5683
- }, _callee41, this);
5474
+ }, _callee37, this);
5684
5475
  }));
5685
- function submitSalesOrder(_x48) {
5476
+ function submitSalesOrder(_x42) {
5686
5477
  return _submitSalesOrder.apply(this, arguments);
5687
5478
  }
5688
5479
  return submitSalesOrder;
@@ -5696,37 +5487,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5696
5487
  }, {
5697
5488
  key: "sendCustomerPayLink",
5698
5489
  value: (function () {
5699
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5490
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5700
5491
  var _params$emails;
5701
5492
  var orderIds;
5702
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
5703
- while (1) switch (_context45.prev = _context45.next) {
5493
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5494
+ while (1) switch (_context41.prev = _context41.next) {
5704
5495
  case 0:
5705
5496
  orderIds = params.order_ids || params.orderIds || [];
5706
5497
  if (orderIds.length) {
5707
- _context45.next = 3;
5498
+ _context41.next = 3;
5708
5499
  break;
5709
5500
  }
5710
5501
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5711
5502
  case 3:
5712
5503
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5713
- _context45.next = 5;
5504
+ _context41.next = 5;
5714
5505
  break;
5715
5506
  }
5716
5507
  throw new Error('发送支付链接需要至少一个邮箱');
5717
5508
  case 5:
5718
- return _context45.abrupt("return", this.request.post('/order/batch-email', {
5509
+ return _context41.abrupt("return", this.request.post('/order/batch-email', {
5719
5510
  order_ids: orderIds,
5720
5511
  notify_action: params.notify_action || 'order_payment_reminder',
5721
5512
  emails: params.emails
5722
5513
  }));
5723
5514
  case 6:
5724
5515
  case "end":
5725
- return _context45.stop();
5516
+ return _context41.stop();
5726
5517
  }
5727
- }, _callee42, this);
5518
+ }, _callee38, this);
5728
5519
  }));
5729
- function sendCustomerPayLink(_x49) {
5520
+ function sendCustomerPayLink(_x43) {
5730
5521
  return _sendCustomerPayLink.apply(this, arguments);
5731
5522
  }
5732
5523
  return sendCustomerPayLink;
@@ -5734,14 +5525,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5734
5525
  }, {
5735
5526
  key: "getSalesOrderByLookup",
5736
5527
  value: function () {
5737
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5528
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5738
5529
  var lookup, res;
5739
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
5740
- while (1) switch (_context46.prev = _context46.next) {
5530
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5531
+ while (1) switch (_context42.prev = _context42.next) {
5741
5532
  case 0:
5742
5533
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5743
5534
  if (lookup) {
5744
- _context46.next = 3;
5535
+ _context42.next = 3;
5745
5536
  break;
5746
5537
  }
5747
5538
  throw new Error('加载销售详情需要 lookup');
@@ -5750,7 +5541,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5750
5541
  if (lookup.startsWith('LOCAL_')) {
5751
5542
  params.forceRemote = false;
5752
5543
  }
5753
- _context46.next = 6;
5544
+ _context42.next = 6;
5754
5545
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5755
5546
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5756
5547
  }, params.forceRemote ? {
@@ -5759,18 +5550,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5759
5550
  osServer: true
5760
5551
  });
5761
5552
  case 6:
5762
- res = _context46.sent;
5553
+ res = _context42.sent;
5763
5554
  if (res.code === 200) {
5764
5555
  this.store.lastOrderInfo = res.data;
5765
5556
  }
5766
- return _context46.abrupt("return", res);
5557
+ return _context42.abrupt("return", res);
5767
5558
  case 9:
5768
5559
  case "end":
5769
- return _context46.stop();
5560
+ return _context42.stop();
5770
5561
  }
5771
- }, _callee43, this);
5562
+ }, _callee39, this);
5772
5563
  }));
5773
- function getSalesOrderByLookup(_x50) {
5564
+ function getSalesOrderByLookup(_x44) {
5774
5565
  return _getSalesOrderByLookup.apply(this, arguments);
5775
5566
  }
5776
5567
  return getSalesOrderByLookup;
@@ -5784,11 +5575,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5784
5575
  }, {
5785
5576
  key: "hydrateTempOrderFromRecord",
5786
5577
  value: (function () {
5787
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
5578
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5788
5579
  var _this$store$discount19;
5789
- var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5790
- return _regeneratorRuntime().wrap(function _callee44$(_context47) {
5791
- while (1) switch (_context47.prev = _context47.next) {
5580
+ var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5581
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5582
+ while (1) switch (_context43.prev = _context43.next) {
5792
5583
  case 0:
5793
5584
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5794
5585
  identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
@@ -5813,13 +5604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5813
5604
  }
5814
5605
  nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5815
5606
  makeEditMark: true
5816
- }); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
5817
- sourceLastOrderInfo = raw.lastOrderInfo || raw;
5818
- isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
5819
- syntheticIdentityOptions = {
5820
- isDraftOrder: isDraftOrder,
5821
- externalSaleNumber: nextTempOrder.external_sale_number
5822
- };
5607
+ });
5823
5608
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5824
5609
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5825
5610
  return _objectSpread({}, s || {});
@@ -5839,11 +5624,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5839
5624
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5840
5625
  }
5841
5626
  });
5842
- this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5843
- hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5844
- if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
5845
- this.store.syncState = 'local';
5846
- }
5627
+ // lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
5628
+ // Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
5629
+ // rewrite this protocol snapshot as a side effect of hydration.
5630
+ this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
5847
5631
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5848
5632
  currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5849
5633
  currentScanDiscounts = currentDiscounts.filter(function (discount) {
@@ -5858,34 +5642,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5858
5642
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5859
5643
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5860
5644
  if (shouldSkipEmptyDiscountSync) {
5861
- _context47.next = 31;
5645
+ _context43.next = 26;
5862
5646
  break;
5863
5647
  }
5864
5648
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5865
- _context47.next = 29;
5649
+ _context43.next = 24;
5866
5650
  return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5867
- case 29:
5868
- _context47.next = 31;
5651
+ case 24:
5652
+ _context43.next = 26;
5869
5653
  return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5870
- case 31:
5654
+ case 26:
5871
5655
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5872
- _context47.next = 34;
5656
+ _context43.next = 29;
5873
5657
  break;
5874
5658
  }
5875
- _context47.next = 34;
5659
+ _context43.next = 29;
5876
5660
  return this.recalculateSummary({
5877
5661
  createIfMissing: false
5878
5662
  });
5879
- case 34:
5663
+ case 29:
5880
5664
  this.persistTempOrder();
5881
- return _context47.abrupt("return", nextTempOrder);
5882
- case 36:
5665
+ return _context43.abrupt("return", nextTempOrder);
5666
+ case 31:
5883
5667
  case "end":
5884
- return _context47.stop();
5668
+ return _context43.stop();
5885
5669
  }
5886
- }, _callee44, this);
5670
+ }, _callee40, this);
5887
5671
  }));
5888
- function hydrateTempOrderFromRecord(_x51, _x52) {
5672
+ function hydrateTempOrderFromRecord(_x45, _x46) {
5889
5673
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5890
5674
  }
5891
5675
  return hydrateTempOrderFromRecord;
@@ -5999,12 +5783,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5999
5783
  }, {
6000
5784
  key: "normalizeTempOrderForRuntime",
6001
5785
  value: function normalizeTempOrderForRuntime(raw, options) {
6002
- var _this32 = this;
6003
- var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6004
- var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
5786
+ var _this29 = this;
5787
+ var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
6005
5788
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
6006
- if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== undefined && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== null) {
6007
- nextTempOrder.order_id = runtimeRaw.id;
5789
+ if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
5790
+ nextTempOrder.order_id = raw.id;
6008
5791
  }
6009
5792
  delete nextTempOrder.summary;
6010
5793
  delete nextTempOrder.lastOrderInfo;
@@ -6023,12 +5806,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6023
5806
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
6024
5807
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
6025
5808
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
6026
- return _this32.normalizeHydratedOrderProduct(p, {
5809
+ return _this29.normalizeHydratedOrderProduct(p, {
6027
5810
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
6028
5811
  });
6029
5812
  }) : [];
6030
5813
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
6031
- var booking = _this32.normalizeHydratedBookingHolder(b || {});
5814
+ var booking = _this29.normalizeHydratedBookingHolder(b || {});
6032
5815
  return _objectSpread(_objectSpread({}, booking), {}, {
6033
5816
  is_all: normalizeBookingIsAll(booking),
6034
5817
  sub_type: normalizeBookingSubType(booking)
@@ -6058,7 +5841,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6058
5841
  _step24;
6059
5842
  try {
6060
5843
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6061
- var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
5844
+ var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
6062
5845
  var _step24$value = _slicedToArray(_step24.value, 2),
6063
5846
  index = _step24$value[0],
6064
5847
  product = _step24$value[1];
@@ -6066,7 +5849,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6066
5849
  if (!uid) continue;
6067
5850
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6068
5851
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
6069
- var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
5852
+ var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
6070
5853
  var originSnapshot = cloneDeep(origin);
6071
5854
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
6072
5855
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -6094,23 +5877,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6094
5877
  nextTempOrder.vouchers = raw.vouchers || [];
6095
5878
  return nextTempOrder;
6096
5879
  }
6097
- }, {
6098
- key: "isSyntheticDraftOrderIdForRuntime",
6099
- value: function isSyntheticDraftOrderIdForRuntime(record, options) {
6100
- var _options$isDraftOrder, _record$external_sale;
6101
- var isDraftOrder = (_options$isDraftOrder = options === null || options === void 0 ? void 0 : options.isDraftOrder) !== null && _options$isDraftOrder !== void 0 ? _options$isDraftOrder : Number((record === null || record === void 0 ? void 0 : record.is_draft_order) || 0) === 1;
6102
- var externalSaleNumber = (_record$external_sale = record === null || record === void 0 ? void 0 : record.external_sale_number) !== null && _record$external_sale !== void 0 ? _record$external_sale : options === null || options === void 0 ? void 0 : options.externalSaleNumber;
6103
- var orderId = record === null || record === void 0 ? void 0 : record.order_id;
6104
- return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
6105
- }
6106
- }, {
6107
- key: "withoutSyntheticDraftOrderIdForRuntime",
6108
- value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
6109
- if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
6110
- return _objectSpread(_objectSpread({}, record), {}, {
6111
- order_id: null
6112
- });
6113
- }
6114
5880
  }, {
6115
5881
  key: "hydrateLinkedBookingIdentity",
6116
5882
  value: function hydrateLinkedBookingIdentity(tempOrder) {
@@ -6195,10 +5961,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6195
5961
  }, {
6196
5962
  key: "normalizeHydratedProductOptionItem",
6197
5963
  value: function normalizeHydratedProductOptionItem(optionItem) {
6198
- var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
6199
- var rawNum = (_ref79 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref79 !== void 0 ? _ref79 : 1;
5964
+ var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
5965
+ var rawNum = (_ref78 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1;
6200
5966
  var parsedNum = Number(rawNum);
6201
- var rawPrice = (_ref80 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref80 !== void 0 ? _ref80 : 0;
5967
+ var rawPrice = (_ref79 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref79 !== void 0 ? _ref79 : 0;
6202
5968
  var parsedPrice = Number(rawPrice);
6203
5969
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
6204
5970
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6215,7 +5981,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6215
5981
  }, {
6216
5982
  key: "normalizeHydratedOrderProduct",
6217
5983
  value: function normalizeHydratedOrderProduct(product, options) {
6218
- var _this33 = this;
5984
+ var _this30 = this;
6219
5985
  var row = _objectSpread({}, product || {});
6220
5986
  if (row.num === undefined && row.product_quantity !== undefined) {
6221
5987
  row.num = row.product_quantity;
@@ -6223,7 +5989,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6223
5989
  var productSku = ensureProductSku(row);
6224
5990
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
6225
5991
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
6226
- return _this33.normalizeHydratedProductOptionItem(optionItem || {});
5992
+ return _this30.normalizeHydratedProductOptionItem(optionItem || {});
6227
5993
  }))
6228
5994
  });
6229
5995
  delete row["product_".concat('option', "_item")];
@@ -6260,27 +6026,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6260
6026
  }, {
6261
6027
  key: "getOrderInfo",
6262
6028
  value: function () {
6263
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
6029
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
6264
6030
  var res;
6265
- return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6266
- while (1) switch (_context48.prev = _context48.next) {
6031
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6032
+ while (1) switch (_context44.prev = _context44.next) {
6267
6033
  case 0:
6268
- _context48.next = 2;
6034
+ _context44.next = 2;
6269
6035
  return this.request.get("/order/sales/".concat(order_id), {
6270
6036
  with: ['products', 'bookings']
6271
6037
  }, {
6272
6038
  osServer: true
6273
6039
  });
6274
6040
  case 2:
6275
- res = _context48.sent;
6276
- return _context48.abrupt("return", res);
6041
+ res = _context44.sent;
6042
+ return _context44.abrupt("return", res);
6277
6043
  case 4:
6278
6044
  case "end":
6279
- return _context48.stop();
6045
+ return _context44.stop();
6280
6046
  }
6281
- }, _callee45, this);
6047
+ }, _callee41, this);
6282
6048
  }));
6283
- function getOrderInfo(_x53) {
6049
+ function getOrderInfo(_x47) {
6284
6050
  return _getOrderInfo.apply(this, arguments);
6285
6051
  }
6286
6052
  return getOrderInfo;
@@ -6339,10 +6105,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6339
6105
  _step29;
6340
6106
  try {
6341
6107
  for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6342
- var _ref81, _bundle$num3;
6108
+ var _ref80, _bundle$num3;
6343
6109
  var bundle = _step29.value;
6344
6110
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
6345
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref81 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1) || 1).toNumber();
6111
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
6346
6112
  var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6347
6113
  _step30;
6348
6114
  try {