@pisell/pisellos 2.2.173 → 2.2.175

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 (159) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Customer/index.d.ts +0 -6
  3. package/dist/modules/Customer/index.js +83 -129
  4. package/dist/modules/Customer/types.d.ts +0 -2
  5. package/dist/modules/Discount/index.d.ts +4 -2
  6. package/dist/modules/Discount/index.js +93 -8
  7. package/dist/modules/Discount/types.d.ts +7 -1
  8. package/dist/modules/Order/index.d.ts +17 -33
  9. package/dist/modules/Order/index.js +395 -757
  10. package/dist/modules/Order/types.d.ts +17 -58
  11. package/dist/modules/Order/types.js +0 -2
  12. package/dist/modules/Order/utils.d.ts +1 -39
  13. package/dist/modules/Order/utils.js +31 -219
  14. package/dist/modules/Quotation/index.js +5 -16
  15. package/dist/modules/Rules/index.d.ts +0 -4
  16. package/dist/modules/Rules/index.js +10 -26
  17. package/dist/modules/SalesSummary/index.js +2 -4
  18. package/dist/modules/Schedule/index.js +2 -6
  19. package/dist/modules/index.d.ts +0 -1
  20. package/dist/modules/index.js +1 -2
  21. package/dist/server/index.js +6 -10
  22. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  23. package/dist/server/modules/products/index.js +94 -113
  24. package/dist/server/modules/schedule/index.js +6 -13
  25. package/dist/solution/BaseSales/index.d.ts +7 -53
  26. package/dist/solution/BaseSales/index.js +339 -1160
  27. package/dist/solution/BaseSales/types.d.ts +1 -67
  28. package/dist/solution/BaseSales/types.js +1 -3
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  30. package/dist/solution/BaseSales/utils.js +8 -46
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +1 -133
  33. package/dist/solution/BookingTicket/index.js +175 -776
  34. package/dist/solution/BookingTicket/types.d.ts +0 -2
  35. package/dist/solution/BookingTicket/types.js +0 -3
  36. package/dist/solution/ScanOrder/index.d.ts +3 -9
  37. package/dist/solution/ScanOrder/index.js +128 -231
  38. package/dist/solution/ScanOrder/utils.js +8 -46
  39. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  40. package/dist/solution/ShopDiscount/index.js +23 -18
  41. package/dist/solution/VenueBooking/index.d.ts +9 -5
  42. package/dist/solution/VenueBooking/index.js +55 -103
  43. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  44. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  45. package/lib/modules/Customer/index.d.ts +0 -6
  46. package/lib/modules/Customer/index.js +11 -26
  47. package/lib/modules/Customer/types.d.ts +0 -2
  48. package/lib/modules/Discount/index.d.ts +4 -2
  49. package/lib/modules/Discount/index.js +63 -8
  50. package/lib/modules/Discount/types.d.ts +7 -1
  51. package/lib/modules/Order/index.d.ts +17 -33
  52. package/lib/modules/Order/index.js +148 -402
  53. package/lib/modules/Order/types.d.ts +17 -58
  54. package/lib/modules/Order/utils.d.ts +1 -39
  55. package/lib/modules/Order/utils.js +22 -197
  56. package/lib/modules/Quotation/index.js +6 -17
  57. package/lib/modules/Rules/index.d.ts +0 -4
  58. package/lib/modules/Rules/index.js +14 -22
  59. package/lib/modules/SalesSummary/index.js +2 -4
  60. package/lib/modules/Schedule/index.js +1 -3
  61. package/lib/modules/index.d.ts +0 -1
  62. package/lib/modules/index.js +1 -3
  63. package/lib/server/index.js +0 -2
  64. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  65. package/lib/server/modules/products/index.js +12 -23
  66. package/lib/server/modules/schedule/index.js +1 -2
  67. package/lib/solution/BaseSales/index.d.ts +7 -53
  68. package/lib/solution/BaseSales/index.js +20 -527
  69. package/lib/solution/BaseSales/types.d.ts +1 -67
  70. package/lib/solution/BaseSales/types.js +1 -3
  71. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  72. package/lib/solution/BaseSales/utils.js +6 -46
  73. package/lib/solution/BookingByStep/index.d.ts +1 -1
  74. package/lib/solution/BookingTicket/index.d.ts +1 -133
  75. package/lib/solution/BookingTicket/index.js +8 -349
  76. package/lib/solution/BookingTicket/types.d.ts +0 -2
  77. package/lib/solution/BookingTicket/types.js +0 -6
  78. package/lib/solution/ScanOrder/index.d.ts +3 -9
  79. package/lib/solution/ScanOrder/index.js +66 -147
  80. package/lib/solution/ScanOrder/utils.js +6 -46
  81. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  82. package/lib/solution/ShopDiscount/index.js +4 -2
  83. package/lib/solution/VenueBooking/index.d.ts +9 -5
  84. package/lib/solution/VenueBooking/index.js +14 -50
  85. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  86. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  87. package/package.json +2 -2
  88. package/dist/modules/BookingContext/index.d.ts +0 -37
  89. package/dist/modules/BookingContext/index.js +0 -436
  90. package/dist/modules/BookingContext/types.d.ts +0 -102
  91. package/dist/modules/BookingContext/types.js +0 -51
  92. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  93. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  94. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  95. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  96. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  97. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  98. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  99. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  100. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  101. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  102. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  103. package/dist/modules/BookingContext/utils/index.js +0 -11
  104. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  105. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  106. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  107. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  108. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  109. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  110. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  111. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  112. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  113. package/dist/modules/BookingContext/utils/resources.js +0 -486
  114. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  115. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  116. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  117. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  118. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  119. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  120. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  121. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  124. package/lib/modules/BookingContext/index.d.ts +0 -37
  125. package/lib/modules/BookingContext/index.js +0 -297
  126. package/lib/modules/BookingContext/types.d.ts +0 -102
  127. package/lib/modules/BookingContext/types.js +0 -34
  128. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  129. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  130. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  131. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  132. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  133. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  134. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  135. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  136. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  137. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  138. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  139. package/lib/modules/BookingContext/utils/index.js +0 -43
  140. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  141. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  142. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  143. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  144. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  145. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  146. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  147. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  148. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  149. package/lib/modules/BookingContext/utils/resources.js +0 -377
  150. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  151. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  152. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  153. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  154. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  155. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  156. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  157. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  158. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  159. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -26,11 +26,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
26
26
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
27
  import { BaseModule } from "../BaseModule";
28
28
  import { OrderHooks } from "./types";
29
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, sumOptionUnitPrice, clearTempOrderHolderAssignments } from "./utils";
29
+ import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments } from "./utils";
30
30
  import { isNormalProduct } from "../Product/utils";
31
31
  import dayjs from 'dayjs';
32
32
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
33
- import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
34
33
  import { DiscountModule } from "../Discount";
35
34
  import { RulesModule } from "../Rules";
36
35
  import { UnavailableReason } from "../Rules/types";
@@ -60,30 +59,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
60
59
  return _this;
61
60
  }
