@pisell/pisellos 2.2.318 → 2.2.320

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 (35) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  2. package/dist/model/strategy/adapter/promotion/evaluator.js +19 -12
  3. package/dist/modules/Discount/types.d.ts +4 -0
  4. package/dist/modules/Order/index.js +740 -775
  5. package/dist/modules/Order/types.d.ts +2 -2
  6. package/dist/modules/Order/types.js +2 -2
  7. package/dist/modules/Order/utils.js +45 -45
  8. package/dist/modules/Payment/walletpass.js +32 -6
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Rules/index.d.ts +3 -10
  11. package/dist/modules/Rules/index.js +169 -87
  12. package/dist/modules/Rules/promotionSelection.d.ts +14 -0
  13. package/dist/modules/Rules/promotionSelection.js +390 -0
  14. package/dist/modules/Rules/types.d.ts +9 -0
  15. package/dist/solution/BaseSales/index.js +41 -21
  16. package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
  17. package/dist/solution/BookingByStep/index.d.ts +2 -2
  18. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
  19. package/lib/model/strategy/adapter/promotion/evaluator.js +18 -11
  20. package/lib/modules/Discount/types.d.ts +4 -0
  21. package/lib/modules/Order/index.js +13 -8
  22. package/lib/modules/Order/types.d.ts +2 -2
  23. package/lib/modules/Order/types.js +2 -2
  24. package/lib/modules/Order/utils.js +1 -1
  25. package/lib/modules/Payment/walletpass.js +23 -1
  26. package/lib/modules/Product/index.d.ts +1 -1
  27. package/lib/modules/Rules/index.d.ts +3 -10
  28. package/lib/modules/Rules/index.js +62 -22
  29. package/lib/modules/Rules/promotionSelection.d.ts +14 -0
  30. package/lib/modules/Rules/promotionSelection.js +230 -0
  31. package/lib/modules/Rules/types.d.ts +9 -0
  32. package/lib/solution/BaseSales/index.js +19 -5
  33. package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
  34. package/lib/solution/BookingByStep/index.d.ts +2 -2
  35. package/package.json +1 -1
@@ -676,7 +676,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
676
676
  _this$store$discount,
677
677
  _this4 = this,
678
678
  _this$store$tempOrder2;
679
- var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
679
+ var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentPromotionSelections, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
680
680
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
681
681
  while (1) switch (_context3.prev = _context3.next) {
682
682
  case 0:
@@ -721,10 +721,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
721
721
  });
722
722
  }
723
723
  if (!discountList) {
724
- _context3.next = 32;
724
+ _context3.next = 33;
725
725
  break;
726
726
  }
727
727
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
728
+ currentPromotionSelections = new Map(currentDiscountList.filter(function (discount) {
729
+ return !discount.isEditMode && discount.promotionSelection;
730
+ }).map(function (discount) {
731
+ return [String(discount.id), discount];
732
+ }));
728
733
  currentCommittedDiscounts = currentDiscountList.filter(function (discount) {
729
734
  var _discount$committedAp;
730
735
  return (discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 || (_discount$committedAp = discount.committedAppliedProductDetails) === null || _discount$committedAp === void 0 ? void 0 : _discount$committedAp.length);
@@ -767,6 +772,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
767
772
  isManualSelect: (_currentScanDiscount$2 = currentScanDiscount.isManualSelect) !== null && _currentScanDiscount$2 !== void 0 ? _currentScanDiscount$2 : nextDiscount.isManualSelect
768
773
  });
769
774
  }
775
+ var currentSelection = currentPromotionSelections.get(String(discount.id));
776
+ if (currentSelection) {
777
+ nextDiscount = _objectSpread(_objectSpread({}, nextDiscount), {}, {
778
+ promotionSelection: currentSelection.promotionSelection,
779
+ promotionSelectionStrategyIds: currentSelection.promotionSelectionStrategyIds,
780
+ isManualSelect: currentSelection.isManualSelect,
781
+ isSelected: currentSelection.isSelected
782
+ });
783
+ }
770
784
  return [nextDiscount];
771
785
  });
772
786
  retainedCommittedDiscounts = currentCommittedDiscounts.filter(function (discount) {
@@ -788,34 +802,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
788
802
  });
789
803
  mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
790
804
  if (isCurrentRequest()) {
791
- _context3.next = 26;
805
+ _context3.next = 27;
792
806
  break;
793
807
  }
794
808
  return _context3.abrupt("return", this.getDiscountList());
795
- case 26:
796
- _context3.next = 28;
809
+ case 27:
810
+ _context3.next = 29;
797
811
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
798
- case 28:
812
+ case 29:
799
813
  if (isCurrentRequest()) {
800
- _context3.next = 30;
814
+ _context3.next = 31;
801
815
  break;
802
816
  }
803
817
  return _context3.abrupt("return", this.getDiscountList());
804
- case 30:
805
- _context3.next = 32;
818
+ case 31:
819
+ _context3.next = 33;
806
820
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
807
- case 32:
821
+ case 33:
808
822
  if (isCurrentRequest()) {
809
- _context3.next = 34;
823
+ _context3.next = 35;
810
824
  break;
811
825
  }
812
826
  return _context3.abrupt("return", this.getDiscountList());
813
- case 34:
827
+ case 35:
814
828
  if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
815
829
  this.applyDiscount();
816
830
  }
817
831
  return _context3.abrupt("return", this.getDiscountList());
818
- case 36:
832
+ case 37:
819
833
  case "end":
820
834
  return _context3.stop();
821
835
  }
@@ -1242,54 +1256,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1242
1256
  key: "evaluatePromotion",
1243
1257
  value: (function () {
1244
1258
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options) {
1245
- var _this$promotionEvalua,
1246
- _this$promotionEvalua2,
1247
- _this6 = this;
1248
- var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, _ret, payload;
1249
- return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1250
- while (1) switch (_context9.prev = _context9.next) {
1259
+ var _this$promotionEvalua, _this$promotionEvalua2;
1260
+ var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop, _iterator4, _step4, addAction, giftMutationBaseline, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked, payload;
1261
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
1262
+ while (1) switch (_context8.prev = _context8.next) {
1251
1263
  case 0:
1252
1264
  if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1253
- _context9.next = 2;
1265
+ _context8.next = 2;
1254
1266
  break;
1255
1267
  }
1256
- return _context9.abrupt("return", null);
1268
+ return _context8.abrupt("return", null);
1257
1269
  case 2:
1258
1270
  if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
1259
- _context9.next = 4;
1271
+ _context8.next = 4;
1260
1272
  break;
1261
1273
  }
1262
- return _context9.abrupt("return", null);
1274
+ return _context8.abrupt("return", null);
1263
1275
  case 4:
1264
1276
  if (this.promotionEvaluator) {
1265
- _context9.next = 6;
1277
+ _context8.next = 6;
1266
1278
  break;
1267
1279
  }
1268
- return _context9.abrupt("return", null);
1280
+ return _context8.abrupt("return", null);
1269
1281
  case 6:
1270
1282
  tempOrder = this.store.tempOrder;
1271
1283
  if (tempOrder) {
1272
- _context9.next = 9;
1284
+ _context8.next = 9;
1273
1285
  break;
1274
1286
  }
1275
- return _context9.abrupt("return", null);
1287
+ return _context8.abrupt("return", null);
1276
1288
  case 9:
1277
1289
  if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
1278
- _context9.next = 12;
1290
+ _context8.next = 12;
1279
1291
  break;
1280
1292
  }
1281
1293
  tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
1282
- return _context9.abrupt("return", null);
1294
+ return _context8.abrupt("return", null);
1283
1295
  case 12:
1284
1296
  strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
1285
1297
  if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
1286
- _context9.next = 15;
1298
+ _context8.next = 15;
1287
1299
  break;
1288
1300
  }
1289
- return _context9.abrupt("return", null);
1301
+ return _context8.abrupt("return", null);
1290
1302
  case 15:
1291
1303
  this.isApplyingPromotion = true;
1292
- _context9.prev = 16;
1304
+ _context8.prev = 16;
1293
1305
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
1294
1306
  if (result.giftActions.toRemove.length > 0) {
1295
1307
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -1301,20 +1313,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1301
1313
 
1302
1314
  // step 2: toReduce —— 调整数量
1303
1315
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
1304
- _context9.prev = 20;
1316
+ _context8.prev = 20;
1305
1317
  _iterator3.s();
1306
1318
  case 22:
1307
1319
  if ((_step3 = _iterator3.n()).done) {
1308
- _context9.next = 42;
1320
+ _context8.next = 42;
1309
1321
  break;
1310
1322
  }
1311
1323
  reduce = _step3.value;
1312
1324
  _iterator6 = _createForOfIteratorHelper(reduce.items);
1313
- _context9.prev = 25;
1314
- _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
1325
+ _context8.prev = 25;
1326
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1315
1327
  var item, product;
1316
- return _regeneratorRuntime().wrap(function _loop2$(_context8) {
1317
- while (1) switch (_context8.prev = _context8.next) {
1328
+ return _regeneratorRuntime().wrap(function _loop$(_context7) {
1329
+ while (1) switch (_context7.prev = _context7.next) {
1318
1330
  case 0:
1319
1331
  item = _step6.value;
1320
1332
  product = result.products.find(function (p) {
@@ -1325,52 +1337,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1325
1337
  }
1326
1338
  case 3:
1327
1339
  case "end":
1328
- return _context8.stop();
1340
+ return _context7.stop();
1329
1341
  }
1330
- }, _loop2);
1342
+ }, _loop);
1331
1343
  });
1332
1344
  _iterator6.s();
1333
1345
  case 28:
1334
1346
  if ((_step6 = _iterator6.n()).done) {
1335
- _context9.next = 32;
1347
+ _context8.next = 32;
1336
1348
  break;
1337
1349
  }
1338
- return _context9.delegateYield(_loop2(), "t0", 30);
1350
+ return _context8.delegateYield(_loop(), "t0", 30);
1339
1351
  case 30:
1340
- _context9.next = 28;
1352
+ _context8.next = 28;
1341
1353
  break;
1342
1354
  case 32:
1343
- _context9.next = 37;
1355
+ _context8.next = 37;
1344
1356
  break;
1345
1357
  case 34:
1346
- _context9.prev = 34;
1347
- _context9.t1 = _context9["catch"](25);
1348
- _iterator6.e(_context9.t1);
1358
+ _context8.prev = 34;
1359
+ _context8.t1 = _context8["catch"](25);
1360
+ _iterator6.e(_context8.t1);
1349
1361
  case 37:
1350
- _context9.prev = 37;
1362
+ _context8.prev = 37;
1351
1363
  _iterator6.f();
1352
- return _context9.finish(37);
1364
+ return _context8.finish(37);
1353
1365
  case 40:
1354
- _context9.next = 22;
1366
+ _context8.next = 22;
1355
1367
  break;
1356
1368
  case 42:
1357
- _context9.next = 47;
1369
+ _context8.next = 47;
1358
1370
  break;
1359
1371
  case 44:
1360
- _context9.prev = 44;
1361
- _context9.t2 = _context9["catch"](20);
1362
- _iterator3.e(_context9.t2);
1372
+ _context8.prev = 44;
1373
+ _context8.t2 = _context8["catch"](20);
1374
+ _iterator3.e(_context8.t2);
1363
1375
  case 47:
1364
- _context9.prev = 47;
1376
+ _context8.prev = 47;
1365
1377
  _iterator3.f();
1366
- return _context9.finish(47);
1378
+ return _context8.finish(47);
1367
1379
  case 50:
1368
1380
  if (!(result.giftActions.toAdd.length > 0)) {
1369
- _context9.next = 76;
1381
+ _context8.next = 115;
1370
1382
  break;
1371
1383
  }
1372
1384
  if (this.giftSelectResolver) {
1373
- _context9.next = 55;
1385
+ _context8.next = 55;
1374
1386
  break;
1375
1387
  }
1376
1388
  if (result.giftActions.toAdd.some(function (g) {
@@ -1381,190 +1393,143 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1381
1393
  } else {
1382
1394
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
1383
1395
  }
1384
- _context9.next = 76;
1396
+ _context8.next = 115;
1385
1397
  break;
1386
1398
  case 55:
1387
1399
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
1388
- _context9.prev = 56;
1389
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1390
- var addAction, _sameStrategy$metadat, sameStrategy, giftMutationBaseline, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
1391
- return _regeneratorRuntime().wrap(function _loop$(_context7) {
1392
- while (1) switch (_context7.prev = _context7.next) {
1393
- case 0:
1394
- addAction = _step4.value;
1395
- if (!(addAction.giftOptions.length === 1)) {
1396
- _context7.next = 6;
1397
- break;
1398
- }
1399
- sameStrategy = result.products.find(function (p) {
1400
- var _p$metadata;
1401
- return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
1402
- });
1403
- if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
1404
- _context7.next = 6;
1405
- break;
1406
- }
1407
- sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
1408
- return _context7.abrupt("return", 0);
1409
- case 6:
1410
- giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
1411
- products: tempOrder.products,
1412
- bookings: tempOrder.bookings
1413
- }) : null;
1414
- _context7.prev = 7;
1415
- _context7.next = 10;
1416
- return _this6.giftSelectResolver({
1417
- strategyId: addAction.strategyId,
1418
- strategyName: addAction.strategyName,
1419
- giftCount: addAction.giftCount,
1420
- giftOptions: addAction.giftOptions,
1421
- sourceProductIds: addAction.sourceProductIds
1422
- });
1423
- case 10:
1424
- giftResult = _context7.sent;
1425
- if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1426
- _context7.next = 13;
1427
- break;
1428
- }
1429
- return _context7.abrupt("return", {
1430
- v: null
1431
- });
1432
- case 13:
1433
- if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
1434
- products: tempOrder.products,
1435
- bookings: tempOrder.bookings
1436
- }, giftMutationBaseline))) {
1437
- _context7.next = 15;
1438
- break;
1439
- }
1440
- return _context7.abrupt("return", {
1441
- v: null
1442
- });
1443
- case 15:
1444
- giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
1445
- giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
1446
- if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
1447
- _context7.next = 42;
1448
- break;
1449
- }
1450
- _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
1451
- _context7.prev = 19;
1452
- _iterator5.s();
1453
- case 21:
1454
- if ((_step5 = _iterator5.n()).done) {
1455
- _context7.next = 34;
1456
- break;
1457
- }
1458
- _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
1459
- if (gp) {
1460
- _context7.next = 25;
1461
- break;
1462
- }
1463
- return _context7.abrupt("continue", 32);
1464
- case 25:
1465
- booking = giftBookings[index];
1466
- if (!booking) {
1467
- _context7.next = 31;
1468
- break;
1469
- }
1470
- linked = _this6.createLinkedProductAndBooking({
1471
- product: gp,
1472
- booking: booking
1473
- });
1474
- result.products.push(linked.product);
1475
- tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1476
- return _context7.abrupt("continue", 32);
1477
- case 31:
1478
- // normalize 略过:调用方应保证返回完整 OrderProduct。
1479
- result.products.push(gp);
1480
- case 32:
1481
- _context7.next = 21;
1482
- break;
1483
- case 34:
1484
- _context7.next = 39;
1485
- break;
1486
- case 36:
1487
- _context7.prev = 36;
1488
- _context7.t0 = _context7["catch"](19);
1489
- _iterator5.e(_context7.t0);
1490
- case 39:
1491
- _context7.prev = 39;
1492
- _iterator5.f();
1493
- return _context7.finish(39);
1494
- case 42:
1495
- _context7.next = 51;
1496
- break;
1497
- case 44:
1498
- _context7.prev = 44;
1499
- _context7.t1 = _context7["catch"](7);
1500
- if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1501
- _context7.next = 48;
1502
- break;
1503
- }
1504
- return _context7.abrupt("return", {
1505
- v: null
1506
- });
1507
- case 48:
1508
- if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
1509
- products: tempOrder.products,
1510
- bookings: tempOrder.bookings
1511
- }, giftMutationBaseline))) {
1512
- _context7.next = 50;
1513
- break;
1514
- }
1515
- return _context7.abrupt("return", {
1516
- v: null
1517
- });
1518
- case 50:
1519
- // 用户取消 / 选择失败 → 视为放弃本次新增
1520
- console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
1521
- case 51:
1522
- case "end":
1523
- return _context7.stop();
1524
- }
1525
- }, _loop, null, [[7, 44], [19, 36, 39, 42]]);
1526
- });
1400
+ _context8.prev = 56;
1527
1401
  _iterator4.s();
1528
- case 59:
1402
+ case 58:
1529
1403
  if ((_step4 = _iterator4.n()).done) {
1530
- _context9.next = 68;
1404
+ _context8.next = 107;
1531
1405
  break;
1532
1406
  }
1533
- return _context9.delegateYield(_loop(), "t3", 61);
1534
- case 61:
1535
- _ret = _context9.t3;
1536
- if (!(_ret === 0)) {
1537
- _context9.next = 64;
1407
+ addAction = _step4.value;
1408
+ // 唯一候选也可能有规格/套餐。每次补赠都交给 SDK 判断,不能复用旧赠品的选择。
1409
+ giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
1410
+ products: tempOrder.products,
1411
+ bookings: tempOrder.bookings
1412
+ }) : null;
1413
+ _context8.prev = 61;
1414
+ _context8.next = 64;
1415
+ return this.giftSelectResolver({
1416
+ strategyId: addAction.strategyId,
1417
+ strategyName: addAction.strategyName,
1418
+ giftCount: addAction.giftCount,
1419
+ giftOptions: addAction.giftOptions,
1420
+ sourceProductIds: addAction.sourceProductIds
1421
+ });
1422
+ case 64:
1423
+ giftResult = _context8.sent;
1424
+ if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1425
+ _context8.next = 67;
1538
1426
  break;
