@pisell/pisellos 2.2.170 → 2.2.171

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 (149) 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 +15 -27
  9. package/dist/modules/Order/index.js +322 -695
  10. package/dist/modules/Order/types.d.ts +14 -49
  11. package/dist/modules/Order/types.js +0 -2
  12. package/dist/modules/Order/utils.d.ts +0 -17
  13. package/dist/modules/Order/utils.js +26 -97
  14. package/dist/modules/Rules/index.d.ts +0 -4
  15. package/dist/modules/Rules/index.js +10 -26
  16. package/dist/modules/SalesSummary/index.js +2 -4
  17. package/dist/modules/index.d.ts +0 -1
  18. package/dist/modules/index.js +1 -2
  19. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  20. package/dist/solution/BaseSales/index.d.ts +7 -46
  21. package/dist/solution/BaseSales/index.js +315 -1009
  22. package/dist/solution/BaseSales/types.d.ts +1 -53
  23. package/dist/solution/BaseSales/types.js +1 -3
  24. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  25. package/dist/solution/BaseSales/utils.js +8 -46
  26. package/dist/solution/BookingByStep/index.d.ts +1 -1
  27. package/dist/solution/BookingTicket/index.d.ts +1 -133
  28. package/dist/solution/BookingTicket/index.js +175 -768
  29. package/dist/solution/BookingTicket/types.d.ts +0 -2
  30. package/dist/solution/BookingTicket/types.js +0 -3
  31. package/dist/solution/ScanOrder/index.d.ts +3 -9
  32. package/dist/solution/ScanOrder/index.js +128 -231
  33. package/dist/solution/ScanOrder/utils.js +8 -46
  34. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  35. package/dist/solution/ShopDiscount/index.js +23 -18
  36. package/dist/solution/VenueBooking/index.d.ts +9 -5
  37. package/dist/solution/VenueBooking/index.js +55 -103
  38. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  39. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  40. package/lib/modules/Customer/index.d.ts +0 -6
  41. package/lib/modules/Customer/index.js +11 -26
  42. package/lib/modules/Customer/types.d.ts +0 -2
  43. package/lib/modules/Discount/index.d.ts +4 -2
  44. package/lib/modules/Discount/index.js +63 -8
  45. package/lib/modules/Discount/types.d.ts +7 -1
  46. package/lib/modules/Order/index.d.ts +15 -27
  47. package/lib/modules/Order/index.js +84 -336
  48. package/lib/modules/Order/types.d.ts +14 -49
  49. package/lib/modules/Order/utils.d.ts +0 -17
  50. package/lib/modules/Order/utils.js +18 -105
  51. package/lib/modules/Rules/index.d.ts +0 -4
  52. package/lib/modules/Rules/index.js +14 -22
  53. package/lib/modules/SalesSummary/index.js +2 -4
  54. package/lib/modules/index.d.ts +0 -1
  55. package/lib/modules/index.js +1 -3
  56. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  57. package/lib/solution/BaseSales/index.d.ts +7 -46
  58. package/lib/solution/BaseSales/index.js +20 -434
  59. package/lib/solution/BaseSales/types.d.ts +1 -53
  60. package/lib/solution/BaseSales/types.js +1 -3
  61. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  62. package/lib/solution/BaseSales/utils.js +6 -46
  63. package/lib/solution/BookingByStep/index.d.ts +1 -1
  64. package/lib/solution/BookingTicket/index.d.ts +1 -133
  65. package/lib/solution/BookingTicket/index.js +8 -341
  66. package/lib/solution/BookingTicket/types.d.ts +0 -2
  67. package/lib/solution/BookingTicket/types.js +0 -6
  68. package/lib/solution/ScanOrder/index.d.ts +3 -9
  69. package/lib/solution/ScanOrder/index.js +66 -147
  70. package/lib/solution/ScanOrder/utils.js +6 -46
  71. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  72. package/lib/solution/ShopDiscount/index.js +4 -2
  73. package/lib/solution/VenueBooking/index.d.ts +9 -5
  74. package/lib/solution/VenueBooking/index.js +14 -50
  75. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  76. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  77. package/package.json +2 -2
  78. package/dist/modules/BookingContext/index.d.ts +0 -37
  79. package/dist/modules/BookingContext/index.js +0 -436
  80. package/dist/modules/BookingContext/types.d.ts +0 -102
  81. package/dist/modules/BookingContext/types.js +0 -51
  82. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  83. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  84. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  85. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  86. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  87. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  88. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  89. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  90. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  91. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  92. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  93. package/dist/modules/BookingContext/utils/index.js +0 -11
  94. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  95. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  96. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  97. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  98. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  99. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  100. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  101. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  102. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  103. package/dist/modules/BookingContext/utils/resources.js +0 -486
  104. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  105. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  106. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  107. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  108. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  109. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  110. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  111. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -159
  112. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  113. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  114. package/lib/modules/BookingContext/index.d.ts +0 -37
  115. package/lib/modules/BookingContext/index.js +0 -297
  116. package/lib/modules/BookingContext/types.d.ts +0 -102
  117. package/lib/modules/BookingContext/types.js +0 -34
  118. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  119. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  120. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  121. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  122. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  123. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  124. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  125. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  126. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  128. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  129. package/lib/modules/BookingContext/utils/index.js +0 -43
  130. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  131. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  132. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  133. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  134. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  135. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  136. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  137. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  138. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  139. package/lib/modules/BookingContext/utils/resources.js +0 -377
  140. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  141. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  142. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  143. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  144. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  145. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  146. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  147. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -201
  148. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  149. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -30,7 +30,6 @@ import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPa
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";
@@ -197,40 +196,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
197
196
  key: "loadDiscountConfig",
198
197
  value: function () {
199
198
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
200
- var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
201
- var orderId, discountList, _this$store$discount2, _this$store$discount3;
199
+ var _this$store$discount, _this$store$tempOrder;
200
+ var discountList, _this$store$discount2;
202
201
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
203
202
  while (1) switch (_context2.prev = _context2.next) {
204
203
  case 0:
205
- orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
206
- _context2.next = 3;
207
- 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({
208
206
  customer_id: params.customerId,
209
- action: params.action || (orderId ? 'edit' : 'create'),
207
+ action: params.action || 'create',
210
208
  with_good_pass: 1,
211
209
  with_discount_card: 1,
212
210
  with_wallet_pass_holder: 1,
213
211
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
214
- }, orderId ? {
215
- order_id: orderId
216
- } : {}));
217
- case 3:
212
+ });
213
+ case 2:
218
214
  discountList = _context2.sent;
219
- if (!discountList) {
220
- _context2.next = 9;
221
- break;
215
+ if (discountList) {
216
+ (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
222
217
  }
223
- _context2.next = 7;
224
- return (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.setOriginalDiscountList(discountList);
225
- case 7:
226
- _context2.next = 9;
227
- return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setDiscountList(discountList);
228
- case 9:
229
- 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) {
230
219
  this.applyDiscount();
231
220
  }
232
- return _context2.abrupt("return", this.getDiscountList());
233
- case 11:
221
+ case 5:
234
222
  case "end":
235
223
  return _context2.stop();
236
224
  }
@@ -244,20 +232,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
244
232
  }, {
245
233
  key: "getDiscountList",
246
234
  value: function getDiscountList() {
247
- var _this$store$discount4;
248
- 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()) || [];
249
237
  }
250
238
  }, {
251
239
  key: "scanCode",
252
240
  value: function () {
253
241
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
254
- var _this$store$discount5, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
255
- 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;
256
244
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
257
245
  while (1) switch (_context3.prev = _context3.next) {
258
246
  case 0:
259
247
  _context3.next = 2;
260
- 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, {
261
249
  customerId: customerId
262
250
  });
263
251
  case 2:
@@ -266,33 +254,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
266
254
  _context3.next = 5;
267
255
  break;
268
256
  }
269
- _context3.t0 = [];
257
+ _context3.t0 = {
258
+ discountList: [],
259
+ unavailableReasonKey: null
260
+ };
270
261
  case 5:
271
- resultDiscountList = _context3.t0;
262
+ resultDiscountWithReason = _context3.t0;
263
+ resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
272
264
  rulesModule = this.store.rules;
273
265
  if (rulesModule) {
274
- _context3.next = 9;
266
+ _context3.next = 10;
275
267
  break;
276
268
  }
277
269
  return _context3.abrupt("return", {
278
270
  type: 'clientCalc',
279
271
  isAvailable: false,
280
272
  discountList: this.getDiscountList(),
281
- scannedDiscountList: resultDiscountList,
282
273
  unavailableReason: UnavailableReason.Unknown
283
274
  });
284
- case 9:
275
+ case 10:
285
276
  if (resultDiscountList.length) {
286
- _context3.next = 11;
277
+ _context3.next = 12;
287
278
  break;
288
279
  }
289
280
  return _context3.abrupt("return", {
290
281
  type: 'server',
291
282
  isAvailable: false,
292
283
  discountList: this.getDiscountList(),
293
- scannedDiscountList: resultDiscountList
284
+ unavailableReasonKey: unavailableReasonKey
294
285
  });
295
- case 11:
286
+ case 12:
296
287
  withScanList = resultDiscountList.map(function (item) {
297
288
  return _objectSpread(_objectSpread({}, item), {}, {
298
289
  isScan: true
@@ -306,16 +297,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
306
297
  return m.id === n.id;
307
298
  });
308
299
  }))) {
309
- _context3.next = 15;
300
+ _context3.next = 16;
310
301
  break;
311
302
  }
