@pisell/pisellos 2.2.274 → 2.2.276

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 (117) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/OpenData/index.d.ts +2 -0
  14. package/dist/modules/OpenData/index.js +8 -0
  15. package/dist/modules/Order/index.d.ts +28 -8
  16. package/dist/modules/Order/index.js +907 -588
  17. package/dist/modules/Order/payment-utils.d.ts +26 -0
  18. package/dist/modules/Order/payment-utils.js +225 -0
  19. package/dist/modules/Order/types.d.ts +35 -1
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  21. package/dist/modules/Order/utils.js +10 -6
  22. package/dist/modules/Payment/index.d.ts +2 -0
  23. package/dist/modules/Payment/index.js +78 -49
  24. package/dist/modules/Payment/types.d.ts +104 -25
  25. package/dist/modules/Payment/types.js +17 -0
  26. package/dist/modules/Payment/walletpass.d.ts +38 -1
  27. package/dist/modules/Payment/walletpass.js +917 -114
  28. package/dist/modules/Rules/index.d.ts +3 -0
  29. package/dist/modules/Rules/index.js +100 -70
  30. package/dist/server/index.d.ts +25 -0
  31. package/dist/server/index.js +1993 -1061
  32. package/dist/server/modules/index.d.ts +1 -1
  33. package/dist/server/modules/order/index.d.ts +70 -4
  34. package/dist/server/modules/order/index.js +1816 -728
  35. package/dist/server/modules/order/types.d.ts +25 -3
  36. package/dist/server/modules/order/types.js +7 -1
  37. package/dist/solution/BaseSales/index.d.ts +104 -5
  38. package/dist/solution/BaseSales/index.js +1767 -436
  39. package/dist/solution/BaseSales/types.d.ts +55 -1
  40. package/dist/solution/BaseSales/types.js +2 -1
  41. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  42. package/dist/solution/BaseSales/utils/cartPromotion.js +94 -32
  43. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  44. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -4
  45. package/dist/solution/BookingByStep/index.d.ts +1 -1
  46. package/dist/solution/BookingTicket/index.d.ts +21 -5
  47. package/dist/solution/BookingTicket/index.js +139 -56
  48. package/dist/solution/BookingTicket/types.d.ts +1 -0
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  50. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  51. package/dist/solution/Sales/index.d.ts +2 -0
  52. package/dist/solution/Sales/index.js +26 -4
  53. package/dist/solution/ScanOrder/index.js +31 -20
  54. package/dist/solution/VenueBooking/index.d.ts +1 -0
  55. package/dist/solution/VenueBooking/index.js +30 -19
  56. package/dist/types/index.d.ts +1 -0
  57. package/dist/utils/payment-number.d.ts +9 -0
  58. package/dist/utils/payment-number.js +69 -0
  59. package/lib/core/index.d.ts +2 -0
  60. package/lib/core/index.js +4 -0
  61. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  62. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  63. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  64. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  65. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  66. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  67. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  68. package/lib/model/strategy/adapter/promotion/index.js +2 -0
  69. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  70. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  71. package/lib/modules/OpenData/index.d.ts +2 -0
  72. package/lib/modules/OpenData/index.js +5 -0
  73. package/lib/modules/Order/index.d.ts +28 -8
  74. package/lib/modules/Order/index.js +252 -84
  75. package/lib/modules/Order/payment-utils.d.ts +26 -0
  76. package/lib/modules/Order/payment-utils.js +224 -0
  77. package/lib/modules/Order/types.d.ts +35 -1
  78. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  79. package/lib/modules/Order/utils.js +11 -4
  80. package/lib/modules/Payment/index.d.ts +2 -0
  81. package/lib/modules/Payment/index.js +33 -12
  82. package/lib/modules/Payment/types.d.ts +104 -25
  83. package/lib/modules/Payment/types.js +1 -0
  84. package/lib/modules/Payment/walletpass.d.ts +38 -1
  85. package/lib/modules/Payment/walletpass.js +730 -21
  86. package/lib/modules/Rules/index.d.ts +3 -0
  87. package/lib/modules/Rules/index.js +38 -9
  88. package/lib/server/index.d.ts +25 -0
  89. package/lib/server/index.js +726 -31
  90. package/lib/server/modules/index.d.ts +1 -1
  91. package/lib/server/modules/order/index.d.ts +70 -4
  92. package/lib/server/modules/order/index.js +818 -69
  93. package/lib/server/modules/order/types.d.ts +25 -3
  94. package/lib/server/modules/order/types.js +1 -0
  95. package/lib/solution/BaseSales/index.d.ts +104 -5
  96. package/lib/solution/BaseSales/index.js +858 -27
  97. package/lib/solution/BaseSales/types.d.ts +55 -1
  98. package/lib/solution/BaseSales/types.js +2 -1
  99. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  100. package/lib/solution/BaseSales/utils/cartPromotion.js +66 -12
  101. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  102. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -3
  103. package/lib/solution/BookingByStep/index.d.ts +1 -1
  104. package/lib/solution/BookingTicket/index.d.ts +21 -5
  105. package/lib/solution/BookingTicket/index.js +64 -13
  106. package/lib/solution/BookingTicket/types.d.ts +1 -0
  107. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  108. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  109. package/lib/solution/Sales/index.d.ts +2 -0
  110. package/lib/solution/Sales/index.js +20 -6
  111. package/lib/solution/ScanOrder/index.js +8 -0
  112. package/lib/solution/VenueBooking/index.d.ts +1 -0
  113. package/lib/solution/VenueBooking/index.js +8 -0
  114. package/lib/types/index.d.ts +1 -0
  115. package/lib/utils/payment-number.d.ts +9 -0
  116. package/lib/utils/payment-number.js +64 -0
  117. package/package.json +1 -1
@@ -10,8 +10,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
10
10
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
13
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
14
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -27,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
27
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
28
26
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
27
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
28
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
30
30
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
@@ -35,6 +35,8 @@ import { OrderHooks } from "./types";
35
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";
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";
38
40
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
39
41
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
40
42
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
@@ -68,6 +70,22 @@ function isManualProductDiscountProduct(product) {
68
70
  }
69
71
  var ORDER_PAYMENT_STATUS_PAID = 'paid';
70
72
  var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
73
+ var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
74
+ function isCustomerPromotionDiscount(discount) {
75
+ return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
76
+ }
77
+ function markScannedDiscounts(discountList, scannedDiscountList) {
78
+ var scannedIds = new Set(scannedDiscountList.map(function (discount) {
79
+ return discount === null || discount === void 0 ? void 0 : discount.id;
80
+ }).filter(function (id) {
81
+ return id !== undefined && id !== null;
82
+ }).map(String));
83
+ return discountList.map(function (discount) {
84
+ return scannedIds.has(String(discount === null || discount === void 0 ? void 0 : discount.id)) ? _objectSpread(_objectSpread({}, discount), {}, {
85
+ isScan: true
86
+ }) : discount;
87
+ });
88
+ }
71
89
  function isVoucherPaymentRecord(payment) {
72
90
  return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
73
91
  }
