@pisell/pisellos 2.2.294 → 2.2.295

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 (69) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +1 -4
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +35 -135
  3. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
  4. package/dist/model/strategy/adapter/itemRule/evaluator.js +1 -25
  5. package/dist/model/strategy/adapter/itemRule/type.d.ts +0 -44
  6. package/dist/model/strategy/adapter/itemRule/type.js +1 -19
  7. package/dist/modules/Order/index.d.ts +3 -18
  8. package/dist/modules/Order/index.js +485 -885
  9. package/dist/modules/Order/types.d.ts +5 -91
  10. package/dist/modules/Order/types.js +0 -5
  11. package/dist/modules/Order/utils.js +10 -22
  12. package/dist/modules/ProductList/index.d.ts +1 -2
  13. package/dist/modules/ProductList/index.js +20 -100
  14. package/dist/modules/ProductList/types.d.ts +0 -10
  15. package/dist/server/index.d.ts +0 -6
  16. package/dist/server/index.js +3 -43
  17. package/dist/solution/BaseSales/index.d.ts +1 -9
  18. package/dist/solution/BaseSales/index.js +706 -894
  19. package/dist/solution/BookingByStep/index.d.ts +2 -2
  20. package/dist/solution/BookingTicket/utils/orderCustomer.js +2 -3
  21. package/dist/solution/RegisterAndLogin/config.d.ts +3 -9
  22. package/dist/solution/RegisterAndLogin/config.js +40 -95
  23. package/dist/solution/RegisterAndLogin/index.js +1 -4
  24. package/dist/solution/ScanOrder/index.d.ts +0 -1
  25. package/dist/solution/ScanOrder/index.js +27 -31
  26. package/dist/solution/ScanOrder/utils.d.ts +0 -1
  27. package/dist/solution/ScanOrder/utils.js +0 -2
  28. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -15
  29. package/dist/solution/UnifiedBookingSales/index.js +484 -752
  30. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -14
  31. package/dist/solution/VenueBooking/index.d.ts +0 -1
  32. package/dist/solution/VenueBooking/index.js +4 -8
  33. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +1 -4
  34. package/lib/model/strategy/adapter/itemRule/adapter.js +4 -73
  35. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +1 -8
  36. package/lib/model/strategy/adapter/itemRule/evaluator.js +1 -23
  37. package/lib/model/strategy/adapter/itemRule/type.d.ts +0 -44
  38. package/lib/model/strategy/adapter/itemRule/type.js +1 -19
  39. package/lib/modules/Order/index.d.ts +3 -18
  40. package/lib/modules/Order/index.js +28 -325
  41. package/lib/modules/Order/types.d.ts +5 -91
  42. package/lib/modules/Order/types.js +0 -4
  43. package/lib/modules/Order/utils.js +1 -13
  44. package/lib/modules/ProductList/index.d.ts +1 -2
  45. package/lib/modules/ProductList/index.js +2 -47
  46. package/lib/modules/ProductList/types.d.ts +0 -10
  47. package/lib/server/index.d.ts +0 -6
  48. package/lib/server/index.js +3 -37
  49. package/lib/solution/BaseSales/index.d.ts +1 -9
  50. package/lib/solution/BaseSales/index.js +1 -105
  51. package/lib/solution/BookingByStep/index.d.ts +2 -2
  52. package/lib/solution/BookingTicket/utils/orderCustomer.js +1 -2
  53. package/lib/solution/RegisterAndLogin/config.d.ts +3 -9
  54. package/lib/solution/RegisterAndLogin/config.js +8 -49
  55. package/lib/solution/RegisterAndLogin/index.js +1 -4
  56. package/lib/solution/ScanOrder/index.d.ts +0 -1
  57. package/lib/solution/ScanOrder/index.js +1 -5
  58. package/lib/solution/ScanOrder/utils.d.ts +0 -1
  59. package/lib/solution/ScanOrder/utils.js +0 -1
  60. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -15
  61. package/lib/solution/UnifiedBookingSales/index.js +1 -125
  62. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -14
  63. package/lib/solution/VenueBooking/index.d.ts +0 -1
  64. package/lib/solution/VenueBooking/index.js +1 -5
  65. package/package.json +1 -1
  66. package/dist/modules/Order/salesNotes.d.ts +0 -31
  67. package/dist/modules/Order/salesNotes.js +0 -492
  68. package/lib/modules/Order/salesNotes.d.ts +0 -31
  69. package/lib/modules/Order/salesNotes.js +0 -382
@@ -35,7 +35,6 @@ 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";
39
38
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
40
39
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
41
40
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
@@ -1374,7 +1373,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1374
1373
  if (!this.store.tempOrder) return;
1375
1374
  this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
1376
1375
  products: _toConsumableArray(this.store.tempOrder.products),
1377
- notes: _toConsumableArray(this.store.tempOrder.notes || []),
1378
1376
  bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
1379
1377
  });
1380
1378
  this.persistTempOrder();
@@ -3229,277 +3227,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3229
3227
  var _this$store$tempOrder3;
3230
3228
  return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
3231
3229
  }
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
- }()
3503
3230
  }, {
3504
3231
  key: "updateTempOrderShopDiscount",
3505
3232
  value: function updateTempOrderShopDiscount(amount) {
@@ -3541,33 +3268,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3541
3268
  this.persistTempOrder();
3542
3269
  return tempOrder.buzzer;
3543
3270
  }
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
- }
3571
3271
  }, {
3572
3272
  key: "updateTempOrderContactsInfo",
3573
3273
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -3609,15 +3309,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3609
3309
  }, {
3610
3310
  key: "productHasCustomerBoundDiscount",
3611
3311
  value: function productHasCustomerBoundDiscount(product) {
3612
- var _this21 = this;
3312
+ var _this19 = this;
3613
3313
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3614
- return _this21.isCustomerBoundDiscount(discount);
3314
+ return _this19.isCustomerBoundDiscount(discount);
3615
3315
  })) {
3616
3316
  return true;
3617
3317
  }
3618
3318
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3619
3319
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3620
- return _this21.isCustomerBoundDiscount(discount);
3320
+ return _this19.isCustomerBoundDiscount(discount);
3621
3321
  });
3622
3322
  });
3623
3323
  }
@@ -3626,18 +3326,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3626
3326
  value: function shouldSkipDiscountCalculation(tempOrder) {
3627
3327
  var _this$store$discount18,
3628
3328
  _this$store$discount19,
3629
- _this22 = this;
3329
+ _this20 = this;
3630
3330
  if (this.hasActiveCustomerBoundDiscount) return false;
3631
3331
  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)) || [];
3632
3332
  if (discountList.length > 0) return false;
3633
3333
  return !(tempOrder.products || []).some(function (product) {
3634
- return _this22.productHasCustomerBoundDiscount(product);
3334
+ return _this20.productHasCustomerBoundDiscount(product);
3635
3335
  });
3636
3336
  }
3637
3337
  }, {
3638
3338
  key: "clearCustomerBoundDiscounts",
3639
3339
  value: function clearCustomerBoundDiscounts(tempOrder) {
3640
- var _this23 = this,
3340
+ var _this21 = this,
3641
3341
  _discountModule$getDi,
3642
3342
  _discountModule$getOr,
3643
3343
  _discountModule$setDi,
@@ -3646,7 +3346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3646
3346
  var filterDiscountList = function filterDiscountList(discountList) {
3647
3347
  if (!Array.isArray(discountList)) return [];
3648
3348
  return discountList.filter(function (discount) {
3649
- var shouldRemove = _this23.isCustomerBoundDiscount(discount);
3349
+ var shouldRemove = _this21.isCustomerBoundDiscount(discount);
3650
3350
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3651
3351
  return !shouldRemove;
3652
3352
  });
@@ -3673,12 +3373,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3673
3373
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3674
3374
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3675
3375
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3676
- if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3677
- return !_this23.isCustomerBoundDiscount(discount);
3376
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3377
+ return !_this21.isCustomerBoundDiscount(discount);
3678
3378
  });
3679
3379
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3680
- if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3681
- return !_this23.isCustomerBoundDiscount(discount);
3380
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3381
+ return !_this21.isCustomerBoundDiscount(discount);
3682
3382
  });
3683
3383
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3684
3384
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3839,10 +3539,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3839
3539
  }, {
3840
3540
  key: "setOrderPayments",
3841
3541
  value: function setOrderPayments(payments) {
3842
- var _this24 = this;
3542
+ var _this22 = this;
3843
3543
  var tempOrder = this.ensureTempOrder();
3844
3544
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
3845
- return _this24.normalizePaymentSource(payment, {
3545
+ return _this22.normalizePaymentSource(payment, {
3846
3546
  defaultPaid: false
3847
3547
  });
3848
3548
  }));
@@ -3862,34 +3562,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3862
3562
  }, {
3863
3563
  key: "addOrderPaymentAsync",
3864
3564
  value: (function () {
3865
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(payment) {
3565
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
3866
3566
  var hasPaymentNumber, devicePrefix;
3867
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3868
- while (1) switch (_context20.prev = _context20.next) {
3567
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3568
+ while (1) switch (_context17.prev = _context17.next) {
3869
3569
  case 0:
3870
3570
  hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3871
3571
  if (!hasPaymentNumber) {
3872
- _context20.next = 5;
3572
+ _context17.next = 5;
3873
3573
  break;
3874
3574
  }
3875
- _context20.t0 = 'LOCAL';
3876
- _context20.next = 8;
3575
+ _context17.t0 = 'LOCAL';
3576
+ _context17.next = 8;
3877
3577
  break;
3878
3578
  case 5:
3879
- _context20.next = 7;
3579
+ _context17.next = 7;
3880
3580
  return this.getPaymentNumberDevicePrefixAsync();
3881
3581
  case 7:
3882
- _context20.t0 = _context20.sent;
3582
+ _context17.t0 = _context17.sent;
3883
3583
  case 8:
3884
- devicePrefix = _context20.t0;
3885
- return _context20.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3584
+ devicePrefix = _context17.t0;
3585
+ return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3886
3586
  case 10:
3887
3587
  case "end":
3888
- return _context20.stop();
3588
+ return _context17.stop();
3889
3589
  }
3890
- }, _callee18, this);
3590
+ }, _callee15, this);
3891
3591
  }));