312
303
  return _context3.abrupt("return", {
313
304
  type: 'clientCalc',
314
305
  isAvailable: true,
315
- discountList: this.getDiscountList(),
316
- scannedDiscountList: resultDiscountList
306
+ discountList: this.getDiscountList()
317
307
  });
318
- case 15:
308
+ case 16:
319
309
  tempOrder = this.store.tempOrder;
320
310
  holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
321
311
  form_record_id: tempOrder.holder.form_record_id
@@ -332,17 +322,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
332
322
  discountList: this.getDiscountList()
333
323
  }, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
334
324
  if (isAvailable && newDiscountList) {
335
- (_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);
336
326
  this.applyDiscount();
337
327
  }
338
328
  return _context3.abrupt("return", {
339
329
  type: 'clientCalc',
340
330
  isAvailable: isAvailable || false,
341
331
  discountList: newDiscountList || this.getDiscountList(),
342
- scannedDiscountList: resultDiscountList,
343
332
  unavailableReason: unavailableReason
344
333
  });
345
- case 20:
334
+ case 21:
346
335
  case "end":
347
336
  return _context3.stop();
348
337
  }
@@ -356,7 +345,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
356
345
  }, {
357
346
  key: "applyDiscount",
358
347
  value: function applyDiscount() {
359
- var _this$store$discount7, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
348
+ var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
360
349
  var tempOrder = this.store.tempOrder;
361
350
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
362
351
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -364,7 +353,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
364
353
  if (!tempOrder) return;
365
354
  var rulesModule = this.store.rules;
366
355
  if (!rulesModule) return;
367
- 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()) || [];
368
357
  var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
369
358
  form_record_id: tempOrder.holder.form_record_id
370
359
  }] : [];
@@ -376,16 +365,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
376
365
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
377
366
  });
378
367
  if (result !== null && result !== void 0 && result.productList) {
379
- tempOrder.products = (result.productList || []).map(function (product) {
380
- return _objectSpread(_objectSpread({}, product), {}, {
381
- discount_list: syncManualProductDiscountProductNum(product.discount_list, product.num)
382
- });
383
- });
368
+ tempOrder.products = result.productList;
384
369
  }
385
370
  if (result !== null && result !== void 0 && result.discountList) {
386
- var _this$store$discount8;
371
+ var _this$store$discount7;
387
372
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
388
- (_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);
389
374
  tempOrder.discount_list = result.discountList.filter(function (d) {
390
375
  return d.isSelected;
391
376
  });
@@ -736,11 +721,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
736
721
  }
737
722
  return saveDraft;
738
723
  }()
739
- }, {
740
- key: "saveDraftInBackground",
741
- value: function saveDraftInBackground() {
742
- void this.saveDraft();
743
- }
744
724
  }, {
745
725
  key: "hydrateTempOrderFromLocalRecord",
746
726
  value: function () {
@@ -832,15 +812,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
832
812
  }, {
833
813
  key: "restoreOrder",
834
814
  value: function restoreOrder() {
835
- var _this$store$discount9, _this$store$discount10;
836
815
  var freshTempOrder = this.createDefaultTempOrderInstance();
837
816
  this.ensureExternalSaleNumber(freshTempOrder);
838
817
  this.store.tempOrder = freshTempOrder;
839
818
  this.store.summary = createEmptySummary();
840
819
  this.store.lastOrderInfo = undefined;
841
- this.store.syncState = undefined;
842
- void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
843
- void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
844
820
  this.persistTempOrder();
845
821
  return freshTempOrder;
846
822
  }
@@ -849,60 +825,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
849
825
  value: function getTempOrder() {
850
826
  return this.store.tempOrder;
851
827
  }
852
- }, {
853
- key: "replaceTempOrder",
854
- value: function () {
855
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
856
- var nextTempOrder;
857
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
858
- while (1) switch (_context9.prev = _context9.next) {
859
- case 0:
860
- if (isTempOrder(tempOrder)) {
861
- _context9.next = 2;
862
- break;
863
- }
864
- throw new Error('无效的 tempOrder 数据');
865
- case 2:
866
- nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
867
- ensureIdentity: false
868
- });
869
- this.store.tempOrder = nextTempOrder;
870
- if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
871
- _context9.next = 9;
872
- break;
873
- }
874
- _context9.next = 7;
875
- return this.recalculateSummary({
876
- createIfMissing: false
877
- });
878
- case 7:
879
- _context9.next = 10;
880
- break;
881
- case 9:
882
- this.store.summary = createEmptySummary();
883
- case 10:
884
- if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
885
- this.persistTempOrder();
886
- }
887
- if (!(options !== null && options !== void 0 && options.saveDraft)) {
888
- _context9.next = 14;
889
- break;
890
- }
891
- _context9.next = 14;
892
- return this.saveDraft();
893
- case 14:
894
- return _context9.abrupt("return", nextTempOrder);
895
- case 15:
896
- case "end":
897
- return _context9.stop();
898
- }
899
- }, _callee9, this);
900
- }));
901
- function replaceTempOrder(_x10, _x11) {
902
- return _replaceTempOrder.apply(this, arguments);
903
- }
904
- return replaceTempOrder;
905
- }()
906
828
  }, {
907
829
  key: "getOrderIdentity",
908
830
  value: function getOrderIdentity() {
@@ -981,28 +903,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
981
903
  }, {
982
904
  key: "addNewOrder",
983
905
  value: function () {
984
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
906
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
985
907
  var tempOrder;
986
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
987
- while (1) switch (_context10.prev = _context10.next) {
908
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
909
+ while (1) switch (_context9.prev = _context9.next) {
988
910
  case 0:
989
911
  tempOrder = this.ensureTempOrder();
990
912
  this.ensureExternalSaleNumber(tempOrder);
991
- _context10.next = 4;
913
+ _context9.next = 4;
992
914
  return this.recalculateSummary({
993
915
  createIfMissing: true
994
916
  });
995
917
  case 4:
996
918
  this.persistTempOrder();
997
- _context10.next = 7;
919
+ _context9.next = 7;
998
920
  return this.saveDraft();
999
921
  case 7:
1000
- return _context10.abrupt("return", tempOrder);
922
+ return _context9.abrupt("return", tempOrder);
1001
923
  case 8:
1002
924
  case "end":
1003
- return _context10.stop();
925
+ return _context9.stop();
1004
926
  }
1005
- }, _callee10, this);
927
+ }, _callee9, this);
1006
928
  }));
1007
929
  function addNewOrder() {
1008
930
  return _addNewOrder.apply(this, arguments);
@@ -1078,38 +1000,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1078
1000
  })
1079
1001
  };
1080
1002
  }
1081
- }, {
1082
- key: "getBookingUniqueIdentificationNumber",
1083
- value: function getBookingUniqueIdentificationNumber(booking) {
1084
- var _booking$metadata;
1085
- var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
1086
- if (uid === undefined || uid === null || uid === '') return null;
1087
- return String(uid);
1088
- }
1089
- }, {
1090
- key: "findBookingIndexByUniqueIdentificationNumber",
1091
- value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
1092
- var _this3 = this;
1093
- return (tempOrder.bookings || []).findIndex(function (booking) {
1094
- return _this3.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
1095
- });
1096
- }
1097
- }, {
1098
- key: "removeLinkedBookingsForProduct",
1099
- value: function removeLinkedBookingsForProduct(tempOrder, product) {
1100
- var _product$metadata,
1101
- _product$metadata2,
1102
- _this4 = this;
1103
- var productUid = (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
1104
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid);
1105
- if (!productUid && !bookingUid) return;
1106
- tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
1107
- var currentBookingUid = _this4.getBookingUniqueIdentificationNumber(booking);
1108
- if (bookingUid && currentBookingUid === String(bookingUid)) return false;
1109
- if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
1110
- return true;
1111
- });
1112
- }
1113
1003
 