@@ -83,6 +101,10 @@ function isPaidPaymentRecord(payment) {
83
101
  function isCommittedVoucherPaymentRecord(payment) {
84
102
  return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
85
103
  }
104
+ function getVoucherPaymentLifecycleKey(payment) {
105
+ if (!isVoucherPaymentRecord(payment)) return null;
106
+ return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
107
+ }
86
108
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
87
109
  _inherits(OrderModule, _BaseModule);
88
110
  var _super = _createSuper(OrderModule);
@@ -97,6 +119,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
97
119
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
98
120
  // LoggerManager 实例
99
121
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
122
+ _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
100
123
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
101
124
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
102
125
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
@@ -136,22 +159,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
136
159
  _step2;
137
160
  try {
138
161
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
139
- var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$amount, _ref3, _item$discount$origin, _item$discount3, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount4, _ref9, _item$discount$origin2, _item$discount5, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref10, _product$original_pri, _ref11, _item$discount$discou2, _item$discount6, _item$discount$discou3, _item$discount7;
162
+ var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$discount4, _item$discount5, _item$amount, _ref3, _item$discount$origin, _item$discount6, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount7, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount8, _item$discount$discou3, _item$discount9;
140
163
  var item = _step2.value;
141
164
  var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
142
165
  if (!type || type === 'product') continue;
166
+ var isDiscountCard = type === 'discount_card' || type === 'product_discount_card';
143
167
  var resourceId = (_ref = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.order_discount_id;
144
168
  if (resourceId === undefined || resourceId === null || resourceId === '') continue;
145
169
  var id = Number(resourceId);
146
170
  var key = Number.isFinite(id) ? id : String(resourceId);
147
171
  var title = (_item$discount$title = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.title) !== null && _item$discount$title !== void 0 ? _item$discount$title : {};
148
172
  var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
173
+ var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
174
+ var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.percent : '0';
149
175
  var detail = {
150
176
  amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
151
177
  type: type,
152
178
  resource_id: key,
153
179
  title: title,
154
- original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
180
+ original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
155
181
  num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
156
182
  metadata: item === null || item === void 0 ? void 0 : item.metadata,
157
183
  discount: item === null || item === void 0 ? void 0 : item.discount,
@@ -162,7 +188,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
162
188
  var _existed$limited_rela;
163
189
  existed.amount = Number(existed.amount || 0) + amount;
164
190
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
165
- existed.balance = String(Number(existed.balance || 0) + amount);
191
+ if (!isDiscountCard) {
192
+ existed.balance = String(Number(existed.balance || 0) + amount);
193
+ }
166
194
  var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
167
195
  if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
168
196
  existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
@@ -179,9 +207,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
179
207
  encoded: '',
180
208
  code: '',
181
209
  tag: type,
182
- product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
210
+ product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
183
211
  relation_type: '',
184
- par_value: String((_ref9 = (_item$discount$origin2 = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.original_amount) !== null && _item$discount$origin2 !== void 0 ? _item$discount$origin2 : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref9 !== void 0 ? _ref9 : '0'),
212
+ par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
185
213
  used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
186
214
  limit_status: 'enable',
187
215
  limited_relation_product_data: {
@@ -194,13 +222,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
194
222
  filter: 0,
195
223
  exclude_product_ids: []
196
224
  },
197
- balance: String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
225
+ balance: isDiscountCard ? undefined : String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
198
226
  format_title: title,
199
227
  product: {
200
228
  id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
201
229
  title: '',
202
230
  is_charge_tax: (_product$is_charge_ta = product === null || product === void 0 ? void 0 : product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
203
- base_price: String((_ref10 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref10 !== void 0 ? _ref10 : '0')
231
+ base_price: String((_ref9 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref9 !== void 0 ? _ref9 : '0')
204
232
  },
205
233
  type: type,
206
234
  resource_id: key,
@@ -212,8 +240,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
212
240
  amount: amount,
213
241
  discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
214
242
  resource_id: key,
215
- discount_product_id: (_ref11 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref11 !== void 0 ? _ref11 : 0,
216
- discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
243
+ discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
244
+ discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
217
245
  }),
218
246
  applicableProductDetails: [detail],
219
247
  appliedProductDetails: [detail]
@@ -261,10 +289,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
261
289
  }
262
290
  if (Array.isArray(product.product_bundle)) {
263
291
  product.product_bundle = product.product_bundle.map(function (bundle) {
264
- var _ref12, _bundle$original_pric;
292
+ var _ref11, _bundle$original_pric;
265
293
  var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
266
294
  if (hasBundleDiscount) return bundle;
267
- var restoredPrice = (_ref12 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
295
+ var restoredPrice = (_ref11 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
268
296
  if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
269
297
  return _objectSpread(_objectSpread({}, bundle), {}, {
270
298
  price: restoredPrice,
@@ -284,7 +312,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
284
312
  value: function () {
285
313
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
286
314
  var _otherParams$rules, _otherParams$order, _otherParams$hooks;
287
- var appPlugin, app, otherParams;
315
+ var app, otherParams;
288
316
  return _regeneratorRuntime().wrap(function _callee$(_context) {
289
317
  while (1) switch (_context.prev = _context.next) {
290
318
  case 0:
@@ -300,14 +328,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
300
328
  this.store.availableWalletIds = [];
301
329
  }
302
330
  this.request = this.core.getPlugin('request');
303
- appPlugin = this.core.getPlugin('app');
304
- if (appPlugin) {
331
+ this.appPlugin = this.core.getPlugin('app');
332
+ if (this.appPlugin) {
305
333
  _context.next = 9;
306
334
  break;
307
335
  }
308
336
  throw new Error('Order 模块需要 app 插件支持');
309
337
  case 9:
310
- app = appPlugin.getApp();
338
+ app = this.appPlugin.getApp();
311
339
  this.logger = app.logger;
312
340
  this.window = this.core.getPlugin('window');
313
341
  otherParams = options.otherParams || {};
@@ -660,7 +688,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
660
688
  value: function () {
661
689
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
662
690
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
663
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
691
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
664
692
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
665
693
  while (1) switch (_context6.prev = _context6.next) {
666
694
  case 0:
@@ -689,6 +717,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
689
717
  return _context6.abrupt("return", {
690
718
  type: 'clientCalc',
691
719
  isAvailable: false,
720
+ isAccepted: false,
692
721
  discountList: this.getDiscountList(),
693
722
  scannedDiscountList: resultDiscountList,
694
723
  unavailableReason: UnavailableReason.Unknown
@@ -701,6 +730,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
701
730
  return _context6.abrupt("return", {
702
731
  type: 'server',
703
732
  isAvailable: false,
733
+ isAccepted: false,
704
734
  discountList: this.getDiscountList(),
705
735
  scannedDiscountList: resultDiscountList,
706
736
  unavailableReasonKey: unavailableReasonKey
@@ -728,13 +758,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
728
758
  return _context6.abrupt("return", {
729
759
  type: 'clientCalc',
730
760
  isAvailable: true,
761
+ isAccepted: true,
731
762
  discountList: this.getDiscountList(),
732
763
  scannedDiscountList: resultDiscountList
733
764
  });
734
765
  case 18:
735
766
  tempOrder = this.store.tempOrder;
736
767
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
737
- _ref13 = rulesModule.isDiscountListAvailable({
768
+ _ref12 = rulesModule.isDiscountListAvailable({
738
769
  productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
739
770
  oldDiscountList: this.getDiscountList(),
740
771
  newDiscountList: withScanList,
@@ -746,24 +777,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
746
777
  }) || {
747
778
  isAvailable: false,
748
779
  discountList: this.getDiscountList()
749
- }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
750
- if (!(isAvailable && newDiscountList)) {
751
- _context6.next = 26;
780
+ }, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, evaluatedDiscountList = _ref12.evaluatedDiscountList, unavailableReason = _ref12.unavailableReason;
781
+ shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
782
+ normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
783
+ retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
784
+ resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
785
+ if (!(isAvailable && normalizedNewDiscountList)) {
786
+ _context6.next = 34;
752
787
  break;
753
788
  }
754
- (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
789
+ _context6.next = 28;
790
+ return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
791
+ case 28:
755
792
  this.applyDiscount();
756
- _context6.next = 26;
793
+ _context6.next = 31;
757
794
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
758
- case 26:
795
+ case 31:
796
+ resolvedDiscountList = this.getDiscountList();
797
+ _context6.next = 40;
798
+ break;
799
+ case 34:
800
+ if (!(shouldRetainForLater && retainedDiscountList)) {
801
+ _context6.next = 40;
802
+ break;
803
+ }
804
+ _context6.next = 37;
805
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
806
+ case 37:
807
+ _context6.next = 39;
808
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
809
+ case 39:
810
+ resolvedDiscountList = this.getDiscountList();
811
+ case 40:
759
812
  return _context6.abrupt("return", {
760
813
  type: 'clientCalc',
761
814
  isAvailable: isAvailable || false,
762
- discountList: newDiscountList || this.getDiscountList(),
815
+ isAccepted: Boolean(isAvailable || shouldRetainForLater),
816
+ discountList: resolvedDiscountList,
763
817
  scannedDiscountList: resultDiscountList,
764
818
  unavailableReason: unavailableReason
765
819
  });
766
- case 27:
820
+ case 41:
767
821
  case "end":
768
822
  return _context6.stop();
769
823
  }
@@ -777,7 +831,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
777
831
  }, {
778
832
  key: "applyDiscount",
779
833
  value: function applyDiscount(options) {
780
- var _this$store$discount13,
834
+ var _this$store$discount14,
781
835
  _this$store$summary2,
782
836
  _this2 = this;
783
837
  var tempOrder = this.store.tempOrder;
@@ -787,7 +841,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
787
841
  if (!tempOrder) return;
788
842
  this.syncLinkedBookingHoldersToProducts(tempOrder);
789
843
  delete tempOrder.discount_list;
790
- var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
844
+ var discountList = ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.getDiscountList()) || [];
791
845
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
792
846
  if (shouldSkipDiscountCalculation) return;
793
847
  var rulesModule = this.store.rules;
@@ -806,9 +860,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
806
860
  if (result !== null && result !== void 0 && result.productList) {
807
861
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
808
862
  tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
809
- var _ref14;
863
+ var _ref13;
810
864
  var uid = getOrderProductLineUid(product);
811
- var previous = (_ref14 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref14 !== void 0 ? _ref14 : previousProductsByUid.get("__index__:".concat(index));
865
+ var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
812
866
  if (isManualProductDiscountProduct(previous)) {
813
867
  return previous;
814
868
  }
@@ -819,9 +873,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
819
873
  }));
820
874
  }
821
875
  if (result !== null && result !== void 0 && result.discountList) {
822
- var _this$store$discount14;
876
+ var _this$store$discount15;
823
877
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
824
- (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
878
+ (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 || _this$store$discount15.setDiscountList(result.discountList);
825
879
  }
826
880
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
827
881
  return _this2.productHasCustomerBoundDiscount(product);
@@ -1333,15 +1387,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1333
1387
  }, {
1334
1388
  key: "extractOrderIdFromSubmitResult",
1335
1389
  value: function extractOrderIdFromSubmitResult(result) {
1336
- var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
1337
- return (_ref15 = (_ref16 = (_ref17 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref17 !== void 0 ? _ref17 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref15 !== void 0 ? _ref15 : null;
1390
+ var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
1391
+ return (_ref14 = (_ref15 = (_ref16 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
1338
1392
  }
1339
1393
  }, {
1340
1394
  key: "calculatePaymentEffectiveAmount",
1341
1395
  value: function calculatePaymentEffectiveAmount(payment) {
1342
- var _ref18, _payment$origin_amoun;
1396
+ var _ref17, _payment$origin_amoun;
1343
1397
  var amount = new Decimal(payment.amount || 0);
1344
- var originAmount = new Decimal((_ref18 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref18 !== void 0 ? _ref18 : 0);
1398
+ var originAmount = new Decimal((_ref17 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref17 !== void 0 ? _ref17 : 0);
1345
1399
  var serviceFee = new Decimal(payment.service_fee || 0);
1346
1400
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1347
1401
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1510,19 +1564,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1510
1564
  var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
1511
1565
  return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
1512
1566
  }
1567
+ }, {
1568
+ key: "getPaymentNumberAppData",
1569
+ value: function getPaymentNumberAppData(key) {
1570
+ var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
1571
+ var appPlugin = this.appPlugin;
1572
+ if (!appPlugin) return undefined;
1573
+ var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
1574
+ if (typeof getData === 'function') return getData(key);
1575
+ var app = appPlugin.getApp();
1576
+ 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');
1577
+ return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1578
+ }
1579
+ }, {
1580
+ key: "getPaymentNumberDevicePrefixSync",
1581
+ value: function getPaymentNumberDevicePrefixSync() {
1582
+ var _this7 = this;
1583
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1584
+ return _this7.getPaymentNumberAppData(key);
1585
+ });
1586
+ }
1587
+ }, {
1588
+ key: "getPaymentNumberDevicePrefixAsync",
1589
+ value: function getPaymentNumberDevicePrefixAsync() {
1590
+ var _this8 = this;
1591
+ return resolvePaymentNumberDevicePrefix(function (key) {
1592
+ return _this8.getPaymentNumberAppData(key);
1593
+ });
1594
+ }
1513
1595
  }, {
1514
1596
  key: "normalizePaymentSource",
1515
1597
  value: function normalizePaymentSource(payment, options) {
1516
- var _ref19, _paymentRecord$origin;
1598
+ var _ref18, _paymentRecord$origin;
1517
1599
  var paymentRecord = payment;
1518
1600
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1519
- if (!metadata.unique_payment_number) {
1520
- metadata.unique_payment_number = createUuidV4();
1521
- }
1522
- var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1601
+ var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1523
1602
  metadata: metadata,
1524
- origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
1525
- });
1603
+ origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
1604
+ }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1526
1605
  if (paymentRecord.status !== undefined) {
1527
1606
  normalized.status = paymentRecord.status;
1528
1607
  } else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
@@ -1640,16 +1719,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1640
1719
  }, {
1641
1720
  key: "calculatePaidPaymentSummary",
1642
1721
  value: function calculatePaidPaymentSummary(payments) {
1643
- var _this7 = this;
1722
+ var _this9 = this;
1644
1723
  return (payments || []).reduce(function (summary, payment) {
1645
1724
  var paymentRecord = payment;
1646
1725
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1647
1726
  return {
1648
1727
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1649
- orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1650
- gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1651
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1652
- roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1728
+ orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
1729
+ gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
1730
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
1731
+ roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
1653
1732
  };
1654
1733
  }, {
1655
1734
  customerPaidAmount: new Decimal(0),
@@ -1851,15 +1930,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1851
1930
  }, {
1852
1931
  key: "normalizeFingerprintValue",
1853
1932
  value: function normalizeFingerprintValue(value) {
1854
- var _this8 = this;
1933
+ var _this10 = this;
1855
1934
  if (Array.isArray(value)) {
1856
1935
  return value.map(function (item) {
1857
- return _this8.normalizeFingerprintValue(item);
1936
+ return _this10.normalizeFingerprintValue(item);
1858
1937
  });
1859
1938
  }
1860
1939
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1861
1940
  return Object.keys(value).sort().reduce(function (result, key) {
1862
- result[key] = _this8.normalizeFingerprintValue(value[key]);
1941
+ result[key] = _this10.normalizeFingerprintValue(value[key]);
1863
1942
  return result;
1864
1943
  }, {});
1865
1944
  }
@@ -1872,9 +1951,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1872
1951
  _product$payment_pric,
1873
1952
  _sku$code,
1874
1953
  _sku$barcode,
1875
- _ref20,
1954
+ _ref19,
1876
1955
  _sku$variant_id,
1877
- _this9 = this;
1956
+ _this11 = this;
1878
1957
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1879
1958
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1880
1959
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1899,37 +1978,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1899
1978
  product_sku: this.normalizeFingerprintValue({
1900
1979
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
1901
1980
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
1902
- variant_id: (_ref20 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
1981
+ variant_id: (_ref19 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref19 !== void 0 ? _ref19 : 0,
1903
1982
  variant: sku.variant || [],
1904
1983
  option: getProductSkuOptions(product || {}).map(function (option) {
1905
- var _ref21, _option$id, _option$option_group_, _ref22, _option$option_group_2, _option$num, _option$add_price;
1984
+ var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
1906
1985
  return {
1907
- id: (_ref21 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref21 !== void 0 ? _ref21 : null,
1986
+ id: (_ref20 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref20 !== void 0 ? _ref20 : null,
1908
1987
  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,
1909
- 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,
1988
+ option_group_item_id: (_ref21 = (_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 && _ref21 !== void 0 ? _ref21 : null,
1910
1989
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1911
- 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)
1990
+ 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)
1912
1991
  };
1913
1992
  })
1914
1993
  }),
1915
1994
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1916
- var _ref23, _ref24, _bundle$bundle_produc, _ref25, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1995
+ var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1917
1996
  return {
1918
- 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,
1919
- 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,
1997
+ bundle_product_id: (_ref22 = (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
1998
+ bundle_variant_id: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 0,
1920
1999
  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),
1921
- price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1922
- bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2000
+ price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2001
+ bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1923
2002
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1924
2003
  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 : ''
1925
2004
  };
1926
2005
  })),
1927
2006
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1928
- var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
2007
+ var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
1929
2008
  return {
1930
- 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 : '',
1931
- 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,
1932
- amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2009
+ type: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : '',
2010
+ discount_id: (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
2011
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1933
2012
  };
1934
2013
  }))
1935
2014
  };
@@ -1937,9 +2016,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1937
2016
  }, {
1938
2017
  key: "buildOrderProductsFingerprint",
1939
2018
  value: function buildOrderProductsFingerprint(products) {
1940
- var _this10 = this;
2019
+ var _this12 = this;
1941
2020
  var items = (products || []).map(function (product) {
1942
- return _this10.buildProductFingerprintItem(product);
2021
+ return _this12.buildProductFingerprintItem(product);
1943
2022
  });
1944
2023
  items.sort(function (left, right) {
1945
2024
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1952,16 +2031,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1952
2031
  var _product$product_id3,
1953
2032
  _product$product_vari2,
1954
2033
  _product$num2,
1955
- _ref29,
2034
+ _ref28,
1956
2035
  _metadata$unique_iden,
1957
2036
  _metadata$price_overr,
1958
2037
  _metadata$is_manual_d,
1959
2038
  _metadata$product_dis,
1960
2039
  _sku$code2,
1961
2040
  _sku$barcode2,
1962
- _ref30,
2041
+ _ref29,
1963
2042
  _sku$variant_id2,
1964
- _this11 = this;
2043
+ _this13 = this;
1965
2044
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1966
2045
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1967
2046
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1975,7 +2054,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1975
2054
  extension_type: extensionType,
1976
2055
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
1977
2056
  metadata: {
1978
- unique_identification_number: (_ref29 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref29 !== void 0 ? _ref29 : '',
2057
+ unique_identification_number: (_ref28 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref28 !== void 0 ? _ref28 : '',
1979
2058
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
1980
2059
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
1981
2060
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -1983,47 +2062,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1983
2062
  product_sku: this.normalizeFingerprintValue({
1984
2063
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
1985
2064
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
1986
- variant_id: (_ref30 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref30 !== void 0 ? _ref30 : 0,
2065
+ variant_id: (_ref29 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref29 !== void 0 ? _ref29 : 0,
1987
2066
  variant: sku.variant || [],
1988
2067
  option: getProductSkuOptions(product || {}).map(function (option) {
1989
- var _ref31, _option$id2, _option$option_group_3, _ref32, _option$option_group_4, _option$num2, _option$add_price2;
2068
+ var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
1990
2069
  return {
1991
- id: (_ref31 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref31 !== void 0 ? _ref31 : null,
2070
+ id: (_ref30 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref30 !== void 0 ? _ref30 : null,
1992
2071
  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,
1993
- 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,
2072
+ option_group_item_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : null,
1994
2073
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1995
- 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)
2074
+ 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)
1996
2075
  };
1997
2076
  })
1998
2077
  }),
1999
2078
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2000
- var _ref33, _bundle$bundle_id, _ref34, _bundle$bundle_group_, _ref35, _ref36, _bundle$bundle_produc2, _ref37, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2079
+ var _ref32, _bundle$bundle_id, _ref33, _bundle$bundle_group_, _ref34, _ref35, _bundle$bundle_produc2, _ref36, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2001
2080
  return {
2002
- bundle_id: (_ref33 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref33 !== void 0 ? _ref33 : null,
2003
- bundle_group_id: (_ref34 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2004
- bundle_product_id: (_ref35 = (_ref36 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref36 !== void 0 ? _ref36 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref35 !== void 0 ? _ref35 : null,
2005
- bundle_variant_id: (_ref37 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref37 !== void 0 ? _ref37 : 0,
2081
+ bundle_id: (_ref32 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2082
+ bundle_group_id: (_ref33 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2083
+ bundle_product_id: (_ref34 = (_ref35 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2084
+ bundle_variant_id: (_ref36 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2006
2085
  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),
2007
2086
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2008
2087
  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 : '',
2009
- option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2010
- var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
2088
+ option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2089
+ var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
2011
2090
  return {
2012
- 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,
2091
+ id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
2013
2092
  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,
2014
- 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,
2093
+ option_group_item_id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
2015
2094
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2016
- 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)
2095
+ 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)
2017
2096
  };
2018
2097
  }))
2019
2098
  };
2020
2099
  })),
2021
2100
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2022
- var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
2101
+ var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
2023
2102
  return {
2024
- 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 : '',
2025
- 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,
2026
- amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2103
+ type: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : '',
2104
+ discount_id: (_ref40 = (_ref41 = (_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 && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2105
+ amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2027
2106
  };
2028
2107
  }))
2029
2108
  };
@@ -2031,9 +2110,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2031
2110
  }, {
2032
2111
  key: "buildOrderProductsStructuralFingerprint",
2033
2112
  value: function buildOrderProductsStructuralFingerprint(products) {
2034
- var _this12 = this;
2113
+ var _this14 = this;
2035
2114
  var items = (products || []).map(function (product) {
2036
- return _this12.buildProductStructuralFingerprintItem(product);
2115
+ return _this14.buildProductStructuralFingerprintItem(product);
2037
2116
  });
2038
2117
  items.sort(function (left, right) {
2039
2118
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2250,7 +2329,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2250
2329
  }, {
2251
2330
  key: "restoreOrder",
2252
2331
  value: function restoreOrder() {
2253
- var _this$store$discount15, _this$store$discount16;
2332
+ var _this$store$discount16, _this$store$discount17;
2254
2333
  this.logInfo('restoreOrder start', {});
2255
2334
  var freshTempOrder = this.createDefaultTempOrderInstance();
2256
2335
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2258,8 +2337,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2258
2337
  this.store.summary = createEmptySummary();
2259
2338
  this.store.lastOrderInfo = undefined;
2260
2339
  this.store.syncState = undefined;
2261
- void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2262
- void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2340
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList([]));
2341
+ void ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList([]));
2263
2342
  this.persistTempOrder();
2264
2343
  return freshTempOrder;
2265
2344
  }
@@ -2325,11 +2404,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2325
2404
  }, {
2326
2405
  key: "getOrderIdentity",
2327
2406
  value: function getOrderIdentity() {
2328
- var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
2407
+ var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2329
2408
  var tempOrder = this.store.tempOrder;
2330
2409
  if (!tempOrder) return null;
2331
2410
  var lastOrderInfo = this.store.lastOrderInfo || {};
2332
- var orderId = (_ref43 = (_ref44 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref44 !== void 0 ? _ref44 : lastOrderInfo.id) !== null && _ref43 !== void 0 ? _ref43 : null;
2411
+ var orderId = (_ref42 = (_ref43 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref43 !== void 0 ? _ref43 : lastOrderInfo.id) !== null && _ref42 !== void 0 ? _ref42 : null;
2333
2412
  return {
2334
2413
  localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2335
2414
  orderId: orderId,
@@ -2461,9 +2540,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2461
2540
  }, {
2462
2541
  key: "sanitizeTempOrderProducts",
2463
2542
  value: function sanitizeTempOrderProducts(tempOrder) {
2464
- var _this13 = this;
2543
+ var _this15 = this;
2465
2544
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2466
- return _this13.sanitizeOrderProductForTempOrder(product);
2545
+ return _this15.sanitizeOrderProductForTempOrder(product);
2467
2546
  });
2468
2547
  }
2469
2548
  }, {
@@ -2482,11 +2561,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2482
2561
  }, {
2483
2562
  key: "captureProductRuntime",
2484
2563
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2485
- var _extend$productsByUid, _ref45, _rawProduct$_origin;
2564
+ var _extend$productsByUid, _ref44, _rawProduct$_origin;
2486
2565
  var uid = existedUid || this.getProductUid(normalizedProduct);
2487
2566
  var extend = this.ensureExtend(tempOrder);
2488
2567
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2489
- var origin = (_ref45 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref45 !== void 0 ? _ref45 : existed.origin;
2568
+ var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
2490
2569
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2491
2570
  origin: origin
2492
2571
  } : {});
@@ -2566,7 +2645,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2566
2645
  }, {
2567
2646
  key: "syncLinkedBookingHoldersToProducts",
2568
2647
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2569
- var _this14 = this;
2648
+ var _this16 = this;
2570
2649
  var bookings = tempOrder.bookings || [];
2571
2650
  var products = tempOrder.products || [];
2572
2651
  if (!bookings.length || !products.length) return;
@@ -2591,7 +2670,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2591
2670
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2592
2671
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2593
2672
  if (linkedBooking) {
2594
- _this14.setProductHolderFromBooking(product, linkedBooking);
2673
+ _this16.setProductHolderFromBooking(product, linkedBooking);
2595
2674
  }
2596
2675
  });
2597
2676
  }
@@ -2629,7 +2708,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2629
2708
  }, {
2630
2709
  key: "buildTempOrderHolderFromBookings",
2631
2710
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2632
- var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2711
+ var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2633
2712
  var holderRecords = [];
2634
2713
  var holderNames = [];
2635
2714
  var baseHolder = null;
@@ -2676,7 +2755,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2676
2755
  }
2677
2756
  var nextHolder = {
2678
2757
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
2679
- form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
2758
+ form_id: (_ref45 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref45 !== void 0 ? _ref45 : 0,
2680
2759
  form_record: holderRecords
2681
2760
  };
2682
2761
  if (holderNames.length) {
@@ -2719,9 +2798,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2719
2798
  }, {
2720
2799
  key: "findBookingIndexByUniqueIdentificationNumber",
2721
2800
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2722
- var _this15 = this;
2801
+ var _this17 = this;
2723
2802
  return (tempOrder.bookings || []).findIndex(function (booking) {
2724
- return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2803
+ return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2725
2804
  });
2726
2805
  }
2727
2806
  }, {
@@ -2729,12 +2808,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2729
2808
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2730
2809
  var _product$metadata7,
2731
2810
  _product$metadata8,
2732
- _this16 = this;
2811
+ _this18 = this;
2733
2812
  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);
2734
2813
  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);
2735
2814
  if (!productUid && !bookingUid) return;
2736
2815
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2737
- var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2816
+ var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
2738
2817
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2739
2818
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2740
2819
  return true;
@@ -2781,7 +2860,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2781
2860
  key: "recalculateSummary",
2782
2861
  value: function () {
2783
2862
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2784
- var _this$otherParams2, _ref47, _salesSummaryResult$e;
2863
+ var _this$otherParams2, _ref46, _salesSummaryResult$e;
2785
2864
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2786
2865
  return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2787
2866
  while (1) switch (_context14.prev = _context14.next) {
@@ -2859,7 +2938,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2859
2938
  roundingAmount = paidPaymentSummary.roundingAmount;
2860
2939
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2861
2940
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2862
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref47 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref47 !== void 0 ? _ref47 : 0) : null;
2941
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref46 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref46 !== void 0 ? _ref46 : 0) : null;
2863
2942
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2864
2943
  rounding_amount: roundingAmount.toFixed(2)
2865
2944
  }, expectAmount ? {
@@ -3037,17 +3116,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3037
3116
  }, {
3038
3117
  key: "buildTempOrderCustomer",
3039
3118
  value: function buildTempOrderCustomer(params) {
3040
- var _ref48, _ref49, _ref50, _source$name, _ref51, _ref52, _ref53, _source$customer_name, _source$id, _source$customer_id, _ref54, _source$country_calli, _source$phone, _source$email;
3119
+ var _ref47, _ref48, _ref49, _source$name, _ref50, _ref51, _ref52, _source$customer_name, _source$id, _source$customer_id, _ref53, _source$country_calli, _source$phone, _source$email;
3041
3120
  if (!params.customerId) return null;
3042
3121
  var source = params.source ? cloneDeep(params.source) : {};
3043
- var name = (_ref48 = (_ref49 = (_ref50 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.customerName) !== null && _ref49 !== void 0 ? _ref49 : source.customer_name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
3044
- var customerName = (_ref51 = (_ref52 = (_ref53 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref53 !== void 0 ? _ref53 : source.display_name) !== null && _ref52 !== void 0 ? _ref52 : source.name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
3122
+ var name = (_ref47 = (_ref48 = (_ref49 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.customerName) !== null && _ref48 !== void 0 ? _ref48 : source.customer_name) !== null && _ref47 !== void 0 ? _ref47 : params.customerName;
3123
+ var customerName = (_ref50 = (_ref51 = (_ref52 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.display_name) !== null && _ref51 !== void 0 ? _ref51 : source.name) !== null && _ref50 !== void 0 ? _ref50 : params.customerName;
3045
3124
  return _objectSpread(_objectSpread({}, source), {}, {
3046
3125
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3047
3126
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3048
3127
  name: String(name || ''),
3049
3128
  customer_name: String(customerName || ''),
3050
- country_calling_code: String((_ref54 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref54 !== void 0 ? _ref54 : params.countryCallingCode),
3129
+ country_calling_code: String((_ref53 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref53 !== void 0 ? _ref53 : params.countryCallingCode),
3051
3130
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3052
3131
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3053
3132
  });
@@ -3067,35 +3146,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3067
3146
  }, {
3068
3147
  key: "productHasCustomerBoundDiscount",
3069
3148
  value: function productHasCustomerBoundDiscount(product) {
3070
- var _this17 = this;
3149
+ var _this19 = this;
3071
3150
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3072
- return _this17.isCustomerBoundDiscount(discount);
3151
+ return _this19.isCustomerBoundDiscount(discount);
3073
3152
  })) {
3074
3153
  return true;
3075
3154
  }
3076
3155
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3077
3156
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3078
- return _this17.isCustomerBoundDiscount(discount);
3157
+ return _this19.isCustomerBoundDiscount(discount);
3079
3158
  });
3080
3159
  });
3081
3160
  }
3082
3161
  }, {
3083
3162
  key: "shouldSkipDiscountCalculation",
3084
3163
  value: function shouldSkipDiscountCalculation(tempOrder) {
3085
- var _this$store$discount17,
3086
- _this$store$discount18,
3087
- _this18 = this;
3164
+ var _this$store$discount18,
3165
+ _this$store$discount19,
3166
+ _this20 = this;
3088
3167
  if (this.hasActiveCustomerBoundDiscount) return false;
3089
- 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)) || [];
3168
+ var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
3090
3169
  if (discountList.length > 0) return false;
3091
3170
  return !(tempOrder.products || []).some(function (product) {
3092
- return _this18.productHasCustomerBoundDiscount(product);
3171
+ return _this20.productHasCustomerBoundDiscount(product);
3093
3172
  });
3094
3173
  }
3095
3174
  }, {
3096
3175
  key: "clearCustomerBoundDiscounts",
3097
3176
  value: function clearCustomerBoundDiscounts(tempOrder) {
3098
- var _this19 = this,
3177
+ var _this21 = this,
3099
3178
  _discountModule$getDi,
3100
3179
  _discountModule$getOr,
3101
3180
  _discountModule$setDi,
@@ -3104,7 +3183,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3104
3183
  var filterDiscountList = function filterDiscountList(discountList) {
3105
3184
  if (!Array.isArray(discountList)) return [];
3106
3185
  return discountList.filter(function (discount) {
3107
- var shouldRemove = _this19.isCustomerBoundDiscount(discount);
3186
+ var shouldRemove = _this21.isCustomerBoundDiscount(discount);
3108
3187
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3109
3188
  return !shouldRemove;
3110
3189
  });
@@ -3131,12 +3210,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3131
3210
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3132
3211
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3133
3212
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3134
- if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3135
- return !_this19.isCustomerBoundDiscount(discount);
3213
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3214
+ return !_this21.isCustomerBoundDiscount(discount);
3136
3215
  });
3137
3216
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3138
- if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3139
- return !_this19.isCustomerBoundDiscount(discount);
3217
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3218
+ return !_this21.isCustomerBoundDiscount(discount);
3140
3219
  });
3141
3220
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3142
3221
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3151,14 +3230,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3151
3230
  }, {
3152
3231
  key: "updateTempOrderCustomer",
3153
3232
  value: function updateTempOrderCustomer(customer) {
3154
- var _tempOrder$customer_i2, _ref55, _ref56, _customer$customer_id, _ref57, _ref58, _ref59, _customer$customer_na, _ref60, _customer$country_cal, _tempOrder$customer_i3;
3233
+ var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
3155
3234
  var tempOrder = this.ensureTempOrder();
3156
3235
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
3157
- var customerId = (_ref55 = (_ref56 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref56 !== void 0 ? _ref56 : customer.id) !== null && _ref55 !== void 0 ? _ref55 : null;
3158
- var customerName = (_ref57 = (_ref58 = (_ref59 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref59 !== void 0 ? _ref59 : customer.display_name) !== null && _ref58 !== void 0 ? _ref58 : customer.name) !== null && _ref57 !== void 0 ? _ref57 : '';
3236
+ var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
3237
+ var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
3159
3238
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
3160
3239
  tempOrder.customer_name = String(customerName || '');
3161
- tempOrder.country_calling_code = String((_ref60 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : '');
3240
+ tempOrder.country_calling_code = String((_ref59 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref59 !== void 0 ? _ref59 : '');
3162
3241
  tempOrder.phone = String(customer.phone || '');
3163
3242
  tempOrder.email = String(customer.email || '');
3164
3243
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3290,23 +3369,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3290
3369
  * 用一组支付来源覆盖当前订单支付项。
3291
3370
  *
3292
3371
  * 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
3293
- * uuid -> metadata.unique_payment_number,id -> custom_payment_id,
3372
+ * 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
3294
3373
  * isSynced 等运行态字段不会进入 tempOrder.payments。
3295
3374
  */
3296
3375
  }, {
3297
3376
  key: "setOrderPayments",
3298
3377
  value: function setOrderPayments(payments) {
3378
+ var _this22 = this;
3299
3379
  var tempOrder = this.ensureTempOrder();
3300
- tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
3380
+ tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
3381
+ return _this22.normalizePaymentSource(payment, {
3382
+ defaultPaid: false
3383
+ });
3384
+ }));
3301
3385
  this.persistTempOrder();
3302
3386
  return tempOrder.payments;
3303
3387
  }
3304
3388
 
3305
- /** 追加单个支付项,并立即持久化当前 tempOrder。 */
3389
+ /** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
3306
3390
  }, {
3307
3391
  key: "addOrderPayment",
3308
3392
  value: function addOrderPayment(payment) {
3309
- var _this20 = this;
3393
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3394
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3395
+ }
3396
+
3397
+ /** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
3398
+ }, {
3399
+ key: "addOrderPaymentAsync",
3400
+ value: (function () {
3401
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
3402
+ var hasPaymentNumber, devicePrefix;
3403
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3404
+ while (1) switch (_context17.prev = _context17.next) {
3405
+ case 0:
3406
+ hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3407
+ if (!hasPaymentNumber) {
3408
+ _context17.next = 5;
3409
+ break;
3410
+ }
3411
+ _context17.t0 = 'LOCAL';
3412
+ _context17.next = 8;
3413
+ break;
3414
+ case 5:
3415
+ _context17.next = 7;
3416
+ return this.getPaymentNumberDevicePrefixAsync();
3417
+ case 7:
3418
+ _context17.t0 = _context17.sent;
3419
+ case 8:
3420
+ devicePrefix = _context17.t0;
3421
+ return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3422
+ case 10:
3423
+ case "end":
3424
+ return _context17.stop();
3425
+ }
3426
+ }, _callee15, this);
3427
+ }));
3428
+ function addOrderPaymentAsync(_x14) {
3429
+ return _addOrderPaymentAsync.apply(this, arguments);
3430
+ }
3431
+ return addOrderPaymentAsync;
3432
+ }())
3433
+ }, {
3434
+ key: "addOrderPaymentWithDevicePrefix",
3435
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3436
+ var _this23 = this;
3310
3437
  this.logInfo('addOrderPayment', {
3311
3438
  payment: payment
3312
3439
  });
@@ -3316,14 +3443,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3316
3443
  type: orderPaymentType,
3317
3444
  order_payment_type: orderPaymentType
3318
3445
  }), {
3319
- defaultPaid: true
3446
+ defaultPaid: true,
3447
+ devicePrefix: devicePrefix
3320
3448
  })]);
3321
3449
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
3322
3450
  this.persistTempOrder();
3323
3451
  void this.recalculateSummary({
3324
3452
  createIfMissing: true
3325
3453
  }).catch(function (error) {
3326
- _this20.logError('recalculate summary after addOrderPayment failed', {
3454
+ _this23.logError('recalculate summary after addOrderPayment failed', {
3327
3455
  error: error instanceof Error ? error.message : String(error)
3328
3456
  });
3329
3457
  });
@@ -3331,49 +3459,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3331
3459
  }
3332
3460
 
3333
3461
  /**
3334
- * 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
3335
- *
3336
- * 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
3337
- * 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
3462
+ * 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
3463
+ * metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
3338
3464
  */
3339
3465
  }, {
3340
3466
  key: "updateOrderPayment",
3341
- value: function updateOrderPayment(paymentIdentity, updates) {
3342
- var tempOrder = this.ensureTempOrder();
3343
- var identity = String(paymentIdentity);
3344
- tempOrder.payments = (tempOrder.payments || []).map(function (payment) {
3345
- var _payment$metadata;
3346
- var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
3347
- var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3348
- var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3349
- var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3350
- var matched = [uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3351
- return value !== undefined && String(value) === identity;
3352
- });
3353
- if (!matched) return payment;
3354
- return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
3355
- metadata: _objectSpread(_objectSpread({}, payment.metadata || {}), updates.metadata || {})
3356
- });
3357
- });
3358
- this.persistTempOrder();
3359
- return tempOrder.payments;
3360
- }
3361
-
3362
- /** 从当前订单支付项中移除指定支付项。 */
3467
+ value: (function () {
3468
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
3469
+ var options,
3470
+ tempOrder,
3471
+ identity,
3472
+ matchMode,
3473
+ matchedPayment,
3474
+ updatedPayment,
3475
+ summary,
3476
+ payments,
3477
+ _args18 = arguments;
3478
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3479
+ while (1) switch (_context18.prev = _context18.next) {
3480
+ case 0:
3481
+ options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
3482
+ tempOrder = this.ensureTempOrder();
3483
+ identity = String(paymentIdentity);
3484
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3485
+ matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
3486
+ if (matchedPayment) {
3487
+ _context18.next = 7;
3488
+ break;
3489
+ }
3490
+ throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
3491
+ case 7:
3492
+ updatedPayment = null;
3493
+ tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
3494
+ if (index !== matchedPayment.index) return payment;
3495
+ var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
3496
+ updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
3497
+ }));
3498
+ updatedPayment = nextPayment;
3499
+ return nextPayment;
3500
+ });
3501
+ this.persistTempOrder();
3502
+ _context18.next = 12;
3503
+ return this.recalculateSummary({
3504
+ createIfMissing: true
3505
+ });
3506
+ case 12:
3507
+ summary = _context18.sent;
3508
+ this.persistTempOrder();
3509
+ payments = tempOrder.payments;
3510
+ return _context18.abrupt("return", {
3511
+ updated: true,
3512
+ payment: payments[matchedPayment.index] || updatedPayment,
3513
+ payments: payments,
3514
+ summary: summary
3515
+ });
3516
+ case 16:
3517
+ case "end":
3518
+ return _context18.stop();
3519
+ }
3520
+ }, _callee16, this);
3521
+ }));
3522
+ function updateOrderPayment(_x15, _x16) {
3523
+ return _updateOrderPayment.apply(this, arguments);
3524
+ }
3525
+ return updateOrderPayment;
3526
+ }() /** 从当前订单支付项中移除指定支付项。 */)
3363
3527
  }, {
3364
3528
  key: "deleteOrderPayment",
3365
3529
  value: function deleteOrderPayment(paymentIdentity) {
3366
3530
  var tempOrder = this.ensureTempOrder();
3367
3531
  var identity = String(paymentIdentity);
3368
- tempOrder.payments = (tempOrder.payments || []).filter(function (payment) {
3369
- var _payment$metadata2;
3370
- var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.unique_payment_number;
3371
- var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3372
- var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3373
- var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3374
- return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3375
- return value !== undefined && String(value) === identity;
3376
- });
3532
+ var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
3533
+ if (!matchedPayment) return tempOrder.payments;
3534
+ tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
3535
+ return index !== matchedPayment.index;
3377
3536
  });
3378
3537
  this.persistTempOrder();
3379
3538
  return tempOrder.payments;
@@ -3405,7 +3564,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3405
3564
  }, {
3406
3565
  key: "applyPaymentLifecycleChange",
3407
3566
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3408
- var _this21 = this;
3567
+ var _this24 = this;
3409
3568
  this.updateTempOrderPaymentStatus(tempOrder);
3410
3569
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3411
3570
  this.persistTempOrder();
@@ -3415,7 +3574,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3415
3574
  void this.recalculateSummary({
3416
3575
  createIfMissing: true
3417
3576
  }).catch(function (error) {
3418
- _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3577
+ _this24.logError("recalculate summary after ".concat(logContext, " failed"), {
3419
3578
  error: error instanceof Error ? error.message : String(error)
3420
3579
  });
3421
3580
  });
@@ -3459,7 +3618,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3459
3618
  }, {
3460
3619
  key: "updateVoucherOrderPayments",
3461
3620
  value: function updateVoucherOrderPayments(payments, options) {
3462
- var _this22 = this;
3621
+ var _this25 = this;
3463
3622
  var tempOrder = this.ensureTempOrder();
3464
3623
  var isOrderPaymentType = function isOrderPaymentType(value) {
3465
3624
  return value === 'normal' || value === 'deposit';
@@ -3494,8 +3653,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3494
3653
  });
3495
3654
  };
3496
3655
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3497
- return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3498
- defaultPaid: false
3656
+ return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3657
+ defaultPaid: false,
3658
+ devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
3499
3659
  });
3500
3660
  })).filter(function (payment) {
3501
3661
  return isVoucherPaymentRecord(payment);
@@ -3521,14 +3681,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3521
3681
  }).map(function (payment) {
3522
3682
  return String(payment.order_payment_id);
3523
3683
  }));
3524
- var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
3525
- return String(payment.voucher_id);
3684
+ var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
3685
+ return getVoucherPaymentLifecycleKey(payment);
3686
+ }).filter(function (key) {
3687
+ return key !== null;
3526
3688
  }));
3527
3689
  var replaceableVouchers = mappedVouchers.filter(function (payment) {
3528
3690
  if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
3529
3691
  return false;
3530
3692
  }
3531
- if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
3693
+ var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
3694
+ if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
3532
3695
  return false;
3533
3696
  }
3534
3697
  return true;
@@ -3543,54 +3706,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3543
3706
  void this.recalculateSummary({
3544
3707
  createIfMissing: true
3545
3708
  }).catch(function (error) {
3546
- _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3709
+ _this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
3547
3710
  error: error instanceof Error ? error.message : String(error)
3548
3711
  });
3549
3712
  });
3550
3713
  return tempOrder.payments;
3551
3714
  }
3715
+ }, {
3716
+ key: "updateVoucherOrderPaymentsAsync",
3717
+ value: function () {
3718
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
3719
+ var needsPaymentNumber, devicePrefix;
3720
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3721
+ while (1) switch (_context19.prev = _context19.next) {
3722
+ case 0:
3723
+ needsPaymentNumber = (payments || []).some(function (payment) {
3724
+ return String(payment.payment_number || '').trim() === '';
3725
+ });
3726
+ if (!needsPaymentNumber) {
3727
+ _context19.next = 7;
3728
+ break;
3729
+ }
3730
+ _context19.next = 4;
3731
+ return this.getPaymentNumberDevicePrefixAsync();
3732
+ case 4:
3733
+ _context19.t0 = _context19.sent;
3734
+ _context19.next = 8;
3735
+ break;
3736
+ case 7:
3737
+ _context19.t0 = 'LOCAL';
3738
+ case 8:
3739
+ devicePrefix = _context19.t0;
3740
+ return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
3741
+ devicePrefix: devicePrefix
3742
+ })));
3743
+ case 10:
3744
+ case "end":
3745
+ return _context19.stop();
3746
+ }
3747
+ }, _callee17, this);
3748
+ }));
3749
+ function updateVoucherOrderPaymentsAsync(_x17, _x18) {
3750
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3751
+ }
3752
+ return updateVoucherOrderPaymentsAsync;
3753
+ }()
3552
3754
  }, {
3553
3755
  key: "shouldMergeProductToOrder",
3554
3756
  value: function () {
3555
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3757
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
3556
3758
  var _this$orderHooks;
3557
3759
  var onBeforeMergeProductToOrder, result;
3558
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3559
- while (1) switch (_context17.prev = _context17.next) {
3760
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3761
+ while (1) switch (_context20.prev = _context20.next) {
3560
3762
  case 0:
3561
3763
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3562
3764
  if (onBeforeMergeProductToOrder) {
3563
- _context17.next = 3;
3765
+ _context20.next = 3;
3564
3766
  break;
3565
3767
  }
3566
- return _context17.abrupt("return", true);
3768
+ return _context20.abrupt("return", true);
3567
3769
  case 3:
3568
- _context17.next = 5;
3770
+ _context20.next = 5;
3569
3771
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3570
3772
  defaultShouldMerge: true
3571
3773
  }));
3572
3774
  case 5:
3573
- result = _context17.sent;
3775
+ result = _context20.sent;
3574
3776
  if (!(typeof result === 'boolean')) {
3575
- _context17.next = 8;
3777
+ _context20.next = 8;
3576
3778
  break;
3577
3779
  }
3578
- return _context17.abrupt("return", result);
3780
+ return _context20.abrupt("return", result);
3579
3781
  case 8:
3580
3782
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3581
- _context17.next = 10;
3783
+ _context20.next = 10;
3582
3784
  break;
3583
3785
  }
