@pisell/pisellos 2.3.94 → 2.3.96

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 (88) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.js +13 -2
  2. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  4. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  5. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  6. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  7. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  8. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  9. package/dist/modules/Order/index.d.ts +20 -3
  10. package/dist/modules/Order/index.js +931 -508
  11. package/dist/modules/Order/salesNotes.d.ts +31 -0
  12. package/dist/modules/Order/salesNotes.js +492 -0
  13. package/dist/modules/Order/types.d.ts +91 -5
  14. package/dist/modules/Order/types.js +5 -0
  15. package/dist/modules/Order/utils.d.ts +12 -0
  16. package/dist/modules/Order/utils.js +75 -26
  17. package/dist/modules/ProductList/index.d.ts +2 -1
  18. package/dist/modules/ProductList/index.js +100 -20
  19. package/dist/modules/ProductList/types.d.ts +10 -0
  20. package/dist/modules/SalesSummary/index.js +6 -4
  21. package/dist/server/index.d.ts +6 -0
  22. package/dist/server/index.js +57 -11
  23. package/dist/server/modules/products/index.d.ts +2 -2
  24. package/dist/server/modules/products/index.js +10 -9
  25. package/dist/server/utils/product.d.ts +1 -1
  26. package/dist/server/utils/product.js +186 -22
  27. package/dist/server/utils/small-ticket.js +23 -2
  28. package/dist/solution/BaseSales/index.d.ts +9 -1
  29. package/dist/solution/BaseSales/index.js +894 -706
  30. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  31. package/dist/solution/BookingByStep/index.d.ts +2 -2
  32. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  33. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  34. package/dist/solution/RegisterAndLogin/config.js +95 -40
  35. package/dist/solution/RegisterAndLogin/index.js +4 -1
  36. package/dist/solution/ScanOrder/index.d.ts +1 -0
  37. package/dist/solution/ScanOrder/index.js +31 -27
  38. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  39. package/dist/solution/ScanOrder/utils.js +2 -0
  40. package/dist/solution/UnifiedBookingSales/index.d.ts +15 -2
  41. package/dist/solution/UnifiedBookingSales/index.js +751 -483
  42. package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
  43. package/dist/solution/VenueBooking/index.d.ts +1 -0
  44. package/dist/solution/VenueBooking/index.js +8 -4
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.js +12 -2
  46. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  47. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  48. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  49. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  50. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  51. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  52. package/lib/modules/Order/index.d.ts +20 -3
  53. package/lib/modules/Order/index.js +358 -42
  54. package/lib/modules/Order/salesNotes.d.ts +31 -0
  55. package/lib/modules/Order/salesNotes.js +382 -0
  56. package/lib/modules/Order/types.d.ts +91 -5
  57. package/lib/modules/Order/types.js +4 -0
  58. package/lib/modules/Order/utils.d.ts +12 -0
  59. package/lib/modules/Order/utils.js +68 -16
  60. package/lib/modules/ProductList/index.d.ts +2 -1
  61. package/lib/modules/ProductList/index.js +47 -2
  62. package/lib/modules/ProductList/types.d.ts +10 -0
  63. package/lib/modules/SalesSummary/index.js +3 -1
  64. package/lib/server/index.d.ts +6 -0
  65. package/lib/server/index.js +47 -9
  66. package/lib/server/modules/products/index.d.ts +2 -2
  67. package/lib/server/modules/products/index.js +5 -4
  68. package/lib/server/utils/product.d.ts +1 -1
  69. package/lib/server/utils/product.js +163 -3
  70. package/lib/server/utils/small-ticket.js +22 -1
  71. package/lib/solution/BaseSales/index.d.ts +9 -1
  72. package/lib/solution/BaseSales/index.js +105 -1
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  74. package/lib/solution/BookingByStep/index.d.ts +2 -2
  75. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  76. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  77. package/lib/solution/RegisterAndLogin/config.js +49 -8
  78. package/lib/solution/RegisterAndLogin/index.js +4 -1
  79. package/lib/solution/ScanOrder/index.d.ts +1 -0
  80. package/lib/solution/ScanOrder/index.js +5 -1
  81. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  82. package/lib/solution/ScanOrder/utils.js +1 -0
  83. package/lib/solution/UnifiedBookingSales/index.d.ts +15 -2
  84. package/lib/solution/UnifiedBookingSales/index.js +125 -1
  85. package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
  86. package/lib/solution/VenueBooking/index.d.ts +1 -0
  87. package/lib/solution/VenueBooking/index.js +5 -1
  88. package/package.json +1 -1
@@ -35,6 +35,7 @@ import { OrderHooks } from "./types";
35
35
  import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
+ import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
38
39
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
39
40
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
40
41
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
@@ -1373,6 +1374,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1373
1374
  if (!this.store.tempOrder) return;
1374
1375
  this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
1375
1376
  products: _toConsumableArray(this.store.tempOrder.products),
1377
+ notes: _toConsumableArray(this.store.tempOrder.notes || []),
1376
1378
  bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
1377
1379
  });
1378
1380
  this.persistTempOrder();
@@ -1534,21 +1536,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1534
1536
  return Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
1535
1537
  }
1536
1538
  }, {
1537
- key: "getLastOrderDepositSnapshot",
1538
- value: function getLastOrderDepositSnapshot() {
1539
- var _lastOrderInfo$deposi, _lastOrderInfo$summar;
1540
- var lastOrderInfo = this.store.lastOrderInfo;
1541
- if (!lastOrderInfo || _typeof(lastOrderInfo) !== 'object') return null;
1542
- var rawDepositAmount = (_lastOrderInfo$deposi = lastOrderInfo.deposit_amount) !== null && _lastOrderInfo$deposi !== void 0 ? _lastOrderInfo$deposi : (_lastOrderInfo$summar = lastOrderInfo.summary) === null || _lastOrderInfo$summar === void 0 ? void 0 : _lastOrderInfo$summar.deposit_amount;
1539
+ key: "normalizeDepositFlag",
1540
+ value: function normalizeDepositFlag(value) {
1541
+ if (value === 0 || value === '0') return 0;
1542
+ if (value === 1 || value === '1') return 1;
1543
+ return null;
1544
+ }
1545
+ }, {
1546
+ key: "getHistoricalDepositSnapshot",
1547
+ value: function getHistoricalDepositSnapshot(source) {
1548
+ var _record$deposit_amoun, _record$summary, _this$normalizeDeposi;
1549
+ if (!source || _typeof(source) !== 'object') return null;
1550
+ var record = source;
1551
+ var rawDepositAmount = (_record$deposit_amoun = record.deposit_amount) !== null && _record$deposit_amoun !== void 0 ? _record$deposit_amoun : (_record$summary = record.summary) === null || _record$summary === void 0 ? void 0 : _record$summary.deposit_amount;
1543
1552
  var depositAmount = this.normalizeDepositAmount(rawDepositAmount !== null && rawDepositAmount !== void 0 ? rawDepositAmount : 0);
1544
- var hasDepositAmount = new Decimal(depositAmount).gt(0);
1545
- var isDeposit = Number(lastOrderInfo.is_deposit) === 1 || hasDepositAmount;
1546
- if (!isDeposit || !hasDepositAmount) return null;
1553
+ if (!new Decimal(depositAmount).gt(0)) return null;
1547
1554
  return {
1548
- isDeposit: 1,
1555
+ // 兼容历史数据:旧快照缺少 is_deposit 时,沿用正定金金额的推导规则。
1556
+ isDeposit: (_this$normalizeDeposi = this.normalizeDepositFlag(record.is_deposit)) !== null && _this$normalizeDeposi !== void 0 ? _this$normalizeDeposi : 1,
1549
1557
  depositAmount: depositAmount
1550
1558
  };
1551
1559
  }
1560
+ }, {
1561
+ key: "getLastOrderDepositSnapshot",
1562
+ value: function getLastOrderDepositSnapshot() {
1563
+ return this.getHistoricalDepositSnapshot(this.store.lastOrderInfo);
1564
+ }
1552
1565
  }, {
1553
1566
  key: "getLastOrderSubmitSnapshot",
1554
1567
  value: function getLastOrderSubmitSnapshot() {
@@ -1595,7 +1608,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1595
1608
  })
1596
1609
  });
1597
1610
  tempOrder.deposit_amount = snapshot.depositAmount;
1598
- tempOrder.is_deposit = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0) ? 0 : snapshot.isDeposit;
1611
+ tempOrder.is_deposit = snapshot.isDeposit;
1599
1612
  return nextSummary;
1600
1613
  }
1601
1614
  }, {
@@ -2305,6 +2318,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2305
2318
  }, {
2306
2319
  key: "restoreOriginalSnapshotIfProductsUnchanged",
2307
2320
  value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
2321
+ var _historicalDepositSna;
2308
2322
  // merge hydrate 的商品集合包含本地未提交行,但 summary 仍来自远端旧订单,不能复用。
2309
2323
  if (snapshot.requiresFullSummaryRecalculation === true) return null;
2310
2324
  var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
@@ -2316,10 +2330,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2316
2330
  }
2317
2331
  var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
2318
2332
  var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === this.buildOrderProductsStructuralFingerprint(tempOrder.products));
2333
+ var historicalDepositSnapshot = this.getHistoricalDepositSnapshot(snapshot);
2319
2334
  if (shouldUseManualDepositOverride) {
2320
2335
  summary = this.applyDepositAmountToSummary(tempOrder, summary, manualDepositOverride.amount);
2321
- } else if (manualDepositOverride) {
2322
- this.clearManualDepositOverride(tempOrder);
2336
+ } else {
2337
+ if (manualDepositOverride) {
2338
+ this.clearManualDepositOverride(tempOrder);
2339
+ }
2340
+ if (historicalDepositSnapshot) {
2341
+ summary = this.applyDepositAmountToSummary(tempOrder, summary, historicalDepositSnapshot.depositAmount);
2342
+ tempOrder.is_deposit = historicalDepositSnapshot.isDeposit;
2343
+ }
2323
2344
  }
2324
2345
  var isPayableAmountUnchanged = this.isSnapshotPayableAmountUnchanged(tempOrder, snapshot, summary);
2325
2346
  if (!isPayableAmountUnchanged) return null;
@@ -2336,8 +2357,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2336
2357
  tempOrder.surcharges = cloneDeep(snapshot.surcharges);
2337
2358
  }
2338
2359
  tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
2339
- tempOrder.deposit_amount = summary.deposit_amount || '0.00';
2340
- tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
2360
+ tempOrder.deposit_amount = this.normalizeDepositAmount(summary.deposit_amount || 0);
2361
+ tempOrder.is_deposit = shouldUseManualDepositOverride ? new Decimal(tempOrder.deposit_amount).gt(0) ? 1 : 0 : (_historicalDepositSna = historicalDepositSnapshot === null || historicalDepositSnapshot === void 0 ? void 0 : historicalDepositSnapshot.isDeposit) !== null && _historicalDepositSna !== void 0 ? _historicalDepositSna : new Decimal(tempOrder.deposit_amount).gt(0) ? 1 : 0;
2341
2362
  var previousSummary = this.store.summary;
2342
2363
  this.store.summary = summary;
2343
2364
  this.updateTempOrderPaymentStatus(tempOrder, {
@@ -2998,7 +3019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2998
3019
  var isExistingDepositDisabled = tempOrder.is_deposit === 0 && new Decimal(tempOrder.deposit_amount || 0).gt(0);
2999
3020
  tempOrder.deposit_amount = depositAmount;
3000
3021
  tempOrder.is_deposit = hasDepositAmount && !isExistingDepositDisabled ? 1 : 0;
3001
- return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
3022
+ return shouldUseManualDepositOverride ? nextSummary : this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
3002
3023
  }
3003
3024
  }, {
3004
3025
  key: "recalculateSummary",
@@ -3208,6 +3229,277 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3208
3229
  var _this$store$tempOrder3;
3209
3230
  return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
3210
3231
  }