1114
1004
  // ─── TempOrder: 金额汇总 ───
1115
1005
  }, {
@@ -1121,23 +1011,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1121
1011
  }, {
1122
1012
  key: "recalculateSummary",
1123
1013
  value: function () {
1124
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
1014
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
1125
1015
  var tempOrder, salesSummary, existedSummary, paidPaymentSummary, emptySummary, salesSummaryResult, summary;
1126
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1127
- while (1) switch (_context11.prev = _context11.next) {
1016
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1017
+ while (1) switch (_context10.prev = _context10.next) {
1128
1018
  case 0:
1129
1019
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
1130
1020
  if (tempOrder) {
1131
- _context11.next = 3;
1021
+ _context10.next = 3;
1132
1022
  break;
1133
1023
  }
1134
- return _context11.abrupt("return", null);
1024
+ return _context10.abrupt("return", null);
1135
1025
  case 3:
1136
1026
  salesSummary = this.getSalesSummary();
1137
1027
  existedSummary = this.store.summary || createEmptySummary();
1138
1028
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
1139
1029
  if (salesSummary) {
1140
- _context11.next = 11;
1030
+ _context10.next = 11;
1141
1031
  break;
1142
1032
  }
1143
1033
  emptySummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
@@ -1148,16 +1038,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1148
1038
  });
1149
1039
  this.store.summary = emptySummary;
1150
1040
  tempOrder.surcharge_fee = emptySummary.surcharge_fee;
1151
- return _context11.abrupt("return", this.store.summary);
1041
+ return _context10.abrupt("return", this.store.summary);
1152
1042
  case 11:
1153
- _context11.next = 13;
1043
+ _context10.next = 13;
1154
1044
  return salesSummary.getSummary({
1155
1045
  products: tempOrder.products,
1156
1046
  isPriceIncludeTax: tempOrder.is_price_include_tax,
1157
1047
  shopDiscount: tempOrder.shop_discount
1158
1048
  });
1159
1049
  case 13:
1160
- salesSummaryResult = _context11.sent;
1050
+ salesSummaryResult = _context10.sent;
1161
1051
  summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
1162
1052
  total_refund_amount: existedSummary.total_refund_amount || '0.00',
1163
1053
  customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
@@ -1175,14 +1065,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1175
1065
  tempOrder.surcharges = summary.surcharges || [];
1176
1066
  tempOrder.deposit_amount = summary.deposit_amount || '0.00';
1177
1067
  tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
1178
- return _context11.abrupt("return", this.store.summary);
1068
+ return _context10.abrupt("return", this.store.summary);
1179
1069
  case 23:
1180
1070
  case "end":
1181
- return _context11.stop();
1071
+ return _context10.stop();
1182
1072
  }
1183
- }, _callee11, this);
1073
+ }, _callee10, this);
1184
1074
  }));
1185
- function recalculateSummary(_x12) {
1075
+ function recalculateSummary(_x10) {
1186
1076
  return _recalculateSummary.apply(this, arguments);
1187
1077
  }
1188
1078
  return recalculateSummary;
@@ -1190,30 +1080,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1190
1080
  }, {
1191
1081
  key: "getOrderSummary",
1192
1082
  value: function () {
1193
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1083
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1194
1084
  var summary;
1195
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1196
- while (1) switch (_context12.prev = _context12.next) {
1085
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1086
+ while (1) switch (_context11.prev = _context11.next) {
1197
1087
  case 0:
1198
- _context12.next = 2;
1088
+ _context11.next = 2;
1199
1089
  return this.recalculateSummary({
1200
1090
  createIfMissing: true
1201
1091
  });
1202
1092
  case 2:
1203
- summary = _context12.sent;
1093
+ summary = _context11.sent;
1204
1094
  if (summary) {
1205
- _context12.next = 5;
1095
+ _context11.next = 5;
1206
1096
  break;
1207
1097
  }
1208
- return _context12.abrupt("return", createEmptySummary());
1098
+ return _context11.abrupt("return", createEmptySummary());
1209
1099
  case 5:
1210
1100
  this.persistTempOrder();
1211
- return _context12.abrupt("return", summary);
1101
+ return _context11.abrupt("return", summary);
1212
1102
  case 7:
1213
1103
  case "end":
1214
- return _context12.stop();
1104
+ return _context11.stop();
1215
1105
  }
1216
- }, _callee12, this);
1106
+ }, _callee11, this);
1217
1107
  }));
1218
1108
  function getOrderSummary() {
1219
1109
  return _getOrderSummary.apply(this, arguments);
@@ -1223,46 +1113,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1223
1113
  }, {
1224
1114
  key: "updateTempOrderNote",
1225
1115
  value: function updateTempOrderNote(note) {
1226
- var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1227
1116
  var tempOrder = this.ensureTempOrder();
1228
1117
  tempOrder.note = String(note || '');
1229
1118
  this.persistTempOrder();
1230
- if (sync) {
1231
- var orderId = tempOrder.order_id;
1232
- if (!orderId) return tempOrder.note;
1233
- return this.syncTempOrderNoteToRemote(orderId, tempOrder.note);
1234
- }
1235
1119
  return tempOrder.note;
1236
1120
  }
1237
- }, {
1238
- key: "syncTempOrderNoteToRemote",
1239
- value: function () {
1240
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
1241
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1242
- while (1) switch (_context13.prev = _context13.next) {
1243
- case 0:
1244
- _context13.next = 2;
1245
- return this.request.put("/order/order/".concat(orderId, "/note"), {
1246
- note: note
1247
- });
1248
- case 2:
1249
- return _context13.abrupt("return", note);
1250
- case 3:
1251
- case "end":
1252
- return _context13.stop();
1253
- }
1254
- }, _callee13, this);
1255
- }));
1256
- function syncTempOrderNoteToRemote(_x13, _x14) {
1257
- return _syncTempOrderNoteToRemote.apply(this, arguments);
1258
- }
1259
- return syncTempOrderNoteToRemote;
1260
- }()
1261
1121
  }, {
1262
1122
  key: "getTempOrderNote",
1263
1123
  value: function getTempOrderNote() {
1264
- var _this$store$tempOrder3;
1265
- 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) || '';
1266
1126
  }
1267
1127
  }, {
1268
1128
  key: "updateTempOrderShopDiscount",
@@ -1289,51 +1149,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1289
1149
  this.persistTempOrder();
1290
1150
  return tempOrder.contacts_info;
1291
1151
  }
1292
- }, {
1293
- key: "buildTempOrderCustomer",
1294
- value: function buildTempOrderCustomer(params) {
1295
- 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;
1296
- if (!params.customerId) return null;
1297
- var source = params.source ? cloneDeep(params.source) : {};
1298
- 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;
1299
- 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;
1300
- return _objectSpread(_objectSpread({}, source), {}, {
1301
- id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
1302
- customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
1303
- name: String(name || ''),
1304
- customer_name: String(customerName || ''),
1305
- 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),
1306
- phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
1307
- email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
1308
- });
1309
- }
1310
1152
 
1311
1153
  /**
1312
1154
  * 更新当前 tempOrder 的客户协议字段。
1313
1155
  *
1314
- * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
1156
+ * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
1315
1157
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
1316
1158
  */