62
61
  _createClass(OrderModule, [{
63
- key: "applyProductDiscountPrices",
64
- value: function applyProductDiscountPrices(products) {
65
- return (products || []).map(function (product) {
66
- var _product$metadata, _product$metadata$sou, _product$metadata2, _product$metadata3, _product$original_pri;
67
- if ((_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.is_manual_discount) return product;
68
- var totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, discount) {
69
- return sum + Number(discount.amount || 0);
70
- }, 0);
71
- var optionSum = sumOptionUnitPrice(product.product_option_item);
72
- var sourcePrice = (_product$metadata$sou = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
73
- var newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
74
- var newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
75
- if (product.metadata) {
76
- product.metadata.main_product_selling_price = newMainSellingPrice;
77
- product.metadata.price_schema_version = 2;
78
- }
79
- product.selling_price = composeLinePrice({
80
- mainPrice: newMainSellingPrice,
81
- bundle: product.product_bundle
82
- });
83
- return product;
84
- });
85
- }
86
- }, {
87
62
  key: "initialize",
88
63
  value: function () {
89
64
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
@@ -119,8 +94,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
119
94
  this.orderHooks = options.hooks || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
120
95
  this.otherParams = otherParams;
121
96
  this.registerDiscountModules(options);
97
+ this.restoreTempOrderFromStorage();
122
98
  this.logInfo('OrderModule initialized successfully');
123
- case 20:
99
+ case 21:
124
100
  case "end":
125
101
  return _context.stop();
126
102
  }
@@ -220,40 +196,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
220
196
  key: "loadDiscountConfig",
221
197
  value: function () {
222
198
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
223
- var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
224
- var orderId, discountList, _this$store$discount2, _this$store$discount3;
199
+ var _this$store$discount, _this$store$tempOrder;
200
+ var discountList, _this$store$discount2;
225
201
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
226
202
  while (1) switch (_context2.prev = _context2.next) {
227
203
  case 0:
228
- orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
229
- _context2.next = 3;
230
- return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
204
+ _context2.next = 2;
205
+ return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig({
231
206
  customer_id: params.customerId,
232
- action: params.action || (orderId ? 'edit' : 'create'),
207
+ action: params.action || 'create',
233
208
  with_good_pass: 1,
234
209
  with_discount_card: 1,
235
210
  with_wallet_pass_holder: 1,
236
211
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
237
- }, orderId ? {
238
- order_id: orderId
239
- } : {}));
240
- case 3:
212
+ });
213
+ case 2:
241
214
  discountList = _context2.sent;
242
- if (!discountList) {
243
- _context2.next = 9;
244
- break;
215
+ if (discountList) {
216
+ (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
245
217
  }
246
- _context2.next = 7;
247
- return (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.setOriginalDiscountList(discountList);
248
- case 7:
249
- _context2.next = 9;
250
- return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setDiscountList(discountList);
251
- case 9:
252
- if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
218
+ if ((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.products) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length) {
253
219
  this.applyDiscount();
254
220
  }
255
- return _context2.abrupt("return", this.getDiscountList());
256
- case 11:
221
+ case 5:
257
222
  case "end":
258
223
  return _context2.stop();
259
224
  }
@@ -267,20 +232,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
267
232
  }, {
268
233
  key: "getDiscountList",
269
234
  value: function getDiscountList() {
270
- var _this$store$discount4;
271
- return ((_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.getDiscountList()) || [];
235
+ var _this$store$discount3;
236
+ return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
272
237
  }
273
238
  }, {
274
239
  key: "scanCode",
275
240
  value: function () {
276
241
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
277
- var _this$store$discount5, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
278
- var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount6;
242
+ var _this$store$discount4, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
243
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount5;
279
244
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
280
245
  while (1) switch (_context3.prev = _context3.next) {
281
246
  case 0:
282
247
  _context3.next = 2;
283
- return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.batchSearch(code, {
248
+ return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
284
249
  customerId: customerId
285
250
  });
286
251
  case 2:
@@ -289,33 +254,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
289
254
  _context3.next = 5;
290
255
  break;
291
256
  }
292
- _context3.t0 = [];
257
+ _context3.t0 = {
258
+ discountList: [],
259
+ unavailableReasonKey: null
260
+ };
293
261
  case 5:
294
- resultDiscountList = _context3.t0;
262
+ resultDiscountWithReason = _context3.t0;
263
+ resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
295
264
  rulesModule = this.store.rules;
296
265
  if (rulesModule) {
297
- _context3.next = 9;
266
+ _context3.next = 10;
298
267
  break;
299
268
  }
300
269
  return _context3.abrupt("return", {
301
270
  type: 'clientCalc',
302
271
  isAvailable: false,
303
272
  discountList: this.getDiscountList(),
304
- scannedDiscountList: resultDiscountList,
305
273
  unavailableReason: UnavailableReason.Unknown
306
274
  });
307
- case 9:
275
+ case 10:
308
276
  if (resultDiscountList.length) {
309
- _context3.next = 11;
277
+ _context3.next = 12;
310
278
  break;
311
279
  }
312
280
  return _context3.abrupt("return", {
313
281
  type: 'server',
314
282
  isAvailable: false,
315
283
  discountList: this.getDiscountList(),
316
- scannedDiscountList: resultDiscountList
284
+ unavailableReasonKey: unavailableReasonKey
317
285
  });
318
- case 11:
286
+ case 12:
319
287
  withScanList = resultDiscountList.map(function (item) {
320
288
  return _objectSpread(_objectSpread({}, item), {}, {
321
289
  isScan: true
@@ -329,16 +297,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
329
297
  return m.id === n.id;
330
298
  });
331
299
  }))) {
332
- _context3.next = 15;
300
+ _context3.next = 16;
333
301
  break;
334
302
  }
335
303
  return _context3.abrupt("return", {
336
304
  type: 'clientCalc',
337
305
  isAvailable: true,
338
- discountList: this.getDiscountList(),
339
- scannedDiscountList: resultDiscountList
306
+ discountList: this.getDiscountList()
340
307
  });
341
- case 15:
308
+ case 16:
342
309
  tempOrder = this.store.tempOrder;
343
310
  holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
344
311
  form_record_id: tempOrder.holder.form_record_id
@@ -355,17 +322,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
355
322
  discountList: this.getDiscountList()
356
323
  }, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
357
324
  if (isAvailable && newDiscountList) {
358
- (_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
325
+ (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
359
326
  this.applyDiscount();
360
327
  }
361
328
  return _context3.abrupt("return", {
362
329
  type: 'clientCalc',
363
330
  isAvailable: isAvailable || false,
364
331
  discountList: newDiscountList || this.getDiscountList(),
365
- scannedDiscountList: resultDiscountList,
366
332
  unavailableReason: unavailableReason
367
333
  });
368
- case 20:
334
+ case 21:
369
335
  case "end":
370
336
  return _context3.stop();
371
337
  }
@@ -379,16 +345,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
379
345
  }, {
380
346
  key: "applyDiscount",
381
347
  value: function applyDiscount() {
382
- var _this$store$discount7, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
348
+ var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
383
349
  var tempOrder = this.store.tempOrder;
384
350
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
385
351
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
386
- // appliedProductDetails / savedAmount 复位。
352
+ // appliedProductDetails / savedAmount 以及 tempOrder.discount_list 复位。
387
353
  if (!tempOrder) return;
388
- delete tempOrder.discount_list;
389
354
  var rulesModule = this.store.rules;
390
355
  if (!rulesModule) return;
391
- var discountList = ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
356
+ var discountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
392
357
  var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
393
358
  form_record_id: tempOrder.holder.form_record_id
394
359
  }] : [];
@@ -400,16 +365,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
400
365
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
401
366
  });
402
367
  if (result !== null && result !== void 0 && result.productList) {
403
- tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product) {
404
- return _objectSpread(_objectSpread({}, product), {}, {
405
- discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(product.discount_list, product.num))
406
- });
407
- }));
368
+ tempOrder.products = result.productList;
408
369
  }
409
370
  if (result !== null && result !== void 0 && result.discountList) {
410
- var _this$store$discount8;
371
+ var _this$store$discount7;
411
372
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
412
- (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(result.discountList);
373
+ (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
374
+ tempOrder.discount_list = result.discountList.filter(function (d) {
375
+ return d.isSelected;
376
+ });
413
377
  }
414
378
  }
415
379
 
@@ -419,25 +383,76 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
419
383
  value: function initTempOrder(params) {
420
384
  if (params.cacheId !== undefined) this.cacheId = params.cacheId;
421
385
  if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
386
+ this.restoreTempOrderFromStorage();
422
387
  }
423
388
 
424
- /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
389
+ // ─── TempOrder: localStorage 持久化 ───
425
390
  }, {
426
- key: "setEnableTempOrderPersist",
427
- value: function setEnableTempOrderPersist(_enabled) {}
428
-
429
- /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
391
+ key: "getTempOrderStorageKey",
392
+ value: function getTempOrderStorageKey() {
393
+ if (!this.cacheId) return null;
394
+ return "scanOrder:tempOrder:".concat(this.cacheId);
395
+ }
430
396
  }, {
431
- key: "isTempOrderPersistEnabled",
432
- value: function isTempOrderPersistEnabled() {
433
- return false;
397
+ key: "restoreTempOrderFromStorage",
398
+ value: function restoreTempOrderFromStorage() {
399
+ var key = this.getTempOrderStorageKey();
400
+ if (!key) return;
401
+ if (!this.window) return;
402
+ var cachedData = this.window.localStorage.getItem(key);
403
+ if (!cachedData) return;
404
+ try {
405
+ var parsedData = JSON.parse(cachedData);
406
+ if (!isTempOrder(parsedData)) {
407
+ this.window.localStorage.removeItem(key);
408
+ return;
409
+ }
410
+ if (Array.isArray(parsedData.products)) {
411
+ for (var i = 0; i < parsedData.products.length; i++) {
412
+ var p = parsedData.products[i];
413
+ if (!p || _typeof(p) !== 'object') continue;
414
+ if (!Array.isArray(p.product_option_item)) {
415
+ p.product_option_item = [];
416
+ }
417
+ if (!Array.isArray(p.product_bundle)) {
418
+ p.product_bundle = [];
419
+ }
420
+ var row = p;
421
+ // 价格 schema 迁移:重跑 normalizeOrderProduct。
422
+ // `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
423
+ // 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
424
+ // 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
425
+ // 幂等:多次 restore 不会重复叠加 option/bundle。
426
+ parsedData.products[i] = normalizeOrderProduct(row);
427
+ }
428
+ }
429
+ var parsedRecord = parsedData;
430
+ this.store.summary = parsedRecord.summary || createEmptySummary();
431
+ delete parsedData.summary;
432
+ if (parsedRecord.lastOrderInfo) {
433
+ this.store.lastOrderInfo = parsedRecord.lastOrderInfo;
434
+ delete parsedData.lastOrderInfo;
435
+ }
436
+ if (!parsedData._extend || _typeof(parsedData._extend) !== 'object') {
437
+ parsedData._extend = {
438
+ productsByUid: {}
439
+ };
440
+ } else if (!parsedData._extend.productsByUid) {
441
+ parsedData._extend.productsByUid = {};
442
+ }
443
+ this.store.tempOrder = parsedData;
444
+ } catch (_unused2) {
445
+ var _this$window;
446
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
447
+ }
434
448
  }
435
-
436
- /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
437
449
  }, {
438
450
  key: "persistTempOrder",
439
451
  value: function persistTempOrder() {
440
- // no-op: OrderModule 的刷新恢复不再依赖 localStorage。
452
+ var key = this.getTempOrderStorageKey();
453
+ if (!key || !this.store.tempOrder) return;
454
+ if (!this.window) return;
455
+ this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
441
456
  }
442
457
 
443
458
  // ─── TempOrder: 创建 & 获取 ───
@@ -706,11 +721,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
706
721
  }
707
722
  return saveDraft;
708
723
  }()
709
- }, {
710
- key: "saveDraftInBackground",
711
- value: function saveDraftInBackground() {
712
- void this.saveDraft();
713
- }
714
724
  }, {
715
725
  key: "hydrateTempOrderFromLocalRecord",
716
726
  value: function () {
@@ -802,15 +812,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
802
812
  }, {
803
813
  key: "restoreOrder",
804
814
  value: function restoreOrder() {
805
- var _this$store$discount9, _this$store$discount10;
806
815
  var freshTempOrder = this.createDefaultTempOrderInstance();
807
816
  this.ensureExternalSaleNumber(freshTempOrder);
808
817
  this.store.tempOrder = freshTempOrder;
809
818
  this.store.summary = createEmptySummary();
810
819
  this.store.lastOrderInfo = undefined;
811
- this.store.syncState = undefined;
812
- void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
813
- void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
814
820
  this.persistTempOrder();
815
821
  return freshTempOrder;
816
822
  }
@@ -819,60 +825,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
819
825
  value: function getTempOrder() {
820
826
  return this.store.tempOrder;
821
827
  }
822
- }, {
823
- key: "replaceTempOrder",
824
- value: function () {
825
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
826
- var nextTempOrder;
827
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
828
- while (1) switch (_context9.prev = _context9.next) {
829
- case 0:
830
- if (isTempOrder(tempOrder)) {
831
- _context9.next = 2;
832
- break;
833
- }
834
- throw new Error('无效的 tempOrder 数据');
835
- case 2:
836
- nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
837
- ensureIdentity: false
838
- });
839
- this.store.tempOrder = nextTempOrder;
840
- if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
841
- _context9.next = 9;
842
- break;
843
- }
844
- _context9.next = 7;
845
- return this.recalculateSummary({
846
- createIfMissing: false
847
- });
848
- case 7:
849
- _context9.next = 10;
850
- break;
851
- case 9:
852
- this.store.summary = createEmptySummary();
853
- case 10:
854
- if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
855
- this.persistTempOrder();
856
- }
857
- if (!(options !== null && options !== void 0 && options.saveDraft)) {
858
- _context9.next = 14;
859
- break;
860
- }
861
- _context9.next = 14;
862
- return this.saveDraft();
863
- case 14:
864
- return _context9.abrupt("return", nextTempOrder);
865
- case 15:
866
- case "end":
867
- return _context9.stop();
868
- }
869
- }, _callee9, this);
870
- }));
871
- function replaceTempOrder(_x10, _x11) {
872
- return _replaceTempOrder.apply(this, arguments);
873
- }
874
- return replaceTempOrder;
875
- }()
876
828
  }, {
877
829
  key: "getOrderIdentity",
878
830
  value: function getOrderIdentity() {
@@ -951,28 +903,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
951
903
  }, {
952
904
  key: "addNewOrder",
953
905
  value: function () {
954
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
906
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
955
907
  var tempOrder;
956
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
957
- while (1) switch (_context10.prev = _context10.next) {
908
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
909
+ while (1) switch (_context9.prev = _context9.next) {
958
910
  case 0:
959
911
  tempOrder = this.ensureTempOrder();
960
912
  this.ensureExternalSaleNumber(tempOrder);
961
- _context10.next = 4;
913
+ _context9.next = 4;
962
914
  return this.recalculateSummary({
963
915
  createIfMissing: true
964
916
  });
965
917
  case 4:
966
918
  this.persistTempOrder();
967
- _context10.next = 7;
919
+ _context9.next = 7;
968
920
  return this.saveDraft();
969
921
  case 7:
970
- return _context10.abrupt("return", tempOrder);
922
+ return _context9.abrupt("return", tempOrder);
971
923
  case 8:
972
924
  case "end":
973
- return _context10.stop();
925
+ return _context9.stop();
974
926
  }
975
- }, _callee10, this);
927
+ }, _callee9, this);
976
928
  }));