3232
+ }, {
3233
+ key: "ensureSalesNotesRuntimeState",
3234
+ value: function ensureSalesNotesRuntimeState(tempOrder) {
3235
+ var hadNotesSnapshot = Array.isArray(tempOrder.notes);
3236
+ if (!Array.isArray(tempOrder.notes)) tempOrder.notes = [];
3237
+ if (!tempOrder._extend || _typeof(tempOrder._extend) !== 'object') {
3238
+ tempOrder._extend = {
3239
+ productsByUid: {}
3240
+ };
3241
+ }
3242
+ if (!tempOrder._extend.salesNotesState) {
3243
+ tempOrder._extend.salesNotesState = {
3244
+ loaded: hadNotesSnapshot,
3245
+ dirty: false
3246
+ };
3247
+ }
3248
+ return tempOrder._extend.salesNotesState;
3249
+ }
3250
+ }, {
3251
+ key: "ensureSalesNotesLoadedForMutation",
3252
+ value: function ensureSalesNotesLoadedForMutation(tempOrder) {
3253
+ var state = this.ensureSalesNotesRuntimeState(tempOrder);
3254
+ if (state.loaded) return;
3255
+ if (tempOrder.order_id === null || tempOrder.order_id === undefined) {
3256
+ state.loaded = true;
3257
+ tempOrder.notes = [];
3258
+ return;
3259
+ }
3260
+ throw new Error('[Order Notes] 当前订单 Notes 尚未完整加载,禁止提交部分快照');
3261
+ }
3262
+ }, {
3263
+ key: "normalizeSalesNoteUuid",
3264
+ value: function normalizeSalesNoteUuid(value, field) {
3265
+ var uuid = String(value !== null && value !== void 0 ? value : '').trim();
3266
+ if (!uuid) throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u4E3A\u7A7A"));
3267
+ if (uuid.length > 255) {
3268
+ throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u8D85\u8FC7 255 \u4E2A\u5B57\u7B26"));
3269
+ }
3270
+ return uuid;
3271
+ }
3272
+ }, {
3273
+ key: "getSalesNotePrimaryRelation",
3274
+ value: function getSalesNotePrimaryRelation(note) {
3275
+ return note.note_relations.find(function (relation) {
3276
+ return relation.is_primary === 1;
3277
+ }) || null;
3278
+ }
3279
+ }, {
3280
+ key: "removeSalesNotesForMissingProductLines",
3281
+ value: function removeSalesNotesForMissingProductLines(tempOrder) {
3282
+ var _this19 = this;
3283
+ var state = this.ensureSalesNotesRuntimeState(tempOrder);
3284
+ if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3285
+ return;
3286
+ }
3287
+ var remainingProductUids = new Set((tempOrder.products || []).map(function (product) {
3288
+ var _product$metadata7;
3289
+ return ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || product.unique_identification_number;
3290
+ }).filter(function (uid) {
3291
+ return typeof uid === 'string' && uid.length > 0;
3292
+ }));
3293
+ var nextNotes = tempOrder.notes.filter(function (note) {
3294
+ var primary = _this19.getSalesNotePrimaryRelation(note);
3295
+ if (!primary || primary.target_type !== 'order_detail') return true;
3296
+ return remainingProductUids.has(primary.target_uuid);
3297
+ });
3298
+ if (nextNotes.length === tempOrder.notes.length) return;
3299
+ tempOrder.notes = nextNotes;
3300
+ state.dirty = true;
3301
+ }
3302
+ }, {
3303
+ key: "setSalesNoteOnTempOrder",
3304
+ value: function setSalesNoteOnTempOrder(tempOrder, input) {
3305
+ var _input$target,
3306
+ _this20 = this,
3307
+ _tempOrder$shop_order;
3308
+ this.ensureSalesNotesLoadedForMutation(tempOrder);
3309
+ var note_type = String(input.note_type || '').trim();
3310
+ var policy = getSalesNotePolicy(note_type);
3311
+ if (!policy) {
3312
+ throw new Error("[Order Notes] \u5F53\u524D\u672A\u6CE8\u518C\u5907\u6CE8\u7C7B\u578B: ".concat(note_type || '(empty)'));
3313
+ }
3314
+ if (((_input$target = input.target) === null || _input$target === void 0 ? void 0 : _input$target.target_type) !== 'order_detail') {
3315
+ throw new Error('[Order Notes] 本期只支持 order_detail 作为主体');
3316
+ }
3317
+ var target_uuid = this.normalizeSalesNoteUuid(input.target.target_uuid, 'target_uuid');
3318
+ var targetProductExists = (tempOrder.products || []).some(function (product) {
3319
+ var _product$metadata8;
3320
+ var productLineUid = ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number) || product.unique_identification_number;
3321
+ return String(productLineUid !== null && productLineUid !== void 0 ? productLineUid : '') === target_uuid;
3322
+ });
3323
+ if (!targetProductExists) {
3324
+ throw new Error('[Order Notes] 目标商品行不存在');
3325
+ }
3326
+ var text = buildSalesNoteText(input.text);
3327
+ var notes = tempOrder.notes || [];
3328
+ // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3329
+ var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3330
+ var primary = _this20.getSalesNotePrimaryRelation(note);
3331
+ return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3332
+ }) : -1;
3333
+ var existing = existingIndex >= 0 ? notes[existingIndex] : null;
3334
+ var existingPrimary = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
3335
+ return relation.is_primary === 1 && relation.target_type === 'order_detail';
3336
+ });
3337
+ var existingOrderRelation = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
3338
+ return relation.is_primary === 0 && relation.target_type === 'order';
3339
+ });
3340
+ var note = {
3341
+ uuid: (existing === null || existing === void 0 ? void 0 : existing.uuid) || createUuidV4(),
3342
+ note_type: policy.note_type,
3343
+ content: {
3344
+ text: text
3345
+ },
3346
+ importance: policy.importance,
3347
+ note_relations: [{
3348
+ uuid: (existingPrimary === null || existingPrimary === void 0 ? void 0 : existingPrimary.uuid) || createUuidV4(),
3349
+ relation_type: policy.primary_relation_type,
3350
+ target_type: 'order_detail',
3351
+ target_uuid: target_uuid,
3352
+ is_primary: 1
3353
+ }, {
3354
+ uuid: (existingOrderRelation === null || existingOrderRelation === void 0 ? void 0 : existingOrderRelation.uuid) || createUuidV4(),
3355
+ relation_type: policy.secondary_order_relation_type,
3356
+ target_type: 'order',
3357
+ target_uuid: String((_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : ''),
3358
+ is_primary: 0
3359
+ }]
3360
+ };
3361
+ var duplicateIndex = notes.findIndex(function (item, index) {
3362
+ return item.uuid === note.uuid && index !== existingIndex;
3363
+ });
3364
+ if (duplicateIndex >= 0) {
3365
+ throw new Error('[Order Notes] uuid 已被其他 Note 使用');
3366
+ }
3367
+ tempOrder.notes = existingIndex >= 0 ? notes.map(function (item, index) {
3368
+ return index === existingIndex ? note : item;
3369
+ }) : [].concat(_toConsumableArray(notes), [note]);
3370
+ var state = this.ensureSalesNotesRuntimeState(tempOrder);
3371
+ state.loaded = true;
3372
+ state.dirty = true;
3373
+ return note;
3374
+ }
3375
+ }, {
3376
+ key: "getSalesNotes",
3377
+ value: function getSalesNotes() {
3378
+ var tempOrder = this.ensureTempOrder();
3379
+ this.ensureSalesNotesRuntimeState(tempOrder);
3380
+ return cloneDeep(tempOrder.notes || []);
3381
+ }
3382
+ }, {
3383
+ key: "createSalesNotesMutationSnapshot",
3384
+ value: function createSalesNotesMutationSnapshot() {
3385
+ var _tempOrder$order_id2;
3386
+ var tempOrder = this.ensureTempOrder();
3387
+ var state = this.ensureSalesNotesRuntimeState(tempOrder);
3388
+ return {
3389
+ orderIdentity: {
3390
+ orderId: (_tempOrder$order_id2 = tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : null,
3391
+ externalSaleNumber: String(tempOrder.external_sale_number || '')
3392
+ },
3393
+ notes: cloneDeep(tempOrder.notes || []),
3394
+ state: cloneDeep(state)
3395
+ };
3396
+ }
3397
+ }, {
3398
+ key: "restoreSalesNotesMutationSnapshot",
3399
+ value: function restoreSalesNotesMutationSnapshot(snapshot) {
3400
+ var _snapshot$state, _snapshot$state2;
3401
+ if (!snapshot || !Array.isArray(snapshot.notes) || !snapshot.orderIdentity || typeof snapshot.orderIdentity.externalSaleNumber !== 'string' || typeof ((_snapshot$state = snapshot.state) === null || _snapshot$state === void 0 ? void 0 : _snapshot$state.loaded) !== 'boolean' || typeof ((_snapshot$state2 = snapshot.state) === null || _snapshot$state2 === void 0 ? void 0 : _snapshot$state2.dirty) !== 'boolean') {
3402
+ throw new Error('[Order Notes] 无效的 mutation snapshot');
3403
+ }
3404
+ var tempOrder = this.store.tempOrder;
3405
+ if (!tempOrder) throw new Error('[Order Notes] 当前订单不存在');
3406
+ var snapshotOrderId = snapshot.orderIdentity.orderId;
3407
+ var currentOrderId = tempOrder.order_id;
3408
+ var hasSnapshotOrderId = snapshotOrderId !== null && snapshotOrderId !== undefined && String(snapshotOrderId).trim().length > 0;
3409
+ var hasCurrentOrderId = currentOrderId !== null && currentOrderId !== undefined && String(currentOrderId).trim().length > 0;
3410
+ var isSameOrder = hasSnapshotOrderId && hasCurrentOrderId ? String(snapshotOrderId) === String(currentOrderId) : Boolean(snapshot.orderIdentity.externalSaleNumber) && snapshot.orderIdentity.externalSaleNumber === String(tempOrder.external_sale_number || '');
3411
+ if (!isSameOrder) {
3412
+ throw new Error('[Order Notes] 当前订单已切换,拒绝恢复旧订单快照');
3413
+ }
3414
+ this.ensureSalesNotesRuntimeState(tempOrder);
3415
+ tempOrder.notes = cloneDeep(snapshot.notes);
3416
+ tempOrder._extend.salesNotesState = cloneDeep(snapshot.state);
3417
+ this.notifyTempOrderChanged();
3418
+ }
3419
+ }, {
3420
+ key: "setSalesNote",
3421
+ value: function () {
3422
+ var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(input) {
3423
+ var tempOrder, note;
3424
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3425
+ while (1) switch (_context17.prev = _context17.next) {
3426
+ case 0:
3427
+ tempOrder = this.ensureTempOrder();
3428
+ note = this.setSalesNoteOnTempOrder(tempOrder, input);
3429
+ this.notifyTempOrderChanged();
3430
+ return _context17.abrupt("return", cloneDeep(note));
3431
+ case 4:
3432
+ case "end":
3433
+ return _context17.stop();
3434
+ }
3435
+ }, _callee15, this);
3436
+ }));
3437
+ function setSalesNote(_x14) {
3438
+ return _setSalesNote.apply(this, arguments);
3439
+ }
3440
+ return setSalesNote;
3441
+ }()
3442
+ }, {
3443
+ key: "removeSalesNote",
3444
+ value: function () {
3445
+ var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(uuid) {
3446
+ var tempOrder, normalizedUuid, notes, nextNotes, state;
3447
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3448
+ while (1) switch (_context18.prev = _context18.next) {
3449
+ case 0:
3450
+ tempOrder = this.ensureTempOrder();
3451
+ this.ensureSalesNotesLoadedForMutation(tempOrder);
3452
+ normalizedUuid = this.normalizeSalesNoteUuid(uuid, 'uuid');
3453
+ notes = tempOrder.notes || [];
3454
+ nextNotes = notes.filter(function (note) {
3455
+ return note.uuid !== normalizedUuid;
3456
+ });
3457
+ if (!(nextNotes.length === notes.length)) {
3458
+ _context18.next = 7;
3459
+ break;
3460
+ }
3461
+ return _context18.abrupt("return");
3462
+ case 7:
3463
+ tempOrder.notes = nextNotes;
3464
+ state = this.ensureSalesNotesRuntimeState(tempOrder);
3465
+ state.dirty = true;
3466
+ this.notifyTempOrderChanged();
3467
+ case 11:
3468
+ case "end":
3469
+ return _context18.stop();
3470
+ }
3471
+ }, _callee16, this);
3472
+ }));
3473
+ function removeSalesNote(_x15) {
3474
+ return _removeSalesNote.apply(this, arguments);
3475
+ }
3476
+ return removeSalesNote;
3477
+ }()
3478
+ }, {
3479
+ key: "clearSalesNotes",
3480
+ value: function () {
3481
+ var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
3482
+ var tempOrder, state;
3483
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3484
+ while (1) switch (_context19.prev = _context19.next) {
3485
+ case 0:
3486
+ tempOrder = this.ensureTempOrder();
3487
+ tempOrder.notes = [];
3488
+ state = this.ensureSalesNotesRuntimeState(tempOrder);
3489
+ state.loaded = true;
3490
+ state.dirty = true;
3491
+ this.notifyTempOrderChanged();
3492
+ case 6:
3493
+ case "end":
3494
+ return _context19.stop();
3495
+ }
3496
+ }, _callee17, this);
3497
+ }));
3498
+ function clearSalesNotes() {
3499
+ return _clearSalesNotes.apply(this, arguments);
3500
+ }
3501
+ return clearSalesNotes;
3502
+ }()
3211
3503
  }, {
3212
3504
  key: "updateTempOrderShopDiscount",
3213
3505
  value: function updateTempOrderShopDiscount(amount) {
@@ -3249,6 +3541,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3249
3541
  this.persistTempOrder();
3250
3542
  return tempOrder.buzzer;
3251
3543
  }
3544
+ }, {
3545
+ key: "updateTempOrderShopServiceData",
3546
+ value: function updateTempOrderShopServiceData(patch) {
3547
+ var tempOrder = this.ensureTempOrder();
3548
+ var metadata = tempOrder.metadata && _typeof(tempOrder.metadata) === 'object' && !Array.isArray(tempOrder.metadata) ? tempOrder.metadata : {};
3549
+ var currentShopServiceData = metadata.shop_service_data && _typeof(metadata.shop_service_data) === 'object' && !Array.isArray(metadata.shop_service_data) ? metadata.shop_service_data : {};
3550
+ var shopServiceData = _objectSpread(_objectSpread({}, currentShopServiceData), patch);
3551
+ tempOrder.metadata = _objectSpread(_objectSpread({}, metadata), {}, {
3552
+ shop_service_data: shopServiceData
3553
+ });
3554
+ this.persistTempOrder();
3555
+ return shopServiceData;
3556
+ }
3557
+ }, {
3558
+ key: "updateTempOrderPickupReferenceMode",
3559
+ value: function updateTempOrderPickupReferenceMode(mode) {
3560
+ return this.updateTempOrderShopServiceData({
3561
+ pickup_reference_mode: mode
3562
+ });
3563
+ }
3564
+ }, {
3565
+ key: "updateTempOrderServiceType",
3566
+ value: function updateTempOrderServiceType(serviceType) {
3567
+ return this.updateTempOrderShopServiceData({
3568
+ service_type: serviceType
3569
+ });
3570
+ }
3252
3571
  }, {
3253
3572
  key: "updateTempOrderContactsInfo",
3254
3573
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -3290,15 +3609,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3290
3609
  }, {
3291
3610
  key: "productHasCustomerBoundDiscount",
3292
3611
  value: function productHasCustomerBoundDiscount(product) {
3293
- var _this19 = this;
3612
+ var _this21 = this;
3294
3613
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3295
- return _this19.isCustomerBoundDiscount(discount);
3614
+ return _this21.isCustomerBoundDiscount(discount);
3296
3615
  })) {
3297
3616
  return true;
3298
3617
  }
3299
3618
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3300
3619
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3301
- return _this19.isCustomerBoundDiscount(discount);
3620
+ return _this21.isCustomerBoundDiscount(discount);
3302
3621
  });
3303
3622
  });
3304
3623
  }
@@ -3307,18 +3626,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3307
3626
  value: function shouldSkipDiscountCalculation(tempOrder) {
3308
3627
  var _this$store$discount18,
3309
3628
  _this$store$discount19,
3310
- _this20 = this;
3629
+ _this22 = this;
3311
3630
  if (this.hasActiveCustomerBoundDiscount) return false;
3312
3631
  var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
3313
3632
  if (discountList.length > 0) return false;
3314
3633
  return !(tempOrder.products || []).some(function (product) {
3315
- return _this20.productHasCustomerBoundDiscount(product);
3634
+ return _this22.productHasCustomerBoundDiscount(product);
3316
3635
  });
3317
3636
  }
3318
3637
  }, {
3319
3638
  key: "clearCustomerBoundDiscounts",
3320
3639
  value: function clearCustomerBoundDiscounts(tempOrder) {
3321
- var _this21 = this,
3640
+ var _this23 = this,
3322
3641
  _discountModule$getDi,
3323
3642
  _discountModule$getOr,
3324
3643
  _discountModule$setDi,
@@ -3327,7 +3646,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3327
3646
  var filterDiscountList = function filterDiscountList(discountList) {
3328
3647
  if (!Array.isArray(discountList)) return [];
3329
3648
  return discountList.filter(function (discount) {
3330
- var shouldRemove = _this21.isCustomerBoundDiscount(discount);
3649
+ var shouldRemove = _this23.isCustomerBoundDiscount(discount);
3331
3650
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3332
3651
  return !shouldRemove;
3333
3652
  });
@@ -3354,12 +3673,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3354
3673
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3355
3674
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3356
3675
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3357
- if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3358
- return !_this21.isCustomerBoundDiscount(discount);
3676
+ if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3677
+ return !_this23.isCustomerBoundDiscount(discount);
3359
3678
  });
3360
3679
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3361
- if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3362
- return !_this21.isCustomerBoundDiscount(discount);
3680
+ if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3681
+ return !_this23.isCustomerBoundDiscount(discount);
3363
3682
  });