1317
1159
  }, {
1318
1160
  key: "updateTempOrderCustomer",
1319
1161
  value: function updateTempOrderCustomer(customer) {
1320
- 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;
1321
1163
  var tempOrder = this.ensureTempOrder();
1322
- 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;
1323
- 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 : '';
1324
1166
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
1325
1167
  tempOrder.customer_name = String(customerName || '');
1326
- 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 : '');
1327
1169
  tempOrder.phone = String(customer.phone || '');
1328
1170
  tempOrder.email = String(customer.email || '');
1329
- tempOrder.customer = this.buildTempOrderCustomer({
1330
- source: customer,
1331
- customerId: tempOrder.customer_id,
1332
- customerName: tempOrder.customer_name,
1333
- countryCallingCode: tempOrder.country_calling_code,
1334
- phone: tempOrder.phone,
1335
- email: tempOrder.email
1336
- });
1337
1171
  this.persistTempOrder();
1338
1172
  return {
1339
1173
  customerId: tempOrder.customer_id,
@@ -1355,27 +1189,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1355
1189
  tempOrder.country_calling_code = String(patch.country_calling_code || '');
1356
1190
  tempOrder.phone = String(patch.phone || '');
1357
1191
  tempOrder.email = String(patch.email || '');
1358
- tempOrder.customer = this.buildTempOrderCustomer({
1359
- source: snapshot || null,
1360
- customerId: tempOrder.customer_id,
1361
- customerName: tempOrder.customer_name,
1362
- countryCallingCode: tempOrder.country_calling_code,
1363
- phone: tempOrder.phone,
1364
- email: tempOrder.email
1365
- });
1366
1192
  if (snapshot !== undefined) {
1367
1193
  var extend = this.ensureExtend(tempOrder);
1368
1194
  if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
1369
1195
  }
1370
1196
  this.persistTempOrder();
1371
- this.saveDraftInBackground();
1372
1197
  this.emitOrderCustomerChange();
1373
1198
  }
1374
1199
  }, {
1375
1200
  key: "getOrderCustomer",
1376
1201
  value: function getOrderCustomer() {
1377
1202
  var tempOrder = this.store.tempOrder;
1378
- if (!tempOrder || !tempOrder.customer_id) {
1203
+ if (!tempOrder || tempOrder.customer_id === null || tempOrder.customer_id === undefined) {
1379
1204
  return null;
1380
1205
  }
1381
1206
  return {
@@ -1389,8 +1214,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1389
1214
  }, {
1390
1215
  key: "getOrderCustomerSnapshot",
1391
1216
  value: function getOrderCustomerSnapshot() {
1392
- var _this$store$tempOrder4;
1393
- 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;
1394
1219
  return snapshot ? cloneDeep(snapshot) : null;
1395
1220
  }
1396
1221
  }, {
@@ -1402,10 +1227,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1402
1227
  tempOrder.country_calling_code = '';
1403
1228
  tempOrder.phone = '';
1404
1229
  tempOrder.email = '';
1405
- tempOrder.customer = null;
1406
1230
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
1407
1231
  this.persistTempOrder();
1408
- this.saveDraftInBackground();
1409
1232
  this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
1410
1233
  }
1411
1234
  }, {
@@ -1456,9 +1279,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1456
1279
  }, {
1457
1280
  key: "addOrderPayment",
1458
1281
  value: function addOrderPayment(payment) {
1459
- this.logInfo('addOrderPayment', {
1460
- payment: payment
1461
- });
1462
1282
  var tempOrder = this.ensureTempOrder();
1463
1283
  var mapped = mapPaymentItemsToOrderPayments([payment]);
1464
1284
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
@@ -1538,45 +1358,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1538
1358
  }, {
1539
1359
  key: "shouldMergeProductToOrder",
1540
1360
  value: function () {
1541
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1361
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
1542
1362
  var _this$orderHooks;
1543
1363
  var onBeforeMergeProductToOrder, result;
1544
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1545
- while (1) switch (_context14.prev = _context14.next) {
1364
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1365
+ while (1) switch (_context12.prev = _context12.next) {
1546
1366
  case 0:
1547
1367
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
1548
1368
  if (onBeforeMergeProductToOrder) {
1549
- _context14.next = 3;
1369
+ _context12.next = 3;
1550
1370
  break;
1551
1371
  }
1552
- return _context14.abrupt("return", true);
1372
+ return _context12.abrupt("return", true);
1553
1373
  case 3:
1554
- _context14.next = 5;
1374
+ _context12.next = 5;
1555
1375
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
1556
1376
  defaultShouldMerge: true
1557
1377
  }));
1558
1378
  case 5:
1559
- result = _context14.sent;
1379
+ result = _context12.sent;
1560
1380
  if (!(typeof result === 'boolean')) {
1561
- _context14.next = 8;
1381
+ _context12.next = 8;
1562
1382
  break;
1563
1383
  }
1564
- return _context14.abrupt("return", result);
1384
+ return _context12.abrupt("return", result);
1565
1385
  case 8:
1566
1386
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
1567
- _context14.next = 10;
1387
+ _context12.next = 10;
1568
1388
  break;
1569
1389
  }
1570
- return _context14.abrupt("return", result.shouldMerge);
1390
+ return _context12.abrupt("return", result.shouldMerge);
1571
1391
  case 10:
1572
- return _context14.abrupt("return", true);
1392
+ return _context12.abrupt("return", true);
1573
1393
  case 11:
1574
1394
  case "end":
1575
- return _context14.stop();
1395
+ return _context12.stop();
1576
1396
  }
1577
- }, _callee14, this);
1397
+ }, _callee12, this);
1578
1398
  }));
1579
- function shouldMergeProductToOrder(_x15) {
1399
+ function shouldMergeProductToOrder(_x11) {
1580
1400
  return _shouldMergeProductToOrder.apply(this, arguments);
1581
1401
  }
1582
1402
  return shouldMergeProductToOrder;
@@ -1584,11 +1404,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1584
1404
  }, {
1585
1405
  key: "addProductToOrder",
1586
1406
  value: function () {
1587
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
1588
- var _this5 = this;
1407
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(product, booking) {
1408
+ var _this3 = this;
1589
1409
  var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
1590
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1591
- while (1) switch (_context15.prev = _context15.next) {
1410
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1411
+ while (1) switch (_context13.prev = _context13.next) {
1592
1412
  case 0:
1593
1413
  tempOrder = this.ensureTempOrder();
1594
1414
  linked = booking ? this.createLinkedProductAndBooking({
@@ -1601,7 +1421,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1601
1421
  hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
1602
1422
  shouldForceNewLine = !!booking;
1603
1423
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
1604
- if (_this5.hasGoodPassDiscount(item)) return false;
1424
+ if (_this3.hasGoodPassDiscount(item)) return false;
1605
1425
  if (item.product_id !== productToAdd.product_id) return false;
1606
1426
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
1607
1427
  var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
@@ -1610,10 +1430,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1610
1430
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
1611
1431
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
1612
1432
  if (!matchedProduct) {
1613
- _context15.next = 16;
1433
+ _context13.next = 16;
1614
1434
  break;
1615
1435
  }
1616
- _context15.next = 13;
1436
+ _context13.next = 13;
1617
1437
  return this.shouldMergeProductToOrder({
1618
1438
  incomingProduct: productToAdd,
1619
1439
  normalizedIncoming: normalizedIncoming,
@@ -1625,13 +1445,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1625
1445
  booking: booking
1626
1446
  });
1627
1447
  case 13:
1628
- _context15.t0 = _context15.sent;
1629
- _context15.next = 17;
1448
+ _context13.t0 = _context13.sent;
1449
+ _context13.next = 17;
1630
1450
  break;
1631
1451
  case 16:
1632
- _context15.t0 = false;
1452
+ _context13.t0 = false;
1633
1453
  case 17:
1634
- shouldMerge = _context15.t0;
1454
+ shouldMerge = _context13.t0;
1635
1455
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
1636
1456
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
1637
1457
  if (linked) {
@@ -1663,20 +1483,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1663
1483
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1664
1484
  }
1665
1485
  this.applyDiscount();
1666
- _context15.next = 23;
1486
+ _context13.next = 23;
1667
1487
  return this.recalculateSummary({
1668
1488
  createIfMissing: true
1669
1489
  });
1670
1490
  case 23:
1671
1491
  this.persistTempOrder();
1672
- return _context15.abrupt("return", tempOrder.products);
1492
+ return _context13.abrupt("return", tempOrder.products);
1673
1493
  case 25:
1674
1494
  case "end":
1675
- return _context15.stop();
1495
+ return _context13.stop();
1676
1496
  }
1677
- }, _callee15, this);
1497
+ }, _callee13, this);
1678
1498
  }));
1679
- function addProductToOrder(_x16, _x17) {
1499
+ function addProductToOrder(_x12, _x13) {
1680
1500
  return _addProductToOrder.apply(this, arguments);
1681
1501
  }
1682
1502
  return addProductToOrder;
@@ -1701,15 +1521,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1701
1521
  });
1702
1522
  }
1703
1523
  }, {
1704
- key: "updateOrderProduct",
1524
+ key: "updateProductInOrder",
1705
1525
  value: function () {
1706
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1526
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1707
1527
  var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
1708
- 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;
1709
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1710
- 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) {
1711
1531
  case 0:
1712
- 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;
1713
1533
  tempOrder = this.ensureTempOrder();
1714
1534
  identityLookup = {
1715
1535
  product_id: product_id,
@@ -1717,32 +1537,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1717
1537
  };
1718
1538
  if (unique_identification_number !== undefined) {
1719
1539
  identityLookup.unique_identification_number = unique_identification_number;
1720
- if (identity_key === undefined) {
1721
- identityLookup.identity_key = unique_identification_number;
1722
- }
1723
- }
1724
- if (identity_key !== undefined) {
1725
- identityLookup.identity_key = identity_key;
1726
1540
  }
1727
1541
  if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
1728
1542
  if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
1729
- productIndex = -1;
1730
- if (unique_identification_number !== undefined) {
1731
- targetUid = String(unique_identification_number);
1732
- productIndex = tempOrder.products.findIndex(function (item) {
1733
- var _item$metadata;
1734
- return String(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.unique_identification_number) || item.unique_identification_number || '') === targetUid;
1735
- });
1736
- }
1737
- if (productIndex === -1) {
1738
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1739
- }
1543
+ productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1740
1544
  if (!(productIndex === -1)) {
1741
- _context16.next = 12;
1545
+ _context14.next = 9;
1742
1546
  break;
1743
1547
  }
1744
1548
  throw new Error('[Order] 目标商品不存在,无法更新');
1745
- case 12:
1549
+ case 9:
1746
1550
  targetProduct = tempOrder.products[productIndex];
1747
1551
  nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
1748
1552
  product_id: product_id,
@@ -1770,217 +1574,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1770
1574
  }