1539
1427
  }
1540
- return _context9.abrupt("continue", 66);
1541
- case 64:
1542
- if (!_ret) {
1543
- _context9.next = 66;
1428
+ return _context8.abrupt("return", null);
1429
+ case 67:
1430
+ if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
1431
+ products: tempOrder.products,
1432
+ bookings: tempOrder.bookings
1433
+ }, giftMutationBaseline))) {
1434
+ _context8.next = 69;
1544
1435
  break;
1545
1436
  }
1546
- return _context9.abrupt("return", _ret.v);
1547
- case 66:
1548
- _context9.next = 59;
1437
+ return _context8.abrupt("return", null);
1438
+ case 69:
1439
+ giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
1440
+ giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
1441
+ if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
1442
+ _context8.next = 96;
1443
+ break;
1444
+ }
1445
+ _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
1446
+ _context8.prev = 73;
1447
+ _iterator5.s();
1448
+ case 75:
1449
+ if ((_step5 = _iterator5.n()).done) {
1450
+ _context8.next = 88;
1451
+ break;
1452
+ }
1453
+ _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
1454
+ if (gp) {
1455
+ _context8.next = 79;
1456
+ break;
1457
+ }
1458
+ return _context8.abrupt("continue", 86);
1459
+ case 79:
1460
+ booking = giftBookings[index];
1461
+ if (!booking) {
1462
+ _context8.next = 85;
1463
+ break;
1464
+ }
1465
+ linked = this.createLinkedProductAndBooking({
1466
+ product: gp,
1467
+ booking: booking
1468
+ });
1469
+ result.products.push(linked.product);
1470
+ tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1471
+ return _context8.abrupt("continue", 86);
1472
+ case 85:
1473
+ // normalize 略过:调用方应保证返回完整 OrderProduct。
1474
+ result.products.push(gp);
1475
+ case 86:
1476
+ _context8.next = 75;
1549
1477
  break;
1550
- case 68:
1551
- _context9.next = 73;
1478
+ case 88:
1479
+ _context8.next = 93;
1552
1480
  break;
1553
- case 70:
1554
- _context9.prev = 70;
1555
- _context9.t4 = _context9["catch"](56);
1556
- _iterator4.e(_context9.t4);
1557
- case 73:
1558
- _context9.prev = 73;
1481
+ case 90:
1482
+ _context8.prev = 90;
1483
+ _context8.t3 = _context8["catch"](73);
1484
+ _iterator5.e(_context8.t3);
1485
+ case 93:
1486
+ _context8.prev = 93;
1487
+ _iterator5.f();
1488
+ return _context8.finish(93);
1489
+ case 96:
1490
+ _context8.next = 105;
1491
+ break;
1492
+ case 98:
1493
+ _context8.prev = 98;
1494
+ _context8.t4 = _context8["catch"](61);
1495
+ if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1496
+ _context8.next = 102;
1497
+ break;
1498
+ }
1499
+ return _context8.abrupt("return", null);
1500
+ case 102:
1501
+ if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
1502
+ products: tempOrder.products,
1503
+ bookings: tempOrder.bookings
1504
+ }, giftMutationBaseline))) {
1505
+ _context8.next = 104;
1506
+ break;
1507
+ }
1508
+ return _context8.abrupt("return", null);
1509
+ case 104:
1510
+ // 用户取消 / 选择失败 → 视为放弃本次新增
1511
+ console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context8.t4);
1512
+ case 105:
1513
+ _context8.next = 58;
1514
+ break;
1515
+ case 107:
1516
+ _context8.next = 112;
1517
+ break;
1518
+ case 109:
1519
+ _context8.prev = 109;
1520
+ _context8.t5 = _context8["catch"](56);
1521
+ _iterator4.e(_context8.t5);
1522
+ case 112:
1523
+ _context8.prev = 112;
1559
1524
  _iterator4.f();
1560
- return _context9.finish(73);
1561
- case 76:
1525
+ return _context8.finish(112);
1526
+ case 115:
1562
1527
  if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
1563
- _context9.next = 78;
1528
+ _context8.next = 117;
1564
1529
  break;
1565
1530
  }
1566
- return _context9.abrupt("return", null);
1567
- case 78:
1531
+ return _context8.abrupt("return", null);
1532
+ case 117:
1568
1533
  tempOrder.products = result.products;
1569
1534
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
1570
1535
  this.lastGiftActions = result.giftActions;
@@ -1581,21 +1546,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1581
1546
  }),
1582
1547
  products: tempOrder.products
1583
1548
  };
1584
- return _context9.abrupt("return", payload);
1585
- case 85:
1586
- _context9.prev = 85;
1587
- _context9.t5 = _context9["catch"](16);
1588
- console.error('[OrderModule] applyPromotion failed', _context9.t5);
1589
- return _context9.abrupt("return", null);
1590
- case 89:
1591
- _context9.prev = 89;
1549
+ return _context8.abrupt("return", payload);
1550
+ case 124:
1551
+ _context8.prev = 124;
1552
+ _context8.t6 = _context8["catch"](16);
1553
+ console.error('[OrderModule] applyPromotion failed', _context8.t6);
1554
+ return _context8.abrupt("return", null);
1555
+ case 128:
1556
+ _context8.prev = 128;
1592
1557
  this.isApplyingPromotion = false;
1593
- return _context9.finish(89);
1594
- case 92:
1558
+ return _context8.finish(128);
1559
+ case 131:
1595
1560
  case "end":
1596
- return _context9.stop();
1561
+ return _context8.stop();
1597
1562
  }
1598
- }, _callee7, this, [[16, 85, 89, 92], [20, 44, 47, 50], [25, 34, 37, 40], [56, 70, 73, 76]]);
1563
+ }, _callee7, this, [[16, 124, 128, 131], [20, 44, 47, 50], [25, 34, 37, 40], [56, 109, 112, 115], [61, 98], [73, 90, 93, 96]]);
1599
1564
  }));
1600
1565
  function evaluatePromotion(_x8) {
1601
1566
  return _evaluatePromotion.apply(this, arguments);
@@ -1625,29 +1590,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1625
1590
  value: (function () {
1626
1591
  var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1627
1592
  var payload, tempOrder;
1628
- return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1629
- while (1) switch (_context10.prev = _context10.next) {
1593
+ return _regeneratorRuntime().wrap(function _callee8$(_context9) {
1594
+ while (1) switch (_context9.prev = _context9.next) {
1630
1595
  case 0:
1631
- _context10.next = 2;
1596
+ _context9.next = 2;
1632
1597
  return this.evaluatePromotion();
1633
1598
  case 2:
1634
- payload = _context10.sent;
1599
+ payload = _context9.sent;
1635
1600
  if (payload) {
1636
- _context10.next = 5;
1601
+ _context9.next = 5;
1637
1602
  break;
1638
1603
  }
1639
- return _context10.abrupt("return");
1604
+ return _context9.abrupt("return");
1640
1605
  case 5:
1641
1606
  tempOrder = this.store.tempOrder;
1642
1607
  if (tempOrder) {
1643
- _context10.next = 8;
1608
+ _context9.next = 8;
1644
1609
  break;
1645
1610
  }
1646
- return _context10.abrupt("return");
1611
+ return _context9.abrupt("return");
1647
1612
  case 8:
1648
1613
  this.applyDiscount();
1649
1614
  this.sanitizeTempOrderProducts(tempOrder);
1650
- _context10.next = 12;
1615
+ _context9.next = 12;
1651
1616
  return this.recalculateSummary({
1652
1617
  createIfMissing: true
1653
1618
  });
@@ -1656,7 +1621,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1656
1621
  this.emitPromotionApplied(payload);
1657
1622
  case 14:
1658
1623
  case "end":
1659
- return _context10.stop();
1624
+ return _context9.stop();
1660
1625
  }
1661
1626
  }, _callee8, this);
1662
1627
  }));
@@ -1831,12 +1796,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1831
1796
  }, {
1832
1797
  key: "rememberPointCardSnapshotCodeCandidates",
1833
1798
  value: function rememberPointCardSnapshotCodeCandidates(value) {
1834
- var _this7 = this;
1799
+ var _this6 = this;
1835
1800
  collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1836
1801
  var id = _ref18.id,
1837
1802
  code = _ref18.code;
1838
- if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
1839
- _this7.pointCardSnapshotCodeCandidates.set(id, code);
1803
+ if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
1804
+ _this6.pointCardSnapshotCodeCandidates.set(id, code);
1840
1805
  }
1841
1806
  });
1842
1807
  }
@@ -1985,11 +1950,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1985
1950
  key: "saveDraft",
1986
1951
  value: function () {
1987
1952
  var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1988
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
1989
- while (1) switch (_context11.prev = _context11.next) {
1953
+ return _regeneratorRuntime().wrap(function _callee9$(_context10) {
1954
+ while (1) switch (_context10.prev = _context10.next) {
1990
1955
  case 0:
1991
1956
  case "end":
1992
- return _context11.stop();
1957
+ return _context10.stop();
1993
1958
  }
1994
1959
  }, _callee9);
1995
1960
  }));
@@ -2007,13 +1972,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2007
1972
  key: "hydrateTempOrderFromLocalRecord",
2008
1973
  value: function () {
2009
1974
  var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(record) {
2010
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2011
- while (1) switch (_context12.prev = _context12.next) {
1975
+ return _regeneratorRuntime().wrap(function _callee10$(_context11) {
1976
+ while (1) switch (_context11.prev = _context11.next) {
2012
1977
  case 0:
2013
- return _context12.abrupt("return", this.hydrateTempOrderFromRecord(record));
1978
+ return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
2014
1979
  case 1:
2015
1980
  case "end":
2016
- return _context12.stop();
1981
+ return _context11.stop();
2017
1982
  }
2018
1983
  }, _callee10, this);
2019
1984
  }));
@@ -2043,23 +2008,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2043
2008
  }, {
2044
2009
  key: "calculatePaymentTotal",
2045
2010
  value: function calculatePaymentTotal(payments) {
2046
- var _this8 = this;
2011
+ var _this7 = this;
2047
2012
  return mapPaymentItemsToOrderPayments(payments, {
2048
2013
  includeVoided: false
2049
2014
  }).reduce(function (sum, payment) {
2050
2015
  if (!isPaidPaymentRecord(payment)) return sum;
2051
- return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
2016
+ return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
2052
2017
  }, new Decimal(0));
2053
2018
  }
2054
2019
  }, {
2055
2020
  key: "calculateOrderPaidPaymentTotal",
2056
2021
  value: function calculateOrderPaidPaymentTotal(payments) {
2057
- var _this9 = this;
2022
+ var _this8 = this;
2058
2023
  return mapPaymentItemsToOrderPayments(payments, {
2059
2024
  includeVoided: false
2060
2025
  }).reduce(function (sum, payment) {
2061
2026
  if (!isPaidPaymentRecord(payment)) return sum;
2062
- return sum.plus(_this9.calculatePaymentGapAmount(payment));
2027
+ return sum.plus(_this8.calculatePaymentGapAmount(payment));
2063
2028
  }, new Decimal(0));
2064
2029
  }
2065
2030
  }, {
@@ -2195,13 +2160,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2195
2160
  }, {
2196
2161
  key: "calculateDepositPaidAmount",
2197
2162
  value: function calculateDepositPaidAmount(payments) {
2198
- var _this10 = this;
2163
+ var _this9 = this;
2199
2164
  return (payments || []).reduce(function (sum, payment) {
2200
2165
  var paymentRecord = payment;
2201
2166
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
2202
2167
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
2203
2168
  if (!isDepositPayment) return sum;
2204
- return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
2169
+ return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
2205
2170
  }, new Decimal(0));
2206
2171
  }
2207
2172
  }, {
@@ -2238,17 +2203,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2238
2203
  }, {
2239
2204
  key: "getPaymentNumberDevicePrefixSync",
2240
2205
  value: function getPaymentNumberDevicePrefixSync() {
2241
- var _this11 = this;
2206
+ var _this10 = this;
2242
2207
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
2243
- return _this11.getPaymentNumberAppData(key);
2208
+ return _this10.getPaymentNumberAppData(key);
2244
2209
  });
2245
2210
  }
2246
2211
  }, {
2247
2212
  key: "getPaymentNumberDevicePrefixAsync",
2248
2213
  value: function getPaymentNumberDevicePrefixAsync() {
2249
- var _this12 = this;
2214
+ var _this11 = this;
2250
2215
  return resolvePaymentNumberDevicePrefix(function (key) {
2251
- return _this12.getPaymentNumberAppData(key);
2216
+ return _this11.getPaymentNumberAppData(key);
2252
2217
  });
2253
2218
  }
2254
2219
  }, {
@@ -2378,16 +2343,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2378
2343
  }, {
2379
2344
  key: "calculatePaidPaymentSummary",
2380
2345
  value: function calculatePaidPaymentSummary(payments) {
2381
- var _this13 = this;
2346
+ var _this12 = this;
2382
2347
  return (payments || []).reduce(function (summary, payment) {
2383
2348
  var paymentRecord = payment;
2384
2349
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2385
2350
  return {
2386
2351
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2387
- orderPaidAmount: summary.orderPaidAmount.plus(_this13.calculatePaymentOrderAmount(paymentRecord)),
2388
- gapPaidAmount: summary.gapPaidAmount.plus(_this13.calculatePaymentGapAmount(paymentRecord)),
2389
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this13.calculatePaymentServiceFee(paymentRecord)),
2390
- roundingAmount: summary.roundingAmount.plus(_this13.calculatePaymentRoundingAmount(paymentRecord))
2352
+ orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
2353
+ gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
2354
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
2355
+ roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
2391
2356
  };
2392
2357
  }, {
2393
2358
  customerPaidAmount: new Decimal(0),
@@ -2594,15 +2559,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2594
2559
  }, {
2595
2560
  key: "normalizeFingerprintValue",
2596
2561
  value: function normalizeFingerprintValue(value) {
2597
- var _this14 = this;
2562
+ var _this13 = this;
2598
2563
  if (Array.isArray(value)) {
2599
2564
  return value.map(function (item) {
2600
- return _this14.normalizeFingerprintValue(item);
2565
+ return _this13.normalizeFingerprintValue(item);
2601
2566
  });
2602
2567
  }
2603
2568
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2604
2569
  return Object.keys(value).sort().reduce(function (result, key) {
2605
- result[key] = _this14.normalizeFingerprintValue(value[key]);
2570
+ result[key] = _this13.normalizeFingerprintValue(value[key]);
2606
2571
  return result;
2607
2572
  }, {});
2608
2573
  }
@@ -2617,7 +2582,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2617
2582
  _sku$barcode,
2618
2583
  _ref26,
2619
2584
  _sku$variant_id,
2620
- _this15 = this;
2585
+ _this14 = this;
2621
2586
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2622
2587
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2623
2588
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2656,7 +2621,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2656
2621
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
2657
2622
  option_group_item_id: (_ref28 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref28 !== void 0 ? _ref28 : null,
2658
2623
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2659
- add_price: _this15.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
2624
+ add_price: _this14.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
2660
2625
  };
2661
2626
  })
2662
2627
  }),
@@ -2666,8 +2631,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2666
2631
  bundle_product_id: (_ref29 = (_ref30 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
2667
2632
  bundle_variant_id: (_ref31 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref31 !== void 0 ? _ref31 : 0,
2668
2633
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2669
- price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2670
- bundle_selling_price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2634
+ price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2635
+ bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2671
2636
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2672
2637
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
2673
2638
  };
@@ -2677,7 +2642,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2677
2642
  return {
2678
2643
  type: (_ref32 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref32 !== void 0 ? _ref32 : '',
2679
2644
  discount_id: (_ref33 = (_ref34 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2680
- amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2645
+ amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2681
2646
  };
2682
2647
  }))
2683
2648
  };
@@ -2685,9 +2650,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2685
2650
  }, {
2686
2651
  key: "buildOrderProductsFingerprint",
2687
2652
  value: function buildOrderProductsFingerprint(products) {
2688
- var _this16 = this;
2653
+ var _this15 = this;
2689
2654
  var items = (products || []).map(function (product) {
2690
- return _this16.buildProductFingerprintItem(product);
2655
+ return _this15.buildProductFingerprintItem(product);
2691
2656
  });
2692
2657
  items.sort(function (left, right) {
2693
2658
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2709,7 +2674,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2709
2674
  _sku$barcode2,
2710
2675
  _ref36,
2711
2676
  _sku$variant_id2,
2712
- _this17 = this;
2677
+ _this16 = this;
2713
2678
  var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
2714
2679
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2715
2680
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
@@ -2746,7 +2711,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2746
2711
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
2747
2712
  option_group_item_id: (_ref38 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
2748
2713
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2749
- add_price: _this17.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2714
+ add_price: _this16.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2750
2715
  };
2751
2716
  })
2752
2717
  }),
@@ -2760,14 +2725,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2760
2725
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2761
2726
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2762
2727
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
2763
- option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2728
+ option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2764
2729
  var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2765
2730
  return {
2766
2731
  id: (_ref44 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref44 !== void 0 ? _ref44 : null,
2767
2732
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
2768
2733
  option_group_item_id: (_ref45 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref45 !== void 0 ? _ref45 : null,
2769
2734
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2770
- add_price: _this17.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2735
+ add_price: _this16.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2771
2736
  };
2772
2737
  }))
2773
2738
  };
@@ -2777,7 +2742,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2777
2742
  return {
2778
2743
  type: (_ref46 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref46 !== void 0 ? _ref46 : '',
2779
2744
  discount_id: (_ref47 = (_ref48 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
2780
- amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2745
+ amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2781
2746
  };
2782
2747
  }))
2783
2748
  };