3364
3683
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3365
3684
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3520,10 +3839,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3520
3839
  }, {
3521
3840
  key: "setOrderPayments",
3522
3841
  value: function setOrderPayments(payments) {
3523
- var _this22 = this;
3842
+ var _this24 = this;
3524
3843
  var tempOrder = this.ensureTempOrder();
3525
3844
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
3526
- return _this22.normalizePaymentSource(payment, {
3845
+ return _this24.normalizePaymentSource(payment, {
3527
3846
  defaultPaid: false
3528
3847
  });
3529
3848
  }));
@@ -3543,34 +3862,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3543
3862
  }, {
3544
3863
  key: "addOrderPaymentAsync",
3545
3864
  value: (function () {
3546
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
3865
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(payment) {
3547
3866
  var hasPaymentNumber, devicePrefix;
3548
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3549
- while (1) switch (_context17.prev = _context17.next) {
3867
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3868
+ while (1) switch (_context20.prev = _context20.next) {
3550
3869
  case 0:
3551
3870
  hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3552
3871
  if (!hasPaymentNumber) {
3553
- _context17.next = 5;
3872
+ _context20.next = 5;
3554
3873
  break;
3555
3874
  }
3556
- _context17.t0 = 'LOCAL';
3557
- _context17.next = 8;
3875
+ _context20.t0 = 'LOCAL';
3876
+ _context20.next = 8;
3558
3877
  break;
3559
3878
  case 5:
3560
- _context17.next = 7;
3879
+ _context20.next = 7;
3561
3880
  return this.getPaymentNumberDevicePrefixAsync();
3562
3881
  case 7:
3563
- _context17.t0 = _context17.sent;
3882
+ _context20.t0 = _context20.sent;
3564
3883
  case 8:
3565
- devicePrefix = _context17.t0;
3566
- return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3884
+ devicePrefix = _context20.t0;
3885
+ return _context20.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3567
3886
  case 10:
3568
3887
  case "end":
3569
- return _context17.stop();
3888
+ return _context20.stop();
3570
3889
  }
3571
- }, _callee15, this);
3890
+ }, _callee18, this);
3572
3891
  }));
3573
- function addOrderPaymentAsync(_x14) {
3892
+ function addOrderPaymentAsync(_x16) {
3574
3893
  return _addOrderPaymentAsync.apply(this, arguments);
3575
3894
  }
3576
3895
  return addOrderPaymentAsync;
@@ -3578,7 +3897,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3578
3897
  }, {
3579
3898
  key: "addOrderPaymentWithDevicePrefix",
3580
3899
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3581
- var _this23 = this;
3900
+ var _this25 = this;
3582
3901
  this.logInfo('addOrderPayment', {
3583
3902
  payment: payment
3584
3903
  });
@@ -3596,7 +3915,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3596
3915
  void this.recalculateSummary({
3597
3916
  createIfMissing: true
3598
3917
  }).catch(function (error) {
3599
- _this23.logError('recalculate summary after addOrderPayment failed', {
3918
+ _this25.logError('recalculate summary after addOrderPayment failed', {
3600
3919
  error: error instanceof Error ? error.message : String(error)
3601
3920
  });
3602
3921
  });
@@ -3610,7 +3929,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3610
3929
  }, {
3611
3930
  key: "updateOrderPayment",
3612
3931
  value: (function () {
3613
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
3932
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(paymentIdentity, updates) {
3614
3933
  var options,
3615
3934
  tempOrder,
3616
3935
  identity,
@@ -3619,17 +3938,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3619
3938
  updatedPayment,
3620
3939
  summary,
3621
3940
  payments,
3622
- _args18 = arguments;
3623
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3624
- while (1) switch (_context18.prev = _context18.next) {
3941
+ _args21 = arguments;
3942
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3943
+ while (1) switch (_context21.prev = _context21.next) {
3625
3944
  case 0:
3626
- options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
3945
+ options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
3627
3946
  tempOrder = this.ensureTempOrder();
3628
3947
  identity = String(paymentIdentity);
3629
3948
  matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3630
3949
  matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
3631
3950
  if (matchedPayment) {
3632
- _context18.next = 7;
3951
+ _context21.next = 7;
3633
3952
  break;
3634
3953
  }
3635
3954
  throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
@@ -3644,15 +3963,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3644
3963
  return nextPayment;
3645
3964
  });
3646
3965
  this.persistTempOrder();
3647
- _context18.next = 12;
3966
+ _context21.next = 12;
3648
3967
  return this.recalculateSummary({
3649
3968
  createIfMissing: true
3650
3969
  });
3651
3970
  case 12:
3652
- summary = _context18.sent;
3971
+ summary = _context21.sent;
3653
3972
  this.persistTempOrder();
3654
3973
  payments = tempOrder.payments;
3655
- return _context18.abrupt("return", {
3974
+ return _context21.abrupt("return", {
3656
3975
  updated: true,
3657
3976
  payment: payments[matchedPayment.index] || updatedPayment,
3658
3977
  payments: payments,
@@ -3660,11 +3979,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3660
3979
  });
3661
3980
  case 16:
3662
3981
  case "end":
3663
- return _context18.stop();
3982
+ return _context21.stop();
3664
3983
  }
3665
- }, _callee16, this);
3984
+ }, _callee19, this);
3666
3985
  }));
3667
- function updateOrderPayment(_x15, _x16) {
3986
+ function updateOrderPayment(_x17, _x18) {
3668
3987
  return _updateOrderPayment.apply(this, arguments);
3669
3988
  }
3670
3989
  return updateOrderPayment;
@@ -3709,7 +4028,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3709
4028
  }, {
3710
4029
  key: "applyPaymentLifecycleChange",
3711
4030
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3712
- var _this24 = this;
4031
+ var _this26 = this;
3713
4032
  this.updateTempOrderPaymentStatus(tempOrder);
3714
4033
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3715
4034
  this.persistTempOrder();
@@ -3719,7 +4038,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3719
4038
  void this.recalculateSummary({
3720
4039
  createIfMissing: true
3721
4040
  }).catch(function (error) {
3722
- _this24.logError("recalculate summary after ".concat(logContext, " failed"), {
4041
+ _this26.logError("recalculate summary after ".concat(logContext, " failed"), {
3723
4042
  error: error instanceof Error ? error.message : String(error)
3724
4043
  });
3725
4044
  });
@@ -3763,7 +4082,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3763
4082
  }, {
3764
4083
  key: "updateVoucherOrderPayments",
3765
4084
  value: function updateVoucherOrderPayments(payments, options) {
3766
- var _this25 = this;
4085
+ var _this27 = this;
3767
4086
  var tempOrder = this.ensureTempOrder();
3768
4087
  var isOrderPaymentType = function isOrderPaymentType(value) {
3769
4088
  return value === 'normal' || value === 'deposit';
@@ -3798,7 +4117,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3798
4117
  });
3799
4118
  };
3800
4119
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3801
- return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4120
+ return _this27.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3802
4121
  defaultPaid: false,
3803
4122
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
3804
4123
  });
@@ -3851,7 +4170,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3851
4170
  void this.recalculateSummary({
3852
4171
  createIfMissing: true
3853
4172
  }).catch(function (error) {
3854
- _this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
4173
+ _this27.logError('recalculate summary after updateVoucherOrderPayments failed', {
3855
4174
  error: error instanceof Error ? error.message : String(error)
3856
4175
  });
3857
4176
  });
@@ -3860,38 +4179,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3860
4179
  }, {
3861
4180
  key: "updateVoucherOrderPaymentsAsync",
3862
4181
  value: function () {
3863
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
4182
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(payments, options) {
3864
4183
  var needsPaymentNumber, devicePrefix;
3865
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3866
- while (1) switch (_context19.prev = _context19.next) {
4184
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4185
+ while (1) switch (_context22.prev = _context22.next) {
3867
4186
  case 0:
3868
4187
  needsPaymentNumber = (payments || []).some(function (payment) {
3869
4188
  return String(payment.payment_number || '').trim() === '';
3870
4189
  });
3871
4190
  if (!needsPaymentNumber) {
3872
- _context19.next = 7;
4191
+ _context22.next = 7;
3873
4192
  break;
3874
4193
  }
3875
- _context19.next = 4;
4194
+ _context22.next = 4;
3876
4195
  return this.getPaymentNumberDevicePrefixAsync();
3877
4196
  case 4:
3878
- _context19.t0 = _context19.sent;
3879
- _context19.next = 8;
4197
+ _context22.t0 = _context22.sent;
4198
+ _context22.next = 8;
3880
4199
  break;
3881
4200
  case 7:
3882
- _context19.t0 = 'LOCAL';
4201
+ _context22.t0 = 'LOCAL';
3883
4202
  case 8:
3884
- devicePrefix = _context19.t0;
3885
- return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
4203
+ devicePrefix = _context22.t0;
4204
+ return _context22.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
3886
4205
  devicePrefix: devicePrefix
3887
4206
  })));
3888
4207
  case 10:
3889
4208
  case "end":
3890
- return _context19.stop();
4209
+ return _context22.stop();
3891
4210
  }
3892
- }, _callee17, this);
4211
+ }, _callee20, this);
3893
4212
  }));
3894
- function updateVoucherOrderPaymentsAsync(_x17, _x18) {
4213
+ function updateVoucherOrderPaymentsAsync(_x19, _x20) {
3895
4214
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3896
4215
  }
3897
4216
  return updateVoucherOrderPaymentsAsync;
@@ -3909,7 +4228,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3909
4228
  key: "shouldMergeProductToOrder",
3910
4229
  value: function shouldMergeProductToOrder(params) {
3911
4230
  var _this$orderHooks,
3912
- _this26 = this;
4231
+ _this28 = this;
3913
4232
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3914
4233
  if (!onBeforeMergeProductToOrder) return true;
3915
4234
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -3917,7 +4236,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3917
4236
  }));
3918
4237
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
3919
4238
  return Promise.resolve(result).then(function (resolved) {
3920
- return _this26.normalizeShouldMergeProductResult(resolved);
4239
+ return _this28.normalizeShouldMergeProductResult(resolved);
3921
4240
  });
3922
4241
  }
3923
4242
  return this.normalizeShouldMergeProductResult(result);
@@ -3937,8 +4256,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3937
4256
  }, {
3938
4257
  key: "hasLinkedBookingUid",
3939
4258
  value: function hasLinkedBookingUid(product) {
3940
- var _product$booking_uid, _product$metadata7;
3941
- var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid;
4259
+ var _product$booking_uid, _product$metadata9;
4260
+ var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
3942
4261
  return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
3943
4262
  }
3944
4263
 
@@ -3953,30 +4272,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3953
4272
  }, {
3954
4273
  key: "finalizeProductOrderMutation",
3955
4274
  value: function () {
3956
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(tempOrder, options) {
3957
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3958
- while (1) switch (_context20.prev = _context20.next) {
4275
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(tempOrder, options) {
4276
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4277
+ while (1) switch (_context23.prev = _context23.next) {
3959
4278
  case 0:
3960
4279
  this.syncTempOrderHolderFromBookings(tempOrder);
3961
4280
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3962
- _context20.next = 4;
4281
+ _context23.next = 4;
3963
4282
  break;
3964
4283
  }
3965
- _context20.next = 4;
4284
+ _context23.next = 4;
3966
4285
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3967
4286
  case 4:
3968
4287
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3969
- _context20.next = 7;
4288
+ _context23.next = 7;
3970
4289
  break;
3971
4290
  }
3972
- _context20.next = 7;
4291
+ _context23.next = 7;
3973
4292
  return this.applyPromotion();
3974
4293
  case 7:
3975
4294
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3976
4295
  this.applyDiscount();
3977
4296
  }
3978
4297
  this.sanitizeTempOrderProducts(tempOrder);
3979
- _context20.next = 11;
4298
+ _context23.next = 11;
3980
4299
  return this.recalculateSummary({
3981
4300
  createIfMissing: true
3982
4301
  });
@@ -3984,11 +4303,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3984
4303
  this.persistTempOrder();
3985
4304
  case 12:
3986
4305
  case "end":
3987
- return _context20.stop();
4306
+ return _context23.stop();
3988
4307
  }
3989
- }, _callee18, this);
4308
+ }, _callee21, this);
3990
4309
  }));