977
929
  function addNewOrder() {
978
930
  return _addNewOrder.apply(this, arguments);
@@ -1048,38 +1000,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1048
1000
  })
1049
1001
  };
1050
1002
  }
1051
- }, {
1052
- key: "getBookingUniqueIdentificationNumber",
1053
- value: function getBookingUniqueIdentificationNumber(booking) {
1054
- var _booking$metadata;
1055
- var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
1056
- if (uid === undefined || uid === null || uid === '') return null;
1057
- return String(uid);
1058
- }
1059
- }, {
1060
- key: "findBookingIndexByUniqueIdentificationNumber",
1061
- value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
1062
- var _this3 = this;
1063
- return (tempOrder.bookings || []).findIndex(function (booking) {
1064
- return _this3.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
1065
- });
1066
- }
1067
- }, {
1068
- key: "removeLinkedBookingsForProduct",
1069
- value: function removeLinkedBookingsForProduct(tempOrder, product) {
1070
- var _product$metadata4,
1071
- _product$metadata5,
1072
- _this4 = this;
1073
- var productUid = (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
1074
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid);
1075
- if (!productUid && !bookingUid) return;
1076
- tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
1077
- var currentBookingUid = _this4.getBookingUniqueIdentificationNumber(booking);
1078
- if (bookingUid && currentBookingUid === String(bookingUid)) return false;
1079
- if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
1080
- return true;
1081
- });
1082
- }
1083
1003
 
1084
1004
  // ─── TempOrder: 金额汇总 ───
1085
1005
  }, {
@@ -1091,23 +1011,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1091
1011
  }, {
1092
1012
  key: "recalculateSummary",
1093
1013
  value: function () {
1094
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
1014
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
1095
1015
  var tempOrder, salesSummary, existedSummary, paidPaymentSummary, emptySummary, salesSummaryResult, summary;
1096
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1097
- while (1) switch (_context11.prev = _context11.next) {
1016
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1017
+ while (1) switch (_context10.prev = _context10.next) {
1098
1018
  case 0:
1099
1019
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
1100
1020
  if (tempOrder) {
1101
- _context11.next = 3;
1021
+ _context10.next = 3;
1102
1022
  break;
1103
1023
  }
1104
- return _context11.abrupt("return", null);
1024
+ return _context10.abrupt("return", null);
1105
1025
  case 3:
1106
1026
  salesSummary = this.getSalesSummary();
1107
1027
  existedSummary = this.store.summary || createEmptySummary();
1108
1028
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
1109
1029
  if (salesSummary) {
1110
- _context11.next = 11;
1030
+ _context10.next = 11;
1111
1031
  break;
1112
1032
  }
1113
1033
  emptySummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
@@ -1118,16 +1038,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1118
1038
  });
1119
1039
  this.store.summary = emptySummary;
1120
1040
  tempOrder.surcharge_fee = emptySummary.surcharge_fee;
1121
- return _context11.abrupt("return", this.store.summary);
1041
+ return _context10.abrupt("return", this.store.summary);
1122
1042
  case 11:
1123
- _context11.next = 13;
1043
+ _context10.next = 13;
1124
1044
  return salesSummary.getSummary({
1125
1045
  products: tempOrder.products,
1126
1046
  isPriceIncludeTax: tempOrder.is_price_include_tax,
1127
1047
  shopDiscount: tempOrder.shop_discount
1128
1048
  });
1129
1049
  case 13:
1130
- salesSummaryResult = _context11.sent;
1050
+ salesSummaryResult = _context10.sent;
1131
1051
  summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
1132
1052
  total_refund_amount: existedSummary.total_refund_amount || '0.00',
1133
1053
  customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
@@ -1145,14 +1065,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1145
1065
  tempOrder.surcharges = summary.surcharges || [];
1146
1066
  tempOrder.deposit_amount = summary.deposit_amount || '0.00';
1147
1067
  tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
1148
- return _context11.abrupt("return", this.store.summary);
1068
+ return _context10.abrupt("return", this.store.summary);
1149
1069
  case 23:
1150
1070
  case "end":
1151
- return _context11.stop();
1071
+ return _context10.stop();
1152
1072
  }
1153
- }, _callee11, this);
1073
+ }, _callee10, this);
1154
1074
  }));
1155
- function recalculateSummary(_x12) {
1075
+ function recalculateSummary(_x10) {
1156
1076
  return _recalculateSummary.apply(this, arguments);
1157
1077
  }
1158
1078
  return recalculateSummary;
@@ -1160,30 +1080,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1160
1080
  }, {
1161
1081
  key: "getOrderSummary",
1162
1082
  value: function () {
1163
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1083
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1164
1084
  var summary;
1165
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1166
- while (1) switch (_context12.prev = _context12.next) {
1085
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1086
+ while (1) switch (_context11.prev = _context11.next) {
1167
1087
  case 0:
1168
- _context12.next = 2;
1088
+ _context11.next = 2;
1169
1089
  return this.recalculateSummary({
1170
1090
  createIfMissing: true
1171
1091
  });
1172
1092
  case 2:
1173
- summary = _context12.sent;
1093
+ summary = _context11.sent;
1174
1094
  if (summary) {
1175
- _context12.next = 5;
1095
+ _context11.next = 5;
1176
1096
  break;
1177
1097
  }
1178
- return _context12.abrupt("return", createEmptySummary());
1098
+ return _context11.abrupt("return", createEmptySummary());
1179
1099
  case 5:
1180
1100
  this.persistTempOrder();
1181
- return _context12.abrupt("return", summary);
1101
+ return _context11.abrupt("return", summary);
1182
1102
  case 7:
1183
1103
  case "end":
1184
- return _context12.stop();
1104
+ return _context11.stop();
1185
1105
  }
1186
- }, _callee12, this);
1106
+ }, _callee11, this);
1187
1107
  }));
1188
1108
  function getOrderSummary() {
1189
1109
  return _getOrderSummary.apply(this, arguments);
@@ -1193,46 +1113,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1193
1113
  }, {
1194
1114
  key: "updateTempOrderNote",
1195
1115
  value: function updateTempOrderNote(note) {
1196
- var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1197
1116
  var tempOrder = this.ensureTempOrder();
1198
1117
  tempOrder.note = String(note || '');
1199
1118
  this.persistTempOrder();
1200
- if (sync) {
1201
- var orderId = tempOrder.order_id;
1202
- if (!orderId) return tempOrder.note;
1203
- return this.syncTempOrderNoteToRemote(orderId, tempOrder.note);
1204
- }
1205
1119
  return tempOrder.note;
1206
1120
  }
1207
- }, {
1208
- key: "syncTempOrderNoteToRemote",
1209
- value: function () {
1210
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
1211
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1212
- while (1) switch (_context13.prev = _context13.next) {
1213
- case 0:
1214
- _context13.next = 2;
1215
- return this.request.put("/order/order/".concat(orderId, "/note"), {
1216
- note: note
1217
- });
1218
- case 2:
1219
- return _context13.abrupt("return", note);
1220
- case 3:
1221
- case "end":
1222
- return _context13.stop();
1223
- }
1224
- }, _callee13, this);
1225
- }));
1226
- function syncTempOrderNoteToRemote(_x13, _x14) {
1227
- return _syncTempOrderNoteToRemote.apply(this, arguments);
1228
- }
1229
- return syncTempOrderNoteToRemote;
1230
- }()
1231
1121
  }, {
1232
1122
  key: "getTempOrderNote",
1233
1123
  value: function getTempOrderNote() {
1234
- var _this$store$tempOrder3;
1235
- return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
1124
+ var _this$store$tempOrder2;
1125
+ return ((_this$store$tempOrder2 = this.store.tempOrder) === null || _this$store$tempOrder2 === void 0 ? void 0 : _this$store$tempOrder2.note) || '';
1236
1126
  }
1237
1127
  }, {
1238
1128
  key: "updateTempOrderShopDiscount",
@@ -1259,51 +1149,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1259
1149
  this.persistTempOrder();
1260
1150
  return tempOrder.contacts_info;
1261
1151
  }