@@ -2785,10 +2750,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2785
2750
  }, {
2786
2751
  key: "buildOrderProductsStructuralFingerprint",
2787
2752
  value: function buildOrderProductsStructuralFingerprint(products) {
2788
- var _this18 = this;
2753
+ var _this17 = this;
2789
2754
  var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
2790
2755
  var items = (products || []).map(function (product) {
2791
- return _this18.buildProductStructuralFingerprintItem(product, order);
2756
+ return _this17.buildProductStructuralFingerprintItem(product, order);
2792
2757
  });
2793
2758
  items.sort(function (left, right) {
2794
2759
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -3050,11 +3015,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3050
3015
  value: function () {
3051
3016
  var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder, options) {
3052
3017
  var nextTempOrder;
3053
- return _regeneratorRuntime().wrap(function _callee11$(_context13) {
3054
- while (1) switch (_context13.prev = _context13.next) {
3018
+ return _regeneratorRuntime().wrap(function _callee11$(_context12) {
3019
+ while (1) switch (_context12.prev = _context12.next) {
3055
3020
  case 0:
3056
3021
  if (isTempOrder(tempOrder)) {
3057
- _context13.next = 2;
3022
+ _context12.next = 2;
3058
3023
  break;
3059
3024
  }
3060
3025
  throw new Error('无效的 tempOrder 数据');
@@ -3066,15 +3031,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3066
3031
  this.store.tempOrder = nextTempOrder;
3067
3032
  this.clearCustomerWalletRuntimeState();
3068
3033
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
3069
- _context13.next = 11;
3034
+ _context12.next = 11;
3070
3035
  break;
3071
3036
  }
3072
- _context13.next = 9;
3037
+ _context12.next = 9;
3073
3038
  return this.recalculateSummary({
3074
3039
  createIfMissing: false
3075
3040
  });
3076
3041
  case 9:
3077
- _context13.next = 12;
3042
+ _context12.next = 12;
3078
3043
  break;
3079
3044
  case 11:
3080
3045
  this.store.summary = createEmptySummary();
@@ -3083,16 +3048,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3083
3048
  this.persistTempOrder();
3084
3049
  }
3085
3050
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
3086
- _context13.next = 16;
3051
+ _context12.next = 16;
3087
3052
  break;
3088
3053
  }
3089
- _context13.next = 16;
3054
+ _context12.next = 16;
3090
3055
  return this.saveDraft();
3091
3056
  case 16:
3092
- return _context13.abrupt("return", nextTempOrder);
3057
+ return _context12.abrupt("return", nextTempOrder);
3093
3058
  case 17:
3094
3059
  case "end":
3095
- return _context13.stop();
3060
+ return _context12.stop();
3096
3061
  }
3097
3062
  }, _callee11, this);
3098
3063
  }));
@@ -3184,28 +3149,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3184
3149
  value: function () {
3185
3150
  var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
3186
3151
  var tempOrder;
3187
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
3188
- while (1) switch (_context14.prev = _context14.next) {
3152
+ return _regeneratorRuntime().wrap(function _callee12$(_context13) {
3153
+ while (1) switch (_context13.prev = _context13.next) {
3189
3154
  case 0:
3190
3155
  tempOrder = this.ensureTempOrder();
3191
3156
  this.ensureExternalSaleNumber(tempOrder);
3192
- _context14.next = 4;
3157
+ _context13.next = 4;
3193
3158
  return this.recalculateSummary({
3194
3159
  createIfMissing: true
3195
3160
  });
3196
3161
  case 4:
3197
3162
  this.persistTempOrder();
3198
3163
  if (!this.draftPersistEnabled) {
3199
- _context14.next = 8;
3164
+ _context13.next = 8;
3200
3165
  break;
3201
3166
  }
3202
- _context14.next = 8;
3167
+ _context13.next = 8;
3203
3168
  return this.saveDraft();
3204
3169
  case 8:
3205
- return _context14.abrupt("return", tempOrder);
3170
+ return _context13.abrupt("return", tempOrder);
3206
3171
  case 9:
3207
3172
  case "end":
3208
- return _context14.stop();
3173
+ return _context13.stop();
3209
3174
  }
3210
3175
  }, _callee12, this);
3211
3176
  }));
@@ -3249,9 +3214,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3249
3214
  }, {
3250
3215
  key: "sanitizeTempOrderProducts",
3251
3216
  value: function sanitizeTempOrderProducts(tempOrder) {
3252
- var _this19 = this;
3217
+ var _this18 = this;
3253
3218
  tempOrder.products = (tempOrder.products || []).map(function (product) {
3254
- return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
3219
+ return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
3255
3220
  });
3256
3221
  this.syncTempOrderSettlementState(tempOrder);
3257
3222
  ensureUniqueProductLineUids(tempOrder);
@@ -3371,7 +3336,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3371
3336
  }, {
3372
3337
  key: "syncLinkedBookingHoldersToProducts",
3373
3338
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3374
- var _this20 = this;
3339
+ var _this19 = this;
3375
3340
  var bookings = tempOrder.bookings || [];
3376
3341
  var products = tempOrder.products || [];
3377
3342
  if (!bookings.length || !products.length) return;
@@ -3397,7 +3362,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3397
3362
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3398
3363
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3399
3364
  if (linkedBooking) {
3400
- _this20.setProductHolderFromBooking(product, linkedBooking);
3365
+ _this19.setProductHolderFromBooking(product, linkedBooking);
3401
3366
  }
3402
3367
  });
3403
3368
  }
@@ -3528,9 +3493,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3528
3493
  }, {
3529
3494
  key: "findBookingIndexByUniqueIdentificationNumber",
3530
3495
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3531
- var _this21 = this;
3496
+ var _this20 = this;
3532
3497
  return (tempOrder.bookings || []).findIndex(function (booking) {
3533
- return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3498
+ return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3534
3499
  });
3535
3500
  }
3536
3501
  }, {
@@ -3538,13 +3503,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3538
3503
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3539
3504
  var _product$metadata5,
3540
3505
  _product$metadata6,
3541
- _this22 = this;
3506
+ _this21 = this;
3542
3507
  var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
3543
3508
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
3544
3509
  if (!productUid && !bookingUid) return;
3545
3510
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3546
3511
  if (isFulfillmentTimingBooking(booking)) return true;
3547
- var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
3512
+ var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
3548
3513
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3549
3514
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3550
3515
  return true;
@@ -3593,21 +3558,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3593
3558
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
3594
3559
  var _this$otherParams3, _ref53, _salesSummaryResult$e;
3595
3560
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryMutationBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
3596
- return _regeneratorRuntime().wrap(function _callee13$(_context15) {
3597
- while (1) switch (_context15.prev = _context15.next) {
3561
+ return _regeneratorRuntime().wrap(function _callee13$(_context14) {
3562
+ while (1) switch (_context14.prev = _context14.next) {
3598
3563
  case 0:
3599
3564
  if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
3600
- _context15.next = 2;
3565
+ _context14.next = 2;
3601
3566
  break;
3602
3567
  }
3603
- return _context15.abrupt("return", null);
3568
+ return _context14.abrupt("return", null);
3604
3569
  case 2:
3605
3570
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
3606
3571
  if (tempOrder) {
3607
- _context15.next = 5;
3572
+ _context14.next = 5;
3608
3573
  break;
3609
3574
  }
3610
- return _context15.abrupt("return", null);
3575
+ return _context14.abrupt("return", null);
3611
3576
  case 5:
3612
3577
  this.sanitizeTempOrderProducts(tempOrder);
3613
3578
  originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
@@ -3615,10 +3580,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3615
3580
  shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
3616
3581
  snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
3617
3582
  if (!snapshotSummary) {
3618
- _context15.next = 12;
3583
+ _context14.next = 12;
3619
3584
  break;
3620
3585
  }
3621
- return _context15.abrupt("return", snapshotSummary);
3586
+ return _context14.abrupt("return", snapshotSummary);
3622
3587
  case 12:
3623
3588
  shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
3624
3589
  summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -3630,7 +3595,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3630
3595
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
3631
3596
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
3632
3597
  if (salesSummary) {
3633
- _context15.next = 28;
3598
+ _context14.next = 28;
3634
3599
  break;
3635
3600
  }
3636
3601
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -3656,13 +3621,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3656
3621
  previousSummary: existedSummary,
3657
3622
  summary: emptySummary
3658
3623
  });
3659
- return _context15.abrupt("return", this.store.summary);
3624
+ return _context14.abrupt("return", this.store.summary);
3660
3625
  case 28:
3661
3626
  summaryMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
3662
3627
  tempOrder: tempOrder,
3663
3628
  summary: this.store.summary
3664
3629
  }) : null;
3665
- _context15.next = 31;
3630
+ _context14.next = 31;
3666
3631
  return salesSummary.getSummary(_objectSpread({
3667
3632
  products: summaryProducts,
3668
3633
  isPriceIncludeTax: tempOrder.is_price_include_tax,
@@ -3672,21 +3637,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3672
3637
  channel: this.otherParams.channel
3673
3638
  } : {}));
3674
3639
  case 31:
3675
- salesSummaryResult = _context15.sent;
3640
+ salesSummaryResult = _context14.sent;
3676
3641
  if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
3677
- _context15.next = 34;
3642
+ _context14.next = 34;
3678
3643
  break;
3679
3644
  }
3680
- return _context15.abrupt("return", null);
3645
+ return _context14.abrupt("return", null);
3681
3646
  case 34:
3682
3647
  if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
3683
3648
  tempOrder: tempOrder,
3684
3649
  summary: this.store.summary
3685
3650
  }, summaryMutationBaseline))) {
3686
- _context15.next = 36;
3651
+ _context14.next = 36;
3687
3652
  break;
3688
3653
  }
3689
- return _context15.abrupt("return", null);
3654
+ return _context14.abrupt("return", null);
3690
3655
  case 36:
3691
3656
  if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
3692
3657
  tempOrder.products = summaryProducts;
@@ -3732,10 +3697,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3732
3697
  previousSummary: existedSummary,
3733
3698
  summary: summary
3734
3699
  });
3735
- return _context15.abrupt("return", this.store.summary);
3700
+ return _context14.abrupt("return", this.store.summary);
3736
3701
  case 53:
3737
3702
  case "end":
3738
- return _context15.stop();
3703
+ return _context14.stop();
3739
3704
  }
3740
3705
  }, _callee13, this);
3741
3706
  }));
@@ -3749,26 +3714,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3749
3714
  value: function () {
3750
3715
  var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
3751
3716
  var summary;
3752
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3753
- while (1) switch (_context16.prev = _context16.next) {
3717
+ return _regeneratorRuntime().wrap(function _callee14$(_context15) {
3718
+ while (1) switch (_context15.prev = _context15.next) {
3754
3719
  case 0:
3755
- _context16.next = 2;
3720
+ _context15.next = 2;
3756
3721
  return this.recalculateSummary({
3757
3722
  createIfMissing: true
3758
3723
  });
3759
3724
  case 2:
3760
- summary = _context16.sent;
3725
+ summary = _context15.sent;
3761
3726
  if (summary) {
3762
- _context16.next = 5;
3727
+ _context15.next = 5;
3763
3728
  break;
3764
3729
  }
3765
- return _context16.abrupt("return", createEmptySummary());
3730
+ return _context15.abrupt("return", createEmptySummary());
3766
3731
  case 5:
3767
3732
  this.persistTempOrder();
3768
- return _context16.abrupt("return", summary);
3733
+ return _context15.abrupt("return", summary);
3769
3734
  case 7:
3770
3735
  case "end":
3771
- return _context16.stop();
3736
+ return _context15.stop();
3772
3737
  }
3773
3738
  }, _callee14, this);
3774
3739
  }));
@@ -3795,18 +3760,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3795
3760
  key: "syncTempOrderNoteToRemote",
3796
3761
  value: function () {
3797
3762
  var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderId, note) {
3798
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3799
- while (1) switch (_context17.prev = _context17.next) {
3763
+ return _regeneratorRuntime().wrap(function _callee15$(_context16) {
3764
+ while (1) switch (_context16.prev = _context16.next) {
3800
3765
  case 0:
3801
- _context17.next = 2;
3766
+ _context16.next = 2;
3802
3767
  return this.request.put("/order/order/".concat(orderId, "/note"), {
3803
3768
  note: note
3804
3769
  });
3805
3770
  case 2:
3806
- return _context17.abrupt("return", note);
3771
+ return _context16.abrupt("return", note);
3807
3772
  case 3:
3808
3773
  case "end":
3809
- return _context17.stop();
3774
+ return _context16.stop();
3810
3775
  }
3811
3776
  }, _callee15, this);
3812
3777
  }));
@@ -3871,7 +3836,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3871
3836
  }, {
3872
3837
  key: "removeSalesNotesForMissingProductLines",
3873
3838
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3874
- var _this23 = this;
3839
+ var _this22 = this;
3875
3840
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3876
3841
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3877
3842
  return;
@@ -3883,7 +3848,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3883
3848
  return typeof uid === 'string' && uid.length > 0;
3884
3849
  }));
3885
3850
  var nextNotes = tempOrder.notes.filter(function (note) {
3886
- var primary = _this23.getSalesNotePrimaryRelation(note);
3851
+ var primary = _this22.getSalesNotePrimaryRelation(note);
3887
3852
  if (!primary || primary.target_type !== 'order_detail') return true;
3888
3853
  return remainingProductUids.has(primary.target_uuid);
3889
3854
  });
@@ -3895,7 +3860,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3895
3860
  key: "setSalesNoteOnTempOrder",
3896
3861
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3897
3862
  var _input$target,
3898
- _this24 = this,
3863
+ _this23 = this,
3899
3864
  _tempOrder$shop_order;
3900
3865
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3901
3866
  var note_type = String(input.note_type || '').trim();
@@ -3919,7 +3884,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3919
3884
  var notes = tempOrder.notes || [];
3920
3885
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3921
3886
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3922
- var primary = _this24.getSalesNotePrimaryRelation(note);
3887
+ var primary = _this23.getSalesNotePrimaryRelation(note);
3923
3888
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3924
3889
  }) : -1;
3925
3890
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -4013,16 +3978,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4013
3978
  value: function () {
4014
3979
  var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
4015
3980
  var tempOrder, note;
4016
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
4017
- while (1) switch (_context18.prev = _context18.next) {
3981
+ return _regeneratorRuntime().wrap(function _callee16$(_context17) {
3982
+ while (1) switch (_context17.prev = _context17.next) {
4018
3983
  case 0:
4019
3984
  tempOrder = this.ensureTempOrder();
4020
3985
  note = this.setSalesNoteOnTempOrder(tempOrder, input);
4021
3986
  this.notifyTempOrderChanged();
4022
- return _context18.abrupt("return", cloneDeep(note));
3987
+ return _context17.abrupt("return", cloneDeep(note));
4023
3988
  case 4:
4024
3989
  case "end":
4025
- return _context18.stop();
3990
+ return _context17.stop();
4026
3991
  }
4027
3992
  }, _callee16, this);
4028
3993
  }));
@@ -4036,8 +4001,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4036
4001
  value: function () {
4037
4002
  var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
4038
4003
  var tempOrder, normalizedUuid, notes, nextNotes, state;
4039
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
4040
- while (1) switch (_context19.prev = _context19.next) {
4004
+ return _regeneratorRuntime().wrap(function _callee17$(_context18) {
4005
+ while (1) switch (_context18.prev = _context18.next) {
4041
4006
  case 0:
4042
4007
  tempOrder = this.ensureTempOrder();
4043
4008
  this.ensureSalesNotesLoadedForMutation(tempOrder);
@@ -4047,10 +4012,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4047
4012
  return note.uuid !== normalizedUuid;
4048
4013
  });
4049
4014
  if (!(nextNotes.length === notes.length)) {
4050
- _context19.next = 7;
4015
+ _context18.next = 7;
4051
4016
  break;
4052
4017
  }
4053
- return _context19.abrupt("return");
4018
+ return _context18.abrupt("return");
4054
4019
  case 7:
4055
4020
  tempOrder.notes = nextNotes;
4056
4021
  state = this.ensureSalesNotesRuntimeState(tempOrder);
@@ -4058,7 +4023,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4058
4023
  this.notifyTempOrderChanged();
4059
4024
  case 11:
4060
4025
  case "end":
4061
- return _context19.stop();
4026
+ return _context18.stop();
4062
4027
  }
4063
4028
  }, _callee17, this);
4064
4029
  }));
@@ -4072,8 +4037,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4072
4037
  value: function () {
4073
4038
  var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
4074
4039
  var tempOrder, state;
4075
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
4076
- while (1) switch (_context20.prev = _context20.next) {
4040
+ return _regeneratorRuntime().wrap(function _callee18$(_context19) {
4041
+ while (1) switch (_context19.prev = _context19.next) {
4077
4042
  case 0:
4078
4043
  tempOrder = this.ensureTempOrder();
4079
4044
  tempOrder.notes = [];
@@ -4083,7 +4048,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4083
4048
  this.notifyTempOrderChanged();
4084
4049
  case 6:
4085
4050
  case "end":
4086
- return _context20.stop();
4051
+ return _context19.stop();
4087
4052
  }
4088
4053
  }, _callee18, this);
4089
4054
  }));
@@ -4238,15 +4203,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4238
4203
  }, {
4239
4204
  key: "productHasCustomerBoundDiscount",
4240
4205
  value: function productHasCustomerBoundDiscount(product) {
4241
- var _this25 = this;
4206
+ var _this24 = this;
4242
4207
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
4243
- return _this25.isCustomerBoundDiscount(discount);
4208
+ return _this24.isCustomerBoundDiscount(discount);
4244
4209
  })) {
4245
4210
  return true;
4246
4211
  }
4247
4212
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
4248
4213
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
4249
- return _this25.isCustomerBoundDiscount(discount);
4214
+ return _this24.isCustomerBoundDiscount(discount);
4250
4215
  });
