@pisell/pisellos 2.3.27 → 2.3.29

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 (83) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/Discount/index.d.ts +5 -2
  14. package/dist/modules/Discount/index.js +30 -7
  15. package/dist/modules/Discount/types.d.ts +4 -0
  16. package/dist/modules/Order/index.d.ts +7 -1
  17. package/dist/modules/Order/index.js +187 -74
  18. package/dist/modules/Order/types.d.ts +2 -0
  19. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  21. package/dist/modules/Order/utils.d.ts +2 -1
  22. package/dist/modules/Order/utils.js +2 -8
  23. package/dist/modules/Product/types.d.ts +22 -0
  24. package/dist/modules/ProductList/index.d.ts +1 -1
  25. package/dist/modules/ProductList/index.js +4 -2
  26. package/dist/modules/ProductList/types.d.ts +2 -0
  27. package/dist/server/index.d.ts +50 -0
  28. package/dist/server/index.js +995 -749
  29. package/dist/server/modules/order/index.d.ts +10 -4
  30. package/dist/server/modules/order/index.js +404 -399
  31. package/dist/server/modules/products/index.d.ts +26 -7
  32. package/dist/server/modules/products/index.js +167 -76
  33. package/dist/server/modules/products/types.d.ts +14 -0
  34. package/dist/solution/BaseSales/index.d.ts +9 -1
  35. package/dist/solution/BaseSales/index.js +998 -756
  36. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  37. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  38. package/dist/solution/BookingByStep/index.d.ts +1 -1
  39. package/dist/solution/BookingTicket/index.d.ts +14 -2
  40. package/dist/solution/BookingTicket/types.d.ts +2 -0
  41. package/dist/solution/ShopDiscount/index.js +15 -14
  42. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  43. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  44. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  46. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  48. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  50. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  52. package/lib/model/strategy/adapter/index.d.ts +4 -0
  53. package/lib/model/strategy/adapter/index.js +13 -2
  54. package/lib/modules/Discount/index.d.ts +5 -2
  55. package/lib/modules/Discount/index.js +23 -3
  56. package/lib/modules/Discount/types.d.ts +4 -0
  57. package/lib/modules/Order/index.d.ts +7 -1
  58. package/lib/modules/Order/index.js +104 -6
  59. package/lib/modules/Order/types.d.ts +2 -0
  60. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  61. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  62. package/lib/modules/Order/utils.d.ts +2 -1
  63. package/lib/modules/Order/utils.js +4 -11
  64. package/lib/modules/Product/types.d.ts +22 -0
  65. package/lib/modules/ProductList/index.d.ts +1 -1
  66. package/lib/modules/ProductList/index.js +4 -2
  67. package/lib/modules/ProductList/types.d.ts +2 -0
  68. package/lib/server/index.d.ts +50 -0
  69. package/lib/server/index.js +206 -29
  70. package/lib/server/modules/order/index.d.ts +10 -4
  71. package/lib/server/modules/order/index.js +199 -141
  72. package/lib/server/modules/products/index.d.ts +26 -7
  73. package/lib/server/modules/products/index.js +114 -35
  74. package/lib/server/modules/products/types.d.ts +14 -0
  75. package/lib/solution/BaseSales/index.d.ts +9 -1
  76. package/lib/solution/BaseSales/index.js +229 -54
  77. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  78. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingTicket/index.d.ts +14 -2
  81. package/lib/solution/BookingTicket/types.d.ts +2 -0
  82. package/lib/solution/ShopDiscount/index.js +2 -1
  83. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- 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; } } }; }
2
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
3
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
@@ -20,9 +19,10 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
20
19
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
20
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
22
21
  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."); }
23
- 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); }
24
22
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
25
23
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
+ 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; } } }; }
25
+ 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); }
26
26
  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
27
  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; }
28
28
  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; }
@@ -37,6 +37,7 @@ import Decimal from 'decimal.js';
37
37
  import { cloneDeep, mergeWith } from 'lodash-es';
38
38
  import { createModule } from "../BookingByStep/types";
39
39
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
40
+ import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
40
41
  import dayjs from 'dayjs';
41
42
  export * from "./types";
42
43
  import { QuotationModule } from "../../modules/Quotation";
@@ -71,9 +72,15 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
71
72
  function isBaseSalesHistoricalDiscountEntry(discount) {
72
73
  return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
73
74
  }
74
- function getBaseSalesUniqueArrayMetadataKey(key) {
75
- if (key === 'products' || key === 'bookings') return 'unique_identification_number';
76
- if (key === 'payments' || key === 'payment') return 'unique_payment_number';
75
+ var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
76
+ product: 'order_detail_id',
77
+ booking: 'schedule_event_id',
78
+ payment: 'order_payment_id'
79
+ };
80
+ function getBaseSalesOrderCollectionKind(key) {
81
+ if (key === 'products') return 'product';
82
+ if (key === 'bookings') return 'booking';
83
+ if (key === 'payments' || key === 'payment') return 'payment';
77
84
  return null;
78
85
  }
79
86
  function isSameBaseSalesOrderRecord(left, right) {
@@ -86,12 +93,6 @@ function isSameBaseSalesOrderRecord(left, right) {
86
93
  return value !== undefined && value !== null && value !== '' && leftIdentities.has(String(value));
87
94
  });
88
95
  }
89
- function getBaseSalesMetadataUid(item, metadataKey) {
90
- var _item$metadata$metada, _item$metadata;
91
- var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
92
- if (uid === undefined || uid === null || uid === '') return null;
93
- return String(uid);
94
- }
95
96
  function isBaseSalesBlankValue(value) {
96
97
  return value === undefined || value === null || value === '';
97
98
  }
@@ -109,36 +110,102 @@ function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
109
110
  }
110
111
  return mergedItem;
111
112
  }
112
- function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, arrayKey) {
113
- var result = [];
114
- var indexByUid = new Map();
115
- var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
116
- var clonedItem = cloneDeep(item);
117
- var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
118
- if (!uid) {
119
- result.push(clonedItem);
120
- return;
113
+ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps) {
114
+ var currentReferenceUid = getOrderCollectionReferenceUid(kind, currentItem);
115
+ var incomingReferenceUid = getOrderCollectionReferenceUid(kind, incomingItem);
116
+ var identityMergedItem = mergeOrderCollectionItems(kind, currentItem, incomingItem);
117
+ var mergedUid = getOrderCollectionUid(kind, identityMergedItem);
118
+ if (mergedUid) {
119
+ var _iterator = _createForOfIteratorHelper(new Set([currentReferenceUid, incomingReferenceUid])),
120
+ _step;
121
+ try {
122
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
123
+ var from = _step.value;
124
+ if (!from || from === mergedUid) continue;
125
+ uidRemaps.push({
126
+ kind: kind,
127
+ from: from,
128
+ to: mergedUid,
129
+ persistentId: getOrderCollectionPersistentId(kind, incomingItem) || getOrderCollectionPersistentId(kind, currentItem)
130
+ });
131
+ }
132
+ } catch (err) {
133
+ _iterator.e(err);
134
+ } finally {
135
+ _iterator.f();
121
136
  }
122
- var existingIndex = indexByUid.get(uid);
123
- if (existingIndex !== undefined) {
124
- result[existingIndex] = arrayKey === 'products' ? mergeBaseSalesProductSnapshotFields(result[existingIndex], clonedItem) : clonedItem;
137
+ }
138
+ var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
139
+ var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
140
+ if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
141
+ mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
142
+ }
143
+ return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
144
+ }
145
+ function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
146
+ var currentItems = normalizeOrderCollection(kind, currentValue, {
147
+ ensureUid: false
148
+ }).items;
149
+ var incomingItems = normalizeOrderCollection(kind, incomingValue, {
150
+ ensureUid: false
151
+ }).items;
152
+ if (strategy === 'authoritative-incoming') {
153
+ var _result = cloneDeep(incomingItems);
154
+ currentItems.forEach(function (currentItem) {
155
+ var incomingIndex = _result.findIndex(function (incomingItem) {
156
+ return isSameOrderCollectionItem(kind, currentItem, incomingItem);
157
+ });
158
+ if (incomingIndex !== -1) {
159
+ _result[incomingIndex] = mergeBaseSalesCollectionItem(kind, currentItem, _result[incomingIndex], uidRemaps);
160
+ return;
161
+ }
162
+
163
+ // 完整服务端快照负责已落库行;仅保留尚未提交的本地新行。
164
+ if (!getOrderCollectionPersistentId(kind, currentItem)) {
165
+ _result.push(cloneDeep(currentItem));
166
+ }
167
+ });
168
+ return _result;
169
+ }
170
+ var result = cloneDeep(currentItems);
171
+ incomingItems.forEach(function (incomingItem) {
172
+ var currentIndex = result.findIndex(function (currentItem) {
173
+ return isSameOrderCollectionItem(kind, currentItem, incomingItem);
174
+ });
175
+ if (currentIndex !== -1) {
176
+ result[currentIndex] = mergeBaseSalesCollectionItem(kind, result[currentIndex], incomingItem, uidRemaps);
125
177
  return;
126
178
  }
127
- indexByUid.set(uid, result.length);
128
- result.push(clonedItem);
129
- };
130
- currentValue.forEach(appendOrReplaceByUid);
131
- loadedValue.forEach(appendOrReplaceByUid);
179
+ result.push(cloneDeep(incomingItem));
180
+ });
132
181
  return result;
133
182
  }
134
- function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
135
- if (!currentTempOrder) return loadedRecord;
136
- var mergedRecord = mergeWith(cloneDeep(currentTempOrder), cloneDeep(loadedRecord || {}), function (currentValue, loadedValue, key) {
183
+ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
184
+ var normalizedRecord = normalizeOrderCollections(cloneDeep(sourceRecord || {}), options).order;
185
+
186
+ // 兼容旧调用方偶尔使用的单数 payment 字段。
187
+ if (Array.isArray(normalizedRecord.payment)) {
188
+ normalizedRecord.payment = normalizeOrderCollection('payment', normalizedRecord.payment, options).items;
189
+ }
190
+ return normalizedRecord;
191
+ }
192
+ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
193
+ var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
194
+ ensureUid: false
195
+ });
196
+ if (!currentTempOrder) {
197
+ return normalizeBaseSalesRecordCollections(normalizedLoadedRecord);
198
+ }
199
+ var normalizedCurrentTempOrder = normalizeBaseSalesRecordCollections(currentTempOrder, {
200
+ ensureUid: false
201
+ });
202
+ var uidRemaps = [];
203
+ var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
204
+ var collectionKind = getBaseSalesOrderCollectionKind(key);
205
+ if (collectionKind && Array.isArray(loadedValue)) {
206
+ return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
207
+ }
137
208
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
138
- var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
139
- if (metadataKey) {
140
- return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey, key);
141
- }
142
209
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
143
210
  }
144
211
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -148,7 +215,7 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
148
215
  return undefined;
149
216
  });
150
217
  delete mergedRecord.request_unique_idempotency_token;
151
- return mergedRecord;
218
+ return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
152
219
  }
153
220
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
154
221
  _inherits(BaseSalesImpl, _BaseModule);
@@ -184,9 +251,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
184
251
  _defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
185
252
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
186
253
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
187
- _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlight", false);
254
+ _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
255
+ _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
256
+ _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
188
257
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
189
258
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
259
+ _defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
190
260
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
191
261
  return _this;
192
262
  }
@@ -281,75 +351,139 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
281
351
  key: "setServerOrderChangeSyncEnabled",
282
352
  value: function setServerOrderChangeSyncEnabled(enabled) {
283
353
  this.serverOrderChangeSyncEnabled = enabled;
354
+ if (!enabled) this.queuedServerOrderChanges = [];
284
355
  }
356
+ }, {
357
+ key: "queueLatestServerOrderChange",
358
+ value: function queueLatestServerOrderChange(order) {
359
+ var snapshot = cloneDeep(order);
360
+ var existingIndex = this.queuedServerOrderChanges.findIndex(function (queued) {
361
+ return isSameBaseSalesOrderRecord(queued, snapshot);
362
+ });
363
+ if (existingIndex >= 0) {
364
+ this.queuedServerOrderChanges[existingIndex] = snapshot;
365
+ return;
366
+ }
367
+ this.queuedServerOrderChanges.push(snapshot);
368
+ }
369
+ }, {
370
+ key: "drainQueuedServerOrderChanges",
371
+ value: function () {
372
+ var _drainQueuedServerOrderChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
373
+ var changedOrders;
374
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
375
+ while (1) switch (_context.prev = _context.next) {
376
+ case 0:
377
+ if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
378
+ _context.next = 2;
379
+ break;
380
+ }
381
+ return _context.abrupt("return");
382
+ case 2:
383
+ changedOrders = this.queuedServerOrderChanges;
384
+ this.queuedServerOrderChanges = [];
385
+ _context.next = 6;
386
+ return this.syncCurrentSalesDetailFromServerOrderChange({
387
+ changedOrders: changedOrders
388
+ });
389
+ case 6:
390
+ case "end":
391
+ return _context.stop();
392
+ }
393
+ }, _callee, this);
394
+ }));
395
+ function drainQueuedServerOrderChanges() {
396
+ return _drainQueuedServerOrderChanges.apply(this, arguments);
397
+ }
398
+ return drainQueuedServerOrderChanges;
399
+ }()
285
400
  }, {
286
401
  key: "syncCurrentSalesDetailFromServerOrderChange",
287
402
  value: function () {
288
- var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
403
+ var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
289
404
  var _this2 = this;
290
405
  var changedOrders, changedOrder;
291
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
292
- while (1) switch (_context2.prev = _context2.next) {
406
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
407
+ while (1) switch (_context3.prev = _context3.next) {
293
408
  case 0:
294
409
  changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
295
- if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
296
- _context2.next = 3;
410
+ if (this.serverOrderChangeSyncEnabled) {
411
+ _context3.next = 3;
297
412
  break;
298
413
  }
299
- return _context2.abrupt("return");
414
+ return _context3.abrupt("return");
300
415
  case 3:
416
+ if (!(this.salesDetailLoadInFlightCount > 0)) {
417
+ _context3.next = 6;
418
+ break;
419
+ }
420
+ changedOrders.forEach(function (order) {
421
+ return _this2.queueLatestServerOrderChange(order);
422
+ });
423
+ return _context3.abrupt("return");
424
+ case 6:
301
425
  changedOrder = changedOrders.find(function (order) {
302
426
  return _this2.isCurrentSalesOrderRecord(order);
303
427
  });
304
428
  if (changedOrder) {
305
- _context2.next = 6;
429
+ _context3.next = 9;
306
430
  break;
307
431
  }
308
- return _context2.abrupt("return");
309
- case 6:
432
+ return _context3.abrupt("return");
433
+ case 9:
434
+ if (!this.serverOrderChangeHydrateInFlight) {
435
+ _context3.next = 12;
436
+ break;
437
+ }
438
+ this.queueLatestServerOrderChange(changedOrder);
439
+ return _context3.abrupt("return");
440
+ case 12:
310
441
  if (this.store.order) {
311
- _context2.next = 8;
442
+ _context3.next = 14;
312
443
  break;
313
444
  }
314
- return _context2.abrupt("return");
315
- case 8:
316
- this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
445
+ return _context3.abrupt("return");
446
+ case 14:
447
+ this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
317
448
  var _getTempOrder, _ref2;
318
449
  var currentTempOrder, record, sales;
319
- return _regeneratorRuntime().wrap(function _callee$(_context) {
320
- while (1) switch (_context.prev = _context.next) {
450
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
451
+ while (1) switch (_context2.prev = _context2.next) {
321
452
  case 0:
322
453
  currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
323
- record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder);
324
- _context.next = 4;
454
+ record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
455
+ _context2.next = 4;
325
456
  return _this2.store.order.hydrateTempOrderFromRecord(record, {
326
457
  recalcOnHydrate: false
327
458
  });
328
459
  case 4:
329
- sales = _context.sent;
460
+ sales = _context2.sent;
330
461
  _this2.currentSalesDetail = sales;
331
- _context.next = 8;
462
+ _context2.next = 8;
332
463
  return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
333
464
  sales: sales
334
465
  });
335
466
  case 8:
336
467
  case "end":
337
- return _context.stop();
468
+ return _context2.stop();
338
469
  }
339
- }, _callee);
470
+ }, _callee2);
340
471
  }))();