3991
- function finalizeProductOrderMutation(_x19, _x20) {
4310
+ function finalizeProductOrderMutation(_x21, _x22) {
3992
4311
  return _finalizeProductOrderMutation.apply(this, arguments);
3993
4312
  }
3994
4313
  return finalizeProductOrderMutation;
@@ -4014,7 +4333,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4014
4333
  _metadata,
4015
4334
  _productToAdd$metadat,
4016
4335
  _origin,
4017
- _this27 = this;
4336
+ _this29 = this;
4018
4337
  var linked = booking ? this.createLinkedProductAndBooking({
4019
4338
  product: product,
4020
4339
  booking: booking
@@ -4047,8 +4366,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4047
4366
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4048
4367
  var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4049
4368
  var _item$metadata3;
4050
- if (_this27.hasGoodPassDiscount(item)) return false;
4051
- if (_this27.hasOrderProductLineNote(item)) return false;
4369
+ if (_this29.hasGoodPassDiscount(item)) return false;
4370
+ if (_this29.hasOrderProductLineNote(item)) return false;
4052
4371
  if (isManualProductDiscountProduct(item)) return false;
4053
4372
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4054
4373
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
@@ -4060,8 +4379,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4060
4379
  var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
4061
4380
  var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
4062
4381
  var commitProductLine = function commitProductLine(shouldMerge) {
4382
+ var committedProduct;
4063
4383
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4064
- _this27.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4384
+ _this29.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4065
4385
  if (linked) {
4066
4386
  normalizedIncoming.booking_uid = linked.bookingUid;
4067
4387
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4074,6 +4394,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4074
4394
  } else {
4075
4395
  tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
4076
4396
  }
4397
+ committedProduct = normalizedIncoming;
4077
4398
  } else {
4078
4399
  var _targetProduct$metada;
4079
4400
  var targetProduct = matchedProduct;
@@ -4101,7 +4422,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4101
4422
  order_detail_id: targetProduct.order_detail_id,
4102
4423
  num: nextNum
4103
4424
  });
4104
- _this27.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4425
+ _this29.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4426
+ committedProduct = tempOrder.products[matchedIndex];
4105
4427
  if (matchedIndex !== tempOrder.products.length - 1) {
4106
4428
  var mergedProduct = tempOrder.products[matchedIndex];
4107
4429
  tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
@@ -4110,10 +4432,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4110
4432
  if (linked) {
4111
4433
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
4112
4434
  }
4435
+ return committedProduct;
4113
4436
  };
4114
4437
  if (!matchedProduct) {
4115
- commitProductLine(false);
4116
- return;
4438
+ return commitProductLine(false);
4117
4439
  }
4118
4440
  var shouldMerge = this.shouldMergeProductToOrder({
4119
4441
  incomingProduct: productToAdd,
@@ -4128,7 +4450,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4128
4450
  if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
4129
4451
  return Promise.resolve(shouldMerge).then(commitProductLine);
4130
4452
  }
4131
- commitProductLine(shouldMerge);
4453
+ return commitProductLine(shouldMerge);
4132
4454
  }
4133
4455
 
4134
4456
  /**
@@ -4141,12 +4463,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4141
4463
  }, {
4142
4464
  key: "addProductToOrder",
4143
4465
  value: (function () {
4144
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product, booking, options) {
4145
- var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4146
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4147
- while (1) switch (_context21.prev = _context21.next) {
4466
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(product, booking, options) {
4467
+ var _this30 = this;
4468
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, singleBooking, committedProduct, _committedProduct, _committedProduct2;
4469
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4470
+ while (1) switch (_context24.prev = _context24.next) {
4148
4471
  case 0:
4149
4472
  tempOrder = this.ensureTempOrder();
4473
+ salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
4474
+ return {
4475
+ note_type: String(draft.note_type || '').trim(),
4476
+ text: {
4477
+ kind: 'resolved',
4478
+ text: buildSalesNoteText(draft.text)
4479
+ }
4480
+ };
4481
+ });
4482
+ mutationSnapshot = salesNoteDrafts.length > 0 ? {
4483
+ products: cloneDeep(tempOrder.products || []),
4484
+ bookings: cloneDeep(tempOrder.bookings || []),
4485
+ notes: cloneDeep(tempOrder.notes || []),
4486
+ extend: cloneDeep(tempOrder._extend || {})
4487
+ } : null;
4488
+ attachSalesNoteDrafts = function attachSalesNoteDrafts(orderProduct) {
4489
+ var _orderProduct$metadat;
4490
+ if (!salesNoteDrafts.length) return;
4491
+ var productLineUid = ((_orderProduct$metadat = orderProduct.metadata) === null || _orderProduct$metadat === void 0 ? void 0 : _orderProduct$metadat.unique_identification_number) || orderProduct.unique_identification_number;
4492
+ if (!productLineUid) {
4493
+ throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
4494
+ }
4495
+ salesNoteDrafts.forEach(function (draft) {
4496
+ _this30.setSalesNoteOnTempOrder(tempOrder, {
4497
+ note_type: draft.note_type,
4498
+ target: {
4499
+ target_type: 'order_detail',
4500
+ target_uuid: String(productLineUid)
4501
+ },
4502
+ text: draft.text
4503
+ });
4504
+ });
4505
+ };
4506
+ rollbackProductAndNotesMutation = function rollbackProductAndNotesMutation() {
4507
+ if (!mutationSnapshot) return;
4508
+ tempOrder.products = mutationSnapshot.products;
4509
+ tempOrder.bookings = mutationSnapshot.bookings;
4510
+ tempOrder.notes = mutationSnapshot.notes;
4511
+ tempOrder._extend = mutationSnapshot.extend;
4512
+ };
4150
4513
  insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
4151
4514
  anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
4152
4515
  var _line$metadata;
@@ -4154,73 +4517,102 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4154
4517
  return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
4155
4518
  }) : -1;
4156
4519
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
4520
+ _context24.prev = 8;
4157
4521
  if (!booking) {
4158
- _context21.next = 24;
4522
+ _context24.next = 36;
4159
4523
  break;
4160
4524
  }
4161
4525
  productRecord = product;
4162
4526
  splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
4163
4527
  if (!(splitCount > 1)) {
4164
- _context21.next = 24;
4528
+ _context24.next = 30;
4165
4529
  break;
4166
4530
  }
4167
4531
  i = 0;
4168
- case 9:
4532
+ case 14:
4169
4533
  if (!(i < splitCount)) {
4170
- _context21.next = 21;
4534
+ _context24.next = 28;
4171
4535
  break;
4172
4536
  }
4173
4537
  singleLine = cloneDeep(productRecord);
4538
+ singleBooking = cloneDeep(booking);
4174
4539
  singleLine.num = 1;
4175
4540
  delete singleLine.product_quantity;
4176
- _appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
4541
+ if (i > 0) {
4542
+ delete singleLine.unique_identification_number;
4543
+ delete singleLine.identity_key;
4544
+ if (singleLine.metadata) {
4545
+ singleLine.metadata = _objectSpread({}, singleLine.metadata);
4546
+ delete singleLine.metadata.unique_identification_number;
4547
+ delete singleLine.metadata.identity_key;
4548
+ }
4549
+ delete singleBooking.booking_uid;
4550
+ if (singleBooking.metadata) {
4551
+ singleBooking.metadata = _objectSpread({}, singleBooking.metadata);
4552
+ delete singleBooking.metadata.unique_identification_number;
4553
+ }
4554
+ }
4555
+ _context24.next = 22;
4556
+ return this.appendProductLineToTempOrder(tempOrder, singleLine, singleBooking, {
4177
4557
  insertAtIndex: insertAtIndex,
4178
4558
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4179
4559
  });
4180
- if (!_appendResult) {
4181
- _context21.next = 17;
4182
- break;
4183
- }
4184
- _context21.next = 17;
4185
- return _appendResult;
4186
- case 17:
4560
+ case 22:
4561
+ committedProduct = _context24.sent;
4562
+ attachSalesNoteDrafts(committedProduct);
4187
4563
  if (insertAtIndex !== undefined) insertAtIndex += 1;
4188
- case 18:
4564
+ case 25:
4189
4565
  i += 1;
4190
- _context21.next = 9;
4566
+ _context24.next = 14;
4191
4567
  break;
4192
- case 21:
4193
- _context21.next = 23;
4194
- return this.finalizeProductOrderMutation(tempOrder);
4195
- case 23:
4196
- return _context21.abrupt("return", tempOrder.products);
4197
- case 24:
4198
- appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
4568
+ case 28:
4569
+ _context24.next = 34;
4570
+ break;
4571
+ case 30:
4572
+ _context24.next = 32;
4573
+ return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
4199
4574
  insertAtIndex: insertAtIndex,
4200
4575
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4201
4576
  });
4202
- if (!appendResult) {
4203
- _context21.next = 28;
4204
- break;
4205
- }
4206
- _context21.next = 28;
4207
- return appendResult;
4208
- case 28:
4209
- _context21.next = 30;
4577
+ case 32:
4578
+ _committedProduct = _context24.sent;
4579
+ attachSalesNoteDrafts(_committedProduct);
4580
+ case 34:
4581
+ _context24.next = 40;
4582
+ break;
4583
+ case 36:
4584
+ _context24.next = 38;
4585
+ return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
4586
+ insertAtIndex: insertAtIndex,
4587
+ disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4588
+ });
4589
+ case 38:
4590
+ _committedProduct2 = _context24.sent;
4591
+ attachSalesNoteDrafts(_committedProduct2);
4592
+ case 40:
4593
+ _context24.next = 46;
4594
+ break;
4595
+ case 42:
4596
+ _context24.prev = 42;
4597
+ _context24.t0 = _context24["catch"](8);
4598
+ rollbackProductAndNotesMutation();
4599
+ throw _context24.t0;
4600
+ case 46:
4601
+ _context24.next = 48;
4210
4602
  return this.finalizeProductOrderMutation(tempOrder);
4211
- case 30:
4603
+ case 48:
4212
4604
  this.logInfo('addProductToOrder success', {
4213
4605
  product_id: product.product_id,
4214
4606
  with_booking: !!booking
4215
4607
  });
4216
- return _context21.abrupt("return", tempOrder.products);
4217
- case 32:
4608
+ return _context24.abrupt("return", tempOrder.products);
4609
+ case 50:
4218
4610
  case "end":
4219
- return _context21.stop();
4611
+ return _context24.stop();
4220
4612
  }
4221
- }, _callee19, this);
4613
+ }, _callee22, this, [[8, 42]]);
4222
4614
  }));
4223
- function addProductToOrder(_x21, _x22, _x23) {
4615
+ function addProductToOrder(_x23, _x24, _x25) {
4224
4616
  return _addProductToOrder.apply(this, arguments);
4225
4617
  }
4226
4618
  return addProductToOrder;
@@ -4238,103 +4630,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4238
4630
  }, {
4239
4631
  key: "addProductsToOrder",
4240
4632
  value: (function () {
4241
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(items, options) {
4242
- var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult2, appendResult;
4243
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4244
- while (1) switch (_context22.prev = _context22.next) {
4633
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(items, options) {
4634
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4635
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4636
+ while (1) switch (_context25.prev = _context25.next) {
4245
4637
  case 0:
4246
4638
  tempOrder = this.ensureTempOrder();
4247
4639
  if (!(!Array.isArray(items) || items.length === 0)) {
4248
- _context22.next = 3;
4640
+ _context25.next = 3;
4249
4641
  break;
4250
4642
  }
4251
- return _context22.abrupt("return", tempOrder.products);
4643
+ return _context25.abrupt("return", tempOrder.products);
4252
4644
  case 3:
4253
4645
  _iterator20 = _createForOfIteratorHelper(items || []);
4254
- _context22.prev = 4;
4646
+ _context25.prev = 4;
4255
4647
  _iterator20.s();
4256
4648
  case 6:
4257
4649
  if ((_step20 = _iterator20.n()).done) {
4258
- _context22.next = 34;
4650
+ _context25.next = 34;
4259
4651
  break;
4260
4652
  }
4261
4653
  item = _step20.value;
4262
4654
  product = item.product, booking = item.booking;
4263
4655
  if (product) {
4264
- _context22.next = 11;
4656
+ _context25.next = 11;
4265
4657
  break;
4266
4658
  }
4267
- return _context22.abrupt("continue", 32);
4659
+ return _context25.abrupt("continue", 32);
4268
4660
  case 11:
4269
4661
  if (!booking) {
4270
- _context22.next = 28;
4662
+ _context25.next = 28;
4271
4663
  break;
4272
4664
  }
4273
4665
  productRecord = product;
4274
4666
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4275
4667
  if (!(splitCount > 1)) {
4276
- _context22.next = 28;
4668
+ _context25.next = 28;
4277
4669
  break;
4278
4670
  }
4279
4671
  i = 0;
4280
4672
  case 16:
4281
4673
  if (!(i < splitCount)) {
4282
- _context22.next = 27;
4674
+ _context25.next = 27;
4283
4675
  break;
4284
4676
  }
4285
4677
  singleLine = cloneDeep(productRecord);
4286
4678
  singleLine.num = 1;
4287
4679
  delete singleLine.product_quantity;
4288
- _appendResult2 = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4289
- if (!_appendResult2) {
4290
- _context22.next = 24;
4680
+ _appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4681
+ if (!_appendResult) {
4682
+ _context25.next = 24;
4291
4683
  break;
4292
4684
  }
4293
- _context22.next = 24;
4294
- return _appendResult2;
4685
+ _context25.next = 24;
4686
+ return _appendResult;
4295
4687
  case 24:
4296
4688
  i += 1;
4297
- _context22.next = 16;
4689
+ _context25.next = 16;
4298
4690
  break;
4299
4691
  case 27:
4300
- return _context22.abrupt("continue", 32);
4692
+ return _context25.abrupt("continue", 32);
4301
4693
  case 28:
4302
4694
  appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
4303
4695
  if (!appendResult) {
4304
- _context22.next = 32;
4696
+ _context25.next = 32;
4305
4697
  break;
4306
4698
  }
4307
- _context22.next = 32;
4699
+ _context25.next = 32;
4308
4700
  return appendResult;
4309
4701
  case 32:
4310
- _context22.next = 6;
4702
+ _context25.next = 6;
4311
4703
  break;
4312
4704
  case 34:
4313
- _context22.next = 39;
4705
+ _context25.next = 39;
4314
4706
  break;
4315
4707
  case 36:
4316
- _context22.prev = 36;
4317
- _context22.t0 = _context22["catch"](4);
4318
- _iterator20.e(_context22.t0);
4708
+ _context25.prev = 36;
4709
+ _context25.t0 = _context25["catch"](4);
4710
+ _iterator20.e(_context25.t0);
4319
4711
  case 39:
4320
- _context22.prev = 39;
4712
+ _context25.prev = 39;
4321
4713
  _iterator20.f();
4322
- return _context22.finish(39);
4714
+ return _context25.finish(39);
4323
4715
  case 42:
4324
- _context22.next = 44;
4716
+ _context25.next = 44;
4325
4717
  return this.finalizeProductOrderMutation(tempOrder, options);
4326
4718
  case 44:
4327
4719
  this.logInfo('addProductsToOrder success', {
4328
4720
  itemsCount: items.length
4329
4721
  });
4330
- return _context22.abrupt("return", tempOrder.products);
4722
+ return _context25.abrupt("return", tempOrder.products);
4331
4723
  case 46:
4332
4724
  case "end":
4333
- return _context22.stop();
4725
+ return _context25.stop();
4334
4726
  }
4335
- }, _callee20, this, [[4, 36, 39, 42]]);
4727
+ }, _callee23, this, [[4, 36, 39, 42]]);
4336
4728
  }));
4337
- function addProductsToOrder(_x24, _x25) {
4729
+ function addProductsToOrder(_x26, _x27) {
4338
4730
  return _addProductsToOrder.apply(this, arguments);
4339
4731
  }
4340
4732
  return addProductsToOrder;
@@ -4368,17 +4760,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4368
4760
  }, {
4369
4761
  key: "preservePersistedBundlePriceFields",
4370
4762
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4371
- var _this28 = this;
4763
+ var _this31 = this;
4372
4764
  if (!Array.isArray(nextBundles)) return nextBundles;
4373
4765
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4374
4766
  var previousByIdentity = new Map();
4375
4767
  previousBundles.forEach(function (bundle) {
4376
- var identity = _this28.getBundleRuntimeIdentity(bundle);
4768
+ var identity = _this31.getBundleRuntimeIdentity(bundle);
4377
4769
  if (identity) previousByIdentity.set(identity, bundle);
4378
4770
  });
4379
4771
  return nextBundles.map(function (bundle, index) {
4380
4772
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4381
- var previous = previousByIdentity.get(_this28.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4773
+ var previous = previousByIdentity.get(_this31.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4382
4774
  if (!previous || _typeof(previous) !== 'object') return bundle;
4383
4775
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4384
4776
  cover: previous.cover
@@ -4579,21 +4971,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4579
4971
  }, {
4580
4972
  key: "updateOrderProduct",
4581
4973
  value: function () {
4582
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4974
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
4583
4975
  var tempOrder, updatedProductUid;
4584
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4585
- while (1) switch (_context23.prev = _context23.next) {
4976
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4977
+ while (1) switch (_context26.prev = _context26.next) {
4586
4978
  case 0:
4587
4979
  tempOrder = this.ensureTempOrder();
4588
4980
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4589
- _context23.next = 4;
4981
+ _context26.next = 4;
4590
4982
  return this.applyPromotion();
4591
4983
  case 4:
4592
4984
  this.applyDiscount({
4593
4985
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4594
4986
  });
4595
4987
  this.sanitizeTempOrderProducts(tempOrder);
4596
- _context23.next = 8;
4988
+ _context26.next = 8;
4597
4989
  return this.recalculateSummary({
4598
4990
  createIfMissing: true
4599
4991
  });
@@ -4602,14 +4994,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4602
4994
  this.logInfo('updateOrderProduct success', {
4603
4995
  params: params
4604
4996
  });
4605
- return _context23.abrupt("return", tempOrder.products);
4997
+ return _context26.abrupt("return", tempOrder.products);
4606
4998
  case 11:
4607
4999
  case "end":
4608
- return _context23.stop();
5000
+ return _context26.stop();
4609
5001
  }
4610
- }, _callee21, this);
5002
+ }, _callee24, this);
4611
5003
  }));
4612
- function updateOrderProduct(_x26) {
5004
+ function updateOrderProduct(_x28) {
4613
5005
  return _updateOrderProduct.apply(this, arguments);
4614
5006
  }
4615
5007
  return updateOrderProduct;
@@ -4617,28 +5009,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4617
5009
  }, {
4618
5010
  key: "updateOrderProducts",
4619
5011
  value: function () {
4620
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paramsList) {
4621
- var _this29 = this;
5012
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paramsList) {
5013
+ var _this32 = this;
4622
5014
  var tempOrder, reapplyBookingDiscountProductUids;
4623
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4624
- while (1) switch (_context24.prev = _context24.next) {
5015
+ return _regeneratorRuntime().wrap(function _callee25$(_context27) {
5016
+ while (1) switch (_context27.prev = _context27.next) {
4625
5017
  case 0:
4626
5018
  tempOrder = this.ensureTempOrder();
4627
5019
  if (paramsList.length) {
4628
- _context24.next = 3;
5020
+ _context27.next = 3;
4629
5021
  break;
4630
5022
  }
4631
- return _context24.abrupt("return", tempOrder.products);
5023
+ return _context27.abrupt("return", tempOrder.products);
4632
5024
  case 3:
4633
5025
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4634
- var updatedProductUid = _this29.applyOrderProductUpdateToTempOrder(tempOrder, params);
5026
+ var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params);
4635
5027
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4636
5028
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4637
5029
  acc.push(String(updatedProductUid));
4638
5030
  }
4639
5031
  return acc;
4640
5032
  }, []);
4641
- _context24.next = 6;
5033
+ _context27.next = 6;
4642
5034
  return this.finalizeAfterProductsMutation(tempOrder, {
4643
5035
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4644
5036
  });
@@ -4646,14 +5038,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4646
5038
  this.logInfo('updateOrderProduct success', {
4647
5039
  paramsList: paramsList
4648
5040
  });
4649
- return _context24.abrupt("return", tempOrder.products);
5041
+ return _context27.abrupt("return", tempOrder.products);
4650
5042
  case 8:
4651
5043
  case "end":
4652
- return _context24.stop();
5044
+ return _context27.stop();
4653
5045
  }
4654
- }, _callee22, this);
5046
+ }, _callee25, this);
4655
5047
  }));
4656
- function updateOrderProducts(_x27) {
5048
+ function updateOrderProducts(_x29) {
4657
5049
  return _updateOrderProducts.apply(this, arguments);
4658
5050
  }
4659
5051
  return updateOrderProducts;
@@ -4661,11 +5053,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4661
5053
  }, {
4662
5054
  key: "updateOrderProductQuantity",
4663
5055
  value: function () {
4664
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
5056
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4665
5057
  var _targetProduct$metada17;
4666
5058
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4667
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4668
- while (1) switch (_context25.prev = _context25.next) {
5059
+ return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5060
+ while (1) switch (_context28.prev = _context28.next) {
4669
5061
  case 0:
4670
5062
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4671
5063
  tempOrder = this.ensureTempOrder();
@@ -4695,7 +5087,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4695
5087
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4696
5088
  }
4697
5089
  if (!(productIndex === -1)) {
4698
- _context25.next = 13;
5090
+ _context28.next = 13;
4699
5091
  break;
4700
5092
  }
4701
5093
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4709,12 +5101,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4709
5101
  }));
4710
5102
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4711
5103
  tempOrder.products[productIndex] = normalizedProduct;
4712
- _context25.next = 19;
5104
+ _context28.next = 19;
4713
5105
  return this.applyPromotion();
4714
5106
  case 19:
4715
5107
  this.applyDiscount();
4716
5108
  this.sanitizeTempOrderProducts(tempOrder);
4717
- _context25.next = 23;
5109
+ _context28.next = 23;
4718
5110
  return this.recalculateSummary({
4719
5111
  createIfMissing: true
4720
5112
  });
@@ -4723,14 +5115,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4723
5115
  this.logInfo('updateOrderProductQuantity success', {
4724
5116
  params: params
4725
5117
  });
4726
- return _context25.abrupt("return", tempOrder.products);
5118
+ return _context28.abrupt("return", tempOrder.products);
4727
5119
  case 26:
4728
5120
  case "end":
4729
- return _context25.stop();
5121
+ return _context28.stop();
4730
5122
  }
4731
- }, _callee23, this);
5123
+ }, _callee26, this);
4732
5124
  }));
4733
- function updateOrderProductQuantity(_x28) {
5125
+ function updateOrderProductQuantity(_x30) {
4734
5126
  return _updateOrderProductQuantity.apply(this, arguments);
4735
5127
  }
4736
5128
  return updateOrderProductQuantity;
@@ -4771,19 +5163,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4771
5163
  }, {
4772
5164
  key: "finalizeAfterProductsMutation",
4773
5165
  value: (function () {
4774
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(tempOrder, options) {
4775
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4776
- while (1) switch (_context26.prev = _context26.next) {
5166
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(tempOrder, options) {
5167
+ return _regeneratorRuntime().wrap(function _callee27$(_context29) {
5168
+ while (1) switch (_context29.prev = _context29.next) {
4777
5169
  case 0:
4778
5170
  this.syncTempOrderHolderFromBookings(tempOrder);
4779
- _context26.next = 3;
5171
+ _context29.next = 3;
4780
5172
  return this.applyPromotion();
4781
5173
  case 3:
4782
5174
  this.applyDiscount({
4783
5175
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4784
5176
  });
4785
5177
  this.sanitizeTempOrderProducts(tempOrder);
4786
- _context26.next = 7;
5178
+ _context29.next = 7;
4787
5179
  return this.recalculateSummary({
4788
5180
  createIfMissing: true
4789
5181
  });
@@ -4791,11 +5183,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4791
5183
  this.persistTempOrder();
4792
5184
  case 8:
4793
5185
  case "end":
4794
- return _context26.stop();
5186
+ return _context29.stop();
4795
5187
  }
4796
- }, _callee24, this);
5188
+ }, _callee27, this);
4797
5189
  }));
4798
- function finalizeAfterProductsMutation(_x29, _x30) {
5190
+ function finalizeAfterProductsMutation(_x31, _x32) {
4799
5191
  return _finalizeAfterProductsMutation.apply(this, arguments);
4800
5192
  }
4801
5193
  return finalizeAfterProductsMutation;
@@ -4810,20 +5202,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4810
5202
  }, {
4811
5203
  key: "removeProductsFromOrder",
4812
5204
  value: (function () {
4813
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identities, options) {
4814
- var _this30 = this;
5205
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identities, options) {
5206
+ var _this33 = this;
4815
5207
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
4816
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4817
- while (1) switch (_context28.prev = _context28.next) {
5208
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
5209
+ while (1) switch (_context31.prev = _context31.next) {
4818
5210
  case 0:
4819
5211
  tempOrder = this.ensureTempOrder();
4820
- this.repairDuplicateProductLineIdentities(tempOrder);
4821
5212
  if (identities.length) {
4822
- _context28.next = 4;
5213
+ _context31.next = 3;
4823
5214
  break;
4824
5215
  }
4825
- return _context28.abrupt("return", tempOrder.products);
4826
- case 4:
5216
+ return _context31.abrupt("return", tempOrder.products);
5217
+ case 3:
5218
+ // 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
5219
+ this.ensureSalesNotesLoadedForMutation(tempOrder);
5220
+ this.repairDuplicateProductLineIdentities(tempOrder);
4827
5221
  productsBeforeRemove = tempOrder.products || [];
4828
5222
  bookingsBeforeRemove = tempOrder.bookings || [];
4829
5223
  preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
@@ -4852,29 +5246,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4852
5246
  }
4853
5247
  linkedBookingUidsToRemove = new Set();
4854
5248
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4855
- _context28.prev = 15;
5249
+ _context31.prev = 16;
4856
5250
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4857
5251
  var _metadata11, _metadata12, _metadata13, _metadata14;
4858
5252
  var product, productUid, productBookingUid, isAddTimeProduct;
4859
- return _regeneratorRuntime().wrap(function _loop3$(_context27) {
4860
- while (1) switch (_context27.prev = _context27.next) {
5253
+ return _regeneratorRuntime().wrap(function _loop3$(_context30) {
5254
+ while (1) switch (_context30.prev = _context30.next) {
4861
5255
  case 0:
4862
5256
  product = _step21.value;
4863
5257
  productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4864
5258
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
4865
5259
  isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
4866
5260
  if (!isAddTimeProduct) {
4867
- _context27.next = 6;
5261
+ _context30.next = 6;
4868
5262
  break;
4869
5263
  }
4870
- return _context27.abrupt("return", 1);
5264
+ return _context30.abrupt("return", 1);
4871
5265
  case 6:
4872
5266
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4873
5267
  linkedBookingUidsToRemove.add(String(productBookingUid));
4874
5268
  }
4875
5269
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4876
5270
  bookingsBeforeRemove.forEach(function (booking) {
4877
- var bookingUid = _this30.getBookingUniqueIdentificationNumber(booking);
5271
+ var bookingUid = _this33.getBookingUniqueIdentificationNumber(booking);
4878
5272
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4879
5273
  linkedBookingUidsToRemove.add(bookingUid);
4880
5274
  }
@@ -4882,38 +5276,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4882
5276
  }
4883
5277
  case 8:
4884
5278
  case "end":
4885
- return _context27.stop();
5279
+ return _context30.stop();
4886
5280
  }
4887
5281
  }, _loop3);
4888
5282
  });
4889
5283
  _iterator21.s();
4890
- case 18:
5284
+ case 19:
4891
5285
  if ((_step21 = _iterator21.n()).done) {
4892
- _context28.next = 24;
5286
+ _context31.next = 25;
4893
5287
  break;
4894
5288
  }
4895
- return _context28.delegateYield(_loop3(), "t0", 20);
4896
- case 20:
4897
- if (!_context28.t0) {
4898
- _context28.next = 22;
5289
+ return _context31.delegateYield(_loop3(), "t0", 21);
5290
+ case 21:
5291
+ if (!_context31.t0) {
5292
+ _context31.next = 23;
4899
5293
  break;
4900
5294
  }
4901
- return _context28.abrupt("continue", 22);
4902
- case 22:
4903
- _context28.next = 18;
5295
+ return _context31.abrupt("continue", 23);
5296
+ case 23:
5297
+ _context31.next = 19;
4904
5298
  break;
4905
- case 24:
4906
- _context28.next = 29;
5299
+ case 25:
5300
+ _context31.next = 30;
4907
5301
  break;
4908
- case 26:
4909
- _context28.prev = 26;
4910
- _context28.t1 = _context28["catch"](15);
4911
- _iterator21.e(_context28.t1);
4912
- case 29:
4913
- _context28.prev = 29;
5302
+ case 27:
5303
+ _context31.prev = 27;
5304
+ _context31.t1 = _context31["catch"](16);
5305
+ _iterator21.e(_context31.t1);
5306
+ case 30:
5307
+ _context31.prev = 30;
4914
5308
  _iterator21.f();
4915
- return _context28.finish(29);
4916
- case 32:
5309
+ return _context31.finish(30);
5310
+ case 33:
4917
5311
  if (linkedBookingUidsToRemove.size > 0) {
4918
5312
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
4919
5313
  tempOrder.products = (tempOrder.products || []).filter(function (line) {
@@ -4939,20 +5333,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4939
5333
  tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
4940
5334
  }
4941
5335
  }
4942
- _context28.next = 36;
5336
+ this.removeSalesNotesForMissingProductLines(tempOrder);
5337
+ _context31.next = 38;
4943
5338
  return this.finalizeAfterProductsMutation(tempOrder);
4944
- case 36:
5339
+ case 38:
4945
5340
  this.logInfo('removeProductsFromOrder success', {
4946
5341
  identities: identities
4947
5342
  });
4948
- return _context28.abrupt("return", tempOrder.products);
4949
- case 38:
5343
+ return _context31.abrupt("return", tempOrder.products);
5344
+ case 40:
4950
5345
  case "end":
4951
- return _context28.stop();
5346
+ return _context31.stop();
4952
5347
  }
4953
- }, _callee25, this, [[15, 26, 29, 32]]);
5348
+ }, _callee28, this, [[16, 27, 30, 33]]);
4954
5349
  }));
4955
- function removeProductsFromOrder(_x31, _x32) {
5350
+ function removeProductsFromOrder(_x33, _x34) {
4956
5351
  return _removeProductsFromOrder.apply(this, arguments);
4957
5352
  }
4958
5353
  return removeProductsFromOrder;
@@ -4960,61 +5355,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4960
5355
  }, {
4961
5356
  key: "removeProductFromOrder",
4962
5357
  value: function () {
4963
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity, options) {
4964
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4965
- while (1) switch (_context29.prev = _context29.next) {
5358
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identity, options) {
5359
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5360
+ while (1) switch (_context32.prev = _context32.next) {
4966
5361
  case 0:
4967
- return _context29.abrupt("return", this.removeProductsFromOrder([identity], options));
5362
+ return _context32.abrupt("return", this.removeProductsFromOrder([identity], options));
4968
5363
  case 1:
4969
5364
  case "end":
4970
- return _context29.stop();
5365
+ return _context32.stop();
4971
5366
  }
4972
- }, _callee26, this);
5367
+ }, _callee29, this);
4973
5368
  }));
4974
- function removeProductFromOrder(_x33, _x34) {
5369
+ function removeProductFromOrder(_x35, _x36) {
4975
5370
  return _removeProductFromOrder.apply(this, arguments);
4976
5371
  }
4977
5372
  return removeProductFromOrder;
4978
5373
  }()
4979
5374
  /**
4980
5375
  * 仅清空购物车行(products / bookings),不重置整单。
4981
- * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
5376
+ * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
4982
5377
  */
4983
5378
  }, {
4984
5379
  key: "clearOrderCartLines",
4985
5380
  value: (function () {
4986
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
5381
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
4987
5382
  var tempOrder;
4988
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4989
- while (1) switch (_context30.prev = _context30.next) {
5383
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
5384
+ while (1) switch (_context33.prev = _context33.next) {
4990
5385
  case 0:
4991
5386
  tempOrder = this.ensureTempOrder();
5387
+ this.ensureSalesNotesLoadedForMutation(tempOrder);
4992
5388
  tempOrder.products = [];
4993
5389
  tempOrder.bookings = [];
5390
+ this.removeSalesNotesForMissingProductLines(tempOrder);
4994
5391
  this.syncTempOrderHolderFromBookings(tempOrder);
4995
5392
  if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
4996
5393
  tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
4997
5394
  productsByUid: {}
4998
5395
  });
4999
5396
  }
5000
- _context30.next = 7;
5397
+ _context33.next = 9;
5001
5398
  return this.applyPromotion();
5002
- case 7:
5399
+ case 9:
5003
5400
  this.applyDiscount();
5004
5401
  this.sanitizeTempOrderProducts(tempOrder);
5005
- _context30.next = 11;
5402
+ _context33.next = 13;
5006
5403
  return this.recalculateSummary({
5007
5404
  createIfMissing: true
5008
5405
  });
5009
- case 11:
5406
+ case 13:
5010
5407
  this.persistTempOrder();
5011
5408
  this.logInfo('clearOrderCartLines success', {});
5012
- return _context30.abrupt("return", tempOrder);
5013
- case 14:
5409
+ return _context33.abrupt("return", tempOrder);
5410
+ case 16:
5014
5411
  case "end":
5015
- return _context30.stop();
5412
+ return _context33.stop();
5016
5413
  }
5017
- }, _callee27, this);
5414
+ }, _callee30, this);
5018
5415
  }));