4251
4216
  });
4252
4217
  }
@@ -4255,18 +4220,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4255
4220
  value: function shouldSkipDiscountCalculation(tempOrder) {
4256
4221
  var _this$store$discount20,
4257
4222
  _this$store$discount21,
4258
- _this26 = this;
4223
+ _this25 = this;
4259
4224
  if (this.hasActiveCustomerBoundDiscount) return false;
4260
4225
  var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
4261
4226
  if (discountList.length > 0) return false;
4262
4227
  return !(tempOrder.products || []).some(function (product) {
4263
- return _this26.productHasCustomerBoundDiscount(product);
4228
+ return _this25.productHasCustomerBoundDiscount(product);
4264
4229
  });
4265
4230
  }
4266
4231
  }, {
4267
4232
  key: "clearCustomerBoundDiscounts",
4268
4233
  value: function clearCustomerBoundDiscounts(tempOrder) {
4269
- var _this27 = this,
4234
+ var _this26 = this,
4270
4235
  _discountModule$getDi,
4271
4236
  _discountModule$getOr,
4272
4237
  _discountModule$setDi,
@@ -4275,7 +4240,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4275
4240
  var filterDiscountList = function filterDiscountList(discountList) {
4276
4241
  if (!Array.isArray(discountList)) return [];
4277
4242
  return discountList.filter(function (discount) {
4278
- var shouldRemove = _this27.isCustomerBoundDiscount(discount);
4243
+ var shouldRemove = _this26.isCustomerBoundDiscount(discount);
4279
4244
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
4280
4245
  return !shouldRemove;
4281
4246
  });
@@ -4302,12 +4267,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4302
4267
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
4303
4268
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
4304
4269
  var nextDiscounts = currentDiscounts.filter(function (discount) {
4305
- if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4306
- return !_this27.isCustomerBoundDiscount(discount);
4270
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4271
+ return !_this26.isCustomerBoundDiscount(discount);
4307
4272
  });
4308
4273
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
4309
- if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4310
- return !_this27.isCustomerBoundDiscount(discount);
4274
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4275
+ return !_this26.isCustomerBoundDiscount(discount);
4311
4276
  });
4312
4277
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
4313
4278
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -4474,10 +4439,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4474
4439
  }, {
4475
4440
  key: "setOrderPayments",
4476
4441
  value: function setOrderPayments(payments) {
4477
- var _this28 = this;
4442
+ var _this27 = this;
4478
4443
  var tempOrder = this.ensureTempOrder();
4479
4444
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4480
- return _this28.normalizePaymentSource(payment, {
4445
+ return _this27.normalizePaymentSource(payment, {
4481
4446
  defaultPaid: false
4482
4447
  });
4483
4448
  }));
@@ -4499,28 +4464,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4499
4464
  value: (function () {
4500
4465
  var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(payment) {
4501
4466
  var hasPaymentNumber, devicePrefix;
4502
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4503
- while (1) switch (_context21.prev = _context21.next) {
4467
+ return _regeneratorRuntime().wrap(function _callee19$(_context20) {
4468
+ while (1) switch (_context20.prev = _context20.next) {
4504
4469
  case 0:
4505
4470
  hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
4506
4471
  if (!hasPaymentNumber) {
4507
- _context21.next = 5;
4472
+ _context20.next = 5;
4508
4473
  break;
4509
4474
  }
4510
- _context21.t0 = 'LOCAL';
4511
- _context21.next = 8;
4475
+ _context20.t0 = 'LOCAL';
4476
+ _context20.next = 8;
4512
4477
  break;
4513
4478
  case 5:
4514
- _context21.next = 7;
4479
+ _context20.next = 7;
4515
4480
  return this.getPaymentNumberDevicePrefixAsync();
4516
4481
  case 7:
4517
- _context21.t0 = _context21.sent;
4482
+ _context20.t0 = _context20.sent;
4518
4483
  case 8:
4519
- devicePrefix = _context21.t0;
4520
- return _context21.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4484
+ devicePrefix = _context20.t0;
4485
+ return _context20.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4521
4486
  case 10:
4522
4487
  case "end":
4523
- return _context21.stop();
4488
+ return _context20.stop();
4524
4489
  }
4525
4490
  }, _callee19, this);
4526
4491
  }));
@@ -4532,7 +4497,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4532
4497
  }, {
4533
4498
  key: "addOrderPaymentWithDevicePrefix",
4534
4499
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4535
- var _this29 = this;
4500
+ var _this28 = this;
4536
4501
  this.logInfo('addOrderPayment', {
4537
4502
  payment: payment
4538
4503
  });
@@ -4550,7 +4515,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4550
4515
  void this.recalculateSummary({
4551
4516
  createIfMissing: true
4552
4517
  }).catch(function (error) {
4553
- _this29.logError('recalculate summary after addOrderPayment failed', {
4518
+ _this28.logError('recalculate summary after addOrderPayment failed', {
4554
4519
  error: error instanceof Error ? error.message : String(error)
4555
4520
  });
4556
4521
  });
@@ -4575,17 +4540,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4575
4540
  updatedPayment,
4576
4541
  summary,
4577
4542
  payments,
4578
- _args22 = arguments;
4579
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4580
- while (1) switch (_context22.prev = _context22.next) {
4543
+ _args21 = arguments;
4544
+ return _regeneratorRuntime().wrap(function _callee20$(_context21) {
4545
+ while (1) switch (_context21.prev = _context21.next) {
4581
4546
  case 0:
4582
- options = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
4547
+ options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
4583
4548
  tempOrder = this.ensureTempOrder();
4584
4549
  identity = String(paymentIdentity);
4585
4550
  matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
4586
4551
  matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
4587
4552
  if (matchedPayment) {
4588
- _context22.next = 8;
4553
+ _context21.next = 8;
4589
4554
  break;
4590
4555
  }
4591
4556
  try {
@@ -4614,15 +4579,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4614
4579
  return nextPayment;
4615
4580
  });
4616
4581
  this.persistTempOrder();
4617
- _context22.next = 13;
4582
+ _context21.next = 13;
4618
4583
  return this.recalculateSummary({
4619
4584
  createIfMissing: true
4620
4585
  });
4621
4586
  case 13:
4622
- summary = _context22.sent;
4587
+ summary = _context21.sent;
4623
4588
  this.persistTempOrder();
4624
4589
  payments = tempOrder.payments;
4625
- return _context22.abrupt("return", {
4590
+ return _context21.abrupt("return", {
4626
4591
  updated: true,
4627
4592
  payment: payments[matchedPayment.index] || updatedPayment,
4628
4593
  payments: payments,
@@ -4630,7 +4595,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4630
4595
  });
4631
4596
  case 17:
4632
4597
  case "end":
4633
- return _context22.stop();
4598
+ return _context21.stop();
4634
4599
  }
4635
4600
  }, _callee20, this);
4636
4601
  }));
@@ -4679,7 +4644,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4679
4644
  }, {
4680
4645
  key: "applyPaymentLifecycleChange",
4681
4646
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4682
- var _this30 = this;
4647
+ var _this29 = this;
4683
4648
  this.updateTempOrderPaymentStatus(tempOrder);
4684
4649
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4685
4650
  this.persistTempOrder();
@@ -4689,7 +4654,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4689
4654
  void this.recalculateSummary({
4690
4655
  createIfMissing: true
4691
4656
  }).catch(function (error) {
4692
- _this30.logError("recalculate summary after ".concat(logContext, " failed"), {
4657
+ _this29.logError("recalculate summary after ".concat(logContext, " failed"), {
4693
4658
  error: error instanceof Error ? error.message : String(error)
4694
4659
  });
4695
4660
  });
@@ -4733,7 +4698,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4733
4698
  }, {
4734
4699
  key: "updateVoucherOrderPayments",
4735
4700
  value: function updateVoucherOrderPayments(payments, options) {
4736
- var _this31 = this;
4701
+ var _this30 = this;
4737
4702
  var tempOrder = this.ensureTempOrder();
4738
4703
  var isOrderPaymentType = function isOrderPaymentType(value) {
4739
4704
  return value === 'normal' || value === 'deposit';
@@ -4768,7 +4733,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4768
4733
  });
4769
4734
  };
4770
4735
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4771
- return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4736
+ return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4772
4737
  defaultPaid: false,
4773
4738
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4774
4739
  });
@@ -4821,7 +4786,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4821
4786
  void this.recalculateSummary({
4822
4787
  createIfMissing: true
4823
4788
  }).catch(function (error) {
4824
- _this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
4789
+ _this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
4825
4790
  error: error instanceof Error ? error.message : String(error)
4826
4791
  });
4827
4792
  });
@@ -4832,32 +4797,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4832
4797
  value: function () {
4833
4798
  var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(payments, options) {
4834
4799
  var needsPaymentNumber, devicePrefix;
4835
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4836
- while (1) switch (_context23.prev = _context23.next) {
4800
+ return _regeneratorRuntime().wrap(function _callee21$(_context22) {
4801
+ while (1) switch (_context22.prev = _context22.next) {
4837
4802
  case 0:
4838
4803
  needsPaymentNumber = (payments || []).some(function (payment) {
4839
4804
  return String(payment.payment_number || '').trim() === '';
4840
4805
  });
4841
4806
  if (!needsPaymentNumber) {
4842
- _context23.next = 7;
4807
+ _context22.next = 7;
4843
4808
  break;
4844
4809
  }
4845
- _context23.next = 4;
4810
+ _context22.next = 4;
4846
4811
  return this.getPaymentNumberDevicePrefixAsync();
4847
4812
  case 4:
4848
- _context23.t0 = _context23.sent;
4849
- _context23.next = 8;
4813
+ _context22.t0 = _context22.sent;
4814
+ _context22.next = 8;
4850
4815
  break;
4851
4816
  case 7:
4852
- _context23.t0 = 'LOCAL';
4817
+ _context22.t0 = 'LOCAL';
4853
4818
  case 8:
4854
- devicePrefix = _context23.t0;
4855
- return _context23.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
4819
+ devicePrefix = _context22.t0;
4820
+ return _context22.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
4856
4821
  devicePrefix: devicePrefix
4857
4822
  })));
4858
4823
  case 10:
4859
4824
  case "end":
4860
- return _context23.stop();
4825
+ return _context22.stop();
4861
4826
  }
4862
4827
  }, _callee21, this);
4863
4828
  }));
@@ -4879,7 +4844,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4879
4844
  key: "shouldMergeProductToOrder",
4880
4845
  value: function shouldMergeProductToOrder(params) {
4881
4846
  var _this$orderHooks3,
4882
- _this32 = this;
4847
+ _this31 = this;
4883
4848
  var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
4884
4849
  if (!onBeforeMergeProductToOrder) return true;
4885
4850
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4887,7 +4852,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4887
4852
  }));
4888
4853
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4889
4854
  return Promise.resolve(result).then(function (resolved) {
4890
- return _this32.normalizeShouldMergeProductResult(resolved);
4855
+ return _this31.normalizeShouldMergeProductResult(resolved);
4891
4856
  });
4892
4857
  }
4893
4858
  return this.normalizeShouldMergeProductResult(result);
@@ -5018,77 +4983,77 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5018
4983
  value: function () {
5019
4984
  var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
5020
4985
  var isCurrentOrder, isVirtualSettlement, promotionPayload, summary;
5021
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
5022
- while (1) switch (_context24.prev = _context24.next) {
4986
+ return _regeneratorRuntime().wrap(function _callee22$(_context23) {
4987
+ while (1) switch (_context23.prev = _context23.next) {
5023
4988
  case 0:
5024
4989
  isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
5025
4990
  if (!(isCurrentOrder && !isCurrentOrder())) {
5026
- _context24.next = 3;
4991
+ _context23.next = 3;
5027
4992
  break;
5028
4993
  }
5029
- return _context24.abrupt("return");
4994
+ return _context23.abrupt("return");
5030
4995
  case 3:
5031
4996
  this.syncTempOrderHolderFromBookings(tempOrder);
5032
4997
  this.prepareVirtualSettlementTempOrder(tempOrder);
5033
4998
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
5034
4999
  if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
5035
- _context24.next = 9;
5000
+ _context23.next = 9;
5036
5001
  break;
5037
5002
  }
5038
- _context24.next = 9;
5003
+ _context23.next = 9;
5039
5004
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
5040
5005
  case 9:
5041
5006
  if (!(isCurrentOrder && !isCurrentOrder())) {
5042
- _context24.next = 11;
5007
+ _context23.next = 11;
5043
5008
  break;
5044
5009
  }
5045
- return _context24.abrupt("return");
5010
+ return _context23.abrupt("return");
5046
5011
  case 11:
5047
5012
  if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
5048
- _context24.next = 17;
5013
+ _context23.next = 17;
5049
5014
  break;
5050
5015
  }
5051
- _context24.next = 14;
5016
+ _context23.next = 14;
5052
5017
  return this.evaluatePromotion(isCurrentOrder ? {
5053
5018
  isCurrentOrder: isCurrentOrder
5054
5019
  } : undefined);
5055
5020
  case 14:
5056
- _context24.t0 = _context24.sent;
5057
- _context24.next = 18;
5021
+ _context23.t0 = _context23.sent;
5022
+ _context23.next = 18;
5058
5023
  break;
5059
5024
  case 17:
5060
- _context24.t0 = null;
5025
+ _context23.t0 = null;
5061
5026
  case 18:
5062
- promotionPayload = _context24.t0;
5027
+ promotionPayload = _context23.t0;
5063
5028
  if (!(isCurrentOrder && !isCurrentOrder())) {
5064
- _context24.next = 21;
5029
+ _context23.next = 21;
5065
5030
  break;
5066
5031
  }
5067
- return _context24.abrupt("return");
5032
+ return _context23.abrupt("return");
5068
5033
  case 21:
5069
5034
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
5070
5035
  this.applyDiscount();
5071
5036
  }
5072
5037
  this.sanitizeTempOrderProducts(tempOrder);
5073
- _context24.next = 25;
5038
+ _context23.next = 25;
5074
5039
  return this.recalculateSummary(_objectSpread({
5075
5040
  createIfMissing: true
5076
5041
  }, isCurrentOrder ? {
5077
5042
  isCurrentOrder: isCurrentOrder
5078
5043
  } : {}));
5079
5044
  case 25:
5080
- summary = _context24.sent;
5045
+ summary = _context23.sent;
5081
5046
  if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
5082
- _context24.next = 28;
5047
+ _context23.next = 28;
5083
5048
  break;
5084
5049
  }
5085
- return _context24.abrupt("return");
5050
+ return _context23.abrupt("return");
5086
5051
  case 28:
5087
5052
  this.persistTempOrder();
5088
5053
  this.emitPromotionApplied(promotionPayload);
5089
5054
  case 30:
5090
5055
  case "end":
5091
- return _context24.stop();
5056
+ return _context23.stop();
5092
5057
  }
5093
5058
  }, _callee22, this);
5094
5059
  }));
@@ -5119,7 +5084,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5119
5084
  _productToAdd$_extend,
5120
5085
  _productToAdd$metadat,
5121
5086
  _origin,
5122
- _this33 = this;
5087
+ _this32 = this;
5123
5088
  var linked = booking ? this.createLinkedProductAndBooking({
5124
5089
  product: product,
5125
5090
  booking: booking
@@ -5157,27 +5122,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5157
5122
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || hasIncomingHolder || isIncomingCustomItem || isWeighingProduct;
5158
5123
  var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
5159
5124
  var _item$metadata4;
5160
- if (_this33.hasGoodPassDiscount(item)) return false;
5125
+ if (_this32.hasGoodPassDiscount(item)) return false;
5161
5126
  if (getProductHolderRelations(tempOrder, item).length > 0 || hasAssignedHolderId((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.holder_id)) return false;
5162
- var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
5127
+ var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
5163
5128
  if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
5164
5129
  return false;
5165
5130
  }
5166
- if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
5131
+ if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
5167
5132
  return false;
5168
5133
  }
5169
- var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
5134
+ var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
5170
5135
  if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
5171
5136
  return false;
5172
5137
  }
5173
5138
  var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
5174
- if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
5139
+ if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
5175
5140
  return false;
5176
5141
  }
5177
5142
  if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
5178
5143
  return false;
5179
5144
  }
5180
- if (_this33.isPersistedProductLine(item)) return false;
5145
+ if (_this32.isPersistedProductLine(item)) return false;
5181
5146
  if (item.product_id !== productToAdd.product_id) return false;
5182
5147
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
5183
5148
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -5188,10 +5153,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5188
5153
  var commitProductLine = function commitProductLine(shouldMerge) {
5189
5154
  var _options$beforeCommit;
5190
5155
  options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
5191
- _this33.assertAndLockProductSettlement(tempOrder, productToAdd);
5156
+ _this32.assertAndLockProductSettlement(tempOrder, productToAdd);
5192
5157
  var committedProduct;
5193
5158
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
5194
- _this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
5159
+ _this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
5195
5160
  if (linked) {
5196
5161
  normalizedIncoming.booking_uid = linked.bookingUid;
5197
5162
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -5209,7 +5174,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5209
5174
  var _targetProduct$metada;
5210
5175
  var targetProduct = matchedProduct;
5211
5176
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
5212
- var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5177
+ var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5213
5178
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
5214
5179
  unique_identification_number: targetUid
5215
5180
  })
@@ -5232,7 +5197,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5232
5197
  order_detail_id: targetProduct.order_detail_id,
5233
5198
  num: nextNum
5234
5199
  });
5235
- _this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5200
+ _this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5236
5201
  committedProduct = tempOrder.products[matchedIndex];