3584
- return _context17.abrupt("return", result.shouldMerge);
3786
+ return _context20.abrupt("return", result.shouldMerge);
3585
3787
  case 10:
3586
- return _context17.abrupt("return", true);
3788
+ return _context20.abrupt("return", true);
3587
3789
  case 11:
3588
3790
  case "end":
3589
- return _context17.stop();
3791
+ return _context20.stop();
3590
3792
  }
3591
- }, _callee15, this);
3793
+ }, _callee18, this);
3592
3794
  }));
3593
- function shouldMergeProductToOrder(_x14) {
3795
+ function shouldMergeProductToOrder(_x19) {
3594
3796
  return _shouldMergeProductToOrder.apply(this, arguments);
3595
3797
  }
3596
3798
  return shouldMergeProductToOrder;
@@ -3626,30 +3828,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3626
3828
  }, {
3627
3829
  key: "finalizeProductOrderMutation",
3628
3830
  value: function () {
3629
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3630
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3631
- while (1) switch (_context18.prev = _context18.next) {
3831
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
3832
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3833
+ while (1) switch (_context21.prev = _context21.next) {
3632
3834
  case 0:
3633
3835
  this.syncTempOrderHolderFromBookings(tempOrder);
3634
3836
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3635
- _context18.next = 4;
3837
+ _context21.next = 4;
3636
3838
  break;
3637
3839
  }
3638
- _context18.next = 4;
3840
+ _context21.next = 4;
3639
3841
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3640
3842
  case 4:
3641
3843
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3642
- _context18.next = 7;
3844
+ _context21.next = 7;
3643
3845
  break;
3644
3846
  }
3645
- _context18.next = 7;
3847
+ _context21.next = 7;
3646
3848
  return this.applyPromotion();
3647
3849
  case 7:
3648
3850
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3649
3851
  this.applyDiscount();
3650
3852
  }
3651
3853
  this.sanitizeTempOrderProducts(tempOrder);
3652
- _context18.next = 11;
3854
+ _context21.next = 11;
3653
3855
  return this.recalculateSummary({
3654
3856
  createIfMissing: true
3655
3857
  });
@@ -3657,11 +3859,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3657
3859
  this.persistTempOrder();
3658
3860
  case 12:
3659
3861
  case "end":
3660
- return _context18.stop();
3862
+ return _context21.stop();
3661
3863
  }