341
- _context2.prev = 9;
342
- _context2.next = 12;
472
+ _context3.prev = 15;
473
+ _context3.next = 18;
343
474
  return this.serverOrderChangeHydrateInFlight;
344
- case 12:
345
- _context2.prev = 12;
475
+ case 18:
476
+ _context3.prev = 18;
346
477
  this.serverOrderChangeHydrateInFlight = null;
347
- return _context2.finish(12);
348
- case 15:
478
+ _context3.next = 22;
479
+ return this.drainQueuedServerOrderChanges();
480
+ case 22:
481
+ return _context3.finish(18);
482
+ case 23:
349
483
  case "end":
350
- return _context2.stop();
484
+ return _context3.stop();
351
485
  }
352
- }, _callee2, this, [[9,, 12, 15]]);
486
+ }, _callee3, this, [[15,, 18, 23]]);
353
487
  }));
354
488
  function syncCurrentSalesDetailFromServerOrderChange(_x) {
355
489
  return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
@@ -366,13 +500,100 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
366
500
  var effects = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.effects;
367
501
  if (!effects || typeof effects.on !== 'function') return;
368
502
  this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, function (payload) {
369
- void _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
503
+ return _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
370
504
  _this3.logError('sync sales detail from server order change failed', {
371
505
  error: error instanceof Error ? error.message : String(error)
372
506
  });
373
507
  });
374
508
  });
375
509
  }
510
+ }, {
511
+ key: "hydrateLatestLoadedSalesDetail",
512
+ value: function () {
513
+ var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
514
+ var _this4 = this;
515
+ var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
516
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
517
+ while (1) switch (_context5.prev = _context5.next) {
518
+ case 0:
519
+ hydratedSales = null;
520
+ skippedBeforeHydrate = false;
521
+ hydrateTask = /*#__PURE__*/function () {
522
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
523
+ var sales;
524
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
525
+ while (1) switch (_context4.prev = _context4.next) {
526
+ case 0:
527
+ if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
528
+ _context4.next = 3;
529
+ break;
530
+ }
531
+ skippedBeforeHydrate = true;
532
+ return _context4.abrupt("return");
533
+ case 3:
534
+ if (_this4.store.order) {
535
+ _context4.next = 5;
536
+ break;
537
+ }
538
+ throw new Error('order 模块未初始化');
539
+ case 5:
540
+ _context4.next = 7;
541
+ return _this4.store.order.hydrateTempOrderFromRecord(record, {
542
+ recalcOnHydrate: false
543
+ });
544
+ case 7:
545
+ sales = _context4.sent;
546
+ hydratedSales = sales;
547
+
548
+ // hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
549
+ if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
550
+ _context4.next = 11;
551
+ break;
552
+ }
553
+ return _context4.abrupt("return");
554
+ case 11:
555
+ _this4.currentSalesDetail = sales;
556
+ _context4.next = 14;
557
+ return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
558
+ sales: sales
559
+ });
560
+ case 14:
561
+ case "end":
562
+ return _context4.stop();
563
+ }
564
+ }, _callee4);
565
+ }));
566
+ return function hydrateTask() {
567
+ return _ref3.apply(this, arguments);
568
+ };
569
+ }();
570
+ queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
571
+ this.salesDetailHydrateQueue = queuedTask.then(function () {
572
+ return undefined;
573
+ }, function () {
574
+ return undefined;
575
+ });
576
+ _context5.next = 7;
577
+ return queuedTask;
578
+ case 7:
579
+ if (!skippedBeforeHydrate) {
580
+ _context5.next = 9;
581
+ break;
582
+ }
583
+ return _context5.abrupt("return", record);
584
+ case 9:
585
+ return _context5.abrupt("return", hydratedSales || this.currentSalesDetail || record);
586
+ case 10:
587
+ case "end":
588
+ return _context5.stop();
589
+ }
590
+ }, _callee5, this);
591
+ }));
592
+ function hydrateLatestLoadedSalesDetail(_x2, _x3) {
593
+ return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
594
+ }
595
+ return hydrateLatestLoadedSalesDetail;
596
+ }()
376
597
  }, {
377
598
  key: "hydrateOrderPaymentNames",
378
599
  value: function hydrateOrderPaymentNames(payments) {
@@ -437,10 +658,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
437
658
  });
438
659
  }
439
660
  quotation.setScheduleResolver(function (id) {
440
- var _scheduleModule$getSc, _getScheduleByIds, _ref3;
661
+ var _scheduleModule$getSc, _getScheduleByIds, _ref4;
441
662
  var scheduleId = String(id);
442
663
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
443
- var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref3 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref3, [id])) || [];
664
+ var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
444
665
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
445
666
  return schedules[0];
446
667
  });
@@ -448,30 +669,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
448
669
  }, {
449
670
  key: "loadQuotationForPriceQuery",
450
671
  value: function () {
451
- var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
672
+ var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
452
673
  var _this$otherParams;
453
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
454
- while (1) switch (_context3.prev = _context3.next) {
674
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
675
+ while (1) switch (_context6.prev = _context6.next) {
455
676
  case 0:
456
677
  if (params.quotation) {
457
- _context3.next = 2;
678
+ _context6.next = 2;
458
679
  break;
459
680
  }
460
- return _context3.abrupt("return");
681
+ return _context6.abrupt("return");
461
682
  case 2:
462
683
  this.applyQuotationScheduleResolver(params.quotation);
463
- _context3.next = 5;
684
+ _context6.next = 5;
464
685
  return params.quotation.loadQuotations({
465
686
  channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
466
687
  customer_id: params.customer_id
467
688
  });
468
689
  case 5:
469
690
  case "end":
470
- return _context3.stop();
691
+ return _context6.stop();
471
692
  }
472
- }, _callee3, this);
693
+ }, _callee6, this);
473
694
  }));
474
- function loadQuotationForPriceQuery(_x2) {
695
+ function loadQuotationForPriceQuery(_x4) {
475
696
  return _loadQuotationForPriceQuery.apply(this, arguments);
476
697
  }
477
698
  return loadQuotationForPriceQuery;
@@ -515,23 +736,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
515
736
  }, {
516
737
  key: "loadProductsForPriceQuery",
517
738
  value: function () {
518
- var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
739
+ var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
519
740
  var ids, productsById, _this$otherParams2, _response$data, response, list;
520
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
521
- while (1) switch (_context4.prev = _context4.next) {
741
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
742
+ while (1) switch (_context7.prev = _context7.next) {
522
743
  case 0:
523
744
  ids = Array.from(new Set(params.ids.filter(function (id) {
524
745
  return Number.isFinite(id);
525
746
  })));
526
747
  productsById = new Map();
527
748
  if (!(!ids.length || !this.request)) {
528
- _context4.next = 4;
749
+ _context7.next = 4;
529
750
  break;
530
751
  }
531
- return _context4.abrupt("return", productsById);
752
+ return _context7.abrupt("return", productsById);
532
753
  case 4:
533
- _context4.prev = 4;
534
- _context4.next = 7;
754
+ _context7.prev = 4;
755
+ _context7.next = 7;
535
756
  return this.request.post('/product/query', {
536
757
  ids: ids,
537
758
  open_quotation: 1,
@@ -548,35 +769,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
548
769
  customToast: function customToast() {}
549
770
  });
550
771
  case 7:
551
- response = _context4.sent;
772
+ response = _context7.sent;
552
773
  list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
553
774
  if (Array.isArray(list)) {
554
- _context4.next = 11;
775
+ _context7.next = 11;
555
776
  break;
556
777
  }
557
- return _context4.abrupt("return", productsById);
778
+ return _context7.abrupt("return", productsById);
558
779
  case 11:
559
780
  list.forEach(function (item) {
560
781
  var _item$id;
561
782
  var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
562
783
  if (Number.isFinite(productId)) productsById.set(productId, item);
563
784
  });
564
- return _context4.abrupt("return", productsById);
785
+ return _context7.abrupt("return", productsById);
565
786
  case 15:
566
- _context4.prev = 15;
567
- _context4.t0 = _context4["catch"](4);
787
+ _context7.prev = 15;
788
+ _context7.t0 = _context7["catch"](4);
568
789
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
569
790
  ids: ids,
570
- error: _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0)
791
+ error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
571
792
  });
572
- return _context4.abrupt("return", productsById);
793
+ return _context7.abrupt("return", productsById);
573
794
  case 19:
574
795
  case "end":
575
- return _context4.stop();
796
+ return _context7.stop();
576
797
  }
577
- }, _callee4, this, [[4, 15]]);
798
+ }, _callee7, this, [[4, 15]]);
578
799
  }));
579
- function loadProductsForPriceQuery(_x3) {
800
+ function loadProductsForPriceQuery(_x5) {
580
801
  return _loadProductsForPriceQuery.apply(this, arguments);
581
802
  }
582
803
  return loadProductsForPriceQuery;
@@ -584,21 +805,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
584
805
  }, {
585
806
  key: "loadProductForPriceQuery",
586
807
  value: function () {
587
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params, customerId) {
808
+ var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
588
809
  var product, productId, schedule, productsById;
589
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
590
- while (1) switch (_context5.prev = _context5.next) {
810
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
811
+ while (1) switch (_context8.prev = _context8.next) {
591
812
  case 0:
592
813
  product = params.product || {};
593
814
  productId = this.getPriceQueryProductId(product);
594
815
  if (!(productId === null || !this.request)) {
595
- _context5.next = 4;
816
+ _context8.next = 4;
596
817
  break;
597
818
  }
598
- return _context5.abrupt("return", null);
819
+ return _context8.abrupt("return", null);
599
820
  case 4:
600
821
  schedule = this.getPriceQuerySchedule(params);
601
- _context5.next = 7;
822
+ _context8.next = 7;
602
823
  return this.loadProductsForPriceQuery({
603
824
  ids: [productId],
604
825
  schedule: schedule,
@@ -606,15 +827,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
606
827
  channel: params.channel
607
828
  });
608
829
  case 7:
609
- productsById = _context5.sent;
610
- return _context5.abrupt("return", productsById.get(productId) || null);
830
+ productsById = _context8.sent;
831
+ return _context8.abrupt("return", productsById.get(productId) || null);
611
832
  case 9:
612
833
  case "end":
613
- return _context5.stop();
834
+ return _context8.stop();
614
835
  }
615
- }, _callee5, this);
836
+ }, _callee8, this);
616
837
  }));
617
- function loadProductForPriceQuery(_x4, _x5) {
838
+ function loadProductForPriceQuery(_x6, _x7) {
618
839
  return _loadProductForPriceQuery.apply(this, arguments);
619
840
  }
620
841
  return loadProductForPriceQuery;
@@ -627,10 +848,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
627
848
  return groups.flatMap(function (group) {
628
849
  var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
629
850
  return items.map(function (item) {
630
- var _item$group_id, _ref4, _item$bundle_group_id;
851
+ var _item$group_id, _ref5, _item$bundle_group_id;
631
852
  return _objectSpread(_objectSpread({}, item), {}, {
632
853
  group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
633
- bundle_group_id: (_ref4 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref4 !== void 0 ? _ref4 : group === null || group === void 0 ? void 0 : group.id
854
+ bundle_group_id: (_ref5 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
634
855
  });
635
856
  });
636
857
  });
@@ -661,21 +882,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
661
882
  }, {
662
883
  key: "getAuthoritativeBundleUnitPrice",
663
884
  value: function getAuthoritativeBundleUnitPrice(bundle) {
664
- var _ref5, _ref6, _ref7, _bundle$price;
665
- return (_ref5 = (_ref6 = (_ref7 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.custom_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.product_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.base_price;
885
+ var _ref6, _ref7, _ref8, _bundle$price;
886
+ return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
666
887
  }
667
888
  }, {
668
889
  key: "mergeProductForPriceQuery",
669
890
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
670
- var _this4 = this,
891
+ var _this5 = this,
671
892
  _product$id,
672
- _ref8,
673
- _product$product_id2,
674
893
  _ref9,
675
- _product$product_vari,
894
+ _product$product_id2,
676
895
  _ref10,
677
- _product$num,
896
+ _product$product_vari,
678
897
  _ref11,
898
+ _product$num,
899
+ _ref12,
679
900
  _product$quantity,
680
901
  _product$metadata4;
681
902
  if (!authoritativeProduct) return product;
@@ -683,8 +904,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
683
904
  var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
684
905
  var productBundle = selectedBundles.map(function (bundle) {
685
906
  var _authoritativeBundle$, _authoritativeBundle$2;
686
- var authoritativeBundle = _this4.findAuthoritativeBundleItem(bundle, authoritativeBundles);
687
- var unitPrice = authoritativeBundle ? _this4.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
907
+ var authoritativeBundle = _this5.findAuthoritativeBundleItem(bundle, authoritativeBundles);
908
+ var unitPrice = authoritativeBundle ? _this5.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
688
909
  if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
689
910
  return _objectSpread(_objectSpread({}, bundle), {}, {
690
911
  price: unitPrice,
@@ -695,10 +916,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
695
916
  });
696
917
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
697
918
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
698
- product_id: (_ref8 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.id,
699
- product_variant_id: (_ref9 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0,
700
- num: (_ref10 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref10 !== void 0 ? _ref10 : authoritativeProduct.num,
701
- quantity: (_ref11 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.quantity,
919
+ product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
920
+ product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
921
+ num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
922
+ quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
702
923
  product_sku: function () {
703
924
  var authoritativeSku = ensureProductSku(authoritativeProduct);
704
925
  var productSku = ensureProductSku(product);
@@ -772,61 +993,61 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
772
993
  }, {
773
994
  key: "syncOtherParamsToSubModules",
774
995
  value: (function () {
775
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
776
- var _this5 = this;
777
- var _ref12,
778
- _ref12$cover,
996
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
997
+ var _this6 = this;
998
+ var _ref13,
999
+ _ref13$cover,
779
1000
  cover,
780
1001
  nextSubModuleOtherParams,
781
- _args7 = arguments;
782
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
783
- while (1) switch (_context7.prev = _context7.next) {
1002
+ _args10 = arguments;
1003
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1004
+ while (1) switch (_context10.prev = _context10.next) {
784
1005
  case 0:
785
- _ref12 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
1006
+ _ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
786
1007
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
787
- _context7.next = 4;
1008
+ _context10.next = 4;
788
1009
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
789
- var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref13) {
790
- var _ref15, moduleName, subModule, targetModule;
791
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
792
- while (1) switch (_context6.prev = _context6.next) {
1010
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
1011
+ var _ref16, moduleName, subModule, targetModule;
1012
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1013
+ while (1) switch (_context9.prev = _context9.next) {
793
1014
  case 0:
794
- _ref15 = _slicedToArray(_ref13, 2), moduleName = _ref15[0], subModule = _ref15[1];
795
- if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
796
- _context6.next = 3;
1015
+ _ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
1016
+ if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1017
+ _context9.next = 3;
797
1018
  break;
798
1019
  }
799
- return _context6.abrupt("return");
1020
+ return _context9.abrupt("return");
800
1021
  case 3:
801
1022
  targetModule = subModule;
802
1023
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
803
- _context6.next = 6;
1024
+ _context9.next = 6;
804
1025
  break;
805
1026
  }
806
- return _context6.abrupt("return");
1027
+ return _context9.abrupt("return");
807
1028
  case 6:
808
- _context6.next = 8;
1029
+ _context9.next = 8;
809
1030
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
810
1031
  changedParams: changedParams,
811
1032
  cover: cover
812
1033
  });
813
1034
  case 8:
814
1035
  case "end":
815
- return _context6.stop();
1036
+ return _context9.stop();
816
1037
  }
817
- }, _callee6);
1038
+ }, _callee9);
818
1039
  }));
819
- return function (_x7) {
820
- return _ref14.apply(this, arguments);
1040
+ return function (_x9) {
1041
+ return _ref15.apply(this, arguments);
821
1042
  };
822
1043
  }()));
823
1044
  case 4:
824
1045
  case "end":
825
- return _context7.stop();
1046
+ return _context10.stop();
826
1047
  }
827
- }, _callee7, this);
1048
+ }, _callee10, this);
828
1049
  }));