5019
5416
  function clearOrderCartLines() {
5020
5417
  return _clearOrderCartLines.apply(this, arguments);
@@ -5037,10 +5434,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5037
5434
  type: params === null || params === void 0 ? void 0 : params.type,
5038
5435
  summary: this.store.summary || createEmptySummary(),
5039
5436
  enhance: function enhance(nextPayload) {
5040
- var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
5437
+ var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order2, _ref72, _tempOrder$shop_full_;
5041
5438
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
5042
5439
  order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
5043
- shop_order_number: (_ref71 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
5440
+ shop_order_number: (_ref71 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
5044
5441
  shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
5045
5442
  small_ticket_data_flag: 1
5046
5443
  });
@@ -5052,17 +5449,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5052
5449
  }, {
5053
5450
  key: "applyLocalPrintOrderNumbers",
5054
5451
  value: function () {
5055
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(order) {
5452
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
5056
5453
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
5057
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
5058
- while (1) switch (_context31.prev = _context31.next) {
5454
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5455
+ while (1) switch (_context34.prev = _context34.next) {
5059
5456
  case 0:
5060
5457
  tempOrder = this.ensureTempOrder();
5061
5458
  if (!(!order || _typeof(order) !== 'object')) {
5062
- _context31.next = 3;
5459
+ _context34.next = 3;
5063
5460
  break;
5064
5461
  }
5065
- return _context31.abrupt("return", tempOrder);
5462
+ return _context34.abrupt("return", tempOrder);
5066
5463
  case 3:
5067
5464
  shopOrderNumber = order.shop_order_number;
5068
5465
  shopFullOrderNumber = order.shop_full_order_number;
@@ -5073,17 +5470,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5073
5470
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
5074
5471
  }
5075
5472
  this.persistTempOrder();
5076
- _context31.next = 10;
5473
+ _context34.next = 10;
5077
5474
  return this.saveDraft();
5078
5475
  case 10:
5079
- return _context31.abrupt("return", tempOrder);
5476
+ return _context34.abrupt("return", tempOrder);
5080
5477
  case 11:
5081
5478
  case "end":
5082
- return _context31.stop();
5479
+ return _context34.stop();
5083
5480
  }
5084
- }, _callee28, this);
5481
+ }, _callee31, this);
5085
5482
  }));