1771
1575
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
1772
1576
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
1773
- normalizedProduct = normalizeOrderProduct(nextProduct);
1774
- if (booking) {
1775
- 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());
1776
- normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
1777
- unique_identification_number: productUid
1778
- });
1779
- linked = this.createLinkedProductAndBooking({
1780
- product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
1781
- unique_identification_number: productUid
1782
- }),
1783
- booking: booking
1784
- });
1785
- this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
1786
- normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
1787
- booking_uid: linked.bookingUid,
1788
- metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
1789
- booking_uid: linked.bookingUid,
1790
- unique_identification_number: productUid
1791
- })
1792
- });
1793
- tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1794
- }
1795
- tempOrder.products[productIndex] = normalizedProduct;
1577
+ tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
1796
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);
1797
1579
  this.applyDiscount();
1798
- _context16.next = 25;
1580
+ _context14.next = 20;
1799
1581
  return this.recalculateSummary({
1800
1582
  createIfMissing: true
1801
1583
  });
1802
- case 25:
1803
- this.persistTempOrder();
1804
- return _context16.abrupt("return", tempOrder.products);
1805
- case 27:
1806
- case "end":
1807
- return _context16.stop();
1808
- }
1809
- }, _callee16, this);
1810
- }));
1811
- function updateOrderProduct(_x18) {
1812
- return _updateOrderProduct.apply(this, arguments);
1813
- }
1814
- return updateOrderProduct;
1815
- }()
1816
- }, {
1817
- key: "updateOrderProductQuantity",
1818
- value: function () {
1819
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1820
- var _targetProduct$metada4;
1821
- var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
1822
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1823
- while (1) switch (_context17.prev = _context17.next) {
1824
- case 0:
1825
- 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;
1826
- tempOrder = this.ensureTempOrder();
1827
- identityLookup = {
1828
- product_id: product_id,
1829
- product_variant_id: product_variant_id
1830
- };
1831
- if (unique_identification_number !== undefined) {
1832
- identityLookup.unique_identification_number = unique_identification_number;
1833
- if (identity_key === undefined) {
1834
- identityLookup.identity_key = unique_identification_number;
1835
- }
1836
- }
1837
- if (identity_key !== undefined) identityLookup.identity_key = identity_key;
1838
- if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
1839
- if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
1840
- productIndex = -1;
1841
- if (unique_identification_number !== undefined) {
1842
- targetUid = String(unique_identification_number);
1843
- productIndex = tempOrder.products.findIndex(function (item) {
1844
- var _item$metadata2;
1845
- return String(((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_identification_number) || item.unique_identification_number || '') === targetUid;
1846
- });
1847
- }
1848
- if (productIndex === -1) {
1849
- productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
1850
- }
1851
- if (!(productIndex === -1)) {
1852
- _context17.next = 12;
1853
- break;
1854
- }
1855
- throw new Error('[Order] 目标商品不存在,无法更新数量');
1856
- case 12:
1857
- targetProduct = tempOrder.products[productIndex];
1858
- normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
1859
- num: getSafeProductNum(num),
1860
- metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
1861
- unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
1862
- })
1863
- }));
1864
- tempOrder.products[productIndex] = normalizedProduct;
1865
- this.applyDiscount();
1866
- _context17.next = 18;
1867
- return this.recalculateSummary({
1868
- createIfMissing: true
1869
- });
1870
- case 18:
1871
- this.persistTempOrder();
1872
- return _context17.abrupt("return", tempOrder.products);
1873
1584
  case 20:
1585
+ this.persistTempOrder();
1586
+ return _context14.abrupt("return", tempOrder.products);
1587
+ case 22:
1874
1588
  case "end":
1875
- return _context17.stop();
1589
+ return _context14.stop();
1876
1590
  }
1877
- }, _callee17, this);
1591
+ }, _callee14, this);
1878
1592
  }));
1879
- function updateOrderProductQuantity(_x19) {
1880
- return _updateOrderProductQuantity.apply(this, arguments);
1593
+ function updateProductInOrder(_x14) {
1594
+ return _updateProductInOrder.apply(this, arguments);
1881
1595
  }
1882
- return updateOrderProductQuantity;
1596
+ return updateProductInOrder;
1883
1597
  }()
1884
- }, {
1885
- key: "updateOrderBooking",
1886
- value: function updateOrderBooking(params) {
1887
- var unique_identification_number = params.unique_identification_number,
1888
- updates = params.updates;
1889
- var tempOrder = this.ensureTempOrder();
1890
- var bookingUid = String(unique_identification_number || '');
1891
- var bookingIndex = this.findBookingIndexByUniqueIdentificationNumber(tempOrder, bookingUid);
1892
- if (!bookingUid || bookingIndex === -1) {
1893
- throw new Error('[Order] 目标 booking 不存在,无法更新');
1894
- }
1895
- var targetBooking = tempOrder.bookings[bookingIndex] || {};
1896
- var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
1897
- metadata: _objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), {}, {
1898
- unique_identification_number: bookingUid
1899
- })
1900
- });
1901
- nextBooking.is_all = normalizeBookingIsAll(nextBooking);
1902
- nextBooking.sub_type = normalizeBookingSubType(nextBooking);
1903
- tempOrder.bookings[bookingIndex] = nextBooking;
1904
- this.persistTempOrder();
1905
- return tempOrder.bookings;
1906
- }
1907
1598
  }, {
1908
1599
  key: "removeProductFromOrder",
1909
1600
  value: function () {
1910
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
1911
- var tempOrder, removedProducts, _i, _removedProducts, product;
1912
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1913
- 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) {
1914
1605
  case 0:
1915
1606
  tempOrder = this.ensureTempOrder();
1916
- removedProducts = [];
1917
1607
  tempOrder.products = tempOrder.products.filter(function (item) {
1918
- var shouldRemove = isIdentityMatch(item, identity);
1919
- if (shouldRemove) removedProducts.push(item);
1920
- return !shouldRemove;
1608
+ return !isIdentityMatch(item, identity);
1921
1609
  });
1922
- for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
1923
- product = _removedProducts[_i];
1924
- this.removeLinkedBookingsForProduct(tempOrder, product);
1925
- }
1926
1610
  this.applyDiscount();
1927
- _context18.next = 7;
1611
+ _context15.next = 5;
1928
1612
  return this.recalculateSummary({
1929
1613
  createIfMissing: true
1930
1614
  });
1931
- case 7:
1615
+ case 5:
1932
1616
  this.persistTempOrder();
1933
- return _context18.abrupt("return", tempOrder.products);
1934
- case 9:
1617
+ return _context15.abrupt("return", tempOrder.products);
1618
+ case 7:
1935
1619
  case "end":
1936
- return _context18.stop();
1620
+ return _context15.stop();
1937
1621
  }
1938
- }, _callee18, this);
1622
+ }, _callee15, this);
1939
1623
  }));
1940
- function removeProductFromOrder(_x20) {
1624
+ function removeProductFromOrder(_x15) {
1941
1625
  return _removeProductFromOrder.apply(this, arguments);
1942
1626
  }
1943
1627
  return removeProductFromOrder;
1944
- }()
1945
- /**
1946
- * 仅清空购物车行(products / bookings / discount_list),不重置整单。
1947
- * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
1948
- */
1949
- }, {
1950
- key: "clearOrderCartLines",
1951
- value: (function () {
1952
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1953
- var tempOrder;
1954
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1955
- while (1) switch (_context19.prev = _context19.next) {
1956
- case 0:
1957
- tempOrder = this.ensureTempOrder();
1958
- tempOrder.products = [];
1959
- tempOrder.bookings = [];
1960
- tempOrder.discount_list = [];
1961
- if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
1962
- tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
1963
- productsByUid: {}
1964
- });
1965
- }
1966
- this.applyDiscount();
1967
- _context19.next = 8;
1968
- return this.recalculateSummary({
1969
- createIfMissing: true
1970
- });
1971
- case 8:
1972
- this.persistTempOrder();
1973
- return _context19.abrupt("return", tempOrder);
1974
- case 10:
1975
- case "end":
1976
- return _context19.stop();
1977
- }
1978
- }, _callee19, this);
1979
- }));
1980
- function clearOrderCartLines() {
1981
- return _clearOrderCartLines.apply(this, arguments);
1982
- }
1983
- return clearOrderCartLines;
1984
1628
  }() // ─── TempOrder: 提交 ───