5237
5202
  if (matchedIndex !== tempOrder.products.length - 1) {
5238
5203
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -5343,10 +5308,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5343
5308
  key: "addProductToOrder",
5344
5309
  value: (function () {
5345
5310
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
5346
- var _this34 = this;
5311
+ var _this33 = this;
5347
5312
  var availabilityCommitGuard, liveTempOrder, beforeCommit, tempOrder, guardedMutationFields, readGuardedMutationFields, guardedMutationBaseline, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2, committedIdentity, isCurrentOrder;
5348
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
5349
- while (1) switch (_context25.prev = _context25.next) {
5313
+ return _regeneratorRuntime().wrap(function _callee23$(_context24) {
5314
+ while (1) switch (_context24.prev = _context24.next) {
5350
5315
  case 0:
5351
5316
  availabilityCommitGuard = options === null || options === void 0 ? void 0 : options.availabilityCommitGuard;
5352
5317
  availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
@@ -5385,7 +5350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5385
5350
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
5386
5351
  }
5387
5352
  salesNoteDrafts.forEach(function (draft) {
5388
- _this34.setSalesNoteOnTempOrder(tempOrder, {
5353
+ _this33.setSalesNoteOnTempOrder(tempOrder, {
5389
5354
  note_type: draft.note_type,
5390
5355
  target: {
5391
5356
  target_type: 'order_detail',
@@ -5410,21 +5375,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5410
5375
  return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
5411
5376
  }) : -1;
5412
5377
  insertAtIndex = options !== null && options !== void 0 && options.insertAtStart ? 0 : anchorIndex >= 0 ? anchorIndex + 1 : undefined;
5413
- _context25.prev = 15;
5378
+ _context24.prev = 15;
5414
5379
  if (!booking) {
5415
- _context25.next = 42;
5380
+ _context24.next = 42;
5416
5381
  break;
5417
5382
  }
5418
5383
  productRecord = product;
5419
5384
  splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
5420
5385
  if (!(splitCount > 1)) {
5421
- _context25.next = 35;
5386
+ _context24.next = 35;
5422
5387
  break;
5423
5388
  }
5424
5389
  i = 0;
5425
5390
  case 21:
5426
5391
  if (!(i < splitCount)) {
5427
- _context25.next = 33;
5392
+ _context24.next = 33;
5428
5393
  break;
5429
5394
  }
5430
5395
  splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
@@ -5442,52 +5407,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5442
5407
  delete splitLine.booking.metadata.unique_identification_number;
5443
5408
  }
5444
5409
  }
5445
- _context25.next = 26;
5410
+ _context24.next = 26;
5446
5411
  return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
5447
5412
  insertAtIndex: insertAtIndex,
5448
5413
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5449
5414
  beforeCommit: beforeCommit
5450
5415
  });
5451
5416
  case 26:
5452
- committedProduct = _context25.sent;
5417
+ committedProduct = _context24.sent;
5453
5418
  availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
5454
5419
  attachSalesNoteDrafts(committedProduct);
5455
5420
  if (insertAtIndex !== undefined) insertAtIndex += 1;
5456
5421
  case 30:
5457
5422
  i += 1;
5458
- _context25.next = 21;
5423
+ _context24.next = 21;
5459
5424
  break;
5460
5425
  case 33:
5461
- _context25.next = 40;
5426
+ _context24.next = 40;
5462
5427
  break;
5463
5428
  case 35:
5464
- _context25.next = 37;
5429
+ _context24.next = 37;
5465
5430
  return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
5466
5431
  insertAtIndex: insertAtIndex,
5467
5432
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5468
5433
  beforeCommit: beforeCommit
5469
5434
  });
5470
5435
  case 37:
5471
- _committedProduct = _context25.sent;
5436
+ _committedProduct = _context24.sent;
5472
5437
  availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
5473
5438
  attachSalesNoteDrafts(_committedProduct);
5474
5439
  case 40:
5475
- _context25.next = 47;
5440
+ _context24.next = 47;
5476
5441
  break;
5477
5442
  case 42:
5478
- _context25.next = 44;
5443
+ _context24.next = 44;
5479
5444
  return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
5480
5445
  insertAtIndex: insertAtIndex,
5481
5446
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5482
5447
  beforeCommit: beforeCommit
5483
5448
  });
5484
5449
  case 44:
5485
- _committedProduct2 = _context25.sent;
5450
+ _committedProduct2 = _context24.sent;
5486
5451
  availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
5487
5452
  attachSalesNoteDrafts(_committedProduct2);
5488
5453
  case 47:
5489
5454
  if (!availabilityCommitGuard) {
5490
- _context25.next = 53;
5455
+ _context24.next = 53;
5491
5456
  break;
5492
5457
  }
5493
5458
  availabilityCommitGuard();
@@ -5495,7 +5460,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5495
5460
  // 调用方的结构 revision 可能不包括备注、价格或结算元数据。
5496
5461
  // 本次会覆盖的字段也要保持原值,不能让草稿覆盖并发编辑。
5497
5462
  if (isEqual(readGuardedMutationFields(liveTempOrder), guardedMutationBaseline)) {
5498
- _context25.next = 52;
5463
+ _context24.next = 52;
5499
5464
  break;
5500
5465
  }
5501
5466
  throw Object.assign(new Error('预约加购期间订单已变化,请重新选择'), {
@@ -5506,57 +5471,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5506
5471
  // 字段;其余订单字段继续使用 live 对象,外部持有的订单引用也不变。
5507
5472
  Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
5508
5473
  case 53:
5509
- _context25.next = 59;
5474
+ _context24.next = 59;
5510
5475
  break;
5511
5476
  case 55:
5512
- _context25.prev = 55;
5513
- _context25.t0 = _context25["catch"](15);
5477
+ _context24.prev = 55;
5478
+ _context24.t0 = _context24["catch"](15);
5514
5479
  rollbackProductAndNotesMutation();
5515
- throw _context25.t0;
5480
+ throw _context24.t0;
5516
5481
  case 59:
5517
5482
  if (!availabilityCommitGuard) {
5518
- _context25.next = 73;
5483
+ _context24.next = 73;
5519
5484
  break;
5520
5485
  }
5521
5486
  committedIdentity = [liveTempOrder.order_id, liveTempOrder.external_sale_number];
5522
5487
  isCurrentOrder = function isCurrentOrder() {
5523
5488
  var _options$availability, _options$availability2;
5524
- return _this34.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
5489
+ return _this33.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
5525
5490
  };
5526
- _context25.prev = 62;
5491
+ _context24.prev = 62;
5527
5492
  // 新增已发布,即使后续报价/促销收尾失败,也不能向调用方报告未加购。
5528
5493
  // 先保存已提交行;异步结果只允许写回仍属于本次提交的订单。
5529
5494
  if (isCurrentOrder()) this.persistTempOrder();
5530
- _context25.next = 66;
5495
+ _context24.next = 66;
5531
5496
  return this.finalizeProductOrderMutation(liveTempOrder, {
5532
5497
  isCurrentOrder: isCurrentOrder
5533
5498
  });
5534
5499
  case 66:
5535
- _context25.next = 71;
5500
+ _context24.next = 71;
5536
5501
  break;
5537
5502
  case 68:
5538
- _context25.prev = 68;
5539
- _context25.t1 = _context25["catch"](62);
5503
+ _context24.prev = 68;
5504
+ _context24.t1 = _context24["catch"](62);
5540
5505
  this.logWarning('addProductToOrder committed; finalization failed', {
5541
5506
  product_id: product.product_id,
5542
5507
  committed: true,
5543
- error: _context25.t1 instanceof Error ? _context25.t1.message : String(_context25.t1)
5508
+ error: _context24.t1 instanceof Error ? _context24.t1.message : String(_context24.t1)
5544
5509
  });
5545
5510
  case 71:
5546
- _context25.next = 75;
5511
+ _context24.next = 75;
5547
5512
  break;
5548
5513
  case 73:
5549
- _context25.next = 75;
5514
+ _context24.next = 75;
5550
5515
  return this.finalizeProductOrderMutation(liveTempOrder);
5551
5516
  case 75:
5552
5517
  this.logInfo('addProductToOrder success', {
5553
5518
  product_id: product.product_id,
5554
5519
  with_booking: !!booking
5555
5520
  });
5556
- return _context25.abrupt("return", liveTempOrder.products);
5521
+ return _context24.abrupt("return", liveTempOrder.products);
5557
5522
  case 77:
5558
5523
  case "end":
5559
- return _context25.stop();
5524
+ return _context24.stop();
5560
5525
  }
5561
5526
  }, _callee23, this, [[15, 55], [62, 68]]);
5562
5527
  }));
@@ -5580,47 +5545,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5580
5545
  value: (function () {
5581
5546
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
5582
5547
  var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5583
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
5584
- while (1) switch (_context26.prev = _context26.next) {
5548
+ return _regeneratorRuntime().wrap(function _callee24$(_context25) {
5549
+ while (1) switch (_context25.prev = _context25.next) {
5585
5550
  case 0:
5586
5551
  tempOrder = this.ensureTempOrder();
5587
5552
  if (!(!Array.isArray(items) || items.length === 0)) {
5588
- _context26.next = 3;
5553
+ _context25.next = 3;
5589
5554
  break;
5590
5555
  }
5591
- return _context26.abrupt("return", tempOrder.products);
5556
+ return _context25.abrupt("return", tempOrder.products);
5592
5557
  case 3:
5593
5558
  beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
5594
5559
  _iterator20 = _createForOfIteratorHelper(items || []);
5595
- _context26.prev = 5;
5560
+ _context25.prev = 5;
5596
5561
  _iterator20.s();
5597
5562
  case 7:
5598
5563
  if ((_step20 = _iterator20.n()).done) {
5599
- _context26.next = 33;
5564
+ _context25.next = 33;
5600
5565
  break;
5601
5566
  }
5602
5567
  item = _step20.value;
5603
5568
  product = item.product, booking = item.booking;
5604
5569
  if (product) {
5605
- _context26.next = 12;
5570
+ _context25.next = 12;
5606
5571
  break;
5607
5572
  }
5608
- return _context26.abrupt("continue", 31);
5573
+ return _context25.abrupt("continue", 31);
5609
5574
  case 12:
5610
5575
  if (!booking) {
5611
- _context26.next = 27;
5576
+ _context25.next = 27;
5612
5577
  break;
5613
5578
  }
5614
5579
  productRecord = product;
5615
5580
  splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5616
5581
  if (!(splitCount > 1)) {
5617
- _context26.next = 27;
5582
+ _context25.next = 27;
5618
5583
  break;
5619
5584
  }
5620
5585
  i = 0;
5621
5586
  case 17:
5622
5587
  if (!(i < splitCount)) {
5623
- _context26.next = 26;
5588
+ _context25.next = 26;
5624
5589
  break;
5625
5590
  }
5626
5591
  splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
@@ -5628,52 +5593,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5628
5593
  beforeCommit: beforeCommit
5629
5594
  });
5630
5595
  if (!_appendResult) {
5631
- _context26.next = 23;
5596
+ _context25.next = 23;
5632
5597
  break;
5633
5598
  }
5634
- _context26.next = 23;
5599
+ _context25.next = 23;
5635
5600
  return _appendResult;
5636
5601
  case 23:
5637
5602
  i += 1;
5638
- _context26.next = 17;
5603
+ _context25.next = 17;
5639
5604
  break;
5640
5605
  case 26:
5641
- return _context26.abrupt("continue", 31);
5606
+ return _context25.abrupt("continue", 31);
5642
5607
  case 27:
5643
5608
  appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
5644
5609
  beforeCommit: beforeCommit
5645
5610
  });
5646
5611
  if (!appendResult) {
5647
- _context26.next = 31;
5612
+ _context25.next = 31;
5648
5613
  break;
5649
5614
  }
5650
- _context26.next = 31;
5615
+ _context25.next = 31;
5651
5616
  return appendResult;
5652
5617
  case 31:
5653
- _context26.next = 7;
5618
+ _context25.next = 7;
5654
5619
  break;
5655
5620
  case 33:
5656
- _context26.next = 38;
5621
+ _context25.next = 38;
5657
5622
  break;
5658
5623
  case 35:
5659
- _context26.prev = 35;
5660
- _context26.t0 = _context26["catch"](5);
5661
- _iterator20.e(_context26.t0);
5624
+ _context25.prev = 35;
5625
+ _context25.t0 = _context25["catch"](5);
5626
+ _iterator20.e(_context25.t0);
5662
5627
  case 38:
5663
- _context26.prev = 38;
5628
+ _context25.prev = 38;
5664
5629
  _iterator20.f();
5665
- return _context26.finish(38);
5630
+ return _context25.finish(38);
5666
5631
  case 41:
5667
- _context26.next = 43;
5632
+ _context25.next = 43;
5668
5633
  return this.finalizeProductOrderMutation(tempOrder, options);
5669
5634
  case 43:
5670
5635
  this.logInfo('addProductsToOrder success', {
5671
5636
  itemsCount: items.length
5672
5637
  });
5673
- return _context26.abrupt("return", tempOrder.products);
5638
+ return _context25.abrupt("return", tempOrder.products);
5674
5639
  case 45:
5675
5640
  case "end":
5676
- return _context26.stop();
5641
+ return _context25.stop();
5677
5642
  }
5678
5643
  }, _callee24, this, [[5, 35, 38, 41]]);
5679
5644
  }));
@@ -5729,7 +5694,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5729
5694
  }, {
5730
5695
  key: "hasSameEntitlementMergePriceConfig",
5731
5696
  value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5732
- var _this35 = this;
5697
+ var _this34 = this;
5733
5698
  var buildPriceConfig = function buildPriceConfig(product) {
5734
5699
  var metadata = product.metadata || {};
5735
5700
  var bundle = (product.product_bundle || []).map(function (item) {
@@ -5745,10 +5710,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5745
5710
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
5746
5711
  });
5747
5712
  return JSON.stringify({
5748
- original_price: _this35.normalizeFingerprintMoney(product.original_price),
5749
- source_product_price: _this35.normalizeFingerprintMoney(metadata.source_product_price),
5750
- main_product_original_price: _this35.normalizeFingerprintMoney(metadata.main_product_original_price),
5751
- price_override: _this35.normalizeFingerprintMoney(metadata.price_override),
5713
+ original_price: _this34.normalizeFingerprintMoney(product.original_price),
5714
+ source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
5715
+ main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
5716
+ price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
5752
5717
  is_manual_discount: Boolean(metadata.is_manual_discount),
5753
5718
  bundle: bundle
5754
5719
  });
@@ -5765,17 +5730,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5765
5730
  }, {
5766
5731
  key: "preservePersistedBundlePriceFields",
5767
5732
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5768
- var _this36 = this;
5733
+ var _this35 = this;
5769
5734
  if (!Array.isArray(nextBundles)) return nextBundles;
5770
5735
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5771
5736
  var previousByIdentity = new Map();
5772
5737
  previousBundles.forEach(function (bundle) {
5773
- var identity = _this36.getBundleRuntimeIdentity(bundle);
5738
+ var identity = _this35.getBundleRuntimeIdentity(bundle);
5774
5739
  if (identity) previousByIdentity.set(identity, bundle);
5775
5740
  });
5776
5741
  return nextBundles.map(function (bundle, index) {
5777
5742
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5778
- var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5743
+ var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5779
5744
  if (!previous || _typeof(previous) !== 'object') return bundle;
5780
5745
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5781
5746
  cover: previous.cover
@@ -6049,8 +6014,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6049
6014
  value: function () {
6050
6015
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
6051
6016
  var tempOrder, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
6052
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
6053
- while (1) switch (_context27.prev = _context27.next) {
6017
+ return _regeneratorRuntime().wrap(function _callee25$(_context26) {
6018
+ while (1) switch (_context26.prev = _context26.next) {
6054
6019
  case 0:
6055
6020
  tempOrder = this.ensureTempOrder();
6056
6021
  if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
@@ -6058,16 +6023,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6058
6023
  }
6059
6024
  reapplyWeighedDiscountProductUids = [];
6060
6025
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
6061
- _context27.next = 6;
6026
+ _context26.next = 6;
6062
6027
  return this.evaluatePromotion();
6063
6028
  case 6:
6064
- promotionPayload = _context27.sent;
6029
+ promotionPayload = _context26.sent;
6065
6030
  this.applyDiscount({
6066
6031
  reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
6067
6032
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
6068
6033
  });
6069
6034
  this.sanitizeTempOrderProducts(tempOrder);
6070
- _context27.next = 11;
6035
+ _context26.next = 11;
6071
6036
  return this.recalculateSummary({
6072
6037
  createIfMissing: true
6073
6038
  });
@@ -6077,10 +6042,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6077
6042
  this.logInfo('updateOrderProduct success', {
6078
6043
  params: params
6079
6044
  });
6080
- return _context27.abrupt("return", tempOrder.products);
6045
+ return _context26.abrupt("return", tempOrder.products);
6081
6046
  case 15:
6082
6047
  case "end":
6083
- return _context27.stop();
6048
+ return _context26.stop();
6084
6049
  }
6085
6050
  }, _callee25, this);
6086
6051
  }));
@@ -6093,33 +6058,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6093
6058
  key: "updateOrderProducts",
6094
6059
  value: function () {
6095
6060
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
6096
- var _this37 = this;
6061
+ var _this36 = this;
6097
6062
  var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
6098
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
6099
- while (1) switch (_context28.prev = _context28.next) {
6063
+ return _regeneratorRuntime().wrap(function _callee26$(_context27) {
6064
+ while (1) switch (_context27.prev = _context27.next) {
6100
6065
  case 0:
6101
6066
  tempOrder = this.ensureTempOrder();
6102
6067
  if (paramsList.length) {
6103
- _context28.next = 3;
6068
+ _context27.next = 3;
6104
6069
  break;
6105
6070
  }
6106
- return _context28.abrupt("return", tempOrder.products);
6071
+ return _context27.abrupt("return", tempOrder.products);
6107
6072
  case 3:
6108
6073
  if (paramsList.some(function (params) {
6109
- return _this37.isRestrictedCartProductUpdate(tempOrder, params);
6074
+ return _this36.isRestrictedCartProductUpdate(tempOrder, params);
6110
6075
  })) {
6111
6076
  this.createCartIntentCommitGuard('update_product', tempOrder)();
6112
6077
  }
6113
6078
  reapplyWeighedDiscountProductUids = [];
6114
6079
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
6115
- var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
6080
+ var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
6116
6081
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
6117
6082
  if (params.allow_booking_discount_reapply && updatedProductUid) {
6118
6083
  acc.push(String(updatedProductUid));
6119
6084
  }
6120
6085
  return acc;
6121
6086
  }, []);
6122
- _context28.next = 8;
6087
+ _context27.next = 8;
6123
6088
  return this.finalizeAfterProductsMutation(tempOrder, {
6124
6089
  reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
6125
6090
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
@@ -6128,10 +6093,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6128
6093
  this.logInfo('updateOrderProduct success', {
6129
6094
  paramsList: paramsList
6130
6095
  });
6131
- return _context28.abrupt("return", tempOrder.products);
6096
+ return _context27.abrupt("return", tempOrder.products);
6132
6097
  case 10:
6133
6098
  case "end":
6134
- return _context28.stop();
6099
+ return _context27.stop();
6135
6100
  }
6136
6101
  }, _callee26, this);
6137
6102
  }));
@@ -6146,15 +6111,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6146
6111
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params, options) {
6147
6112
  var _this$store$tempOrder9, _targetProduct$metada22;
6148
6113
  var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
6149
- return _regeneratorRuntime().wrap(function _callee27$(_context29) {
6150
- while (1) switch (_context29.prev = _context29.next) {
6114
+ return _regeneratorRuntime().wrap(function _callee27$(_context28) {
6115
+ while (1) switch (_context28.prev = _context28.next) {
6151
6116
  case 0:
6152
6117
  isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
6153
6118
  if (!(isCurrentOrder && !isCurrentOrder())) {
6154
- _context29.next = 3;
6119
+ _context28.next = 3;
6155
6120
  break;
6156
6121
  }
6157
- return _context29.abrupt("return", ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.products) || []);
6122
+ return _context28.abrupt("return", ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.products) || []);
6158
6123
  case 3:
6159
6124
  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;
6160
6125
  tempOrder = this.ensureTempOrder();
@@ -6184,7 +6149,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6184
6149
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
6185
6150
  }
6186
6151
  if (!(productIndex === -1)) {
6187
- _context29.next = 16;
6152
+ _context28.next = 16;
6188
6153
  break;
6189
6154
  }
6190
6155
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -6200,7 +6165,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6200
6165
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
6201
6166
  settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
6202
6167
  if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
6203
- _context29.next = 30;
6168
+ _context28.next = 30;
6204
6169
  break;
6205
6170
  }
6206
6171
  currencyProductId = Number(settlementSnapshot.currency_product_id);
@@ -6208,7 +6173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6208
6173
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
6209
6174
  });
6210
6175
  if (asset) {
6211
- _context29.next = 26;
6176
+ _context28.next = 26;
6212
6177
  break;
6213
6178
  }
6214
6179
  throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
@@ -6220,7 +6185,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6220
6185
  }, new Decimal(0));