5086
- function applyLocalPrintOrderNumbers(_x35) {
5483
+ function applyLocalPrintOrderNumbers(_x37) {
5087
5484
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
5088
5485
  }
5089
5486
  return applyLocalPrintOrderNumbers;
@@ -5091,35 +5488,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5091
5488
  }, {
5092
5489
  key: "saveTempOrderAsDraft",
5093
5490
  value: function () {
5094
- var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
5491
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5095
5492
  var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
5096
5493
  var tempOrder, latestSummary, payload;
5097
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5098
- while (1) switch (_context32.prev = _context32.next) {
5494
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5495
+ while (1) switch (_context35.prev = _context35.next) {
5099
5496
  case 0:
5100
5497
  tempOrder = this.ensureTempOrder();
5101
5498
  this.ensureExternalSaleNumber(tempOrder);
5102
5499
  this.persistTempOrder();
5103
- _context32.next = 5;
5500
+ _context35.next = 5;
5104
5501
  return this.recalculateSummary({
5105
5502
  createIfMissing: true
5106
5503
  });
5107
5504
  case 5:
5108
- _context32.t1 = _context32.sent;
5109
- if (_context32.t1) {
5110
- _context32.next = 8;
5505
+ _context35.t1 = _context35.sent;
5506
+ if (_context35.t1) {
5507
+ _context35.next = 8;
5111
5508
  break;
5112
5509
  }
5113
- _context32.t1 = this.store.summary;
5510
+ _context35.t1 = this.store.summary;
5114
5511
  case 8:
5115
- _context32.t0 = _context32.t1;
5116
- if (_context32.t0) {
5117
- _context32.next = 11;
5512
+ _context35.t0 = _context35.t1;
5513
+ if (_context35.t0) {
5514
+ _context35.next = 11;
5118
5515
  break;
5119
5516
  }
5120
- _context32.t0 = createEmptySummary();
5517
+ _context35.t0 = createEmptySummary();
5121
5518
  case 11:
5122
- latestSummary = _context32.t0;
5519
+ latestSummary = _context35.t0;
5123
5520
  payload = buildSubmitPayload({
5124
5521
  tempOrder: tempOrder,
5125
5522
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
@@ -5140,17 +5537,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5140
5537
  externalSaleNumber: payload.external_sale_number,
5141
5538
  productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
5142
5539
  });
5143
- return _context32.abrupt("return", this.request.post('/order/sales/draft', payload, {
5540
+ return _context35.abrupt("return", this.request.post('/order/sales/draft', payload, {
5144
5541
  osServer: true,
5145
5542
  customToast: function customToast() {}
5146
5543
  }));
5147
5544
  case 18:
5148
5545
  case "end":
5149
- return _context32.stop();
5546
+ return _context35.stop();
5150
5547
  }
5151
- }, _callee29, this);
5548
+ }, _callee32, this);
5152
5549
  }));
5153
- function saveTempOrderAsDraft(_x36) {
5550
+ function saveTempOrderAsDraft(_x38) {
5154
5551
  return _saveTempOrderAsDraft.apply(this, arguments);
5155
5552
  }
5156
5553
  return saveTempOrderAsDraft;
@@ -5164,18 +5561,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5164
5561
  }, {
5165
5562
  key: "submitTempOrder",
5166
5563
  value: (function () {
5167
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
5168
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
5169
- while (1) switch (_context33.prev = _context33.next) {
5564
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5565
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5566
+ while (1) switch (_context36.prev = _context36.next) {
5170
5567
  case 0:
5171
- return _context33.abrupt("return", this.runSubmitTempOrder(params));
5568
+ return _context36.abrupt("return", this.runSubmitTempOrder(params));
5172
5569
  case 1:
5173
5570
  case "end":
5174
- return _context33.stop();
5571
+ return _context36.stop();
5175
5572
  }
5176
- }, _callee30, this);
5573
+ }, _callee33, this);
5177
5574
  }));
5178
- function submitTempOrder(_x37) {
5575
+ function submitTempOrder(_x39) {
5179
5576
  return _submitTempOrder.apply(this, arguments);
5180
5577
  }
5181
5578
  return submitTempOrder;
@@ -5183,20 +5580,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5183
5580
  }, {
5184
5581
  key: "submitTempOrderAsync",
5185
5582
  value: function () {
5186
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
5187
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5188
- while (1) switch (_context34.prev = _context34.next) {
5583
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5584
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5585
+ while (1) switch (_context37.prev = _context37.next) {
5189
5586
  case 0:
5190
- return _context34.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5587
+ return _context37.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5191
5588
  syncMode: true
5192
5589
  })));
5193
5590
  case 1:
5194
5591
  case "end":
5195
- return _context34.stop();
5592
+ return _context37.stop();
5196
5593
  }
5197
- }, _callee31, this);
5594
+ }, _callee34, this);
5198
5595
  }));
5199
- function submitTempOrderAsync(_x38) {
5596
+ function submitTempOrderAsync(_x40) {
5200
5597
  return _submitTempOrderAsync.apply(this, arguments);
5201
5598
  }
5202
5599
  return submitTempOrderAsync;
@@ -5204,11 +5601,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5204
5601
  }, {
5205
5602
  key: "runSubmitTempOrder",
5206
5603
  value: function () {
5207
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5604
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5208
5605
  var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
5209
- var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
5210
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5211
- while (1) switch (_context35.prev = _context35.next) {
5606
+ var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
5607
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5608
+ while (1) switch (_context38.prev = _context38.next) {
5212
5609
  case 0:
5213
5610
  tempOrder = this.ensureTempOrder();
5214
5611
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -5228,26 +5625,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5228
5625
  }
5229
5626
  }
5230
5627
  this.persistTempOrder();
5231
- _context35.next = 8;
5628
+ _context38.next = 8;
5232
5629
  return this.recalculateSummary({
5233
5630
  createIfMissing: true
5234
5631
  });
5235
5632
  case 8:
5236
- _context35.t1 = _context35.sent;
5237
- if (_context35.t1) {
5238
- _context35.next = 11;
5633
+ _context38.t1 = _context38.sent;
5634
+ if (_context38.t1) {
5635
+ _context38.next = 11;
5239
5636
  break;
5240
5637
  }
5241
- _context35.t1 = this.store.summary;
5638
+ _context38.t1 = this.store.summary;
5242
5639
  case 11:
5243
- _context35.t0 = _context35.t1;
5244
- if (_context35.t0) {
5245
- _context35.next = 14;
5640
+ _context38.t0 = _context38.t1;
5641
+ if (_context38.t0) {
5642
+ _context38.next = 14;
5246
5643
  break;
5247
5644
  }
5248
- _context35.t0 = createEmptySummary();
5645
+ _context38.t0 = createEmptySummary();
5249
5646
  case 14:
5250
- latestSummary = _context35.t0;
5647
+ latestSummary = _context38.t0;
5251
5648
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
5252
5649
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
5253
5650
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -5281,10 +5678,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5281
5678
  if (!payload.created_at) {
5282
5679
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5283
5680
  }
5284
- _context35.next = 25;
5681
+ _context38.next = 25;
5285
5682
  return this.saveDraft();
5286
5683
  case 25:
5287
- _context35.prev = 25;
5684
+ _context38.prev = 25;
5288
5685
  this.logInfo('submitTempOrder calling sales checkout', {
5289
5686
  orderId: payload.order_id,
5290
5687
  externalSaleNumber: payload.external_sale_number,
@@ -5294,44 +5691,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5294
5691
  smallTicketDataFlag: payload.small_ticket_data_flag,
5295
5692
  syncMode: payload.sync_mode
5296
5693
  });
5297
- _context35.next = 29;
5694
+ _context38.next = 29;
5298
5695
  return this.submitSalesOrder({
5299
5696
  query: payload
5300
5697
  });
5301
5698
  case 29:
5302
- result = _context35.sent;
5303
- _context35.next = 42;
5699
+ result = _context38.sent;
5700
+ _context38.next = 42;
5304
5701
  break;
5305
5702
  case 32:
5306
- _context35.prev = 32;
5307
- _context35.t2 = _context35["catch"](25);
5308
- backendErrorResponse = this.extractSubmitErrorResponse(_context35.t2);
5703
+ _context38.prev = 32;
5704
+ _context38.t2 = _context38["catch"](25);
5705
+ backendErrorResponse = this.extractSubmitErrorResponse(_context38.t2);
5309
5706
  if (!backendErrorResponse) {
5310
- _context35.next = 39;
5707
+ _context38.next = 39;
5311
5708
  break;
5312
5709
  }
5313
5710
  this.store.syncState = 'failed';
5314
5711
  this.logSubmitBackendRejected(backendErrorResponse, payload);
5315
- return _context35.abrupt("return", backendErrorResponse);
5712
+ return _context38.abrupt("return", backendErrorResponse);
5316
5713
  case 39:
5317
5714
  this.store.syncState = 'failed';
5318
5715
  this.logError('submitTempOrder failed', {
5319
- error: _context35.t2 instanceof Error ? _context35.t2.message : String(_context35.t2),
5716
+ error: _context38.t2 instanceof Error ? _context38.t2.message : String(_context38.t2),
5320
5717
  orderId: payload.order_id,
5321
5718
  externalSaleNumber: payload.external_sale_number,
5322
5719
  paymentStatus: payload.payment_status,
5323
5720
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
5324
5721
  });
5325
- throw _context35.t2;
5722
+ throw _context38.t2;
5326
5723
  case 42:
5327
5724
  if (!this.isSubmitResponseRejected(result)) {
5328
- _context35.next = 46;
5725
+ _context38.next = 46;
5329
5726
  break;
5330
5727
  }
5331
5728
  this.store.syncState = 'failed';
5332
5729
  this.logSubmitBackendRejected(result, payload);
5333
- return _context35.abrupt("return", result);
5730
+ return _context38.abrupt("return", result);
5334
5731
  case 46:
5732
+ isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
5733
+ if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
5734
+ salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
5735
+ salesNotesState.dirty = false;
5736
+ }
5335
5737
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
5336
5738
  this.logInfo('runSubmitTempOrder: 提交成功', {
5337
5739
  submittedOrderId: submittedOrderId,
@@ -5341,31 +5743,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5341
5743
  })
5342
5744
  });
5343
5745
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
5344
- _context35.next = 55;
5746
+ _context38.next = 55;
5345
5747
  break;
5346
5748
  }
5347
5749
  tempOrder.order_id = submittedOrderId;
5348
5750
  resultRecord = result;
5349
- _context35.next = 53;
5751
+ _context38.next = 55;
5350
5752
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
5351
- case 53:
5352
- _context35.next = 56;
5353
- break;
5354
5753
  case 55:
5355
- if (this.isLocalPendingSubmitResult(result)) {
5754
+ if (isLocalPendingSubmit) {
5356
5755
  this.store.syncState = 'local';
5357
- } else {
5756
+ } else if (submittedOrderId === null || submittedOrderId === undefined) {
5358
5757
  this.store.syncState = 'submitted';
5359
5758
  }
5360
- case 56:
5361
- return _context35.abrupt("return", result);
5759
+ return _context38.abrupt("return", result);
5362
5760
  case 57:
5363
5761
  case "end":
5364
- return _context35.stop();
5762
+ return _context38.stop();
5365
5763
  }
5366
- }, _callee32, this, [[25, 32]]);
5764
+ }, _callee35, this, [[25, 32]]);
5367
5765
  }));
5368
- function runSubmitTempOrder(_x39) {
5766
+ function runSubmitTempOrder(_x41) {
5369
5767
  return _runSubmitTempOrder.apply(this, arguments);
5370
5768
  }
5371
5769
  return runSubmitTempOrder;
@@ -5373,10 +5771,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5373
5771
  }, {
5374
5772
  key: "markLocalOrderSynced",
5375
5773
  value: function () {
5376
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(orderId, remoteOrder) {
5774
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId, remoteOrder) {
5377
5775
  var tempOrder;
5378
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5379
- while (1) switch (_context36.prev = _context36.next) {
5776
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5777
+ while (1) switch (_context39.prev = _context39.next) {
5380
5778
  case 0:
5381
5779
  tempOrder = this.ensureTempOrder();
5382
5780
  tempOrder.order_id = orderId;
@@ -5384,15 +5782,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5384
5782
  this.store.lastOrderInfo = remoteOrder;
5385
5783
  this.store.syncState = 'submitted';
5386
5784
  this.persistTempOrder();
5387
- _context36.next = 8;
5785
+ _context39.next = 8;
5388
5786
  return this.saveDraft();
5389
5787
  case 8:
5390
5788
  case "end":
5391
- return _context36.stop();
5789
+ return _context39.stop();
5392
5790
  }
5393
- }, _callee33, this);
5791
+ }, _callee36, this);
5394
5792
  }));