3892
- function addOrderPaymentAsync(_x16) {
3592
+ function addOrderPaymentAsync(_x14) {
3893
3593
  return _addOrderPaymentAsync.apply(this, arguments);
3894
3594
  }
3895
3595
  return addOrderPaymentAsync;
@@ -3897,7 +3597,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3897
3597
  }, {
3898
3598
  key: "addOrderPaymentWithDevicePrefix",
3899
3599
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3900
- var _this25 = this;
3600
+ var _this23 = this;
3901
3601
  this.logInfo('addOrderPayment', {
3902
3602
  payment: payment
3903
3603
  });
@@ -3915,7 +3615,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3915
3615
  void this.recalculateSummary({
3916
3616
  createIfMissing: true
3917
3617
  }).catch(function (error) {
3918
- _this25.logError('recalculate summary after addOrderPayment failed', {
3618
+ _this23.logError('recalculate summary after addOrderPayment failed', {
3919
3619
  error: error instanceof Error ? error.message : String(error)
3920
3620
  });
3921
3621
  });
@@ -3929,7 +3629,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3929
3629
  }, {
3930
3630
  key: "updateOrderPayment",
3931
3631
  value: (function () {
3932
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(paymentIdentity, updates) {
3632
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
3933
3633
  var options,
3934
3634
  tempOrder,
3935
3635
  identity,
@@ -3938,17 +3638,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3938
3638
  updatedPayment,
3939
3639
  summary,
3940
3640
  payments,
3941
- _args21 = arguments;
3942
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3943
- while (1) switch (_context21.prev = _context21.next) {
3641
+ _args18 = arguments;
3642
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3643
+ while (1) switch (_context18.prev = _context18.next) {
3944
3644
  case 0:
3945
- options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
3645
+ options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
3946
3646
  tempOrder = this.ensureTempOrder();
3947
3647
  identity = String(paymentIdentity);
3948
3648
  matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3949
3649
  matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
3950
3650
  if (matchedPayment) {
3951
- _context21.next = 7;
3651
+ _context18.next = 7;
3952
3652
  break;
3953
3653
  }
3954
3654
  throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
@@ -3963,15 +3663,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3963
3663
  return nextPayment;
3964
3664
  });
3965
3665
  this.persistTempOrder();
3966
- _context21.next = 12;
3666
+ _context18.next = 12;
3967
3667
  return this.recalculateSummary({
3968
3668
  createIfMissing: true
3969
3669
  });
3970
3670
  case 12:
3971
- summary = _context21.sent;
3671
+ summary = _context18.sent;
3972
3672
  this.persistTempOrder();
3973
3673
  payments = tempOrder.payments;
3974
- return _context21.abrupt("return", {
3674
+ return _context18.abrupt("return", {
3975
3675
  updated: true,
3976
3676
  payment: payments[matchedPayment.index] || updatedPayment,
3977
3677
  payments: payments,
@@ -3979,11 +3679,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3979
3679
  });
3980
3680
  case 16:
3981
3681
  case "end":
3982
- return _context21.stop();
3682
+ return _context18.stop();
3983
3683
  }
3984
- }, _callee19, this);
3684
+ }, _callee16, this);
3985
3685
  }));
3986
- function updateOrderPayment(_x17, _x18) {
3686
+ function updateOrderPayment(_x15, _x16) {
3987
3687
  return _updateOrderPayment.apply(this, arguments);
3988
3688
  }
3989
3689
  return updateOrderPayment;
@@ -4028,7 +3728,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4028
3728
  }, {
4029
3729
  key: "applyPaymentLifecycleChange",
4030
3730
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4031
- var _this26 = this;
3731
+ var _this24 = this;
4032
3732
  this.updateTempOrderPaymentStatus(tempOrder);
4033
3733
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4034
3734
  this.persistTempOrder();
@@ -4038,7 +3738,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4038
3738
  void this.recalculateSummary({
4039
3739
  createIfMissing: true
4040
3740
  }).catch(function (error) {
4041
- _this26.logError("recalculate summary after ".concat(logContext, " failed"), {
3741
+ _this24.logError("recalculate summary after ".concat(logContext, " failed"), {
4042
3742
  error: error instanceof Error ? error.message : String(error)
4043
3743
  });
4044
3744
  });
@@ -4082,7 +3782,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4082
3782
  }, {
4083
3783
  key: "updateVoucherOrderPayments",
4084
3784
  value: function updateVoucherOrderPayments(payments, options) {
4085
- var _this27 = this;
3785
+ var _this25 = this;
4086
3786
  var tempOrder = this.ensureTempOrder();
4087
3787
  var isOrderPaymentType = function isOrderPaymentType(value) {
4088
3788
  return value === 'normal' || value === 'deposit';
@@ -4117,7 +3817,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4117
3817
  });
4118
3818
  };
4119
3819
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4120
- return _this27.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3820
+ return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4121
3821
  defaultPaid: false,
4122
3822
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4123
3823
  });
@@ -4170,7 +3870,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4170
3870
  void this.recalculateSummary({
4171
3871
  createIfMissing: true
4172
3872
  }).catch(function (error) {
4173
- _this27.logError('recalculate summary after updateVoucherOrderPayments failed', {
3873
+ _this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
4174
3874
  error: error instanceof Error ? error.message : String(error)
4175
3875
  });
4176
3876
  });
@@ -4179,38 +3879,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4179
3879
  }, {
4180
3880
  key: "updateVoucherOrderPaymentsAsync",
4181
3881
  value: function () {
4182
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(payments, options) {
3882
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
4183
3883
  var needsPaymentNumber, devicePrefix;
4184
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4185
- while (1) switch (_context22.prev = _context22.next) {
3884
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3885
+ while (1) switch (_context19.prev = _context19.next) {
4186
3886
  case 0:
4187
3887
  needsPaymentNumber = (payments || []).some(function (payment) {
4188
3888
  return String(payment.payment_number || '').trim() === '';
4189
3889
  });
4190
3890
  if (!needsPaymentNumber) {
4191
- _context22.next = 7;
3891
+ _context19.next = 7;
4192
3892
  break;
4193
3893
  }
4194
- _context22.next = 4;
3894
+ _context19.next = 4;
4195
3895
  return this.getPaymentNumberDevicePrefixAsync();
4196
3896
  case 4:
4197
- _context22.t0 = _context22.sent;
4198
- _context22.next = 8;
3897
+ _context19.t0 = _context19.sent;
3898
+ _context19.next = 8;
4199
3899
  break;
4200
3900
  case 7:
4201
- _context22.t0 = 'LOCAL';
3901
+ _context19.t0 = 'LOCAL';
4202
3902
  case 8:
4203
- devicePrefix = _context22.t0;
4204
- return _context22.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
3903
+ devicePrefix = _context19.t0;
3904
+ return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
4205
3905
  devicePrefix: devicePrefix
4206
3906
  })));
4207
3907
  case 10:
4208
3908
  case "end":
4209
- return _context22.stop();
3909
+ return _context19.stop();
4210
3910
  }
4211
- }, _callee20, this);
3911
+ }, _callee17, this);
4212
3912
  }));
4213
- function updateVoucherOrderPaymentsAsync(_x19, _x20) {
3913
+ function updateVoucherOrderPaymentsAsync(_x17, _x18) {
4214
3914
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
4215
3915
  }
4216
3916
  return updateVoucherOrderPaymentsAsync;
@@ -4228,7 +3928,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4228
3928
  key: "shouldMergeProductToOrder",
4229
3929
  value: function shouldMergeProductToOrder(params) {
4230
3930
  var _this$orderHooks,
4231
- _this28 = this;
3931
+ _this26 = this;
4232
3932
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4233
3933
  if (!onBeforeMergeProductToOrder) return true;
4234
3934
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4236,7 +3936,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4236
3936
  }));
4237
3937
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4238
3938
  return Promise.resolve(result).then(function (resolved) {
4239
- return _this28.normalizeShouldMergeProductResult(resolved);
3939
+ return _this26.normalizeShouldMergeProductResult(resolved);
4240
3940
  });
4241
3941
  }
4242
3942
  return this.normalizeShouldMergeProductResult(result);
@@ -4256,8 +3956,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4256
3956
  }, {
4257
3957
  key: "hasLinkedBookingUid",
4258
3958
  value: function hasLinkedBookingUid(product) {
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;
3959
+ var _product$booking_uid, _product$metadata7;
3960
+ 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;
4261
3961
  return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
4262
3962
  }
4263
3963
 
@@ -4272,30 +3972,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4272
3972
  }, {
4273
3973
  key: "finalizeProductOrderMutation",
4274
3974
  value: function () {
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) {
3975
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(tempOrder, options) {
3976
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3977
+ while (1) switch (_context20.prev = _context20.next) {
4278
3978
  case 0:
4279
3979
  this.syncTempOrderHolderFromBookings(tempOrder);
4280
3980
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
4281
- _context23.next = 4;
3981
+ _context20.next = 4;
4282
3982
  break;
4283
3983
  }
4284
- _context23.next = 4;
3984
+ _context20.next = 4;
4285
3985
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
4286
3986
  case 4:
4287
3987
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
4288
- _context23.next = 7;
3988
+ _context20.next = 7;
4289
3989
  break;
4290
3990
  }
4291
- _context23.next = 7;
3991
+ _context20.next = 7;
4292
3992
  return this.applyPromotion();
4293
3993
  case 7:
4294
3994
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
4295
3995
  this.applyDiscount();
4296
3996
  }
4297
3997
  this.sanitizeTempOrderProducts(tempOrder);
4298
- _context23.next = 11;
3998
+ _context20.next = 11;
4299
3999
  return this.recalculateSummary({
4300
4000
  createIfMissing: true
4301
4001
  });
@@ -4303,11 +4003,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4303
4003
  this.persistTempOrder();
4304
4004
  case 12:
4305
4005
  case "end":
4306
- return _context23.stop();
4006
+ return _context20.stop();
4307
4007
  }
4308
- }, _callee21, this);
4008
+ }, _callee18, this);
4309
4009
  }));