1262
- }, {
1263
- key: "buildTempOrderCustomer",
1264
- value: function buildTempOrderCustomer(params) {
1265
- var _ref8, _ref9, _ref10, _source$name, _ref11, _ref12, _ref13, _source$customer_name, _source$id, _source$customer_id, _ref14, _source$country_calli, _source$phone, _source$email;
1266
- if (!params.customerId) return null;
1267
- var source = params.source ? cloneDeep(params.source) : {};
1268
- var name = (_ref8 = (_ref9 = (_ref10 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref10 !== void 0 ? _ref10 : source.customerName) !== null && _ref9 !== void 0 ? _ref9 : source.customer_name) !== null && _ref8 !== void 0 ? _ref8 : params.customerName;
1269
- var customerName = (_ref11 = (_ref12 = (_ref13 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref13 !== void 0 ? _ref13 : source.display_name) !== null && _ref12 !== void 0 ? _ref12 : source.name) !== null && _ref11 !== void 0 ? _ref11 : params.customerName;
1270
- return _objectSpread(_objectSpread({}, source), {}, {
1271
- id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
1272
- customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
1273
- name: String(name || ''),
1274
- customer_name: String(customerName || ''),
1275
- country_calling_code: String((_ref14 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref14 !== void 0 ? _ref14 : params.countryCallingCode),
1276
- phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
1277
- email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
1278
- });
1279
- }
1280
1152
 
1281
1153
  /**
1282
1154
  * 更新当前 tempOrder 的客户协议字段。
1283
1155
  *
1284
- * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
1156
+ * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
1285
1157
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
1286
1158
  */
1287
1159
  }, {
1288
1160
  key: "updateTempOrderCustomer",
1289
1161
  value: function updateTempOrderCustomer(customer) {
1290
- var _ref15, _ref16, _customer$customer_id, _ref17, _ref18, _ref19, _customer$customer_na, _ref20, _customer$country_cal;
1162
+ var _ref8, _ref9, _customer$customer_id, _ref10, _ref11, _ref12, _customer$customer_na, _ref13, _customer$country_cal;
1291
1163
  var tempOrder = this.ensureTempOrder();
1292
- var customerId = (_ref15 = (_ref16 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref16 !== void 0 ? _ref16 : customer.id) !== null && _ref15 !== void 0 ? _ref15 : null;
1293
- var customerName = (_ref17 = (_ref18 = (_ref19 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref19 !== void 0 ? _ref19 : customer.display_name) !== null && _ref18 !== void 0 ? _ref18 : customer.name) !== null && _ref17 !== void 0 ? _ref17 : '';
1164
+ var customerId = (_ref8 = (_ref9 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref9 !== void 0 ? _ref9 : customer.id) !== null && _ref8 !== void 0 ? _ref8 : null;
1165
+ var customerName = (_ref10 = (_ref11 = (_ref12 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref12 !== void 0 ? _ref12 : customer.display_name) !== null && _ref11 !== void 0 ? _ref11 : customer.name) !== null && _ref10 !== void 0 ? _ref10 : '';
1294
1166
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
1295
1167
  tempOrder.customer_name = String(customerName || '');
1296
- tempOrder.country_calling_code = String((_ref20 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref20 !== void 0 ? _ref20 : '');
1168
+ tempOrder.country_calling_code = String((_ref13 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref13 !== void 0 ? _ref13 : '');
1297
1169
  tempOrder.phone = String(customer.phone || '');
1298
1170
  tempOrder.email = String(customer.email || '');
1299
- tempOrder.customer = this.buildTempOrderCustomer({
1300
- source: customer,
1301
- customerId: tempOrder.customer_id,
1302
- customerName: tempOrder.customer_name,
1303
- countryCallingCode: tempOrder.country_calling_code,
1304
- phone: tempOrder.phone,
1305
- email: tempOrder.email
1306
- });
1307
1171
  this.persistTempOrder();
1308
1172
  return {
1309
1173
  customerId: tempOrder.customer_id,
@@ -1315,43 +1179,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1315
1179
  }, {
1316
1180
  key: "setOrderCustomer",
1317
1181
  value: function setOrderCustomer(patch, snapshot) {
1318
- var _tempOrder$customer_i2, _tempOrder$customer_i3;
1319
1182
  if (!patch) {
1320
1183
  this.clearOrderCustomer();
1321
1184
  return;
1322
1185
  }
1323
1186
  var tempOrder = this.ensureTempOrder();
1324
- var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
1325
1187
  tempOrder.customer_id = patch.customer_id || patch.id || null;
1326
1188
  tempOrder.customer_name = String(patch.customer_name || '');
1327
1189
  tempOrder.country_calling_code = String(patch.country_calling_code || '');
1328
1190
  tempOrder.phone = String(patch.phone || '');
1329
1191
  tempOrder.email = String(patch.email || '');
1330
- tempOrder.customer = this.buildTempOrderCustomer({
1331
- source: snapshot || null,
1332
- customerId: tempOrder.customer_id,
1333
- customerName: tempOrder.customer_name,
1334
- countryCallingCode: tempOrder.country_calling_code,
1335
- phone: tempOrder.phone,
1336
- email: tempOrder.email
1337
- });
1338
1192
  if (snapshot !== undefined) {
1339
1193
  var extend = this.ensureExtend(tempOrder);
1340
1194
  if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
1341
1195
  }
1342
- var nextCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
1343
- if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
1344
- clearTempOrderHolderAssignments(tempOrder);
1345
- }
1346
1196
  this.persistTempOrder();
1347
- this.saveDraftInBackground();
1348
1197
  this.emitOrderCustomerChange();
1349
1198
  }
1350
1199
  }, {
1351
1200
  key: "getOrderCustomer",
1352
1201
  value: function getOrderCustomer() {
1353
1202
  var tempOrder = this.store.tempOrder;
1354
- if (!tempOrder || !tempOrder.customer_id) {
1203
+ if (!tempOrder || tempOrder.customer_id === null || tempOrder.customer_id === undefined) {
1355
1204
  return null;
1356
1205
  }
1357
1206
  return {
@@ -1365,24 +1214,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1365
1214
  }, {
1366
1215
  key: "getOrderCustomerSnapshot",
1367
1216
  value: function getOrderCustomerSnapshot() {
1368
- var _this$store$tempOrder4;
1369
- var snapshot = (_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 || (_this$store$tempOrder4 = _this$store$tempOrder4._extend) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.customerSnapshot;
1217
+ var _this$store$tempOrder3;
1218
+ var snapshot = (_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 || (_this$store$tempOrder3 = _this$store$tempOrder3._extend) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.customerSnapshot;
1370
1219
  return snapshot ? cloneDeep(snapshot) : null;
1371
1220
  }
1372
1221
  }, {
1373
1222
  key: "clearOrderCustomer",
1374
1223
  value: function clearOrderCustomer() {
1375
1224
  var tempOrder = this.ensureTempOrder();
1376
- clearTempOrderHolderAssignments(tempOrder);
1377
1225
  tempOrder.customer_id = null;
1378
1226
  tempOrder.customer_name = '';
1379
1227
  tempOrder.country_calling_code = '';
1380
1228
  tempOrder.phone = '';
1381
1229
  tempOrder.email = '';
1382
- tempOrder.customer = null;
1383
1230
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
1384
1231
  this.persistTempOrder();
1385
- this.saveDraftInBackground();
1386
1232
  this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
1387
1233
  }
1388
1234
  }, {
@@ -1433,9 +1279,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1433
1279
  }, {
1434
1280
  key: "addOrderPayment",
1435
1281
  value: function addOrderPayment(payment) {
1436
- this.logInfo('addOrderPayment', {
1437
- payment: payment
1438
- });
1439
1282
  var tempOrder = this.ensureTempOrder();
1440
1283
  var mapped = mapPaymentItemsToOrderPayments([payment]);
1441
1284
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
@@ -1515,45 +1358,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1515
1358
  }, {
1516
1359
  key: "shouldMergeProductToOrder",
1517
1360
  value: function () {
1518
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1361
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
1519
1362
  var _this$orderHooks;
1520
1363
  var onBeforeMergeProductToOrder, result;
1521
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1522
- while (1) switch (_context14.prev = _context14.next) {
1364
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1365
+ while (1) switch (_context12.prev = _context12.next) {
1523
1366
  case 0:
1524
1367
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
1525
1368
  if (onBeforeMergeProductToOrder) {
1526
- _context14.next = 3;
1369
+ _context12.next = 3;
1527
1370
  break;
1528
1371
  }
1529
- return _context14.abrupt("return", true);
1372
+ return _context12.abrupt("return", true);
1530
1373
  case 3:
1531
- _context14.next = 5;
1374
+ _context12.next = 5;
1532
1375
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
1533
1376
  defaultShouldMerge: true
1534
1377
  }));
1535
1378
  case 5:
1536
- result = _context14.sent;
1379
+ result = _context12.sent;
1537
1380
  if (!(typeof result === 'boolean')) {
1538
- _context14.next = 8;
1381
+ _context12.next = 8;
1539
1382
  break;
1540
1383
  }
1541
- return _context14.abrupt("return", result);
1384
+ return _context12.abrupt("return", result);
1542
1385
  case 8:
1543
1386
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
1544
- _context14.next = 10;
1387
+ _context12.next = 10;
1545
1388
  break;
1546
1389
  }
1547
- return _context14.abrupt("return", result.shouldMerge);
1390
+ return _context12.abrupt("return", result.shouldMerge);
1548
1391
  case 10:
1549
- return _context14.abrupt("return", true);
1392
+ return _context12.abrupt("return", true);
1550
1393
  case 11:
1551
1394
  case "end":
1552
- return _context14.stop();
1395
+ return _context12.stop();
1553
1396
  }
1554
- }, _callee14, this);
1397
+ }, _callee12, this);
1555
1398
  }));
1556
- function shouldMergeProductToOrder(_x15) {
1399
+ function shouldMergeProductToOrder(_x11) {
1557
1400
  return _shouldMergeProductToOrder.apply(this, arguments);
1558
1401
  }
1559
1402
  return shouldMergeProductToOrder;
@@ -1561,11 +1404,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1561
1404
  }, {
1562
1405
  key: "addProductToOrder",
1563
1406
  value: function () {
1564
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
1565
- var _this5 = this;
1407
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(product, booking) {
1408
+ var _this3 = this;
1566
1409
  var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
1567
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1568
- while (1) switch (_context15.prev = _context15.next) {
1410
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1411
+ while (1) switch (_context13.prev = _context13.next) {
1569
1412
  case 0:
1570
1413
  tempOrder = this.ensureTempOrder();
1571
1414
  linked = booking ? this.createLinkedProductAndBooking({
@@ -1575,11 +1418,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1575
1418
  productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
1576
1419
  incomingFingerprint = buildProductLineFingerprint(productToAdd.product_option_item, productToAdd.product_bundle);
1577
1420
  normalizedIncoming = normalizeOrderProduct(productToAdd);
1578
- normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
1579
1421
  hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
1580
1422
  shouldForceNewLine = !!booking;
1581
1423
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
1582
- if (_this5.hasGoodPassDiscount(item)) return false;
1424
+ if (_this3.hasGoodPassDiscount(item)) return false;
1583
1425
  if (item.product_id !== productToAdd.product_id) return false;
1584
1426
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
1585
1427
  var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
@@ -1588,10 +1430,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1588
1430
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
1589
1431
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
1590
1432
  if (!matchedProduct) {
1591
- _context15.next = 17;
1433
+ _context13.next = 16;
1592
1434
  break;
1593
1435
  }
1594
- _context15.next = 14;
1436
+ _context13.next = 13;
1595
1437
  return this.shouldMergeProductToOrder({
1596
1438
  incomingProduct: productToAdd,
1597
1439
  normalizedIncoming: normalizedIncoming,
@@ -1602,14 +1444,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1602
1444
  tempOrder: tempOrder,
1603
1445
  booking: booking
1604
1446
  });
1605
- case 14:
1606
- _context15.t0 = _context15.sent;
1607
- _context15.next = 18;
1447
+ case 13:
1448
+ _context13.t0 = _context13.sent;
1449
+ _context13.next = 17;
1608
1450
  break;
1451
+ case 16:
1452
+ _context13.t0 = false;
1609
1453
  case 17:
1610
- _context15.t0 = false;
1611
- case 18:
1612
- shouldMerge = _context15.t0;
1454
+ shouldMerge = _context13.t0;
1613
1455
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
1614
1456
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
1615
1457
  if (linked) {
@@ -1627,7 +1469,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1627
1469
  unique_identification_number: targetUid
1628
1470
  })
1629
1471
  }));
1630
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
1631
1472
  tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
1632
1473
  metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
1633
1474
  unique_identification_number: targetUid
@@ -1642,20 +1483,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1642
1483
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1643
1484
  }
1644
1485
  this.applyDiscount();
1645
- _context15.next = 24;
1486
+ _context13.next = 23;
1646
1487
  return this.recalculateSummary({
1647
1488
  createIfMissing: true
1648
1489
  });
1649
- case 24:
1490
+ case 23:
1650
1491
  this.persistTempOrder();
1651
- return _context15.abrupt("return", tempOrder.products);
1652
- case 26:
1492
+ return _context13.abrupt("return", tempOrder.products);
1493
+ case 25:
1653
1494
  case "end":
1654
- return _context15.stop();
1495
+ return _context13.stop();
1655
1496
  }
1656
- }, _callee15, this);
1497
+ }, _callee13, this);
1657
1498
  }));
1658
- function addProductToOrder(_x16, _x17) {
1499
+ function addProductToOrder(_x12, _x13) {
1659
1500
  return _addProductToOrder.apply(this, arguments);
1660
1501
  }
1661
1502
  return addProductToOrder;
@@ -1680,15 +1521,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1680
1521
  });
1681
1522
  }