1985
1629
  /**
1986
1630
  * 提交当前 Sales tempOrder。
@@ -1988,15 +1632,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1988
1632
  * smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
1989
1633
  * 应传 1,确保 /order/sales/checkout 返回打印所需数据。
1990
1634
  */
1991
- )
1992
1635
  }, {
1993
1636
  key: "submitTempOrder",
1994
1637
  value: function () {
1995
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1638
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1996
1639
  var _params$cacheId, _this$otherParams;
1997
1640
  var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
1998
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1999
- while (1) switch (_context20.prev = _context20.next) {
1641
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1642
+ while (1) switch (_context16.prev = _context16.next) {
2000
1643
  case 0:
2001
1644
  tempOrder = this.ensureTempOrder();
2002
1645
  this.persistTempOrder();
@@ -2023,10 +1666,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2023
1666
  type: params === null || params === void 0 ? void 0 : params.type,
2024
1667
  enhance: enhancePayload
2025
1668
  });
2026
- _context20.next = 10;
1669
+ _context16.next = 10;
2027
1670
  return this.saveDraft();
2028
1671
  case 10:
2029
- _context20.prev = 10;
1672
+ _context16.prev = 10;
2030
1673
  this.logInfo('submitTempOrder calling sales checkout', {
2031
1674
  orderId: payload.order_id,
2032
1675
  externalSaleNumber: payload.external_sale_number,
@@ -2034,62 +1677,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2034
1677
  paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
2035
1678
  smallTicketDataFlag: payload.small_ticket_data_flag
2036
1679
  });
2037
- _context20.next = 14;
1680
+ _context16.next = 14;
2038
1681
  return this.submitSalesOrder({
2039
1682
  query: payload
2040
1683
  });
2041
1684
  case 14:
2042
- result = _context20.sent;
2043
- _context20.next = 27;
1685
+ result = _context16.sent;
1686
+ _context16.next = 27;
2044
1687
  break;
2045
1688
  case 17:
2046
- _context20.prev = 17;
2047
- _context20.t0 = _context20["catch"](10);
2048
- backendErrorResponse = this.extractSubmitErrorResponse(_context20.t0);
1689
+ _context16.prev = 17;
1690
+ _context16.t0 = _context16["catch"](10);
1691
+ backendErrorResponse = this.extractSubmitErrorResponse(_context16.t0);
2049
1692
  if (!backendErrorResponse) {
2050
- _context20.next = 24;
1693
+ _context16.next = 24;
2051
1694
  break;
2052
1695
  }
2053
1696
  this.store.syncState = 'failed';
2054
1697
  this.logSubmitBackendRejected(backendErrorResponse, payload);
2055
- return _context20.abrupt("return", backendErrorResponse);
1698
+ return _context16.abrupt("return", backendErrorResponse);
2056
1699
  case 24:
2057
1700
  this.store.syncState = 'failed';
2058
1701
  this.logError('submitTempOrder failed', {
2059
- error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
1702
+ error: _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0),
2060
1703
  orderId: payload.order_id,
2061
1704
  externalSaleNumber: payload.external_sale_number,
2062
1705
  paymentStatus: payload.payment_status,
2063
1706
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
2064
1707
  });
2065
- throw _context20.t0;
1708
+ throw _context16.t0;
2066
1709
  case 27:
2067
1710
  if (!this.isSubmitResponseRejected(result)) {
2068
- _context20.next = 31;
1711
+ _context16.next = 31;
2069
1712
  break;
2070
1713
  }
2071
1714
  this.store.syncState = 'failed';
2072
1715
  this.logSubmitBackendRejected(result, payload);
2073
- return _context20.abrupt("return", result);
1716
+ return _context16.abrupt("return", result);
2074
1717
  case 31:
2075
1718
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
2076
1719
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
2077
- _context20.next = 37;
1720
+ _context16.next = 37;
2078
1721
  break;
2079
1722
  }
2080
1723
  tempOrder.order_id = submittedOrderId;
2081
1724
  resultRecord = result;
2082
- _context20.next = 37;
1725
+ _context16.next = 37;
2083
1726
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
2084
1727
  case 37:
2085
- return _context20.abrupt("return", result);
1728
+ return _context16.abrupt("return", result);
2086
1729
  case 38:
2087
1730
  case "end":
2088
- return _context20.stop();
1731
+ return _context16.stop();
2089
1732
  }
2090
- }, _callee20, this, [[10, 17]]);
1733
+ }, _callee16, this, [[10, 17]]);
2091
1734
  }));
2092
- function submitTempOrder(_x21) {
1735
+ function submitTempOrder(_x16) {
2093
1736
  return _submitTempOrder.apply(this, arguments);
2094
1737
  }
2095
1738
  return submitTempOrder;
@@ -2097,25 +1740,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2097
1740
  }, {
2098
1741
  key: "markLocalOrderSynced",
2099
1742
  value: function () {
2100
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderId, remoteOrder) {
1743
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderId, remoteOrder) {
2101
1744
  var tempOrder;
2102
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2103
- while (1) switch (_context21.prev = _context21.next) {
1745
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1746
+ while (1) switch (_context17.prev = _context17.next) {
2104
1747
  case 0:
2105
1748
  tempOrder = this.ensureTempOrder();
2106
1749
  tempOrder.order_id = orderId;
2107
1750
  this.store.lastOrderInfo = remoteOrder;
2108
1751
  this.store.syncState = 'submitted';
2109
1752
  this.persistTempOrder();
2110
- _context21.next = 7;
1753
+ _context17.next = 7;
2111
1754
  return this.saveDraft();
2112
1755
  case 7:
2113
1756
  case "end":
2114
- return _context21.stop();
1757
+ return _context17.stop();
2115
1758
  }
2116
- }, _callee21, this);
1759
+ }, _callee17, this);
2117
1760
  }));
2118
- function markLocalOrderSynced(_x22, _x23) {
1761
+ function markLocalOrderSynced(_x17, _x18) {
2119
1762
  return _markLocalOrderSynced.apply(this, arguments);
2120
1763
  }
2121
1764
  return markLocalOrderSynced;
@@ -2139,10 +1782,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2139
1782
  value: function extractSubmitErrorResponse(error) {
2140
1783
  var _error$response,
2141
1784
  _error$response2,
2142
- _this6 = this;
1785
+ _this4 = this;
2143
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];
2144
1787
  return candidates.find(function (candidate) {
2145
- return _this6.isSubmitErrorResponse(candidate);
1788
+ return _this4.isSubmitErrorResponse(candidate);
2146
1789
  }) || null;
2147
1790
  }
2148
1791
  }, {
@@ -2162,60 +1805,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2162
1805
  }, {
2163
1806
  key: "syncPaymentsToOrder",
2164
1807
  value: function () {
2165
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2166
- var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
2167
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2168
- 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) {
2169
1812
  case 0:
2170
1813
  tempOrder = this.ensureTempOrder();
2171
1814
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
2172
- paymentTotal = this.calculatePaymentTotal(mappedPayments);
2173
- targetAmount = this.getPaymentTargetAmount();
2174
- isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
2175
- paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
2176
1815
  tempOrder.payments = mappedPayments;
2177
- tempOrder.payment_status = paymentStatus;
1816
+ if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
2178
1817
  this.persistTempOrder();
2179
- _context22.next = 11;
1818
+ _context18.next = 7;
2180
1819
  return this.saveDraft();
2181
- case 11:
2182
- if (params.submitWhenPaid) {
2183
- _context22.next = 13;
2184
- break;
2185
- }
2186
- return _context22.abrupt("return", {
2187
- isFullyPaid: isFullyPaid
2188
- });
2189
- case 13:
2190
- if (!(this.store.syncState === 'submitting')) {
2191
- _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;
2192
1826
  break;
2193
1827
  }
2194
- return _context22.abrupt("return", {
1828
+ return _context18.abrupt("return", {
2195
1829
  isFullyPaid: isFullyPaid
2196
1830
  });
2197
- case 15:
2198
- this.store.syncState = 'submitting';
2199
- _context22.next = 18;
1831
+ case 12:
1832
+ _context18.next = 14;
2200
1833
  return this.submitTempOrder({
2201
1834
  payments: mappedPayments,
2202
- paymentStatus: paymentStatus,
2203
- smallTicketDataFlag: params.smallTicketDataFlag,
2204
- channel: params.channel
1835
+ paymentStatus: params.paymentStatus || 'paid',
1836
+ smallTicketDataFlag: params.smallTicketDataFlag
2205
1837
  });
2206
- case 18:
2207
- submitResult = _context22.sent;
2208
- return _context22.abrupt("return", {
1838
+ case 14:
1839
+ submitResult = _context18.sent;
1840
+ return _context18.abrupt("return", {
2209
1841
  isFullyPaid: isFullyPaid,
2210
1842
  submitResult: submitResult
2211
1843
  });
2212
- case 20:
1844
+ case 16:
2213
1845
  case "end":
2214
- return _context22.stop();
1846
+ return _context18.stop();
2215
1847
  }
2216
- }, _callee22, this);
1848
+ }, _callee18, this);
2217
1849
  }));