5395
- function markLocalOrderSynced(_x40, _x41) {
5793
+ function markLocalOrderSynced(_x42, _x43) {
5396
5794
  return _markLocalOrderSynced.apply(this, arguments);
5397
5795
  }
5398
5796
  return markLocalOrderSynced;
@@ -5435,10 +5833,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5435
5833
  value: function extractSubmitErrorResponse(error) {
5436
5834
  var _error$response,
5437
5835
  _error$response2,
5438
- _this31 = this;
5836
+ _this34 = this;
5439
5837
  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];
5440
5838
  return candidates.find(function (candidate) {
5441
- return _this31.isSubmitErrorResponse(candidate);
5839
+ return _this34.isSubmitErrorResponse(candidate);
5442
5840
  }) || null;
5443
5841
  }
5444
5842
  }, {
@@ -5465,33 +5863,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5465
5863
  }, {
5466
5864
  key: "syncPaymentsToOrder",
5467
5865
  value: function () {
5468
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5469
- var _this32 = this,
5866
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5867
+ var _this35 = this,
5470
5868
  _params$confirmPendin;
5471
5869
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
5472
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5473
- while (1) switch (_context37.prev = _context37.next) {
5870
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5871
+ while (1) switch (_context40.prev = _context40.next) {
5474
5872
  case 0:
5475
5873
  tempOrder = this.ensureTempOrder();
5476
5874
  needsPaymentNumber = (params.payments || []).some(function (payment) {
5477
5875
  return String(payment.payment_number || '').trim() === '';
5478
5876
  });
5479
5877
  if (!needsPaymentNumber) {
5480
- _context37.next = 8;
5878
+ _context40.next = 8;
5481
5879
  break;
5482
5880
  }
5483
- _context37.next = 5;
5881
+ _context40.next = 5;
5484
5882
  return this.getPaymentNumberDevicePrefixAsync();
5485
5883
  case 5:
5486
- _context37.t0 = _context37.sent;
5487
- _context37.next = 9;
5884
+ _context40.t0 = _context40.sent;
5885
+ _context40.next = 9;
5488
5886
  break;
5489
5887
  case 8:
5490
- _context37.t0 = 'LOCAL';
5888
+ _context40.t0 = 'LOCAL';
5491
5889
  case 9:
5492
- devicePrefix = _context37.t0;
5890
+ devicePrefix = _context40.t0;
5493
5891
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5494
- return _this32.normalizePaymentSource(payment, {
5892
+ return _this35.normalizePaymentSource(payment, {
5495
5893
  defaultPaid: false,
5496
5894
  devicePrefix: devicePrefix
5497
5895
  });
@@ -5504,20 +5902,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5504
5902
  tempOrder.payments = effectivePayments;
5505
5903
  tempOrder.payment_status = paymentStatus;
5506
5904
  this.persistTempOrder();
5507
- _context37.next = 21;
5905
+ _context40.next = 21;
5508
5906
  return this.saveDraft();
5509
5907
  case 21:
5510
5908
  if (params.submitWhenPaid) {
5511
- _context37.next = 23;
5909
+ _context40.next = 23;
5512
5910
  break;
5513
5911
  }
5514
- return _context37.abrupt("return", completion);
5912
+ return _context40.abrupt("return", completion);
5515
5913
  case 23:
5516
5914
  if (!(this.store.syncState === 'submitting')) {
5517
- _context37.next = 25;
5915
+ _context40.next = 25;
5518
5916
  break;
5519
5917
  }
5520
- return _context37.abrupt("return", completion);
5918
+ return _context40.abrupt("return", completion);
5521
5919
  case 25:
5522
5920
  this.store.syncState = 'submitting';
5523
5921
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
@@ -5537,32 +5935,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5537
5935
  enhancePayload: enhancePayload
5538
5936
  };
5539
5937
  if (!(params.checkoutSyncTaskEnabled === false)) {
5540
- _context37.next = 35;
5938
+ _context40.next = 35;
5541
5939
  break;
5542
5940
  }
5543
- _context37.next = 32;
5941
+ _context40.next = 32;
5544
5942
  return this.submitTempOrderAsync(submitParams);
5545
5943
  case 32:
5546
- _context37.t1 = _context37.sent;
5547
- _context37.next = 38;
5944
+ _context40.t1 = _context40.sent;
5945
+ _context40.next = 38;
5548
5946
  break;
5549
5947
  case 35:
5550
- _context37.next = 37;
5948
+ _context40.next = 37;
5551
5949
  return this.submitTempOrder(submitParams);
5552
5950
  case 37:
5553
- _context37.t1 = _context37.sent;
5951
+ _context40.t1 = _context40.sent;
5554
5952
  case 38:
5555
- submitResult = _context37.t1;
5556
- return _context37.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5953
+ submitResult = _context40.t1;
5954
+ return _context40.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5557
5955
  submitResult: submitResult
5558
5956
  }));
5559
5957
  case 40:
5560
5958
  case "end":
5561
- return _context37.stop();
5959
+ return _context40.stop();
5562
5960
  }
5563
- }, _callee34, this);
5961
+ }, _callee37, this);
5564
5962
  }));
5565
- function syncPaymentsToOrder(_x42) {
5963
+ function syncPaymentsToOrder(_x44) {
5566
5964
  return _syncPaymentsToOrder.apply(this, arguments);
5567
5965
  }
5568
5966
  return syncPaymentsToOrder;
@@ -5570,7 +5968,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5570
5968
  }, {
5571
5969
  key: "createOrder",
5572
5970
  value: function createOrder(params) {
5573
- var _this33 = this;
5971
+ var _this36 = this;
5574
5972
  var order = _objectSpread({
5575
5973
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
5576
5974
  // 要从外面拿,virtual
@@ -5602,7 +6000,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5602
6000
 
5603
6001
  // 为预约补齐 holder 信息
5604
6002
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
5605
- ensureCartItemOriginHolder(item, _this33.window);
6003
+ ensureCartItemOriginHolder(item, _this36.window);
5606
6004
  }
5607
6005
 
5608
6006
  // 购物车是否为普通商品
@@ -5659,11 +6057,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5659
6057
  }, {
5660
6058
  key: "submitOrder",
5661
6059
  value: function () {
5662
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(order) {
6060
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order) {
5663
6061
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5664
6062
  var url, query, fetchUrl, params;
5665
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5666
- while (1) switch (_context38.prev = _context38.next) {
6063
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
6064
+ while (1) switch (_context41.prev = _context41.next) {
5667
6065
  case 0:
5668
6066
  this.logInfo('submitOrder called', {
5669
6067
  url: order.url,
@@ -5683,14 +6081,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5683
6081
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5684
6082
  scheduleDate: params.schedule_date
5685
6083
  });
5686
- return _context38.abrupt("return", this.request.post(fetchUrl, params));
6084
+ return _context41.abrupt("return", this.request.post(fetchUrl, params));
5687
6085
  case 6:
5688
6086
  case "end":
5689
- return _context38.stop();
6087
+ return _context41.stop();
5690
6088
  }
5691
- }, _callee35, this);
6089
+ }, _callee38, this);
5692
6090
  }));
5693
- function submitOrder(_x43) {
6091
+ function submitOrder(_x45) {
5694
6092
  return _submitOrder.apply(this, arguments);
5695
6093
  }
5696
6094
  return submitOrder;
@@ -5698,13 +6096,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5698
6096
  }, {
5699
6097
  key: "cancelOrder",
5700
6098
  value: function () {
5701
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
6099
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5702
6100
  var payload;
5703
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5704
- while (1) switch (_context39.prev = _context39.next) {
6101
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
6102
+ while (1) switch (_context42.prev = _context42.next) {
5705
6103
  case 0:
5706
6104
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5707
- _context39.next = 2;
6105
+ _context42.next = 2;
5708
6106
  break;
5709
6107
  }
5710
6108
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5720,16 +6118,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5720
6118
  method: 'PUT',
5721
6119
  orderIdsCount: params.order_ids.length
5722
6120
  });
5723
- return _context39.abrupt("return", this.request.put('/order/update-status', payload, {
6121
+ return _context42.abrupt("return", this.request.put('/order/update-status', payload, {
5724
6122
  isShopApi: true
5725
6123
  }));
5726
6124
  case 5:
5727
6125
  case "end":
5728
- return _context39.stop();
6126
+ return _context42.stop();
5729
6127
  }
5730
- }, _callee36, this);
6128
+ }, _callee39, this);
5731
6129
  }));
5732
- function cancelOrder(_x44) {
6130
+ function cancelOrder(_x46) {
5733
6131
  return _cancelOrder.apply(this, arguments);
5734
6132
  }
5735
6133
  return cancelOrder;
@@ -5737,19 +6135,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5737
6135
  }, {
5738
6136
  key: "changeBookingStatus",
5739
6137
  value: function () {
5740
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6138
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5741
6139
  var url, payload;
5742
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5743
- while (1) switch (_context40.prev = _context40.next) {
6140
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
6141
+ while (1) switch (_context43.prev = _context43.next) {
5744
6142
  case 0:
5745
6143
  if (params.booking_id) {
5746
- _context40.next = 2;
6144
+ _context43.next = 2;
5747
6145
  break;
5748
6146
  }
5749
6147
  throw new Error('变更预约状态失败:booking_id 不能为空');
5750
6148
  case 2:
5751
6149
  if (params.appointment_status) {
5752
- _context40.next = 4;
6150
+ _context43.next = 4;
5753
6151
  break;
5754
6152
  }
5755
6153
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5764,16 +6162,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5764
6162
  bookingId: params.booking_id,
5765
6163
  appointmentStatus: params.appointment_status
5766
6164
  });
5767
- return _context40.abrupt("return", this.request.put(url, payload, {
6165
+ return _context43.abrupt("return", this.request.put(url, payload, {
5768
6166
  isShopApi: true
5769
6167
  }));
5770
6168
  case 8:
5771
6169
  case "end":
5772
- return _context40.stop();
6170
+ return _context43.stop();
5773
6171
  }
5774
- }, _callee37, this);
6172
+ }, _callee40, this);
5775
6173
  }));
5776
- function changeBookingStatus(_x45) {
6174
+ function changeBookingStatus(_x47) {
5777
6175
  return _changeBookingStatus.apply(this, arguments);
5778
6176
  }
5779
6177
  return changeBookingStatus;
@@ -5791,11 +6189,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5791
6189
  }, {
5792
6190
  key: "createOrderByCheckout",
5793
6191
  value: (function () {
5794
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
6192
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5795
6193
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
5796
6194
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
5797
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5798
- while (1) switch (_context41.prev = _context41.next) {
6195
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6196
+ while (1) switch (_context44.prev = _context44.next) {
5799
6197
  case 0:
5800
6198
  // 过滤掉由在线店铺下单的 payment 支付数据
5801
6199
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5820,7 +6218,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5820
6218
  return p.code;
5821
6219
  })) || []
5822
6220
  });
5823
- _context41.prev = 3;
6221
+ _context44.prev = 3;
5824
6222
  // 构建订单数据,设置默认值并允许 params 覆盖
5825
6223
  orderData = _objectSpread({
5826
6224
  sales_channel: 'my_pisel',
@@ -5868,32 +6266,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5868
6266
  hasOrderId: !!orderData.order_id,
5869
6267
  smallTicketDataFlag: orderData.small_ticket_data_flag
5870
6268
  });
5871
- _context41.next = 10;
6269
+ _context44.next = 10;
5872
6270
  return this.request.post('/order/checkout', orderData, {
5873
6271
  osServer: true,
5874
6272
  customToast: function customToast() {}
5875
6273
  });
5876
6274
  case 10:
5877
- response = _context41.sent;
6275
+ response = _context44.sent;
5878
6276
  this.logInfo('Order API called successfully', {
5879
6277
  response: response
5880
6278
  });
5881
- return _context41.abrupt("return", response);
6279
+ return _context44.abrupt("return", response);
5882
6280
  case 15:
5883
- _context41.prev = 15;
5884
- _context41.t0 = _context41["catch"](3);
5885
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context41.t0);
6281
+ _context44.prev = 15;
6282
+ _context44.t0 = _context44["catch"](3);
6283
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context44.t0);
5886
6284
  this.logInfo('Order API called failed', {
5887
- error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
6285
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
5888
6286
  });
5889
- throw _context41.t0;
6287
+ throw _context44.t0;
5890
6288
  case 20:
5891
6289
  case "end":
5892
- return _context41.stop();
6290
+ return _context44.stop();
5893
6291
  }
5894
- }, _callee38, this, [[3, 15]]);
6292
+ }, _callee41, this, [[3, 15]]);
5895
6293
  }));
5896
- function createOrderByCheckout(_x46) {
6294
+ function createOrderByCheckout(_x48) {
5897
6295
  return _createOrderByCheckout.apply(this, arguments);
5898
6296
  }
5899
6297
  return createOrderByCheckout;
@@ -5901,24 +6299,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5901
6299
  }, {
5902
6300
  key: "submitSalesOrder",
5903
6301
  value: function () {
5904
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6302
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5905
6303
  var url, query, fetchUrl;
5906
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5907
- while (1) switch (_context42.prev = _context42.next) {
6304
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6305
+ while (1) switch (_context45.prev = _context45.next) {
5908
6306
  case 0:
5909
6307
  url = params.url, query = params.query;
5910
6308
  fetchUrl = url || '/order/sales/checkout';
5911
- return _context42.abrupt("return", this.request.post(fetchUrl, query, {
6309
+ return _context45.abrupt("return", this.request.post(fetchUrl, query, {
5912
6310
  osServer: true,
5913
6311
  customToast: function customToast() {}
5914
6312
  }));
5915
6313
  case 3:
5916
6314
  case "end":
5917
- return _context42.stop();
6315
+ return _context45.stop();
5918
6316
  }
5919
- }, _callee39, this);
6317
+ }, _callee42, this);
5920
6318
  }));
5921
- function submitSalesOrder(_x47) {
6319
+ function submitSalesOrder(_x49) {
5922
6320
  return _submitSalesOrder.apply(this, arguments);
5923
6321
  }
5924
6322
  return submitSalesOrder;
@@ -5932,37 +6330,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5932
6330
  }, {
5933
6331
  key: "sendCustomerPayLink",
5934
6332
  value: (function () {
5935
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
6333
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5936
6334
  var _params$emails;
5937
6335
  var orderIds;
5938
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5939
- while (1) switch (_context43.prev = _context43.next) {
6336
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6337
+ while (1) switch (_context46.prev = _context46.next) {
5940
6338
  case 0:
5941
6339
  orderIds = params.order_ids || params.orderIds || [];
5942
6340
  if (orderIds.length) {
5943
- _context43.next = 3;
6341
+ _context46.next = 3;
5944
6342
  break;
5945
6343
  }
5946
6344
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5947
6345
  case 3:
5948
6346
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5949
- _context43.next = 5;
6347
+ _context46.next = 5;
5950
6348
  break;
5951
6349
  }
5952
6350
  throw new Error('发送支付链接需要至少一个邮箱');
5953
6351
  case 5:
5954
- return _context43.abrupt("return", this.request.post('/order/batch-email', {
6352
+ return _context46.abrupt("return", this.request.post('/order/batch-email', {
5955
6353
  order_ids: orderIds,
5956
6354
  notify_action: params.notify_action || 'order_payment_reminder',
5957
6355
  emails: params.emails
5958
6356
  }));
5959
6357
  case 6:
5960
6358
  case "end":
5961
- return _context43.stop();
6359
+ return _context46.stop();
5962
6360
  }
5963
- }, _callee40, this);
6361
+ }, _callee43, this);
5964
6362
  }));