4310
- function finalizeProductOrderMutation(_x21, _x22) {
4010
+ function finalizeProductOrderMutation(_x19, _x20) {
4311
4011
  return _finalizeProductOrderMutation.apply(this, arguments);
4312
4012
  }
4313
4013
  return finalizeProductOrderMutation;
@@ -4333,7 +4033,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4333
4033
  _metadata,
4334
4034
  _productToAdd$metadat,
4335
4035
  _origin,
4336
- _this29 = this;
4036
+ _this27 = this;
4337
4037
  var linked = booking ? this.createLinkedProductAndBooking({
4338
4038
  product: product,
4339
4039
  booking: booking
@@ -4366,8 +4066,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4366
4066
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4367
4067
  var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4368
4068
  var _item$metadata3;
4369
- if (_this29.hasGoodPassDiscount(item)) return false;
4370
- if (_this29.hasOrderProductLineNote(item)) return false;
4069
+ if (_this27.hasGoodPassDiscount(item)) return false;
4070
+ if (_this27.hasOrderProductLineNote(item)) return false;
4371
4071
  if (isManualProductDiscountProduct(item)) return false;
4372
4072
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4373
4073
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
@@ -4379,9 +4079,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4379
4079
  var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
4380
4080
  var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
4381
4081
  var commitProductLine = function commitProductLine(shouldMerge) {
4382
- var committedProduct;
4383
4082
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4384
- _this29.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4083
+ _this27.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4385
4084
  if (linked) {
4386
4085
  normalizedIncoming.booking_uid = linked.bookingUid;
4387
4086
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4394,7 +4093,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4394
4093
  } else {
4395
4094
  tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
4396
4095
  }
4397
- committedProduct = normalizedIncoming;
4398
4096
  } else {
4399
4097
  var _targetProduct$metada;
4400
4098
  var targetProduct = matchedProduct;
@@ -4422,8 +4120,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4422
4120
  order_detail_id: targetProduct.order_detail_id,
4423
4121
  num: nextNum
4424
4122
  });
4425
- _this29.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4426
- committedProduct = tempOrder.products[matchedIndex];
4123
+ _this27.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4427
4124
  if (matchedIndex !== tempOrder.products.length - 1) {
4428
4125
  var mergedProduct = tempOrder.products[matchedIndex];
4429
4126
  tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
@@ -4432,10 +4129,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4432
4129
  if (linked) {
4433
4130
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
4434
4131
  }
4435
- return committedProduct;
4436
4132
  };
4437
4133
  if (!matchedProduct) {
4438
- return commitProductLine(false);
4134
+ commitProductLine(false);
4135
+ return;
4439
4136
  }
4440
4137
  var shouldMerge = this.shouldMergeProductToOrder({
4441
4138
  incomingProduct: productToAdd,
@@ -4450,7 +4147,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4450
4147
  if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
4451
4148
  return Promise.resolve(shouldMerge).then(commitProductLine);
4452
4149
  }
4453
- return commitProductLine(shouldMerge);
4150
+ commitProductLine(shouldMerge);
4454
4151
  }
4455
4152
 
4456
4153
  /**
@@ -4463,53 +4160,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4463
4160
  }, {
4464
4161
  key: "addProductToOrder",
4465
4162
  value: (function () {
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) {
4163
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product, booking, options) {
4164
+ var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4165
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4166
+ while (1) switch (_context21.prev = _context21.next) {
4471
4167
  case 0:
4472
4168
  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
- };
4513
4169
  insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
4514
4170
  anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
4515
4171
  var _line$metadata;
@@ -4517,102 +4173,73 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4517
4173
  return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
4518
4174
  }) : -1;
4519
4175
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
4520
- _context24.prev = 8;
4521
4176
  if (!booking) {
4522
- _context24.next = 36;
4177
+ _context21.next = 24;
4523
4178
  break;
4524
4179
  }
4525
4180
  productRecord = product;
4526
4181
  splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
4527
4182
  if (!(splitCount > 1)) {
4528
- _context24.next = 30;
4183
+ _context21.next = 24;
4529
4184
  break;
4530
4185
  }
4531
4186
  i = 0;
4532
- case 14:
4187
+ case 9:
4533
4188
  if (!(i < splitCount)) {
4534
- _context24.next = 28;
4189
+ _context21.next = 21;
4535
4190
  break;
4536
4191
  }
4537
4192
  singleLine = cloneDeep(productRecord);
4538
- singleBooking = cloneDeep(booking);
4539
4193
  singleLine.num = 1;
4540
4194
  delete singleLine.product_quantity;
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, {
4195
+ _appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
4557
4196
  insertAtIndex: insertAtIndex,
4558
4197
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4559
4198
  });
4560
- case 22:
4561
- committedProduct = _context24.sent;
4562
- attachSalesNoteDrafts(committedProduct);
4199
+ if (!_appendResult) {
4200
+ _context21.next = 17;
4201
+ break;
4202
+ }
4203
+ _context21.next = 17;
4204
+ return _appendResult;
4205
+ case 17:
4563
4206
  if (insertAtIndex !== undefined) insertAtIndex += 1;
4564
- case 25:
4207
+ case 18:
4565
4208
  i += 1;
4566
- _context24.next = 14;
4567
- break;
4568
- case 28:
4569
- _context24.next = 34;
4209
+ _context21.next = 9;
4570
4210
  break;
4571
- case 30:
4572
- _context24.next = 32;
4573
- return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
4574
- insertAtIndex: insertAtIndex,
4575
- disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4576
- });
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, {
4211
+ case 21:
4212
+ _context21.next = 23;
4213
+ return this.finalizeProductOrderMutation(tempOrder);
4214
+ case 23:
4215
+ return _context21.abrupt("return", tempOrder.products);
4216
+ case 24:
4217
+ appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
4586
4218
  insertAtIndex: insertAtIndex,
4587
4219
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
4588
4220
  });
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;
4221
+ if (!appendResult) {
4222
+ _context21.next = 28;
4223
+ break;
4224
+ }
4225
+ _context21.next = 28;
4226
+ return appendResult;
4227
+ case 28:
4228
+ _context21.next = 30;
4602
4229
  return this.finalizeProductOrderMutation(tempOrder);
4603
- case 48:
4230
+ case 30:
4604
4231
  this.logInfo('addProductToOrder success', {
4605
4232
  product_id: product.product_id,
4606
4233
  with_booking: !!booking
4607
4234
  });
4608
- return _context24.abrupt("return", tempOrder.products);
4609
- case 50:
4235
+ return _context21.abrupt("return", tempOrder.products);
4236
+ case 32:
4610
4237
  case "end":
4611
- return _context24.stop();
4238
+ return _context21.stop();
4612
4239
  }
4613
- }, _callee22, this, [[8, 42]]);
4240
+ }, _callee19, this);
4614
4241
  }));
4615
- function addProductToOrder(_x23, _x24, _x25) {
4242
+ function addProductToOrder(_x21, _x22, _x23) {
4616
4243
  return _addProductToOrder.apply(this, arguments);
4617
4244
  }
4618
4245
  return addProductToOrder;
@@ -4630,103 +4257,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4630
4257
  }, {
4631
4258
  key: "addProductsToOrder",
4632
4259
  value: (function () {
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) {
4260
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(items, options) {
4261
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult2, appendResult;
4262
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4263
+ while (1) switch (_context22.prev = _context22.next) {
4637
4264
  case 0:
4638
4265
  tempOrder = this.ensureTempOrder();
4639
4266
  if (!(!Array.isArray(items) || items.length === 0)) {
4640
- _context25.next = 3;
4267
+ _context22.next = 3;
4641
4268
  break;
4642
4269
  }
4643
- return _context25.abrupt("return", tempOrder.products);
4270
+ return _context22.abrupt("return", tempOrder.products);
4644
4271
  case 3:
4645
4272
  _iterator20 = _createForOfIteratorHelper(items || []);
4646
- _context25.prev = 4;
4273
+ _context22.prev = 4;
4647
4274
  _iterator20.s();
4648
4275
  case 6:
4649
4276
  if ((_step20 = _iterator20.n()).done) {
4650
- _context25.next = 34;
4277
+ _context22.next = 34;
4651
4278
  break;
4652
4279
  }
4653
4280
  item = _step20.value;
4654
4281
  product = item.product, booking = item.booking;
4655
4282
  if (product) {
4656
- _context25.next = 11;
4283
+ _context22.next = 11;
4657
4284
  break;
4658
4285
  }
4659
- return _context25.abrupt("continue", 32);
4286
+ return _context22.abrupt("continue", 32);
4660
4287
  case 11:
4661
4288
  if (!booking) {
4662
- _context25.next = 28;
4289
+ _context22.next = 28;
4663
4290
  break;
4664
4291
  }
4665
4292
  productRecord = product;
4666
4293
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4667
4294
  if (!(splitCount > 1)) {
4668
- _context25.next = 28;
4295
+ _context22.next = 28;
4669
4296
  break;
4670
4297
  }
4671
4298
  i = 0;
4672
4299
  case 16:
4673
4300
  if (!(i < splitCount)) {
4674
- _context25.next = 27;
4301
+ _context22.next = 27;
4675
4302
  break;
4676
4303
  }
4677
4304
  singleLine = cloneDeep(productRecord);
4678
4305
  singleLine.num = 1;
4679
4306
  delete singleLine.product_quantity;
4680
- _appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4681
- if (!_appendResult) {
4682
- _context25.next = 24;
4307
+ _appendResult2 = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4308
+ if (!_appendResult2) {
4309
+ _context22.next = 24;
4683
4310
  break;
4684
4311
  }
4685
- _context25.next = 24;
4686
- return _appendResult;
4312
+ _context22.next = 24;
4313
+ return _appendResult2;
4687
4314
  case 24:
4688
4315
  i += 1;
4689
- _context25.next = 16;
4316
+ _context22.next = 16;
4690
4317
  break;
4691
4318
  case 27:
4692
- return _context25.abrupt("continue", 32);
4319
+ return _context22.abrupt("continue", 32);
4693
4320
  case 28:
4694
4321
  appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
4695
4322
  if (!appendResult) {
4696
- _context25.next = 32;
4323
+ _context22.next = 32;
4697
4324
  break;
4698
4325
  }
4699
- _context25.next = 32;
4326
+ _context22.next = 32;
4700
4327
  return appendResult;
4701
4328
  case 32:
4702
- _context25.next = 6;
4329
+ _context22.next = 6;
4703
4330
  break;
4704
4331
  case 34:
4705
- _context25.next = 39;
4332
+ _context22.next = 39;
4706
4333
  break;
4707
4334
  case 36:
4708
- _context25.prev = 36;
4709
- _context25.t0 = _context25["catch"](4);
4710
- _iterator20.e(_context25.t0);
4335
+ _context22.prev = 36;
4336
+ _context22.t0 = _context22["catch"](4);
4337
+ _iterator20.e(_context22.t0);
4711
4338
  case 39:
4712
- _context25.prev = 39;
4339
+ _context22.prev = 39;
4713
4340
  _iterator20.f();
4714
- return _context25.finish(39);
4341
+ return _context22.finish(39);
4715
4342
  case 42:
4716
- _context25.next = 44;
4343
+ _context22.next = 44;
4717
4344
  return this.finalizeProductOrderMutation(tempOrder, options);
4718
4345
  case 44:
4719
4346
  this.logInfo('addProductsToOrder success', {
4720
4347
  itemsCount: items.length
4721
4348
  });
4722
- return _context25.abrupt("return", tempOrder.products);
4349
+ return _context22.abrupt("return", tempOrder.products);
4723
4350
  case 46:
4724
4351
  case "end":
4725
- return _context25.stop();
4352
+ return _context22.stop();
4726
4353
  }
4727
- }, _callee23, this, [[4, 36, 39, 42]]);
4354
+ }, _callee20, this, [[4, 36, 39, 42]]);
4728
4355
  }));
4729
- function addProductsToOrder(_x26, _x27) {
4356
+ function addProductsToOrder(_x24, _x25) {
4730
4357
  return _addProductsToOrder.apply(this, arguments);
4731
4358
  }
4732
4359
  return addProductsToOrder;
@@ -4760,17 +4387,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4760
4387
  }, {
4761
4388
  key: "preservePersistedBundlePriceFields",
4762
4389
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4763
- var _this31 = this;
4390
+ var _this28 = this;
4764
4391
  if (!Array.isArray(nextBundles)) return nextBundles;
4765
4392
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4766
4393
  var previousByIdentity = new Map();
4767
4394
  previousBundles.forEach(function (bundle) {
4768
- var identity = _this31.getBundleRuntimeIdentity(bundle);
4395
+ var identity = _this28.getBundleRuntimeIdentity(bundle);
4769
4396
  if (identity) previousByIdentity.set(identity, bundle);
4770
4397
  });
4771
4398
  return nextBundles.map(function (bundle, index) {
4772
4399
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4773
- var previous = previousByIdentity.get(_this31.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4400
+ var previous = previousByIdentity.get(_this28.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4774
4401
  if (!previous || _typeof(previous) !== 'object') return bundle;
4775
4402
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4776
4403
  cover: previous.cover
@@ -4971,21 +4598,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4971
4598
  }, {
4972
4599
  key: "updateOrderProduct",
4973
4600
  value: function () {
4974
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
4601
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4975
4602
  var tempOrder, updatedProductUid;
4976
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4977
- while (1) switch (_context26.prev = _context26.next) {
4603
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4604
+ while (1) switch (_context23.prev = _context23.next) {
4978
4605
  case 0:
4979
4606
  tempOrder = this.ensureTempOrder();
4980
4607
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4981
- _context26.next = 4;
4608
+ _context23.next = 4;
4982
4609
  return this.applyPromotion();
4983
4610
  case 4:
4984
4611
  this.applyDiscount({
4985
4612
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4986
4613
  });
4987
4614
  this.sanitizeTempOrderProducts(tempOrder);
4988
- _context26.next = 8;
4615
+ _context23.next = 8;
4989
4616
  return this.recalculateSummary({
4990
4617
  createIfMissing: true
4991
4618
  });
@@ -4994,14 +4621,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4994
4621
  this.logInfo('updateOrderProduct success', {
4995
4622
  params: params
4996
4623
  });
4997
- return _context26.abrupt("return", tempOrder.products);
4624
+ return _context23.abrupt("return", tempOrder.products);
4998
4625
  case 11:
4999
4626
  case "end":
5000
- return _context26.stop();
4627
+ return _context23.stop();
5001
4628
  }
5002
- }, _callee24, this);
4629
+ }, _callee21, this);
5003
4630
  }));
5004
- function updateOrderProduct(_x28) {
4631
+ function updateOrderProduct(_x26) {
5005
4632
  return _updateOrderProduct.apply(this, arguments);
5006
4633
  }
5007
4634
  return updateOrderProduct;
@@ -5009,28 +4636,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5009
4636
  }, {
5010
4637
  key: "updateOrderProducts",
5011
4638
  value: function () {
5012
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paramsList) {
5013
- var _this32 = this;
4639
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paramsList) {
4640
+ var _this29 = this;
5014
4641
  var tempOrder, reapplyBookingDiscountProductUids;
5015
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
5016
- while (1) switch (_context27.prev = _context27.next) {
4642
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4643
+ while (1) switch (_context24.prev = _context24.next) {
5017
4644
  case 0:
5018
4645
  tempOrder = this.ensureTempOrder();
5019
4646
  if (paramsList.length) {
5020
- _context27.next = 3;
4647
+ _context24.next = 3;
5021
4648
  break;
5022
4649
  }
5023
- return _context27.abrupt("return", tempOrder.products);
4650
+ return _context24.abrupt("return", tempOrder.products);
5024
4651
  case 3:
5025
4652
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5026
- var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params);
4653
+ var updatedProductUid = _this29.applyOrderProductUpdateToTempOrder(tempOrder, params);
5027
4654
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5028
4655
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5029
4656
  acc.push(String(updatedProductUid));
5030
4657
  }
5031
4658
  return acc;
5032
4659
  }, []);
5033
- _context27.next = 6;
4660
+ _context24.next = 6;
5034
4661
  return this.finalizeAfterProductsMutation(tempOrder, {
5035
4662
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
5036
4663
  });
@@ -5038,14 +4665,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5038
4665
  this.logInfo('updateOrderProduct success', {
5039
4666
  paramsList: paramsList
5040
4667
  });
5041
- return _context27.abrupt("return", tempOrder.products);
4668
+ return _context24.abrupt("return", tempOrder.products);
5042
4669
  case 8:
5043
4670
  case "end":
5044
- return _context27.stop();
4671
+ return _context24.stop();
5045
4672
  }
5046
- }, _callee25, this);
4673
+ }, _callee22, this);
5047
4674
  }));
5048
- function updateOrderProducts(_x29) {
4675
+ function updateOrderProducts(_x27) {
5049
4676
  return _updateOrderProducts.apply(this, arguments);
5050
4677
  }
5051
4678
  return updateOrderProducts;
@@ -5053,11 +4680,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5053
4680
  }, {
5054
4681
  key: "updateOrderProductQuantity",
5055
4682
  value: function () {
5056
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4683
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
5057
4684
  var _targetProduct$metada17;
5058
4685
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
5059
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5060
- while (1) switch (_context28.prev = _context28.next) {
4686
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4687
+ while (1) switch (_context25.prev = _context25.next) {
5061
4688
  case 0:
5062
4689
  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;
5063
4690
  tempOrder = this.ensureTempOrder();
@@ -5087,7 +4714,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5087
4714
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
5088
4715
  }
5089
4716
  if (!(productIndex === -1)) {
5090
- _context28.next = 13;
4717
+ _context25.next = 13;
5091
4718
  break;
5092
4719
  }
5093
4720
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -5101,12 +4728,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5101
4728
  }));
5102
4729
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5103
4730
  tempOrder.products[productIndex] = normalizedProduct;
5104
- _context28.next = 19;
4731
+ _context25.next = 19;
5105
4732
  return this.applyPromotion();
5106
4733
  case 19:
5107
4734
  this.applyDiscount();
5108
4735
  this.sanitizeTempOrderProducts(tempOrder);
5109
- _context28.next = 23;
4736
+ _context25.next = 23;
5110
4737
  return this.recalculateSummary({
5111
4738
  createIfMissing: true
5112
4739
  });
@@ -5115,14 +4742,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5115
4742
  this.logInfo('updateOrderProductQuantity success', {
5116
4743
  params: params
5117
4744
  });
5118
- return _context28.abrupt("return", tempOrder.products);
4745
+ return _context25.abrupt("return", tempOrder.products);
5119
4746
  case 26:
5120
4747
  case "end":
5121
- return _context28.stop();
4748
+ return _context25.stop();
5122
4749
  }
5123
- }, _callee26, this);
4750
+ }, _callee23, this);
5124
4751
  }));
5125
- function updateOrderProductQuantity(_x30) {
4752
+ function updateOrderProductQuantity(_x28) {
5126
4753
  return _updateOrderProductQuantity.apply(this, arguments);
5127
4754
  }
5128
4755
  return updateOrderProductQuantity;
@@ -5163,19 +4790,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5163
4790
  }, {
5164
4791
  key: "finalizeAfterProductsMutation",
5165
4792
  value: (function () {
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) {
4793
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(tempOrder, options) {
4794
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4795
+ while (1) switch (_context26.prev = _context26.next) {
5169
4796
  case 0:
5170
4797
  this.syncTempOrderHolderFromBookings(tempOrder);
5171
- _context29.next = 3;
4798
+ _context26.next = 3;
5172
4799
  return this.applyPromotion();
5173
4800
  case 3:
5174
4801
  this.applyDiscount({
5175
4802
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
5176
4803
  });
5177
4804
  this.sanitizeTempOrderProducts(tempOrder);
5178
- _context29.next = 7;
4805
+ _context26.next = 7;
5179
4806
  return this.recalculateSummary({
5180
4807
  createIfMissing: true
5181
4808
  });
@@ -5183,11 +4810,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5183
4810
  this.persistTempOrder();
5184
4811
  case 8:
5185
4812
  case "end":
5186
- return _context29.stop();
4813
+ return _context26.stop();
5187
4814
  }
5188
- }, _callee27, this);
4815
+ }, _callee24, this);
5189
4816
  }));
5190
- function finalizeAfterProductsMutation(_x31, _x32) {
4817
+ function finalizeAfterProductsMutation(_x29, _x30) {
5191
4818
  return _finalizeAfterProductsMutation.apply(this, arguments);
5192
4819
  }
5193
4820
  return finalizeAfterProductsMutation;
@@ -5202,22 +4829,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5202
4829
  }, {
5203
4830
  key: "removeProductsFromOrder",
5204
4831
  value: (function () {
5205
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identities, options) {
5206
- var _this33 = this;
4832
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identities, options) {
4833
+ var _this30 = this;
5207
4834
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5208
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
5209
- while (1) switch (_context31.prev = _context31.next) {
4835
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4836
+ while (1) switch (_context28.prev = _context28.next) {
5210
4837
  case 0:
5211
4838
  tempOrder = this.ensureTempOrder();
4839
+ this.repairDuplicateProductLineIdentities(tempOrder);
5212
4840
  if (identities.length) {
5213
- _context31.next = 3;
4841
+ _context28.next = 4;
5214
4842
  break;
5215
4843
  }
5216
- return _context31.abrupt("return", tempOrder.products);
5217
- case 3:
5218
- // 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
5219
- this.ensureSalesNotesLoadedForMutation(tempOrder);
5220
- this.repairDuplicateProductLineIdentities(tempOrder);
4844
+ return _context28.abrupt("return", tempOrder.products);
4845
+ case 4:
5221
4846
  productsBeforeRemove = tempOrder.products || [];
5222
4847
  bookingsBeforeRemove = tempOrder.bookings || [];
5223
4848
  preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
@@ -5246,29 +4871,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5246
4871
  }
5247
4872
  linkedBookingUidsToRemove = new Set();
5248
4873
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
5249
- _context31.prev = 16;
4874
+ _context28.prev = 15;
5250
4875
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
5251
4876
  var _metadata11, _metadata12, _metadata13, _metadata14;
5252
4877
  var product, productUid, productBookingUid, isAddTimeProduct;
5253
- return _regeneratorRuntime().wrap(function _loop3$(_context30) {
5254
- while (1) switch (_context30.prev = _context30.next) {
4878
+ return _regeneratorRuntime().wrap(function _loop3$(_context27) {
4879
+ while (1) switch (_context27.prev = _context27.next) {
5255
4880
  case 0:
5256
4881
  product = _step21.value;
5257
4882
  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);
5258
4883
  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);
5259
4884
  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;
5260
4885
  if (!isAddTimeProduct) {
5261
- _context30.next = 6;
4886
+ _context27.next = 6;
5262
4887
  break;
5263
4888
  }
5264
- return _context30.abrupt("return", 1);
4889
+ return _context27.abrupt("return", 1);
5265
4890
  case 6:
5266
4891
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
5267
4892
  linkedBookingUidsToRemove.add(String(productBookingUid));
5268
4893
  }
5269
4894
  if (productUid !== undefined && productUid !== null && productUid !== '') {
5270
4895
  bookingsBeforeRemove.forEach(function (booking) {
5271
- var bookingUid = _this33.getBookingUniqueIdentificationNumber(booking);
4896
+ var bookingUid = _this30.getBookingUniqueIdentificationNumber(booking);
5272
4897
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
5273
4898
  linkedBookingUidsToRemove.add(bookingUid);
5274
4899
  }
@@ -5276,38 +4901,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5276
4901
  }
5277
4902
  case 8:
5278
4903
  case "end":
5279
- return _context30.stop();
4904
+ return _context27.stop();
5280
4905
  }
5281
4906
  }, _loop3);
5282
4907
  });
5283
4908
  _iterator21.s();
5284
- case 19:
4909
+ case 18:
5285
4910
  if ((_step21 = _iterator21.n()).done) {
5286
- _context31.next = 25;
4911
+ _context28.next = 24;
5287
4912
  break;
5288
4913
  }
5289
- return _context31.delegateYield(_loop3(), "t0", 21);
5290
- case 21:
5291
- if (!_context31.t0) {
5292
- _context31.next = 23;
4914
+ return _context28.delegateYield(_loop3(), "t0", 20);
4915
+ case 20:
4916
+ if (!_context28.t0) {
4917
+ _context28.next = 22;
5293
4918
  break;
5294
4919
  }
5295
- return _context31.abrupt("continue", 23);
5296
- case 23:
5297
- _context31.next = 19;
4920
+ return _context28.abrupt("continue", 22);
4921
+ case 22:
4922
+ _context28.next = 18;
5298
4923
  break;
5299
- case 25:
5300
- _context31.next = 30;
4924
+ case 24:
4925
+ _context28.next = 29;
5301
4926
  break;
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;
4927
+ case 26:
4928
+ _context28.prev = 26;
4929
+ _context28.t1 = _context28["catch"](15);
4930
+ _iterator21.e(_context28.t1);
4931
+ case 29:
4932
+ _context28.prev = 29;
5308
4933
  _iterator21.f();
5309
- return _context31.finish(30);
5310
- case 33:
4934
+ return _context28.finish(29);
4935
+ case 32:
5311
4936
  if (linkedBookingUidsToRemove.size > 0) {
5312
4937
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
5313
4938
  tempOrder.products = (tempOrder.products || []).filter(function (line) {
@@ -5333,21 +4958,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5333
4958
  tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
5334
4959
  }
5335
4960
  }
5336
- this.removeSalesNotesForMissingProductLines(tempOrder);
5337
- _context31.next = 38;
4961
+ _context28.next = 36;
5338
4962
  return this.finalizeAfterProductsMutation(tempOrder);
5339
- case 38:
4963
+ case 36:
5340
4964
  this.logInfo('removeProductsFromOrder success', {
5341
4965
  identities: identities
5342
4966
  });
5343
- return _context31.abrupt("return", tempOrder.products);
5344
- case 40:
4967
+ return _context28.abrupt("return", tempOrder.products);
4968
+ case 38:
5345
4969
  case "end":
5346
- return _context31.stop();
4970
+ return _context28.stop();
5347
4971
  }
5348
- }, _callee28, this, [[16, 27, 30, 33]]);
4972
+ }, _callee25, this, [[15, 26, 29, 32]]);
5349
4973
  }));
5350
- function removeProductsFromOrder(_x33, _x34) {
4974
+ function removeProductsFromOrder(_x31, _x32) {
5351
4975
  return _removeProductsFromOrder.apply(this, arguments);
5352
4976
  }
5353
4977
  return removeProductsFromOrder;
@@ -5355,63 +4979,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5355
4979
  }, {
5356
4980
  key: "removeProductFromOrder",
5357
4981
  value: function () {
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) {
4982
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity, options) {
4983
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4984
+ while (1) switch (_context29.prev = _context29.next) {
5361
4985
  case 0:
5362
- return _context32.abrupt("return", this.removeProductsFromOrder([identity], options));
4986
+ return _context29.abrupt("return", this.removeProductsFromOrder([identity], options));
5363
4987
  case 1:
5364
4988
  case "end":
5365
- return _context32.stop();
4989
+ return _context29.stop();
5366
4990
  }
5367
- }, _callee29, this);
4991
+ }, _callee26, this);
5368
4992
  }));
5369
- function removeProductFromOrder(_x35, _x36) {
4993
+ function removeProductFromOrder(_x33, _x34) {
5370
4994
  return _removeProductFromOrder.apply(this, arguments);
5371
4995
  }
5372
4996
  return removeProductFromOrder;
5373
4997
  }()
5374
4998
  /**
5375
4999
  * 仅清空购物车行(products / bookings),不重置整单。
5376
- * 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
5000
+ * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
5377
5001
  */
5378
5002
  }, {
5379
5003
  key: "clearOrderCartLines",
5380
5004
  value: (function () {
5381
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
5005
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
5382
5006
  var tempOrder;
5383
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
5384
- while (1) switch (_context33.prev = _context33.next) {
5007
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
5008
+ while (1) switch (_context30.prev = _context30.next) {
5385
5009
  case 0:
5386
5010
  tempOrder = this.ensureTempOrder();
5387
- this.ensureSalesNotesLoadedForMutation(tempOrder);
5388
5011
  tempOrder.products = [];
5389
5012
  tempOrder.bookings = [];
5390
- this.removeSalesNotesForMissingProductLines(tempOrder);
5391
5013
  this.syncTempOrderHolderFromBookings(tempOrder);
5392
5014
  if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
5393
5015
  tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
5394
5016
  productsByUid: {}
5395
5017
  });
5396
5018
  }
5397
- _context33.next = 9;
5019
+ _context30.next = 7;
5398
5020
  return this.applyPromotion();
5399
- case 9:
5021
+ case 7:
5400
5022
  this.applyDiscount();
5401
5023
  this.sanitizeTempOrderProducts(tempOrder);
5402
- _context33.next = 13;
5024
+ _context30.next = 11;
5403
5025
  return this.recalculateSummary({
5404
5026
  createIfMissing: true
5405
5027
  });
5406
- case 13:
5028
+ case 11:
5407
5029
  this.persistTempOrder();
5408
5030
  this.logInfo('clearOrderCartLines success', {});
5409
- return _context33.abrupt("return", tempOrder);
5410
- case 16:
5031
+ return _context30.abrupt("return", tempOrder);
5032
+ case 14:
5411
5033
  case "end":
5412
- return _context33.stop();
5034
+ return _context30.stop();
5413
5035
  }
5414
- }, _callee30, this);
5036
+ }, _callee27, this);
5415
5037
  }));