829
- function syncOtherParamsToSubModules(_x6) {
1050
+ function syncOtherParamsToSubModules(_x8) {
830
1051
  return _syncOtherParamsToSubModules.apply(this, arguments);
831
1052
  }
832
1053
  return syncOtherParamsToSubModules;
@@ -900,19 +1121,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
900
1121
  }, {
901
1122
  key: "initialize",
902
1123
  value: function () {
903
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(core) {
1124
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
904
1125
  var _this$otherParams4,
905
- _this6 = this,
1126
+ _this7 = this,
906
1127
  _this$otherParams5;
907
1128
  var options,
908
1129
  app,
909
1130
  targetCacheData,
910
1131
  moduleNames,
911
- _args8 = arguments;
912
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
913
- while (1) switch (_context8.prev = _context8.next) {
1132
+ _args11 = arguments;
1133
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1134
+ while (1) switch (_context11.prev = _context11.next) {
914
1135
  case 0:
915
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1136
+ options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
916
1137
  this.core = core;
917
1138
  this.initializeOptions = options || {};
918
1139
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
@@ -925,7 +1146,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
925
1146
  // 获取 logger 实例
926
1147
  this.appPlugin = core.getPlugin('app');
927
1148
  if (this.appPlugin) {
928
- _context8.next = 11;
1149
+ _context11.next = 11;
929
1150
  break;
930
1151
  }
931
1152
  throw new Error('Checkout 解决方案需要 app 插件支持');
@@ -935,48 +1156,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
935
1156
  targetCacheData = this.readSessionCacheData();
936
1157
  moduleNames = this.getRegisteredModuleNames();
937
1158
  moduleNames.forEach(function (step) {
938
- var reusedModule = _this6.getReusableSharedSubModule(step);
1159
+ var reusedModule = _this7.getReusableSharedSubModule(step);
939
1160
  if (reusedModule) {
940
- _this6.store[step] = reusedModule;
941
- _this6.reusedSharedSubModuleNames.add(step);
1161
+ _this7.store[step] = reusedModule;
1162
+ _this7.reusedSharedSubModuleNames.add(step);
942
1163
  return;
943
1164
  }
944
- var targetModule = _this6.createSubModule(step);
1165
+ var targetModule = _this7.createSubModule(step);
945
1166
  if (!targetModule) {
946
1167
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
947
1168
  }
948
- var hooks = _this6.getSubModuleHooks(step);
949
- _this6.store[step] = targetModule;
950
- _this6.core.registerModule(targetModule, _objectSpread(_objectSpread({
1169
+ var hooks = _this7.getSubModuleHooks(step);
1170
+ _this7.store[step] = targetModule;
1171
+ _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
951
1172
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
952
1173
  }, hooks ? {
953
1174
  hooks: hooks
954
1175
  } : {}), {}, {
955
- otherParams: _this6.buildSubModuleOtherParams()
1176
+ otherParams: _this7.buildSubModuleOtherParams()
956
1177
  }));
957
1178
  });
958
1179
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
959
- _context8.next = 19;
1180
+ _context11.next = 19;
960
1181
  break;
961
1182
  }
962
- _context8.next = 19;
1183
+ _context11.next = 19;
963
1184
  return this.store.schedule.loadAllSchedule();
964
1185
  case 19:
965
1186
  if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
966
1187
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
967
1188
  }
968
- _context8.next = 22;
1189
+ _context11.next = 22;
969
1190
  return this.getPaymentMethodsAsync();
970
1191
  case 22:
971
1192
  this.registerServerOrderChangeSync();
972
1193
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
973
1194
  case 24:
974
1195
  case "end":
975
- return _context8.stop();
1196
+ return _context11.stop();
976
1197
  }
977
- }, _callee8, this);
1198
+ }, _callee11, this);
978
1199
  }));
979
- function initialize(_x8) {
1200
+ function initialize(_x10) {
980
1201
  return _initialize.apply(this, arguments);
981
1202
  }
982
1203
  return initialize;
@@ -984,17 +1205,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
984
1205
  }, {
985
1206
  key: "destroy",
986
1207
  value: function () {
987
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1208
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
988
1209
  var _this$serverOrderChan2,
989
- _this7 = this;
990
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
991
- while (1) switch (_context9.prev = _context9.next) {
1210
+ _this8 = this;
1211
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1212
+ while (1) switch (_context12.prev = _context12.next) {
992
1213
  case 0:
993
1214
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
994
1215
  this.serverOrderChangeUnsubscribe = null;
995
1216
  Object.keys(this.store).forEach(function (key) {
996
- if (_this7.reusedSharedSubModuleNames.has(key)) return;
997
- var sub = _this7.store[key];
1217
+ if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
+ var sub = _this8.store[key];
998
1219
  if (sub && typeof sub.destroy === 'function') {
999
1220
  try {
1000
1221
  sub.destroy();
@@ -1004,15 +1225,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1004
1225
  }
1005
1226
  });
1006
1227
  this.currentSalesDetail = null;
1007
- _context9.next = 6;
1228
+ this.queuedServerOrderChanges = [];
1229
+ this.salesDetailLoadSequence += 1;
1230
+ _context12.next = 8;
1008
1231
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1009
- case 6:
1232
+ case 8:
1010
1233
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1011
- case 7:
1234
+ case 9:
1012
1235
  case "end":
1013
- return _context9.stop();
1236
+ return _context12.stop();
1014
1237
  }
1015
- }, _callee9, this);
1238
+ }, _callee12, this);
1016
1239
  }));
1017
1240
  function destroy() {
1018
1241
  return _destroy.apply(this, arguments);
@@ -1029,82 +1252,91 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1029
1252
  }, {
1030
1253
  key: "loadSalesDetail",
1031
1254
  value: (function () {
1032
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderIdOrParams) {
1033
- var _ref16, _ref17, _ref18, _ref19, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
1034
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1035
- while (1) switch (_context10.prev = _context10.next) {
1255
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1256
+ var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1257
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1258
+ while (1) switch (_context13.prev = _context13.next) {
1036
1259
  case 0:
1037
1260
  if (this.store.order) {
1038
- _context10.next = 2;
1261
+ _context13.next = 2;
1039
1262
  break;
1040
1263
  }
1041
1264
  throw new Error('order 模块未初始化');
1042
1265
  case 2:
1043
- this.salesDetailLoadInFlight = true;
1044
- _context10.prev = 3;
1266
+ loadSequence = ++this.salesDetailLoadSequence;
1267
+ this.salesDetailLoadInFlightCount += 1;
1268
+ _context13.prev = 4;
1045
1269
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
1046
1270
  orderId: orderIdOrParams
1047
1271
  };
1048
1272
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1049
1273
  preloadedSalesDetail = params.preloadedSalesDetail;
1050
- lookup = (_ref16 = (_ref17 = (_ref18 = (_ref19 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref19 !== void 0 ? _ref19 : params.orderNumber) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref16 !== void 0 ? _ref16 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1274
+ lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1051
1275
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1052
- _context10.next = 10;
1276
+ _context13.next = 11;
1053
1277
  break;
1054
1278
  }
1055
1279
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
1056
- case 10:
1280
+ case 11:
1057
1281
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
1058
- _context10.next = 14;
1282
+ _context13.next = 15;
1059
1283
  break;
1060
1284
  }
1061
- _context10.t0 = preloadedSalesDetail;
1062
- _context10.next = 17;
1285
+ _context13.t0 = preloadedSalesDetail;
1286
+ _context13.next = 18;
1063
1287
  break;
1064
- case 14:
1065
- _context10.next = 16;
1288
+ case 15:
1289
+ _context13.next = 17;
1066
1290
  return this.store.order.getSalesOrderByLookup({
1067
1291
  lookup: lookup,
1068
1292
  forceRemote: params.forceRemote
1069
1293
  });
1070
- case 16:
1071
- _context10.t0 = _context10.sent;
1072
1294
  case 17:
1073
- loadedRecord = _context10.t0;
1295
+ _context13.t0 = _context13.sent;
1296
+ case 18:
1297
+ loadedRecord = _context13.t0;
1074
1298
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
1075
- _context10.next = 21;
1299
+ _context13.next = 22;
1076
1300
  break;
1077
1301
  }
1078
1302
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1079
1303
  throw new Error(message);
1080
- case 21:
1304
+ case 22:
1081
1305
  remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1082
1306
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1083
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
1084
- _context10.next = 26;
1085
- return this.store.order.hydrateTempOrderFromRecord(record, {
1086
- recalcOnHydrate: false
1087
- });
1088
- case 26:
1089
- sales = _context10.sent;
1090
- this.currentSalesDetail = sales;
1091
- _context10.next = 30;
1092
- return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
1093
- sales: sales
1094
- });
1095
- case 30:
1096
- return _context10.abrupt("return", sales);
1097
- case 31:
1098
- _context10.prev = 31;
1099
- this.salesDetailLoadInFlight = false;
1100
- return _context10.finish(31);
1307
+ record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1308
+ _context13.next = 27;
1309
+ return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1310
+ case 27:
1311
+ return _context13.abrupt("return", _context13.sent);
1312
+ case 28:
1313
+ _context13.prev = 28;
1314
+ this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1315
+ if (!(this.salesDetailLoadInFlightCount === 0)) {
1316
+ _context13.next = 39;
1317
+ break;
1318
+ }
1319
+ _context13.prev = 31;
1320
+ _context13.next = 34;
1321
+ return this.drainQueuedServerOrderChanges();
1101
1322
  case 34:
1323
+ _context13.next = 39;
1324
+ break;
1325
+ case 36:
1326
+ _context13.prev = 36;
1327
+ _context13.t1 = _context13["catch"](31);
1328
+ this.logError('drain queued server order changes failed', {
1329
+ error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1330
+ });
1331
+ case 39:
1332
+ return _context13.finish(28);
1333
+ case 40:
1102
1334
  case "end":
1103
- return _context10.stop();
1335
+ return _context13.stop();
1104
1336
  }
1105
- }, _callee10, this, [[3,, 31, 34]]);
1337
+ }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1106
1338
  }));
1107
- function loadSalesDetail(_x9) {
1339
+ function loadSalesDetail(_x11) {
1108
1340
  return _loadSalesDetail.apply(this, arguments);
1109
1341
  }
1110
1342
  return loadSalesDetail;
@@ -1184,34 +1416,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1184
1416
  }, {
1185
1417
  key: "replaceTempOrder",
1186
1418
  value: function () {
1187
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder) {
1419
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
1188
1420
  var nextTempOrder;
1189
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1190
- while (1) switch (_context11.prev = _context11.next) {
1421
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1422
+ while (1) switch (_context14.prev = _context14.next) {
1191
1423
  case 0:
1192
1424
  if (this.store.order) {
1193
- _context11.next = 2;
1425
+ _context14.next = 2;
1194
1426
  break;
1195
1427
  }
1196
1428
  throw new Error('order 模块未初始化');
1197
1429
  case 2:
1198
- _context11.next = 4;
1430
+ _context14.next = 4;
1199
1431
  return this.store.order.replaceTempOrder(tempOrder);
1200
1432
  case 4:
1201
- nextTempOrder = _context11.sent;
1202
- _context11.next = 7;
1433
+ nextTempOrder = _context14.sent;
1434
+ _context14.next = 7;
1203
1435
  return this.effectsEmit('onTempOrderReplaced', {
1204
1436
  tempOrder: nextTempOrder
1205
1437
  });
1206
1438
  case 7:
1207
- return _context11.abrupt("return", nextTempOrder);
1439
+ return _context14.abrupt("return", nextTempOrder);
1208
1440
  case 8:
1209
1441
  case "end":
1210
- return _context11.stop();
1442
+ return _context14.stop();
1211
1443
  }
1212
- }, _callee11, this);
1444
+ }, _callee14, this);
1213
1445
  }));
1214
- function replaceTempOrder(_x10) {
1446
+ function replaceTempOrder(_x12) {
1215
1447
  return _replaceTempOrder.apply(this, arguments);
1216
1448
  }
1217
1449
  return replaceTempOrder;
@@ -1309,40 +1541,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1309
1541
  }, {
1310
1542
  key: "addNewOrder",
1311
1543
  value: function () {
1312
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1544
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1313
1545
  var tempOrder;
1314
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1315
- while (1) switch (_context12.prev = _context12.next) {
1546
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1547
+ while (1) switch (_context15.prev = _context15.next) {
1316
1548
  case 0:
1317
- _context12.prev = 0;
1549
+ _context15.prev = 0;
1318
1550
  if (this.store.order) {
1319
- _context12.next = 3;
1551
+ _context15.next = 3;
1320
1552
  break;
1321
1553
  }
1322
1554
  throw new Error('order 模块未初始化');
1323
1555
  case 3:
1324
- _context12.next = 5;
1556
+ _context15.next = 5;
1325
1557
  return this.store.order.addNewOrder();
1326
1558
  case 5:
1327
- tempOrder = _context12.sent;
1559
+ tempOrder = _context15.sent;
1328
1560
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1329
- _context12.next = 10;
1561
+ _context15.next = 10;
1330
1562
  break;
1331
1563
  }
1332
1564
  this.store.order.persistTempOrder();
1333
- _context12.next = 10;
1565
+ _context15.next = 10;
1334
1566
  return this.store.order.saveDraft();
1335
1567
  case 10:
1336
- return _context12.abrupt("return", tempOrder);
1568
+ return _context15.abrupt("return", tempOrder);
1337
1569
  case 13:
1338
- _context12.prev = 13;
1339
- _context12.t0 = _context12["catch"](0);
1340
- throw _context12.t0;
1570
+ _context15.prev = 13;
1571
+ _context15.t0 = _context15["catch"](0);
1572
+ throw _context15.t0;
1341
1573
  case 16:
1342
1574
  case "end":
1343
- return _context12.stop();
1575
+ return _context15.stop();
1344
1576
  }
1345
- }, _callee12, this, [[0, 13]]);
1577
+ }, _callee15, this, [[0, 13]]);
1346
1578
  }));
1347
1579
  function addNewOrder() {
1348
1580
  return _addNewOrder.apply(this, arguments);
@@ -1352,22 +1584,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1352
1584
  }, {
1353
1585
  key: "saveDraft",
1354
1586
  value: function () {
1355
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1356
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1357
- while (1) switch (_context13.prev = _context13.next) {
1587
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1588
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1589
+ while (1) switch (_context16.prev = _context16.next) {
1358
1590
  case 0:
1359
1591
  if (this.store.order) {
1360
- _context13.next = 2;
1592
+ _context16.next = 2;
1361
1593
  break;
1362
1594
  }
1363
1595
  throw new Error('order 模块未初始化');
1364
1596
  case 2:
1365
- return _context13.abrupt("return", this.store.order.saveDraft());
1597
+ return _context16.abrupt("return", this.store.order.saveDraft());
1366
1598
  case 3:
1367
1599
  case "end":
1368
- return _context13.stop();
1600
+ return _context16.stop();
1369
1601
  }
1370
- }, _callee13, this);
1602
+ }, _callee16, this);
1371
1603
  }));