1682
1523
  }, {
1683
- key: "updateOrderProduct",
1524
+ key: "updateProductInOrder",
1684
1525
  value: function () {
1685
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1526
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1686
1527
  var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
1687
- var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, _normalizedProduct$me, _targetProduct$metada3, productUid, linked;
1688
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1689
- while (1) switch (_context16.prev = _context16.next) {
1528
+ var product_id, product_variant_id, updates, unique_identification_number, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
1529
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1530
+ while (1) switch (_context14.prev = _context14.next) {
1690
1531
  case 0:
1691
- product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle, booking = params.booking;
1532
+ product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
1692
1533
  tempOrder = this.ensureTempOrder();
1693
1534
  identityLookup = {
1694
1535
  product_id: product_id,
@@ -1696,32 +1537,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1696
1537
  };
1697
1538
  if (unique_identification_number !== undefined) {
1698
1539
  identityLookup.unique_identification_number = unique_identification_number;
1699
- if (identity_key === undefined) {
1700
- identityLookup.identity_key = unique_identification_number;
1701
- }
1702
- }
1703
- if (identity_key !== undefined) {
1704
- identityLookup.identity_key = identity_key;
1705
1540
  }
1706
1541
  if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
1707
1542
  if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
1708
- productIndex = -1;
1709
- if (unique_identification_number !== undefined) {
1710
- targetUid = String(unique_identification_number);
1711
- productIndex = tempOrder.products.findIndex(function (item) {
1712
- var _item$metadata;
1713
- return String(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.unique_identification_number) || item.unique_identification_number || '') === targetUid;
1714
- });
1715
- }
1716
- if (productIndex === -1) {
1717
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1718
- }
1543
+ productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1719
1544
  if (!(productIndex === -1)) {
1720
- _context16.next = 12;
1545
+ _context14.next = 9;
1721
1546
  break;
1722
1547
  }
1723
1548
  throw new Error('[Order] 目标商品不存在,无法更新');
1724
- case 12:
1549
+ case 9:
1725
1550
  targetProduct = tempOrder.products[productIndex];
1726
1551
  nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
1727
1552
  product_id: product_id,
@@ -1749,218 +1574,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1749
1574
  }
1750
1575
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
1751
1576
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
1752
- normalizedProduct = normalizeOrderProduct(nextProduct);
1753
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
1754
- if (booking) {
1755
- productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.unique_identification_number) || unique_identification_number || createUuidV4());
1756
- normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
1757
- unique_identification_number: productUid
1758
- });
1759
- linked = this.createLinkedProductAndBooking({
1760
- product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
1761
- unique_identification_number: productUid
1762
- }),
1763
- booking: booking
1764
- });
1765
- this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
1766
- normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
1767
- booking_uid: linked.bookingUid,
1768
- metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
1769
- booking_uid: linked.bookingUid,
1770
- unique_identification_number: productUid
1771
- })
1772
- });
1773
- tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1774
- }
1775
- tempOrder.products[productIndex] = normalizedProduct;
1577
+ tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
1776
1578
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
1777
1579
  this.applyDiscount();
1778
- _context16.next = 26;
1779
- return this.recalculateSummary({
1780
- createIfMissing: true
1781
- });
1782
- case 26:
1783
- this.persistTempOrder();
1784
- return _context16.abrupt("return", tempOrder.products);
1785
- case 28:
1786
- case "end":
1787
- return _context16.stop();
1788
- }
1789
- }, _callee16, this);
1790
- }));
1791
- function updateOrderProduct(_x18) {
1792
- return _updateOrderProduct.apply(this, arguments);
1793
- }
1794
- return updateOrderProduct;
1795
- }()
1796
- }, {
1797
- key: "updateOrderProductQuantity",
1798
- value: function () {
1799
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1800
- var _targetProduct$metada4;
1801
- var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
1802
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1803
- while (1) switch (_context17.prev = _context17.next) {
1804
- case 0:
1805
- product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
1806
- tempOrder = this.ensureTempOrder();
1807
- identityLookup = {
1808
- product_id: product_id,
1809
- product_variant_id: product_variant_id
1810
- };
1811
- if (unique_identification_number !== undefined) {
1812
- identityLookup.unique_identification_number = unique_identification_number;
1813
- if (identity_key === undefined) {
1814
- identityLookup.identity_key = unique_identification_number;
1815
- }
1816
- }
1817
- if (identity_key !== undefined) identityLookup.identity_key = identity_key;
1818
- if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
1819
- if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
1820
- productIndex = -1;
1821
- if (unique_identification_number !== undefined) {
1822
- targetUid = String(unique_identification_number);
1823
- productIndex = tempOrder.products.findIndex(function (item) {
1824
- var _item$metadata2;
1825
- return String(((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_identification_number) || item.unique_identification_number || '') === targetUid;
1826
- });
1827
- }
1828
- if (productIndex === -1) {
1829
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1830
- }
1831
- if (!(productIndex === -1)) {
1832
- _context17.next = 12;
1833
- break;
1834
- }
1835
- throw new Error('[Order] 目标商品不存在,无法更新数量');
1836
- case 12:
1837
- targetProduct = tempOrder.products[productIndex];
1838
- normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
1839
- num: getSafeProductNum(num),
1840
- metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
1841
- unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
1842
- })
1843
- }));
1844
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
1845
- tempOrder.products[productIndex] = normalizedProduct;
1846
- this.applyDiscount();
1847
- _context17.next = 19;
1580
+ _context14.next = 20;
1848
1581
  return this.recalculateSummary({
1849
1582
  createIfMissing: true
1850
1583
  });
1851
- case 19:
1584
+ case 20:
1852
1585
  this.persistTempOrder();
1853
- return _context17.abrupt("return", tempOrder.products);
1854
- case 21:
1586
+ return _context14.abrupt("return", tempOrder.products);
1587
+ case 22:
1855
1588
  case "end":
1856
- return _context17.stop();
1589
+ return _context14.stop();
1857
1590
  }
1858
- }, _callee17, this);
1591
+ }, _callee14, this);
1859
1592
  }));
1860
- function updateOrderProductQuantity(_x19) {
1861
- return _updateOrderProductQuantity.apply(this, arguments);
1593
+ function updateProductInOrder(_x14) {
1594
+ return _updateProductInOrder.apply(this, arguments);
1862
1595
  }
1863
- return updateOrderProductQuantity;
1596
+ return updateProductInOrder;
1864
1597
  }()
1865
- }, {
1866
- key: "updateOrderBooking",
1867
- value: function updateOrderBooking(params) {
1868
- var unique_identification_number = params.unique_identification_number,
1869
- updates = params.updates;
1870
- var tempOrder = this.ensureTempOrder();
1871
- var bookingUid = String(unique_identification_number || '');
1872
- var bookingIndex = this.findBookingIndexByUniqueIdentificationNumber(tempOrder, bookingUid);
1873
- if (!bookingUid || bookingIndex === -1) {
1874
- throw new Error('[Order] 目标 booking 不存在,无法更新');
1875
- }
1876
- var targetBooking = tempOrder.bookings[bookingIndex] || {};
1877
- var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
1878
- metadata: _objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), {}, {
1879
- unique_identification_number: bookingUid
1880
- })
1881
- });
1882
- nextBooking.is_all = normalizeBookingIsAll(nextBooking);
1883
- nextBooking.sub_type = normalizeBookingSubType(nextBooking);
1884
- tempOrder.bookings[bookingIndex] = nextBooking;
1885
- this.persistTempOrder();
1886
- return tempOrder.bookings;
1887
- }
1888
1598
  }, {
1889
1599
  key: "removeProductFromOrder",
1890
1600
  value: function () {
1891
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
1892
- var tempOrder, removedProducts, _i, _removedProducts, product;
1893
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1894
- while (1) switch (_context18.prev = _context18.next) {
1601
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(identity) {
1602
+ var tempOrder;
1603
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1604
+ while (1) switch (_context15.prev = _context15.next) {
1895
1605
  case 0:
1896
1606
  tempOrder = this.ensureTempOrder();
1897
- removedProducts = [];
1898
1607
  tempOrder.products = tempOrder.products.filter(function (item) {
1899
- var shouldRemove = isIdentityMatch(item, identity);
1900
- if (shouldRemove) removedProducts.push(item);
1901
- return !shouldRemove;
1608
+ return !isIdentityMatch(item, identity);
1902
1609
  });
1903
- for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
1904
- product = _removedProducts[_i];
1905
- this.removeLinkedBookingsForProduct(tempOrder, product);
1906
- }
1907
1610
  this.applyDiscount();
1908
- _context18.next = 7;
1611
+ _context15.next = 5;
1909
1612
  return this.recalculateSummary({
1910
1613
  createIfMissing: true
1911
1614
  });
1912
- case 7:
1615
+ case 5:
1913
1616
  this.persistTempOrder();
1914
- return _context18.abrupt("return", tempOrder.products);
1915
- case 9:
1617
+ return _context15.abrupt("return", tempOrder.products);
1618
+ case 7:
1916
1619
  case "end":
1917
- return _context18.stop();
1620
+ return _context15.stop();
1918
1621
  }
1919
- }, _callee18, this);
1622
+ }, _callee15, this);
1920
1623
  }));