3662
- }, _callee16, this);
3864
+ }, _callee19, this);
3663
3865
  }));
3664
- function finalizeProductOrderMutation(_x15, _x16) {
3866
+ function finalizeProductOrderMutation(_x20, _x21) {
3665
3867
  return _finalizeProductOrderMutation.apply(this, arguments);
3666
3868
  }
3667
3869
  return finalizeProductOrderMutation;
@@ -3676,15 +3878,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3676
3878
  }, {
3677
3879
  key: "appendProductLineToTempOrder",
3678
3880
  value: (function () {
3679
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking, options) {
3881
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking, options) {
3680
3882
  var _normalizedIncoming$p,
3681
3883
  _normalizedIncoming$p2,
3682
3884
  _booking_uid,
3683
3885
  _metadata,
3684
- _this23 = this;
3685
- var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
3686
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3687
- while (1) switch (_context19.prev = _context19.next) {
3886
+ _productToAdd$metadat,
3887
+ _origin,
3888
+ _this26 = this;
3889
+ var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, isIncomingCustomItem, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
3890
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3891
+ while (1) switch (_context22.prev = _context22.next) {
3688
3892
  case 0:
3689
3893
  linked = booking ? this.createLinkedProductAndBooking({
3690
3894
  product: product,
@@ -3696,7 +3900,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3696
3900
  isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
3697
3901
  netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
3698
3902
  if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
3699
- _context19.next = 8;
3903
+ _context22.next = 8;
3700
3904
  break;
3701
3905
  }
3702
3906
  throw new Error('[Order] 称重商品净重必须大于 0');
@@ -3712,11 +3916,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3712
3916
  hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
3713
3917
  hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
3714
3918
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3715
- shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
3919
+ isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
3920
+ shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
3716
3921
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3717
3922
  var _item$metadata3;
3718
- if (_this23.hasGoodPassDiscount(item)) return false;
3719
- if (_this23.hasOrderProductLineNote(item)) return false;
3923
+ if (_this26.hasGoodPassDiscount(item)) return false;
3924
+ if (_this26.hasOrderProductLineNote(item)) return false;
3720
3925
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3721
3926
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3722
3927
  if (item.product_id !== productToAdd.product_id) return false;
@@ -3727,10 +3932,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3727
3932
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3728
3933
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3729
3934
  if (!matchedProduct) {
3730
- _context19.next = 24;
3935
+ _context22.next = 25;
3731
3936
  break;
3732
3937
  }
3733
- _context19.next = 21;
3938
+ _context22.next = 22;
3734
3939
  return this.shouldMergeProductToOrder({
3735
3940
  incomingProduct: productToAdd,
3736
3941
  normalizedIncoming: normalizedIncoming,
@@ -3741,14 +3946,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3741
3946
  tempOrder: tempOrder,
3742
3947
  booking: booking
3743
3948
  });
3744
- case 21:
3745
- _context19.t0 = _context19.sent;
3746
- _context19.next = 25;
3949
+ case 22:
3950
+ _context22.t0 = _context22.sent;
3951
+ _context22.next = 26;
3747
3952
  break;
3748
- case 24:
3749
- _context19.t0 = false;
3750
3953
  case 25:
3751
- shouldMerge = _context19.t0;
3954
+ _context22.t0 = false;
3955
+ case 26:
3956
+ shouldMerge = _context22.t0;
3752
3957
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3753
3958
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3754
3959
  if (linked) {
@@ -3808,13 +4013,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3808
4013
  if (linked) {
3809
4014
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
3810
4015
  }
3811
- case 28:
4016
+ case 29:
3812
4017
  case "end":
3813
- return _context19.stop();
4018
+ return _context22.stop();
3814
4019
  }
3815
- }, _callee17, this);
4020
+ }, _callee20, this);
3816
4021
  }));
3817
- function appendProductLineToTempOrder(_x17, _x18, _x19, _x20) {
4022
+ function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
3818
4023
  return _appendProductLineToTempOrder.apply(this, arguments);
3819
4024
  }
3820
4025
  return appendProductLineToTempOrder;
@@ -3830,10 +4035,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3830
4035
  }, {
3831
4036
  key: "addProductToOrder",
3832
4037
  value: (function () {
3833
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking, options) {
3834
- var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3835
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3836
- while (1) switch (_context20.prev = _context20.next) {
4038
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
4039
+ var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
4040
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4041
+ while (1) switch (_context23.prev = _context23.next) {
3837
4042
  case 0:
3838
4043
  tempOrder = this.ensureTempOrder();
3839
4044
  insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
@@ -3844,25 +4049,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3844
4049
  }) : -1;
3845
4050
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
3846
4051
  if (!booking) {
3847
- _context20.next = 22;
4052
+ _context23.next = 22;
3848
4053
  break;
3849
4054
  }
3850
4055
  productRecord = product;
3851
- splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4056
+ splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
3852
4057
  if (!(splitCount > 1)) {
3853
- _context20.next = 22;
4058
+ _context23.next = 22;
3854
4059
  break;
3855
4060
  }
3856
4061
  i = 0;
3857
4062
  case 9:
3858
4063
  if (!(i < splitCount)) {
3859
- _context20.next = 19;
4064
+ _context23.next = 19;
3860
4065
  break;
3861
4066
  }
3862
4067
  singleLine = cloneDeep(productRecord);
3863
4068
  singleLine.num = 1;
3864
4069
  delete singleLine.product_quantity;
3865
- _context20.next = 15;
4070
+ _context23.next = 15;
3866
4071
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
3867
4072
  insertAtIndex: insertAtIndex
3868
4073
  });
@@ -3870,34 +4075,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3870
4075
  if (insertAtIndex !== undefined) insertAtIndex += 1;
3871
4076
  case 16:
3872
4077
  i += 1;
3873
- _context20.next = 9;
4078
+ _context23.next = 9;
3874
4079
  break;
3875
4080
  case 19:
3876
- _context20.next = 21;
4081
+ _context23.next = 21;
3877
4082
  return this.finalizeProductOrderMutation(tempOrder);
3878
4083
  case 21:
3879
- return _context20.abrupt("return", tempOrder.products);
4084
+ return _context23.abrupt("return", tempOrder.products);
3880
4085
  case 22:
3881
- _context20.next = 24;
4086
+ _context23.next = 24;
3882
4087
  return this.appendProductLineToTempOrder(tempOrder, product, booking, {
3883
4088
  insertAtIndex: insertAtIndex
3884
4089
  });
3885
4090
  case 24:
3886
- _context20.next = 26;
4091
+ _context23.next = 26;
3887
4092
  return this.finalizeProductOrderMutation(tempOrder);
3888
4093
  case 26:
3889
4094
  this.logInfo('addProductToOrder success', {
3890
4095
  product_id: product.product_id,
3891
4096
  with_booking: !!booking
3892
4097
  });
3893
- return _context20.abrupt("return", tempOrder.products);
4098
+ return _context23.abrupt("return", tempOrder.products);
3894
4099
  case 28:
3895
4100
  case "end":
3896
- return _context20.stop();
4101
+ return _context23.stop();
3897
4102
  }