6221
6186
  balance = new Decimal(asset.balance || 0);
6222
6187
  if (!balance.lt(requiredAmount)) {
6223
- _context29.next = 30;
6188
+ _context28.next = 30;
6224
6189
  break;
6225
6190
  }
6226
6191
  throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
@@ -6229,46 +6194,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6229
6194
  this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
6230
6195
  }
6231
6196
  if (!(isCurrentOrder && !isCurrentOrder())) {
6232
- _context29.next = 33;
6197
+ _context28.next = 33;
6233
6198
  break;
6234
6199
  }
6235
- return _context29.abrupt("return", tempOrder.products);
6200
+ return _context28.abrupt("return", tempOrder.products);
6236
6201
  case 33:
6237
6202
  tempOrder.products[productIndex] = normalizedProduct;
6238
6203
  if (!isCurrentOrder) {
6239
- _context29.next = 39;
6204
+ _context28.next = 39;
6240
6205
  break;
6241
6206
  }
6242
- _context29.next = 37;
6207
+ _context28.next = 37;
6243
6208
  return this.finalizeProductOrderMutation(tempOrder, {
6244
6209
  skipEditDiscountConfigRefresh: true,
6245
6210
  isCurrentOrder: isCurrentOrder
6246
6211
  });
6247
6212
  case 37:
6248
- _context29.next = 55;
6213
+ _context28.next = 55;
6249
6214
  break;
6250
6215
  case 39:
6251
6216
  this.prepareVirtualSettlementTempOrder(tempOrder);
6252
6217
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
6253
6218
  if (isVirtualSettlement) {
6254
- _context29.next = 47;
6219
+ _context28.next = 47;
6255
6220
  break;
6256
6221
  }
6257
- _context29.next = 44;
6222
+ _context28.next = 44;
6258
6223
  return this.evaluatePromotion();
6259
6224
  case 44:
6260
- _context29.t0 = _context29.sent;
6261
- _context29.next = 48;
6225
+ _context28.t0 = _context28.sent;
6226
+ _context28.next = 48;
6262
6227
  break;
6263
6228
  case 47:
6264
- _context29.t0 = null;
6229
+ _context28.t0 = null;
6265
6230
  case 48:
6266
- promotionPayload = _context29.t0;
6231
+ promotionPayload = _context28.t0;
6267
6232
  if (!isVirtualSettlement) {
6268
6233
  this.applyDiscount();
6269
6234
  }
6270
6235
  this.sanitizeTempOrderProducts(tempOrder);
6271
- _context29.next = 53;
6236
+ _context28.next = 53;
6272
6237
  return this.recalculateSummary({
6273
6238
  createIfMissing: true
6274
6239
  });
@@ -6279,10 +6244,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6279
6244
  this.logInfo('updateOrderProductQuantity success', {
6280
6245
  params: params
6281
6246
  });
6282
- return _context29.abrupt("return", tempOrder.products);
6247
+ return _context28.abrupt("return", tempOrder.products);
6283
6248
  case 57:
6284
6249
  case "end":
6285
- return _context29.stop();
6250
+ return _context28.stop();
6286
6251
  }
6287
6252
  }, _callee27, this);
6288
6253
  }));
@@ -6329,20 +6294,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6329
6294
  value: (function () {
6330
6295
  var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
6331
6296
  var promotionPayload;
6332
- return _regeneratorRuntime().wrap(function _callee28$(_context30) {
6333
- while (1) switch (_context30.prev = _context30.next) {
6297
+ return _regeneratorRuntime().wrap(function _callee28$(_context29) {
6298
+ while (1) switch (_context29.prev = _context29.next) {
6334
6299
  case 0:
6335
6300
  this.syncTempOrderHolderFromBookings(tempOrder);
6336
- _context30.next = 3;
6301
+ _context29.next = 3;
6337
6302
  return this.evaluatePromotion();
6338
6303
  case 3:
6339
- promotionPayload = _context30.sent;
6304
+ promotionPayload = _context29.sent;
6340
6305
  this.applyDiscount({
6341
6306
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
6342
6307
  reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
6343
6308
  });
6344
6309
  this.sanitizeTempOrderProducts(tempOrder);
6345
- _context30.next = 8;
6310
+ _context29.next = 8;
6346
6311
  return this.recalculateSummary({
6347
6312
  createIfMissing: true
6348
6313
  });
@@ -6351,7 +6316,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6351
6316
  this.emitPromotionApplied(promotionPayload);
6352
6317
  case 10:
6353
6318
  case "end":
6354
- return _context30.stop();
6319
+ return _context29.stop();
6355
6320
  }
6356
6321
  }, _callee28, this);
6357
6322
  }));
@@ -6372,24 +6337,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6372
6337
  value: (function () {
6373
6338
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
6374
6339
  var _this$store$tempOrder10,
6375
- _this38 = this;
6376
- var isCurrentOrder, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
6377
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
6378
- while (1) switch (_context32.prev = _context32.next) {
6340
+ _this37 = this;
6341
+ var isCurrentOrder, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop2, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
6342
+ return _regeneratorRuntime().wrap(function _callee29$(_context31) {
6343
+ while (1) switch (_context31.prev = _context31.next) {
6379
6344
  case 0:
6380
6345
  isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
6381
6346
  if (!(isCurrentOrder && !isCurrentOrder())) {
6382
- _context32.next = 3;
6347
+ _context31.next = 3;
6383
6348
  break;
6384
6349
  }
6385
- return _context32.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
6350
+ return _context31.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
6386
6351
  case 3:
6387
6352
  tempOrder = this.ensureTempOrder();
6388
6353
  if (identities.length) {
6389
- _context32.next = 6;
6354
+ _context31.next = 6;
6390
6355
  break;
6391
6356
  }
6392
- return _context32.abrupt("return", tempOrder.products);
6357
+ return _context31.abrupt("return", tempOrder.products);
6393
6358
  case 6:
6394
6359
  // 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
6395
6360
  this.ensureSalesNotesLoadedForMutation(tempOrder);
@@ -6422,29 +6387,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6422
6387
  }
6423
6388
  linkedBookingUidsToRemove = new Set();
6424
6389
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
6425
- _context32.prev = 19;
6426
- _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
6390
+ _context31.prev = 19;
6391
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
6427
6392
  var _metadata11, _metadata12, _metadata13, _metadata14;
6428
6393
  var product, productUid, productBookingUid, isAddTimeProduct;
6429
- return _regeneratorRuntime().wrap(function _loop3$(_context31) {
6430
- while (1) switch (_context31.prev = _context31.next) {
6394
+ return _regeneratorRuntime().wrap(function _loop2$(_context30) {
6395
+ while (1) switch (_context30.prev = _context30.next) {
6431
6396
  case 0:
6432
6397
  product = _step21.value;
6433
6398
  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);
6434
6399
  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);
6435
6400
  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;
6436
6401
  if (!isAddTimeProduct) {
6437
- _context31.next = 6;
6402
+ _context30.next = 6;
6438
6403
  break;
6439
6404
  }
6440
- return _context31.abrupt("return", 1);
6405
+ return _context30.abrupt("return", 1);
6441
6406
  case 6:
6442
6407
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
6443
6408
  linkedBookingUidsToRemove.add(String(productBookingUid));
6444
6409
  }
6445
6410
  if (productUid !== undefined && productUid !== null && productUid !== '') {
6446
6411
  bookingsBeforeRemove.forEach(function (booking) {
6447
- var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
6412
+ var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
6448
6413
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
6449
6414
  linkedBookingUidsToRemove.add(bookingUid);
6450
6415
  }
@@ -6452,37 +6417,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6452
6417
  }
6453
6418
  case 8:
6454
6419
  case "end":
6455
- return _context31.stop();
6420
+ return _context30.stop();
6456
6421
  }
6457
- }, _loop3);
6422
+ }, _loop2);
6458
6423
  });
6459
6424
  _iterator21.s();
6460
6425
  case 22:
6461
6426
  if ((_step21 = _iterator21.n()).done) {
6462
- _context32.next = 28;
6427
+ _context31.next = 28;
6463
6428
  break;
6464
6429
  }
6465
- return _context32.delegateYield(_loop3(), "t0", 24);
6430
+ return _context31.delegateYield(_loop2(), "t0", 24);
6466
6431
  case 24:
6467
- if (!_context32.t0) {
6468
- _context32.next = 26;
6432
+ if (!_context31.t0) {
6433
+ _context31.next = 26;
6469
6434
  break;
6470
6435
  }
6471
- return _context32.abrupt("continue", 26);
6436
+ return _context31.abrupt("continue", 26);
6472
6437
  case 26:
6473
- _context32.next = 22;
6438
+ _context31.next = 22;
6474
6439
  break;
6475
6440
  case 28:
6476
- _context32.next = 33;
6441
+ _context31.next = 33;
6477
6442
  break;
6478
6443
  case 30:
6479
- _context32.prev = 30;
6480
- _context32.t1 = _context32["catch"](19);
6481
- _iterator21.e(_context32.t1);
6444
+ _context31.prev = 30;
6445
+ _context31.t1 = _context31["catch"](19);
6446
+ _iterator21.e(_context31.t1);
6482
6447
  case 33:
6483
- _context32.prev = 33;
6448
+ _context31.prev = 33;
6484
6449
  _iterator21.f();
6485
- return _context32.finish(33);
6450
+ return _context31.finish(33);
6486
6451
  case 36:
6487
6452
  if (linkedBookingUidsToRemove.size > 0) {
6488
6453
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -6514,28 +6479,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6514
6479
  }));
6515
6480
  this.removeSalesNotesForMissingProductLines(tempOrder);
6516
6481
  if (!isCurrentOrder) {
6517
- _context32.next = 45;
6482
+ _context31.next = 45;
6518
6483
  break;
6519
6484
  }
6520
- _context32.next = 43;
6485
+ _context31.next = 43;
6521
6486
  return this.finalizeProductOrderMutation(tempOrder, {
6522
6487
  skipEditDiscountConfigRefresh: true,
6523
6488
  isCurrentOrder: isCurrentOrder
6524
6489
  });
6525
6490
  case 43:
6526
- _context32.next = 47;
6491
+ _context31.next = 47;
6527
6492
  break;
6528
6493
  case 45:
6529
- _context32.next = 47;
6494
+ _context31.next = 47;
6530
6495
  return this.finalizeAfterProductsMutation(tempOrder);
6531
6496
  case 47:
6532
6497
  this.logInfo('removeProductsFromOrder success', {
6533
6498
  identities: identities
6534
6499
  });
6535
- return _context32.abrupt("return", tempOrder.products);
6500
+ return _context31.abrupt("return", tempOrder.products);
6536
6501
  case 49:
6537
6502
  case "end":
6538
- return _context32.stop();
6503
+ return _context31.stop();
6539
6504
  }
6540
6505
  }, _callee29, this, [[19, 30, 33, 36]]);
6541
6506
  }));
@@ -6548,13 +6513,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6548
6513
  key: "removeProductFromOrder",
6549
6514
  value: function () {
6550
6515
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(identity, options) {
6551
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
6552
- while (1) switch (_context33.prev = _context33.next) {
6516
+ return _regeneratorRuntime().wrap(function _callee30$(_context32) {
6517
+ while (1) switch (_context32.prev = _context32.next) {
6553
6518
  case 0:
6554
- return _context33.abrupt("return", this.removeProductsFromOrder([identity], options));
6519
+ return _context32.abrupt("return", this.removeProductsFromOrder([identity], options));
6555
6520
  case 1:
6556
6521
  case "end":
6557
- return _context33.stop();
6522
+ return _context32.stop();
6558
6523
  }
6559
6524
  }, _callee30, this);
6560
6525
  }));
@@ -6572,8 +6537,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6572
6537
  value: (function () {
6573
6538
  var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
6574
6539
  var tempOrder, promotionPayload;
6575
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
6576
- while (1) switch (_context34.prev = _context34.next) {
6540
+ return _regeneratorRuntime().wrap(function _callee31$(_context33) {
6541
+ while (1) switch (_context33.prev = _context33.next) {
6577
6542
  case 0:
6578
6543
  tempOrder = this.ensureTempOrder();
6579
6544
  this.ensureSalesNotesLoadedForMutation(tempOrder);
@@ -6588,13 +6553,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6588
6553
  productsByUid: {}
6589
6554
  });
6590
6555
  }
6591
- _context34.next = 11;
6556
+ _context33.next = 11;
6592
6557
  return this.evaluatePromotion();
6593
6558
  case 11:
6594
- promotionPayload = _context34.sent;
6559
+ promotionPayload = _context33.sent;
6595
6560
  this.applyDiscount();
6596
6561
  this.sanitizeTempOrderProducts(tempOrder);
6597
- _context34.next = 16;
6562
+ _context33.next = 16;
6598
6563
  return this.recalculateSummary({
6599
6564
  createIfMissing: true
6600
6565
  });
@@ -6602,10 +6567,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6602
6567
  this.persistTempOrder();
6603
6568
  this.emitPromotionApplied(promotionPayload);
6604
6569
  this.logInfo('clearOrderCartLines success', {});
6605
- return _context34.abrupt("return", tempOrder);
6570
+ return _context33.abrupt("return", tempOrder);
6606
6571
  case 20:
6607
6572
  case "end":
6608
- return _context34.stop();
6573
+ return _context33.stop();
6609
6574
  }
6610
6575
  }, _callee31, this);
6611
6576
  }));
@@ -6624,8 +6589,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6624
6589
  var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
6625
6590
  var _this$store$discount22, _this$store$discount23;
6626
6591
  var tempOrder;
6627
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
6628
- while (1) switch (_context35.prev = _context35.next) {
6592
+ return _regeneratorRuntime().wrap(function _callee32$(_context34) {
6593
+ while (1) switch (_context34.prev = _context34.next) {
6629
6594
  case 0:
6630
6595
  tempOrder = this.ensureTempOrder();
6631
6596
  this.ensureSalesNotesLoadedForMutation(tempOrder);
@@ -6645,26 +6610,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6645
6610
  productsByUid: {}
6646
6611
  });
6647
6612
  }
6648
- _context35.next = 16;
6613
+ _context34.next = 16;
6649
6614
  return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
6650
6615
  case 16:
6651
- _context35.next = 18;
6616
+ _context34.next = 18;
6652
6617
  return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
6653
6618
  case 18:
6654
6619
  this.hasActiveCustomerBoundDiscount = false;
6655
6620
  this.lastUnfulfilledPromotions = [];
6656
6621
  this.lastGiftActions = null;
6657
- _context35.next = 23;
6622
+ _context34.next = 23;
6658
6623
  return this.recalculateSummary({
6659
6624
  createIfMissing: true
6660
6625
  });
6661
6626
  case 23:
6662
6627
  this.persistTempOrder();
6663
6628
  this.logInfo('clearOrderForSettlementSwitch success', {});
6664
- return _context35.abrupt("return", tempOrder);
6629
+ return _context34.abrupt("return", tempOrder);
6665
6630
  case 26:
6666
6631
  case "end":
6667
- return _context35.stop();
6632
+ return _context34.stop();
6668
6633
  }