1372
1604
  function saveDraft() {
1373
1605
  return _saveDraft.apply(this, arguments);
@@ -1378,14 +1610,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1378
1610
  }, {
1379
1611
  key: "restoreOrder",
1380
1612
  value: function () {
1381
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1613
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1382
1614
  var tempOrder;
1383
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1384
- while (1) switch (_context14.prev = _context14.next) {
1615
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1616
+ while (1) switch (_context17.prev = _context17.next) {
1385
1617
  case 0:
1386
- _context14.prev = 0;
1618
+ _context17.prev = 0;
1387
1619
  if (this.store.order) {
1388
- _context14.next = 3;
1620
+ _context17.next = 3;
1389
1621
  break;
1390
1622
  }
1391
1623
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -1395,29 +1627,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1395
1627
  this.currentSalesDetail = null;
1396
1628
  this.discountConfigCacheKey = null;
1397
1629
  this.hasManualDiscountSelection = false;
1398
- _context14.next = 9;
1630
+ _context17.next = 9;
1399
1631
  return this.effectsEmit('onTempOrderReplaced', {
1400
1632
  tempOrder: tempOrder
1401
1633
  });
1402
1634
  case 9:
1403
1635
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1404
- _context14.next = 13;
1636
+ _context17.next = 13;
1405
1637
  break;
1406
1638
  }
1407
1639
  this.store.order.persistTempOrder();
1408
- _context14.next = 13;
1640
+ _context17.next = 13;
1409
1641
  return this.store.order.saveDraft();
1410
1642
  case 13:
1411
- return _context14.abrupt("return", tempOrder);
1643
+ return _context17.abrupt("return", tempOrder);
1412
1644
  case 16:
1413
- _context14.prev = 16;
1414
- _context14.t0 = _context14["catch"](0);
1415
- throw _context14.t0;
1645
+ _context17.prev = 16;
1646
+ _context17.t0 = _context17["catch"](0);
1647
+ throw _context17.t0;
1416
1648
  case 19:
1417
1649
  case "end":
1418
- return _context14.stop();
1650
+ return _context17.stop();
1419
1651
  }
1420
- }, _callee14, this, [[0, 16]]);
1652
+ }, _callee17, this, [[0, 16]]);
1421
1653
  }));
1422
1654
  function restoreOrder() {
1423
1655
  return _restoreOrder.apply(this, arguments);
@@ -1431,22 +1663,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1431
1663
  }, {
1432
1664
  key: "clearOrderCartLines",
1433
1665
  value: (function () {
1434
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1666
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1435
1667
  var tempOrder;
1436
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1437
- while (1) switch (_context15.prev = _context15.next) {
1668
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1669
+ while (1) switch (_context18.prev = _context18.next) {
1438
1670
  case 0:
1439
- _context15.prev = 0;
1671
+ _context18.prev = 0;
1440
1672
  if (this.store.order) {
1441
- _context15.next = 3;
1673
+ _context18.next = 3;
1442
1674
  break;
1443
1675
  }
1444
1676
  throw new Error('order 模块未初始化');
1445
1677
  case 3:
1446
- _context15.next = 5;
1678
+ _context18.next = 5;
1447
1679
  return this.store.order.clearOrderCartLines();
1448
1680
  case 5:
1449
- tempOrder = _context15.sent;
1681
+ tempOrder = _context18.sent;
1450
1682
  if (this.currentSalesDetail) {
1451
1683
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1452
1684
  products: [],
@@ -1456,29 +1688,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1456
1688
  discount_list: []
1457
1689
  });
1458
1690
  }
1459
- _context15.next = 9;
1691
+ _context18.next = 9;
1460
1692
  return this.effectsEmit('onTempOrderReplaced', {
1461
1693
  tempOrder: tempOrder
1462
1694
  });
1463
1695
  case 9:
1464
1696
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1465
- _context15.next = 13;
1697
+ _context18.next = 13;
1466
1698
  break;
1467
1699
  }
1468
1700
  this.store.order.persistTempOrder();
1469
- _context15.next = 13;
1701
+ _context18.next = 13;
1470
1702
  return this.store.order.saveDraft();
1471
1703
  case 13:
1472
- return _context15.abrupt("return", tempOrder);
1704
+ return _context18.abrupt("return", tempOrder);
1473
1705
  case 16:
1474
- _context15.prev = 16;
1475
- _context15.t0 = _context15["catch"](0);
1476
- throw _context15.t0;
1706
+ _context18.prev = 16;
1707
+ _context18.t0 = _context18["catch"](0);
1708
+ throw _context18.t0;
1477
1709
  case 19:
1478
1710
  case "end":
1479
- return _context15.stop();
1711
+ return _context18.stop();
1480
1712
  }
1481
- }, _callee15, this, [[0, 16]]);
1713
+ }, _callee18, this, [[0, 16]]);
1482
1714
  }));
1483
1715
  function clearOrderCartLines() {
1484
1716
  return _clearOrderCartLines.apply(this, arguments);
@@ -1495,32 +1727,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1495
1727
  }, {
1496
1728
  key: "getSummary",
1497
1729
  value: function () {
1498
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1730
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1499
1731
  var summary;
1500
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1501
- while (1) switch (_context16.prev = _context16.next) {
1732
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1733
+ while (1) switch (_context19.prev = _context19.next) {
1502
1734
  case 0:
1503
- _context16.prev = 0;
1735
+ _context19.prev = 0;
1504
1736
  if (this.store.order) {
1505
- _context16.next = 3;
1737
+ _context19.next = 3;
1506
1738
  break;
1507
1739
  }
1508
1740
  throw new Error('order 模块未初始化');
1509
1741
  case 3:
1510
- _context16.next = 5;
1742
+ _context19.next = 5;
1511
1743
  return this.store.order.getOrderSummary();
1512
1744
  case 5:
1513
- summary = _context16.sent;
1514
- return _context16.abrupt("return", summary);
1745
+ summary = _context19.sent;
1746
+ return _context19.abrupt("return", summary);
1515
1747
  case 9:
1516
- _context16.prev = 9;
1517
- _context16.t0 = _context16["catch"](0);
1518
- throw _context16.t0;
1748
+ _context19.prev = 9;
1749
+ _context19.t0 = _context19["catch"](0);
1750
+ throw _context19.t0;
1519
1751
  case 12:
1520
1752
  case "end":
1521
- return _context16.stop();
1753
+ return _context19.stop();
1522
1754
  }
1523
- }, _callee16, this, [[0, 9]]);
1755
+ }, _callee19, this, [[0, 9]]);
1524
1756
  }));
1525
1757
  function getSummary() {
1526
1758
  return _getSummary.apply(this, arguments);
@@ -1530,10 +1762,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1530
1762
  }, {
1531
1763
  key: "getHistoricalProductDiscountList",
1532
1764
  value: function getHistoricalProductDiscountList(products) {
1533
- var _this8 = this;
1765
+ var _this9 = this;
1534
1766
  var historyDiscountList = [];
1535
1767
  products.forEach(function (item) {
1536
- if (!_this8.isPersistedOrderProduct(item)) return;
1768
+ if (!_this9.isPersistedOrderProduct(item)) return;
1537
1769
  (item.discount_list || []).forEach(function (discount) {
1538
1770
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1539
1771
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1593,11 +1825,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1593
1825
  }, {
1594
1826
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1595
1827
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1596
- var _this9 = this;
1828
+ var _this10 = this;
1597
1829
  if (params.discountAction !== 'edit') return false;
1598
1830
  if (!params.products.length) return false;
1599
1831
  var hasDraftProduct = params.products.some(function (product) {
1600
- return !_this9.isPersistedOrderProduct(product);
1832
+ return !_this10.isPersistedOrderProduct(product);
1601
1833
  });
1602
1834
  if (hasDraftProduct) return false;
1603
1835
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -1637,14 +1869,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1637
1869
  }, {
1638
1870
  key: "loadDiscountConfig",
1639
1871
  value: function () {
1640
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1872
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1641
1873
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
1642
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1643
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1644
- while (1) switch (_context17.prev = _context17.next) {
1874
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator2, _step2, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1875
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1876
+ while (1) switch (_context20.prev = _context20.next) {
1645
1877
  case 0:
1646
1878
  if (this.store.order) {
1647
- _context17.next = 2;
1879
+ _context20.next = 2;
1648
1880
  break;
1649
1881
  }
1650
1882
  throw new Error('order 模块未初始化');
@@ -1664,18 +1896,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1664
1896
  discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
1665
1897
  preparedDiscountList = [];
1666
1898
  if (!(customerId && customerId !== 1)) {
1667
- _context17.next = 25;
1899
+ _context20.next = 25;
1668
1900
  break;
1669
1901
  }
1670
1902
  if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
1671
- _context17.next = 19;
1903
+ _context20.next = 19;
1672
1904
  break;
1673
1905
  }
1674
1906
  preparedDiscountList = originalDiscountList;
1675
- _context17.next = 25;
1907
+ _context20.next = 25;
1676
1908
  break;
1677
1909
  case 19:
1678
- _context17.next = 21;
1910
+ _context20.next = 21;
1679
1911
  return this.store.order.loadDiscountConfig({
1680
1912
  customerId: customerId,
1681
1913
  action: discountAction,
@@ -1683,23 +1915,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1683
1915
  apply: false
1684
1916
  });
1685
1917
  case 21:
1686
- preparedDiscountList = _context17.sent;
1918
+ preparedDiscountList = _context20.sent;
1687
1919
  this.discountConfigCacheKey = discountConfigCacheKey;
1688
- _context17.next = 25;
1920
+ _context20.next = 25;
1689
1921
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
1690
1922
  case 25:
1691
1923
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
1692
- _context17.next = 27;
1924
+ _context20.next = 27;
1693
1925
  break;
1694
1926
  }
1695
- return _context17.abrupt("return", {
1927
+ return _context20.abrupt("return", {
1696
1928
  productList: tempOrder.products || [],
1697
- discountList: currentDiscountList
1929
+ discountList: currentDiscountList,
1930
+ availableWalletIds: this.getAvailableWalletIds()
1698
1931
  });
1699
1932
  case 27:
1700
1933
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
1701
1934
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
1702
- _context17.next = 31;
1935
+ _context20.next = 31;
1703
1936
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1704
1937
  case 31:
1705
1938
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
@@ -1709,17 +1942,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1709
1942
  nextDiscountList: nextDiscountList
1710
1943
  });
1711
1944
  if (!shouldSkipAutoApplyFetchedDiscounts) {
1712
- _context17.next = 40;
1945
+ _context20.next = 40;
1713
1946
  break;
1714
1947
  }
1715
- _context17.next = 35;
1948
+ _context20.next = 35;
1716
1949
  return this.store.order.recalculateSummary({
1717
1950
  createIfMissing: true
1718
1951
  });
1719
1952
  case 35:
1720
- _summary = _context17.sent;
1953
+ _summary = _context20.sent;
1721
1954
  this.store.order.persistTempOrder();
1722
- _context17.next = 39;
1955
+ _context20.next = 39;
1723
1956
  return this.effectsEmit('onDiscountApplied', {
1724
1957
  productList: tempOrder.products || [],
1725
1958
  discountList: nextDiscountList,
@@ -1727,13 +1960,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1727
1960
  tempOrder: tempOrder
1728
1961
  });
1729
1962
  case 39:
1730
- return _context17.abrupt("return", {
1963
+ return _context20.abrupt("return", {
1731
1964
  productList: tempOrder.products || [],
1732
- discountList: nextDiscountList
1965
+ discountList: nextDiscountList,
1966
+ availableWalletIds: this.getAvailableWalletIds()
1733
1967
  });
1734
1968
  case 40:
1735
1969
  if (!rulesModule) {
1736
- _context17.next = 77;
1970
+ _context20.next = 77;
1737
1971
  break;
1738
1972
  }
1739
1973
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
@@ -1753,22 +1987,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1753
1987
  if (result.productList) {
1754
1988
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1755
1989
  }
1756
- _iterator = _createForOfIteratorHelper(tempOrder.products || []);
1757
- _context17.prev = 46;
1758
- _iterator.s();
1990
+ _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
1991
+ _context20.prev = 46;
1992
+ _iterator2.s();
1759
1993
  case 48:
1760
- if ((_step = _iterator.n()).done) {
1761
- _context17.next = 63;
1994
+ if ((_step2 = _iterator2.n()).done) {
1995
+ _context20.next = 63;
1762
1996
  break;
1763
1997
  }
1764
- product = _step.value;
1998
+ product = _step2.value;
1765
1999
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
1766
2000
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
1767
2001
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1768
- _context17.next = 54;
2002
+ _context20.next = 54;
1769
2003
  break;
1770
2004
  }
1771
- return _context17.abrupt("continue", 61);
2005
+ return _context20.abrupt("continue", 61);
1772
2006
  case 54:
1773
2007
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
1774
2008
  return sum + Number(pd.amount || 0);
@@ -1786,41 +2020,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1786
2020
  bundle: product.product_bundle
1787
2021
  });
1788
2022
  case 61:
1789
- _context17.next = 48;
2023
+ _context20.next = 48;
1790
2024
  break;
1791
2025
  case 63:
1792
- _context17.next = 68;
2026
+ _context20.next = 68;
1793
2027
  break;
1794
2028
  case 65:
1795
- _context17.prev = 65;
1796
- _context17.t0 = _context17["catch"](46);
1797
- _iterator.e(_context17.t0);
2029
+ _context20.prev = 65;
2030
+ _context20.t0 = _context20["catch"](46);
2031
+ _iterator2.e(_context20.t0);
1798
2032
  case 68:
1799
- _context17.prev = 68;
1800
- _iterator.f();
1801
- return _context17.finish(68);
2033
+ _context20.prev = 68;
2034
+ _iterator2.f();
2035
+ return _context20.finish(68);
1802
2036
  case 71:
1803
2037
  if (!result.discountList) {
1804
- _context17.next = 77;
2038
+ _context20.next = 77;
1805
2039
  break;
1806
2040
  }
1807
2041
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1808
2042
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1809
- _context17.next = 76;
2043
+ _context20.next = 76;
1810
2044
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1811
2045
  case 76:
1812
2046
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1813
2047
  return discount.isSelected;
1814
2048
  });
1815
2049
  case 77:
1816
- _context17.next = 79;
2050
+ _context20.next = 79;
1817
2051
  return this.store.order.recalculateSummary({
1818
2052
  createIfMissing: true
1819
2053
  });
1820
2054
  case 79:
1821
- summary = _context17.sent;
2055
+ summary = _context20.sent;
1822
2056
  this.store.order.persistTempOrder();
1823
- _context17.next = 83;
2057
+ _context20.next = 83;
1824
2058
  return this.effectsEmit('onDiscountApplied', {
1825
2059
  productList: tempOrder.products || [],
1826
2060
  discountList: nextDiscountList,
@@ -1828,32 +2062,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1828
2062
  tempOrder: tempOrder
1829
2063
  });
1830
2064
  case 83:
1831
- return _context17.abrupt("return", {
2065
+ return _context20.abrupt("return", {
1832
2066
  productList: tempOrder.products || [],
1833
- discountList: nextDiscountList
2067
+ discountList: nextDiscountList,
2068
+ availableWalletIds: this.getAvailableWalletIds()
1834
2069
  });
1835
2070
  case 84:
1836
2071
  case "end":
1837
- return _context17.stop();
2072
+ return _context20.stop();
1838
2073
  }
1839
- }, _callee17, this, [[46, 65, 68, 71]]);
2074
+ }, _callee20, this, [[46, 65, 68, 71]]);
1840
2075
  }));
1841
- function loadDiscountConfig(_x11) {
2076
+ function loadDiscountConfig(_x13) {
1842
2077
  return _loadDiscountConfig.apply(this, arguments);
1843
2078
  }
1844
2079
  return loadDiscountConfig;
1845
2080
  }()