3898
- }, _callee18, this);
4103
+ }, _callee21, this);
3899
4104
  }));
3900
- function addProductToOrder(_x21, _x22, _x23) {
4105
+ function addProductToOrder(_x26, _x27, _x28) {
3901
4106
  return _addProductToOrder.apply(this, arguments);
3902
4107
  }
3903
4108
  return addProductToOrder;
@@ -3915,93 +4120,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3915
4120
  }, {
3916
4121
  key: "addProductsToOrder",
3917
4122
  value: (function () {
3918
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
3919
- var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3920
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3921
- while (1) switch (_context21.prev = _context21.next) {
4123
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
4124
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine;
4125
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4126
+ while (1) switch (_context24.prev = _context24.next) {
3922
4127
  case 0:
3923
4128
  tempOrder = this.ensureTempOrder();
3924
4129
  if (!(!Array.isArray(items) || items.length === 0)) {
3925
- _context21.next = 3;
4130
+ _context24.next = 3;
3926
4131
  break;
3927
4132
  }
3928
- return _context21.abrupt("return", tempOrder.products);
4133
+ return _context24.abrupt("return", tempOrder.products);
3929
4134
  case 3:
3930
4135
  _iterator20 = _createForOfIteratorHelper(items || []);
3931
- _context21.prev = 4;
4136
+ _context24.prev = 4;
3932
4137
  _iterator20.s();
3933
4138
  case 6:
3934
4139
  if ((_step20 = _iterator20.n()).done) {
3935
- _context21.next = 30;
4140
+ _context24.next = 30;
3936
4141
  break;
3937
4142
  }
3938
4143
  item = _step20.value;
3939
4144
  product = item.product, booking = item.booking;
3940
4145
  if (product) {
3941
- _context21.next = 11;
4146
+ _context24.next = 11;
3942
4147
  break;
3943
4148
  }
3944
- return _context21.abrupt("continue", 28);
4149
+ return _context24.abrupt("continue", 28);
3945
4150
  case 11:
3946
4151
  if (!booking) {
3947
- _context21.next = 26;
4152
+ _context24.next = 26;
3948
4153
  break;
3949
4154
  }
3950
4155
  productRecord = product;
3951
- splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
4156
+ splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3952
4157
  if (!(splitCount > 1)) {
3953
- _context21.next = 26;
4158
+ _context24.next = 26;
3954
4159
  break;
3955
4160
  }
3956
4161
  i = 0;
3957
4162
  case 16:
3958
4163
  if (!(i < splitCount)) {
3959
- _context21.next = 25;
4164
+ _context24.next = 25;
3960
4165
  break;
3961
4166
  }
3962
4167
  singleLine = cloneDeep(productRecord);
3963
4168
  singleLine.num = 1;
3964
4169
  delete singleLine.product_quantity;
3965
- _context21.next = 22;
4170
+ _context24.next = 22;
3966
4171
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3967
4172
  case 22:
3968
4173
  i += 1;
3969
- _context21.next = 16;
4174
+ _context24.next = 16;
3970
4175
  break;
3971
4176
  case 25:
3972
- return _context21.abrupt("continue", 28);
4177
+ return _context24.abrupt("continue", 28);
3973
4178
  case 26:
3974
- _context21.next = 28;
4179
+ _context24.next = 28;
3975
4180
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3976
4181
  case 28:
3977
- _context21.next = 6;
4182
+ _context24.next = 6;
3978
4183
  break;
3979
4184
  case 30:
3980
- _context21.next = 35;
4185
+ _context24.next = 35;
3981
4186
  break;
3982
4187
  case 32:
3983
- _context21.prev = 32;
3984
- _context21.t0 = _context21["catch"](4);
3985
- _iterator20.e(_context21.t0);
4188
+ _context24.prev = 32;
4189
+ _context24.t0 = _context24["catch"](4);
4190
+ _iterator20.e(_context24.t0);
3986
4191
  case 35:
3987
- _context21.prev = 35;
4192
+ _context24.prev = 35;
3988
4193
  _iterator20.f();
3989
- return _context21.finish(35);
4194
+ return _context24.finish(35);
3990
4195
  case 38:
3991
- _context21.next = 40;
4196
+ _context24.next = 40;
3992
4197
  return this.finalizeProductOrderMutation(tempOrder, options);
3993
4198
  case 40:
3994
4199
  this.logInfo('addProductsToOrder success', {
3995
4200
  itemsCount: items.length
3996
4201
  });
3997
- return _context21.abrupt("return", tempOrder.products);
4202
+ return _context24.abrupt("return", tempOrder.products);
3998
4203
  case 42:
3999
4204
  case "end":
4000
- return _context21.stop();
4205
+ return _context24.stop();
4001
4206
  }
4002
- }, _callee19, this, [[4, 32, 35, 38]]);
4207
+ }, _callee22, this, [[4, 32, 35, 38]]);
4003
4208
  }));
4004
- function addProductsToOrder(_x24, _x25) {
4209
+ function addProductsToOrder(_x29, _x30) {
4005
4210
  return _addProductsToOrder.apply(this, arguments);
4006
4211
  }
4007
4212
  return addProductsToOrder;
@@ -4028,24 +4233,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4028
4233
  }, {
4029
4234
  key: "getBundleRuntimeIdentity",
4030
4235
  value: function getBundleRuntimeIdentity(bundle) {
4031
- var _ref63, _bundle$bundle_id2, _ref64, _bundle$bundle_group_2, _ref65, _ref66, _bundle$bundle_produc3, _ref67, _bundle$bundle_varian3;
4236
+ var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
4032
4237
  if (!bundle || _typeof(bundle) !== 'object') return '';
4033
- return [(_ref63 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref65 = (_ref66 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle.product_id) !== null && _ref65 !== void 0 ? _ref65 : '', (_ref67 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref67 !== void 0 ? _ref67 : 0].join('|');
4238
+ return [(_ref62 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_ref65 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref65 !== void 0 ? _ref65 : bundle.product_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref66 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref66 !== void 0 ? _ref66 : 0].join('|');
4034
4239
  }
4035
4240
  }, {
4036
4241
  key: "preservePersistedBundlePriceFields",
4037
4242
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4038
- var _this24 = this;
4243
+ var _this27 = this;
4039
4244
  if (!Array.isArray(nextBundles)) return nextBundles;
4040
4245
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4041
4246
  var previousByIdentity = new Map();
4042
4247
  previousBundles.forEach(function (bundle) {
4043
- var identity = _this24.getBundleRuntimeIdentity(bundle);
4248
+ var identity = _this27.getBundleRuntimeIdentity(bundle);
4044
4249
  if (identity) previousByIdentity.set(identity, bundle);
4045
4250
  });
4046
4251
  return nextBundles.map(function (bundle, index) {
4047
4252
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4048
- var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4253
+ var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4049
4254
  if (!previous || _typeof(previous) !== 'object') return bundle;
4050
4255
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4051
4256
  cover: previous.cover
@@ -4181,13 +4386,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4181
4386
  delete nextProduct.metadata.main_product_original_price;
4182
4387
  delete nextProduct.metadata.price_schema_version;
4183
4388
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4184
- var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4389
+ var _ref67, _targetProduct$metada10, _targetProduct$metada11, _ref68, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4185
4390
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
4186
4391
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
4187
4392
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
4188
4393
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
4189
- var _previousMainOriginal = new Decimal(Number((_ref68 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref68 !== void 0 ? _ref68 : 0) || 0);
4190
- var _previousMainSelling = new Decimal(Number((_ref69 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref69 !== void 0 ? _ref69 : _previousMainOriginal.toNumber()) || 0);
4394
+ var _previousMainOriginal = new Decimal(Number((_ref67 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref67 !== void 0 ? _ref67 : 0) || 0);
4395
+ var _previousMainSelling = new Decimal(Number((_ref68 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref68 !== void 0 ? _ref68 : _previousMainOriginal.toNumber()) || 0);
4191
4396
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
4192
4397
  var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
4193
4398
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -4246,21 +4451,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4246
4451
  }, {
4247
4452
  key: "updateOrderProduct",
4248
4453
  value: function () {
4249
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4454
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4250
4455
  var tempOrder, updatedProductUid;
4251
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4252
- while (1) switch (_context22.prev = _context22.next) {
4456
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4457
+ while (1) switch (_context25.prev = _context25.next) {
4253
4458
  case 0:
4254
4459
  tempOrder = this.ensureTempOrder();
4255
4460
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4256
- _context22.next = 4;
4461
+ _context25.next = 4;
4257
4462
  return this.applyPromotion();
4258
4463
  case 4:
4259
4464
  this.applyDiscount({
4260
4465
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4261
4466
  });
4262
4467
  this.sanitizeTempOrderProducts(tempOrder);
4263
- _context22.next = 8;
4468
+ _context25.next = 8;
4264
4469
  return this.recalculateSummary({
4265
4470
  createIfMissing: true
4266
4471
  });
@@ -4269,14 +4474,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4269
4474
  this.logInfo('updateOrderProduct success', {
4270
4475
  params: params
4271
4476
  });
4272
- return _context22.abrupt("return", tempOrder.products);
4477
+ return _context25.abrupt("return", tempOrder.products);
4273
4478
  case 11:
4274
4479
  case "end":
4275
- return _context22.stop();
4480
+ return _context25.stop();
4276
4481
  }
4277
- }, _callee20, this);
4482
+ }, _callee23, this);
4278
4483
  }));
4279
- function updateOrderProduct(_x26) {
4484
+ function updateOrderProduct(_x31) {
4280
4485
  return _updateOrderProduct.apply(this, arguments);
4281
4486
  }
4282
4487
  return updateOrderProduct;
@@ -4284,28 +4489,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4284
4489
  }, {
4285
4490
  key: "updateOrderProducts",
4286
4491
  value: function () {
4287
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4288
- var _this25 = this;
4492
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
4493
+ var _this28 = this;
4289
4494
  var tempOrder, reapplyBookingDiscountProductUids;
4290
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4291
- while (1) switch (_context23.prev = _context23.next) {
4495
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4496
+ while (1) switch (_context26.prev = _context26.next) {
4292
4497
  case 0:
4293
4498
  tempOrder = this.ensureTempOrder();
4294
4499
  if (paramsList.length) {
4295
- _context23.next = 3;
4500
+ _context26.next = 3;
4296
4501
  break;
4297
4502
  }
4298
- return _context23.abrupt("return", tempOrder.products);
4503
+ return _context26.abrupt("return", tempOrder.products);
4299
4504
  case 3:
4300
4505
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4301
- var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4506
+ var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
4302
4507
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4303
4508
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4304
4509
  acc.push(String(updatedProductUid));
4305
4510
  }
4306
4511
  return acc;
4307
4512
  }, []);
4308
- _context23.next = 6;
4513
+ _context26.next = 6;
4309
4514
  return this.finalizeAfterProductsMutation(tempOrder, {
4310
4515
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4311
4516
  });
@@ -4313,14 +4518,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4313
4518
  this.logInfo('updateOrderProduct success', {
4314
4519
  paramsList: paramsList
4315
4520
  });
4316
- return _context23.abrupt("return", tempOrder.products);
4521
+ return _context26.abrupt("return", tempOrder.products);
4317
4522
  case 8:
4318
4523
  case "end":
4319
- return _context23.stop();
4524
+ return _context26.stop();
4320
4525
  }
4321
- }, _callee21, this);
4526
+ }, _callee24, this);
4322
4527
  }));
4323
- function updateOrderProducts(_x27) {
4528
+ function updateOrderProducts(_x32) {
4324
4529
  return _updateOrderProducts.apply(this, arguments);
4325
4530
  }
4326
4531
  return updateOrderProducts;
@@ -4328,11 +4533,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4328
4533
  }, {
4329
4534
  key: "updateOrderProductQuantity",
4330
4535
  value: function () {
4331
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4536
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4332
4537
  var _targetProduct$metada17;
4333
4538
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4334
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4335
- while (1) switch (_context24.prev = _context24.next) {
4539
+ return _regeneratorRuntime().wrap(function _callee25$(_context27) {
4540
+ while (1) switch (_context27.prev = _context27.next) {
4336
4541
  case 0:
4337
4542
  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;
4338
4543
  tempOrder = this.ensureTempOrder();
@@ -4361,7 +4566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4361
4566
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4362
4567
  }
4363
4568
  if (!(productIndex === -1)) {
4364
- _context24.next = 12;
4569
+ _context27.next = 12;
4365
4570
  break;
4366
4571
  }
4367
4572
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4375,12 +4580,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4375
4580
  }));
4376
4581
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4377
4582
  tempOrder.products[productIndex] = normalizedProduct;
4378
- _context24.next = 18;
4583
+ _context27.next = 18;
4379
4584
  return this.applyPromotion();
4380
4585
  case 18:
4381
4586
  this.applyDiscount();
4382
4587
  this.sanitizeTempOrderProducts(tempOrder);
4383
- _context24.next = 22;
4588
+ _context27.next = 22;
4384
4589
  return this.recalculateSummary({
4385
4590
  createIfMissing: true
4386
4591
  });
@@ -4389,14 +4594,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4389
4594
  this.logInfo('updateOrderProductQuantity success', {
4390
4595
  params: params
4391
4596
  });
4392
- return _context24.abrupt("return", tempOrder.products);
4597
+ return _context27.abrupt("return", tempOrder.products);
4393
4598
  case 25:
4394
4599
  case "end":
4395
- return _context24.stop();
4600
+ return _context27.stop();
4396
4601
  }
4397
- }, _callee22, this);
4602
+ }, _callee25, this);
4398
4603
  }));
4399
- function updateOrderProductQuantity(_x28) {
4604
+ function updateOrderProductQuantity(_x33) {
4400
4605
  return _updateOrderProductQuantity.apply(this, arguments);
4401
4606
  }
4402
4607
  return updateOrderProductQuantity;
@@ -4437,19 +4642,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4437
4642
  }, {
4438
4643
  key: "finalizeAfterProductsMutation",
4439
4644
  value: (function () {
4440
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4441
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4442
- while (1) switch (_context25.prev = _context25.next) {
4645
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
4646
+ return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4647
+ while (1) switch (_context28.prev = _context28.next) {
4443
4648
  case 0:
4444
4649
  this.syncTempOrderHolderFromBookings(tempOrder);
4445
- _context25.next = 3;
4650
+ _context28.next = 3;
4446
4651
  return this.applyPromotion();
4447
4652
  case 3:
4448
4653
  this.applyDiscount({
4449
4654
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4450
4655
  });
4451
4656
  this.sanitizeTempOrderProducts(tempOrder);
4452
- _context25.next = 7;
4657
+ _context28.next = 7;
4453
4658
  return this.recalculateSummary({
4454
4659
  createIfMissing: true
4455
4660
  });
@@ -4457,11 +4662,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4457
4662
  this.persistTempOrder();
4458
4663
  case 8:
4459
4664
  case "end":
4460
- return _context25.stop();
4665
+ return _context28.stop();
4461
4666
  }
4462
- }, _callee23, this);
4667
+ }, _callee26, this);
4463
4668
  }));