5965
- function sendCustomerPayLink(_x48) {
6363
+ function sendCustomerPayLink(_x50) {
5966
6364
  return _sendCustomerPayLink.apply(this, arguments);
5967
6365
  }
5968
6366
  return sendCustomerPayLink;
@@ -5970,14 +6368,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5970
6368
  }, {
5971
6369
  key: "getSalesOrderByLookup",
5972
6370
  value: function () {
5973
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
6371
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
5974
6372
  var lookup, res;
5975
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5976
- while (1) switch (_context44.prev = _context44.next) {
6373
+ return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6374
+ while (1) switch (_context47.prev = _context47.next) {
5977
6375
  case 0:
5978
6376
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5979
6377
  if (lookup) {
5980
- _context44.next = 3;
6378
+ _context47.next = 3;
5981
6379
  break;
5982
6380
  }
5983
6381
  throw new Error('加载销售详情需要 lookup');
@@ -5986,27 +6384,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5986
6384
  if (lookup.startsWith('LOCAL_')) {
5987
6385
  params.forceRemote = false;
5988
6386
  }
5989
- _context44.next = 6;
6387
+ _context47.next = 6;
5990
6388
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5991
- with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
6389
+ with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes']
5992
6390
  }, params.forceRemote ? {
5993
6391
  forceRemote: true
5994
6392
  } : {}), {
5995
6393
  osServer: true
5996
6394
  });
5997
6395
  case 6:
5998
- res = _context44.sent;
6396
+ res = _context47.sent;
5999
6397
  if (res.code === 200) {
6000
6398
  this.store.lastOrderInfo = res.data;
6001
6399
  }
6002
- return _context44.abrupt("return", res);
6400
+ return _context47.abrupt("return", res);
6003
6401
  case 9:
6004
6402
  case "end":
6005
- return _context44.stop();
6403
+ return _context47.stop();
6006
6404
  }
6007
- }, _callee41, this);
6405
+ }, _callee44, this);
6008
6406
  }));
6009
- function getSalesOrderByLookup(_x49) {
6407
+ function getSalesOrderByLookup(_x51) {
6010
6408
  return _getSalesOrderByLookup.apply(this, arguments);
6011
6409
  }
6012
6410
  return getSalesOrderByLookup;
@@ -6020,11 +6418,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6020
6418
  }, {
6021
6419
  key: "hydrateTempOrderFromRecord",
6022
6420
  value: (function () {
6023
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(record, options) {
6421
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(record, options) {
6024
6422
  var _sourceRaw$_extend, _this$store$discount22;
6025
- var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
6026
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6027
- while (1) switch (_context45.prev = _context45.next) {
6423
+ var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
6424
+ return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6425
+ while (1) switch (_context48.prev = _context48.next) {
6028
6426
  case 0:
6029
6427
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
6030
6428
  duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
@@ -6060,11 +6458,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6060
6458
  isMergedSalesDetailHydrate = (options === null || options === void 0 ? void 0 : options.source) === 'mergedSalesDetail';
6061
6459
  nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
6062
6460
  // merge 前已只给远端商品补标记;这里不能把本地未提交商品一并变成 saved item。
6063
- makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate
6461
+ makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate,
6462
+ allowUnresolvedSalesNotes: isSessionStorageHydrate
6064
6463
  });
6065
6464
  this.store.tempOrder = nextTempOrder;
6066
6465
  if (!isSessionStorageHydrate) {
6067
- _context45.next = 30;
6466
+ _context48.next = 30;
6068
6467
  break;
6069
6468
  }
6070
6469
  // 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
@@ -6080,23 +6479,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6080
6479
  nextTempOrder.discount_list = restoredSessionDiscounts;
6081
6480
  this.store.summary = createEmptySummary();
6082
6481
  this.store.lastOrderInfo = undefined;
6083
- _context45.next = 23;
6482
+ _context48.next = 23;
6084
6483
  return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
6085
6484
  case 23:
6086
- _context45.next = 25;
6485
+ _context48.next = 25;
6087
6486
  return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(cloneDeep(restoredSessionDiscounts));
6088
6487
  case 25:
6089
6488
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6090
- _context45.next = 28;
6489
+ _context48.next = 28;
6091
6490
  break;
6092
6491
  }
6093
- _context45.next = 28;
6492
+ _context48.next = 28;
6094
6493
  return this.recalculateSummary({
6095
6494
  createIfMissing: false
6096
6495
  });
6097
6496
  case 28:
6098
6497
  this.persistTempOrder();
6099
- return _context45.abrupt("return", nextTempOrder);
6498
+ return _context48.abrupt("return", nextTempOrder);
6100
6499
  case 30:
6101
6500
  // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
6102
6501
  sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
@@ -6106,6 +6505,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6106
6505
  externalSaleNumber: nextTempOrder.external_sale_number
6107
6506
  };
6108
6507
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
6508
+ historicalDepositSnapshot = this.getHistoricalDepositSnapshot(sourceLastOrderInfo);
6109
6509
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
6110
6510
  return _objectSpread({}, s || {});
6111
6511
  }) : cloneDeep(nextTempOrder.surcharges || []);
@@ -6113,7 +6513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6113
6513
  surcharges: summarySurcharges
6114
6514
  });
6115
6515
  nextTempOrder._extend = _objectSpread(_objectSpread({}, nextTempOrder._extend || {}), {}, {
6116
- originalSalesSnapshot: _objectSpread({
6516
+ originalSalesSnapshot: _objectSpread(_objectSpread({
6117
6517
  summary: cloneDeep(this.store.summary),
6118
6518
  products: cloneDeep(nextTempOrder.products || []),
6119
6519
  bookings: cloneDeep(nextTempOrder.bookings || []),
@@ -6121,7 +6521,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6121
6521
  surcharges: cloneDeep(nextTempOrder.surcharges || []),
6122
6522
  shop_discount: nextTempOrder.shop_discount || '0.00',
6123
6523
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
6124
- }, isMergedSalesDetailHydrate ? {
6524
+ }, historicalDepositSnapshot ? {
6525
+ is_deposit: historicalDepositSnapshot.isDeposit,
6526
+ deposit_amount: historicalDepositSnapshot.depositAmount
6527
+ } : {}), isMergedSalesDetailHydrate ? {
6125
6528
  requiresFullSummaryRecalculation: true
6126
6529
  } : {})
6127
6530
  });
@@ -6144,34 +6547,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6144
6547
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
6145
6548
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
6146
6549
  if (shouldSkipEmptyDiscountSync) {
6147
- _context45.next = 53;
6550
+ _context48.next = 54;
6148
6551
  break;
6149
6552
  }
6150
6553
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
6151
- _context45.next = 51;
6554
+ _context48.next = 52;
6152
6555
  return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList(nextDiscounts);
6153
- case 51:
6154
- _context45.next = 53;
6556
+ case 52:
6557
+ _context48.next = 54;
6155
6558
  return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setDiscountList(nextDiscounts);
6156
- case 53:
6559
+ case 54:
6157
6560
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6158
- _context45.next = 56;
6561
+ _context48.next = 57;
6159
6562
  break;
6160
6563
  }
6161
- _context45.next = 56;
6564
+ _context48.next = 57;
6162
6565
  return this.recalculateSummary({
6163
6566
  createIfMissing: false
6164
6567
  });
6165
- case 56:
6568
+ case 57:
6166
6569
  this.persistTempOrder();
6167
- return _context45.abrupt("return", nextTempOrder);
6168
- case 58:
6570
+ return _context48.abrupt("return", nextTempOrder);
6571
+ case 59:
6169
6572
  case "end":
6170
- return _context45.stop();
6573
+ return _context48.stop();
6171
6574
  }
6172
- }, _callee42, this);
6575
+ }, _callee45, this);
6173
6576
  }));
6174
- function hydrateTempOrderFromRecord(_x50, _x51) {
6577
+ function hydrateTempOrderFromRecord(_x52, _x53) {
6175
6578
  return _hydrateTempOrderFromRecord.apply(this, arguments);
6176
6579
  }
6177
6580
  return hydrateTempOrderFromRecord;
@@ -6224,10 +6627,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6224
6627
  _step22;
6225
6628
  try {
6226
6629
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
6227
- var _product$metadata8;
6630
+ var _product$metadata10;
6228
6631
  var product = _step22.value;
6229
6632
  var productUid = getOrderCollectionUid('product', product);
6230
- var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
6633
+ var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_uid);
6231
6634
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
6232
6635
  continue;
6233
6636
  }
@@ -6285,7 +6688,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6285
6688
  }, {
6286
6689
  key: "normalizeTempOrderForRuntime",
6287
6690
  value: function normalizeTempOrderForRuntime(raw, options) {
6288
- var _this34 = this;
6691
+ var _this37 = this,
6692
+ _raw$_extend;
6289
6693
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6290
6694
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
6291
6695
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
@@ -6309,12 +6713,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6309
6713
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
6310
6714
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
6311
6715
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
6312
- return _this34.normalizeHydratedOrderProduct(p, {
6716
+ return _this37.normalizeHydratedOrderProduct(p, {
6313
6717
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
6314
6718
  });
6315
6719
  }) : [];
6316
6720
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
6317
- var booking = _this34.normalizeHydratedBookingHolder(b || {});
6721
+ var booking = _this37.normalizeHydratedBookingHolder(b || {});
6318
6722
  return _objectSpread(_objectSpread({}, booking), {}, {
6319
6723
  is_all: normalizeBookingIsAll(booking),
6320
6724
  sub_type: normalizeBookingSubType(booking)
@@ -6323,6 +6727,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6323
6727
  nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
6324
6728
  return _objectSpread({}, p || {});
6325
6729
  }) : [];
6730
+ var rawHasSalesNotes = Object.prototype.hasOwnProperty.call(raw, 'notes');
6731
+ var restoredSalesNotesState = (_raw$_extend = raw._extend) === null || _raw$_extend === void 0 ? void 0 : _raw$_extend.salesNotesState;
6732
+ var allowUnresolvedSalesNotes = (options === null || options === void 0 ? void 0 : options.allowUnresolvedSalesNotes) === true || (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || Number(raw.is_draft_order || 0) === 1;
6733
+ var decodedSalesNotes = rawHasSalesNotes ? decodeSalesNotesSnapshot(raw.notes, {
6734
+ allowUnresolvedOrderTarget: allowUnresolvedSalesNotes
6735
+ }) : {
6736
+ notes: [],
6737
+ complete: false
6738
+ };
6739
+ var hasUnresolvedSalesNoteOrderTarget = decodedSalesNotes.notes.some(function (note) {
6740
+ return note.note_relations.some(function (relation) {
6741
+ return relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && relation.target_uuid === '';
6742
+ });
6743
+ });
6744
+ nextTempOrder.notes = decodedSalesNotes.notes;
6326
6745
  nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
6327
6746
  return _objectSpread({}, s || {});
6328
6747
  }) : [];
@@ -6339,16 +6758,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6339
6758
  productsByUid: {}
6340
6759
  };
6341
6760
  var tempOrderExtend = nextTempOrder._extend;
6761
+ tempOrderExtend.salesNotesState = {
6762
+ loaded: rawHasSalesNotes ? decodedSalesNotes.complete : (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.loaded) === true,
6763
+ dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
6764
+ };
6342
6765
  var productsByUid = tempOrderExtend.productsByUid || {};
6343
6766
  var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
6344
6767
  _step24;
6345
6768
  try {
6346
6769
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6347
- var _product$metadata9, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
6770
+ var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
6348
6771
  var _step24$value = _slicedToArray(_step24.value, 2),
6349
6772
  index = _step24$value[0],
6350
6773
  product = _step24$value[1];
6351
- var uid = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.unique_identification_number;
6774
+ var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
6352
6775
  if (!uid) continue;
6353
6776
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6354
6777
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
@@ -6403,8 +6826,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6403
6826
  var bookingUidByProductUid = new Map();
6404
6827
  var productByUid = new Map();
6405
6828
  (tempOrder.products || []).forEach(function (product) {
6406
- var _product$metadata10;
6407
- var productUid = (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
6829
+ var _product$metadata12;
6830
+ var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
6408
6831
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
6409
6832
  productByUid.set(String(productUid), product);
6410
6833
  }
@@ -6425,8 +6848,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6425
6848
  bookingUidByProductUid.set(String(productUid), bookingUid);
6426
6849
  });
6427
6850
  (tempOrder.products || []).forEach(function (product) {
6428
- var _product$metadata11;
6429
- var productUid = (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
6851
+ var _product$metadata13;
6852
+ var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
6430
6853
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
6431
6854
  var bookingUid = bookingUidByProductUid.get(String(productUid));
6432
6855
  if (!bookingUid) return;
@@ -6501,7 +6924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6501
6924
  }, {
6502
6925
  key: "normalizeHydratedOrderProduct",
6503
6926
  value: function normalizeHydratedOrderProduct(product, options) {
6504
- var _this35 = this;
6927
+ var _this38 = this;
6505
6928
  var row = _objectSpread({}, product || {});
6506
6929
  if (row.num === undefined && row.product_quantity !== undefined) {
6507
6930
  row.num = row.product_quantity;
@@ -6509,7 +6932,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6509
6932
  var productSku = ensureProductSku(row);
6510
6933
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
6511
6934
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
6512
- return _this35.normalizeHydratedProductOptionItem(optionItem || {});
6935
+ return _this38.normalizeHydratedProductOptionItem(optionItem || {});
6513
6936
  }))
6514
6937
  });
6515
6938
  delete row["product_".concat('option', "_item")];
@@ -6549,27 +6972,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6549
6972
  }, {
6550
6973
  key: "getOrderInfo",
6551
6974
  value: function () {
6552
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(order_id) {
6975
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order_id) {
6553
6976
  var res;
6554
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6555
- while (1) switch (_context46.prev = _context46.next) {
6977
+ return _regeneratorRuntime().wrap(function _callee46$(_context49) {
6978
+ while (1) switch (_context49.prev = _context49.next) {
6556
6979
  case 0:
6557
- _context46.next = 2;
6980
+ _context49.next = 2;
6558
6981
  return this.request.get("/order/sales/".concat(order_id), {
6559
- with: ['products', 'bookings']
6982
+ with: ['products', 'bookings', 'notes']
6560
6983
  }, {
6561
6984
  osServer: true
6562
6985
  });
6563
6986
  case 2:
6564
- res = _context46.sent;
6565
- return _context46.abrupt("return", res);
6987
+ res = _context49.sent;
6988
+ return _context49.abrupt("return", res);
6566
6989
  case 4:
6567
6990
  case "end":
6568
- return _context46.stop();
6991
+ return _context49.stop();
6569
6992
  }
6570
- }, _callee43, this);
6993
+ }, _callee46, this);
6571
6994
  }));
6572
- function getOrderInfo(_x52) {
6995
+ function getOrderInfo(_x54) {
6573
6996
  return _getOrderInfo.apply(this, arguments);
6574
6997
  }
6575
6998
  return getOrderInfo;