5416
5038
  function clearOrderCartLines() {
5417
5039
  return _clearOrderCartLines.apply(this, arguments);
@@ -5434,10 +5056,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5434
5056
  type: params === null || params === void 0 ? void 0 : params.type,
5435
5057
  summary: this.store.summary || createEmptySummary(),
5436
5058
  enhance: function enhance(nextPayload) {
5437
- var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order2, _ref72, _tempOrder$shop_full_;
5059
+ var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
5438
5060
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
5439
5061
  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,
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,
5062
+ 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,
5441
5063
  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,
5442
5064
  small_ticket_data_flag: 1
5443
5065
  });
@@ -5449,17 +5071,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5449
5071
  }, {
5450
5072
  key: "applyLocalPrintOrderNumbers",
5451
5073
  value: function () {
5452
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
5074
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(order) {
5453
5075
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
5454
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5455
- while (1) switch (_context34.prev = _context34.next) {
5076
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
5077
+ while (1) switch (_context31.prev = _context31.next) {
5456
5078
  case 0:
5457
5079
  tempOrder = this.ensureTempOrder();
5458
5080
  if (!(!order || _typeof(order) !== 'object')) {
5459
- _context34.next = 3;
5081
+ _context31.next = 3;
5460
5082
  break;
5461
5083
  }
5462
- return _context34.abrupt("return", tempOrder);
5084
+ return _context31.abrupt("return", tempOrder);
5463
5085
  case 3:
5464
5086
  shopOrderNumber = order.shop_order_number;
5465
5087
  shopFullOrderNumber = order.shop_full_order_number;
@@ -5470,17 +5092,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5470
5092
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
5471
5093
  }
5472
5094
  this.persistTempOrder();
5473
- _context34.next = 10;
5095
+ _context31.next = 10;
5474
5096
  return this.saveDraft();
5475
5097
  case 10:
5476
- return _context34.abrupt("return", tempOrder);
5098
+ return _context31.abrupt("return", tempOrder);
5477
5099
  case 11:
5478
5100
  case "end":
5479
- return _context34.stop();
5101
+ return _context31.stop();
5480
5102
  }
5481
- }, _callee31, this);
5103
+ }, _callee28, this);
5482
5104
  }));