2218
- function syncPaymentsToOrder(_x24) {
1850
+ function syncPaymentsToOrder(_x19) {
2219
1851
  return _syncPaymentsToOrder.apply(this, arguments);
2220
1852
  }
2221
1853
  return syncPaymentsToOrder;
@@ -2304,11 +1936,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2304
1936
  }, {
2305
1937
  key: "submitOrder",
2306
1938
  value: function () {
2307
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(order) {
1939
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order) {
2308
1940
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
2309
1941
  var url, query, fetchUrl, params;
2310
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2311
- while (1) switch (_context23.prev = _context23.next) {
1942
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1943
+ while (1) switch (_context19.prev = _context19.next) {
2312
1944
  case 0:
2313
1945
  this.logInfo('submitOrder called', {
2314
1946
  url: order.url,
@@ -2328,14 +1960,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2328
1960
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
2329
1961
  scheduleDate: params.schedule_date
2330
1962
  });
2331
- return _context23.abrupt("return", this.request.post(fetchUrl, params));
1963
+ return _context19.abrupt("return", this.request.post(fetchUrl, params));
2332
1964
  case 6:
2333
1965
  case "end":
2334
- return _context23.stop();
1966
+ return _context19.stop();
2335
1967
  }
2336
- }, _callee23, this);
1968
+ }, _callee19, this);
2337
1969
  }));
2338
- function submitOrder(_x25) {
1970
+ function submitOrder(_x20) {
2339
1971
  return _submitOrder.apply(this, arguments);
2340
1972
  }
2341
1973
  return submitOrder;
@@ -2343,13 +1975,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2343
1975
  }, {
2344
1976
  key: "cancelOrder",
2345
1977
  value: function () {
2346
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
1978
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2347
1979
  var payload;
2348
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2349
- while (1) switch (_context24.prev = _context24.next) {
1980
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1981
+ while (1) switch (_context20.prev = _context20.next) {
2350
1982
  case 0:
2351
1983
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
2352
- _context24.next = 2;
1984
+ _context20.next = 2;
2353
1985
  break;
2354
1986
  }
2355
1987
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -2365,16 +1997,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2365
1997
  method: 'PUT',
2366
1998
  orderIdsCount: params.order_ids.length
2367
1999
  });
2368
- return _context24.abrupt("return", this.request.put('/order/update-status', payload, {
2000
+ return _context20.abrupt("return", this.request.put('/order/update-status', payload, {
2369
2001
  isShopApi: true
2370
2002
  }));
2371
2003
  case 5:
2372
2004
  case "end":
2373
- return _context24.stop();
2005
+ return _context20.stop();
2374
2006
  }
2375
- }, _callee24, this);
2007
+ }, _callee20, this);
2376
2008
  }));
2377
- function cancelOrder(_x26) {
2009
+ function cancelOrder(_x21) {
2378
2010
  return _cancelOrder.apply(this, arguments);
2379
2011
  }
2380
2012
  return cancelOrder;
@@ -2382,19 +2014,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2382
2014
  }, {
2383
2015
  key: "changeBookingStatus",
2384
2016
  value: function () {
2385
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
2017
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2386
2018
  var url, payload;
2387
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2388
- while (1) switch (_context25.prev = _context25.next) {
2019
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2020
+ while (1) switch (_context21.prev = _context21.next) {
2389
2021
  case 0:
2390
2022
  if (params.booking_id) {
2391
- _context25.next = 2;
2023
+ _context21.next = 2;
2392
2024
  break;
2393
2025
  }
2394
2026
  throw new Error('变更预约状态失败:booking_id 不能为空');
2395
2027
  case 2:
2396
2028
  if (params.appointment_status) {
2397
- _context25.next = 4;
2029
+ _context21.next = 4;
2398
2030
  break;
2399
2031
  }
2400
2032
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -2409,16 +2041,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2409
2041
  bookingId: params.booking_id,
2410
2042
  appointmentStatus: params.appointment_status
2411
2043
  });
2412
- return _context25.abrupt("return", this.request.put(url, payload, {
2044
+ return _context21.abrupt("return", this.request.put(url, payload, {
2413
2045
  isShopApi: true
2414
2046
  }));
2415
2047
  case 8:
2416
2048
  case "end":
2417
- return _context25.stop();
2049
+ return _context21.stop();
2418
2050
  }
2419
- }, _callee25, this);
2051
+ }, _callee21, this);
2420
2052
  }));
2421
- function changeBookingStatus(_x27) {
2053
+ function changeBookingStatus(_x22) {
2422
2054
  return _changeBookingStatus.apply(this, arguments);
2423
2055
  }
2424
2056
  return changeBookingStatus;
@@ -2436,11 +2068,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2436
2068
  }, {
2437
2069
  key: "createOrderByCheckout",
2438
2070
  value: (function () {
2439
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2071
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2440
2072
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
2441
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;
2442
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2443
- while (1) switch (_context26.prev = _context26.next) {
2074
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2075
+ while (1) switch (_context22.prev = _context22.next) {
2444
2076
  case 0:
2445
2077
  // 过滤掉由在线店铺下单的 payment 支付数据
2446
2078
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -2474,7 +2106,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2474
2106
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
2475
2107
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
2476
2108
  });
2477
- _context26.prev = 4;
2109
+ _context22.prev = 4;
2478
2110
  // 构建订单数据,设置默认值并允许 params 覆盖
2479
2111
  orderData = _objectSpread({
2480
2112
  sales_channel: 'my_pisel',
@@ -2538,10 +2170,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2538
2170
  });
2539
2171
 
2540
2172
  // 调用后端接口
2541
- _context26.next = 12;
2173
+ _context22.next = 12;
2542
2174
  return this.request.post('/order/checkout', orderData);
2543
2175
  case 12:
2544
- response = _context26.sent;
2176
+ response = _context22.sent;
2545
2177
  this.logInfo('Order API called successfully', {
2546
2178
  response: response
2547
2179
  });
@@ -2549,22 +2181,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2549
2181
  success: !!response,
2550
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)
2551
2183
  });
2552
- return _context26.abrupt("return", response);
2184
+ return _context22.abrupt("return", response);
2553
2185
  case 18:
2554
- _context26.prev = 18;
2555
- _context26.t0 = _context26["catch"](4);
2556
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context26.t0);
2186
+ _context22.prev = 18;
2187
+ _context22.t0 = _context22["catch"](4);
2188
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context22.t0);
2557
2189
  this.logInfo('Order API called failed', {
2558
- error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
2190
+ error: _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0)
2559
2191
  });
2560
- throw _context26.t0;
2192
+ throw _context22.t0;
2561
2193
  case 23:
2562
2194
  case "end":
2563
- return _context26.stop();
2195
+ return _context22.stop();
2564
2196
  }
2565
- }, _callee26, this, [[4, 18]]);
2197
+ }, _callee22, this, [[4, 18]]);
2566
2198
  }));
2567
- function createOrderByCheckout(_x28) {
2199
+ function createOrderByCheckout(_x23) {
2568
2200
  return _createOrderByCheckout.apply(this, arguments);
2569
2201
  }
2570
2202
  return createOrderByCheckout;
@@ -2572,23 +2204,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2572
2204
  }, {
2573
2205
  key: "submitSalesOrder",
2574
2206
  value: function () {
2575
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2207
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2576
2208
  var url, query, fetchUrl;
2577
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2578
- while (1) switch (_context27.prev = _context27.next) {
2209
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2210
+ while (1) switch (_context23.prev = _context23.next) {
2579
2211
  case 0:
2580
2212
  url = params.url, query = params.query;
2581
2213
  fetchUrl = url || '/order/sales/checkout';
2582
- return _context27.abrupt("return", this.request.post(fetchUrl, query, {
2214
+ return _context23.abrupt("return", this.request.post(fetchUrl, query, {
2583
2215
  customToast: function customToast() {}
2584
2216
  }));
2585
2217
  case 3:
2586
2218
  case "end":
2587
- return _context27.stop();
2219
+ return _context23.stop();
2588
2220
  }
2589
- }, _callee27, this);
2221
+ }, _callee23, this);
2590
2222
  }));