2081
+ }, {
2082
+ key: "getAvailableWalletIds",
2083
+ value: function getAvailableWalletIds() {
2084
+ var _this$store$order4;
2085
+ if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2086
+ return this.store.order.getAvailableWalletIds();
2087
+ }
1846
2088
  }, {
1847
2089
  key: "bestDiscount",
1848
2090
  value: function () {
1849
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
2091
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
1850
2092
  var _discountModule$getOr2, _discountModule$getDi3;
1851
2093
  var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
1852
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1853
- while (1) switch (_context18.prev = _context18.next) {
2094
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2095
+ while (1) switch (_context21.prev = _context21.next) {
1854
2096
  case 0:
1855
2097
  if (this.store.order) {
1856
- _context18.next = 2;
2098
+ _context21.next = 2;
1857
2099
  break;
1858
2100
  }
1859
2101
  throw new Error('order 模块未初始化');
@@ -1869,11 +2111,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1869
2111
  productList: tempOrder.products || [],
1870
2112
  discountList: nextDiscountList
1871
2113
  };
1872
- _context18.next = 12;
2114
+ _context21.next = 12;
1873
2115
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1874
2116
  case 12:
1875
2117
  if (!rulesModule) {
1876
- _context18.next = 24;
2118
+ _context21.next = 24;
1877
2119
  break;
1878
2120
  }
1879
2121
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -1891,12 +2133,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1891
2133
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1892
2134
  }
1893
2135
  if (!result.discountList) {
1894
- _context18.next = 24;
2136
+ _context21.next = 24;
1895
2137
  break;
1896
2138
  }
1897
2139
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1898
2140
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1899
- _context18.next = 22;
2141
+ _context21.next = 22;
1900
2142
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1901
2143
  case 22:
1902
2144
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
@@ -1907,13 +2149,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1907
2149
  discountList: nextDiscountList
1908
2150
  };
1909
2151
  case 24:
1910
- _context18.next = 26;
2152
+ _context21.next = 26;
1911
2153
  return this.store.order.recalculateSummary({
1912
2154
  createIfMissing: true
1913
2155
  });
1914
2156
  case 26:
1915
2157
  this.store.order.persistTempOrder();
1916
- _context18.next = 29;
2158
+ _context21.next = 29;
1917
2159
  return this.effectsEmit('onDiscountApplied', {
1918
2160
  productList: tempOrder.products || [],
1919
2161
  discountList: nextDiscountList,
@@ -1922,14 +2164,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1922
2164
  });
1923
2165
  case 29:
1924
2166
  cb === null || cb === void 0 || cb(result);
1925
- return _context18.abrupt("return", result);
2167
+ return _context21.abrupt("return", result);
1926
2168
  case 31:
1927
2169
  case "end":
1928
- return _context18.stop();
2170
+ return _context21.stop();
1929
2171
  }
1930
- }, _callee18, this);
2172
+ }, _callee21, this);
1931
2173
  }));
1932
- function bestDiscount(_x12) {
2174
+ function bestDiscount(_x14) {
1933
2175
  return _bestDiscount.apply(this, arguments);
1934
2176
  }
1935
2177
  return bestDiscount;
@@ -1958,41 +2200,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1958
2200
  }, {
1959
2201
  key: "replaceDiscountStoreLists",
1960
2202
  value: (function () {
1961
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
2203
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
1962
2204
  var _store2;
1963
2205
  var discountModule;
1964
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1965
- while (1) switch (_context19.prev = _context19.next) {
2206
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2207
+ while (1) switch (_context22.prev = _context22.next) {
1966
2208
  case 0:
1967
2209
  if (this.store.order) {
1968
- _context19.next = 2;
2210
+ _context22.next = 2;
1969
2211
  break;
1970
2212
  }
1971
2213
  throw new Error('order 模块未初始化');
1972
2214
  case 2:
1973
2215
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
1974
2216
  if (discountModule) {
1975
- _context19.next = 5;
2217
+ _context22.next = 5;
1976
2218
  break;
1977
2219
  }
1978
- return _context19.abrupt("return");
2220
+ return _context22.abrupt("return");
1979
2221
  case 5:
1980
2222
  if (!params.originalDiscountList) {
1981
- _context19.next = 8;
2223
+ _context22.next = 8;
1982
2224
  break;
1983
2225
  }
1984
- _context19.next = 8;
2226
+ _context22.next = 8;
1985
2227
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
1986
2228
  case 8:
1987
- _context19.next = 10;
2229
+ _context22.next = 10;
1988
2230
  return discountModule.setDiscountList(params.discountList);
1989
2231
  case 10:
1990
2232
  case "end":
1991
- return _context19.stop();
2233
+ return _context22.stop();
1992
2234
  }
1993
- }, _callee19, this);
2235
+ }, _callee22, this);
1994
2236
  }));
1995
- function replaceDiscountStoreLists(_x13) {
2237
+ function replaceDiscountStoreLists(_x15) {
1996
2238
  return _replaceDiscountStoreLists.apply(this, arguments);
1997
2239
  }
1998
2240
  return replaceDiscountStoreLists;
@@ -2000,34 +2242,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2000
2242
  }, {
2001
2243
  key: "scanPromotionCode",
2002
2244
  value: function () {
2003
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(code, customerId) {
2245
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
2004
2246
  var raw, tempOrder;
2005
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2006
- while (1) switch (_context20.prev = _context20.next) {
2247
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2248
+ while (1) switch (_context23.prev = _context23.next) {
2007
2249
  case 0:
2008
- _context20.prev = 0;
2250
+ _context23.prev = 0;
2009
2251
  if (this.store.order) {
2010
- _context20.next = 3;
2252
+ _context23.next = 3;
2011
2253
  break;
2012
2254
  }
2013
2255
  throw new Error('order 模块未初始化');
2014
2256
  case 3:
2015
- _context20.next = 5;
2257
+ _context23.next = 5;
2016
2258
  return this.store.order.scanCode(code, customerId);
2017
2259
  case 5:
2018
- raw = _context20.sent;
2260
+ raw = _context23.sent;
2019
2261
  if (!raw.isAvailable) {
2020
- _context20.next = 13;
2262
+ _context23.next = 13;
2021
2263
  break;
2022
2264
  }
2023
- _context20.next = 9;
2265
+ _context23.next = 9;
2024
2266
  return this.store.order.recalculateSummary({
2025
2267
  createIfMissing: true
2026
2268
  });
2027
2269
  case 9:
2028
2270
  this.store.order.persistTempOrder();
2029
2271
  tempOrder = this.store.order.ensureTempOrder();
2030
- _context20.next = 13;
2272
+ _context23.next = 13;
2031
2273
  return this.effectsEmit('onDiscountApplied', {
2032
2274
  productList: tempOrder.products || [],
2033
2275
  discountList: this.store.order.getDiscountList(),
@@ -2035,23 +2277,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2035
2277
  tempOrder: tempOrder
2036
2278
  });
2037
2279
  case 13:
2038
- return _context20.abrupt("return", {
2280
+ return _context23.abrupt("return", {
2039
2281
  isAvailable: raw.isAvailable,
2040
2282
  type: raw.type,
2041
2283
  unavailableReason: raw.unavailableReason,
2042
2284
  scannedDiscountList: raw.scannedDiscountList
2043
2285
  });
2044
2286
  case 16:
2045
- _context20.prev = 16;
2046
- _context20.t0 = _context20["catch"](0);
2047
- throw _context20.t0;
2287
+ _context23.prev = 16;
2288
+ _context23.t0 = _context23["catch"](0);
2289
+ throw _context23.t0;
2048
2290
  case 19:
2049
2291
  case "end":
2050
- return _context20.stop();
2292
+ return _context23.stop();
2051
2293
  }
2052
- }, _callee20, this, [[0, 16]]);
2294
+ }, _callee23, this, [[0, 16]]);
2053
2295
  }));
2054
- function scanPromotionCode(_x14, _x15) {
2296
+ function scanPromotionCode(_x16, _x17) {
2055
2297
  return _scanPromotionCode.apply(this, arguments);
2056
2298
  }
2057
2299
  return scanPromotionCode;
@@ -2059,14 +2301,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2059
2301
  }, {
2060
2302
  key: "setDiscountSelected",
2061
2303
  value: function () {
2062
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2063
- var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2064
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2065
- while (1) switch (_context21.prev = _context21.next) {
2304
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2305
+ var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator3, _step3, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator4, _step4, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2306
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2307
+ while (1) switch (_context24.prev = _context24.next) {
2066
2308
  case 0:
2067
- _context21.prev = 0;
2309
+ _context24.prev = 0;
2068
2310
  if (this.store.order) {
2069
- _context21.next = 3;
2311
+ _context24.next = 3;
2070
2312
  break;
2071
2313
  }
2072
2314
  throw new Error('order 模块未初始化');
@@ -2084,7 +2326,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2084
2326
  discountModule = orderStore.discount;
2085
2327
  rulesModule = orderStore.rules;
2086
2328
  nextDiscountList = updated;
2087
- _context21.next = 13;
2329
+ _context24.next = 13;
2088
2330
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2089
2331
  case 13:
2090
2332
  if (rulesModule) {
@@ -2116,10 +2358,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2116
2358
  }).map(function (d) {
2117
2359
  return d.id;
2118
2360
  }));
2119
- _iterator2 = _createForOfIteratorHelper(nextDiscountList);
2361
+ _iterator3 = _createForOfIteratorHelper(nextDiscountList);
2120
2362
  try {
2121
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2122
- d = _step2.value;
2363
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2364
+ d = _step3.value;
2123
2365
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
2124
2366
  d.isSelected = false;
2125
2367
  d.isManualSelect = true;
@@ -2127,9 +2369,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2127
2369
  }
2128
2370
  }
2129
2371
  } catch (err) {
2130
- _iterator2.e(err);
2372
+ _iterator3.e(err);
2131
2373
  } finally {
2132
- _iterator2.f();
2374
+ _iterator3.f();
2133
2375
  }
2134
2376
  }
2135
2377
  }
@@ -2146,30 +2388,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2146
2388
  return rid != null && selectedResourceIds.has(rid);
2147
2389
  });
2148
2390
  };
2149
- _iterator3 = _createForOfIteratorHelper(tempOrder.products);
2150
- _context21.prev = 17;
2151
- _iterator3.s();
2391
+ _iterator4 = _createForOfIteratorHelper(tempOrder.products);
2392
+ _context24.prev = 17;
2393
+ _iterator4.s();
2152
2394
  case 19:
2153
- if ((_step3 = _iterator3.n()).done) {
2154
- _context21.next = 36;
2395
+ if ((_step4 = _iterator4.n()).done) {
2396
+ _context24.next = 36;
2155
2397
  break;
2156
2398
  }
2157
- product = _step3.value;
2399
+ product = _step4.value;
2158
2400
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
2159
2401
  runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
2160
2402
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2161
- _context21.next = 25;
2403
+ _context24.next = 25;
2162
2404
  break;
2163
2405
  }
2164
- return _context21.abrupt("continue", 34);
2406
+ return _context24.abrupt("continue", 34);
2165
2407
  case 25:
2166
2408
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2167
2409
  if (Array.isArray(product.product_bundle)) {
2168
2410
  product.product_bundle = product.product_bundle.map(function (bundle) {
2169
- var _ref20, _bundle$original_pric;
2411
+ var _ref21, _bundle$original_pric;
2170
2412
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2171
2413
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2172
- var restoredBundlePrice = (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2414
+ var restoredBundlePrice = (_ref21 = (_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 && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2173
2415
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2174
2416
  price: restoredBundlePrice,
2175
2417
  bundle_selling_price: restoredBundlePrice
@@ -2197,28 +2439,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2197
2439
  bundle: product.product_bundle
2198
2440
  });
2199
2441
  case 34:
2200
- _context21.next = 19;
2442
+ _context24.next = 19;
2201
2443
  break;
2202
2444
  case 36:
2203
- _context21.next = 41;
2445
+ _context24.next = 41;
2204
2446
  break;
2205
2447
  case 38:
2206
- _context21.prev = 38;
2207
- _context21.t0 = _context21["catch"](17);
2208
- _iterator3.e(_context21.t0);
2448
+ _context24.prev = 38;
2449
+ _context24.t0 = _context24["catch"](17);
2450
+ _iterator4.e(_context24.t0);
2209
2451
  case 41:
2210
- _context21.prev = 41;
2211
- _iterator3.f();
2212
- return _context21.finish(41);
2452
+ _context24.prev = 41;
2453
+ _iterator4.f();
2454
+ return _context24.finish(41);
2213
2455
  case 44:
2214
2456
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2215
- _context21.next = 47;
2457
+ _context24.next = 47;
2216
2458
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2217
2459
  case 47:
2218
2460
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2219
2461
  return d.isSelected;
2220
2462
  });
2221
- _context21.next = 50;
2463
+ _context24.next = 50;
2222
2464
  return this.store.order.recalculateSummary({
2223
2465
  createIfMissing: true
2224
2466
  });
@@ -2230,19 +2472,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2230
2472
  selectedDiscountList: tempOrder.discount_list,
2231
2473
  tempOrder: tempOrder
2232
2474
  });
2233
- _context21.next = 57;
2475
+ _context24.next = 57;
2234
2476
  break;
2235
2477
  case 54:
2236
- _context21.prev = 54;
2237
- _context21.t1 = _context21["catch"](0);
2238
- throw _context21.t1;
2478
+ _context24.prev = 54;
2479
+ _context24.t1 = _context24["catch"](0);
2480
+ throw _context24.t1;
2239
2481
  case 57:
2240
2482
  case "end":
2241
- return _context21.stop();
2483
+ return _context24.stop();
2242
2484
  }
2243
- }, _callee21, this, [[0, 54], [17, 38, 41, 44]]);
2485
+ }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2244
2486
  }));
2245
- function setDiscountSelected(_x16) {
2487
+ function setDiscountSelected(_x18) {
2246
2488
  return _setDiscountSelected.apply(this, arguments);
2247
2489
  }
2248
2490
  return setDiscountSelected;
@@ -2250,23 +2492,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2250
2492
  }, {
2251
2493
  key: "applyDiscountCalculationResult",
2252
2494
  value: function () {
2253
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(result) {
2495
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
2254
2496
  var tempOrder, orderStore, discountModule;
2255
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2256
- while (1) switch (_context22.prev = _context22.next) {
2497
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2498
+ while (1) switch (_context25.prev = _context25.next) {
2257
2499
  case 0:
2258
- _context22.prev = 0;
2500
+ _context25.prev = 0;
2259
2501
  if (this.store.order) {
2260
- _context22.next = 3;
2502
+ _context25.next = 3;
2261
2503
  break;
2262
2504
  }
2263
2505
  throw new Error('order 模块未初始化');
2264
2506
  case 3:
2265
2507
  if (result) {
2266
- _context22.next = 5;
2508
+ _context25.next = 5;
2267
2509
  break;
2268
2510
  }
2269
- return _context22.abrupt("return");
2511
+ return _context25.abrupt("return");
2270
2512
  case 5:
2271
2513
  tempOrder = this.store.order.ensureTempOrder();
2272
2514
  orderStore = this.store.order.store || {};
@@ -2275,24 +2517,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2275
2517
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2276
2518
  }
2277
2519
  if (!result.discountList) {
2278
- _context22.next = 14;
2520
+ _context25.next = 14;
2279
2521
  break;
2280
2522
  }
2281
2523
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
2282
- _context22.next = 13;
2524
+ _context25.next = 13;
2283
2525
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
2284
2526
  case 13:
2285
2527
  tempOrder.discount_list = result.discountList.filter(function (discount) {
2286
2528
  return discount.isSelected;
2287
2529
  });
2288
2530
  case 14:
2289
- _context22.next = 16;
2531
+ _context25.next = 16;
2290
2532
  return this.store.order.recalculateSummary({
2291
2533
  createIfMissing: true
2292
2534
  });
2293
2535
  case 16:
2294
2536
  this.store.order.persistTempOrder();
2295
- _context22.next = 19;
2537
+ _context25.next = 19;
2296
2538
  return this.effectsEmit('onDiscountApplied', {
2297
2539
  productList: tempOrder.products || [],
2298
2540
  discountList: result.discountList || [],
@@ -2300,19 +2542,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2300
2542
  tempOrder: tempOrder
2301
2543
  });
2302
2544
  case 19:
2303
- _context22.next = 24;
2545
+ _context25.next = 24;
2304
2546
  break;
2305
2547
  case 21:
2306
- _context22.prev = 21;
2307
- _context22.t0 = _context22["catch"](0);
2308
- throw _context22.t0;
2548
+ _context25.prev = 21;
2549
+ _context25.t0 = _context25["catch"](0);
2550
+ throw _context25.t0;
2309
2551
  case 24:
2310
2552
  case "end":
2311
- return _context22.stop();
2553
+ return _context25.stop();
2312
2554
  }
2313
- }, _callee22, this, [[0, 21]]);
2555
+ }, _callee25, this, [[0, 21]]);
2314
2556
  }));