5483
- function applyLocalPrintOrderNumbers(_x37) {
5105
+ function applyLocalPrintOrderNumbers(_x35) {
5484
5106
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
5485
5107
  }
5486
5108
  return applyLocalPrintOrderNumbers;
@@ -5488,35 +5110,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5488
5110
  }, {
5489
5111
  key: "saveTempOrderAsDraft",
5490
5112
  value: function () {
5491
- var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5113
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
5492
5114
  var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
5493
5115
  var tempOrder, latestSummary, payload;
5494
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5495
- while (1) switch (_context35.prev = _context35.next) {
5116
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5117
+ while (1) switch (_context32.prev = _context32.next) {
5496
5118
  case 0:
5497
5119
  tempOrder = this.ensureTempOrder();
5498
5120
  this.ensureExternalSaleNumber(tempOrder);
5499
5121
  this.persistTempOrder();
5500
- _context35.next = 5;
5122
+ _context32.next = 5;
5501
5123
  return this.recalculateSummary({
5502
5124
  createIfMissing: true
5503
5125
  });
5504
5126
  case 5:
5505
- _context35.t1 = _context35.sent;
5506
- if (_context35.t1) {
5507
- _context35.next = 8;
5127
+ _context32.t1 = _context32.sent;
5128
+ if (_context32.t1) {
5129
+ _context32.next = 8;
5508
5130
  break;
5509
5131
  }
5510
- _context35.t1 = this.store.summary;
5132
+ _context32.t1 = this.store.summary;
5511
5133
  case 8:
5512
- _context35.t0 = _context35.t1;
5513
- if (_context35.t0) {
5514
- _context35.next = 11;
5134
+ _context32.t0 = _context32.t1;
5135
+ if (_context32.t0) {
5136
+ _context32.next = 11;
5515
5137
  break;
5516
5138
  }
5517
- _context35.t0 = createEmptySummary();
5139
+ _context32.t0 = createEmptySummary();
5518
5140
  case 11:
5519
- latestSummary = _context35.t0;
5141
+ latestSummary = _context32.t0;
5520
5142
  payload = buildSubmitPayload({
5521
5143
  tempOrder: tempOrder,
5522
5144
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
@@ -5537,17 +5159,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5537
5159
  externalSaleNumber: payload.external_sale_number,
5538
5160
  productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
5539
5161
  });
5540
- return _context35.abrupt("return", this.request.post('/order/sales/draft', payload, {
5162
+ return _context32.abrupt("return", this.request.post('/order/sales/draft', payload, {
5541
5163
  osServer: true,
5542
5164
  customToast: function customToast() {}
5543
5165
  }));
5544
5166
  case 18:
5545
5167
  case "end":
5546
- return _context35.stop();
5168
+ return _context32.stop();
5547
5169
  }
5548
- }, _callee32, this);
5170
+ }, _callee29, this);
5549
5171
  }));
5550
- function saveTempOrderAsDraft(_x38) {
5172
+ function saveTempOrderAsDraft(_x36) {
5551
5173
  return _saveTempOrderAsDraft.apply(this, arguments);
5552
5174
  }
5553
5175
  return saveTempOrderAsDraft;
@@ -5561,18 +5183,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5561
5183
  }, {
5562
5184
  key: "submitTempOrder",
5563
5185
  value: (function () {
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) {
5186
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
5187
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
5188
+ while (1) switch (_context33.prev = _context33.next) {
5567
5189
  case 0:
5568
- return _context36.abrupt("return", this.runSubmitTempOrder(params));
5190
+ return _context33.abrupt("return", this.runSubmitTempOrder(params));
5569
5191
  case 1:
5570
5192
  case "end":
5571
- return _context36.stop();
5193
+ return _context33.stop();
5572
5194
  }
5573
- }, _callee33, this);
5195
+ }, _callee30, this);
5574
5196
  }));
5575
- function submitTempOrder(_x39) {
5197
+ function submitTempOrder(_x37) {
5576
5198
  return _submitTempOrder.apply(this, arguments);
5577
5199
  }
5578
5200
  return submitTempOrder;
@@ -5580,20 +5202,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5580
5202
  }, {
5581
5203
  key: "submitTempOrderAsync",
5582
5204
  value: function () {
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) {
5205
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
5206
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5207
+ while (1) switch (_context34.prev = _context34.next) {
5586
5208
  case 0:
5587
- return _context37.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5209
+ return _context34.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5588
5210
  syncMode: true
5589
5211
  })));
5590
5212
  case 1:
5591
5213
  case "end":
5592
- return _context37.stop();
5214
+ return _context34.stop();
5593
5215
  }
5594
- }, _callee34, this);
5216
+ }, _callee31, this);
5595
5217
  }));