1921
- function removeProductFromOrder(_x20) {
1624
+ function removeProductFromOrder(_x15) {
1922
1625
  return _removeProductFromOrder.apply(this, arguments);
1923
1626
  }
1924
1627
  return removeProductFromOrder;
1925
- }()
1926
- /**
1927
- * 仅清空购物车行(products / bookings),不重置整单。
1928
- * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
1929
- */
1930
- }, {
1931
- key: "clearOrderCartLines",
1932
- value: (function () {
1933
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1934
- var tempOrder;
1935
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1936
- while (1) switch (_context19.prev = _context19.next) {
1937
- case 0:
1938
- tempOrder = this.ensureTempOrder();
1939
- tempOrder.products = [];
1940
- tempOrder.bookings = [];
1941
- if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
1942
- tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
1943
- productsByUid: {}
1944
- });
1945
- }
1946
- this.applyDiscount();
1947
- _context19.next = 7;
1948
- return this.recalculateSummary({
1949
- createIfMissing: true
1950
- });
1951
- case 7:
1952
- this.persistTempOrder();
1953
- return _context19.abrupt("return", tempOrder);
1954
- case 9:
1955
- case "end":
1956
- return _context19.stop();
1957
- }
1958
- }, _callee19, this);
1959
- }));
1960
- function clearOrderCartLines() {
1961
- return _clearOrderCartLines.apply(this, arguments);
1962
- }
1963
- return clearOrderCartLines;
1964
1628
  }() // ─── TempOrder: 提交 ───
1965
1629
  /**
1966
1630
  * 提交当前 Sales tempOrder。
@@ -1968,15 +1632,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1968
1632
  * smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
1969
1633
  * 应传 1,确保 /order/sales/checkout 返回打印所需数据。
1970
1634
  */
1971
- )
1972
1635
  }, {
1973
1636
  key: "submitTempOrder",
1974
1637
  value: function () {
1975
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1638
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1976
1639
  var _params$cacheId, _this$otherParams;
1977
1640
  var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
1978
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1979
- while (1) switch (_context20.prev = _context20.next) {
1641
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1642
+ while (1) switch (_context16.prev = _context16.next) {
1980
1643
  case 0:
1981
1644
  tempOrder = this.ensureTempOrder();
1982
1645
  this.persistTempOrder();
@@ -2003,10 +1666,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2003
1666
  type: params === null || params === void 0 ? void 0 : params.type,
2004
1667
  enhance: enhancePayload
2005
1668
  });
2006
- _context20.next = 10;
1669
+ _context16.next = 10;
2007
1670
  return this.saveDraft();
2008
1671
  case 10:
2009
- _context20.prev = 10;
1672
+ _context16.prev = 10;
2010
1673
  this.logInfo('submitTempOrder calling sales checkout', {
2011
1674
  orderId: payload.order_id,
2012
1675
  externalSaleNumber: payload.external_sale_number,
@@ -2014,62 +1677,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2014
1677
  paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
2015
1678
  smallTicketDataFlag: payload.small_ticket_data_flag
2016
1679
  });
2017
- _context20.next = 14;
1680
+ _context16.next = 14;
2018
1681
  return this.submitSalesOrder({
2019
1682
  query: payload
2020
1683
  });
2021
1684
  case 14:
2022
- result = _context20.sent;
2023
- _context20.next = 27;
1685
+ result = _context16.sent;
1686
+ _context16.next = 27;
2024
1687
  break;
2025
1688
  case 17:
2026
- _context20.prev = 17;
2027
- _context20.t0 = _context20["catch"](10);
2028
- backendErrorResponse = this.extractSubmitErrorResponse(_context20.t0);
1689
+ _context16.prev = 17;
1690
+ _context16.t0 = _context16["catch"](10);
1691
+ backendErrorResponse = this.extractSubmitErrorResponse(_context16.t0);
2029
1692
  if (!backendErrorResponse) {
2030
- _context20.next = 24;
1693
+ _context16.next = 24;
2031
1694
  break;
2032
1695
  }
2033
1696
  this.store.syncState = 'failed';
2034
1697
  this.logSubmitBackendRejected(backendErrorResponse, payload);
2035
- return _context20.abrupt("return", backendErrorResponse);
1698
+ return _context16.abrupt("return", backendErrorResponse);
2036
1699
  case 24:
2037
1700
  this.store.syncState = 'failed';
2038
1701
  this.logError('submitTempOrder failed', {
2039
- error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
1702
+ error: _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0),
2040
1703
  orderId: payload.order_id,
2041
1704
  externalSaleNumber: payload.external_sale_number,
2042
1705
  paymentStatus: payload.payment_status,
2043
1706
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
2044
1707
  });
2045
- throw _context20.t0;
1708
+ throw _context16.t0;
2046
1709
  case 27:
2047
1710
  if (!this.isSubmitResponseRejected(result)) {
2048
- _context20.next = 31;
1711
+ _context16.next = 31;
2049
1712
  break;
2050
1713
  }
2051
1714
  this.store.syncState = 'failed';
2052
1715
  this.logSubmitBackendRejected(result, payload);
2053
- return _context20.abrupt("return", result);
1716
+ return _context16.abrupt("return", result);
2054
1717
  case 31:
2055
1718
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
2056
1719
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
2057
- _context20.next = 37;
1720
+ _context16.next = 37;
2058
1721
  break;
2059
1722
  }
2060
1723
  tempOrder.order_id = submittedOrderId;
2061
1724
  resultRecord = result;
2062
- _context20.next = 37;
1725
+ _context16.next = 37;
2063
1726
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
2064
1727
  case 37:
2065
- return _context20.abrupt("return", result);
1728
+ return _context16.abrupt("return", result);
2066
1729
  case 38:
2067
1730
  case "end":
2068
- return _context20.stop();
1731
+ return _context16.stop();
2069
1732
  }
2070
- }, _callee20, this, [[10, 17]]);
1733
+ }, _callee16, this, [[10, 17]]);
2071
1734
  }));
2072
- function submitTempOrder(_x21) {
1735
+ function submitTempOrder(_x16) {
2073
1736
  return _submitTempOrder.apply(this, arguments);
2074
1737
  }
2075
1738
  return submitTempOrder;
@@ -2077,25 +1740,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2077
1740
  }, {
2078
1741
  key: "markLocalOrderSynced",
2079
1742
  value: function () {
2080
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderId, remoteOrder) {
1743
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderId, remoteOrder) {
2081
1744
  var tempOrder;
2082
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2083
- while (1) switch (_context21.prev = _context21.next) {
1745
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1746
+ while (1) switch (_context17.prev = _context17.next) {
2084
1747
  case 0:
2085
1748
  tempOrder = this.ensureTempOrder();
2086
1749
  tempOrder.order_id = orderId;
2087
1750
  this.store.lastOrderInfo = remoteOrder;
2088
1751
  this.store.syncState = 'submitted';
2089
1752
  this.persistTempOrder();
2090
- _context21.next = 7;
1753
+ _context17.next = 7;
2091
1754
  return this.saveDraft();
2092
1755
  case 7:
2093
1756
  case "end":
2094
- return _context21.stop();
1757
+ return _context17.stop();
2095
1758
  }
2096
- }, _callee21, this);
1759
+ }, _callee17, this);
2097
1760
  }));