6669
6634
  }, _callee32, this);
6670
6635
  }));
@@ -6706,15 +6671,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6706
6671
  value: function () {
6707
6672
  var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
6708
6673
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
6709
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
6710
- while (1) switch (_context36.prev = _context36.next) {
6674
+ return _regeneratorRuntime().wrap(function _callee33$(_context35) {
6675
+ while (1) switch (_context35.prev = _context35.next) {
6711
6676
  case 0:
6712
6677
  tempOrder = this.ensureTempOrder();
6713
6678
  if (!(!order || _typeof(order) !== 'object')) {
6714
- _context36.next = 3;
6679
+ _context35.next = 3;
6715
6680
  break;
6716
6681
  }
6717
- return _context36.abrupt("return", tempOrder);
6682
+ return _context35.abrupt("return", tempOrder);
6718
6683
  case 3:
6719
6684
  shopOrderNumber = order.shop_order_number;
6720
6685
  shopFullOrderNumber = order.shop_full_order_number;
@@ -6725,13 +6690,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6725
6690
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
6726
6691
  }
6727
6692
  this.persistTempOrder();
6728
- _context36.next = 10;
6693
+ _context35.next = 10;
6729
6694
  return this.saveDraft();
6730
6695
  case 10:
6731
- return _context36.abrupt("return", tempOrder);
6696
+ return _context35.abrupt("return", tempOrder);
6732
6697
  case 11:
6733
6698
  case "end":
6734
- return _context36.stop();
6699
+ return _context35.stop();
6735
6700
  }
6736
6701
  }, _callee33, this);
6737
6702
  }));
@@ -6746,32 +6711,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6746
6711
  var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
6747
6712
  var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
6748
6713
  var tempOrder, latestSummary, payload;
6749
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
6750
- while (1) switch (_context37.prev = _context37.next) {
6714
+ return _regeneratorRuntime().wrap(function _callee34$(_context36) {
6715
+ while (1) switch (_context36.prev = _context36.next) {
6751
6716
  case 0:
6752
6717
  tempOrder = this.ensureTempOrder();
6753
6718
  this.ensureExternalSaleNumber(tempOrder);
6754
6719
  this.persistTempOrder();
6755
- _context37.next = 5;
6720
+ _context36.next = 5;
6756
6721
  return this.recalculateSummary({
6757
6722
  createIfMissing: true
6758
6723
  });
6759
6724
  case 5:
6760
- _context37.t1 = _context37.sent;
6761
- if (_context37.t1) {
6762
- _context37.next = 8;
6725
+ _context36.t1 = _context36.sent;
6726
+ if (_context36.t1) {
6727
+ _context36.next = 8;
6763
6728
  break;
6764
6729
  }
6765
- _context37.t1 = this.store.summary;
6730
+ _context36.t1 = this.store.summary;
6766
6731
  case 8:
6767
- _context37.t0 = _context37.t1;
6768
- if (_context37.t0) {
6769
- _context37.next = 11;
6732
+ _context36.t0 = _context36.t1;
6733
+ if (_context36.t0) {
6734
+ _context36.next = 11;
6770
6735
  break;
6771
6736
  }
6772
- _context37.t0 = createEmptySummary();
6737
+ _context36.t0 = createEmptySummary();
6773
6738
  case 11:
6774
- latestSummary = _context37.t0;
6739
+ latestSummary = _context36.t0;
6775
6740
  payload = buildSubmitPayload({
6776
6741
  tempOrder: tempOrder,
6777
6742
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
@@ -6792,13 +6757,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6792
6757
  externalSaleNumber: payload.external_sale_number,
6793
6758
  productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
6794
6759
  });
6795
- return _context37.abrupt("return", this.request.post('/order/sales/draft', payload, {
6760
+ return _context36.abrupt("return", this.request.post('/order/sales/draft', payload, {
6796
6761
  osServer: true,
6797
6762
  customToast: function customToast() {}
6798
6763
  }));
6799
6764
  case 18:
6800
6765
  case "end":
6801
- return _context37.stop();
6766
+ return _context36.stop();
6802
6767
  }
6803
6768
  }, _callee34, this);
6804
6769
  }));
@@ -6817,13 +6782,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6817
6782
  key: "submitTempOrder",
6818
6783
  value: (function () {
6819
6784
  var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
6820
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
6821
- while (1) switch (_context38.prev = _context38.next) {
6785
+ return _regeneratorRuntime().wrap(function _callee35$(_context37) {
6786
+ while (1) switch (_context37.prev = _context37.next) {
6822
6787
  case 0:
6823
- return _context38.abrupt("return", this.runSubmitTempOrder(params));
6788
+ return _context37.abrupt("return", this.runSubmitTempOrder(params));
6824
6789
  case 1:
6825
6790
  case "end":
6826
- return _context38.stop();
6791
+ return _context37.stop();
6827
6792
  }
6828
6793
  }, _callee35, this);
6829
6794
  }));
@@ -6836,15 +6801,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6836
6801
  key: "submitTempOrderAsync",
6837
6802
  value: function () {
6838
6803
  var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
6839
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
6840
- while (1) switch (_context39.prev = _context39.next) {
6804
+ return _regeneratorRuntime().wrap(function _callee36$(_context38) {
6805
+ while (1) switch (_context38.prev = _context38.next) {
6841
6806
  case 0:
6842
- return _context39.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
6807
+ return _context38.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
6843
6808
  syncMode: true
6844
6809
  })));
6845
6810
  case 1:
6846
6811
  case "end":
6847
- return _context39.stop();
6812
+ return _context38.stop();
6848
6813
  }
6849
6814
  }, _callee36, this);
6850
6815
  }));
@@ -6859,12 +6824,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6859
6824
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6860
6825
  var _params$cacheId3, _this$otherParams12, _ref92, _ref93, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6861
6826
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6862
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6863
- while (1) switch (_context40.prev = _context40.next) {
6827
+ return _regeneratorRuntime().wrap(function _callee37$(_context39) {
6828
+ while (1) switch (_context39.prev = _context39.next) {
6864
6829
  case 0:
6865
6830
  tempOrder = this.ensureTempOrder();
6866
6831
  if (!requiresLocalPaymentRefresh(tempOrder)) {
6867
- _context40.next = 3;
6832
+ _context39.next = 3;
6868
6833
  break;
6869
6834
  }
6870
6835
  throw new Error(PAYMENT_REFRESH_MESSAGE);
@@ -6890,26 +6855,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6890
6855
  }
6891
6856
  }
6892
6857
  this.persistTempOrder();
6893
- _context40.next = 12;
6858
+ _context39.next = 12;
6894
6859
  return this.recalculateSummary({
6895
6860
  createIfMissing: true
6896
6861
  });
6897
6862
  case 12:
6898
- _context40.t1 = _context40.sent;
6899
- if (_context40.t1) {
6900
- _context40.next = 15;
6863
+ _context39.t1 = _context39.sent;
6864
+ if (_context39.t1) {
6865
+ _context39.next = 15;
6901
6866
  break;
6902
6867
  }
6903
- _context40.t1 = this.store.summary;
6868
+ _context39.t1 = this.store.summary;
6904
6869
  case 15:
6905
- _context40.t0 = _context40.t1;
6906
- if (_context40.t0) {
6907
- _context40.next = 18;
6870
+ _context39.t0 = _context39.t1;
6871
+ if (_context39.t0) {
6872
+ _context39.next = 18;
6908
6873
  break;
6909
6874
  }
6910
- _context40.t0 = createEmptySummary();
6875
+ _context39.t0 = createEmptySummary();
6911
6876
  case 18:
6912
- latestSummary = _context40.t0;
6877
+ latestSummary = _context39.t0;
6913
6878
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
6914
6879
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
6915
6880
  shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
@@ -6945,10 +6910,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6945
6910
  if (!payload.created_at) {
6946
6911
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
6947
6912
  }
6948
- _context40.next = 30;
6913
+ _context39.next = 30;
6949
6914
  return this.saveDraft();
6950
6915
  case 30:
6951
- _context40.prev = 30;
6916
+ _context39.prev = 30;
6952
6917
  this.logInfo('submitTempOrder calling sales checkout', {
6953
6918
  orderId: payload.order_id,
6954
6919
  externalSaleNumber: payload.external_sale_number,
@@ -6958,43 +6923,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6958
6923
  smallTicketDataFlag: payload.small_ticket_data_flag,
6959
6924
  syncMode: payload.sync_mode
6960
6925
  });
6961
- _context40.next = 34;
6926
+ _context39.next = 34;
6962
6927
  return this.submitSalesOrder({
6963
6928
  query: payload
6964
6929
  });
6965
6930
  case 34:
6966
- result = _context40.sent;
6967
- _context40.next = 47;
6931
+ result = _context39.sent;
6932
+ _context39.next = 47;
6968
6933
  break;
6969
6934
  case 37:
6970
- _context40.prev = 37;
6971
- _context40.t2 = _context40["catch"](30);
6972
- backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
6935
+ _context39.prev = 37;
6936
+ _context39.t2 = _context39["catch"](30);
6937
+ backendErrorResponse = this.extractSubmitErrorResponse(_context39.t2);
6973
6938
  if (!backendErrorResponse) {
6974
- _context40.next = 44;
6939
+ _context39.next = 44;
6975
6940
  break;
6976
6941
  }
6977
6942
  this.store.syncState = 'failed';
6978
6943
  this.logSubmitBackendRejected(backendErrorResponse, payload);
6979
- return _context40.abrupt("return", backendErrorResponse);
6944
+ return _context39.abrupt("return", backendErrorResponse);
6980
6945
  case 44:
6981
6946
  this.store.syncState = 'failed';
6982
6947
  this.logError('submitTempOrder failed', {
6983
- error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
6948
+ error: _context39.t2 instanceof Error ? _context39.t2.message : String(_context39.t2),
6984
6949
  orderId: payload.order_id,
6985
6950
  externalSaleNumber: payload.external_sale_number,
6986
6951
  paymentStatus: payload.payment_status,
6987
6952
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
6988
6953
  });
6989
- throw _context40.t2;
6954
+ throw _context39.t2;
6990
6955
  case 47:
6991
6956
  if (!this.isSubmitResponseRejected(result)) {
6992
- _context40.next = 51;
6957
+ _context39.next = 51;
6993
6958
  break;
6994
6959
  }
6995
6960
  this.store.syncState = 'failed';
6996
6961
  this.logSubmitBackendRejected(result, payload);
6997
- return _context40.abrupt("return", result);
6962
+ return _context39.abrupt("return", result);
6998
6963
  case 51:
6999
6964
  isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
7000
6965
  if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
@@ -7010,12 +6975,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7010
6975
  })
7011
6976
  });
7012
6977
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
7013
- _context40.next = 60;
6978
+ _context39.next = 60;
7014
6979
  break;
7015
6980
  }
7016
6981
  tempOrder.order_id = submittedOrderId;
7017
6982
  resultRecord = result;
7018
- _context40.next = 60;
6983
+ _context39.next = 60;
7019
6984
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
7020
6985
  case 60:
7021
6986
  if (isLocalPendingSubmit) {
@@ -7023,10 +6988,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7023
6988
  } else if (submittedOrderId === null || submittedOrderId === undefined) {
7024
6989
  this.store.syncState = 'submitted';
7025
6990
  }
7026
- return _context40.abrupt("return", result);
6991
+ return _context39.abrupt("return", result);
7027
6992
  case 62:
7028
6993
  case "end":
7029
- return _context40.stop();
6994
+ return _context39.stop();
7030
6995
  }
7031
6996
  }, _callee37, this, [[30, 37]]);
7032
6997
  }));
@@ -7040,8 +7005,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7040
7005
  value: function () {
7041
7006
  var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderId, remoteOrder) {
7042
7007
  var tempOrder;
7043
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
7044
- while (1) switch (_context41.prev = _context41.next) {
7008
+ return _regeneratorRuntime().wrap(function _callee38$(_context40) {
7009
+ while (1) switch (_context40.prev = _context40.next) {
7045
7010
  case 0:
7046
7011
  tempOrder = this.ensureTempOrder();
7047
7012
  tempOrder.order_id = orderId;
@@ -7049,11 +7014,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7049
7014
  this.store.lastOrderInfo = remoteOrder;
7050
7015
  this.store.syncState = 'submitted';
7051
7016
  this.persistTempOrder();
7052
- _context41.next = 8;
7017
+ _context40.next = 8;
7053
7018
  return this.saveDraft();
7054
7019
  case 8:
7055
7020
  case "end":
7056
- return _context41.stop();
7021
+ return _context40.stop();
7057
7022
  }
7058
7023
  }, _callee38, this);
7059
7024
  }));
@@ -7100,10 +7065,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7100
7065
  value: function extractSubmitErrorResponse(error) {
7101
7066
  var _error$response,
7102
7067
  _error$response2,
7103
- _this39 = this;
7068
+ _this38 = this;
7104
7069
  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];
7105
7070
  return candidates.find(function (candidate) {
7106
- return _this39.isSubmitErrorResponse(candidate);
7071
+ return _this38.isSubmitErrorResponse(candidate);
7107
7072
  }) || null;
7108
7073
  }
7109
7074
  }, {
@@ -7131,32 +7096,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7131
7096
  key: "syncPaymentsToOrder",
7132
7097
  value: function () {
7133
7098
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
7134
- var _this40 = this,
7099
+ var _this39 = this,
7135
7100
  _params$confirmPendin;
7136
7101
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
7137
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
7138
- while (1) switch (_context42.prev = _context42.next) {
7102
+ return _regeneratorRuntime().wrap(function _callee39$(_context41) {
7103
+ while (1) switch (_context41.prev = _context41.next) {
7139
7104
  case 0:
7140
7105
  tempOrder = this.ensureTempOrder();
7141
7106
  needsPaymentNumber = (params.payments || []).some(function (payment) {
7142
7107
  return String(payment.payment_number || '').trim() === '';
7143
7108
  });
7144
7109
  if (!needsPaymentNumber) {
7145
- _context42.next = 8;
7110
+ _context41.next = 8;
7146
7111
  break;
7147
7112
  }
7148
- _context42.next = 5;
7113
+ _context41.next = 5;
7149
7114
  return this.getPaymentNumberDevicePrefixAsync();
7150
7115
  case 5:
7151
- _context42.t0 = _context42.sent;
7152
- _context42.next = 9;
7116
+ _context41.t0 = _context41.sent;
7117
+ _context41.next = 9;
7153
7118
  break;
7154
7119
  case 8:
7155
- _context42.t0 = 'LOCAL';
7120
+ _context41.t0 = 'LOCAL';
7156
7121
  case 9:
7157
- devicePrefix = _context42.t0;
7122
+ devicePrefix = _context41.t0;
7158
7123
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
7159
- return _this40.normalizePaymentSource(payment, {
7124
+ return _this39.normalizePaymentSource(payment, {
7160
7125
  defaultPaid: false,
7161
7126
  devicePrefix: devicePrefix
7162
7127
  });
@@ -7169,20 +7134,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7169
7134
  tempOrder.payments = effectivePayments;
7170
7135
  tempOrder.payment_status = paymentStatus;
7171
7136
  this.persistTempOrder();
7172
- _context42.next = 21;
7137
+ _context41.next = 21;
7173
7138
  return this.saveDraft();
7174
7139
  case 21:
7175
7140
  if (params.submitWhenPaid) {
7176
- _context42.next = 23;
7141
+ _context41.next = 23;
7177
7142
  break;
7178
7143
  }
7179
- return _context42.abrupt("return", completion);
7144
+ return _context41.abrupt("return", completion);
7180
7145
  case 23:
7181
7146
  if (!(this.store.syncState === 'submitting')) {
7182
- _context42.next = 25;
7147
+ _context41.next = 25;
7183
7148
  break;
7184
7149
  }
7185
- return _context42.abrupt("return", completion);
7150
+ return _context41.abrupt("return", completion);
7186
7151
  case 25:
7187
7152
  this.store.syncState = 'submitting';
7188
7153
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
@@ -7202,28 +7167,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7202
7167
  enhancePayload: enhancePayload
7203
7168
  };
7204
7169
  if (!(params.checkoutSyncTaskEnabled === false)) {
7205
- _context42.next = 35;
7170
+ _context41.next = 35;
7206
7171
  break;
7207
7172
  }
7208
- _context42.next = 32;
7173
+ _context41.next = 32;
7209
7174
  return this.submitTempOrderAsync(submitParams);
7210
7175
  case 32:
7211
- _context42.t1 = _context42.sent;
7212
- _context42.next = 38;
7176
+ _context41.t1 = _context41.sent;
7177
+ _context41.next = 38;
7213
7178
  break;
7214
7179
  case 35:
7215
- _context42.next = 37;
7180
+ _context41.next = 37;
7216
7181
  return this.submitTempOrder(submitParams);
7217
7182
  case 37:
7218
- _context42.t1 = _context42.sent;
7183
+ _context41.t1 = _context41.sent;
7219
7184
  case 38:
7220
- submitResult = _context42.t1;
7221
- return _context42.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
7185
+ submitResult = _context41.t1;
7186
+ return _context41.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
7222
7187
  submitResult: submitResult
7223
7188
  }));
7224
7189
  case 40:
7225
7190
  case "end":
7226
- return _context42.stop();
7191
+ return _context41.stop();
7227
7192
  }
7228
7193
  }, _callee39, this);
7229
7194
  }));