5596
- function submitTempOrderAsync(_x40) {
5218
+ function submitTempOrderAsync(_x38) {
5597
5219
  return _submitTempOrderAsync.apply(this, arguments);
5598
5220
  }
5599
5221
  return submitTempOrderAsync;
@@ -5601,11 +5223,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5601
5223
  }, {
5602
5224
  key: "runSubmitTempOrder",
5603
5225
  value: function () {
5604
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5226
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5605
5227
  var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
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) {
5228
+ var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
5229
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5230
+ while (1) switch (_context35.prev = _context35.next) {
5609
5231
  case 0:
5610
5232
  tempOrder = this.ensureTempOrder();
5611
5233
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -5625,26 +5247,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5625
5247
  }
5626
5248
  }
5627
5249
  this.persistTempOrder();
5628
- _context38.next = 8;
5250
+ _context35.next = 8;
5629
5251
  return this.recalculateSummary({
5630
5252
  createIfMissing: true
5631
5253
  });
5632
5254
  case 8:
5633
- _context38.t1 = _context38.sent;
5634
- if (_context38.t1) {
5635
- _context38.next = 11;
5255
+ _context35.t1 = _context35.sent;
5256
+ if (_context35.t1) {
5257
+ _context35.next = 11;
5636
5258
  break;
5637
5259
  }
5638
- _context38.t1 = this.store.summary;
5260
+ _context35.t1 = this.store.summary;
5639
5261
  case 11:
5640
- _context38.t0 = _context38.t1;
5641
- if (_context38.t0) {
5642
- _context38.next = 14;
5262
+ _context35.t0 = _context35.t1;
5263
+ if (_context35.t0) {
5264
+ _context35.next = 14;
5643
5265
  break;
5644
5266
  }
5645
- _context38.t0 = createEmptySummary();
5267
+ _context35.t0 = createEmptySummary();
5646
5268
  case 14:
5647
- latestSummary = _context38.t0;
5269
+ latestSummary = _context35.t0;
5648
5270
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
5649
5271
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
5650
5272
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -5678,10 +5300,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5678
5300
  if (!payload.created_at) {
5679
5301
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5680
5302
  }
5681
- _context38.next = 25;
5303
+ _context35.next = 25;
5682
5304
  return this.saveDraft();
5683
5305
  case 25:
5684
- _context38.prev = 25;
5306
+ _context35.prev = 25;
5685
5307
  this.logInfo('submitTempOrder calling sales checkout', {
5686
5308
  orderId: payload.order_id,
5687
5309
  externalSaleNumber: payload.external_sale_number,
@@ -5691,49 +5313,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5691
5313
  smallTicketDataFlag: payload.small_ticket_data_flag,
5692
5314
  syncMode: payload.sync_mode
5693
5315
  });
5694
- _context38.next = 29;
5316
+ _context35.next = 29;
5695
5317
  return this.submitSalesOrder({
5696
5318
  query: payload
5697
5319
  });
5698
5320
  case 29:
5699
- result = _context38.sent;
5700
- _context38.next = 42;
5321
+ result = _context35.sent;
5322
+ _context35.next = 42;
5701
5323
  break;
5702
5324
  case 32:
5703
- _context38.prev = 32;
5704
- _context38.t2 = _context38["catch"](25);
5705
- backendErrorResponse = this.extractSubmitErrorResponse(_context38.t2);
5325
+ _context35.prev = 32;
5326
+ _context35.t2 = _context35["catch"](25);
5327
+ backendErrorResponse = this.extractSubmitErrorResponse(_context35.t2);
5706
5328
  if (!backendErrorResponse) {
5707
- _context38.next = 39;
5329
+ _context35.next = 39;
5708
5330
  break;
5709
5331
  }
5710
5332
  this.store.syncState = 'failed';
5711
5333
  this.logSubmitBackendRejected(backendErrorResponse, payload);
5712
- return _context38.abrupt("return", backendErrorResponse);
5334
+ return _context35.abrupt("return", backendErrorResponse);
5713
5335
  case 39:
5714
5336
  this.store.syncState = 'failed';
5715
5337
  this.logError('submitTempOrder failed', {
5716
- error: _context38.t2 instanceof Error ? _context38.t2.message : String(_context38.t2),
5338
+ error: _context35.t2 instanceof Error ? _context35.t2.message : String(_context35.t2),
5717
5339
  orderId: payload.order_id,
5718
5340
  externalSaleNumber: payload.external_sale_number,
5719
5341
  paymentStatus: payload.payment_status,
5720
5342
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
5721
5343
  });
5722
- throw _context38.t2;
5344
+ throw _context35.t2;
5723
5345
  case 42:
5724
5346
  if (!this.isSubmitResponseRejected(result)) {
5725
- _context38.next = 46;
5347
+ _context35.next = 46;
5726
5348
  break;
5727
5349
  }
5728
5350
  this.store.syncState = 'failed';
5729
5351
  this.logSubmitBackendRejected(result, payload);
5730
- return _context38.abrupt("return", result);
5352
+ return _context35.abrupt("return", result);
5731
5353
  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
- }
5737
5354
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
5738
5355
  this.logInfo('runSubmitTempOrder: 提交成功', {
5739
5356
  submittedOrderId: submittedOrderId,
@@ -5743,27 +5360,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5743
5360
  })
5744
5361
  });
5745
5362
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
5746
- _context38.next = 55;
5363
+ _context35.next = 55;
5747
5364
  break;
5748
5365
  }
5749
5366
  tempOrder.order_id = submittedOrderId;
5750
5367
  resultRecord = result;
5751
- _context38.next = 55;
5368
+ _context35.next = 53;
5752
5369
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
5370
+ case 53:
5371
+ _context35.next = 56;
5372
+ break;
5753
5373
  case 55:
5754
- if (isLocalPendingSubmit) {
5374
+ if (this.isLocalPendingSubmitResult(result)) {
5755
5375
  this.store.syncState = 'local';
5756
- } else if (submittedOrderId === null || submittedOrderId === undefined) {
5376
+ } else {
5757
5377
  this.store.syncState = 'submitted';
5758
5378
  }
5759
- return _context38.abrupt("return", result);
5379
+ case 56:
5380
+ return _context35.abrupt("return", result);
5760
5381
  case 57:
5761
5382
  case "end":
5762
- return _context38.stop();
5383
+ return _context35.stop();
5763
5384
  }
5764
- }, _callee35, this, [[25, 32]]);
5385
+ }, _callee32, this, [[25, 32]]);
5765
5386
  }));
5766
- function runSubmitTempOrder(_x41) {
5387
+ function runSubmitTempOrder(_x39) {
5767
5388
  return _runSubmitTempOrder.apply(this, arguments);
5768
5389
  }
5769
5390
  return runSubmitTempOrder;
@@ -5771,10 +5392,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5771
5392
  }, {
5772
5393
  key: "markLocalOrderSynced",
5773
5394
  value: function () {
5774
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId, remoteOrder) {
5395
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(orderId, remoteOrder) {
5775
5396
  var tempOrder;
5776
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5777
- while (1) switch (_context39.prev = _context39.next) {
5397
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5398
+ while (1) switch (_context36.prev = _context36.next) {
5778
5399
  case 0:
5779
5400
  tempOrder = this.ensureTempOrder();
5780
5401
  tempOrder.order_id = orderId;
@@ -5782,15 +5403,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5782
5403
  this.store.lastOrderInfo = remoteOrder;
5783
5404
  this.store.syncState = 'submitted';
5784
5405
  this.persistTempOrder();
5785
- _context39.next = 8;
5406
+ _context36.next = 8;
5786
5407
  return this.saveDraft();
5787
5408
  case 8:
5788
5409
  case "end":
5789
- return _context39.stop();
5410
+ return _context36.stop();
5790
5411
  }
5791
- }, _callee36, this);
5412
+ }, _callee33, this);
5792
5413
  }));
5793
- function markLocalOrderSynced(_x42, _x43) {
5414
+ function markLocalOrderSynced(_x40, _x41) {
5794
5415
  return _markLocalOrderSynced.apply(this, arguments);
5795
5416
  }
5796
5417
  return markLocalOrderSynced;
@@ -5833,10 +5454,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5833
5454
  value: function extractSubmitErrorResponse(error) {
5834
5455
  var _error$response,
5835
5456
  _error$response2,
5836
- _this34 = this;
5457
+ _this31 = this;
5837
5458
  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];
5838
5459
  return candidates.find(function (candidate) {
5839
- return _this34.isSubmitErrorResponse(candidate);
5460
+ return _this31.isSubmitErrorResponse(candidate);
5840
5461
  }) || null;
5841
5462
  }
5842
5463
  }, {
@@ -5863,33 +5484,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5863
5484
  }, {
5864
5485
  key: "syncPaymentsToOrder",
5865
5486
  value: function () {
5866
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5867
- var _this35 = this,
5487
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5488
+ var _this32 = this,
5868
5489
  _params$confirmPendin;
5869
5490
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
5870
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5871
- while (1) switch (_context40.prev = _context40.next) {
5491
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5492
+ while (1) switch (_context37.prev = _context37.next) {
5872
5493
  case 0:
5873
5494
  tempOrder = this.ensureTempOrder();
5874
5495
  needsPaymentNumber = (params.payments || []).some(function (payment) {
5875
5496
  return String(payment.payment_number || '').trim() === '';
5876
5497
  });
5877
5498
  if (!needsPaymentNumber) {
5878
- _context40.next = 8;
5499
+ _context37.next = 8;
5879
5500
  break;
5880
5501
  }
5881
- _context40.next = 5;
5502
+ _context37.next = 5;
5882
5503
  return this.getPaymentNumberDevicePrefixAsync();
5883
5504
  case 5:
5884
- _context40.t0 = _context40.sent;
5885
- _context40.next = 9;
5505
+ _context37.t0 = _context37.sent;
5506
+ _context37.next = 9;
5886
5507
  break;
5887
5508
  case 8:
5888
- _context40.t0 = 'LOCAL';
5509
+ _context37.t0 = 'LOCAL';
5889
5510
  case 9:
5890
- devicePrefix = _context40.t0;
5511
+ devicePrefix = _context37.t0;
5891
5512
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5892
- return _this35.normalizePaymentSource(payment, {
5513
+ return _this32.normalizePaymentSource(payment, {
5893
5514
  defaultPaid: false,
5894
5515
  devicePrefix: devicePrefix
5895
5516
  });
@@ -5902,20 +5523,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5902
5523
  tempOrder.payments = effectivePayments;
5903
5524
  tempOrder.payment_status = paymentStatus;
5904
5525
  this.persistTempOrder();
5905
- _context40.next = 21;
5526
+ _context37.next = 21;
5906
5527
  return this.saveDraft();
5907
5528
  case 21:
5908
5529
  if (params.submitWhenPaid) {
5909
- _context40.next = 23;
5530
+ _context37.next = 23;
5910
5531
  break;
5911
5532
  }
5912
- return _context40.abrupt("return", completion);
5533
+ return _context37.abrupt("return", completion);
5913
5534
  case 23:
5914
5535
  if (!(this.store.syncState === 'submitting')) {
5915
- _context40.next = 25;
5536
+ _context37.next = 25;
5916
5537
  break;
5917
5538
  }
5918
- return _context40.abrupt("return", completion);
5539
+ return _context37.abrupt("return", completion);
5919
5540
  case 25:
5920
5541
  this.store.syncState = 'submitting';
5921
5542
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
@@ -5935,32 +5556,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5935
5556
  enhancePayload: enhancePayload
5936
5557
  };
5937
5558
  if (!(params.checkoutSyncTaskEnabled === false)) {
5938
- _context40.next = 35;
5559
+ _context37.next = 35;
5939
5560
  break;
5940
5561
  }
5941
- _context40.next = 32;
5562
+ _context37.next = 32;
5942
5563
  return this.submitTempOrderAsync(submitParams);
5943
5564
  case 32:
5944
- _context40.t1 = _context40.sent;
5945
- _context40.next = 38;
5565
+ _context37.t1 = _context37.sent;
5566
+ _context37.next = 38;
5946
5567
  break;
5947
5568
  case 35:
5948
- _context40.next = 37;
5569
+ _context37.next = 37;
5949
5570
  return this.submitTempOrder(submitParams);
5950
5571
  case 37:
5951
- _context40.t1 = _context40.sent;
5572
+ _context37.t1 = _context37.sent;
5952
5573
  case 38:
5953
- submitResult = _context40.t1;
5954
- return _context40.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5574
+ submitResult = _context37.t1;
5575
+ return _context37.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5955
5576
  submitResult: submitResult
5956
5577
  }));
5957
5578
  case 40:
5958
5579
  case "end":
5959
- return _context40.stop();
5580
+ return _context37.stop();
5960
5581
  }
5961
- }, _callee37, this);
5582
+ }, _callee34, this);
5962
5583
  }));