2098
- function markLocalOrderSynced(_x22, _x23) {
1761
+ function markLocalOrderSynced(_x17, _x18) {
2099
1762
  return _markLocalOrderSynced.apply(this, arguments);
2100
1763
  }
2101
1764
  return markLocalOrderSynced;
@@ -2119,10 +1782,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2119
1782
  value: function extractSubmitErrorResponse(error) {
2120
1783
  var _error$response,
2121
1784
  _error$response2,
2122
- _this6 = this;
1785
+ _this4 = this;
2123
1786
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
2124
1787
  return candidates.find(function (candidate) {
2125
- return _this6.isSubmitErrorResponse(candidate);
1788
+ return _this4.isSubmitErrorResponse(candidate);
2126
1789
  }) || null;
2127
1790
  }
2128
1791
  }, {
@@ -2142,60 +1805,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2142
1805
  }, {
2143
1806
  key: "syncPaymentsToOrder",
2144
1807
  value: function () {
2145
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2146
- var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
2147
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2148
- while (1) switch (_context22.prev = _context22.next) {
1808
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1809
+ var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, submitResult;
1810
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1811
+ while (1) switch (_context18.prev = _context18.next) {
2149
1812
  case 0:
2150
1813
  tempOrder = this.ensureTempOrder();
2151
1814
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
2152
- paymentTotal = this.calculatePaymentTotal(mappedPayments);
2153
- targetAmount = this.getPaymentTargetAmount();
2154
- isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
2155
- paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
2156
1815
  tempOrder.payments = mappedPayments;
2157
- tempOrder.payment_status = paymentStatus;
1816
+ if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
2158
1817
  this.persistTempOrder();
2159
- _context22.next = 11;
1818
+ _context18.next = 7;
2160
1819
  return this.saveDraft();
2161
- case 11:
2162
- if (params.submitWhenPaid) {
2163
- _context22.next = 13;
2164
- break;
2165
- }
2166
- return _context22.abrupt("return", {
2167
- isFullyPaid: isFullyPaid
2168
- });
2169
- case 13:
2170
- if (!(this.store.syncState === 'submitting')) {
2171
- _context22.next = 15;
1820
+ case 7:
1821
+ paymentTotal = this.calculatePaymentTotal(mappedPayments);
1822
+ targetAmount = this.getPaymentTargetAmount();
1823
+ isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
1824
+ if (!(!isFullyPaid || !params.submitWhenPaid)) {
1825
+ _context18.next = 12;
2172
1826
  break;
2173
1827
  }
2174
- return _context22.abrupt("return", {
1828
+ return _context18.abrupt("return", {
2175
1829
  isFullyPaid: isFullyPaid
2176
1830
  });
2177
- case 15:
2178
- this.store.syncState = 'submitting';
2179
- _context22.next = 18;
1831
+ case 12:
1832
+ _context18.next = 14;
2180
1833
  return this.submitTempOrder({
2181
1834
  payments: mappedPayments,
2182
- paymentStatus: paymentStatus,
2183
- smallTicketDataFlag: params.smallTicketDataFlag,
2184
- channel: params.channel
1835
+ paymentStatus: params.paymentStatus || 'paid',
1836
+ smallTicketDataFlag: params.smallTicketDataFlag
2185
1837
  });
2186
- case 18:
2187
- submitResult = _context22.sent;
2188
- return _context22.abrupt("return", {
1838
+ case 14:
1839
+ submitResult = _context18.sent;
1840
+ return _context18.abrupt("return", {
2189
1841
  isFullyPaid: isFullyPaid,
2190
1842
  submitResult: submitResult
2191
1843
  });
2192
- case 20:
1844
+ case 16:
2193
1845
  case "end":
2194
- return _context22.stop();
1846
+ return _context18.stop();
2195
1847
  }
2196
- }, _callee22, this);
1848
+ }, _callee18, this);
2197
1849
  }));
2198
- function syncPaymentsToOrder(_x24) {
1850
+ function syncPaymentsToOrder(_x19) {
2199
1851
  return _syncPaymentsToOrder.apply(this, arguments);
2200
1852
  }
2201
1853
  return syncPaymentsToOrder;
@@ -2284,11 +1936,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2284
1936
  }, {
2285
1937
  key: "submitOrder",
2286
1938
  value: function () {
2287
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(order) {
1939
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order) {
2288
1940
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
2289
1941
  var url, query, fetchUrl, params;
2290
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2291
- while (1) switch (_context23.prev = _context23.next) {
1942
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1943
+ while (1) switch (_context19.prev = _context19.next) {
2292
1944
  case 0:
2293
1945
  this.logInfo('submitOrder called', {
2294
1946
  url: order.url,
@@ -2308,14 +1960,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2308
1960
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
2309
1961
  scheduleDate: params.schedule_date
2310
1962
  });
2311
- return _context23.abrupt("return", this.request.post(fetchUrl, params));
1963
+ return _context19.abrupt("return", this.request.post(fetchUrl, params));
2312
1964
  case 6:
2313
1965
  case "end":
2314
- return _context23.stop();
1966
+ return _context19.stop();
2315
1967
  }
2316
- }, _callee23, this);
1968
+ }, _callee19, this);
2317
1969
  }));
2318
- function submitOrder(_x25) {
1970
+ function submitOrder(_x20) {
2319
1971
  return _submitOrder.apply(this, arguments);
2320
1972
  }
2321
1973
  return submitOrder;
@@ -2323,13 +1975,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2323
1975
  }, {
2324
1976
  key: "cancelOrder",
2325
1977
  value: function () {
2326
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
1978
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2327
1979
  var payload;
2328
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2329
- while (1) switch (_context24.prev = _context24.next) {
1980
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1981
+ while (1) switch (_context20.prev = _context20.next) {
2330
1982
  case 0:
2331
1983
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
2332
- _context24.next = 2;
1984
+ _context20.next = 2;
2333
1985
  break;
2334
1986
  }
2335
1987
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -2345,16 +1997,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2345
1997
  method: 'PUT',
2346
1998
  orderIdsCount: params.order_ids.length
2347
1999
  });
2348
- return _context24.abrupt("return", this.request.put('/order/update-status', payload, {
2000
+ return _context20.abrupt("return", this.request.put('/order/update-status', payload, {
2349
2001
  isShopApi: true
2350
2002
  }));
2351
2003
  case 5:
2352
2004
  case "end":
2353
- return _context24.stop();
2005
+ return _context20.stop();
2354
2006
  }
2355
- }, _callee24, this);
2007
+ }, _callee20, this);
2356
2008
  }));
2357
- function cancelOrder(_x26) {
2009
+ function cancelOrder(_x21) {
2358
2010
  return _cancelOrder.apply(this, arguments);
2359
2011
  }
2360
2012
  return cancelOrder;
@@ -2362,19 +2014,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2362
2014
  }, {
2363
2015
  key: "changeBookingStatus",
2364
2016
  value: function () {
2365
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2017
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2366
2018
  var url, payload;
2367
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2368
- while (1) switch (_context25.prev = _context25.next) {
2019
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2020
+ while (1) switch (_context21.prev = _context21.next) {
2369
2021
  case 0:
2370
2022
  if (params.booking_id) {
2371
- _context25.next = 2;
2023
+ _context21.next = 2;
2372
2024
  break;
2373
2025
  }
2374
2026
  throw new Error('变更预约状态失败:booking_id 不能为空');
2375
2027
  case 2:
2376
2028
  if (params.appointment_status) {
2377
- _context25.next = 4;
2029
+ _context21.next = 4;
2378
2030
  break;
2379
2031
  }
2380
2032
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -2389,16 +2041,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2389
2041
  bookingId: params.booking_id,
2390
2042
  appointmentStatus: params.appointment_status
2391
2043
  });
2392
- return _context25.abrupt("return", this.request.put(url, payload, {
2044
+ return _context21.abrupt("return", this.request.put(url, payload, {
2393
2045
  isShopApi: true
2394
2046
  }));
2395
2047
  case 8:
2396
2048
  case "end":
2397
- return _context25.stop();
2049
+ return _context21.stop();
2398
2050
  }
2399
- }, _callee25, this);
2051
+ }, _callee21, this);
2400
2052
  }));
2401
- function changeBookingStatus(_x27) {
2053
+ function changeBookingStatus(_x22) {
2402
2054
  return _changeBookingStatus.apply(this, arguments);
2403
2055
  }
2404
2056
  return changeBookingStatus;
@@ -2416,11 +2068,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2416
2068
  }, {
2417
2069
  key: "createOrderByCheckout",
2418
2070
  value: (function () {
2419
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2071
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2420
2072
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
2421
2073
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
2422
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2423
- while (1) switch (_context26.prev = _context26.next) {
2074
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2075
+ while (1) switch (_context22.prev = _context22.next) {
2424
2076
  case 0:
2425
2077
  // 过滤掉由在线店铺下单的 payment 支付数据
2426
2078
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -2454,7 +2106,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2454
2106
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
2455
2107
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
2456
2108
  });
2457
- _context26.prev = 4;
2109
+ _context22.prev = 4;
2458
2110
  // 构建订单数据,设置默认值并允许 params 覆盖
2459
2111
  orderData = _objectSpread({
2460
2112
  sales_channel: 'my_pisel',
@@ -2518,10 +2170,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2518
2170
  });
2519
2171
 
2520
2172
  // 调用后端接口
2521
- _context26.next = 12;
2173
+ _context22.next = 12;
2522
2174
  return this.request.post('/order/checkout', orderData);
2523
2175
  case 12:
2524
- response = _context26.sent;
2176
+ response = _context22.sent;
2525
2177
  this.logInfo('Order API called successfully', {
2526
2178
  response: response
2527
2179
  });
@@ -2529,22 +2181,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2529
2181
  success: !!response,
2530
2182
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
2531
2183
  });
2532
- return _context26.abrupt("return", response);
2184
+ return _context22.abrupt("return", response);
2533
2185
  case 18:
2534
- _context26.prev = 18;
2535
- _context26.t0 = _context26["catch"](4);
2536
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context26.t0);
2186
+ _context22.prev = 18;
2187
+ _context22.t0 = _context22["catch"](4);
2188
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context22.t0);
2537
2189
  this.logInfo('Order API called failed', {
2538
- error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
2190
+ error: _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0)
2539
2191
  });
2540
- throw _context26.t0;
2192
+ throw _context22.t0;
2541
2193
  case 23:
2542
2194
  case "end":
2543
- return _context26.stop();
2195
+ return _context22.stop();
2544
2196
  }
2545
- }, _callee26, this, [[4, 18]]);
2197
+ }, _callee22, this, [[4, 18]]);
2546
2198
  }));
2547
- function createOrderByCheckout(_x28) {
2199
+ function createOrderByCheckout(_x23) {
2548
2200
  return _createOrderByCheckout.apply(this, arguments);
2549
2201
  }
2550
2202
  return createOrderByCheckout;
@@ -2552,23 +2204,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2552
2204
  }, {
2553
2205
  key: "submitSalesOrder",
2554
2206
  value: function () {
2555
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2207
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2556
2208
  var url, query, fetchUrl;
2557
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2558
- while (1) switch (_context27.prev = _context27.next) {
2209
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2210
+ while (1) switch (_context23.prev = _context23.next) {
2559
2211
  case 0:
2560
2212
  url = params.url, query = params.query;
2561
2213
  fetchUrl = url || '/order/sales/checkout';
2562
- return _context27.abrupt("return", this.request.post(fetchUrl, query, {
2214
+ return _context23.abrupt("return", this.request.post(fetchUrl, query, {
2563
2215
  customToast: function customToast() {}
2564
2216
  }));
2565
2217
  case 3:
2566
2218
  case "end":
2567
- return _context27.stop();
2219
+ return _context23.stop();
2568
2220
  }
2569
- }, _callee27, this);
2221
+ }, _callee23, this);
2570
2222
  }));