2315
- function applyDiscountCalculationResult(_x17) {
2557
+ function applyDiscountCalculationResult(_x19) {
2316
2558
  return _applyDiscountCalculationResult.apply(this, arguments);
2317
2559
  }
2318
2560
  return applyDiscountCalculationResult;
@@ -2320,18 +2562,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2320
2562
  }, {
2321
2563
  key: "submitScanOrder",
2322
2564
  value: function () {
2323
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2324
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2325
- while (1) switch (_context23.prev = _context23.next) {
2565
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2566
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2567
+ while (1) switch (_context26.prev = _context26.next) {
2326
2568
  case 0:
2327
- return _context23.abrupt("return", this.submitSalesOrder(params));
2569
+ return _context26.abrupt("return", this.submitSalesOrder(params));
2328
2570
  case 1:
2329
2571
  case "end":
2330
- return _context23.stop();
2572
+ return _context26.stop();
2331
2573
  }
2332
- }, _callee23, this);
2574
+ }, _callee26, this);
2333
2575
  }));
2334
- function submitScanOrder(_x18) {
2576
+ function submitScanOrder(_x20) {
2335
2577
  return _submitScanOrder.apply(this, arguments);
2336
2578
  }
2337
2579
  return submitScanOrder;
@@ -2345,14 +2587,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2345
2587
  }, {
2346
2588
  key: "submitSalesOrder",
2347
2589
  value: (function () {
2348
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2590
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2349
2591
  var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
2350
2592
  var inferredPaymentStatus, submitParams;
2351
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2352
- while (1) switch (_context24.prev = _context24.next) {
2593
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2594
+ while (1) switch (_context27.prev = _context27.next) {
2353
2595
  case 0:
2354
2596
  if (this.store.order) {
2355
- _context24.next = 2;
2597
+ _context27.next = 2;
2356
2598
  break;
2357
2599
  }
2358
2600
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2377,14 +2619,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2377
2619
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2378
2620
  enhancePayload: params.enhancePayload
2379
2621
  } : {});
2380
- return _context24.abrupt("return", this.store.order.submitTempOrder(submitParams));
2622
+ return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
2381
2623
  case 5:
2382
2624
  case "end":
2383
- return _context24.stop();
2625
+ return _context27.stop();
2384
2626
  }
2385
- }, _callee24, this);
2627
+ }, _callee27, this);
2386
2628
  }));
2387
- function submitSalesOrder(_x19) {
2629
+ function submitSalesOrder(_x21) {
2388
2630
  return _submitSalesOrder.apply(this, arguments);
2389
2631
  }
2390
2632
  return submitSalesOrder;
@@ -2392,14 +2634,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2392
2634
  }, {
2393
2635
  key: "submitTempOrderAsync",
2394
2636
  value: function () {
2395
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2637
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2396
2638
  var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2397
2639
  var inferredPaymentStatus, submitParams;
2398
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2399
- while (1) switch (_context25.prev = _context25.next) {
2640
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2641
+ while (1) switch (_context28.prev = _context28.next) {
2400
2642
  case 0:
2401
2643
  if (this.store.order) {
2402
- _context25.next = 2;
2644
+ _context28.next = 2;
2403
2645
  break;
2404
2646
  }
2405
2647
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2422,14 +2664,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2422
2664
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2423
2665
  enhancePayload: params.enhancePayload
2424
2666
  } : {});
2425
- return _context25.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2667
+ return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2426
2668
  case 5:
2427
2669
  case "end":
2428
- return _context25.stop();
2670
+ return _context28.stop();
2429
2671
  }
2430
- }, _callee25, this);
2672
+ }, _callee28, this);
2431
2673
  }));
2432
- function submitTempOrderAsync(_x20) {
2674
+ function submitTempOrderAsync(_x22) {
2433
2675
  return _submitTempOrderAsync.apply(this, arguments);
2434
2676
  }
2435
2677
  return submitTempOrderAsync;
@@ -2437,14 +2679,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2437
2679
  }, {
2438
2680
  key: "printLocalOrderReceipt",
2439
2681
  value: function () {
2440
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(lookup) {
2682
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2441
2683
  var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2442
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order4, _data;
2443
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2444
- while (1) switch (_context26.prev = _context26.next) {
2684
+ var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2685
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2686
+ while (1) switch (_context29.prev = _context29.next) {
2445
2687
  case 0:
2446
2688
  if (this.store.order) {
2447
- _context26.next = 2;
2689
+ _context29.next = 2;
2448
2690
  break;
2449
2691
  }
2450
2692
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2475,28 +2717,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2475
2717
  channel: context.channel,
2476
2718
  type: context.type
2477
2719
  });
2478
- _context26.next = 8;
2720
+ _context29.next = 8;
2479
2721
  return this.request.post('/local/print-order', payload, {
2480
2722
  osServer: true,
2481
2723
  customToast: function customToast() {}
2482
2724
  });
2483
2725
  case 8:
2484
- response = _context26.sent;
2726
+ response = _context29.sent;
2485
2727
  if (hasLookup) {
2486
- _context26.next = 12;
2728
+ _context29.next = 12;
2487
2729
  break;
2488
2730
  }
2489
- _context26.next = 12;
2490
- return (_this$store$order$app = (_this$store$order4 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order4, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2731
+ _context29.next = 12;
2732
+ return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2491
2733
  case 12:
2492
- return _context26.abrupt("return", response);
2734
+ return _context29.abrupt("return", response);
2493
2735
  case 13:
2494
2736
  case "end":
2495
- return _context26.stop();
2737
+ return _context29.stop();
2496
2738
  }
2497
- }, _callee26, this);
2739
+ }, _callee29, this);
2498
2740
  }));
2499
- function printLocalOrderReceipt(_x21) {
2741
+ function printLocalOrderReceipt(_x23) {
2500
2742
  return _printLocalOrderReceipt.apply(this, arguments);
2501
2743
  }
2502
2744
  return printLocalOrderReceipt;
@@ -2504,9 +2746,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2504
2746
  }, {
2505
2747
  key: "getSubmitPaymentStatus",
2506
2748
  value: function getSubmitPaymentStatus(paymentStatus) {
2507
- var _this$store$order5, _this$store$order5$ge;
2749
+ var _this$store$order6, _this$store$order6$ge;
2508
2750
  if (paymentStatus !== undefined) return paymentStatus;
2509
- var amountSnapshot = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderAmountSnapshot) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2751
+ var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
2510
2752
  if (!amountSnapshot) return undefined;
2511
2753
  try {
2512
2754
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -2517,19 +2759,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2517
2759
  }, {
2518
2760
  key: "syncPaymentsToOrder",
2519
2761
  value: function () {
2520
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2521
- var _ref21, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2762
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
+ var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2522
2764
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2523
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2524
- while (1) switch (_context27.prev = _context27.next) {
2765
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2766
+ while (1) switch (_context30.prev = _context30.next) {
2525
2767
  case 0:
2526
2768
  if (this.store.order) {
2527
- _context27.next = 2;
2769
+ _context30.next = 2;
2528
2770
  break;
2529
2771
  }
2530
2772
  throw new Error('order 模块未初始化');
2531
2773
  case 2:
2532
- businessCode = (_ref21 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref21 !== void 0 ? _ref21 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2774
+ businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2533
2775
  channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
2534
2776
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2535
2777
  businessCode: businessCode
@@ -2538,14 +2780,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2538
2780
  } : {});
2539
2781
  syncState = this.store.order.getOrderSyncState();
2540
2782
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2541
- _context27.next = 9;
2783
+ _context30.next = 9;
2542
2784
  break;
2543
2785
  }
2544
2786
  this.queueLatestAutoPaymentSync();
2545
- return _context27.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2787
+ return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2546
2788
  case 9:
2547
2789
  payments = params.payments || [];
2548
- _context27.next = 12;
2790
+ _context30.next = 12;
2549
2791
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2550
2792
  payments: payments,
2551
2793
  params: syncParams,
@@ -2553,11 +2795,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2553
2795
  orderSnapshot: this.store.order.getOrderSnapshot()
2554
2796
  });
2555
2797
  case 12:
2556
- _context27.prev = 12;
2557
- _context27.next = 15;
2798
+ _context30.prev = 12;
2799
+ _context30.next = 15;
2558
2800
  return this.store.order.syncPaymentsToOrder(syncParams);
2559
2801
  case 15:
2560
- syncResult = _context27.sent;
2802
+ syncResult = _context30.sent;
2561
2803
  latestPayments = this.store.order.getOrderPayments();
2562
2804
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2563
2805
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2575,25 +2817,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2575
2817
  depositAmount: syncResult.depositAmount,
2576
2818
  orderExpectedAmount: syncResult.orderExpectedAmount
2577
2819
  };
2578
- _context27.next = 22;
2820
+ _context30.next = 22;
2579
2821
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2580
2822
  case 22:
2581
2823
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2582
- _context27.next = 25;
2824
+ _context30.next = 25;
2583
2825
  break;
2584
2826
  }
2585
- _context27.next = 25;
2827
+ _context30.next = 25;
2586
2828
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2587
2829
  case 25:
2588
2830
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2589
- return _context27.abrupt("return", syncResult);
2831
+ return _context30.abrupt("return", syncResult);
2590
2832
  case 29:
2591
- _context27.prev = 29;
2592
- _context27.t0 = _context27["catch"](12);
2593
- _context27.next = 33;
2833
+ _context30.prev = 29;
2834
+ _context30.t0 = _context30["catch"](12);
2835
+ _context30.next = 33;
2594
2836
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2595
2837
  ok: false,
2596
- error: _context27.t0,
2838
+ error: _context30.t0,
2597
2839
  payments: this.store.order.getOrderPayments(),
2598
2840
  params: syncParams,
2599
2841
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2601,14 +2843,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2601
2843
  });
2602
2844
  case 33:
2603
2845
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2604
- throw _context27.t0;
2846
+ throw _context30.t0;
2605
2847
  case 35:
2606
2848
  case "end":
2607
- return _context27.stop();
2849
+ return _context30.stop();
2608
2850
  }
2609
- }, _callee27, this, [[12, 29]]);
2851
+ }, _callee30, this, [[12, 29]]);
2610
2852
  }));
2611
- function syncPaymentsToOrder(_x22) {
2853
+ function syncPaymentsToOrder(_x24) {
2612
2854
  return _syncPaymentsToOrder.apply(this, arguments);
2613
2855
  }
2614
2856
  return syncPaymentsToOrder;
@@ -2645,58 +2887,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2645
2887
  }, {
2646
2888
  key: "scheduleQueuedAutoPaymentSyncFlush",
2647
2889
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2648
- var _this10 = this;
2890
+ var _this11 = this;
2649
2891
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2650
2892
  if (!this.queuedAutoPaymentSync) return;
2651
2893
  if (this.autoPaymentSyncTimer) return;
2652
2894
  this.autoPaymentSyncTimer = setTimeout(function () {
2653
- _this10.autoPaymentSyncTimer = null;
2654
- void _this10.flushQueuedAutoPaymentSync();
2895
+ _this11.autoPaymentSyncTimer = null;
2896
+ void _this11.flushQueuedAutoPaymentSync();
2655
2897
  }, delay);
2656
2898
  }
2657
2899
  }, {
2658
2900
  key: "flushQueuedAutoPaymentSync",
2659
2901
  value: function () {
2660
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2902
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2661
2903
  var payments;
2662
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2663
- while (1) switch (_context28.prev = _context28.next) {
2904
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
+ while (1) switch (_context31.prev = _context31.next) {
2664
2906
  case 0:
2665
2907
  if (this.store.order) {
2666
- _context28.next = 2;
2908
+ _context31.next = 2;
2667
2909
  break;
2668
2910
  }
2669
- return _context28.abrupt("return");
2911
+ return _context31.abrupt("return");
2670
2912
  case 2:
2671
2913
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2672
- _context28.next = 4;
2914
+ _context31.next = 4;
2673
2915
  break;
2674
2916
  }
2675
- return _context28.abrupt("return");
2917
+ return _context31.abrupt("return");
2676
2918
  case 4:
2677
2919
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2678
- _context28.next = 7;
2920
+ _context31.next = 7;
2679
2921
  break;
2680
2922
  }
2681
2923
  this.scheduleQueuedAutoPaymentSyncFlush();
2682
- return _context28.abrupt("return");
2924
+ return _context31.abrupt("return");
2683
2925
  case 7:
2684
2926
  this.autoPaymentSyncFlushing = true;
2685
- _context28.prev = 8;
2927
+ _context31.prev = 8;
2686
2928
  case 9:
2687
2929
  if (!this.queuedAutoPaymentSync) {
2688
- _context28.next = 18;
2930
+ _context31.next = 18;
2689
2931
  break;
2690
2932
  }
2691
2933
  this.queuedAutoPaymentSync = false;
2692
2934
  payments = this.store.order.getOrderPayments();
2693
2935
  if (payments.length) {
2694
- _context28.next = 14;
2936
+ _context31.next = 14;
2695
2937
  break;
2696
2938
  }
2697
- return _context28.abrupt("continue", 9);
2939
+ return _context31.abrupt("continue", 9);
2698
2940
  case 14:
2699
- _context28.next = 16;
2941
+ _context31.next = 16;
2700
2942
  return this.syncPaymentsToOrder({
2701
2943
  payments: payments,
2702
2944
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2704,29 +2946,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2704
2946
  smallTicketDataFlag: 1
2705
2947
  });
2706
2948
  case 16:
2707
- _context28.next = 9;
2949
+ _context31.next = 9;
2708
2950
  break;
2709
2951
  case 18:
2710
- _context28.next = 23;
2952
+ _context31.next = 23;
2711
2953
  break;
2712
2954
  case 20:
2713
- _context28.prev = 20;
2714
- _context28.t0 = _context28["catch"](8);
2955
+ _context31.prev = 20;
2956
+ _context31.t0 = _context31["catch"](8);
2715
2957
  this.logError('queued auto sync payments failed', {
2716
- error: _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0)
2958
+ error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
2717
2959
  });
2718
2960
  case 23:
2719
- _context28.prev = 23;
2961
+ _context31.prev = 23;
2720
2962
  this.autoPaymentSyncFlushing = false;
2721
2963
  if (this.queuedAutoPaymentSync) {
2722
2964
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2723
2965
  }
2724
- return _context28.finish(23);
2966
+ return _context31.finish(23);
2725
2967
  case 27:
2726
2968
  case "end":
2727
- return _context28.stop();
2969
+ return _context31.stop();
2728
2970
  }
2729
- }, _callee28, this, [[8, 20, 23, 27]]);
2971
+ }, _callee31, this, [[8, 20, 23, 27]]);
2730
2972
  }));