5963
- function syncPaymentsToOrder(_x44) {
5584
+ function syncPaymentsToOrder(_x42) {
5964
5585
  return _syncPaymentsToOrder.apply(this, arguments);
5965
5586
  }
5966
5587
  return syncPaymentsToOrder;
@@ -5968,7 +5589,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5968
5589
  }, {
5969
5590
  key: "createOrder",
5970
5591
  value: function createOrder(params) {
5971
- var _this36 = this;
5592
+ var _this33 = this;
5972
5593
  var order = _objectSpread({
5973
5594
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
5974
5595
  // 要从外面拿,virtual
@@ -6000,7 +5621,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6000
5621
 
6001
5622
  // 为预约补齐 holder 信息
6002
5623
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6003
- ensureCartItemOriginHolder(item, _this36.window);
5624
+ ensureCartItemOriginHolder(item, _this33.window);
6004
5625
  }
6005
5626
 
6006
5627
  // 购物车是否为普通商品
@@ -6057,11 +5678,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6057
5678
  }, {
6058
5679
  key: "submitOrder",
6059
5680
  value: function () {
6060
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order) {
5681
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(order) {
6061
5682
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
6062
5683
  var url, query, fetchUrl, params;
6063
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
6064
- while (1) switch (_context41.prev = _context41.next) {
5684
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5685
+ while (1) switch (_context38.prev = _context38.next) {
6065
5686
  case 0:
6066
5687
  this.logInfo('submitOrder called', {
6067
5688
  url: order.url,
@@ -6081,14 +5702,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6081
5702
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
6082
5703
  scheduleDate: params.schedule_date
6083
5704
  });
6084
- return _context41.abrupt("return", this.request.post(fetchUrl, params));
5705
+ return _context38.abrupt("return", this.request.post(fetchUrl, params));
6085
5706
  case 6:
6086
5707
  case "end":
6087
- return _context41.stop();
5708
+ return _context38.stop();
6088
5709
  }
6089
- }, _callee38, this);
5710
+ }, _callee35, this);
6090
5711
  }));
6091
- function submitOrder(_x45) {
5712
+ function submitOrder(_x43) {
6092
5713
  return _submitOrder.apply(this, arguments);
6093
5714
  }
6094
5715
  return submitOrder;
@@ -6096,13 +5717,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6096
5717
  }, {
6097
5718
  key: "cancelOrder",
6098
5719
  value: function () {
6099
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5720
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
6100
5721
  var payload;
6101
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
6102
- while (1) switch (_context42.prev = _context42.next) {
5722
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5723
+ while (1) switch (_context39.prev = _context39.next) {
6103
5724
  case 0:
6104
5725
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
6105
- _context42.next = 2;
5726
+ _context39.next = 2;
6106
5727
  break;
6107
5728
  }
6108
5729
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -6118,16 +5739,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6118
5739
  method: 'PUT',
6119
5740
  orderIdsCount: params.order_ids.length
6120
5741
  });
6121
- return _context42.abrupt("return", this.request.put('/order/update-status', payload, {
5742
+ return _context39.abrupt("return", this.request.put('/order/update-status', payload, {
6122
5743
  isShopApi: true
6123
5744
  }));
6124
5745
  case 5:
6125
5746
  case "end":
6126
- return _context42.stop();
5747
+ return _context39.stop();
6127
5748
  }
6128
- }, _callee39, this);
5749
+ }, _callee36, this);
6129
5750
  }));
6130
- function cancelOrder(_x46) {
5751
+ function cancelOrder(_x44) {
6131
5752
  return _cancelOrder.apply(this, arguments);
6132
5753
  }
6133
5754
  return cancelOrder;
@@ -6135,19 +5756,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6135
5756
  }, {
6136
5757
  key: "changeBookingStatus",
6137
5758
  value: function () {
6138
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5759
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6139
5760
  var url, payload;
6140
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
6141
- while (1) switch (_context43.prev = _context43.next) {
5761
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5762
+ while (1) switch (_context40.prev = _context40.next) {
6142
5763
  case 0:
6143
5764
  if (params.booking_id) {
6144
- _context43.next = 2;
5765
+ _context40.next = 2;
6145
5766
  break;
6146
5767
  }
6147
5768
  throw new Error('变更预约状态失败:booking_id 不能为空');
6148
5769
  case 2:
6149
5770
  if (params.appointment_status) {
6150
- _context43.next = 4;
5771
+ _context40.next = 4;
6151
5772
  break;
6152
5773
  }
6153
5774
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -6162,16 +5783,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6162
5783
  bookingId: params.booking_id,
6163
5784
  appointmentStatus: params.appointment_status
6164
5785
  });
6165
- return _context43.abrupt("return", this.request.put(url, payload, {
5786
+ return _context40.abrupt("return", this.request.put(url, payload, {
6166
5787
  isShopApi: true
6167
5788
  }));
6168
5789
  case 8:
6169
5790
  case "end":
6170
- return _context43.stop();
5791
+ return _context40.stop();
6171
5792
  }
6172
- }, _callee40, this);
5793
+ }, _callee37, this);
6173
5794
  }));
6174
- function changeBookingStatus(_x47) {
5795
+ function changeBookingStatus(_x45) {
6175
5796
  return _changeBookingStatus.apply(this, arguments);
6176
5797
  }
6177
5798
  return changeBookingStatus;
@@ -6189,11 +5810,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6189
5810
  }, {
6190
5811
  key: "createOrderByCheckout",
6191
5812
  value: (function () {
6192
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5813
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
6193
5814
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
6194
5815
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
6195
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6196
- while (1) switch (_context44.prev = _context44.next) {
5816
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5817
+ while (1) switch (_context41.prev = _context41.next) {
6197
5818
  case 0:
6198
5819
  // 过滤掉由在线店铺下单的 payment 支付数据
6199
5820
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -6218,7 +5839,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6218
5839
  return p.code;
6219
5840
  })) || []
6220
5841
  });
6221
- _context44.prev = 3;
5842
+ _context41.prev = 3;
6222
5843
  // 构建订单数据,设置默认值并允许 params 覆盖
6223
5844
  orderData = _objectSpread({
6224
5845
  sales_channel: 'my_pisel',
@@ -6266,32 +5887,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6266
5887
  hasOrderId: !!orderData.order_id,
6267
5888
  smallTicketDataFlag: orderData.small_ticket_data_flag
6268
5889
  });
6269
- _context44.next = 10;
5890
+ _context41.next = 10;
6270
5891
  return this.request.post('/order/checkout', orderData, {
6271
5892
  osServer: true,
6272
5893
  customToast: function customToast() {}
6273
5894
  });
6274
5895
  case 10:
6275
- response = _context44.sent;
5896
+ response = _context41.sent;
6276
5897
  this.logInfo('Order API called successfully', {
6277
5898
  response: response
6278
5899
  });
6279
- return _context44.abrupt("return", response);
5900
+ return _context41.abrupt("return", response);
6280
5901
  case 15:
6281
- _context44.prev = 15;
6282
- _context44.t0 = _context44["catch"](3);
6283
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context44.t0);
5902
+ _context41.prev = 15;
5903
+ _context41.t0 = _context41["catch"](3);
5904
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context41.t0);
6284
5905
  this.logInfo('Order API called failed', {
6285
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
5906
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
6286
5907
  });
6287
- throw _context44.t0;
5908
+ throw _context41.t0;
6288
5909
  case 20:
6289
5910
  case "end":
6290
- return _context44.stop();
5911
+ return _context41.stop();
6291
5912
  }
6292
- }, _callee41, this, [[3, 15]]);
5913
+ }, _callee38, this, [[3, 15]]);
6293
5914
  }));
6294
- function createOrderByCheckout(_x48) {
5915
+ function createOrderByCheckout(_x46) {
6295
5916
  return _createOrderByCheckout.apply(this, arguments);
6296
5917
  }
6297
5918
  return createOrderByCheckout;
@@ -6299,24 +5920,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6299
5920
  }, {
6300
5921
  key: "submitSalesOrder",
6301
5922
  value: function () {
6302
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5923
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6303
5924
  var url, query, fetchUrl;
6304
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6305
- while (1) switch (_context45.prev = _context45.next) {
5925
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5926
+ while (1) switch (_context42.prev = _context42.next) {
6306
5927
  case 0:
6307
5928
  url = params.url, query = params.query;
6308
5929
  fetchUrl = url || '/order/sales/checkout';
6309
- return _context45.abrupt("return", this.request.post(fetchUrl, query, {
5930
+ return _context42.abrupt("return", this.request.post(fetchUrl, query, {
6310
5931
  osServer: true,
6311
5932
  customToast: function customToast() {}
6312
5933
  }));
6313
5934
  case 3:
6314
5935
  case "end":
6315
- return _context45.stop();
5936
+ return _context42.stop();
6316
5937
  }
6317
- }, _callee42, this);
5938
+ }, _callee39, this);
6318
5939
  }));
6319
- function submitSalesOrder(_x49) {
5940
+ function submitSalesOrder(_x47) {
6320
5941
  return _submitSalesOrder.apply(this, arguments);
6321
5942
  }
6322
5943
  return submitSalesOrder;
@@ -6330,37 +5951,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6330
5951
  }, {
6331
5952
  key: "sendCustomerPayLink",
6332
5953
  value: (function () {
6333
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5954
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
6334
5955
  var _params$emails;
6335
5956
  var orderIds;
6336
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6337
- while (1) switch (_context46.prev = _context46.next) {
5957
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5958
+ while (1) switch (_context43.prev = _context43.next) {
6338
5959
  case 0:
6339
5960
  orderIds = params.order_ids || params.orderIds || [];
6340
5961
  if (orderIds.length) {
6341
- _context46.next = 3;
5962
+ _context43.next = 3;
6342
5963
  break;
6343
5964
  }
6344
5965
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
6345
5966
  case 3:
6346
5967
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
6347
- _context46.next = 5;
5968
+ _context43.next = 5;
6348
5969
  break;
6349
5970
  }
6350
5971
  throw new Error('发送支付链接需要至少一个邮箱');
6351
5972
  case 5:
6352
- return _context46.abrupt("return", this.request.post('/order/batch-email', {
5973
+ return _context43.abrupt("return", this.request.post('/order/batch-email', {
6353
5974
  order_ids: orderIds,
6354
5975
  notify_action: params.notify_action || 'order_payment_reminder',
6355
5976
  emails: params.emails
6356
5977
  }));
6357
5978
  case 6:
6358
5979
  case "end":
6359
- return _context46.stop();
5980
+ return _context43.stop();
6360
5981
  }
6361
- }, _callee43, this);
5982
+ }, _callee40, this);
6362
5983
  }));