2591
- function submitSalesOrder(_x29) {
2223
+ function submitSalesOrder(_x24) {
2592
2224
  return _submitSalesOrder.apply(this, arguments);
2593
2225
  }
2594
2226
  return submitSalesOrder;
@@ -2602,37 +2234,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2602
2234
  }, {
2603
2235
  key: "sendCustomerPayLink",
2604
2236
  value: (function () {
2605
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2237
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2606
2238
  var _params$emails;
2607
2239
  var orderIds;
2608
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2609
- while (1) switch (_context28.prev = _context28.next) {
2240
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2241
+ while (1) switch (_context24.prev = _context24.next) {
2610
2242
  case 0:
2611
2243
  orderIds = params.order_ids || params.orderIds || [];
2612
2244
  if (orderIds.length) {
2613
- _context28.next = 3;
2245
+ _context24.next = 3;
2614
2246
  break;
2615
2247
  }
2616
2248
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
2617
2249
  case 3:
2618
2250
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
2619
- _context28.next = 5;
2251
+ _context24.next = 5;
2620
2252
  break;
2621
2253
  }
2622
2254
  throw new Error('发送支付链接需要至少一个邮箱');
2623
2255
  case 5:
2624
- return _context28.abrupt("return", this.request.post('/order/batch-email', {
2256
+ return _context24.abrupt("return", this.request.post('/order/batch-email', {
2625
2257
  order_ids: orderIds,
2626
2258
  notify_action: params.notify_action || 'order_payment_reminder',
2627
2259
  emails: params.emails
2628
2260
  }));
2629
2261
  case 6:
2630
2262
  case "end":
2631
- return _context28.stop();
2263
+ return _context24.stop();
2632
2264
  }
2633
- }, _callee28, this);
2265
+ }, _callee24, this);
2634
2266
  }));
2635
- function sendCustomerPayLink(_x30) {
2267
+ function sendCustomerPayLink(_x25) {
2636
2268
  return _sendCustomerPayLink.apply(this, arguments);
2637
2269
  }
2638
2270
  return sendCustomerPayLink;
@@ -2641,28 +2273,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2641
2273
  }, {
2642
2274
  key: "getOrderInfoByRemote",
2643
2275
  value: function () {
2644
- var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(order_id) {
2276
+ var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order_id) {
2645
2277
  var res;
2646
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2647
- while (1) switch (_context29.prev = _context29.next) {
2278
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2279
+ while (1) switch (_context25.prev = _context25.next) {
2648
2280
  case 0:
2649
- _context29.next = 2;
2281
+ _context25.next = 2;
2650
2282
  return this.request.get("/order/sales/".concat(order_id), {
2651
2283
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
2652
2284
  });
2653
2285
  case 2:
2654
- res = _context29.sent;
2286
+ res = _context25.sent;
2655
2287
  if (res.code === 200) {
2656
2288
  this.store.lastOrderInfo = res.data;
2657
2289
  }
2658
- return _context29.abrupt("return", res);
2290
+ return _context25.abrupt("return", res);
2659
2291
  case 5:
2660
2292
  case "end":
2661
- return _context29.stop();
2293
+ return _context25.stop();
2662
2294
  }
2663
- }, _callee29, this);
2295
+ }, _callee25, this);
2664
2296
  }));
2665
- function getOrderInfoByRemote(_x31) {
2297
+ function getOrderInfoByRemote(_x26) {
2666
2298
  return _getOrderInfoByRemote.apply(this, arguments);
2667
2299
  }
2668
2300
  return getOrderInfoByRemote;
@@ -2676,84 +2308,79 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2676
2308
  }, {
2677
2309
  key: "hydrateTempOrderFromRecord",
2678
2310
  value: (function () {
2679
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(record, options) {
2680
- var raw, nextTempOrder;
2681
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2682
- 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) {
2683
2316
  case 0:
2684
2317
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
2685
- nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
2686
- 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
+ }
2687
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);
2688
2359
  this.store.tempOrder = nextTempOrder;
2689
2360
  this.store.summary = raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread(_objectSpread({}, createEmptySummary()), raw.summary) : createEmptySummary();
2690
2361
  this.store.lastOrderInfo = raw.lastOrderInfo || raw;
2691
2362
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
2692
- _context30.next = 8;
2363
+ _context26.next = 23;
2693
2364
  break;
2694
2365
  }
2695
- _context30.next = 8;
2366
+ _context26.next = 23;
2696
2367
  return this.recalculateSummary({
2697
2368
  createIfMissing: false
2698
2369
  });
2699
- case 8:
2370
+ case 23:
2700
2371
  this.persistTempOrder();
2701
- return _context30.abrupt("return", nextTempOrder);
2702
- case 10:
2372
+ return _context26.abrupt("return", nextTempOrder);
2373
+ case 25:
2703
2374
  case "end":
2704
- return _context30.stop();
2375
+ return _context26.stop();
2705
2376
  }
2706
- }, _callee30, this);
2377
+ }, _callee26, this);
2707
2378
  }));
2708
- function hydrateTempOrderFromRecord(_x32, _x33) {
2379
+ function hydrateTempOrderFromRecord(_x27, _x28) {
2709
2380
  return _hydrateTempOrderFromRecord.apply(this, arguments);
2710
2381
  }
2711
2382
  return hydrateTempOrderFromRecord;
2712
2383
  }())
2713
- }, {
2714
- key: "normalizeTempOrderForRuntime",
2715
- value: function normalizeTempOrderForRuntime(raw, options) {
2716
- var _this7 = this;
2717
- var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
2718
- delete nextTempOrder.summary;
2719
- delete nextTempOrder.lastOrderInfo;
2720
- nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
2721
- nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
2722
- nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
2723
- return _this7.normalizeHydratedOrderProduct(p);
2724
- }) : [];
2725
- nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
2726
- return _objectSpread(_objectSpread({}, b || {}), {}, {
2727
- is_all: normalizeBookingIsAll(b || {}),
2728
- sub_type: normalizeBookingSubType(b || {})
2729
- });
2730
- }) : [];
2731
- nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
2732
- return _objectSpread({}, p || {});
2733
- }) : [];
2734
- nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
2735
- return _objectSpread({}, s || {});
2736
- }) : [];
2737
- nextTempOrder.discount_list = Array.isArray(raw.discount_list) ? raw.discount_list.map(function (d) {
2738
- return _objectSpread({}, d || {});
2739
- }) : [];
2740
- nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
2741
- return _objectSpread({}, f || {});
2742
- }) : [];
2743
- nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
2744
- return _objectSpread({}, c || {});
2745
- }) : [];
2746
- nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
2747
- nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
2748
- productsByUid: raw._extend.productsByUid || {}
2749
- }) : {
2750
- productsByUid: {}
2751
- };
2752
- if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
2753
- this.ensureExternalSaleNumber(nextTempOrder);
2754
- }
2755
- return nextTempOrder;
2756
- }
2757
2384
  }, {
2758
2385
  key: "normalizeHydratedOrderProduct",
2759
2386
  value: function normalizeHydratedOrderProduct(product) {
@@ -2784,25 +2411,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2784
2411
  }, {
2785
2412
  key: "getOrderInfo",
2786
2413
  value: function () {
2787
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order_id) {
2414
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order_id) {
2788
2415
  var res;
2789
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2790
- while (1) switch (_context31.prev = _context31.next) {
2416
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2417
+ while (1) switch (_context27.prev = _context27.next) {
2791
2418
  case 0:
2792
- _context31.next = 2;
2419
+ _context27.next = 2;
2793
2420
  return this.request.get("/order/sales/".concat(order_id), {
2794
2421
  with: ['products', 'bookings']
2795
2422
  });
2796
2423
  case 2:
2797
- res = _context31.sent;
2798
- return _context31.abrupt("return", res);
2424
+ res = _context27.sent;
2425
+ return _context27.abrupt("return", res);
2799
2426
  case 4:
2800
2427
  case "end":
2801
- return _context31.stop();
2428
+ return _context27.stop();
2802
2429
  }
2803
- }, _callee31, this);
2430
+ }, _callee27, this);
2804
2431
  }));
2805
- function getOrderInfo(_x34) {
2432
+ function getOrderInfo(_x29) {
2806
2433
  return _getOrderInfo.apply(this, arguments);
2807
2434
  }
2808
2435
  return getOrderInfo;