2571
- function submitSalesOrder(_x29) {
2223
+ function submitSalesOrder(_x24) {
2572
2224
  return _submitSalesOrder.apply(this, arguments);
2573
2225
  }
2574
2226
  return submitSalesOrder;
@@ -2582,37 +2234,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2582
2234
  }, {
2583
2235
  key: "sendCustomerPayLink",
2584
2236
  value: (function () {
2585
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2237
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2586
2238
  var _params$emails;
2587
2239
  var orderIds;
2588
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2589
- while (1) switch (_context28.prev = _context28.next) {
2240
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2241
+ while (1) switch (_context24.prev = _context24.next) {
2590
2242
  case 0:
2591
2243
  orderIds = params.order_ids || params.orderIds || [];
2592
2244
  if (orderIds.length) {
2593
- _context28.next = 3;
2245
+ _context24.next = 3;
2594
2246
  break;
2595
2247
  }
2596
2248
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
2597
2249
  case 3:
2598
2250
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
2599
- _context28.next = 5;
2251
+ _context24.next = 5;
2600
2252
  break;
2601
2253
  }
2602
2254
  throw new Error('发送支付链接需要至少一个邮箱');
2603
2255
  case 5:
2604
- return _context28.abrupt("return", this.request.post('/order/batch-email', {
2256
+ return _context24.abrupt("return", this.request.post('/order/batch-email', {
2605
2257
  order_ids: orderIds,
2606
2258
  notify_action: params.notify_action || 'order_payment_reminder',
2607
2259
  emails: params.emails
2608
2260
  }));
2609
2261
  case 6:
2610
2262
  case "end":
2611
- return _context28.stop();
2263
+ return _context24.stop();
2612
2264
  }
2613
- }, _callee28, this);
2265
+ }, _callee24, this);
2614
2266
  }));
2615
- function sendCustomerPayLink(_x30) {
2267
+ function sendCustomerPayLink(_x25) {
2616
2268
  return _sendCustomerPayLink.apply(this, arguments);
2617
2269
  }
2618
2270
  return sendCustomerPayLink;
@@ -2621,28 +2273,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2621
2273
  }, {
2622
2274
  key: "getOrderInfoByRemote",
2623
2275
  value: function () {
2624
- var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(order_id) {
2276
+ var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order_id) {
2625
2277
  var res;
2626
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2627
- while (1) switch (_context29.prev = _context29.next) {
2278
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2279
+ while (1) switch (_context25.prev = _context25.next) {
2628
2280
  case 0:
2629
- _context29.next = 2;
2281
+ _context25.next = 2;
2630
2282
  return this.request.get("/order/sales/".concat(order_id), {
2631
2283
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
2632
2284
  });
2633
2285
  case 2:
2634
- res = _context29.sent;
2286
+ res = _context25.sent;
2635
2287
  if (res.code === 200) {
2636
2288
  this.store.lastOrderInfo = res.data;
2637
2289
  }
2638
- return _context29.abrupt("return", res);
2290
+ return _context25.abrupt("return", res);
2639
2291
  case 5:
2640
2292
  case "end":
2641
- return _context29.stop();
2293
+ return _context25.stop();
2642
2294
  }
2643
- }, _callee29, this);
2295
+ }, _callee25, this);
2644
2296
  }));
2645
- function getOrderInfoByRemote(_x31) {
2297
+ function getOrderInfoByRemote(_x26) {
2646
2298
  return _getOrderInfoByRemote.apply(this, arguments);
2647
2299
  }
2648
2300
  return getOrderInfoByRemote;
@@ -2656,92 +2308,79 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2656
2308
  }, {
2657
2309
  key: "hydrateTempOrderFromRecord",
2658
2310
  value: (function () {
2659
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(record, options) {
2660
- var raw, nextTempOrder;
2661
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2662
- while (1) switch (_context30.prev = _context30.next) {
2311
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(record, options) {
2312
+ var _this5 = this;
2313
+ var raw, defaults, nextTempOrder, TEMP_ORDER_KEYS;
2314
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2315
+ while (1) switch (_context26.prev = _context26.next) {
2663
2316
  case 0:
2664
2317
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
2665
- nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
2666
- ensureIdentity: true
2318
+ defaults = this.createDefaultTempOrderInstance();
2319
+ nextTempOrder = _objectSpread({}, defaults);
2320
+ TEMP_ORDER_KEYS = ['order_id', 'external_sale_number', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'customer', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'buzzer', 'delivery_type', 'table_number', 'schedule_date', 'created_at', 'request_unique_idempotency_token'];
2321
+ TEMP_ORDER_KEYS.forEach(function (key) {
2322
+ if (raw[key] !== undefined) {
2323
+ nextTempOrder[key] = raw[key];
2324
+ }
2667
2325
  });
2326
+ nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
2327
+ nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
2328
+ nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
2329
+ return _this5.normalizeHydratedOrderProduct(p);
2330
+ }) : [];
2331
+ nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
2332
+ return _objectSpread(_objectSpread({}, b || {}), {}, {
2333
+ is_all: normalizeBookingIsAll(b || {}),
2334
+ sub_type: normalizeBookingSubType(b || {})
2335
+ });
2336
+ }) : [];
2337
+ nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
2338
+ return _objectSpread({}, p || {});
2339
+ }) : [];
2340
+ nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
2341
+ return _objectSpread({}, s || {});
2342
+ }) : [];
2343
+ nextTempOrder.discount_list = Array.isArray(raw.discount_list) ? raw.discount_list.map(function (d) {
2344
+ return _objectSpread({}, d || {});
2345
+ }) : [];
2346
+ nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
2347
+ return _objectSpread({}, f || {});
2348
+ }) : [];
2349
+ nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
2350
+ return _objectSpread({}, c || {});
2351
+ }) : [];
2352
+ nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
2353
+ nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
2354
+ productsByUid: raw._extend.productsByUid || {}
2355
+ }) : {
2356
+ productsByUid: {}
2357
+ };
2358
+ this.ensureExternalSaleNumber(nextTempOrder);
2668
2359
  this.store.tempOrder = nextTempOrder;
2669
2360
  this.store.summary = raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread(_objectSpread({}, createEmptySummary()), raw.summary) : createEmptySummary();
2670
2361
  this.store.lastOrderInfo = raw.lastOrderInfo || raw;
2671
2362
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
2672
- _context30.next = 8;
2363
+ _context26.next = 23;
2673
2364
  break;
2674
2365
  }
2675
- _context30.next = 8;
2366
+ _context26.next = 23;
2676
2367
  return this.recalculateSummary({
2677
2368
  createIfMissing: false
2678
2369
  });
2679
- case 8:
2370
+ case 23:
2680
2371
  this.persistTempOrder();
2681
- return _context30.abrupt("return", nextTempOrder);
2682
- case 10:
2372
+ return _context26.abrupt("return", nextTempOrder);
2373
+ case 25:
2683
2374
  case "end":
2684
- return _context30.stop();
2375
+ return _context26.stop();
2685
2376
  }
2686
- }, _callee30, this);
2377
+ }, _callee26, this);
2687
2378
  }));
2688
- function hydrateTempOrderFromRecord(_x32, _x33) {
2379
+ function hydrateTempOrderFromRecord(_x27, _x28) {
2689
2380
  return _hydrateTempOrderFromRecord.apply(this, arguments);
2690
2381
  }
2691
2382
  return hydrateTempOrderFromRecord;
2692
2383
  }())
2693
- }, {
2694
- key: "normalizeTempOrderForRuntime",
2695
- value: function normalizeTempOrderForRuntime(raw, options) {
2696
- var _this7 = this;
2697
- var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
2698
- delete nextTempOrder.summary;
2699
- delete nextTempOrder.lastOrderInfo;
2700
- delete nextTempOrder.discount_list;
2701
- delete nextTempOrder.shop_id;
2702
- delete nextTempOrder.create_date;
2703
- delete nextTempOrder.total_amount;
2704
- delete nextTempOrder.expect_amount;
2705
- delete nextTempOrder.paid_amount;
2706
- delete nextTempOrder.shop_note;
2707
- delete nextTempOrder.start_time;
2708
- delete nextTempOrder.tax_fee;
2709
- delete nextTempOrder.total_refund_amount;
2710
- delete nextTempOrder.holder_id;
2711
- nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
2712
- nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
2713
- nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
2714
- return _this7.normalizeHydratedOrderProduct(p);
2715
- }) : [];
2716
- nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
2717
- return _objectSpread(_objectSpread({}, b || {}), {}, {
2718
- is_all: normalizeBookingIsAll(b || {}),
2719
- sub_type: normalizeBookingSubType(b || {})
2720
- });
2721
- }) : [];
2722
- nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
2723
- return _objectSpread({}, p || {});
2724
- }) : [];
2725
- nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
2726
- return _objectSpread({}, s || {});
2727
- }) : [];
2728
- nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
2729
- return _objectSpread({}, f || {});
2730
- }) : [];
2731
- nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
2732
- return _objectSpread({}, c || {});
2733
- }) : [];
2734
- nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
2735
- nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
2736
- productsByUid: raw._extend.productsByUid || {}
2737
- }) : {
2738
- productsByUid: {}
2739
- };
2740
- if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
2741
- this.ensureExternalSaleNumber(nextTempOrder);
2742
- }
2743
- return nextTempOrder;
2744
- }
2745
2384
  }, {
2746
2385
  key: "normalizeHydratedOrderProduct",
2747
2386
  value: function normalizeHydratedOrderProduct(product) {
@@ -2757,7 +2396,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2757
2396
  row.metadata.unique_identification_number = createUuidV4();
2758
2397
  }
2759
2398
  var normalized = normalizeOrderProduct(row);
2760
- normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
2761
2399
  var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
2762
2400
  metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
2763
2401
  });
@@ -2773,25 +2411,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2773
2411
  }, {
2774
2412
  key: "getOrderInfo",
2775
2413
  value: function () {
2776
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order_id) {
2414
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order_id) {
2777
2415
  var res;
2778
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2779
- while (1) switch (_context31.prev = _context31.next) {
2416
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2417
+ while (1) switch (_context27.prev = _context27.next) {
2780
2418
  case 0:
2781
- _context31.next = 2;
2419
+ _context27.next = 2;
2782
2420
  return this.request.get("/order/sales/".concat(order_id), {
2783
2421
  with: ['products', 'bookings']
2784
2422
  });
2785
2423
  case 2:
2786
- res = _context31.sent;
2787
- return _context31.abrupt("return", res);
2424
+ res = _context27.sent;
2425
+ return _context27.abrupt("return", res);
2788
2426
  case 4:
2789
2427
  case "end":
2790
- return _context31.stop();
2428
+ return _context27.stop();
2791
2429
  }
2792
- }, _callee31, this);
2430
+ }, _callee27, this);
2793
2431
  }));
2794
- function getOrderInfo(_x34) {
2432
+ function getOrderInfo(_x29) {
2795
2433
  return _getOrderInfo.apply(this, arguments);
2796
2434
  }
2797
2435
  return getOrderInfo;