2731
2973
  function flushQueuedAutoPaymentSync() {
2732
2974
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -2739,9 +2981,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2739
2981
  var _this$otherParams20,
2740
2982
  _paymentRecord$paymen,
2741
2983
  _paymentRecord$create,
2742
- _ref22,
2984
+ _ref23,
2743
2985
  _paymentRecord$origin,
2744
- _this11 = this;
2986
+ _this12 = this;
2745
2987
  if (!this.store.order) throw new Error('order 模块未初始化');
2746
2988
  var paymentRecord = payment;
2747
2989
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -2763,7 +3005,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2763
3005
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
2764
3006
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
2765
3007
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
2766
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3008
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
2767
3009
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
2768
3010
  service_fee: calculatedServiceFee
2769
3011
  } : {}), {}, {
@@ -2784,7 +3026,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2784
3026
  submitWhenPaid: true,
2785
3027
  smallTicketDataFlag: 1
2786
3028
  }).catch(function (error) {
2787
- _this11.logError('auto sync payments failed', {
3029
+ _this12.logError('auto sync payments failed', {
2788
3030
  error: error instanceof Error ? error.message : String(error)
2789
3031
  });
2790
3032
  });
@@ -2830,8 +3072,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2830
3072
  }, {
2831
3073
  key: "getWalletProductList",
2832
3074
  value: function getWalletProductList() {
2833
- var _this$store$order6, _tempOrder$products;
2834
- var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
3075
+ var _this$store$order7, _tempOrder$products;
3076
+ var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
2835
3077
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
2836
3078
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
2837
3079
  // debugger
@@ -2891,20 +3133,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2891
3133
  }, {
2892
3134
  key: "initWalletData",
2893
3135
  value: function () {
2894
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2895
- var _params$order_wait_pa, _ref23, _tempOrder$is_price_i;
3136
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
+ var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
2896
3138
  var snapshot, tempOrder, amount, walletBusinessData, result;
2897
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2898
- while (1) switch (_context29.prev = _context29.next) {
3139
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
+ while (1) switch (_context32.prev = _context32.next) {
2899
3141
  case 0:
2900
3142
  if (this.store.order) {
2901
- _context29.next = 2;
3143
+ _context32.next = 2;
2902
3144
  break;
2903
3145
  }
2904
3146
  throw new Error('order 模块未初始化');
2905
3147
  case 2:
2906
3148
  if (this.store.payment) {
2907
- _context29.next = 4;
3149
+ _context32.next = 4;
2908
3150
  break;
2909
3151
  }
2910
3152
  throw new Error('payment 模块未初始化');
@@ -2913,10 +3155,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2913
3155
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
2914
3156
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
2915
3157
  if (!(!tempOrder || !amount)) {
2916
- _context29.next = 9;
3158
+ _context32.next = 9;
2917
3159
  break;
2918
3160
  }
2919
- return _context29.abrupt("return", {
3161
+ return _context32.abrupt("return", {
2920
3162
  walletRecommendList: [],
2921
3163
  userIdentificationCodes: [],
2922
3164
  transformList: [],
@@ -2935,15 +3177,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2935
3177
  },
2936
3178
  products: this.getWalletProductList(),
2937
3179
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
2938
- is_price_include_tax: (_ref23 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref23 !== void 0 ? _ref23 : 1
3180
+ is_price_include_tax: (_ref24 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref24 !== void 0 ? _ref24 : 1
2939
3181
  }, snapshot.identity.orderId ? {
2940
3182
  payment_order_id: String(snapshot.identity.orderId)
2941
3183
  } : {});
2942
- _context29.next = 12;
3184
+ _context32.next = 12;
2943
3185
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
2944
3186
  case 12:
2945
- result = _context29.sent;
2946
- _context29.next = 15;
3187
+ result = _context32.sent;
3188
+ _context32.next = 15;
2947
3189
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
2948
3190
  orderId: snapshot.identity.orderId,
2949
3191
  customerId: walletBusinessData.customer_id,
@@ -2955,14 +3197,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2955
3197
  timestamp: Date.now()
2956
3198
  });
2957
3199
  case 15:
2958
- return _context29.abrupt("return", result);
3200
+ return _context32.abrupt("return", result);
2959
3201
  case 16:
2960
3202
  case "end":
2961
- return _context29.stop();
3203
+ return _context32.stop();
2962
3204
  }
2963
- }, _callee29, this);
3205
+ }, _callee32, this);
2964
3206
  }));
2965
- function initWalletData(_x23) {
3207
+ function initWalletData(_x25) {
2966
3208
  return _initWalletData.apply(this, arguments);
2967
3209
  }
2968
3210
  return initWalletData;
@@ -2989,35 +3231,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2989
3231
  }, {
2990
3232
  key: "getPaymentMethodsAsync",
2991
3233
  value: (function () {
2992
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
3234
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2993
3235
  var response, paymentMethods;
2994
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2995
- while (1) switch (_context30.prev = _context30.next) {
3236
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
+ while (1) switch (_context33.prev = _context33.next) {
2996
3238
  case 0:
2997
- _context30.prev = 0;
2998
- _context30.next = 3;
3239
+ _context33.prev = 0;
3240
+ _context33.next = 3;
2999
3241
  return this.request.get('/pay/custom-payment/all', {
3000
3242
  filterPaymentMethods: true
3001
3243
  }, {
3002
3244
  osServer: true
3003
3245
  });
3004
3246
  case 3:
3005
- response = _context30.sent;
3247
+ response = _context33.sent;
3006
3248
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3007
3249
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3008
- return _context30.abrupt("return", this.getPaymentMethods());
3250
+ return _context33.abrupt("return", this.getPaymentMethods());
3009
3251
  case 9:
3010
- _context30.prev = 9;
3011
- _context30.t0 = _context30["catch"](0);
3252
+ _context33.prev = 9;
3253
+ _context33.t0 = _context33["catch"](0);
3012
3254
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3013
- error: _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0)
3255
+ error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
3014
3256
  });
3015
- return _context30.abrupt("return", this.getPaymentMethods());
3257
+ return _context33.abrupt("return", this.getPaymentMethods());
3016
3258
  case 13:
3017
3259
  case "end":
3018
- return _context30.stop();
3260
+ return _context33.stop();
3019
3261
  }
3020
- }, _callee30, this, [[0, 9]]);
3262
+ }, _callee33, this, [[0, 9]]);
3021
3263
  }));
3022
3264
  function getPaymentMethodsAsync() {
3023
3265
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3065,49 +3307,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3065
3307
  }, {
3066
3308
  key: "sendCustomerPayLink",
3067
3309
  value: (function () {
3068
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3069
- var orderIds, _ref24, _ref25, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3070
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3071
- while (1) switch (_context31.prev = _context31.next) {
3310
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3311
+ var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3312
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3313
+ while (1) switch (_context34.prev = _context34.next) {
3072
3314
  case 0:
3073
3315
  if (this.store.order) {
3074
- _context31.next = 2;
3316
+ _context34.next = 2;
3075
3317
  break;
3076
3318
  }
3077
3319
  throw new Error('order 模块未初始化');
3078
3320
  case 2:
3079
3321
  orderIds = params.order_ids || params.orderIds || [];
3080
3322
  if (!(!orderIds.length || params.submitBeforeSend)) {
3081
- _context31.next = 11;
3323
+ _context34.next = 11;
3082
3324
  break;
3083
3325
  }
3084
- _context31.next = 6;
3326
+ _context34.next = 6;
3085
3327
  return this.submitSalesOrder({
3086
3328
  smallTicketDataFlag: 1
3087
3329
  });
3088
3330
  case 6:
3089
- submitResult = _context31.sent;
3090
- orderId = (_ref24 = (_ref25 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref24 !== void 0 ? _ref24 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3331
+ submitResult = _context34.sent;
3332
+ orderId = (_ref25 = (_ref26 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3091
3333
  if (orderId) {
3092
- _context31.next = 10;
3334
+ _context34.next = 10;
3093
3335
  break;
3094
3336
  }
3095
3337
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3096
3338
  case 10:
3097
3339
  orderIds = [orderId];
3098
3340
  case 11:
3099
- return _context31.abrupt("return", this.store.order.sendCustomerPayLink({
3341
+ return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
3100
3342
  emails: params.emails,
3101
3343
  notify_action: params.notify_action,
3102
3344
  order_ids: orderIds
3103
3345
  }));
3104
3346
  case 12:
3105
3347
  case "end":
3106
- return _context31.stop();
3348
+ return _context34.stop();
3107
3349
  }
3108
- }, _callee31, this);
3350
+ }, _callee34, this);
3109
3351
  }));
3110
- function sendCustomerPayLink(_x24) {
3352
+ function sendCustomerPayLink(_x26) {
3111
3353
  return _sendCustomerPayLink.apply(this, arguments);
3112
3354
  }
3113
3355
  return sendCustomerPayLink;
@@ -3120,27 +3362,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3120
3362
  }, {
3121
3363
  key: "calculateProductBookingPrice",
3122
3364
  value: function () {
3123
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3365
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3124
3366
  var _params$customer_id;
3125
3367
  var quotation, customerId, authoritativeProduct, product;
3126
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3127
- while (1) switch (_context32.prev = _context32.next) {
3368
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3369
+ while (1) switch (_context35.prev = _context35.next) {
3128
3370
  case 0:
3129
3371
  quotation = this.store.quotation;
3130
3372
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3131
- _context32.next = 4;
3373
+ _context35.next = 4;
3132
3374
  return this.loadProductForPriceQuery(params, customerId);
3133
3375
  case 4:
3134
- authoritativeProduct = _context32.sent;
3376
+ authoritativeProduct = _context35.sent;
3135
3377
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3136
- _context32.next = 8;
3378
+ _context35.next = 8;
3137
3379
  return this.loadQuotationForPriceQuery({
3138
3380
  quotation: quotation,
3139
3381
  customer_id: customerId,
3140
3382
  channel: params.channel
3141
3383
  });
3142
3384
  case 8:
3143
- return _context32.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3385
+ return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3144
3386
  product: product,
3145
3387
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3146
3388
  customer_id: customerId,
@@ -3148,11 +3390,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3148
3390
  })));
3149
3391
  case 9:
3150
3392
  case "end":
3151
- return _context32.stop();
3393
+ return _context35.stop();
3152
3394
  }
3153
- }, _callee32, this);
3395
+ }, _callee35, this);
3154
3396
  }));
3155
- function calculateProductBookingPrice(_x25) {
3397
+ function calculateProductBookingPrice(_x27) {
3156
3398
  return _calculateProductBookingPrice.apply(this, arguments);
3157
3399
  }
3158
3400
  return calculateProductBookingPrice;
@@ -3160,7 +3402,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3160
3402
  }, {
3161
3403
  key: "getQuotationCustomerScopeInfo",
3162
3404
  value: function getQuotationCustomerScopeInfo() {
3163
- var _this12 = this;
3405
+ var _this13 = this;
3164
3406
  var quotation = this.store.quotation;
3165
3407
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3166
3408
  return quotation.getQuotationCustomerScopeInfo();
@@ -3172,7 +3414,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3172
3414
  }).map(function (item) {
3173
3415
  var localSeen = new Set();
3174
3416
  var customers = item.customer.filter(function (customer) {
3175
- var customerId = _this12.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3417
+ var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3176
3418
  if (!customerId || localSeen.has(customerId)) return false;
3177
3419
  localSeen.add(customerId);
3178
3420
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3222,32 +3464,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3222
3464
  }, {
3223
3465
  key: "calculateProductBookingPrices",
3224
3466
  value: function () {
3225
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paramsList) {
3467
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
3226
3468
  var _paramsList$0$custome,
3227
3469
  _paramsList$,
3228
- _this13 = this,
3470
+ _this14 = this,
3229
3471
  _paramsList$2;
3230
3472
  var quotation, customerId, productMapsByGroup, groups;
3231
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3232
- while (1) switch (_context34.prev = _context34.next) {
3473
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3474
+ while (1) switch (_context37.prev = _context37.next) {
3233
3475
  case 0:
3234
3476
  if (paramsList.length) {
3235
- _context34.next = 2;
3477
+ _context37.next = 2;
3236
3478
  break;
3237
3479
  }
3238
- return _context34.abrupt("return", []);
3480
+ return _context37.abrupt("return", []);
3239
3481
  case 2:
3240
3482
  quotation = this.store.quotation;
3241
3483
  customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
3242
3484
  productMapsByGroup = new Map();
3243
3485
  groups = new Map();
3244
3486
  paramsList.forEach(function (params) {
3245
- var _this13$otherParams;
3487
+ var _this14$otherParams;
3246
3488
  var product = params.product || {};
3247
- var productId = _this13.getPriceQueryProductId(product);
3489
+ var productId = _this14.getPriceQueryProductId(product);
3248
3490
  if (productId === null) return;
3249
- var schedule = _this13.getPriceQuerySchedule(params);
3250
- var channel = params.channel || ((_this13$otherParams = _this13.otherParams) === null || _this13$otherParams === void 0 ? void 0 : _this13$otherParams.channel);
3491
+ var schedule = _this14.getPriceQuerySchedule(params);
3492
+ var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
3251
3493
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3252
3494
  var group = groups.get(groupKey) || {
3253
3495
  ids: new Set(),
@@ -3257,51 +3499,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3257
3499
  group.ids.add(productId);
3258
3500
  groups.set(groupKey, group);
3259
3501
  });
3260
- _context34.next = 9;
3502
+ _context37.next = 9;
3261
3503
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3262
- var _ref27 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(_ref26) {
3263
- var _ref28, groupKey, group, productsById;
3264
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3265
- while (1) switch (_context33.prev = _context33.next) {
3504
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref27) {
3505
+ var _ref29, groupKey, group, productsById;
3506
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3507
+ while (1) switch (_context36.prev = _context36.next) {
3266
3508
  case 0:
3267
- _ref28 = _slicedToArray(_ref26, 2), groupKey = _ref28[0], group = _ref28[1];
3268
- _context33.next = 3;
3269
- return _this13.loadProductsForPriceQuery({
3509
+ _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3510
+ _context36.next = 3;
3511
+ return _this14.loadProductsForPriceQuery({
3270
3512
  ids: Array.from(group.ids),
3271
3513
  schedule: group.schedule,
3272
3514
  customerId: customerId,
3273
3515
  channel: group.channel
3274
3516
  });
3275
3517
  case 3:
3276
- productsById = _context33.sent;
3518
+ productsById = _context36.sent;
3277
3519
  productMapsByGroup.set(groupKey, productsById);
3278
3520
  case 5:
3279
3521
  case "end":
3280
- return _context33.stop();
3522
+ return _context36.stop();
3281
3523
  }
3282
- }, _callee33);
3524
+ }, _callee36);
3283
3525
  }));
3284
- return function (_x27) {
3285
- return _ref27.apply(this, arguments);
3526
+ return function (_x29) {
3527
+ return _ref28.apply(this, arguments);
3286
3528
  };
3287
3529
  }()));
3288
3530
  case 9:
3289
- _context34.next = 11;
3531
+ _context37.next = 11;
3290
3532
  return this.loadQuotationForPriceQuery({
3291
3533
  quotation: quotation,
3292
3534
  customer_id: customerId,
3293
3535
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3294
3536
  });
3295
3537
  case 11:
3296
- return _context34.abrupt("return", paramsList.map(function (params) {
3297
- var _this13$otherParams2, _productMapsByGroup$g;
3538
+ return _context37.abrupt("return", paramsList.map(function (params) {
3539
+ var _this14$otherParams2, _productMapsByGroup$g;
3298
3540
  var productInput = params.product || {};
3299
- var productId = _this13.getPriceQueryProductId(productInput);
3300
- var schedule = _this13.getPriceQuerySchedule(params);
3301
- var channel = params.channel || ((_this13$otherParams2 = _this13.otherParams) === null || _this13$otherParams2 === void 0 ? void 0 : _this13$otherParams2.channel);
3541
+ var productId = _this14.getPriceQueryProductId(productInput);
3542
+ var schedule = _this14.getPriceQuerySchedule(params);
3543
+ var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
3302
3544
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3303
3545
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3304
- var product = _this13.mergeProductForPriceQuery(productInput, authoritativeProduct);
3546
+ var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
3305
3547
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3306
3548
  product: product,
3307
3549
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3311,11 +3553,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3311
3553
  }));
3312
3554
  case 12:
3313
3555
  case "end":
3314
- return _context34.stop();
3556
+ return _context37.stop();
3315
3557
  }
3316
- }, _callee34, this);
3558
+ }, _callee37, this);
3317
3559
  }));
3318
- function calculateProductBookingPrices(_x26) {
3560
+ function calculateProductBookingPrices(_x28) {
3319
3561
  return _calculateProductBookingPrices.apply(this, arguments);
3320
3562
  }
3321
3563
  return calculateProductBookingPrices;
@@ -3323,34 +3565,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3323
3565
  }, {
3324
3566
  key: "addProductToOrder",
3325
3567
  value: function () {
3326
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(product, booking) {
3568
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
3327
3569
  var products;
3328
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3329
- while (1) switch (_context35.prev = _context35.next) {
3570
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3571
+ while (1) switch (_context38.prev = _context38.next) {
3330
3572
  case 0:
3331
- _context35.prev = 0;
3573
+ _context38.prev = 0;
3332
3574
  if (this.store.order) {
3333
- _context35.next = 3;
3575
+ _context38.next = 3;
3334
3576
  break;
3335
3577
  }
3336
3578
  throw new Error('order 模块未初始化');
3337
3579
  case 3:
3338
- _context35.next = 5;
3580
+ _context38.next = 5;
3339
3581
  return this.store.order.addProductToOrder(product, booking);
3340
3582
  case 5:
3341
- products = _context35.sent;
3342
- return _context35.abrupt("return", products);
3583
+ products = _context38.sent;
3584
+ return _context38.abrupt("return", products);
3343
3585
  case 9:
3344
- _context35.prev = 9;
3345
- _context35.t0 = _context35["catch"](0);
3346
- throw _context35.t0;
3586
+ _context38.prev = 9;
3587
+ _context38.t0 = _context38["catch"](0);
3588
+ throw _context38.t0;
3347
3589
  case 12:
3348
3590
  case "end":
3349
- return _context35.stop();
3591
+ return _context38.stop();
3350
3592
  }
3351
- }, _callee35, this, [[0, 9]]);
3593
+ }, _callee38, this, [[0, 9]]);
3352
3594
  }));