4464
- function finalizeAfterProductsMutation(_x29, _x30) {
4669
+ function finalizeAfterProductsMutation(_x34, _x35) {
4465
4670
  return _finalizeAfterProductsMutation.apply(this, arguments);
4466
4671
  }
4467
4672
  return finalizeAfterProductsMutation;
@@ -4476,18 +4681,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4476
4681
  }, {
4477
4682
  key: "removeProductsFromOrder",
4478
4683
  value: (function () {
4479
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities, options) {
4480
- var _this26 = this;
4684
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
4685
+ var _this29 = this;
4481
4686
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
4482
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4483
- while (1) switch (_context27.prev = _context27.next) {
4687
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4688
+ while (1) switch (_context30.prev = _context30.next) {
4484
4689
  case 0:
4485
4690
  tempOrder = this.ensureTempOrder();
4486
4691
  if (identities.length) {
4487
- _context27.next = 3;
4692
+ _context30.next = 3;
4488
4693
  break;
4489
4694
  }
4490
- return _context27.abrupt("return", tempOrder.products);
4695
+ return _context30.abrupt("return", tempOrder.products);
4491
4696
  case 3:
4492
4697
  productsBeforeRemove = tempOrder.products || [];
4493
4698
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4517,29 +4722,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4517
4722
  }
4518
4723
  linkedBookingUidsToRemove = new Set();
4519
4724
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4520
- _context27.prev = 14;
4725
+ _context30.prev = 14;
4521
4726
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4522
4727
  var _metadata11, _metadata12, _metadata13, _metadata14;
4523
4728
  var product, productUid, productBookingUid, isAddTimeProduct;
4524
- return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4525
- while (1) switch (_context26.prev = _context26.next) {
4729
+ return _regeneratorRuntime().wrap(function _loop3$(_context29) {
4730
+ while (1) switch (_context29.prev = _context29.next) {
4526
4731
  case 0:
4527
4732
  product = _step21.value;
4528
4733
  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);
4529
4734
  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);
4530
4735
  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;
4531
4736
  if (!isAddTimeProduct) {
4532
- _context26.next = 6;
4737
+ _context29.next = 6;
4533
4738
  break;
4534
4739
  }
4535
- return _context26.abrupt("return", 1);
4740
+ return _context29.abrupt("return", 1);
4536
4741
  case 6:
4537
4742
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4538
4743
  linkedBookingUidsToRemove.add(String(productBookingUid));
4539
4744
  }
4540
4745
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4541
4746
  bookingsBeforeRemove.forEach(function (booking) {
4542
- var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4747
+ var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
4543
4748
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4544
4749
  linkedBookingUidsToRemove.add(bookingUid);
4545
4750
  }
@@ -4547,37 +4752,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4547
4752
  }
4548
4753
  case 8:
4549
4754
  case "end":
4550
- return _context26.stop();
4755
+ return _context29.stop();
4551
4756
  }
4552
4757
  }, _loop3);
4553
4758
  });
4554
4759
  _iterator21.s();
4555
4760
  case 17:
4556
4761
  if ((_step21 = _iterator21.n()).done) {
4557
- _context27.next = 23;
4762
+ _context30.next = 23;
4558
4763
  break;
4559
4764
  }
4560
- return _context27.delegateYield(_loop3(), "t0", 19);
4765
+ return _context30.delegateYield(_loop3(), "t0", 19);
4561
4766
  case 19:
4562
- if (!_context27.t0) {
4563
- _context27.next = 21;
4767
+ if (!_context30.t0) {
4768
+ _context30.next = 21;
4564
4769
  break;
4565
4770
  }
4566
- return _context27.abrupt("continue", 21);
4771
+ return _context30.abrupt("continue", 21);
4567
4772
  case 21:
4568
- _context27.next = 17;
4773
+ _context30.next = 17;
4569
4774
  break;
4570
4775
  case 23:
4571
- _context27.next = 28;
4776
+ _context30.next = 28;
4572
4777
  break;
4573
4778
  case 25:
4574
- _context27.prev = 25;
4575
- _context27.t1 = _context27["catch"](14);
4576
- _iterator21.e(_context27.t1);
4779
+ _context30.prev = 25;
4780
+ _context30.t1 = _context30["catch"](14);
4781
+ _iterator21.e(_context30.t1);
4577
4782
  case 28:
4578
- _context27.prev = 28;
4783
+ _context30.prev = 28;
4579
4784
  _iterator21.f();
4580
- return _context27.finish(28);
4785
+ return _context30.finish(28);
4581
4786
  case 31:
4582
4787
  if (linkedBookingUidsToRemove.size > 0) {
4583
4788
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4604,20 +4809,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4604
4809
  tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
4605
4810
  }
4606
4811
  }
4607
- _context27.next = 35;
4812
+ _context30.next = 35;
4608
4813
  return this.finalizeAfterProductsMutation(tempOrder);
4609
4814
  case 35:
4610
4815
  this.logInfo('removeProductsFromOrder success', {
4611
4816
  identities: identities
4612
4817
  });
4613
- return _context27.abrupt("return", tempOrder.products);
4818
+ return _context30.abrupt("return", tempOrder.products);
4614
4819
  case 37:
4615
4820
  case "end":
4616
- return _context27.stop();
4821
+ return _context30.stop();
4617
4822
  }
4618
- }, _callee24, this, [[14, 25, 28, 31]]);
4823
+ }, _callee27, this, [[14, 25, 28, 31]]);
4619
4824
  }));
4620
- function removeProductsFromOrder(_x31, _x32) {
4825
+ function removeProductsFromOrder(_x36, _x37) {
4621
4826
  return _removeProductsFromOrder.apply(this, arguments);
4622
4827
  }
4623
4828
  return removeProductsFromOrder;
@@ -4625,18 +4830,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4625
4830
  }, {
4626
4831
  key: "removeProductFromOrder",
4627
4832
  value: function () {
4628
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity, options) {
4629
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4630
- while (1) switch (_context28.prev = _context28.next) {
4833
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
4834
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4835
+ while (1) switch (_context31.prev = _context31.next) {
4631
4836
  case 0:
4632
- return _context28.abrupt("return", this.removeProductsFromOrder([identity], options));
4837
+ return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
4633
4838
  case 1:
4634
4839
  case "end":
4635
- return _context28.stop();
4840
+ return _context31.stop();
4636
4841
  }
4637
- }, _callee25, this);
4842
+ }, _callee28, this);
4638
4843
  }));
4639
- function removeProductFromOrder(_x33, _x34) {
4844
+ function removeProductFromOrder(_x38, _x39) {
4640
4845
  return _removeProductFromOrder.apply(this, arguments);
4641
4846
  }
4642
4847
  return removeProductFromOrder;
@@ -4648,10 +4853,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4648
4853
  }, {
4649
4854
  key: "clearOrderCartLines",
4650
4855
  value: (function () {
4651
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4856
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
4652
4857
  var tempOrder;
4653
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4654
- while (1) switch (_context29.prev = _context29.next) {
4858
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4859
+ while (1) switch (_context32.prev = _context32.next) {
4655
4860
  case 0:
4656
4861
  tempOrder = this.ensureTempOrder();
4657
4862
  tempOrder.products = [];
@@ -4662,24 +4867,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4662
4867
  productsByUid: {}
4663
4868
  });
4664
4869
  }
4665
- _context29.next = 7;
4870
+ _context32.next = 7;
4666
4871
  return this.applyPromotion();
4667
4872
  case 7:
4668
4873
  this.applyDiscount();
4669
4874
  this.sanitizeTempOrderProducts(tempOrder);
4670
- _context29.next = 11;
4875
+ _context32.next = 11;
4671
4876
  return this.recalculateSummary({
4672
4877
  createIfMissing: true
4673
4878
  });
4674
4879
  case 11:
4675
4880
  this.persistTempOrder();
4676
4881
  this.logInfo('clearOrderCartLines success', {});
4677
- return _context29.abrupt("return", tempOrder);
4882
+ return _context32.abrupt("return", tempOrder);
4678
4883
  case 14:
4679
4884
  case "end":
4680
- return _context29.stop();
4885
+ return _context32.stop();
4681
4886
  }
4682
- }, _callee26, this);
4887
+ }, _callee29, this);
4683
4888
  }));
4684
4889
  function clearOrderCartLines() {
4685
4890
  return _clearOrderCartLines.apply(this, arguments);
@@ -4690,23 +4895,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4690
4895
  }, {
4691
4896
  key: "buildCurrentSubmitPayloadForLocalPrint",
4692
4897
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4693
- var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
4898
+ var _params$cacheId, _this$otherParams3, _ref69, _params$businessCode, _this$otherParams4, _this$otherParams5;
4694
4899
  var tempOrder = this.ensureTempOrder();
4695
4900
  this.persistTempOrder();
4696
4901
  var payload = buildSubmitPayload({
4697
4902
  tempOrder: tempOrder,
4698
4903
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4699
4904
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
4700
- businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4905
+ businessCode: (_ref69 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4701
4906
  channel: params === null || params === void 0 ? void 0 : params.channel,
4702
4907
  type: params === null || params === void 0 ? void 0 : params.type,
4703
4908
  summary: this.store.summary || createEmptySummary(),
4704
4909
  enhance: function enhance(nextPayload) {
4705
- var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
4910
+ var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
4706
4911
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4707
- order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4708
- shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
4709
- shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
4912
+ order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4913
+ shop_order_number: (_ref71 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4914
+ shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
4710
4915
  small_ticket_data_flag: 1
4711
4916
  });
4712
4917
  }
@@ -4717,17 +4922,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4717
4922
  }, {
4718
4923
  key: "applyLocalPrintOrderNumbers",
4719
4924
  value: function () {
4720
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4925
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
4721
4926
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4722
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4723
- while (1) switch (_context30.prev = _context30.next) {
4927
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4928
+ while (1) switch (_context33.prev = _context33.next) {
4724
4929
  case 0:
4725
4930
  tempOrder = this.ensureTempOrder();
4726
4931
  if (!(!order || _typeof(order) !== 'object')) {
4727
- _context30.next = 3;
4932
+ _context33.next = 3;
4728
4933
  break;
4729
4934
  }
4730
- return _context30.abrupt("return", tempOrder);
4935
+ return _context33.abrupt("return", tempOrder);
4731
4936
  case 3:
4732
4937
  shopOrderNumber = order.shop_order_number;
4733
4938
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4738,21 +4943,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4738
4943
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4739
4944
  }
4740
4945
  this.persistTempOrder();
4741
- _context30.next = 10;
4946
+ _context33.next = 10;
4742
4947
  return this.saveDraft();
4743
4948
  case 10:
4744
- return _context30.abrupt("return", tempOrder);
4949
+ return _context33.abrupt("return", tempOrder);
4745
4950
  case 11:
4746
4951
  case "end":
4747
- return _context30.stop();
4952
+ return _context33.stop();
4748
4953
  }
4749
- }, _callee27, this);
4954
+ }, _callee30, this);
4750
4955
  }));
4751
- function applyLocalPrintOrderNumbers(_x35) {
4956
+ function applyLocalPrintOrderNumbers(_x40) {
4752
4957
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4753
4958
  }
4754
4959
  return applyLocalPrintOrderNumbers;
4755
4960
  }()