@@ -7235,7 +7200,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7235
7200
  }, {
7236
7201
  key: "createOrder",
7237
7202
  value: function createOrder(params) {
7238
- var _this41 = this;
7203
+ var _this40 = this;
7239
7204
  var order = _objectSpread({
7240
7205
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
7241
7206
  // 要从外面拿,virtual
@@ -7267,7 +7232,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7267
7232
 
7268
7233
  // 为预约补齐 holder 信息
7269
7234
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
7270
- ensureCartItemOriginHolder(item, _this41.window);
7235
+ ensureCartItemOriginHolder(item, _this40.window);
7271
7236
  }
7272
7237
 
7273
7238
  // 购物车是否为普通商品
@@ -7327,8 +7292,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7327
7292
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order) {
7328
7293
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
7329
7294
  var url, query, fetchUrl, params;
7330
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
7331
- while (1) switch (_context43.prev = _context43.next) {
7295
+ return _regeneratorRuntime().wrap(function _callee40$(_context42) {
7296
+ while (1) switch (_context42.prev = _context42.next) {
7332
7297
  case 0:
7333
7298
  this.logInfo('submitOrder called', {
7334
7299
  url: order.url,
@@ -7348,10 +7313,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7348
7313
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
7349
7314
  scheduleDate: params.schedule_date
7350
7315
  });
7351
- return _context43.abrupt("return", this.request.post(fetchUrl, params));
7316
+ return _context42.abrupt("return", this.request.post(fetchUrl, params));
7352
7317
  case 6:
7353
7318
  case "end":
7354
- return _context43.stop();
7319
+ return _context42.stop();
7355
7320
  }
7356
7321
  }, _callee40, this);
7357
7322
  }));
@@ -7365,11 +7330,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7365
7330
  value: function () {
7366
7331
  var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
7367
7332
  var payload;
7368
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
7369
- while (1) switch (_context44.prev = _context44.next) {
7333
+ return _regeneratorRuntime().wrap(function _callee41$(_context43) {
7334
+ while (1) switch (_context43.prev = _context43.next) {
7370
7335
  case 0:
7371
7336
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
7372
- _context44.next = 2;
7337
+ _context43.next = 2;
7373
7338
  break;
7374
7339
  }
7375
7340
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -7385,12 +7350,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7385
7350
  method: 'PUT',
7386
7351
  orderIdsCount: params.order_ids.length
7387
7352
  });
7388
- return _context44.abrupt("return", this.request.put('/order/update-status', payload, {
7353
+ return _context43.abrupt("return", this.request.put('/order/update-status', payload, {
7389
7354
  isShopApi: true
7390
7355
  }));
7391
7356
  case 5:
7392
7357
  case "end":
7393
- return _context44.stop();
7358
+ return _context43.stop();
7394
7359
  }
7395
7360
  }, _callee41, this);
7396
7361
  }));
@@ -7404,17 +7369,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7404
7369
  value: function () {
7405
7370
  var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
7406
7371
  var url, payload;
7407
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
7408
- while (1) switch (_context45.prev = _context45.next) {
7372
+ return _regeneratorRuntime().wrap(function _callee42$(_context44) {
7373
+ while (1) switch (_context44.prev = _context44.next) {
7409
7374
  case 0:
7410
7375
  if (params.booking_id) {
7411
- _context45.next = 2;
7376
+ _context44.next = 2;
7412
7377
  break;
7413
7378
  }
7414
7379
  throw new Error('变更预约状态失败:booking_id 不能为空');
7415
7380
  case 2:
7416
7381
  if (params.appointment_status) {
7417
- _context45.next = 4;
7382
+ _context44.next = 4;
7418
7383
  break;
7419
7384
  }
7420
7385
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -7429,12 +7394,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7429
7394
  bookingId: params.booking_id,
7430
7395
  appointmentStatus: params.appointment_status
7431
7396
  });
7432
- return _context45.abrupt("return", this.request.put(url, payload, {
7397
+ return _context44.abrupt("return", this.request.put(url, payload, {
7433
7398
  isShopApi: true
7434
7399
  }));
7435
7400
  case 8:
7436
7401
  case "end":
7437
- return _context45.stop();
7402
+ return _context44.stop();
7438
7403
  }
7439
7404
  }, _callee42, this);
7440
7405
  }));
@@ -7459,8 +7424,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7459
7424
  var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
7460
7425
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
7461
7426
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
7462
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
7463
- while (1) switch (_context46.prev = _context46.next) {
7427
+ return _regeneratorRuntime().wrap(function _callee43$(_context45) {
7428
+ while (1) switch (_context45.prev = _context45.next) {
7464
7429
  case 0:
7465
7430
  // 过滤掉由在线店铺下单的 payment 支付数据
7466
7431
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -7485,7 +7450,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7485
7450
  return p.code;
7486
7451
  })) || []
7487
7452
  });
7488
- _context46.prev = 3;
7453
+ _context45.prev = 3;
7489
7454
  // 构建订单数据,设置默认值并允许 params 覆盖
7490
7455
  orderData = _objectSpread({
7491
7456
  sales_channel: 'my_pisel',
@@ -7533,28 +7498,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7533
7498
  hasOrderId: !!orderData.order_id,
7534
7499
  smallTicketDataFlag: orderData.small_ticket_data_flag
7535
7500
  });
7536
- _context46.next = 10;
7501
+ _context45.next = 10;
7537
7502
  return this.request.post('/order/checkout', orderData, {
7538
7503
  osServer: true,
7539
7504
  customToast: function customToast() {}
7540
7505
  });
7541
7506
  case 10:
7542
- response = _context46.sent;
7507
+ response = _context45.sent;
7543
7508
  this.logInfo('Order API called successfully', {
7544
7509
  response: response
7545
7510
  });
7546
- return _context46.abrupt("return", response);
7511
+ return _context45.abrupt("return", response);
7547
7512
  case 15:
7548
- _context46.prev = 15;
7549
- _context46.t0 = _context46["catch"](3);
7550
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context46.t0);
7513
+ _context45.prev = 15;
7514
+ _context45.t0 = _context45["catch"](3);
7515
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context45.t0);
7551
7516
  this.logInfo('Order API called failed', {
7552
- error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
7517
+ error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
7553
7518
  });
7554
- throw _context46.t0;
7519
+ throw _context45.t0;
7555
7520
  case 20:
7556
7521
  case "end":
7557
- return _context46.stop();
7522
+ return _context45.stop();
7558
7523
  }
7559
7524
  }, _callee43, this, [[3, 15]]);
7560
7525
  }));
@@ -7568,19 +7533,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7568
7533
  value: function () {
7569
7534
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
7570
7535
  var url, query, fetchUrl, requestQuery;
7571
- return _regeneratorRuntime().wrap(function _callee44$(_context47) {
7572
- while (1) switch (_context47.prev = _context47.next) {
7536
+ return _regeneratorRuntime().wrap(function _callee44$(_context46) {
7537
+ while (1) switch (_context46.prev = _context46.next) {
7573
7538
  case 0:
7574
7539
  url = params.url, query = params.query;
7575
7540
  fetchUrl = url || '/order/sales/checkout';
7576
7541
  requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
7577
- return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
7542
+ return _context46.abrupt("return", this.request.post(fetchUrl, requestQuery, {
7578
7543
  osServer: true,
7579
7544
  customToast: function customToast() {}
7580
7545
  }));
7581
7546
  case 4:
7582
7547
  case "end":
7583
- return _context47.stop();
7548
+ return _context46.stop();
7584
7549
  }
7585
7550
  }, _callee44, this);
7586
7551
  }));
@@ -7614,30 +7579,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7614
7579
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
7615
7580
  var _params$emails;
7616
7581
  var orderIds;
7617
- return _regeneratorRuntime().wrap(function _callee45$(_context48) {
7618
- while (1) switch (_context48.prev = _context48.next) {
7582
+ return _regeneratorRuntime().wrap(function _callee45$(_context47) {
7583
+ while (1) switch (_context47.prev = _context47.next) {
7619
7584
  case 0:
7620
7585
  orderIds = params.order_ids || params.orderIds || [];
7621
7586
  if (orderIds.length) {
7622
- _context48.next = 3;
7587
+ _context47.next = 3;
7623
7588
  break;
7624
7589
  }
7625
7590
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
7626
7591
  case 3:
7627
7592
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
7628
- _context48.next = 5;
7593
+ _context47.next = 5;
7629
7594
  break;
7630
7595
  }
7631
7596
  throw new Error('发送支付链接需要至少一个邮箱');
7632
7597
  case 5:
7633
- return _context48.abrupt("return", this.request.post('/order/batch-email', {
7598
+ return _context47.abrupt("return", this.request.post('/order/batch-email', {
7634
7599
  order_ids: orderIds,
7635
7600
  notify_action: params.notify_action || 'order_payment_reminder',
7636
7601
  emails: params.emails
7637
7602
  }));
7638
7603
  case 6:
7639
7604
  case "end":
7640
- return _context48.stop();
7605
+ return _context47.stop();
7641
7606
  }
7642
7607
  }, _callee45, this);
7643
7608
  }));
@@ -7651,12 +7616,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7651
7616
  value: function () {
7652
7617
  var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
7653
7618
  var lookup, res;
7654
- return _regeneratorRuntime().wrap(function _callee46$(_context49) {
7655
- while (1) switch (_context49.prev = _context49.next) {
7619
+ return _regeneratorRuntime().wrap(function _callee46$(_context48) {
7620
+ while (1) switch (_context48.prev = _context48.next) {
7656
7621
  case 0:
7657
7622
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
7658
7623
  if (lookup) {
7659
- _context49.next = 3;
7624
+ _context48.next = 3;
7660
7625
  break;
7661
7626
  }
7662
7627
  throw new Error('加载销售详情需要 lookup');
@@ -7665,21 +7630,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7665
7630
  if (lookup.startsWith('LOCAL_')) {
7666
7631
  params.forceRemote = false;
7667
7632
  }
7668
- _context49.next = 6;
7633
+ _context48.next = 6;
7669
7634
  return loadSalesOrderSnapshot(this.request, {
7670
7635
  lookup: lookup,
7671
7636
  transport: 'os-server',
7672
7637
  forceRemote: params.forceRemote
7673
7638
  });
7674
7639
  case 6:
7675
- res = _context49.sent;
7640
+ res = _context48.sent;
7676
7641
  if (res.code === 200) {
7677
7642
  this.store.lastOrderInfo = res.data;
7678
7643
  }
7679
- return _context49.abrupt("return", res);
7644
+ return _context48.abrupt("return", res);
7680
7645
  case 9:
7681
7646
  case "end":
7682
- return _context49.stop();
7647
+ return _context48.stop();
7683
7648
  }
7684
7649
  }, _callee46, this);
7685
7650
  }));
@@ -7700,8 +7665,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7700
7665
  var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(record, options) {
7701
7666
  var _sourceRaw$_extend, _this$store$discount26;
7702
7667
  var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
7703
- return _regeneratorRuntime().wrap(function _callee47$(_context50) {
7704
- while (1) switch (_context50.prev = _context50.next) {
7668
+ return _regeneratorRuntime().wrap(function _callee47$(_context49) {
7669
+ while (1) switch (_context49.prev = _context49.next) {
7705
7670
  case 0:
7706
7671
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
7707
7672
  duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
@@ -7743,7 +7708,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7743
7708
  this.store.tempOrder = nextTempOrder;
7744
7709
  this.clearCustomerWalletRuntimeState();
7745
7710
  if (!isSessionStorageHydrate) {
7746
- _context50.next = 31;
7711
+ _context49.next = 31;
7747
7712
  break;
7748
7713
  }
7749
7714
  // 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
@@ -7759,23 +7724,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7759
7724
  nextTempOrder.discount_list = restoredSessionDiscounts;
7760
7725
  this.store.summary = createEmptySummary();
7761
7726
  this.store.lastOrderInfo = undefined;
7762
- _context50.next = 24;
7727
+ _context49.next = 24;
7763
7728
  return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
7764
7729
  case 24:
7765
- _context50.next = 26;
7730
+ _context49.next = 26;
7766
7731
  return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
7767
7732
  case 26:
7768
7733
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
7769
- _context50.next = 29;
7734
+ _context49.next = 29;
7770
7735
  break;
7771
7736
  }
7772
- _context50.next = 29;
7737
+ _context49.next = 29;
7773
7738
  return this.recalculateSummary({
7774
7739
  createIfMissing: false
7775
7740
  });
7776
7741
  case 29:
7777
7742
  this.persistTempOrder();
7778
- return _context50.abrupt("return", nextTempOrder);
7743
+ return _context49.abrupt("return", nextTempOrder);
7779
7744
  case 31:
7780
7745
  // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
7781
7746
  sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
@@ -7828,30 +7793,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7828
7793
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
7829
7794
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
7830
7795
  if (shouldSkipEmptyDiscountSync) {
7831
- _context50.next = 55;
7796
+ _context49.next = 55;
7832
7797
  break;
7833
7798
  }
7834
7799
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
7835
- _context50.next = 53;
7800
+ _context49.next = 53;
7836
7801
  return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
7837
7802
  case 53:
7838
- _context50.next = 55;
7803
+ _context49.next = 55;
7839
7804
  return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
7840
7805
  case 55:
7841
7806
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
7842
- _context50.next = 58;
7807
+ _context49.next = 58;
7843
7808
  break;
7844
7809
  }
7845
- _context50.next = 58;
7810
+ _context49.next = 58;
7846
7811
  return this.recalculateSummary({
7847
7812
  createIfMissing: false
7848
7813
  });
7849
7814
  case 58:
7850
7815
  this.persistTempOrder();
7851
- return _context50.abrupt("return", nextTempOrder);
7816
+ return _context49.abrupt("return", nextTempOrder);
7852
7817
  case 60:
7853
7818
  case "end":
7854
- return _context50.stop();
7819
+ return _context49.stop();
7855
7820
  }
7856
7821
  }, _callee47, this);
7857
7822
  }));
@@ -7969,7 +7934,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7969
7934
  }, {
7970
7935
  key: "normalizeTempOrderForRuntime",
7971
7936
  value: function normalizeTempOrderForRuntime(raw, options) {
7972
- var _this42 = this,
7937
+ var _this41 = this,
7973
7938
  _raw$_extend;
7974
7939
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7975
7940
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7997,12 +7962,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7997
7962
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7998
7963
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7999
7964
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
8000
- return _this42.normalizeHydratedOrderProduct(p, {
7965
+ return _this41.normalizeHydratedOrderProduct(p, {
8001
7966
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
8002
7967
  });
8003
7968
  }) : [];
8004
7969
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
8005
- var booking = _this42.normalizeHydratedBookingHolder(b || {});
7970
+ var booking = _this41.normalizeHydratedBookingHolder(b || {});
8006
7971
  return _objectSpread(_objectSpread({}, booking), {}, {
8007
7972
  is_all: normalizeBookingIsAll(booking),
8008
7973
  sub_type: normalizeBookingSubType(booking)
@@ -8083,7 +8048,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8083
8048
  tempOrderExtend.productsByUid = productsByUid;
8084
8049
  this.hydrateLinkedBookingIdentity(nextTempOrder);
8085
8050
  nextTempOrder.products.forEach(function (product) {
8086
- return _this42.sanitizeOrderProductForTempOrder(product);
8051
+ return _this41.sanitizeOrderProductForTempOrder(product);
8087
8052
  });
8088
8053
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
8089
8054
  this.ensureExternalSaleNumber(nextTempOrder);
@@ -8212,7 +8177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8212
8177
  }, {
8213
8178
  key: "normalizeHydratedOrderProduct",
8214
8179
  value: function normalizeHydratedOrderProduct(product, options) {
8215
- var _this43 = this;
8180
+ var _this42 = this;
8216
8181
  var row = _objectSpread({}, product || {});
8217
8182
  if (row.num === undefined && row.product_quantity !== undefined) {
8218
8183
  row.num = row.product_quantity;
@@ -8220,7 +8185,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8220
8185
  var productSku = ensureProductSku(row);
8221
8186
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
8222
8187
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
8223
- return _this43.normalizeHydratedProductOptionItem(optionItem || {});
8188
+ return _this42.normalizeHydratedProductOptionItem(optionItem || {});
8224
8189
  }))
8225
8190
  });
8226
8191
  delete row["product_".concat('option', "_item")];
@@ -8282,21 +8247,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8282
8247
  value: function () {
8283
8248
  var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order_id) {
8284
8249
  var res;
8285
- return _regeneratorRuntime().wrap(function _callee48$(_context51) {
8286
- while (1) switch (_context51.prev = _context51.next) {
8250
+ return _regeneratorRuntime().wrap(function _callee48$(_context50) {
8251
+ while (1) switch (_context50.prev = _context50.next) {
8287
8252
  case 0:
8288
- _context51.next = 2;
8253
+ _context50.next = 2;
8289
8254
  return this.request.get("/order/sales/".concat(order_id), {
8290
8255
  with: ['products', 'bookings', 'notes']
8291
8256
  }, {
8292
8257
  osServer: true
8293
8258
  });
8294
8259
  case 2:
8295
- res = _context51.sent;
8296
- return _context51.abrupt("return", res);
8260
+ res = _context50.sent;
8261
+ return _context50.abrupt("return", res);
8297
8262
  case 4:
8298
8263
  case "end":
8299
- return _context51.stop();
8264
+ return _context50.stop();
8300
8265
  }
8301
8266
  }, _callee48, this);
8302
8267
  }));