3353
- function addProductToOrder(_x28, _x29) {
3595
+ function addProductToOrder(_x30, _x31) {
3354
3596
  return _addProductToOrder.apply(this, arguments);
3355
3597
  }
3356
3598
  return addProductToOrder;
@@ -3358,34 +3600,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3358
3600
  }, {
3359
3601
  key: "updateOrderProduct",
3360
3602
  value: function () {
3361
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3603
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3362
3604
  var products;
3363
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3364
- while (1) switch (_context36.prev = _context36.next) {
3605
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3606
+ while (1) switch (_context39.prev = _context39.next) {
3365
3607
  case 0:
3366
- _context36.prev = 0;
3608
+ _context39.prev = 0;
3367
3609
  if (this.store.order) {
3368
- _context36.next = 3;
3610
+ _context39.next = 3;
3369
3611
  break;
3370
3612
  }
3371
3613
  throw new Error('order 模块未初始化');
3372
3614
  case 3:
3373
- _context36.next = 5;
3615
+ _context39.next = 5;
3374
3616
  return this.store.order.updateOrderProduct(params);
3375
3617
  case 5:
3376
- products = _context36.sent;
3377
- return _context36.abrupt("return", products);
3618
+ products = _context39.sent;
3619
+ return _context39.abrupt("return", products);
3378
3620
  case 9:
3379
- _context36.prev = 9;
3380
- _context36.t0 = _context36["catch"](0);
3381
- throw _context36.t0;
3621
+ _context39.prev = 9;
3622
+ _context39.t0 = _context39["catch"](0);
3623
+ throw _context39.t0;
3382
3624
  case 12:
3383
3625
  case "end":
3384
- return _context36.stop();
3626
+ return _context39.stop();
3385
3627
  }
3386
- }, _callee36, this, [[0, 9]]);
3628
+ }, _callee39, this, [[0, 9]]);
3387
3629
  }));
3388
- function updateOrderProduct(_x30) {
3630
+ function updateOrderProduct(_x32) {
3389
3631
  return _updateOrderProduct.apply(this, arguments);
3390
3632
  }
3391
3633
  return updateOrderProduct;
@@ -3393,34 +3635,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3393
3635
  }, {
3394
3636
  key: "updateOrderProducts",
3395
3637
  value: function () {
3396
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
3638
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
3397
3639
  var products;
3398
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3399
- while (1) switch (_context37.prev = _context37.next) {
3640
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3641
+ while (1) switch (_context40.prev = _context40.next) {
3400
3642
  case 0:
3401
- _context37.prev = 0;
3643
+ _context40.prev = 0;
3402
3644
  if (this.store.order) {
3403
- _context37.next = 3;
3645
+ _context40.next = 3;
3404
3646
  break;
3405
3647
  }
3406
3648
  throw new Error('order 模块未初始化');
3407
3649
  case 3:
3408
- _context37.next = 5;
3650
+ _context40.next = 5;
3409
3651
  return this.store.order.updateOrderProducts(paramsList);
3410
3652
  case 5:
3411
- products = _context37.sent;
3412
- return _context37.abrupt("return", products);
3653
+ products = _context40.sent;
3654
+ return _context40.abrupt("return", products);
3413
3655
  case 9:
3414
- _context37.prev = 9;
3415
- _context37.t0 = _context37["catch"](0);
3416
- throw _context37.t0;
3656
+ _context40.prev = 9;
3657
+ _context40.t0 = _context40["catch"](0);
3658
+ throw _context40.t0;
3417
3659
  case 12:
3418
3660
  case "end":
3419
- return _context37.stop();
3661
+ return _context40.stop();
3420
3662
  }
3421
- }, _callee37, this, [[0, 9]]);
3663
+ }, _callee40, this, [[0, 9]]);
3422
3664
  }));
3423
- function updateOrderProducts(_x31) {
3665
+ function updateOrderProducts(_x33) {
3424
3666
  return _updateOrderProducts.apply(this, arguments);
3425
3667
  }
3426
3668
  return updateOrderProducts;
@@ -3428,34 +3670,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3428
3670
  }, {
3429
3671
  key: "updateOrderProductQuantity",
3430
3672
  value: function () {
3431
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3673
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3432
3674
  var products;
3433
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3434
- while (1) switch (_context38.prev = _context38.next) {
3675
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3676
+ while (1) switch (_context41.prev = _context41.next) {
3435
3677
  case 0:
3436
- _context38.prev = 0;
3678
+ _context41.prev = 0;
3437
3679
  if (this.store.order) {
3438
- _context38.next = 3;
3680
+ _context41.next = 3;
3439
3681
  break;
3440
3682
  }
3441
3683
  throw new Error('order 模块未初始化');
3442
3684
  case 3:
3443
- _context38.next = 5;
3685
+ _context41.next = 5;
3444
3686
  return this.store.order.updateOrderProductQuantity(params);
3445
3687
  case 5:
3446
- products = _context38.sent;
3447
- return _context38.abrupt("return", products);
3688
+ products = _context41.sent;
3689
+ return _context41.abrupt("return", products);
3448
3690
  case 9:
3449
- _context38.prev = 9;
3450
- _context38.t0 = _context38["catch"](0);
3451
- throw _context38.t0;
3691
+ _context41.prev = 9;
3692
+ _context41.t0 = _context41["catch"](0);
3693
+ throw _context41.t0;
3452
3694
  case 12:
3453
3695
  case "end":
3454
- return _context38.stop();
3696
+ return _context41.stop();
3455
3697
  }
3456
- }, _callee38, this, [[0, 9]]);
3698
+ }, _callee41, this, [[0, 9]]);
3457
3699
  }));
3458
- function updateOrderProductQuantity(_x32) {
3700
+ function updateOrderProductQuantity(_x34) {
3459
3701
  return _updateOrderProductQuantity.apply(this, arguments);
3460
3702
  }
3461
3703
  return updateOrderProductQuantity;
@@ -3478,12 +3720,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3478
3720
  }, {
3479
3721
  key: "setOrderProductLineNote",
3480
3722
  value: (function () {
3481
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(identity, note) {
3723
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
3482
3724
  var params, products;
3483
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3484
- while (1) switch (_context39.prev = _context39.next) {
3725
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3726
+ while (1) switch (_context42.prev = _context42.next) {
3485
3727
  case 0:
3486
- _context39.prev = 0;
3728
+ _context42.prev = 0;
3487
3729
  params = {
3488
3730
  product_id: identity.product_id,
3489
3731
  product_variant_id: identity.product_variant_id,
@@ -3498,22 +3740,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3498
3740
  params.product_sku = identity.product_sku;
3499
3741
  }
3500
3742
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3501
- _context39.next = 7;
3743
+ _context42.next = 7;
3502
3744
  return this.updateOrderProduct(params);
3503
3745
  case 7:
3504
- products = _context39.sent;
3505
- return _context39.abrupt("return", products);
3746
+ products = _context42.sent;
3747
+ return _context42.abrupt("return", products);
3506
3748
  case 11:
3507
- _context39.prev = 11;
3508
- _context39.t0 = _context39["catch"](0);
3509
- throw _context39.t0;
3749
+ _context42.prev = 11;
3750
+ _context42.t0 = _context42["catch"](0);
3751
+ throw _context42.t0;
3510
3752
  case 14:
3511
3753
  case "end":
3512
- return _context39.stop();
3754
+ return _context42.stop();
3513
3755
  }
3514
- }, _callee39, this, [[0, 11]]);
3756
+ }, _callee42, this, [[0, 11]]);
3515
3757
  }));
3516
- function setOrderProductLineNote(_x33, _x34) {
3758
+ function setOrderProductLineNote(_x35, _x36) {
3517
3759
  return _setOrderProductLineNote.apply(this, arguments);
3518
3760
  }
3519
3761
  return setOrderProductLineNote;
@@ -3528,32 +3770,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3528
3770
  }, {
3529
3771
  key: "removeProductsFromOrder",
3530
3772
  value: (function () {
3531
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identities) {
3532
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3533
- while (1) switch (_context40.prev = _context40.next) {
3773
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities) {
3774
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3775
+ while (1) switch (_context43.prev = _context43.next) {
3534
3776
  case 0:
3535
- _context40.prev = 0;
3777
+ _context43.prev = 0;
3536
3778
  if (this.store.order) {
3537
- _context40.next = 3;
3779
+ _context43.next = 3;
3538
3780
  break;
3539
3781
  }
3540
3782
  throw new Error('order 模块未初始化');
3541
3783
  case 3:
3542
- _context40.next = 5;
3784
+ _context43.next = 5;
3543
3785
  return this.store.order.removeProductsFromOrder(identities);
3544
3786
  case 5:
3545
- return _context40.abrupt("return", _context40.sent);
3787
+ return _context43.abrupt("return", _context43.sent);
3546
3788
  case 8:
3547
- _context40.prev = 8;
3548
- _context40.t0 = _context40["catch"](0);
3549
- throw _context40.t0;
3789
+ _context43.prev = 8;
3790
+ _context43.t0 = _context43["catch"](0);
3791
+ throw _context43.t0;
3550
3792
  case 11:
3551
3793
  case "end":
3552
- return _context40.stop();
3794
+ return _context43.stop();
3553
3795
  }
3554
- }, _callee40, this, [[0, 8]]);
3796
+ }, _callee43, this, [[0, 8]]);
3555
3797
  }));
3556
- function removeProductsFromOrder(_x35) {
3798
+ function removeProductsFromOrder(_x37) {
3557
3799
  return _removeProductsFromOrder.apply(this, arguments);
3558
3800
  }
3559
3801
  return removeProductsFromOrder;
@@ -3561,18 +3803,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3561
3803
  }, {
3562
3804
  key: "removeProductFromOrder",
3563
3805
  value: function () {
3564
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(identity) {
3565
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3566
- while (1) switch (_context41.prev = _context41.next) {
3806
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identity) {
3807
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3808
+ while (1) switch (_context44.prev = _context44.next) {
3567
3809
  case 0:
3568
- return _context41.abrupt("return", this.removeProductsFromOrder([identity]));
3810
+ return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
3569
3811
  case 1:
3570
3812
  case "end":
3571
- return _context41.stop();
3813
+ return _context44.stop();
3572
3814
  }
3573
- }, _callee41, this);
3815
+ }, _callee44, this);
3574
3816
  }));
3575
- function removeProductFromOrder(_x36) {
3817
+ function removeProductFromOrder(_x38) {
3576
3818
  return _removeProductFromOrder.apply(this, arguments);
3577
3819
  }
3578
3820
  return removeProductFromOrder;
@@ -3622,23 +3864,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3622
3864
  }, {
3623
3865
  key: "applyPromotion",
3624
3866
  value: (function () {
3625
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3626
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3627
- while (1) switch (_context42.prev = _context42.next) {
3867
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3868
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3869
+ while (1) switch (_context45.prev = _context45.next) {
3628
3870
  case 0:
3629
3871
  if (this.store.order) {
3630
- _context42.next = 2;
3872
+ _context45.next = 2;
3631
3873
  break;
3632
3874
  }
3633
3875
  throw new Error('order 模块未初始化');
3634
3876
  case 2:
3635
- _context42.next = 4;
3877
+ _context45.next = 4;
3636
3878
  return this.store.order.applyPromotion();
3637
3879
  case 4:
3638
3880
  case "end":
3639
- return _context42.stop();
3881
+ return _context45.stop();
3640
3882
  }
3641
- }, _callee42, this);
3883
+ }, _callee45, this);
3642
3884
  }));
3643
3885
  function applyPromotion() {
3644
3886
  return _applyPromotion.apply(this, arguments);
@@ -3648,16 +3890,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3648
3890
  }, {
3649
3891
  key: "getUnfulfilledPromotions",
3650
3892
  value: function getUnfulfilledPromotions() {
3651
- var _this$store$order7;
3652
- return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getUnfulfilledPromotions()) || [];
3893
+ var _this$store$order8;
3894
+ return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
3653
3895
  }
3654
3896
 
3655
3897
  /** 最近一次促销计算输出的赠品操作 diff。 */
3656
3898
  }, {
3657
3899
  key: "getLastGiftActions",
3658
3900
  value: function getLastGiftActions() {
3659
- var _this$store$order8;
3660
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getLastGiftActions()) || null;
3901
+ var _this$store$order9;
3902
+ return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
3661
3903
  }
3662
3904
 
3663
3905
  // 获取商品列表
@@ -3665,18 +3907,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3665
3907
  }, {
3666
3908
  key: "getProductList",
3667
3909
  value: function () {
3668
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3910
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3669
3911
  var _this$otherParams21;
3670
3912
  var menu_list_ids, _this$store$products, res;
3671
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3672
- while (1) switch (_context43.prev = _context43.next) {
3913
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3914
+ while (1) switch (_context46.prev = _context46.next) {
3673
3915
  case 0:
3674
3916
  // 可以直接通过配置里的 menu 读取
3675
3917
  menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
3676
3918
  return Number(n.value);
3677
3919
  })) || [];
3678
- _context43.prev = 1;
3679
- _context43.next = 4;
3920
+ _context46.prev = 1;
3921
+ _context46.next = 4;
3680
3922
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3681
3923
  menu_list_ids: menu_list_ids,
3682
3924
  cacheId: this.cacheId,
@@ -3684,17 +3926,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3684
3926
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3685
3927
  });
3686
3928
  case 4:
3687
- res = _context43.sent;
3688
- return _context43.abrupt("return", res);
3929
+ res = _context46.sent;
3930
+ return _context46.abrupt("return", res);
3689
3931
  case 8:
3690
- _context43.prev = 8;
3691
- _context43.t0 = _context43["catch"](1);
3692
- throw _context43.t0;
3932
+ _context46.prev = 8;
3933
+ _context46.t0 = _context46["catch"](1);
3934
+ throw _context46.t0;
3693
3935
  case 11:
3694
3936
  case "end":
3695
- return _context43.stop();
3937
+ return _context46.stop();
3696
3938
  }
3697
- }, _callee43, this, [[1, 8]]);
3939
+ }, _callee46, this, [[1, 8]]);
3698
3940
  }));
3699
3941
  function getProductList() {
3700
3942
  return _getProductList.apply(this, arguments);
@@ -3709,33 +3951,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3709
3951
  }, {
3710
3952
  key: "setOtherParams",
3711
3953
  value: function () {
3712
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3954
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
3713
3955
  var _this$otherParams22;
3714
- var _ref29,
3715
- _ref29$cover,
3956
+ var _ref30,
3957
+ _ref30$cover,
3716
3958
  cover,
3717
- _args44 = arguments;
3718
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3719
- while (1) switch (_context44.prev = _context44.next) {
3959
+ _args47 = arguments;
3960
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3961
+ while (1) switch (_context47.prev = _context47.next) {
3720
3962
  case 0:
3721
- _ref29 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref29$cover = _ref29.cover, cover = _ref29$cover === void 0 ? false : _ref29$cover;
3963
+ _ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
3722
3964
  if (cover) {
3723
3965
  this.otherParams = _objectSpread({}, params);
3724
3966
  } else {
3725
3967
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3726
3968
  }
3727
3969
  this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3728
- _context44.next = 5;
3970
+ _context47.next = 5;
3729
3971
  return this.syncOtherParamsToSubModules(params, {
3730
3972
  cover: cover
3731
3973
  });
3732
3974
  case 5:
3733
3975
  case "end":
3734
- return _context44.stop();
3976
+ return _context47.stop();
3735
3977
  }
3736
- }, _callee44, this);
3978
+ }, _callee47, this);
3737
3979
  }));
3738
- function setOtherParams(_x37) {
3980
+ function setOtherParams(_x39) {
3739
3981
  return _setOtherParams.apply(this, arguments);
3740
3982
  }
3741
3983
  return setOtherParams;