4961
+ }, {
4962
+ key: "saveTempOrderAsDraft",
4963
+ value: function () {
4964
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4965
+ var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4966
+ var tempOrder, latestSummary, payload;
4967
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4968
+ while (1) switch (_context34.prev = _context34.next) {
4969
+ case 0:
4970
+ tempOrder = this.ensureTempOrder();
4971
+ this.ensureExternalSaleNumber(tempOrder);
4972
+ this.persistTempOrder();
4973
+ _context34.next = 5;
4974
+ return this.recalculateSummary({
4975
+ createIfMissing: true
4976
+ });
4977
+ case 5:
4978
+ _context34.t1 = _context34.sent;
4979
+ if (_context34.t1) {
4980
+ _context34.next = 8;
4981
+ break;
4982
+ }
4983
+ _context34.t1 = this.store.summary;
4984
+ case 8:
4985
+ _context34.t0 = _context34.t1;
4986
+ if (_context34.t0) {
4987
+ _context34.next = 11;
4988
+ break;
4989
+ }
4990
+ _context34.t0 = createEmptySummary();
4991
+ case 11:
4992
+ latestSummary = _context34.t0;
4993
+ payload = buildSubmitPayload({
4994
+ tempOrder: tempOrder,
4995
+ cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
4996
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4997
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
4998
+ channel: params === null || params === void 0 ? void 0 : params.channel,
4999
+ 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,
5000
+ summary: latestSummary,
5001
+ enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
5002
+ });
5003
+ if (!payload.created_at) {
5004
+ payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5005
+ }
5006
+ payload.need_sync = 0;
5007
+ payload.is_draft_order = 1;
5008
+ this.logInfo('saveTempOrderAsDraft calling sales draft', {
5009
+ orderId: payload.order_id,
5010
+ externalSaleNumber: payload.external_sale_number,
5011
+ productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
5012
+ });
5013
+ return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
5014
+ osServer: true,
5015
+ customToast: function customToast() {}
5016
+ }));
5017
+ case 18:
5018
+ case "end":
5019
+ return _context34.stop();
5020
+ }
5021
+ }, _callee31, this);
5022
+ }));
5023
+ function saveTempOrderAsDraft(_x41) {
5024
+ return _saveTempOrderAsDraft.apply(this, arguments);
5025
+ }
5026
+ return saveTempOrderAsDraft;
5027
+ }()
4756
5028
  /**
4757
5029
  * 提交当前 Sales tempOrder。
4758
5030
  *
@@ -4762,18 +5034,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4762
5034
  }, {
4763
5035
  key: "submitTempOrder",
4764
5036
  value: (function () {
4765
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4766
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4767
- while (1) switch (_context31.prev = _context31.next) {
5037
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5038
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5039
+ while (1) switch (_context35.prev = _context35.next) {
4768
5040
  case 0:
4769
- return _context31.abrupt("return", this.runSubmitTempOrder(params));
5041
+ return _context35.abrupt("return", this.runSubmitTempOrder(params));
4770
5042
  case 1:
4771
5043
  case "end":
4772
- return _context31.stop();
5044
+ return _context35.stop();
4773
5045
  }
4774
- }, _callee28, this);
5046
+ }, _callee32, this);
4775
5047
  }));
4776
- function submitTempOrder(_x36) {
5048
+ function submitTempOrder(_x42) {
4777
5049
  return _submitTempOrder.apply(this, arguments);
4778
5050
  }
4779
5051
  return submitTempOrder;
@@ -4781,20 +5053,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4781
5053
  }, {
4782
5054
  key: "submitTempOrderAsync",
4783
5055
  value: function () {
4784
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4785
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4786
- while (1) switch (_context32.prev = _context32.next) {
5056
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5057
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5058
+ while (1) switch (_context36.prev = _context36.next) {
4787
5059
  case 0:
4788
- return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5060
+ return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4789
5061
  syncMode: true
4790
5062
  })));
4791
5063
  case 1:
4792
5064
  case "end":
4793
- return _context32.stop();
5065
+ return _context36.stop();
4794
5066
  }
4795
- }, _callee29, this);
5067
+ }, _callee33, this);
4796
5068
  }));
4797
- function submitTempOrderAsync(_x37) {
5069
+ function submitTempOrderAsync(_x43) {
4798
5070
  return _submitTempOrderAsync.apply(this, arguments);
4799
5071
  }
4800
5072
  return submitTempOrderAsync;
@@ -4802,11 +5074,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4802
5074
  }, {
4803
5075
  key: "runSubmitTempOrder",
4804
5076
  value: function () {
4805
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4806
- var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
5077
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5078
+ var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4807
5079
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4808
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4809
- while (1) switch (_context33.prev = _context33.next) {
5080
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5081
+ while (1) switch (_context37.prev = _context37.next) {
4810
5082
  case 0:
4811
5083
  tempOrder = this.ensureTempOrder();
4812
5084
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4826,27 +5098,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4826
5098
  }
4827
5099
  }
4828
5100
  this.persistTempOrder();
4829
- _context33.next = 8;
5101
+ _context37.next = 8;
4830
5102
  return this.recalculateSummary({
4831
5103
  createIfMissing: true
4832
5104
  });
4833
5105
  case 8:
4834
- _context33.t1 = _context33.sent;
4835
- if (_context33.t1) {
4836
- _context33.next = 11;
5106
+ _context37.t1 = _context37.sent;
5107
+ if (_context37.t1) {
5108
+ _context37.next = 11;
4837
5109
  break;
4838
5110
  }
4839
- _context33.t1 = this.store.summary;
5111
+ _context37.t1 = this.store.summary;
4840
5112
  case 11:
4841
- _context33.t0 = _context33.t1;
4842
- if (_context33.t0) {
4843
- _context33.next = 14;
5113
+ _context37.t0 = _context37.t1;
5114
+ if (_context37.t0) {
5115
+ _context37.next = 14;
4844
5116
  break;
4845
5117
  }
4846
- _context33.t0 = createEmptySummary();
5118
+ _context37.t0 = createEmptySummary();
4847
5119
  case 14:
4848
- latestSummary = _context33.t0;
4849
- effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
5120
+ latestSummary = _context37.t0;
5121
+ effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
4850
5122
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4851
5123
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
4852
5124
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
@@ -4864,8 +5136,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4864
5136
  payload = buildSubmitPayload({
4865
5137
  tempOrder: tempOrder,
4866
5138
  cacheId: effectiveCacheId,
4867
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4868
- 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,
5139
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5140
+ businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
4869
5141
  channel: params === null || params === void 0 ? void 0 : params.channel,
4870
5142
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4871
5143
  summary: latestSummary,
@@ -4880,10 +5152,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4880
5152
  if (!payload.created_at) {
4881
5153
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4882
5154
  }
4883
- _context33.next = 26;
5155
+ _context37.next = 26;
4884
5156
  return this.saveDraft();
4885
5157
  case 26:
4886
- _context33.prev = 26;
5158
+ _context37.prev = 26;
4887
5159
  this.logInfo('submitTempOrder calling sales checkout', {
4888
5160
  orderId: payload.order_id,
4889
5161
  externalSaleNumber: payload.external_sale_number,
@@ -4893,43 +5165,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4893
5165
  smallTicketDataFlag: payload.small_ticket_data_flag,
4894
5166
  syncMode: payload.sync_mode
4895
5167
  });
4896
- _context33.next = 30;
5168
+ _context37.next = 30;
4897
5169
  return this.submitSalesOrder({
4898
5170
  query: payload
4899
5171
  });
4900
5172
  case 30:
4901
- result = _context33.sent;
4902
- _context33.next = 43;
5173
+ result = _context37.sent;
5174
+ _context37.next = 43;
4903
5175
  break;
4904
5176
  case 33:
4905
- _context33.prev = 33;
4906
- _context33.t2 = _context33["catch"](26);
4907
- backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
5177
+ _context37.prev = 33;
5178
+ _context37.t2 = _context37["catch"](26);
5179
+ backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
4908
5180
  if (!backendErrorResponse) {
4909
- _context33.next = 40;
5181
+ _context37.next = 40;
4910
5182
  break;
4911
5183
  }
4912
5184
  this.store.syncState = 'failed';
4913
5185
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4914
- return _context33.abrupt("return", backendErrorResponse);
5186
+ return _context37.abrupt("return", backendErrorResponse);
4915
5187
  case 40:
4916
5188
  this.store.syncState = 'failed';
4917
5189
  this.logError('submitTempOrder failed', {
4918
- error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
5190
+ error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
4919
5191
  orderId: payload.order_id,
4920
5192
  externalSaleNumber: payload.external_sale_number,
4921
5193
  paymentStatus: payload.payment_status,
4922
5194
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4923
5195
  });
4924
- throw _context33.t2;
5196
+ throw _context37.t2;
4925
5197
  case 43:
4926
5198
  if (!this.isSubmitResponseRejected(result)) {
4927
- _context33.next = 47;
5199
+ _context37.next = 47;
4928
5200
  break;
4929
5201
  }
4930
5202
  this.store.syncState = 'failed';
4931
5203
  this.logSubmitBackendRejected(result, payload);
4932
- return _context33.abrupt("return", result);
5204
+ return _context37.abrupt("return", result);
4933
5205
  case 47:
4934
5206
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4935
5207
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4940,15 +5212,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4940
5212
  })
4941
5213
  });
4942
5214
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4943
- _context33.next = 56;
5215
+ _context37.next = 56;
4944
5216
  break;
4945
5217
  }
4946
5218
  tempOrder.order_id = submittedOrderId;
4947
5219
  resultRecord = result;
4948
- _context33.next = 54;
5220
+ _context37.next = 54;
4949
5221
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4950
5222
  case 54:
4951
- _context33.next = 57;
5223
+ _context37.next = 57;
4952
5224
  break;
4953
5225
  case 56:
4954
5226
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4957,14 +5229,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4957
5229
  this.store.syncState = 'submitted';
4958
5230
  }
4959
5231
  case 57:
4960
- return _context33.abrupt("return", result);
5232
+ return _context37.abrupt("return", result);
4961
5233
  case 58:
4962
5234
  case "end":
4963
- return _context33.stop();
5235
+ return _context37.stop();
4964
5236
  }
4965
- }, _callee30, this, [[26, 33]]);
5237
+ }, _callee34, this, [[26, 33]]);
4966
5238
  }));
4967
- function runSubmitTempOrder(_x38) {
5239
+ function runSubmitTempOrder(_x44) {
4968
5240
  return _runSubmitTempOrder.apply(this, arguments);
4969
5241
  }
4970
5242
  return runSubmitTempOrder;
@@ -4972,10 +5244,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4972
5244
  }, {
4973
5245
  key: "markLocalOrderSynced",
4974
5246
  value: function () {
4975
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
5247
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
4976
5248
  var tempOrder;
4977
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4978
- while (1) switch (_context34.prev = _context34.next) {
5249
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5250
+ while (1) switch (_context38.prev = _context38.next) {
4979
5251
  case 0:
4980
5252
  tempOrder = this.ensureTempOrder();
4981
5253
  tempOrder.order_id = orderId;
@@ -4983,15 +5255,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4983
5255
  this.store.lastOrderInfo = remoteOrder;
4984
5256
  this.store.syncState = 'submitted';
4985
5257
  this.persistTempOrder();
4986
- _context34.next = 8;
5258
+ _context38.next = 8;
4987
5259
  return this.saveDraft();
4988
5260
  case 8:
4989
5261
  case "end":
4990
- return _context34.stop();
5262
+ return _context38.stop();
4991
5263
  }
4992
- }, _callee31, this);
5264
+ }, _callee35, this);
4993
5265
  }));
4994
- function markLocalOrderSynced(_x39, _x40) {
5266
+ function markLocalOrderSynced(_x45, _x46) {
4995
5267
  return _markLocalOrderSynced.apply(this, arguments);
4996
5268
  }
4997
5269
  return markLocalOrderSynced;
@@ -5034,10 +5306,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5034
5306
  value: function extractSubmitErrorResponse(error) {
5035
5307
  var _error$response,
5036
5308
  _error$response2,
5037
- _this27 = this;
5309
+ _this30 = this;
5038
5310
  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];
5039
5311
  return candidates.find(function (candidate) {
5040
- return _this27.isSubmitErrorResponse(candidate);
5312
+ return _this30.isSubmitErrorResponse(candidate);
5041
5313
  }) || null;
5042
5314
  }
5043
5315
  }, {
@@ -5064,14 +5336,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5064
5336
  }, {
5065
5337
  key: "syncPaymentsToOrder",
5066
5338
  value: function () {
5067
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5068
- var _params$confirmPendin;
5069
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
5070
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5071
- while (1) switch (_context35.prev = _context35.next) {
5339
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5340
+ var _this31 = this,
5341
+ _params$confirmPendin;
5342
+ var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
5343
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5344
+ while (1) switch (_context39.prev = _context39.next) {
5072
5345
  case 0:
5073
5346
  tempOrder = this.ensureTempOrder();
5074
- mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
5347
+ needsPaymentNumber = (params.payments || []).some(function (payment) {
5348
+ return String(payment.payment_number || '').trim() === '';
5349
+ });
5350
+ if (!needsPaymentNumber) {
5351
+ _context39.next = 8;
5352
+ break;
5353
+ }
5354
+ _context39.next = 5;
5355
+ return this.getPaymentNumberDevicePrefixAsync();
5356
+ case 5:
5357
+ _context39.t0 = _context39.sent;
5358
+ _context39.next = 9;
5359
+ break;
5360
+ case 8:
5361
+ _context39.t0 = 'LOCAL';
5362
+ case 9:
5363
+ devicePrefix = _context39.t0;
5364
+ mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5365
+ return _this31.normalizePaymentSource(payment, {
5366
+ defaultPaid: false,
5367
+ devicePrefix: devicePrefix
5368
+ });
5369
+ }));
5075
5370
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
5076
5371
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
5077
5372
  completion = this.getPaymentCompletion(effectivePayments);
@@ -5080,24 +5375,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5080
5375
  tempOrder.payments = effectivePayments;
5081
5376
  tempOrder.payment_status = paymentStatus;
5082
5377
  this.persistTempOrder();
5083
- _context35.next = 12;
5378
+ _context39.next = 21;
5084
5379
  return this.saveDraft();
5085
- case 12:
5380
+ case 21:
5086
5381
  if (params.submitWhenPaid) {
5087
- _context35.next = 14;
5382
+ _context39.next = 23;
5088
5383
  break;
5089
5384
  }
5090
- return _context35.abrupt("return", completion);
5091
- case 14:
5385
+ return _context39.abrupt("return", completion);
5386
+ case 23:
5092
5387
  if (!(this.store.syncState === 'submitting')) {
5093
- _context35.next = 16;
5388
+ _context39.next = 25;
5094
5389
  break;
5095
5390
  }
5096
- return _context35.abrupt("return", completion);
5097
- case 16:
5391
+ return _context39.abrupt("return", completion);
5392
+ case 25:
5098
5393
  this.store.syncState = 'submitting';
5099
5394
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
5100
- _context35.next = 20;
5395
+ _context39.next = 29;
5101
5396
  return this.submitTempOrder({
5102
5397
  payments: effectivePayments,
5103
5398
  paymentStatus: paymentStatus,
@@ -5112,18 +5407,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5112
5407
  return nextPayload;
5113
5408
  }
5114
5409
  });
5115
- case 20:
5116
- submitResult = _context35.sent;
5117
- return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5410
+ case 29:
5411
+ submitResult = _context39.sent;
5412
+ return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5118
5413
  submitResult: submitResult
5119
5414
  }));
5120
- case 22:
5415
+ case 31:
5121
5416
  case "end":
5122
- return _context35.stop();
5417
+ return _context39.stop();
5123
5418
  }
5124
- }, _callee32, this);
5419
+ }, _callee36, this);
5125
5420
  }));
5126
- function syncPaymentsToOrder(_x41) {
5421
+ function syncPaymentsToOrder(_x47) {
5127
5422
  return _syncPaymentsToOrder.apply(this, arguments);
5128
5423
  }
5129
5424
  return syncPaymentsToOrder;
@@ -5212,11 +5507,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5212
5507
  }, {
5213
5508
  key: "submitOrder",
5214
5509
  value: function () {
5215
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5510
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
5216
5511
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5217
5512
  var url, query, fetchUrl, params;
5218
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5219
- while (1) switch (_context36.prev = _context36.next) {
5513
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5514
+ while (1) switch (_context40.prev = _context40.next) {
5220
5515
  case 0:
5221
5516
  this.logInfo('submitOrder called', {
5222
5517
  url: order.url,
@@ -5236,14 +5531,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5236
5531
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5237
5532
  scheduleDate: params.schedule_date
5238
5533
  });
5239
- return _context36.abrupt("return", this.request.post(fetchUrl, params));
5534
+ return _context40.abrupt("return", this.request.post(fetchUrl, params));
5240
5535
  case 6:
5241
5536
  case "end":
5242
- return _context36.stop();
5537
+ return _context40.stop();
5243
5538
  }
5244
- }, _callee33, this);
5539
+ }, _callee37, this);
5245
5540
  }));
5246
- function submitOrder(_x42) {
5541
+ function submitOrder(_x48) {
5247
5542
  return _submitOrder.apply(this, arguments);
5248
5543
  }
5249
5544
  return submitOrder;
@@ -5251,13 +5546,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5251
5546
  }, {
5252
5547
  key: "cancelOrder",
5253
5548
  value: function () {
5254
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5549
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5255
5550
  var payload;
5256
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5257
- while (1) switch (_context37.prev = _context37.next) {
5551
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5552
+ while (1) switch (_context41.prev = _context41.next) {
5258
5553
  case 0:
5259
5554
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5260
- _context37.next = 2;
5555
+ _context41.next = 2;
5261
5556
  break;
5262
5557
  }
5263
5558
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5273,16 +5568,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5273
5568
  method: 'PUT',
5274
5569
  orderIdsCount: params.order_ids.length
5275
5570
  });
5276
- return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5571
+ return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
5277
5572
  isShopApi: true
5278
5573
  }));
5279
5574
  case 5:
5280
5575
  case "end":
5281
- return _context37.stop();
5576
+ return _context41.stop();
5282
5577
  }
5283
- }, _callee34, this);
5578
+ }, _callee38, this);
5284
5579
  }));
5285
- function cancelOrder(_x43) {
5580
+ function cancelOrder(_x49) {
5286
5581
  return _cancelOrder.apply(this, arguments);
5287
5582
  }
5288
5583
  return cancelOrder;
@@ -5290,19 +5585,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5290
5585
  }, {
5291
5586
  key: "changeBookingStatus",
5292
5587
  value: function () {
5293
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5588
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5294
5589
  var url, payload;
5295
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5296
- while (1) switch (_context38.prev = _context38.next) {
5590
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5591
+ while (1) switch (_context42.prev = _context42.next) {
5297
5592
  case 0:
5298
5593
  if (params.booking_id) {
5299
- _context38.next = 2;
5594
+ _context42.next = 2;
5300
5595
  break;
5301
5596
  }
5302
5597
  throw new Error('变更预约状态失败:booking_id 不能为空');
5303
5598
  case 2:
5304
5599
  if (params.appointment_status) {
5305
- _context38.next = 4;
5600
+ _context42.next = 4;
5306
5601
  break;
5307
5602
  }
5308
5603
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5317,16 +5612,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5317
5612
  bookingId: params.booking_id,
5318
5613
  appointmentStatus: params.appointment_status
5319
5614
  });
5320
- return _context38.abrupt("return", this.request.put(url, payload, {
5615
+ return _context42.abrupt("return", this.request.put(url, payload, {
5321
5616
  isShopApi: true
5322
5617
  }));
5323
5618
  case 8:
5324
5619
  case "end":
5325
- return _context38.stop();
5620
+ return _context42.stop();
5326
5621
  }
5327
- }, _callee35, this);
5622
+ }, _callee39, this);
5328
5623
  }));
5329
- function changeBookingStatus(_x44) {
5624
+ function changeBookingStatus(_x50) {
5330
5625
  return _changeBookingStatus.apply(this, arguments);
5331
5626
  }
5332
5627
  return changeBookingStatus;
@@ -5344,11 +5639,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5344
5639
  }, {
5345
5640
  key: "createOrderByCheckout",
5346
5641
  value: (function () {
5347
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5642
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5348
5643
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5349
5644
  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;
5350
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5351
- while (1) switch (_context39.prev = _context39.next) {
5645
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5646
+ while (1) switch (_context43.prev = _context43.next) {
5352
5647
  case 0:
5353
5648
  // 过滤掉由在线店铺下单的 payment 支付数据
5354
5649
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5382,7 +5677,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5382
5677
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5383
5678
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5384
5679
  });
5385
- _context39.prev = 4;
5680
+ _context43.prev = 4;
5386
5681
  // 构建订单数据,设置默认值并允许 params 覆盖
5387
5682
  orderData = _objectSpread({
5388
5683
  sales_channel: 'my_pisel',
@@ -5444,13 +5739,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5444
5739
  hasOrderId: !!orderData.order_id,
5445
5740
  smallTicketDataFlag: orderData.small_ticket_data_flag
5446
5741
  });
5447
- _context39.next = 12;
5742
+ _context43.next = 12;
5448
5743
  return this.request.post('/order/checkout', orderData, {
5449
5744
  osServer: true,
5450
5745
  customToast: function customToast() {}
5451
5746
  });
5452
5747
  case 12:
5453
- response = _context39.sent;
5748
+ response = _context43.sent;
5454
5749
  this.logInfo('Order API called successfully', {
5455
5750
  response: response
5456
5751
  });
@@ -5458,22 +5753,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5458
5753
  success: !!response,
5459
5754
  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)
5460
5755
  });
5461
- return _context39.abrupt("return", response);
5756
+ return _context43.abrupt("return", response);
5462
5757
  case 18:
5463
- _context39.prev = 18;
5464
- _context39.t0 = _context39["catch"](4);
5465
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5758
+ _context43.prev = 18;
5759
+ _context43.t0 = _context43["catch"](4);
5760
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
5466
5761
  this.logInfo('Order API called failed', {
5467
- error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5762
+ error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
5468
5763
  });
5469
- throw _context39.t0;
5764
+ throw _context43.t0;
5470
5765
  case 23:
5471
5766
  case "end":
5472
- return _context39.stop();
5767
+ return _context43.stop();
5473
5768
  }
5474
- }, _callee36, this, [[4, 18]]);
5769
+ }, _callee40, this, [[4, 18]]);
5475
5770
  }));
5476
- function createOrderByCheckout(_x45) {
5771
+ function createOrderByCheckout(_x51) {
5477
5772
  return _createOrderByCheckout.apply(this, arguments);
5478
5773
  }
5479
5774
  return createOrderByCheckout;
@@ -5481,24 +5776,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5481
5776
  }, {
5482
5777
  key: "submitSalesOrder",
5483
5778
  value: function () {
5484
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5779
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5485
5780
  var url, query, fetchUrl;
5486
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5487
- while (1) switch (_context40.prev = _context40.next) {
5781
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5782
+ while (1) switch (_context44.prev = _context44.next) {
5488
5783
  case 0:
5489
5784
  url = params.url, query = params.query;
5490
5785
  fetchUrl = url || '/order/sales/checkout';
5491
- return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5786
+ return _context44.abrupt("return", this.request.post(fetchUrl, query, {
5492
5787
  osServer: true,
5493
5788
  customToast: function customToast() {}
5494
5789
  }));
5495
5790
  case 3:
5496
5791
  case "end":
5497
- return _context40.stop();
5792
+ return _context44.stop();
5498
5793
  }
5499
- }, _callee37, this);
5794
+ }, _callee41, this);
5500
5795
  }));
5501
- function submitSalesOrder(_x46) {
5796
+ function submitSalesOrder(_x52) {
5502
5797
  return _submitSalesOrder.apply(this, arguments);
5503
5798
  }
5504
5799
  return submitSalesOrder;
@@ -5512,37 +5807,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5512
5807
  }, {
5513
5808
  key: "sendCustomerPayLink",
5514
5809
  value: (function () {
5515
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5810
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5516
5811
  var _params$emails;
5517
5812
  var orderIds;
5518
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5519
- while (1) switch (_context41.prev = _context41.next) {
5813
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
5814
+ while (1) switch (_context45.prev = _context45.next) {
5520
5815
  case 0:
5521
5816
  orderIds = params.order_ids || params.orderIds || [];
5522
5817
  if (orderIds.length) {
5523
- _context41.next = 3;
5818
+ _context45.next = 3;
5524
5819
  break;
5525
5820
  }
5526
5821
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5527
5822
  case 3:
5528
5823
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5529
- _context41.next = 5;
5824
+ _context45.next = 5;
5530
5825
  break;
5531
5826
  }
5532
5827
  throw new Error('发送支付链接需要至少一个邮箱');
5533
5828
  case 5:
5534
- return _context41.abrupt("return", this.request.post('/order/batch-email', {
5829
+ return _context45.abrupt("return", this.request.post('/order/batch-email', {
5535
5830
  order_ids: orderIds,
5536
5831
  notify_action: params.notify_action || 'order_payment_reminder',
5537
5832
  emails: params.emails
5538
5833
  }));
5539
5834
  case 6:
5540
5835
  case "end":
5541
- return _context41.stop();
5836
+ return _context45.stop();
5542
5837
  }
5543
- }, _callee38, this);
5838
+ }, _callee42, this);
5544
5839
  }));
5545
- function sendCustomerPayLink(_x47) {
5840
+ function sendCustomerPayLink(_x53) {
5546
5841
  return _sendCustomerPayLink.apply(this, arguments);
5547
5842
  }
5548
5843
  return sendCustomerPayLink;
@@ -5550,14 +5845,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5550
5845
  }, {
5551
5846
  key: "getSalesOrderByLookup",
5552
5847
  value: function () {
5553
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5848
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5554
5849
  var lookup, res;
5555
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5556
- while (1) switch (_context42.prev = _context42.next) {
5850
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
5851
+ while (1) switch (_context46.prev = _context46.next) {
5557
5852
  case 0:
5558
5853
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5559
5854
  if (lookup) {
5560
- _context42.next = 3;
5855
+ _context46.next = 3;
5561
5856
  break;
5562
5857
  }
5563
5858
  throw new Error('加载销售详情需要 lookup');
@@ -5566,27 +5861,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5566
5861
  if (lookup.startsWith('LOCAL_')) {
5567
5862
  params.forceRemote = false;
5568
5863
  }
5569
- _context42.next = 6;
5864
+ _context46.next = 6;
5570
5865
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5571
- with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5866
+ with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
5572
5867
  }, params.forceRemote ? {
5573
5868
  forceRemote: true
5574
5869
  } : {}), {
5575
5870
  osServer: true
5576
5871
  });
5577
5872
  case 6:
5578
- res = _context42.sent;
5873
+ res = _context46.sent;
5579
5874
  if (res.code === 200) {
5580
5875
  this.store.lastOrderInfo = res.data;
5581
5876
  }
5582
- return _context42.abrupt("return", res);
5877
+ return _context46.abrupt("return", res);
5583
5878
  case 9:
5584
5879
  case "end":
5585
- return _context42.stop();
5880
+ return _context46.stop();
5586
5881
  }
5587
- }, _callee39, this);
5882
+ }, _callee43, this);
5588
5883
  }));
5589
- function getSalesOrderByLookup(_x48) {
5884
+ function getSalesOrderByLookup(_x54) {
5590
5885
  return _getSalesOrderByLookup.apply(this, arguments);
5591
5886
  }
5592
5887
  return getSalesOrderByLookup;
@@ -5600,11 +5895,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5600
5895
  }, {
5601
5896
  key: "hydrateTempOrderFromRecord",
5602
5897
  value: (function () {
5603
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5604
- var _this$store$discount19;
5605
- var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5606
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5607
- while (1) switch (_context43.prev = _context43.next) {
5898
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
5899
+ var _this$store$discount20;
5900
+ var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
5901
+ return _regeneratorRuntime().wrap(function _callee44$(_context47) {
5902
+ while (1) switch (_context47.prev = _context47.next) {
5608
5903
  case 0:
5609
5904
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5610
5905
  identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
@@ -5629,7 +5924,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5629
5924
  }
5630
5925
  nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5631
5926
  makeEditMark: true
5632
- });
5927
+ }); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
5928
+ sourceLastOrderInfo = raw.lastOrderInfo || raw;
5929
+ isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
5930
+ syntheticIdentityOptions = {
5931
+ isDraftOrder: isDraftOrder,
5932
+ externalSaleNumber: nextTempOrder.external_sale_number
5933
+ };
5633
5934
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5634
5935
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5635
5936
  return _objectSpread({}, s || {});
@@ -5649,12 +5950,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5649
5950
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5650
5951
  }
5651
5952
  });
5652
- // lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
5653
- // Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
5654
- // rewrite this protocol snapshot as a side effect of hydration.
5655
- this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
5953
+ this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5954
+ hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5955
+ if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
5956
+ this.store.syncState = 'local';
5957
+ }
5656
5958
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5657
- 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() || [] : [];
5959
+ currentDiscounts = typeof ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5658
5960
  currentScanDiscounts = currentDiscounts.filter(function (discount) {
5659
5961
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
5660
5962
  });
@@ -5667,34 +5969,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5667
5969
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5668
5970
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5669
5971
  if (shouldSkipEmptyDiscountSync) {
5670
- _context43.next = 26;
5972
+ _context47.next = 31;
5671
5973
  break;
5672
5974
  }
5673
5975
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5674
- _context43.next = 24;
5675
- return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5676
- case 24:
5677
- _context43.next = 26;
5678
- return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5679
- case 26:
5976
+ _context47.next = 29;
5977
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
5978
+ case 29:
5979
+ _context47.next = 31;
5980
+ return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
5981
+ case 31:
5680
5982
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5681
- _context43.next = 29;
5983
+ _context47.next = 34;
5682
5984
  break;
5683
5985
  }
5684
- _context43.next = 29;
5986
+ _context47.next = 34;
5685
5987
  return this.recalculateSummary({
5686
5988
  createIfMissing: false
5687
5989
  });
5688
- case 29:
5990
+ case 34:
5689
5991
  this.persistTempOrder();
5690
- return _context43.abrupt("return", nextTempOrder);
5691
- case 31:
5992
+ return _context47.abrupt("return", nextTempOrder);
5993
+ case 36:
5692
5994
  case "end":
5693
- return _context43.stop();
5995
+ return _context47.stop();
5694
5996
  }
5695
- }, _callee40, this);
5997
+ }, _callee44, this);
5696
5998
  }));
5697
- function hydrateTempOrderFromRecord(_x49, _x50) {
5999
+ function hydrateTempOrderFromRecord(_x55, _x56) {
5698
6000
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5699
6001
  }
5700
6002
  return hydrateTempOrderFromRecord;
@@ -5808,11 +6110,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5808
6110
  }, {
5809
6111
  key: "normalizeTempOrderForRuntime",
5810
6112
  value: function normalizeTempOrderForRuntime(raw, options) {
5811
- var _this28 = this;
5812
- var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
6113
+ var _this32 = this;
6114
+ var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6115
+ var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
5813
6116
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5814
- 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) {
5815
- nextTempOrder.order_id = raw.id;
6117
+ 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) {
6118
+ nextTempOrder.order_id = runtimeRaw.id;
5816
6119
  }
5817
6120
  delete nextTempOrder.summary;
5818
6121
  delete nextTempOrder.lastOrderInfo;
@@ -5831,12 +6134,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5831
6134
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5832
6135
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5833
6136
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5834
- return _this28.normalizeHydratedOrderProduct(p, {
6137
+ return _this32.normalizeHydratedOrderProduct(p, {
5835
6138
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5836
6139
  });
5837
6140
  }) : [];
5838
6141
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5839
- var booking = _this28.normalizeHydratedBookingHolder(b || {});
6142
+ var booking = _this32.normalizeHydratedBookingHolder(b || {});
5840
6143
  return _objectSpread(_objectSpread({}, booking), {}, {
5841
6144
  is_all: normalizeBookingIsAll(booking),
5842
6145
  sub_type: normalizeBookingSubType(booking)
@@ -5866,7 +6169,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5866
6169
  _step24;
5867
6170
  try {
5868
6171
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
5869
- var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
6172
+ var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
5870
6173
  var _step24$value = _slicedToArray(_step24.value, 2),
5871
6174
  index = _step24$value[0],
5872
6175
  product = _step24$value[1];
@@ -5874,7 +6177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5874
6177
  if (!uid) continue;
5875
6178
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5876
6179
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5877
- 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;
6180
+ var origin = (_ref75 = (_ref76 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref76 !== void 0 ? _ref76 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref75 !== void 0 ? _ref75 : rawProduct;
5878
6181
  var originSnapshot = cloneDeep(origin);
5879
6182
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5880
6183
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5902,6 +6205,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5902
6205
  nextTempOrder.vouchers = raw.vouchers || [];
5903
6206
  return nextTempOrder;
5904
6207
  }
6208
+ }, {
6209
+ key: "isSyntheticDraftOrderIdForRuntime",
6210
+ value: function isSyntheticDraftOrderIdForRuntime(record, options) {
6211
+ var _options$isDraftOrder, _record$external_sale;
6212
+ 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;
6213
+ 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;
6214
+ var orderId = record === null || record === void 0 ? void 0 : record.order_id;
6215
+ return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
6216
+ }
6217
+ }, {
6218
+ key: "withoutSyntheticDraftOrderIdForRuntime",
6219
+ value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
6220
+ if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
6221
+ return _objectSpread(_objectSpread({}, record), {}, {
6222
+ order_id: null
6223
+ });
6224
+ }
5905
6225
  }, {
5906
6226
  key: "hydrateLinkedBookingIdentity",
5907
6227
  value: function hydrateLinkedBookingIdentity(tempOrder) {
@@ -5986,10 +6306,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5986
6306
  }, {
5987
6307
  key: "normalizeHydratedProductOptionItem",
5988
6308
  value: function normalizeHydratedProductOptionItem(optionItem) {
5989
- var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
5990
- 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;
6309
+ var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
6310
+ var rawNum = (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 1;
5991
6311
  var parsedNum = Number(rawNum);
5992
- 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;
6312
+ var rawPrice = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0;
5993
6313
  var parsedPrice = Number(rawPrice);
5994
6314
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5995
6315
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6006,7 +6326,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6006
6326
  }, {
6007
6327
  key: "normalizeHydratedOrderProduct",
6008
6328
  value: function normalizeHydratedOrderProduct(product, options) {
6009
- var _this29 = this;
6329
+ var _this33 = this;
6010
6330
  var row = _objectSpread({}, product || {});
6011
6331
  if (row.num === undefined && row.product_quantity !== undefined) {
6012
6332
  row.num = row.product_quantity;
@@ -6014,7 +6334,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6014
6334
  var productSku = ensureProductSku(row);
6015
6335
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
6016
6336
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
6017
- return _this29.normalizeHydratedProductOptionItem(optionItem || {});
6337
+ return _this33.normalizeHydratedProductOptionItem(optionItem || {});
6018
6338
  }))
6019
6339
  });
6020
6340
  delete row["product_".concat('option', "_item")];
@@ -6051,27 +6371,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6051
6371
  }, {
6052
6372
  key: "getOrderInfo",
6053
6373
  value: function () {
6054
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
6374
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
6055
6375
  var res;
6056
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6057
- while (1) switch (_context44.prev = _context44.next) {
6376
+ return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6377
+ while (1) switch (_context48.prev = _context48.next) {
6058
6378
  case 0:
6059
- _context44.next = 2;
6379
+ _context48.next = 2;
6060
6380
  return this.request.get("/order/sales/".concat(order_id), {
6061
6381
  with: ['products', 'bookings']
6062
6382
  }, {
6063
6383
  osServer: true
6064
6384
  });
6065
6385
  case 2:
6066
- res = _context44.sent;
6067
- return _context44.abrupt("return", res);
6386
+ res = _context48.sent;
6387
+ return _context48.abrupt("return", res);
6068
6388
  case 4:
6069
6389
  case "end":
6070
- return _context44.stop();
6390
+ return _context48.stop();
6071
6391
  }
6072
- }, _callee41, this);
6392
+ }, _callee45, this);
6073
6393
  }));
6074
- function getOrderInfo(_x51) {
6394
+ function getOrderInfo(_x57) {
6075
6395
  return _getOrderInfo.apply(this, arguments);
6076
6396
  }
6077
6397
  return getOrderInfo;
@@ -6130,10 +6450,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6130
6450
  _step29;
6131
6451
  try {
6132
6452
  for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6133
- var _ref80, _bundle$num3;
6134
6453
  var bundle = _step29.value;
6135
6454
  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));
6136
- 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();
6455
+ var bundleQty = Number(qty) || 1;
6137
6456
  var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6138
6457
  _step30;
6139
6458
  try {