6363
- function sendCustomerPayLink(_x50) {
5984
+ function sendCustomerPayLink(_x48) {
6364
5985
  return _sendCustomerPayLink.apply(this, arguments);
6365
5986
  }
6366
5987
  return sendCustomerPayLink;
@@ -6368,14 +5989,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6368
5989
  }, {
6369
5990
  key: "getSalesOrderByLookup",
6370
5991
  value: function () {
6371
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
5992
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
6372
5993
  var lookup, res;
6373
- return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6374
- while (1) switch (_context47.prev = _context47.next) {
5994
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5995
+ while (1) switch (_context44.prev = _context44.next) {
6375
5996
  case 0:
6376
5997
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
6377
5998
  if (lookup) {
6378
- _context47.next = 3;
5999
+ _context44.next = 3;
6379
6000
  break;
6380
6001
  }
6381
6002
  throw new Error('加载销售详情需要 lookup');
@@ -6384,27 +6005,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6384
6005
  if (lookup.startsWith('LOCAL_')) {
6385
6006
  params.forceRemote = false;
6386
6007
  }
6387
- _context47.next = 6;
6008
+ _context44.next = 6;
6388
6009
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
6389
- with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes']
6010
+ with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
6390
6011
  }, params.forceRemote ? {
6391
6012
  forceRemote: true
6392
6013
  } : {}), {
6393
6014
  osServer: true
6394
6015
  });
6395
6016
  case 6:
6396
- res = _context47.sent;
6017
+ res = _context44.sent;
6397
6018
  if (res.code === 200) {
6398
6019
  this.store.lastOrderInfo = res.data;
6399
6020
  }
6400
- return _context47.abrupt("return", res);
6021
+ return _context44.abrupt("return", res);
6401
6022
  case 9:
6402
6023
  case "end":
6403
- return _context47.stop();
6024
+ return _context44.stop();
6404
6025
  }
6405
- }, _callee44, this);
6026
+ }, _callee41, this);
6406
6027
  }));
6407
- function getSalesOrderByLookup(_x51) {
6028
+ function getSalesOrderByLookup(_x49) {
6408
6029
  return _getSalesOrderByLookup.apply(this, arguments);
6409
6030
  }
6410
6031
  return getSalesOrderByLookup;
@@ -6418,11 +6039,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6418
6039
  }, {
6419
6040
  key: "hydrateTempOrderFromRecord",
6420
6041
  value: (function () {
6421
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(record, options) {
6042
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(record, options) {
6422
6043
  var _sourceRaw$_extend, _this$store$discount22;
6423
6044
  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) {
6045
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6046
+ while (1) switch (_context45.prev = _context45.next) {
6426
6047
  case 0:
6427
6048
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
6428
6049
  duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
@@ -6458,12 +6079,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6458
6079
  isMergedSalesDetailHydrate = (options === null || options === void 0 ? void 0 : options.source) === 'mergedSalesDetail';
6459
6080
  nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
6460
6081
  // merge 前已只给远端商品补标记;这里不能把本地未提交商品一并变成 saved item。
6461
- makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate,
6462
- allowUnresolvedSalesNotes: isSessionStorageHydrate
6082
+ makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate
6463
6083
  });
6464
6084
  this.store.tempOrder = nextTempOrder;
6465
6085
  if (!isSessionStorageHydrate) {
6466
- _context48.next = 30;
6086
+ _context45.next = 30;
6467
6087
  break;
6468
6088
  }
6469
6089
  // 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
@@ -6479,23 +6099,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6479
6099
  nextTempOrder.discount_list = restoredSessionDiscounts;
6480
6100
  this.store.summary = createEmptySummary();
6481
6101
  this.store.lastOrderInfo = undefined;
6482
- _context48.next = 23;
6102
+ _context45.next = 23;
6483
6103
  return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
6484
6104
  case 23:
6485
- _context48.next = 25;
6105
+ _context45.next = 25;
6486
6106
  return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(cloneDeep(restoredSessionDiscounts));
6487
6107
  case 25:
6488
6108
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6489
- _context48.next = 28;
6109
+ _context45.next = 28;
6490
6110
  break;
6491
6111
  }
6492
- _context48.next = 28;
6112
+ _context45.next = 28;
6493
6113
  return this.recalculateSummary({
6494
6114
  createIfMissing: false
6495
6115
  });
6496
6116
  case 28:
6497
6117
  this.persistTempOrder();
6498
- return _context48.abrupt("return", nextTempOrder);
6118
+ return _context45.abrupt("return", nextTempOrder);
6499
6119
  case 30:
6500
6120
  // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
6501
6121
  sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
@@ -6547,34 +6167,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6547
6167
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
6548
6168
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
6549
6169
  if (shouldSkipEmptyDiscountSync) {
6550
- _context48.next = 54;
6170
+ _context45.next = 54;
6551
6171
  break;
6552
6172
  }
6553
6173
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
6554
- _context48.next = 52;
6174
+ _context45.next = 52;
6555
6175
  return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList(nextDiscounts);
6556
6176
  case 52:
6557
- _context48.next = 54;
6177
+ _context45.next = 54;
6558
6178
  return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setDiscountList(nextDiscounts);
6559
6179
  case 54:
6560
6180
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6561
- _context48.next = 57;
6181
+ _context45.next = 57;
6562
6182
  break;
6563
6183
  }
6564
- _context48.next = 57;
6184
+ _context45.next = 57;
6565
6185
  return this.recalculateSummary({
6566
6186
  createIfMissing: false
6567
6187
  });
6568
6188
  case 57:
6569
6189
  this.persistTempOrder();
6570
- return _context48.abrupt("return", nextTempOrder);
6190
+ return _context45.abrupt("return", nextTempOrder);
6571
6191
  case 59:
6572
6192
  case "end":
6573
- return _context48.stop();
6193
+ return _context45.stop();
6574
6194
  }
6575
- }, _callee45, this);
6195
+ }, _callee42, this);
6576
6196
  }));
6577
- function hydrateTempOrderFromRecord(_x52, _x53) {
6197
+ function hydrateTempOrderFromRecord(_x50, _x51) {
6578
6198
  return _hydrateTempOrderFromRecord.apply(this, arguments);
6579
6199
  }
6580
6200
  return hydrateTempOrderFromRecord;
@@ -6627,10 +6247,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6627
6247
  _step22;
6628
6248
  try {
6629
6249
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
6630
- var _product$metadata10;
6250
+ var _product$metadata8;
6631
6251
  var product = _step22.value;
6632
6252
  var productUid = getOrderCollectionUid('product', product);
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);
6253
+ 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);
6634
6254
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
6635
6255
  continue;
6636
6256
  }
@@ -6688,8 +6308,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6688
6308
  }, {
6689
6309
  key: "normalizeTempOrderForRuntime",
6690
6310
  value: function normalizeTempOrderForRuntime(raw, options) {
6691
- var _this37 = this,
6692
- _raw$_extend;
6311
+ var _this34 = this;
6693
6312
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6694
6313
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
6695
6314
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
@@ -6713,12 +6332,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6713
6332
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
6714
6333
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
6715
6334
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
6716
- return _this37.normalizeHydratedOrderProduct(p, {
6335
+ return _this34.normalizeHydratedOrderProduct(p, {
6717
6336
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
6718
6337
  });
6719
6338
  }) : [];
6720
6339
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
6721
- var booking = _this37.normalizeHydratedBookingHolder(b || {});
6340
+ var booking = _this34.normalizeHydratedBookingHolder(b || {});
6722
6341
  return _objectSpread(_objectSpread({}, booking), {}, {
6723
6342
  is_all: normalizeBookingIsAll(booking),
6724
6343
  sub_type: normalizeBookingSubType(booking)
@@ -6727,21 +6346,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6727
6346
  nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
6728
6347
  return _objectSpread({}, p || {});
6729
6348
  }) : [];
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;
6745
6349
  nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
6746
6350
  return _objectSpread({}, s || {});
6747
6351
  }) : [];
@@ -6758,20 +6362,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6758
6362
  productsByUid: {}
6759
6363
  };
6760
6364
  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
- };
6765
6365
  var productsByUid = tempOrderExtend.productsByUid || {};
6766
6366
  var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
6767
6367
  _step24;
6768
6368
  try {
6769
6369
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6770
- var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
6370
+ var _product$metadata9, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
6771
6371
  var _step24$value = _slicedToArray(_step24.value, 2),
6772
6372
  index = _step24$value[0],
6773
6373
  product = _step24$value[1];
6774
- var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
6374
+ var uid = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.unique_identification_number;
6775
6375
  if (!uid) continue;
6776
6376
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6777
6377
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
@@ -6826,8 +6426,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6826
6426
  var bookingUidByProductUid = new Map();
6827
6427
  var productByUid = new Map();
6828
6428
  (tempOrder.products || []).forEach(function (product) {
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);
6429
+ var _product$metadata10;
6430
+ 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);
6831
6431
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
6832
6432
  productByUid.set(String(productUid), product);
6833
6433
  }
@@ -6848,8 +6448,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6848
6448
  bookingUidByProductUid.set(String(productUid), bookingUid);
6849
6449
  });
6850
6450
  (tempOrder.products || []).forEach(function (product) {
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);
6451
+ var _product$metadata11;
6452
+ 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);
6853
6453
  if (productUid === undefined || productUid === null || String(productUid) === '') return;
6854
6454
  var bookingUid = bookingUidByProductUid.get(String(productUid));
6855
6455
  if (!bookingUid) return;
@@ -6924,7 +6524,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6924
6524
  }, {
6925
6525
  key: "normalizeHydratedOrderProduct",
6926
6526
  value: function normalizeHydratedOrderProduct(product, options) {
6927
- var _this38 = this;
6527
+ var _this35 = this;
6928
6528
  var row = _objectSpread({}, product || {});
6929
6529
  if (row.num === undefined && row.product_quantity !== undefined) {
6930
6530
  row.num = row.product_quantity;
@@ -6932,7 +6532,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6932
6532
  var productSku = ensureProductSku(row);
6933
6533
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
6934
6534
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
6935
- return _this38.normalizeHydratedProductOptionItem(optionItem || {});
6535
+ return _this35.normalizeHydratedProductOptionItem(optionItem || {});
6936
6536
  }))
6937
6537
  });
6938
6538
  delete row["product_".concat('option', "_item")];
@@ -6972,27 +6572,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6972
6572
  }, {
6973
6573
  key: "getOrderInfo",
6974
6574
  value: function () {
6975
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order_id) {
6575
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(order_id) {
6976
6576
  var res;
6977
- return _regeneratorRuntime().wrap(function _callee46$(_context49) {
6978
- while (1) switch (_context49.prev = _context49.next) {
6577
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6578
+ while (1) switch (_context46.prev = _context46.next) {
6979
6579
  case 0:
6980
- _context49.next = 2;
6580
+ _context46.next = 2;
6981
6581
  return this.request.get("/order/sales/".concat(order_id), {
6982
- with: ['products', 'bookings', 'notes']
6582
+ with: ['products', 'bookings']
6983
6583
  }, {
6984
6584
  osServer: true
6985
6585
  });
6986
6586
  case 2:
6987
- res = _context49.sent;
6988
- return _context49.abrupt("return", res);
6587
+ res = _context46.sent;
6588
+ return _context46.abrupt("return", res);
6989
6589
  case 4:
6990
6590
  case "end":
6991
- return _context49.stop();
6591
+ return _context46.stop();
6992
6592
  }
6993
- }, _callee46, this);
6593
+ }, _callee43, this);
6994
6594
  }));
6995
- function getOrderInfo(_x54) {
6595
+ function getOrderInfo(_x52) {
6996
6596
  return _getOrderInfo.apply(this, arguments);
6997
6597
  }
6998
6598
  return getOrderInfo;