@pisell/pisellos 0.10.63 → 0.10.65

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.
@@ -40,6 +40,7 @@ import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOrigi
40
40
  import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
41
41
  import dayjs from 'dayjs';
42
42
  import { getDiscountLifecycleReason } from "../Discount/availability";
43
+ import { allowsProductVoucher, productVoucherGroupKey, validateProductVoucherGroups, voucherGroupError } from "./utils/productVoucherGroups";
43
44
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
44
45
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
45
46
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
@@ -207,8 +208,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
207
208
  _createClass(OrderModule, [{
208
209
  key: "queueCartCommand",
209
210
  value: function queueCartCommand(run) {
210
- var _this$orderHooks;
211
- if (!((_this$orderHooks = this.orderHooks) !== null && _this$orderHooks !== void 0 && _this$orderHooks.onBeforeCartCommit)) return run();
211
+ var _this$orderHooks, _this$store$tempOrder;
212
+ if (!((_this$orderHooks = this.orderHooks) !== null && _this$orderHooks !== void 0 && _this$orderHooks.onBeforeCartCommit) && !((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder._extend) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.productVoucherGroups) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length)) return run();
212
213
  var pending = this.cartCommandQueue.then(run, run);
213
214
  this.cartCommandQueue = pending.catch(function () {
214
215
  return undefined;
@@ -221,10 +222,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
221
222
  key: "beginCartMutation",
222
223
  value: function beginCartMutation() {
223
224
  var _this$orderHooks2,
225
+ _current$_extend,
224
226
  _this2 = this;
225
227
  var current = this.ensureTempOrder();
226
228
  var guard = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.onBeforeCartCommit;
227
- if (!guard) return {
229
+ if (!guard && !((_current$_extend = current._extend) !== null && _current$_extend !== void 0 && (_current$_extend = _current$_extend.productVoucherGroups) !== null && _current$_extend !== void 0 && _current$_extend.length)) return {
228
230
  current: current,
229
231
  draft: current,
230
232
  commit: undefined
@@ -240,25 +242,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
240
242
  return _regeneratorRuntime().wrap(function _callee$(_context) {
241
243
  while (1) switch (_context.prev = _context.next) {
242
244
  case 0:
243
- _context.next = 2;
244
- return guard({
245
+ validateProductVoucherGroups(draft, _this2.getDiscountList(), before);
246
+ _context.next = 3;
247
+ return guard === null || guard === void 0 ? void 0 : guard({
245
248
  currentItems: cloneDeep(before.products),
246
249
  proposedItems: cloneDeep(draft.products)
247
250
  });
248
- case 2:
251
+ case 3:
249
252
  if (!(_this2.store.tempOrder !== current || guard !== ((_this2$orderHooks = _this2.orderHooks) === null || _this2$orderHooks === void 0 ? void 0 : _this2$orderHooks.onBeforeCartCommit) || !isEqual(current, before))) {
250
- _context.next = 4;
253
+ _context.next = 5;
251
254
  break;
252
255
  }
253
256
  throw Object.assign(new Error('The cart changed. Please try again.'), {
254
257
  code: 'SALES_GUARD_REJECTED'
255
258
  });
256
- case 4:
259
+ case 5:
257
260
  // Recheck the accepted intent's scope after asynchronous inventory validation.
258
261
  beforeCommit === null || beforeCommit === void 0 || beforeCommit();
259
262
  Object.assign(current, draft);
260
263
  return _context.abrupt("return", current);
261
- case 7:
264
+ case 8:
262
265
  case "end":
263
266
  return _context.stop();
264
267
  }
@@ -289,21 +292,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
289
292
  while (1) switch (_context2.prev = _context2.next) {
290
293
  case 0:
291
294
  order = _this3.ensureTempOrder();
295
+ validateProductVoucherGroups(order, _this3.getDiscountList(), undefined, true);
292
296
  items = cloneDeep(order.products);
293
- _context2.next = 4;
297
+ _context2.next = 5;
294
298
  return prepare(items);
295
- case 4:
299
+ case 5:
296
300
  result = _context2.sent;
297
301
  if (!(_this3.store.tempOrder !== order || !isEqual(order.products, items))) {
298
- _context2.next = 7;
302
+ _context2.next = 8;
299
303
  break;
300
304
  }
301
305
  throw Object.assign(new Error('The cart changed. Please try again.'), {
302
306
  code: 'SALES_GUARD_REJECTED'
303
307
  });
304
- case 7:
305
- return _context2.abrupt("return", result);
306
308
  case 8:
309
+ validateProductVoucherGroups(order, _this3.getDiscountList(), undefined, true);
310
+ return _context2.abrupt("return", result);
311
+ case 10:
307
312
  case "end":
308
313
  return _context2.stop();
309
314
  }
@@ -740,7 +745,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
740
745
  }, {
741
746
  key: "registerDiscountModules",
742
747
  value: function registerDiscountModules(options) {
743
- var _targetCacheData;
748
+ var _targetCacheData,
749
+ _this5 = this;
744
750
  var targetCacheData = {};
745
751
  if (!this.sessionStoragePersistEnabled && this.openCache && this.cacheId && this.window) {
746
752
  try {
@@ -769,17 +775,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
769
775
  hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
770
776
  });
771
777
  this.store.rules = rules;
778
+ rules.setDiscountScope(function (product, discount) {
779
+ return allowsProductVoucher(_this5.store.tempOrder, product, discount);
780
+ });
781
+ }
782
+ }, {
783
+ key: "setProductVoucherGroups",
784
+ value: function setProductVoucherGroups(groups) {
785
+ var order = this.ensureTempOrder();
786
+ var ids = new Set();
787
+ var keys = new Set();
788
+ var known = new Map(this.getDiscountList().map(function (discount) {
789
+ return [String(discount.id), discount];
790
+ }));
791
+ var _iterator3 = _createForOfIteratorHelper(groups),
792
+ _step3;
793
+ try {
794
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
795
+ var group = _step3.value;
796
+ if (!group.key || keys.has(group.key)) throw voucherGroupError();
797
+ keys.add(group.key);
798
+ var _iterator4 = _createForOfIteratorHelper(group.discountIds),
799
+ _step4;
800
+ try {
801
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
802
+ var id = _step4.value;
803
+ var discount = known.get(String(id));
804
+ if (!discount || (discount.tag || discount.type) !== 'good_pass' || ids.has(String(id))) throw voucherGroupError();
805
+ ids.add(String(id));
806
+ }
807
+ } catch (err) {
808
+ _iterator4.e(err);
809
+ } finally {
810
+ _iterator4.f();
811
+ }
812
+ }
813
+ } catch (err) {
814
+ _iterator3.e(err);
815
+ } finally {
816
+ _iterator3.f();
817
+ }
818
+ this.ensureExtend(order).productVoucherGroups = cloneDeep(groups);
819
+ }
820
+ }, {
821
+ key: "validateProductVoucherSelection",
822
+ value: function validateProductVoucherSelection() {
823
+ validateProductVoucherGroups(this.ensureTempOrder(), this.getDiscountList(), undefined, true);
772
824
  }
773
825
  }, {
774
826
  key: "createDefaultRulesHooks",
775
827
  value: function createDefaultRulesHooks() {
776
- var _this5 = this;
828
+ var _this6 = this;
777
829
  return createDefaultOrderRulesHooks(function () {
778
- var _this5$store$tempOrde;
779
- return ((_this5$store$tempOrde = _this5.store.tempOrder) === null || _this5$store$tempOrde === void 0 ? void 0 : _this5$store$tempOrde.bookings) || [];
830
+ var _this6$store$tempOrde;
831
+ return ((_this6$store$tempOrde = _this6.store.tempOrder) === null || _this6$store$tempOrde === void 0 ? void 0 : _this6$store$tempOrde.bookings) || [];
780
832
  }, function () {
781
- var _this5$store$tempOrde2;
782
- return (_this5$store$tempOrde2 = _this5.store.tempOrder) === null || _this5$store$tempOrde2 === void 0 ? void 0 : _this5$store$tempOrde2.holder_relations;
833
+ var _this6$store$tempOrde2;
834
+ return (_this6$store$tempOrde2 = _this6.store.tempOrder) === null || _this6$store$tempOrde2 === void 0 ? void 0 : _this6$store$tempOrde2.holder_relations;
783
835
  });
784
836
  }
785
837
 
@@ -800,15 +852,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
800
852
  key: "loadDiscountConfig",
801
853
  value: function () {
802
854
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
803
- var _this$store$tempOrder,
855
+ var _this$store$tempOrder2,
804
856
  _this$store$discount,
805
- _this6 = this,
806
- _this$store$tempOrder2;
857
+ _this7 = this,
858
+ _this$store$tempOrder3;
807
859
  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;
808
860
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
809
861
  while (1) switch (_context6.prev = _context6.next) {
810
862
  case 0:
811
- orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
863
+ orderId = params.orderId || ((_this$store$tempOrder2 = this.store.tempOrder) === null || _this$store$tempOrder2 === void 0 ? void 0 : _this$store$tempOrder2.order_id) || undefined;
812
864
  requestEpoch = ++this.customerWalletPrepareConfigEpoch;
813
865
  requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
814
866
  _context6.next = 5;
@@ -830,8 +882,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
830
882
  case 5:
831
883
  prepareConfigResult = _context6.sent;
832
884
  isCurrentRequest = function isCurrentRequest() {
833
- var _this6$store$tempOrde, _this6$store$tempOrde2;
834
- return requestEpoch === _this6.customerWalletPrepareConfigEpoch && _this6.getDiscountConfigOrderIdentityKey(_this6.store.tempOrder) === requestOrderIdentityKey && String((_this6$store$tempOrde = (_this6$store$tempOrde2 = _this6.store.tempOrder) === null || _this6$store$tempOrde2 === void 0 ? void 0 : _this6$store$tempOrde2.customer_id) !== null && _this6$store$tempOrde !== void 0 ? _this6$store$tempOrde : '') === String(params.customerId);
885
+ var _this7$store$tempOrde, _this7$store$tempOrde2;
886
+ return requestEpoch === _this7.customerWalletPrepareConfigEpoch && _this7.getDiscountConfigOrderIdentityKey(_this7.store.tempOrder) === requestOrderIdentityKey && String((_this7$store$tempOrde = (_this7$store$tempOrde2 = _this7.store.tempOrder) === null || _this7$store$tempOrde2 === void 0 ? void 0 : _this7$store$tempOrde2.customer_id) !== null && _this7$store$tempOrde !== void 0 ? _this7$store$tempOrde : '') === String(params.customerId);
835
887
  };
836
888
  if (isCurrentRequest()) {
837
889
  _context6.next = 9;
@@ -939,7 +991,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
939
991
  }
940
992
  return _context6.abrupt("return", this.getDiscountList());
941
993
  case 34:
942
- 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) {
994
+ if (params.apply !== false && (_this$store$tempOrder3 = this.store.tempOrder) !== null && _this$store$tempOrder3 !== void 0 && (_this$store$tempOrder3 = _this$store$tempOrder3.products) !== null && _this$store$tempOrder3 !== void 0 && _this$store$tempOrder3.length) {
943
995
  this.applyDiscount();
944
996
  }
945
997
  return _context6.abrupt("return", this.getDiscountList());
@@ -1061,9 +1113,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1061
1113
  }, {
1062
1114
  key: "scanCode",
1063
1115
  value: function () {
1064
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code, customerId) {
1116
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code, customerId, options) {
1065
1117
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
1066
- var beforeCommit, resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref17, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
1118
+ var beforeCommit, scanOrderKey, resultDiscountWithReason, unavailableReasonKey, resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref17, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
1067
1119
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1068
1120
  while (1) switch (_context9.prev = _context9.next) {
1069
1121
  case 0:
@@ -1081,26 +1133,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1081
1133
  unavailableReason: UnavailableReason.ProductNotApplicable
1082
1134
  });
1083
1135
  case 3:
1084
- _context9.next = 5;
1136
+ scanOrderKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
1137
+ _context9.next = 6;
1085
1138
  return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
1086
1139
  customerId: customerId
1087
1140
  });
1088
- case 5:
1141
+ case 6:
1089
1142
  _context9.t0 = _context9.sent;
1090
1143
  if (_context9.t0) {
1091
- _context9.next = 8;
1144
+ _context9.next = 9;
1092
1145
  break;
1093
1146
  }
1094
1147
  _context9.t0 = {
1095
1148
  discountList: [],
1096
1149
  unavailableReasonKey: null
1097
1150
  };
1098
- case 8:
1151
+ case 9:
1099
1152
  resultDiscountWithReason = _context9.t0;
1100
- resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
1153
+ if (!(scanOrderKey !== this.getDiscountConfigOrderIdentityKey(this.store.tempOrder))) {
1154
+ _context9.next = 12;
1155
+ break;
1156
+ }
1157
+ throw Object.assign(new Error('The scan session ended.'), {
1158
+ code: 'SALES_GUARD_REJECTED'
1159
+ });
1160
+ case 12:
1161
+ unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
1162
+ resultDiscountList = resultDiscountWithReason.discountList.filter(function (discount) {
1163
+ return !(options !== null && options !== void 0 && options.productVouchersOnly) || (discount.tag || discount.type) === 'good_pass';
1164
+ });
1101
1165
  rulesModule = this.store.rules;
1102
1166
  if (rulesModule) {
1103
- _context9.next = 13;
1167
+ _context9.next = 17;
1104
1168
  break;
1105
1169
  }
1106
1170
  return _context9.abrupt("return", {
@@ -1111,9 +1175,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1111
1175
  scannedDiscountList: resultDiscountList,
1112
1176
  unavailableReason: UnavailableReason.Unknown
1113
1177
  });
1114
- case 13:
1178
+ case 17:
1115
1179
  if (resultDiscountList.length) {
1116
- _context9.next = 15;
1180
+ _context9.next = 19;
1117
1181
  break;
1118
1182
  }
1119
1183
  return _context9.abrupt("return", {
@@ -1124,7 +1188,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1124
1188
  scannedDiscountList: resultDiscountList,
1125
1189
  unavailableReasonKey: unavailableReasonKey
1126
1190
  });
1127
- case 15:
1191
+ case 19:
1128
1192
  withScanList = resultDiscountList.map(function (item) {
1129
1193
  return _objectSpread(_objectSpread({}, item), {}, {
1130
1194
  isScan: true
@@ -1133,18 +1197,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1133
1197
  currentSelected = this.getDiscountList().filter(function (n) {
1134
1198
  return n.isSelected;
1135
1199
  });
1136
- if (!(currentSelected.length && currentSelected.some(function (n) {
1200
+ if (!(currentSelected.length && (options !== null && options !== void 0 && options.productVouchersOnly ? withScanList.every(function (scanned) {
1201
+ return currentSelected.some(function (selected) {
1202
+ return selected.id === scanned.id;
1203
+ });
1204
+ }) : currentSelected.some(function (n) {
1137
1205
  return withScanList.some(function (m) {
1138
1206
  return m.id === n.id;
1139
1207
  });
1140
- }))) {
1141
- _context9.next = 22;
1208
+ })))) {
1209
+ _context9.next = 26;
1142
1210
  break;
1143
1211
  }
1144
1212
  beforeCommit();
1145
- _context9.next = 21;
1213
+ _context9.next = 25;
1146
1214
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1147
- case 21:
1215
+ case 25:
1148
1216
  return _context9.abrupt("return", {
1149
1217
  type: 'clientCalc',
1150
1218
  isAvailable: true,
@@ -1152,7 +1220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1152
1220
  discountList: this.getDiscountList(),
1153
1221
  scannedDiscountList: resultDiscountList
1154
1222
  });
1155
- case 22:
1223
+ case 26:
1156
1224
  tempOrder = this.store.tempOrder;
1157
1225
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
1158
1226
  _ref17 = rulesModule.isDiscountListAvailable({
@@ -1178,13 +1246,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1178
1246
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
1179
1247
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
1180
1248
  if (!(isAvailable && normalizedNewDiscountList)) {
1181
- _context9.next = 40;
1249
+ _context9.next = 44;
1182
1250
  break;
1183
1251
  }
1184
1252
  beforeCommit();
1185
- _context9.next = 34;
1253
+ _context9.next = 38;
1186
1254
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
1187
- case 34:
1255
+ case 38:
1188
1256
  // 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
1189
1257
  this.applyDiscount({
1190
1258
  preferredEntitlementPassIds: withScanList.filter(function (discount) {
@@ -1193,15 +1261,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1193
1261
  return discount.id;
1194
1262
  })
1195
1263
  });
1196
- _context9.next = 37;
1264
+ _context9.next = 41;
1197
1265
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1198
- case 37:
1266
+ case 41:
1199
1267
  resolvedDiscountList = this.getDiscountList();
1200
- _context9.next = 49;
1268
+ _context9.next = 53;
1201
1269
  break;
1202
- case 40:
1270
+ case 44:
1203
1271
  if (!shouldRetainForLater) {
1204
- _context9.next = 49;
1272
+ _context9.next = 53;
1205
1273
  break;
1206
1274
  }
1207
1275
  beforeCommit();
@@ -1219,14 +1287,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1219
1287
  savedAmount: 0
1220
1288
  }));
1221
1289
  });
1222
- _context9.next = 46;
1290
+ _context9.next = 50;
1223
1291
  return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
1224
- case 46:
1225
- _context9.next = 48;
1292
+ case 50:
1293
+ _context9.next = 52;
1226
1294
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1227
- case 48:
1295
+ case 52:
1228
1296
  resolvedDiscountList = this.getDiscountList();
1229
- case 49:
1297
+ case 53:
1230
1298
  return _context9.abrupt("return", {
1231
1299
  type: 'clientCalc',
1232
1300
  isAvailable: isAvailable || false,
@@ -1235,13 +1303,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1235
1303
  scannedDiscountList: evaluatedScannedDiscounts,
1236
1304
  unavailableReason: unavailableReason
1237
1305
  });
1238
- case 50:
1306
+ case 54:
1239
1307
  case "end":
1240
1308
  return _context9.stop();
1241
1309
  }
1242
1310
  }, _callee9, this);
1243
1311
  }));
1244
- function scanCode(_x8, _x9) {
1312
+ function scanCode(_x8, _x9, _x10) {
1245
1313
  return _scanCode.apply(this, arguments);
1246
1314
  }
1247
1315
  return scanCode;
@@ -1251,7 +1319,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1251
1319
  value: function applyDiscount(options) {
1252
1320
  var _this$store$discount16,
1253
1321
  _this$store$summary2,
1254
- _this7 = this;
1322
+ _this8 = this;
1255
1323
  var tempOrder = this.store.tempOrder;
1256
1324
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
1257
1325
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -1309,7 +1377,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1309
1377
  (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
1310
1378
  }
1311
1379
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
1312
- return _this7.productHasCustomerBoundDiscount(product);
1380
+ return _this8.productHasCustomerBoundDiscount(product);
1313
1381
  });
1314
1382
  }
1315
1383
 
@@ -1372,8 +1440,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1372
1440
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1373
1441
  var _this$promotionEvalua,
1374
1442
  _this$promotionEvalua2,
1375
- _this8 = this;
1376
- var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
1443
+ _this9 = this;
1444
+ var tempOrder, strategyConfigs, result, removeSet, _iterator5, _step5, reduce, _iterator8, _step8, _loop2, _iterator6, _step6, _loop, payload;
1377
1445
  return _regeneratorRuntime().wrap(function _callee10$(_context12) {
1378
1446
  while (1) switch (_context12.prev = _context12.next) {
1379
1447
  case 0:
@@ -1422,23 +1490,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1422
1490
  }
1423
1491
 
1424
1492
  // step 2: toReduce —— 调整数量
1425
- _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
1493
+ _iterator5 = _createForOfIteratorHelper(result.giftActions.toReduce);
1426
1494
  _context12.prev = 18;
1427
- _iterator3.s();
1495
+ _iterator5.s();
1428
1496
  case 20:
1429
- if ((_step3 = _iterator3.n()).done) {
1497
+ if ((_step5 = _iterator5.n()).done) {
1430
1498
  _context12.next = 40;
1431
1499
  break;
1432
1500
  }
1433
- reduce = _step3.value;
1434
- _iterator6 = _createForOfIteratorHelper(reduce.items);
1501
+ reduce = _step5.value;
1502
+ _iterator8 = _createForOfIteratorHelper(reduce.items);
1435
1503
  _context12.prev = 23;
1436
1504
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
1437
1505
  var item, product;
1438
1506
  return _regeneratorRuntime().wrap(function _loop2$(_context11) {
1439
1507
  while (1) switch (_context11.prev = _context11.next) {
1440
1508
  case 0:
1441
- item = _step6.value;
1509
+ item = _step8.value;
1442
1510
  product = result.products.find(function (p) {
1443
1511
  return getPromotionUid(p) === item.uid;
1444
1512
  });
@@ -1451,9 +1519,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1451
1519
  }
1452
1520
  }, _loop2);
1453
1521
  });
1454
- _iterator6.s();
1522
+ _iterator8.s();
1455
1523
  case 26:
1456
- if ((_step6 = _iterator6.n()).done) {
1524
+ if ((_step8 = _iterator8.n()).done) {
1457
1525
  _context12.next = 30;
1458
1526
  break;
1459
1527
  }
@@ -1467,10 +1535,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1467
1535
  case 32:
1468
1536
  _context12.prev = 32;
1469
1537
  _context12.t1 = _context12["catch"](23);
1470
- _iterator6.e(_context12.t1);
1538
+ _iterator8.e(_context12.t1);
1471
1539
  case 35:
1472
1540
  _context12.prev = 35;
1473
- _iterator6.f();
1541
+ _iterator8.f();
1474
1542
  return _context12.finish(35);
1475
1543
  case 38:
1476
1544
  _context12.next = 20;
@@ -1481,10 +1549,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1481
1549
  case 42:
1482
1550
  _context12.prev = 42;
1483
1551
  _context12.t2 = _context12["catch"](18);
1484
- _iterator3.e(_context12.t2);
1552
+ _iterator5.e(_context12.t2);
1485
1553
  case 45:
1486
1554
  _context12.prev = 45;
1487
- _iterator3.f();
1555
+ _iterator5.f();
1488
1556
  return _context12.finish(45);
1489
1557
  case 48:
1490
1558
  if (!(result.giftActions.toAdd.length > 0)) {
@@ -1506,14 +1574,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1506
1574
  _context12.next = 71;
1507
1575
  break;
1508
1576
  case 53:
1509
- _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
1577
+ _iterator6 = _createForOfIteratorHelper(result.giftActions.toAdd);
1510
1578
  _context12.prev = 54;
1511
1579
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1512
- var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
1580
+ var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator7, _step7, _step7$value, index, gp, booking, linked;
1513
1581
  return _regeneratorRuntime().wrap(function _loop$(_context10) {
1514
1582
  while (1) switch (_context10.prev = _context10.next) {
1515
1583
  case 0:
1516
- addAction = _step4.value;
1584
+ addAction = _step6.value;
1517
1585
  if (!(addAction.giftOptions.length === 1)) {
1518
1586
  _context10.next = 6;
1519
1587
  break;
@@ -1531,7 +1599,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1531
1599
  case 6:
1532
1600
  _context10.prev = 6;
1533
1601
  _context10.next = 9;
1534
- return _this8.giftSelectResolver({
1602
+ return _this9.giftSelectResolver({
1535
1603
  strategyId: addAction.strategyId,
1536
1604
  strategyName: addAction.strategyName,
1537
1605
  giftCount: addAction.giftCount,
@@ -1546,15 +1614,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1546
1614
  _context10.next = 37;
1547
1615
  break;
1548
1616
  }
1549
- _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
1617
+ _iterator7 = _createForOfIteratorHelper(giftProducts.entries());
1550
1618
  _context10.prev = 14;
1551
- _iterator5.s();
1619
+ _iterator7.s();
1552
1620
  case 16:
1553
- if ((_step5 = _iterator5.n()).done) {
1621
+ if ((_step7 = _iterator7.n()).done) {
1554
1622
  _context10.next = 29;
1555
1623
  break;
1556
1624
  }
1557
- _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
1625
+ _step7$value = _slicedToArray(_step7.value, 2), index = _step7$value[0], gp = _step7$value[1];
1558
1626
  if (gp) {
1559
1627
  _context10.next = 20;
1560
1628
  break;
@@ -1566,7 +1634,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1566
1634
  _context10.next = 26;
1567
1635
  break;
1568
1636
  }
1569
- linked = _this8.createLinkedProductAndBooking({
1637
+ linked = _this9.createLinkedProductAndBooking({
1570
1638
  product: gp,
1571
1639
  booking: booking
1572
1640
  });
@@ -1585,10 +1653,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1585
1653
  case 31:
1586
1654
  _context10.prev = 31;
1587
1655
  _context10.t0 = _context10["catch"](14);
1588
- _iterator5.e(_context10.t0);
1656
+ _iterator7.e(_context10.t0);
1589
1657
  case 34:
1590
1658
  _context10.prev = 34;
1591
- _iterator5.f();
1659
+ _iterator7.f();
1592
1660
  return _context10.finish(34);
1593
1661
  case 37:
1594
1662
  _context10.next = 42;
@@ -1604,9 +1672,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1604
1672
  }
1605
1673
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
1606
1674
  });
1607
- _iterator4.s();
1675
+ _iterator6.s();
1608
1676
  case 57:
1609
- if ((_step4 = _iterator4.n()).done) {
1677
+ if ((_step6 = _iterator6.n()).done) {
1610
1678
  _context12.next = 63;
1611
1679
  break;
1612
1680
  }
@@ -1626,10 +1694,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1626
1694
  case 65:
1627
1695
  _context12.prev = 65;
1628
1696
  _context12.t4 = _context12["catch"](54);
1629
- _iterator4.e(_context12.t4);
1697
+ _iterator6.e(_context12.t4);
1630
1698
  case 68:
1631
1699
  _context12.prev = 68;
1632
- _iterator4.f();
1700
+ _iterator6.f();
1633
1701
  return _context12.finish(68);
1634
1702
  case 71:
1635
1703
  tempOrder.products = result.products;
@@ -1672,9 +1740,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1672
1740
  }, {
1673
1741
  key: "emitPromotionApplied",
1674
1742
  value: function emitPromotionApplied(payload) {
1675
- var _this$store$tempOrder3;
1743
+ var _this$store$tempOrder4;
1676
1744
  if (!payload) return;
1677
- var products = ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.products) || payload.products;
1745
+ var products = ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.products) || payload.products;
1678
1746
  this.isEmittingPromotionApplied = true;
1679
1747
  try {
1680
1748
  void this.effectsEmit('onPromotionApplied', _objectSpread(_objectSpread({}, payload), {}, {
@@ -1898,12 +1966,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1898
1966
  }, {
1899
1967
  key: "rememberPointCardSnapshotCodeCandidates",
1900
1968
  value: function rememberPointCardSnapshotCodeCandidates(value) {
1901
- var _this9 = this;
1969
+ var _this10 = this;
1902
1970
  collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref19) {
1903
1971
  var id = _ref19.id,
1904
1972
  code = _ref19.code;
1905
- if (!_this9.pointCardSnapshotCodeCandidates.has(id)) {
1906
- _this9.pointCardSnapshotCodeCandidates.set(id, code);
1973
+ if (!_this10.pointCardSnapshotCodeCandidates.has(id)) {
1974
+ _this10.pointCardSnapshotCodeCandidates.set(id, code);
1907
1975
  }
1908
1976
  });
1909
1977
  }
@@ -1936,9 +2004,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1936
2004
  }, {
1937
2005
  key: "isPointCardSnapshotMergeContextCurrent",
1938
2006
  value: function isPointCardSnapshotMergeContextCurrent(context) {
1939
- var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
2007
+ var _context$customerId, _this$store$tempOrder5, _this$store$tempOrder6;
1940
2008
  if (!context) return true;
1941
- if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder4 = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customer_id) !== null && _this$store$tempOrder4 !== void 0 ? _this$store$tempOrder4 : '')) {
2009
+ if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder5 = (_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.customer_id) !== null && _this$store$tempOrder5 !== void 0 ? _this$store$tempOrder5 : '')) {
1942
2010
  return false;
1943
2011
  }
1944
2012
  var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
@@ -2084,7 +2152,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2084
2152
  }
2085
2153
  }, _callee13, this);
2086
2154
  }));
2087
- function hydrateTempOrderFromLocalRecord(_x10) {
2155
+ function hydrateTempOrderFromLocalRecord(_x11) {
2088
2156
  return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
2089
2157
  }
2090
2158
  return hydrateTempOrderFromLocalRecord;
@@ -2110,23 +2178,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2110
2178
  }, {
2111
2179
  key: "calculatePaymentTotal",
2112
2180
  value: function calculatePaymentTotal(payments) {
2113
- var _this10 = this;
2181
+ var _this11 = this;
2114
2182
  return mapPaymentItemsToOrderPayments(payments, {
2115
2183
  includeVoided: false
2116
2184
  }).reduce(function (sum, payment) {
2117
2185
  if (!isPaidPaymentRecord(payment)) return sum;
2118
- return sum.plus(_this10.calculatePaymentEffectiveAmount(payment));
2186
+ return sum.plus(_this11.calculatePaymentEffectiveAmount(payment));
2119
2187
  }, new Decimal(0));
2120
2188
  }
2121
2189
  }, {
2122
2190
  key: "calculateOrderPaidPaymentTotal",
2123
2191
  value: function calculateOrderPaidPaymentTotal(payments) {
2124
- var _this11 = this;
2192
+ var _this12 = this;
2125
2193
  return mapPaymentItemsToOrderPayments(payments, {
2126
2194
  includeVoided: false
2127
2195
  }).reduce(function (sum, payment) {
2128
2196
  if (!isPaidPaymentRecord(payment)) return sum;
2129
- return sum.plus(_this11.calculatePaymentGapAmount(payment));
2197
+ return sum.plus(_this12.calculatePaymentGapAmount(payment));
2130
2198
  }, new Decimal(0));
2131
2199
  }
2132
2200
  }, {
@@ -2262,13 +2330,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2262
2330
  }, {
2263
2331
  key: "calculateDepositPaidAmount",
2264
2332
  value: function calculateDepositPaidAmount(payments) {
2265
- var _this12 = this;
2333
+ var _this13 = this;
2266
2334
  return (payments || []).reduce(function (sum, payment) {
2267
2335
  var paymentRecord = payment;
2268
2336
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
2269
2337
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
2270
2338
  if (!isDepositPayment) return sum;
2271
- return sum.plus(_this12.calculatePaymentGapAmount(paymentRecord));
2339
+ return sum.plus(_this13.calculatePaymentGapAmount(paymentRecord));
2272
2340
  }, new Decimal(0));
2273
2341
  }
2274
2342
  }, {
@@ -2305,17 +2373,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2305
2373
  }, {
2306
2374
  key: "getPaymentNumberDevicePrefixSync",
2307
2375
  value: function getPaymentNumberDevicePrefixSync() {
2308
- var _this13 = this;
2376
+ var _this14 = this;
2309
2377
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
2310
- return _this13.getPaymentNumberAppData(key);
2378
+ return _this14.getPaymentNumberAppData(key);
2311
2379
  });
2312
2380
  }
2313
2381
  }, {
2314
2382
  key: "getPaymentNumberDevicePrefixAsync",
2315
2383
  value: function getPaymentNumberDevicePrefixAsync() {
2316
- var _this14 = this;
2384
+ var _this15 = this;
2317
2385
  return resolvePaymentNumberDevicePrefix(function (key) {
2318
- return _this14.getPaymentNumberAppData(key);
2386
+ return _this15.getPaymentNumberAppData(key);
2319
2387
  });
2320
2388
  }
2321
2389
  }, {
@@ -2412,11 +2480,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2412
2480
  if (targetAmount.lte(0)) return [];
2413
2481
  var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
2414
2482
  var cappedVouchers = [];
2415
- var _iterator7 = _createForOfIteratorHelper(params.vouchers),
2416
- _step7;
2483
+ var _iterator9 = _createForOfIteratorHelper(params.vouchers),
2484
+ _step9;
2417
2485
  try {
2418
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
2419
- var voucher = _step7.value;
2486
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
2487
+ var voucher = _step9.value;
2420
2488
  if (remainingAmount.lte(0)) break;
2421
2489
  var voucherAmount = Decimal.max(new Decimal(voucher.amount || 0), 0);
2422
2490
  if (voucherAmount.lte(0)) continue;
@@ -2436,25 +2504,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2436
2504
  remainingAmount = remainingAmount.minus(cappedAmount);
2437
2505
  }
2438
2506
  } catch (err) {
2439
- _iterator7.e(err);
2507
+ _iterator9.e(err);
2440
2508
  } finally {
2441
- _iterator7.f();
2509
+ _iterator9.f();
2442
2510
  }
2443
2511
  return cappedVouchers;
2444
2512
  }
2445
2513
  }, {
2446
2514
  key: "calculatePaidPaymentSummary",
2447
2515
  value: function calculatePaidPaymentSummary(payments) {
2448
- var _this15 = this;
2516
+ var _this16 = this;
2449
2517
  return (payments || []).reduce(function (summary, payment) {
2450
2518
  var paymentRecord = payment;
2451
2519
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2452
2520
  return {
2453
2521
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2454
- orderPaidAmount: summary.orderPaidAmount.plus(_this15.calculatePaymentOrderAmount(paymentRecord)),
2455
- gapPaidAmount: summary.gapPaidAmount.plus(_this15.calculatePaymentGapAmount(paymentRecord)),
2456
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this15.calculatePaymentServiceFee(paymentRecord)),
2457
- roundingAmount: summary.roundingAmount.plus(_this15.calculatePaymentRoundingAmount(paymentRecord))
2522
+ orderPaidAmount: summary.orderPaidAmount.plus(_this16.calculatePaymentOrderAmount(paymentRecord)),
2523
+ gapPaidAmount: summary.gapPaidAmount.plus(_this16.calculatePaymentGapAmount(paymentRecord)),
2524
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this16.calculatePaymentServiceFee(paymentRecord)),
2525
+ roundingAmount: summary.roundingAmount.plus(_this16.calculatePaymentRoundingAmount(paymentRecord))
2458
2526
  };
2459
2527
  }, {
2460
2528
  customerPaidAmount: new Decimal(0),
@@ -2523,43 +2591,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2523
2591
  // 整单折扣均摊层产出的 payment 维度字段,直接由计算层写入 metadata,
2524
2592
  // 这里需把它们一并回写到商品 metadata 以便持久化/出站。
2525
2593
  var metadataMoneyKeys = ['main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price'];
2526
- var _iterator8 = _createForOfIteratorHelper(products || []),
2527
- _step8;
2594
+ var _iterator10 = _createForOfIteratorHelper(products || []),
2595
+ _step10;
2528
2596
  try {
2529
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
2530
- var product = _step8.value;
2597
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
2598
+ var product = _step10.value;
2531
2599
  var productRecord = product;
2532
2600
  var metadata = productRecord.metadata && _typeof(productRecord.metadata) === 'object' ? _objectSpread({}, productRecord.metadata) : {};
2533
2601
  var hasMetadataPatch = false;
2534
- var _iterator9 = _createForOfIteratorHelper(moneyKeys),
2535
- _step9;
2602
+ var _iterator11 = _createForOfIteratorHelper(moneyKeys),
2603
+ _step11;
2536
2604
  try {
2537
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
2538
- var key = _step9.value;
2605
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
2606
+ var key = _step11.value;
2539
2607
  var value = this.formatSummaryMetadataMoney(productRecord[key]);
2540
2608
  if (value === undefined) continue;
2541
2609
  metadata[key] = value;
2542
2610
  hasMetadataPatch = true;
2543
2611
  }
2544
2612
  } catch (err) {
2545
- _iterator9.e(err);
2613
+ _iterator11.e(err);
2546
2614
  } finally {
2547
- _iterator9.f();
2615
+ _iterator11.f();
2548
2616
  }
2549
- var _iterator10 = _createForOfIteratorHelper(metadataMoneyKeys),
2550
- _step10;
2617
+ var _iterator12 = _createForOfIteratorHelper(metadataMoneyKeys),
2618
+ _step12;
2551
2619
  try {
2552
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
2553
- var _key = _step10.value;
2620
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2621
+ var _key = _step12.value;
2554
2622
  var _value = this.formatSummaryMetadataMoney(metadata[_key]);
2555
2623
  if (_value === undefined) continue;
2556
2624
  metadata[_key] = _value;
2557
2625
  hasMetadataPatch = true;
2558
2626
  }
2559
2627
  } catch (err) {
2560
- _iterator10.e(err);
2628
+ _iterator12.e(err);
2561
2629
  } finally {
2562
- _iterator10.f();
2630
+ _iterator12.f();
2563
2631
  }
2564
2632
  if (metadata.average_discount_amount_rate !== undefined) {
2565
2633
  hasMetadataPatch = true;
@@ -2574,11 +2642,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2574
2642
  }
2575
2643
  if (hasMetadataPatch) productRecord.metadata = metadata;
2576
2644
  if (!Array.isArray(productRecord.product_bundle)) continue;
2577
- var _iterator11 = _createForOfIteratorHelper(productRecord.product_bundle),
2578
- _step11;
2645
+ var _iterator13 = _createForOfIteratorHelper(productRecord.product_bundle),
2646
+ _step13;
2579
2647
  try {
2580
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
2581
- var bundle = _step11.value;
2648
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2649
+ var bundle = _step13.value;
2582
2650
  var bundleRecord = bundle;
2583
2651
  var bundleMetadata = bundleRecord.metadata && _typeof(bundleRecord.metadata) === 'object' ? _objectSpread({}, bundleRecord.metadata) : {};
2584
2652
  var hasBundleMetadataPatch = false;
@@ -2598,15 +2666,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2598
2666
  if (hasBundleMetadataPatch) bundleRecord.metadata = bundleMetadata;
2599
2667
  }
2600
2668
  } catch (err) {
2601
- _iterator11.e(err);
2669
+ _iterator13.e(err);
2602
2670
  } finally {
2603
- _iterator11.f();
2671
+ _iterator13.f();
2604
2672
  }
2605
2673
  }
2606
2674
  } catch (err) {
2607
- _iterator8.e(err);
2675
+ _iterator10.e(err);
2608
2676
  } finally {
2609
- _iterator8.f();
2677
+ _iterator10.f();
2610
2678
  }
2611
2679
  }
2612
2680
  }, {
@@ -2661,15 +2729,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2661
2729
  }, {
2662
2730
  key: "normalizeFingerprintValue",
2663
2731
  value: function normalizeFingerprintValue(value) {
2664
- var _this16 = this;
2732
+ var _this17 = this;
2665
2733
  if (Array.isArray(value)) {
2666
2734
  return value.map(function (item) {
2667
- return _this16.normalizeFingerprintValue(item);
2735
+ return _this17.normalizeFingerprintValue(item);
2668
2736
  });
2669
2737
  }
2670
2738
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2671
2739
  return Object.keys(value).sort().reduce(function (result, key) {
2672
- result[key] = _this16.normalizeFingerprintValue(value[key]);
2740
+ result[key] = _this17.normalizeFingerprintValue(value[key]);
2673
2741
  return result;
2674
2742
  }, {});
2675
2743
  }
@@ -2684,7 +2752,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2684
2752
  _sku$barcode,
2685
2753
  _ref27,
2686
2754
  _sku$variant_id,
2687
- _this17 = this;
2755
+ _this18 = this;
2688
2756
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2689
2757
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2690
2758
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2723,7 +2791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2723
2791
  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,
2724
2792
  option_group_item_id: (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : null,
2725
2793
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2726
- add_price: _this17.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)
2794
+ add_price: _this18.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)
2727
2795
  };
2728
2796
  })
2729
2797
  }),
@@ -2733,8 +2801,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2733
2801
  bundle_product_id: (_ref30 = (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref30 !== void 0 ? _ref30 : null,
2734
2802
  bundle_variant_id: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : 0,
2735
2803
  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),
2736
- price: _this17.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2737
- bundle_selling_price: _this17.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2804
+ price: _this18.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2805
+ bundle_selling_price: _this18.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2738
2806
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2739
2807
  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 : ''
2740
2808
  };
@@ -2744,7 +2812,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2744
2812
  return {
2745
2813
  type: (_ref33 = (_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 && _ref33 !== void 0 ? _ref33 : '',
2746
2814
  discount_id: (_ref34 = (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2747
- amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2815
+ amount: _this18.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2748
2816
  };
2749
2817
  }))
2750
2818
  };
@@ -2752,9 +2820,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2752
2820
  }, {
2753
2821
  key: "buildOrderProductsFingerprint",
2754
2822
  value: function buildOrderProductsFingerprint(products) {
2755
- var _this18 = this;
2823
+ var _this19 = this;
2756
2824
  var items = (products || []).map(function (product) {
2757
- return _this18.buildProductFingerprintItem(product);
2825
+ return _this19.buildProductFingerprintItem(product);
2758
2826
  });
2759
2827
  items.sort(function (left, right) {
2760
2828
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2776,7 +2844,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2776
2844
  _sku$barcode2,
2777
2845
  _ref37,
2778
2846
  _sku$variant_id2,
2779
- _this19 = this;
2847
+ _this20 = this;
2780
2848
  var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
2781
2849
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2782
2850
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
@@ -2813,7 +2881,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2813
2881
  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,
2814
2882
  option_group_item_id: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : null,
2815
2883
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2816
- add_price: _this19.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)
2884
+ add_price: _this20.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)
2817
2885
  };
2818
2886
  })
2819
2887
  }),
@@ -2827,14 +2895,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2827
2895
  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),
2828
2896
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2829
2897
  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 : '',
2830
- option: _this19.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2898
+ option: _this20.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2831
2899
  var _ref45, _option$id3, _option$option_group_5, _ref46, _option$option_group_6, _option$num3, _option$add_price3;
2832
2900
  return {
2833
2901
  id: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : null,
2834
2902
  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,
2835
2903
  option_group_item_id: (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : null,
2836
2904
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2837
- add_price: _this19.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)
2905
+ add_price: _this20.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)
2838
2906
  };
2839
2907
  }))
2840
2908
  };
@@ -2844,7 +2912,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2844
2912
  return {
2845
2913
  type: (_ref47 = (_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 && _ref47 !== void 0 ? _ref47 : '',
2846
2914
  discount_id: (_ref48 = (_ref49 = (_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 && _ref49 !== void 0 ? _ref49 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref48 !== void 0 ? _ref48 : null,
2847
- amount: _this19.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2915
+ amount: _this20.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2848
2916
  };
2849
2917
  }))
2850
2918
  };
@@ -2852,10 +2920,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2852
2920
  }, {
2853
2921
  key: "buildOrderProductsStructuralFingerprint",
2854
2922
  value: function buildOrderProductsStructuralFingerprint(products) {
2855
- var _this20 = this;
2923
+ var _this21 = this;
2856
2924
  var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
2857
2925
  var items = (products || []).map(function (product) {
2858
- return _this20.buildProductStructuralFingerprintItem(product, order);
2926
+ return _this21.buildProductStructuralFingerprintItem(product, order);
2859
2927
  });
2860
2928
  items.sort(function (left, right) {
2861
2929
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2988,82 +3056,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2988
3056
  value: function clearPersistedAmountFieldsForFullRecalc(products) {
2989
3057
  var moneyKeys = ['surcharge_fee', 'main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder'];
2990
3058
  var metadataMoneyKeys = ['main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee_rounding_remainder'];
2991
- var _iterator12 = _createForOfIteratorHelper(products || []),
2992
- _step12;
3059
+ var _iterator14 = _createForOfIteratorHelper(products || []),
3060
+ _step14;
2993
3061
  try {
2994
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2995
- var product = _step12.value;
3062
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
3063
+ var product = _step14.value;
2996
3064
  var record = product;
2997
- var _iterator13 = _createForOfIteratorHelper(moneyKeys),
2998
- _step13;
3065
+ var _iterator15 = _createForOfIteratorHelper(moneyKeys),
3066
+ _step15;
2999
3067
  try {
3000
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
3001
- var _key2 = _step13.value;
3068
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
3069
+ var _key2 = _step15.value;
3002
3070
  delete record[_key2];
3003
3071
  }
3004
3072
  } catch (err) {
3005
- _iterator13.e(err);
3073
+ _iterator15.e(err);
3006
3074
  } finally {
3007
- _iterator13.f();
3075
+ _iterator15.f();
3008
3076
  }
3009
3077
  if (record.metadata && _typeof(record.metadata) === 'object') {
3010
3078
  record.metadata = _objectSpread({}, record.metadata);
3011
- var _iterator14 = _createForOfIteratorHelper(metadataMoneyKeys),
3012
- _step14;
3079
+ var _iterator16 = _createForOfIteratorHelper(metadataMoneyKeys),
3080
+ _step16;
3013
3081
  try {
3014
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
3015
- var key = _step14.value;
3082
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
3083
+ var key = _step16.value;
3016
3084
  delete record.metadata[key];
3017
3085
  }
3018
3086
  } catch (err) {
3019
- _iterator14.e(err);
3087
+ _iterator16.e(err);
3020
3088
  } finally {
3021
- _iterator14.f();
3089
+ _iterator16.f();
3022
3090
  }
3023
3091
  }
3024
- var _iterator15 = _createForOfIteratorHelper(record.product_bundle || []),
3025
- _step15;
3092
+ var _iterator17 = _createForOfIteratorHelper(record.product_bundle || []),
3093
+ _step17;
3026
3094
  try {
3027
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
3028
- var bundle = _step15.value;
3029
- var _iterator16 = _createForOfIteratorHelper(moneyKeys),
3030
- _step16;
3095
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
3096
+ var bundle = _step17.value;
3097
+ var _iterator18 = _createForOfIteratorHelper(moneyKeys),
3098
+ _step18;
3031
3099
  try {
3032
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
3033
- var _key4 = _step16.value;
3100
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
3101
+ var _key4 = _step18.value;
3034
3102
  delete bundle[_key4];
3035
3103
  }
3036
3104
  } catch (err) {
3037
- _iterator16.e(err);
3105
+ _iterator18.e(err);
3038
3106
  } finally {
3039
- _iterator16.f();
3107
+ _iterator18.f();
3040
3108
  }
3041
3109
  if (bundle.metadata && _typeof(bundle.metadata) === 'object') {
3042
3110
  bundle.metadata = _objectSpread({}, bundle.metadata);
3043
- var _iterator17 = _createForOfIteratorHelper(metadataMoneyKeys),
3044
- _step17;
3111
+ var _iterator19 = _createForOfIteratorHelper(metadataMoneyKeys),
3112
+ _step19;
3045
3113
  try {
3046
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
3047
- var _key3 = _step17.value;
3114
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
3115
+ var _key3 = _step19.value;
3048
3116
  delete bundle.metadata[_key3];
3049
3117
  }
3050
3118
  } catch (err) {
3051
- _iterator17.e(err);
3119
+ _iterator19.e(err);
3052
3120
  } finally {
3053
- _iterator17.f();
3121
+ _iterator19.f();
3054
3122
  }
3055
3123
  }
3056
3124
  }
3057
3125
  } catch (err) {
3058
- _iterator15.e(err);
3126
+ _iterator17.e(err);
3059
3127
  } finally {
3060
- _iterator15.f();
3128
+ _iterator17.f();
3061
3129
  }
3062
3130
  }
3063
3131
  } catch (err) {
3064
- _iterator12.e(err);
3132
+ _iterator14.e(err);
3065
3133
  } finally {
3066
- _iterator12.f();
3134
+ _iterator14.f();
3067
3135
  }
3068
3136
  }
3069
3137
  }, {
@@ -3163,7 +3231,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3163
3231
  }
3164
3232
  }, _callee14, this);
3165
3233
  }));
3166
- function replaceTempOrder(_x11, _x12) {
3234
+ function replaceTempOrder(_x12, _x13) {
3167
3235
  return _replaceTempOrder.apply(this, arguments);
3168
3236
  }
3169
3237
  return replaceTempOrder;
@@ -3316,9 +3384,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3316
3384
  }, {
3317
3385
  key: "sanitizeTempOrderProducts",
3318
3386
  value: function sanitizeTempOrderProducts(tempOrder) {
3319
- var _this21 = this;
3387
+ var _this22 = this;
3320
3388
  tempOrder.products = (tempOrder.products || []).map(function (product) {
3321
- return _this21.sanitizeOrderProductForTempOrder(_this21.normalizeVirtualSettlementProductIfEnabled(product));
3389
+ return _this22.sanitizeOrderProductForTempOrder(_this22.normalizeVirtualSettlementProductIfEnabled(product));
3322
3390
  });
3323
3391
  this.syncTempOrderSettlementState(tempOrder);
3324
3392
  ensureUniqueProductLineUids(tempOrder);
@@ -3359,9 +3427,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3359
3427
  var extend = this.ensureExtend(tempOrder);
3360
3428
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
3361
3429
  var origin = (_ref52 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref52 !== void 0 ? _ref52 : existed.origin;
3362
- extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
3430
+ extend.productsByUid[uid] = _objectSpread(_objectSpread(_objectSpread({}, existed), origin !== undefined ? {
3363
3431
  origin: origin
3432
+ } : {}), rawProduct._productVoucherGroupKey ? {
3433
+ productVoucherGroupKey: rawProduct._productVoucherGroupKey
3364
3434
  } : {});
3435
+ delete normalizedProduct._productVoucherGroupKey;
3365
3436
  delete normalizedProduct._origin;
3366
3437
  delete normalizedProduct.unique_identification_number;
3367
3438
  }
@@ -3438,7 +3509,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3438
3509
  }, {
3439
3510
  key: "syncLinkedBookingHoldersToProducts",
3440
3511
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3441
- var _this22 = this;
3512
+ var _this23 = this;
3442
3513
  var bookings = tempOrder.bookings || [];
3443
3514
  var products = tempOrder.products || [];
3444
3515
  if (!bookings.length || !products.length) return;
@@ -3464,7 +3535,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3464
3535
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3465
3536
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3466
3537
  if (linkedBooking) {
3467
- _this22.setProductHolderFromBooking(product, linkedBooking);
3538
+ _this23.setProductHolderFromBooking(product, linkedBooking);
3468
3539
  }
3469
3540
  });
3470
3541
  }
@@ -3507,11 +3578,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3507
3578
  var holderNames = [];
3508
3579
  var baseHolder = null;
3509
3580
  var seen = new Set();
3510
- var _iterator18 = _createForOfIteratorHelper(tempOrder.bookings || []),
3511
- _step18;
3581
+ var _iterator20 = _createForOfIteratorHelper(tempOrder.bookings || []),
3582
+ _step20;
3512
3583
  try {
3513
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
3514
- var booking = _step18.value;
3584
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
3585
+ var booking = _step20.value;
3515
3586
  if (isFulfillmentTimingBooking(booking)) continue;
3516
3587
  var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
3517
3588
  if (!baseHolder && holder) {
@@ -3519,13 +3590,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3519
3590
  }
3520
3591
  var records = this.collectBookingHolderRecords(booking);
3521
3592
  var names = this.collectBookingHolderNames(booking);
3522
- var _iterator19 = _createForOfIteratorHelper(records.entries()),
3523
- _step19;
3593
+ var _iterator21 = _createForOfIteratorHelper(records.entries()),
3594
+ _step21;
3524
3595
  try {
3525
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
3526
- var _step19$value = _slicedToArray(_step19.value, 2),
3527
- index = _step19$value[0],
3528
- record = _step19$value[1];
3596
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
3597
+ var _step21$value = _slicedToArray(_step21.value, 2),
3598
+ index = _step21$value[0],
3599
+ record = _step21$value[1];
3529
3600
  var key = String(record);
3530
3601
  if (seen.has(key)) continue;
3531
3602
  seen.add(key);
@@ -3535,15 +3606,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3535
3606
  }
3536
3607
  }
3537
3608
  } catch (err) {
3538
- _iterator19.e(err);
3609
+ _iterator21.e(err);
3539
3610
  } finally {
3540
- _iterator19.f();
3611
+ _iterator21.f();
3541
3612
  }
3542
3613
  }
3543
3614
  } catch (err) {
3544
- _iterator18.e(err);
3615
+ _iterator20.e(err);
3545
3616
  } finally {
3546
- _iterator18.f();
3617
+ _iterator20.f();
3547
3618
  }
3548
3619
  if (!holderRecords.length) {
3549
3620
  return null;
@@ -3595,9 +3666,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3595
3666
  }, {
3596
3667
  key: "findBookingIndexByUniqueIdentificationNumber",
3597
3668
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3598
- var _this23 = this;
3669
+ var _this24 = this;
3599
3670
  return (tempOrder.bookings || []).findIndex(function (booking) {
3600
- return _this23.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3671
+ return _this24.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3601
3672
  });
3602
3673
  }
3603
3674
  }, {
@@ -3605,13 +3676,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3605
3676
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3606
3677
  var _product$metadata5,
3607
3678
  _product$metadata6,
3608
- _this24 = this;
3679
+ _this25 = this;
3609
3680
  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);
3610
3681
  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);
3611
3682
  if (!productUid && !bookingUid) return;
3612
3683
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3613
3684
  if (isFulfillmentTimingBooking(booking)) return true;
3614
- var currentBookingUid = _this24.getBookingUniqueIdentificationNumber(booking);
3685
+ var currentBookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
3615
3686
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3616
3687
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3617
3688
  return true;
@@ -3781,7 +3852,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3781
3852
  }
3782
3853
  }, _callee16, this);
3783
3854
  }));
3784
- function recalculateSummary(_x13) {
3855
+ function recalculateSummary(_x14) {
3785
3856
  return _recalculateSummary.apply(this, arguments);
3786
3857
  }
3787
3858
  return recalculateSummary;
@@ -3852,7 +3923,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3852
3923
  }
3853
3924
  }, _callee18, this);
3854
3925
  }));
3855
- function syncTempOrderNoteToRemote(_x14, _x15) {
3926
+ function syncTempOrderNoteToRemote(_x15, _x16) {
3856
3927
  return _syncTempOrderNoteToRemote.apply(this, arguments);
3857
3928
  }
3858
3929
  return syncTempOrderNoteToRemote;
@@ -3860,8 +3931,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3860
3931
  }, {
3861
3932
  key: "getTempOrderNote",
3862
3933
  value: function getTempOrderNote() {
3863
- var _this$store$tempOrder6;
3864
- return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
3934
+ var _this$store$tempOrder7;
3935
+ return ((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.note) || '';
3865
3936
  }
3866
3937
  }, {
3867
3938
  key: "ensureSalesNotesRuntimeState",
@@ -3913,7 +3984,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3913
3984
  }, {
3914
3985
  key: "removeSalesNotesForMissingProductLines",
3915
3986
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3916
- var _this25 = this;
3987
+ var _this26 = this;
3917
3988
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3918
3989
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3919
3990
  return;
@@ -3925,7 +3996,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3925
3996
  return typeof uid === 'string' && uid.length > 0;
3926
3997
  }));
3927
3998
  var nextNotes = tempOrder.notes.filter(function (note) {
3928
- var primary = _this25.getSalesNotePrimaryRelation(note);
3999
+ var primary = _this26.getSalesNotePrimaryRelation(note);
3929
4000
  if (!primary || primary.target_type !== 'order_detail') return true;
3930
4001
  return remainingProductUids.has(primary.target_uuid);
3931
4002
  });
@@ -3937,7 +4008,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3937
4008
  key: "setSalesNoteOnTempOrder",
3938
4009
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3939
4010
  var _input$target,
3940
- _this26 = this,
4011
+ _this27 = this,
3941
4012
  _tempOrder$shop_order;
3942
4013
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3943
4014
  var note_type = String(input.note_type || '').trim();
@@ -3961,7 +4032,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3961
4032
  var notes = tempOrder.notes || [];
3962
4033
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3963
4034
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3964
- var primary = _this26.getSalesNotePrimaryRelation(note);
4035
+ var primary = _this27.getSalesNotePrimaryRelation(note);
3965
4036
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3966
4037
  }) : -1;
3967
4038
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -4068,7 +4139,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4068
4139
  }
4069
4140
  }, _callee19, this);
4070
4141
  }));
4071
- function setSalesNote(_x16) {
4142
+ function setSalesNote(_x17) {
4072
4143
  return _setSalesNote.apply(this, arguments);
4073
4144
  }
4074
4145
  return setSalesNote;
@@ -4104,7 +4175,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4104
4175
  }
4105
4176
  }, _callee20, this);
4106
4177
  }));
4107
- function removeSalesNote(_x17) {
4178
+ function removeSalesNote(_x18) {
4108
4179
  return _removeSalesNote.apply(this, arguments);
4109
4180
  }
4110
4181
  return removeSalesNote;
@@ -4211,8 +4282,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4211
4282
  }, {
4212
4283
  key: "getPickupTimingBooking",
4213
4284
  value: function getPickupTimingBooking() {
4214
- var _this$store$tempOrder7;
4215
- return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
4285
+ var _this$store$tempOrder8;
4286
+ return (((_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.bookings) || []).find(isFulfillmentTimingBooking) || null;
4216
4287
  }
4217
4288
  }, {
4218
4289
  key: "setPickupTimingBooking",
@@ -4280,15 +4351,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4280
4351
  }, {
4281
4352
  key: "productHasCustomerBoundDiscount",
4282
4353
  value: function productHasCustomerBoundDiscount(product) {
4283
- var _this27 = this;
4354
+ var _this28 = this;
4284
4355
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
4285
- return _this27.isCustomerBoundDiscount(discount);
4356
+ return _this28.isCustomerBoundDiscount(discount);
4286
4357
  })) {
4287
4358
  return true;
4288
4359
  }
4289
4360
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
4290
4361
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
4291
- return _this27.isCustomerBoundDiscount(discount);
4362
+ return _this28.isCustomerBoundDiscount(discount);
4292
4363
  });
4293
4364
  });
4294
4365
  }
@@ -4297,18 +4368,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4297
4368
  value: function shouldSkipDiscountCalculation(tempOrder) {
4298
4369
  var _this$store$discount20,
4299
4370
  _this$store$discount21,
4300
- _this28 = this;
4371
+ _this29 = this;
4301
4372
  if (this.hasActiveCustomerBoundDiscount) return false;
4302
4373
  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)) || [];
4303
4374
  if (discountList.length > 0) return false;
4304
4375
  return !(tempOrder.products || []).some(function (product) {
4305
- return _this28.productHasCustomerBoundDiscount(product);
4376
+ return _this29.productHasCustomerBoundDiscount(product);
4306
4377
  });
4307
4378
  }
4308
4379
  }, {
4309
4380
  key: "clearCustomerBoundDiscounts",
4310
4381
  value: function clearCustomerBoundDiscounts(tempOrder) {
4311
- var _this29 = this,
4382
+ var _this30 = this,
4312
4383
  _discountModule$getDi,
4313
4384
  _discountModule$getOr,
4314
4385
  _discountModule$setDi,
@@ -4317,7 +4388,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4317
4388
  var filterDiscountList = function filterDiscountList(discountList) {
4318
4389
  if (!Array.isArray(discountList)) return [];
4319
4390
  return discountList.filter(function (discount) {
4320
- var shouldRemove = _this29.isCustomerBoundDiscount(discount);
4391
+ var shouldRemove = _this30.isCustomerBoundDiscount(discount);
4321
4392
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
4322
4393
  return !shouldRemove;
4323
4394
  });
@@ -4344,12 +4415,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4344
4415
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
4345
4416
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
4346
4417
  var nextDiscounts = currentDiscounts.filter(function (discount) {
4347
- if (_this29.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4348
- return !_this29.isCustomerBoundDiscount(discount);
4418
+ if (_this30.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4419
+ return !_this30.isCustomerBoundDiscount(discount);
4349
4420
  });
4350
4421
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
4351
- if (_this29.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4352
- return !_this29.isCustomerBoundDiscount(discount);
4422
+ if (_this30.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4423
+ return !_this30.isCustomerBoundDiscount(discount);
4353
4424
  });
4354
4425
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
4355
4426
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -4455,8 +4526,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4455
4526
  }, {
4456
4527
  key: "getOrderCustomerSnapshot",
4457
4528
  value: function getOrderCustomerSnapshot() {
4458
- var _this$store$tempOrder8;
4459
- var snapshot = (_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 || (_this$store$tempOrder8 = _this$store$tempOrder8._extend) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.customerSnapshot;
4529
+ var _this$store$tempOrder9;
4530
+ var snapshot = (_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 || (_this$store$tempOrder9 = _this$store$tempOrder9._extend) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.customerSnapshot;
4460
4531
  return snapshot ? cloneDeep(snapshot) : null;
4461
4532
  }
4462
4533
  }, {
@@ -4516,10 +4587,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4516
4587
  }, {
4517
4588
  key: "setOrderPayments",
4518
4589
  value: function setOrderPayments(payments) {
4519
- var _this30 = this;
4590
+ var _this31 = this;
4520
4591
  var tempOrder = this.ensureTempOrder();
4521
4592
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4522
- return _this30.normalizePaymentSource(payment, {
4593
+ return _this31.normalizePaymentSource(payment, {
4523
4594
  defaultPaid: false
4524
4595
  });
4525
4596
  }));
@@ -4566,7 +4637,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4566
4637
  }
4567
4638
  }, _callee22, this);
4568
4639
  }));
4569
- function addOrderPaymentAsync(_x18) {
4640
+ function addOrderPaymentAsync(_x19) {
4570
4641
  return _addOrderPaymentAsync.apply(this, arguments);
4571
4642
  }
4572
4643
  return addOrderPaymentAsync;
@@ -4574,7 +4645,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4574
4645
  }, {
4575
4646
  key: "addOrderPaymentWithDevicePrefix",
4576
4647
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4577
- var _this31 = this;
4648
+ var _this32 = this;
4578
4649
  this.logInfo('addOrderPayment', {
4579
4650
  payment: payment
4580
4651
  });
@@ -4592,7 +4663,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4592
4663
  void this.recalculateSummary({
4593
4664
  createIfMissing: true
4594
4665
  }).catch(function (error) {
4595
- _this31.logError('recalculate summary after addOrderPayment failed', {
4666
+ _this32.logError('recalculate summary after addOrderPayment failed', {
4596
4667
  error: error instanceof Error ? error.message : String(error)
4597
4668
  });
4598
4669
  });
@@ -4660,7 +4731,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4660
4731
  }
4661
4732
  }, _callee23, this);
4662
4733
  }));
4663
- function updateOrderPayment(_x19, _x20) {
4734
+ function updateOrderPayment(_x20, _x21) {
4664
4735
  return _updateOrderPayment.apply(this, arguments);
4665
4736
  }
4666
4737
  return updateOrderPayment;
@@ -4705,7 +4776,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4705
4776
  }, {
4706
4777
  key: "applyPaymentLifecycleChange",
4707
4778
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4708
- var _this32 = this;
4779
+ var _this33 = this;
4709
4780
  this.updateTempOrderPaymentStatus(tempOrder);
4710
4781
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4711
4782
  this.persistTempOrder();
@@ -4715,7 +4786,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4715
4786
  void this.recalculateSummary({
4716
4787
  createIfMissing: true
4717
4788
  }).catch(function (error) {
4718
- _this32.logError("recalculate summary after ".concat(logContext, " failed"), {
4789
+ _this33.logError("recalculate summary after ".concat(logContext, " failed"), {
4719
4790
  error: error instanceof Error ? error.message : String(error)
4720
4791
  });
4721
4792
  });
@@ -4759,7 +4830,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4759
4830
  }, {
4760
4831
  key: "updateVoucherOrderPayments",
4761
4832
  value: function updateVoucherOrderPayments(payments, options) {
4762
- var _this33 = this;
4833
+ var _this34 = this;
4763
4834
  var tempOrder = this.ensureTempOrder();
4764
4835
  var isOrderPaymentType = function isOrderPaymentType(value) {
4765
4836
  return value === 'normal' || value === 'deposit';
@@ -4794,7 +4865,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4794
4865
  });
4795
4866
  };
4796
4867
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4797
- return _this33.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4868
+ return _this34.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4798
4869
  defaultPaid: false,
4799
4870
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4800
4871
  });
@@ -4847,7 +4918,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4847
4918
  void this.recalculateSummary({
4848
4919
  createIfMissing: true
4849
4920
  }).catch(function (error) {
4850
- _this33.logError('recalculate summary after updateVoucherOrderPayments failed', {
4921
+ _this34.logError('recalculate summary after updateVoucherOrderPayments failed', {
4851
4922
  error: error instanceof Error ? error.message : String(error)
4852
4923
  });
4853
4924
  });
@@ -4887,7 +4958,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4887
4958
  }
4888
4959
  }, _callee24, this);
4889
4960
  }));
4890
- function updateVoucherOrderPaymentsAsync(_x21, _x22) {
4961
+ function updateVoucherOrderPaymentsAsync(_x22, _x23) {
4891
4962
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
4892
4963
  }
4893
4964
  return updateVoucherOrderPaymentsAsync;
@@ -4905,7 +4976,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4905
4976
  key: "shouldMergeProductToOrder",
4906
4977
  value: function shouldMergeProductToOrder(params) {
4907
4978
  var _this$orderHooks5,
4908
- _this34 = this;
4979
+ _this35 = this;
4909
4980
  var onBeforeMergeProductToOrder = (_this$orderHooks5 = this.orderHooks) === null || _this$orderHooks5 === void 0 ? void 0 : _this$orderHooks5.onBeforeMergeProductToOrder;
4910
4981
  if (!onBeforeMergeProductToOrder) return true;
4911
4982
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4913,7 +4984,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4913
4984
  }));
4914
4985
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4915
4986
  return Promise.resolve(result).then(function (resolved) {
4916
- return _this34.normalizeShouldMergeProductResult(resolved);
4987
+ return _this35.normalizeShouldMergeProductResult(resolved);
4917
4988
  });
4918
4989
  }
4919
4990
  return this.normalizeShouldMergeProductResult(result);
@@ -5088,7 +5159,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5088
5159
  }
5089
5160
  }, _callee25, this);
5090
5161
  }));
5091
- function finalizeProductOrderMutation(_x23, _x24) {
5162
+ function finalizeProductOrderMutation(_x24, _x25) {
5092
5163
  return _finalizeProductOrderMutation.apply(this, arguments);
5093
5164
  }
5094
5165
  return finalizeProductOrderMutation;
@@ -5115,7 +5186,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5115
5186
  _productToAdd$_extend,
5116
5187
  _productToAdd$metadat,
5117
5188
  _origin,
5118
- _this35 = this;
5189
+ _this36 = this;
5119
5190
  var linked = booking ? this.createLinkedProductAndBooking({
5120
5191
  product: product,
5121
5192
  booking: booking
@@ -5153,27 +5224,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5153
5224
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || hasIncomingHolder || isIncomingCustomItem || isWeighingProduct;
5154
5225
  var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
5155
5226
  var _item$metadata4;
5156
- if (_this35.hasGoodPassDiscount(item)) return false;
5227
+ if (productVoucherGroupKey(tempOrder, item) !== productToAdd._productVoucherGroupKey) return false;
5228
+ if (_this36.hasGoodPassDiscount(item)) return false;
5157
5229
  if (getProductHolderRelations(tempOrder, item).length > 0 || hasAssignedHolderId((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.holder_id)) return false;
5158
- var isRuntimeEntitlementPass = _this35.isRuntimeEntitlementAppend(item, tempOrder);
5230
+ var isRuntimeEntitlementPass = _this36.isRuntimeEntitlementAppend(item, tempOrder);
5159
5231
  if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
5160
5232
  return false;
5161
5233
  }
5162
- if (isIncomingEntitlementAppend && _this35.isPersistedProductLine(item)) {
5234
+ if (isIncomingEntitlementAppend && _this36.isPersistedProductLine(item)) {
5163
5235
  return false;
5164
5236
  }
5165
- var hasExistingProductNote = _this35.hasOrderProductLineNote(item);
5237
+ var hasExistingProductNote = _this36.hasOrderProductLineNote(item);
5166
5238
  if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
5167
5239
  return false;
5168
5240
  }
5169
5241
  var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
5170
- if (isRuntimeEntitlementPass && !_this35.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
5242
+ if (isRuntimeEntitlementPass && !_this36.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
5171
5243
  return false;
5172
5244
  }
5173
5245
  if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
5174
5246
  return false;
5175
5247
  }
5176
- if (_this35.isPersistedProductLine(item)) return false;
5248
+ if (_this36.isPersistedProductLine(item)) return false;
5177
5249
  if (item.product_id !== productToAdd.product_id) return false;
5178
5250
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
5179
5251
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -5184,10 +5256,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5184
5256
  var commitProductLine = function commitProductLine(shouldMerge) {
5185
5257
  var _options$beforeCommit;
5186
5258
  options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
5187
- _this35.assertAndLockProductSettlement(tempOrder, productToAdd);
5259
+ _this36.assertAndLockProductSettlement(tempOrder, productToAdd);
5188
5260
  var committedProduct;
5189
5261
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
5190
- _this35.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
5262
+ _this36.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
5191
5263
  if (linked) {
5192
5264
  normalizedIncoming.booking_uid = linked.bookingUid;
5193
5265
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -5205,7 +5277,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5205
5277
  var _targetProduct$metada;
5206
5278
  var targetProduct = matchedProduct;
5207
5279
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
5208
- var normalizedProduct = _this35.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5280
+ var normalizedProduct = _this36.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5209
5281
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
5210
5282
  unique_identification_number: targetUid
5211
5283
  })
@@ -5228,7 +5300,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5228
5300
  order_detail_id: targetProduct.order_detail_id,
5229
5301
  num: nextNum
5230
5302
  });
5231
- _this35.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5303
+ _this36.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5232
5304
  committedProduct = tempOrder.products[matchedIndex];
5233
5305
  if (matchedIndex !== tempOrder.products.length - 1) {
5234
5306
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -5339,12 +5411,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5339
5411
  key: "addProductToOrder",
5340
5412
  value: (function () {
5341
5413
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(product, booking, options) {
5342
- var _this36 = this;
5414
+ var _this37 = this;
5343
5415
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5344
5416
  while (1) switch (_context28.prev = _context28.next) {
5345
5417
  case 0:
5346
5418
  return _context28.abrupt("return", this.queueCartCommand(function () {
5347
- return _this36.addProductToOrderDraft(product, booking, options);
5419
+ return _this37.addProductToOrderDraft(product, booking, options);
5348
5420
  }));
5349
5421
  case 1:
5350
5422
  case "end":
@@ -5352,7 +5424,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5352
5424
  }
5353
5425
  }, _callee26, this);
5354
5426
  }));
5355
- function addProductToOrder(_x25, _x26, _x27) {
5427
+ function addProductToOrder(_x26, _x27, _x28) {
5356
5428
  return _addProductToOrder.apply(this, arguments);
5357
5429
  }
5358
5430
  return addProductToOrder;
@@ -5361,14 +5433,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5361
5433
  key: "addProductToOrderDraft",
5362
5434
  value: function () {
5363
5435
  var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(product, booking, options) {
5364
- var _this37 = this;
5365
- var mutation, tempOrder, beforeCommit, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref72, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5436
+ var _this38 = this;
5437
+ var mutation, tempOrder, beforeCommit, _tempOrder$_extend10, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref72, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5366
5438
  return _regeneratorRuntime().wrap(function _callee27$(_context29) {
5367
5439
  while (1) switch (_context29.prev = _context29.next) {
5368
5440
  case 0:
5369
5441
  mutation = this.beginCartMutation();
5370
5442
  tempOrder = mutation.draft;
5371
5443
  beforeCommit = this.createCartIntentCommitGuard('add_product', mutation.current);
5444
+ if (!(options !== null && options !== void 0 && options.productVoucherGroupKey)) {
5445
+ _context29.next = 7;
5446
+ break;
5447
+ }
5448
+ if ((_tempOrder$_extend10 = tempOrder._extend) !== null && _tempOrder$_extend10 !== void 0 && (_tempOrder$_extend10 = _tempOrder$_extend10.productVoucherGroups) !== null && _tempOrder$_extend10 !== void 0 && _tempOrder$_extend10.some(function (group) {
5449
+ return group.key === options.productVoucherGroupKey;
5450
+ })) {
5451
+ _context29.next = 6;
5452
+ break;
5453
+ }
5454
+ throw voucherGroupError();
5455
+ case 6:
5456
+ product = _objectSpread(_objectSpread({}, product), {}, {
5457
+ _productVoucherGroupKey: options.productVoucherGroupKey
5458
+ });
5459
+ case 7:
5372
5460
  salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
5373
5461
  return {
5374
5462
  note_type: String(draft.note_type || '').trim(),
@@ -5393,7 +5481,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5393
5481
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
5394
5482
  }
5395
5483
  salesNoteDrafts.forEach(function (draft) {
5396
- _this37.setSalesNoteOnTempOrder(tempOrder, {
5484
+ _this38.setSalesNoteOnTempOrder(tempOrder, {
5397
5485
  note_type: draft.note_type,
5398
5486
  target: {
5399
5487
  target_type: 'order_detail',
@@ -5418,21 +5506,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5418
5506
  return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
5419
5507
  }) : -1;
5420
5508
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
5421
- _context29.prev = 10;
5509
+ _context29.prev = 14;
5422
5510
  if (!booking) {
5423
- _context29.next = 35;
5511
+ _context29.next = 39;
5424
5512
  break;
5425
5513
  }
5426
5514
  productRecord = product;
5427
5515
  splitCount = getSafeProductNum((_ref72 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5428
5516
  if (!(splitCount > 1)) {
5429
- _context29.next = 29;
5517
+ _context29.next = 33;
5430
5518
  break;
5431
5519
  }
5432
5520
  i = 0;
5433
- case 16:
5521
+ case 20:
5434
5522
  if (!(i < splitCount)) {
5435
- _context29.next = 27;
5523
+ _context29.next = 31;
5436
5524
  break;
5437
5525
  }
5438
5526
  splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
@@ -5450,79 +5538,79 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5450
5538
  delete splitLine.booking.metadata.unique_identification_number;
5451
5539
  }
5452
5540
  }
5453
- _context29.next = 21;
5541
+ _context29.next = 25;
5454
5542
  return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
5455
5543
  insertAtIndex: insertAtIndex,
5456
5544
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5457
5545
  beforeCommit: beforeCommit
5458
5546
  });
5459
- case 21:
5547
+ case 25:
5460
5548
  committedProduct = _context29.sent;
5461
5549
  attachSalesNoteDrafts(committedProduct);
5462
5550
  if (insertAtIndex !== undefined) insertAtIndex += 1;
5463
- case 24:
5551
+ case 28:
5464
5552
  i += 1;
5465
- _context29.next = 16;
5553
+ _context29.next = 20;
5466
5554
  break;
5467
- case 27:
5468
- _context29.next = 33;
5555
+ case 31:
5556
+ _context29.next = 37;
5469
5557
  break;
5470
- case 29:
5471
- _context29.next = 31;
5558
+ case 33:
5559
+ _context29.next = 35;
5472
5560
  return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
5473
5561
  insertAtIndex: insertAtIndex,
5474
5562
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5475
5563
  beforeCommit: beforeCommit
5476
5564
  });
5477
- case 31:
5565
+ case 35:
5478
5566
  _committedProduct = _context29.sent;
5479
5567
  attachSalesNoteDrafts(_committedProduct);
5480
- case 33:
5481
- _context29.next = 39;
5568
+ case 37:
5569
+ _context29.next = 43;
5482
5570
  break;
5483
- case 35:
5484
- _context29.next = 37;
5571
+ case 39:
5572
+ _context29.next = 41;
5485
5573
  return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
5486
5574
  insertAtIndex: insertAtIndex,
5487
5575
  disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5488
5576
  beforeCommit: beforeCommit
5489
5577
  });
5490
- case 37:
5578
+ case 41:
5491
5579
  _committedProduct2 = _context29.sent;
5492
5580
  attachSalesNoteDrafts(_committedProduct2);
5493
- case 39:
5494
- _context29.next = 45;
5581
+ case 43:
5582
+ _context29.next = 49;
5495
5583
  break;
5496
- case 41:
5497
- _context29.prev = 41;
5498
- _context29.t0 = _context29["catch"](10);
5584
+ case 45:
5585
+ _context29.prev = 45;
5586
+ _context29.t0 = _context29["catch"](14);
5499
5587
  rollbackProductAndNotesMutation();
5500
5588
  throw _context29.t0;
5501
- case 45:
5589
+ case 49:
5502
5590
  if (!mutation.commit) {
5503
- _context29.next = 49;
5591
+ _context29.next = 53;
5504
5592
  break;
5505
5593
  }
5506
- _context29.next = 48;
5594
+ _context29.next = 52;
5507
5595
  return mutation.commit(beforeCommit);
5508
- case 48:
5596
+ case 52:
5509
5597
  tempOrder = _context29.sent;
5510
- case 49:
5511
- _context29.next = 51;
5598
+ case 53:
5599
+ _context29.next = 55;
5512
5600
  return this.finalizeProductOrderMutation(tempOrder);
5513
- case 51:
5601
+ case 55:
5514
5602
  this.logInfo('addProductToOrder success', {
5515
5603
  product_id: product.product_id,
5516
5604
  with_booking: !!booking
5517
5605
  });
5518
5606
  return _context29.abrupt("return", tempOrder.products);
5519
- case 53:
5607
+ case 57:
5520
5608
  case "end":
5521
5609
  return _context29.stop();
5522
5610
  }
5523
- }, _callee27, this, [[10, 41]]);
5611
+ }, _callee27, this, [[14, 45]]);
5524
5612
  }));
5525
- function addProductToOrderDraft(_x28, _x29, _x30) {
5613
+ function addProductToOrderDraft(_x29, _x30, _x31) {
5526
5614
  return _addProductToOrderDraft.apply(this, arguments);
5527
5615
  }
5528
5616
  return addProductToOrderDraft;
@@ -5540,12 +5628,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5540
5628
  key: "addProductsToOrder",
5541
5629
  value: (function () {
5542
5630
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(items, options) {
5543
- var _this38 = this;
5631
+ var _this39 = this;
5544
5632
  return _regeneratorRuntime().wrap(function _callee28$(_context30) {
5545
5633
  while (1) switch (_context30.prev = _context30.next) {
5546
5634
  case 0:
5547
5635
  return _context30.abrupt("return", this.queueCartCommand(function () {
5548
- return _this38.addProductsToOrderDraft(items, options);
5636
+ return _this39.addProductsToOrderDraft(items, options);
5549
5637
  }));
5550
5638
  case 1:
5551
5639
  case "end":
@@ -5553,7 +5641,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5553
5641
  }
5554
5642
  }, _callee28, this);
5555
5643
  }));
5556
- function addProductsToOrder(_x31, _x32) {
5644
+ function addProductsToOrder(_x32, _x33) {
5557
5645
  return _addProductsToOrder.apply(this, arguments);
5558
5646
  }
5559
5647
  return addProductsToOrder;
@@ -5562,7 +5650,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5562
5650
  key: "addProductsToOrderDraft",
5563
5651
  value: function () {
5564
5652
  var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(items, options) {
5565
- var mutation, tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref73, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5653
+ var mutation, tempOrder, beforeCommit, _iterator22, _step22, item, product, booking, _ref73, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5566
5654
  return _regeneratorRuntime().wrap(function _callee29$(_context31) {
5567
5655
  while (1) switch (_context31.prev = _context31.next) {
5568
5656
  case 0:
@@ -5575,15 +5663,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5575
5663
  return _context31.abrupt("return", tempOrder.products);
5576
5664
  case 4:
5577
5665
  beforeCommit = this.createCartIntentCommitGuard('add_product', mutation.current);
5578
- _iterator20 = _createForOfIteratorHelper(items || []);
5666
+ _iterator22 = _createForOfIteratorHelper(items || []);
5579
5667
  _context31.prev = 6;
5580
- _iterator20.s();
5668
+ _iterator22.s();
5581
5669
  case 8:
5582
- if ((_step20 = _iterator20.n()).done) {
5670
+ if ((_step22 = _iterator22.n()).done) {
5583
5671
  _context31.next = 34;
5584
5672
  break;
5585
5673
  }
5586
- item = _step20.value;
5674
+ item = _step22.value;
5587
5675
  product = item.product, booking = item.booking;
5588
5676
  if (product) {
5589
5677
  _context31.next = 13;
@@ -5642,10 +5730,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5642
5730
  case 36:
5643
5731
  _context31.prev = 36;
5644
5732
  _context31.t0 = _context31["catch"](6);
5645
- _iterator20.e(_context31.t0);
5733
+ _iterator22.e(_context31.t0);
5646
5734
  case 39:
5647
5735
  _context31.prev = 39;
5648
- _iterator20.f();
5736
+ _iterator22.f();
5649
5737
  return _context31.finish(39);
5650
5738
  case 42:
5651
5739
  if (!mutation.commit) {
@@ -5670,7 +5758,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5670
5758
  }
5671
5759
  }, _callee29, this, [[6, 36, 39, 42]]);
5672
5760
  }));
5673
- function addProductsToOrderDraft(_x33, _x34) {
5761
+ function addProductsToOrderDraft(_x34, _x35) {
5674
5762
  return _addProductsToOrderDraft.apply(this, arguments);
5675
5763
  }
5676
5764
  return addProductsToOrderDraft;
@@ -5713,16 +5801,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5713
5801
  }, {
5714
5802
  key: "isRuntimeEntitlementAppend",
5715
5803
  value: function isRuntimeEntitlementAppend(product, tempOrder) {
5716
- var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
5804
+ var _product$metadata$uni, _product$metadata12, _tempOrder$_extend11, _product$_origin;
5717
5805
  if (this.isPersistedProductLine(product)) return false;
5718
5806
  var uid = (_product$metadata$uni = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
5719
- var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend10 = tempOrder._extend) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10.productsByUid) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10[String(uid)]) === null || _tempOrder$_extend10 === void 0 ? void 0 : _tempOrder$_extend10.origin : undefined;
5807
+ var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend11 = tempOrder._extend) === null || _tempOrder$_extend11 === void 0 || (_tempOrder$_extend11 = _tempOrder$_extend11.productsByUid) === null || _tempOrder$_extend11 === void 0 || (_tempOrder$_extend11 = _tempOrder$_extend11[String(uid)]) === null || _tempOrder$_extend11 === void 0 ? void 0 : _tempOrder$_extend11.origin : undefined;
5720
5808
  return Boolean((product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.__entitlementPassRuntimeAppend) === true || (storedOrigin === null || storedOrigin === void 0 ? void 0 : storedOrigin.__entitlementPassRuntimeAppend) === true);
5721
5809
  }
5722
5810
  }, {
5723
5811
  key: "hasSameEntitlementMergePriceConfig",
5724
5812
  value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5725
- var _this39 = this;
5813
+ var _this40 = this;
5726
5814
  var buildPriceConfig = function buildPriceConfig(product) {
5727
5815
  var metadata = product.metadata || {};
5728
5816
  var bundle = (product.product_bundle || []).map(function (item) {
@@ -5738,10 +5826,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5738
5826
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
5739
5827
  });
5740
5828
  return JSON.stringify({
5741
- original_price: _this39.normalizeFingerprintMoney(product.original_price),
5742
- source_product_price: _this39.normalizeFingerprintMoney(metadata.source_product_price),
5743
- main_product_original_price: _this39.normalizeFingerprintMoney(metadata.main_product_original_price),
5744
- price_override: _this39.normalizeFingerprintMoney(metadata.price_override),
5829
+ original_price: _this40.normalizeFingerprintMoney(product.original_price),
5830
+ source_product_price: _this40.normalizeFingerprintMoney(metadata.source_product_price),
5831
+ main_product_original_price: _this40.normalizeFingerprintMoney(metadata.main_product_original_price),
5832
+ price_override: _this40.normalizeFingerprintMoney(metadata.price_override),
5745
5833
  is_manual_discount: Boolean(metadata.is_manual_discount),
5746
5834
  bundle: bundle
5747
5835
  });
@@ -5758,17 +5846,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5758
5846
  }, {
5759
5847
  key: "preservePersistedBundlePriceFields",
5760
5848
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5761
- var _this40 = this;
5849
+ var _this41 = this;
5762
5850
  if (!Array.isArray(nextBundles)) return nextBundles;
5763
5851
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5764
5852
  var previousByIdentity = new Map();
5765
5853
  previousBundles.forEach(function (bundle) {
5766
- var identity = _this40.getBundleRuntimeIdentity(bundle);
5854
+ var identity = _this41.getBundleRuntimeIdentity(bundle);
5767
5855
  if (identity) previousByIdentity.set(identity, bundle);
5768
5856
  });
5769
5857
  return nextBundles.map(function (bundle, index) {
5770
5858
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5771
- var previous = previousByIdentity.get(_this40.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5859
+ var previous = previousByIdentity.get(_this41.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5772
5860
  if (!previous || _typeof(previous) !== 'object') return bundle;
5773
5861
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5774
5862
  cover: previous.cover
@@ -6041,12 +6129,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6041
6129
  key: "updateOrderProduct",
6042
6130
  value: function () {
6043
6131
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
6044
- var _this41 = this;
6132
+ var _this42 = this;
6045
6133
  return _regeneratorRuntime().wrap(function _callee30$(_context32) {
6046
6134
  while (1) switch (_context32.prev = _context32.next) {
6047
6135
  case 0:
6048
6136
  return _context32.abrupt("return", this.queueCartCommand(function () {
6049
- return _this41.updateOrderProductDraft(params);
6137
+ return _this42.updateOrderProductDraft(params);
6050
6138
  }));
6051
6139
  case 1:
6052
6140
  case "end":
@@ -6054,7 +6142,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6054
6142
  }
6055
6143
  }, _callee30, this);
6056
6144
  }));
6057
- function updateOrderProduct(_x35) {
6145
+ function updateOrderProduct(_x36) {
6058
6146
  return _updateOrderProduct.apply(this, arguments);
6059
6147
  }
6060
6148
  return updateOrderProduct;
@@ -6108,7 +6196,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6108
6196
  }
6109
6197
  }, _callee31, this);
6110
6198
  }));
6111
- function updateOrderProductDraft(_x36) {
6199
+ function updateOrderProductDraft(_x37) {
6112
6200
  return _updateOrderProductDraft.apply(this, arguments);
6113
6201
  }
6114
6202
  return updateOrderProductDraft;
@@ -6117,12 +6205,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6117
6205
  key: "updateOrderProducts",
6118
6206
  value: function () {
6119
6207
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(paramsList) {
6120
- var _this42 = this;
6208
+ var _this43 = this;
6121
6209
  return _regeneratorRuntime().wrap(function _callee32$(_context34) {
6122
6210
  while (1) switch (_context34.prev = _context34.next) {
6123
6211
  case 0:
6124
6212
  return _context34.abrupt("return", this.queueCartCommand(function () {
6125
- return _this42.updateOrderProductsDraft(paramsList);
6213
+ return _this43.updateOrderProductsDraft(paramsList);
6126
6214
  }));
6127
6215
  case 1:
6128
6216
  case "end":
@@ -6130,7 +6218,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6130
6218
  }
6131
6219
  }, _callee32, this);
6132
6220
  }));
6133
- function updateOrderProducts(_x37) {
6221
+ function updateOrderProducts(_x38) {
6134
6222
  return _updateOrderProducts.apply(this, arguments);
6135
6223
  }
6136
6224
  return updateOrderProducts;
@@ -6139,7 +6227,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6139
6227
  key: "updateOrderProductsDraft",
6140
6228
  value: function () {
6141
6229
  var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
6142
- var _this43 = this;
6230
+ var _this44 = this;
6143
6231
  var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
6144
6232
  return _regeneratorRuntime().wrap(function _callee33$(_context35) {
6145
6233
  while (1) switch (_context35.prev = _context35.next) {
@@ -6153,12 +6241,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6153
6241
  return _context35.abrupt("return", tempOrder.products);
6154
6242
  case 4:
6155
6243
  beforeCommit = paramsList.some(function (params) {
6156
- return _this43.isRestrictedCartProductUpdate(tempOrder, params);
6244
+ return _this44.isRestrictedCartProductUpdate(tempOrder, params);
6157
6245
  }) ? this.createCartIntentCommitGuard('update_product', mutation.current) : undefined;
6158
6246
  beforeCommit === null || beforeCommit === void 0 || beforeCommit();
6159
6247
  reapplyWeighedDiscountProductUids = [];
6160
6248
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
6161
- var updatedProductUid = _this43.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
6249
+ var updatedProductUid = _this44.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
6162
6250
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
6163
6251
  if (params.allow_booking_discount_reapply && updatedProductUid) {
6164
6252
  acc.push(String(updatedProductUid));
@@ -6190,7 +6278,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6190
6278
  }
6191
6279
  }, _callee33, this);
6192
6280
  }));
6193
- function updateOrderProductsDraft(_x38) {
6281
+ function updateOrderProductsDraft(_x39) {
6194
6282
  return _updateOrderProductsDraft.apply(this, arguments);
6195
6283
  }
6196
6284
  return updateOrderProductsDraft;
@@ -6199,12 +6287,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6199
6287
  key: "updateOrderProductQuantity",
6200
6288
  value: function () {
6201
6289
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
6202
- var _this44 = this;
6290
+ var _this45 = this;
6203
6291
  return _regeneratorRuntime().wrap(function _callee34$(_context36) {
6204
6292
  while (1) switch (_context36.prev = _context36.next) {
6205
6293
  case 0:
6206
6294
  return _context36.abrupt("return", this.queueCartCommand(function () {
6207
- return _this44.updateOrderProductQuantityDraft(params);
6295
+ return _this45.updateOrderProductQuantityDraft(params);
6208
6296
  }));
6209
6297
  case 1:
6210
6298
  case "end":
@@ -6212,7 +6300,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6212
6300
  }
6213
6301
  }, _callee34, this);
6214
6302
  }));
6215
- function updateOrderProductQuantity(_x39) {
6303
+ function updateOrderProductQuantity(_x40) {
6216
6304
  return _updateOrderProductQuantity.apply(this, arguments);
6217
6305
  }
6218
6306
  return updateOrderProductQuantity;
@@ -6345,7 +6433,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6345
6433
  }
6346
6434
  }, _callee35, this);
6347
6435
  }));
6348
- function updateOrderProductQuantityDraft(_x40) {
6436
+ function updateOrderProductQuantityDraft(_x41) {
6349
6437
  return _updateOrderProductQuantityDraft.apply(this, arguments);
6350
6438
  }
6351
6439
  return updateOrderProductQuantityDraft;
@@ -6414,7 +6502,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6414
6502
  }
6415
6503
  }, _callee36, this);
6416
6504
  }));
6417
- function finalizeAfterProductsMutation(_x41, _x42) {
6505
+ function finalizeAfterProductsMutation(_x42, _x43) {
6418
6506
  return _finalizeAfterProductsMutation.apply(this, arguments);
6419
6507
  }
6420
6508
  return finalizeAfterProductsMutation;
@@ -6430,12 +6518,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6430
6518
  key: "removeProductsFromOrder",
6431
6519
  value: (function () {
6432
6520
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(identities, options) {
6433
- var _this45 = this;
6521
+ var _this46 = this;
6434
6522
  return _regeneratorRuntime().wrap(function _callee37$(_context39) {
6435
6523
  while (1) switch (_context39.prev = _context39.next) {
6436
6524
  case 0:
6437
6525
  return _context39.abrupt("return", this.queueCartCommand(function () {
6438
- return _this45.removeProductsFromOrderDraft(identities, options);
6526
+ return _this46.removeProductsFromOrderDraft(identities, options);
6439
6527
  }));
6440
6528
  case 1:
6441
6529
  case "end":
@@ -6443,7 +6531,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6443
6531
  }
6444
6532
  }, _callee37, this);
6445
6533
  }));
6446
- function removeProductsFromOrder(_x43, _x44) {
6534
+ function removeProductsFromOrder(_x44, _x45) {
6447
6535
  return _removeProductsFromOrder.apply(this, arguments);
6448
6536
  }
6449
6537
  return removeProductsFromOrder;
@@ -6452,8 +6540,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6452
6540
  key: "removeProductsFromOrderDraft",
6453
6541
  value: function () {
6454
6542
  var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(identities, options) {
6455
- var _this46 = this;
6456
- var mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
6543
+ var _this47 = this;
6544
+ var mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator23, _step23, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
6457
6545
  return _regeneratorRuntime().wrap(function _callee38$(_context41) {
6458
6546
  while (1) switch (_context41.prev = _context41.next) {
6459
6547
  case 0:
@@ -6495,7 +6583,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6495
6583
  this.removeLinkedBookingsForProduct(tempOrder, product);
6496
6584
  }
6497
6585
  linkedBookingUidsToRemove = new Set();
6498
- _iterator21 = _createForOfIteratorHelper(matchedProducts);
6586
+ _iterator23 = _createForOfIteratorHelper(matchedProducts);
6499
6587
  _context41.prev = 17;
6500
6588
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
6501
6589
  var _metadata11, _metadata12, _metadata13, _metadata14;
@@ -6503,7 +6591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6503
6591
  return _regeneratorRuntime().wrap(function _loop3$(_context40) {
6504
6592
  while (1) switch (_context40.prev = _context40.next) {
6505
6593
  case 0:
6506
- product = _step21.value;
6594
+ product = _step23.value;
6507
6595
  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);
6508
6596
  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);
6509
6597
  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;
@@ -6518,7 +6606,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6518
6606
  }
6519
6607
  if (productUid !== undefined && productUid !== null && productUid !== '') {
6520
6608
  bookingsBeforeRemove.forEach(function (booking) {
6521
- var bookingUid = _this46.getBookingUniqueIdentificationNumber(booking);
6609
+ var bookingUid = _this47.getBookingUniqueIdentificationNumber(booking);
6522
6610
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
6523
6611
  linkedBookingUidsToRemove.add(bookingUid);
6524
6612
  }
@@ -6530,9 +6618,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6530
6618
  }
6531
6619
  }, _loop3);
6532
6620
  });
6533
- _iterator21.s();
6621
+ _iterator23.s();
6534
6622
  case 20:
6535
- if ((_step21 = _iterator21.n()).done) {
6623
+ if ((_step23 = _iterator23.n()).done) {
6536
6624
  _context41.next = 26;
6537
6625
  break;
6538
6626
  }
@@ -6552,10 +6640,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6552
6640
  case 28:
6553
6641
  _context41.prev = 28;
6554
6642
  _context41.t1 = _context41["catch"](17);
6555
- _iterator21.e(_context41.t1);
6643
+ _iterator23.e(_context41.t1);
6556
6644
  case 31:
6557
6645
  _context41.prev = 31;
6558
- _iterator21.f();
6646
+ _iterator23.f();
6559
6647
  return _context41.finish(31);
6560
6648
  case 34:
6561
6649
  if (linkedBookingUidsToRemove.size > 0) {
@@ -6609,7 +6697,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6609
6697
  }
6610
6698
  }, _callee38, this, [[17, 28, 31, 34]]);
6611
6699
  }));
6612
- function removeProductsFromOrderDraft(_x45, _x46) {
6700
+ function removeProductsFromOrderDraft(_x46, _x47) {
6613
6701
  return _removeProductsFromOrderDraft.apply(this, arguments);
6614
6702
  }
6615
6703
  return removeProductsFromOrderDraft;
@@ -6628,7 +6716,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6628
6716
  }
6629
6717
  }, _callee39, this);
6630
6718
  }));
6631
- function removeProductFromOrder(_x47, _x48) {
6719
+ function removeProductFromOrder(_x48, _x49) {
6632
6720
  return _removeProductFromOrder.apply(this, arguments);
6633
6721
  }
6634
6722
  return removeProductFromOrder;
@@ -6641,12 +6729,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6641
6729
  key: "clearOrderCartLines",
6642
6730
  value: (function () {
6643
6731
  var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
6644
- var _this47 = this;
6732
+ var _this48 = this;
6645
6733
  return _regeneratorRuntime().wrap(function _callee40$(_context43) {
6646
6734
  while (1) switch (_context43.prev = _context43.next) {
6647
6735
  case 0:
6648
6736
  return _context43.abrupt("return", this.queueCartCommand(function () {
6649
- return _this47.clearOrderCartLinesDraft();
6737
+ return _this48.clearOrderCartLinesDraft();
6650
6738
  }));
6651
6739
  case 1:
6652
6740
  case "end":
@@ -6836,7 +6924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6836
6924
  }
6837
6925
  }, _callee43, this);
6838
6926
  }));
6839
- function applyLocalPrintOrderNumbers(_x49) {
6927
+ function applyLocalPrintOrderNumbers(_x50) {
6840
6928
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
6841
6929
  }
6842
6930
  return applyLocalPrintOrderNumbers;
@@ -6903,7 +6991,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6903
6991
  }
6904
6992
  }, _callee44, this);
6905
6993
  }));
6906
- function saveTempOrderAsDraft(_x50) {
6994
+ function saveTempOrderAsDraft(_x51) {
6907
6995
  return _saveTempOrderAsDraft.apply(this, arguments);
6908
6996
  }
6909
6997
  return saveTempOrderAsDraft;
@@ -6928,7 +7016,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6928
7016
  }
6929
7017
  }, _callee45, this);
6930
7018
  }));
6931
- function submitTempOrder(_x51) {
7019
+ function submitTempOrder(_x52) {
6932
7020
  return _submitTempOrder.apply(this, arguments);
6933
7021
  }
6934
7022
  return submitTempOrder;
@@ -6949,7 +7037,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6949
7037
  }
6950
7038
  }, _callee46, this);
6951
7039
  }));
6952
- function submitTempOrderAsync(_x52) {
7040
+ function submitTempOrderAsync(_x53) {
6953
7041
  return _submitTempOrderAsync.apply(this, arguments);
6954
7042
  }
6955
7043
  return submitTempOrderAsync;
@@ -6964,6 +7052,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6964
7052
  while (1) switch (_context50.prev = _context50.next) {
6965
7053
  case 0:
6966
7054
  tempOrder = this.ensureTempOrder();
7055
+ validateProductVoucherGroups(tempOrder, this.getDiscountList(), undefined, true);
6967
7056
  this.prepareVirtualSettlementTempOrder(tempOrder);
6968
7057
  isOnlineStorePlatform = this.isOnlineStorePlatform();
6969
7058
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -6985,25 +7074,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6985
7074
  }
6986
7075
  }
6987
7076
  this.persistTempOrder();
6988
- _context50.next = 10;
7077
+ _context50.next = 11;
6989
7078
  return this.recalculateSummary({
6990
7079
  createIfMissing: true
6991
7080
  });
6992
- case 10:
7081
+ case 11:
6993
7082
  _context50.t1 = _context50.sent;
6994
7083
  if (_context50.t1) {
6995
- _context50.next = 13;
7084
+ _context50.next = 14;
6996
7085
  break;
6997
7086
  }
6998
7087
  _context50.t1 = this.store.summary;
6999
- case 13:
7088
+ case 14:
7000
7089
  _context50.t0 = _context50.t1;
7001
7090
  if (_context50.t0) {
7002
- _context50.next = 16;
7091
+ _context50.next = 17;
7003
7092
  break;
7004
7093
  }
7005
7094
  _context50.t0 = createEmptySummary();
7006
- case 16:
7095
+ case 17:
7007
7096
  latestSummary = _context50.t0;
7008
7097
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
7009
7098
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
@@ -7040,10 +7129,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7040
7129
  if (!payload.created_at) {
7041
7130
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
7042
7131
  }
7043
- _context50.next = 28;
7132
+ _context50.next = 29;
7044
7133
  return this.saveDraft();
7045
- case 28:
7046
- _context50.prev = 28;
7134
+ case 29:
7135
+ _context50.prev = 29;
7047
7136
  this.logInfo('submitTempOrder calling sales checkout', {
7048
7137
  orderId: payload.order_id,
7049
7138
  externalSaleNumber: payload.external_sale_number,
@@ -7053,26 +7142,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7053
7142
  smallTicketDataFlag: payload.small_ticket_data_flag,
7054
7143
  syncMode: payload.sync_mode
7055
7144
  });
7056
- _context50.next = 32;
7145
+ _context50.next = 33;
7057
7146
  return this.submitSalesOrder({
7058
7147
  query: payload
7059
7148
  });
7060
- case 32:
7149
+ case 33:
7061
7150
  result = _context50.sent;
7062
- _context50.next = 45;
7151
+ _context50.next = 46;
7063
7152
  break;
7064
- case 35:
7065
- _context50.prev = 35;
7066
- _context50.t2 = _context50["catch"](28);
7153
+ case 36:
7154
+ _context50.prev = 36;
7155
+ _context50.t2 = _context50["catch"](29);
7067
7156
  backendErrorResponse = this.extractSubmitErrorResponse(_context50.t2);
7068
7157
  if (!backendErrorResponse) {
7069
- _context50.next = 42;
7158
+ _context50.next = 43;
7070
7159
  break;
7071
7160
  }
7072
7161
  this.store.syncState = 'failed';
7073
7162
  this.logSubmitBackendRejected(backendErrorResponse, payload);
7074
7163
  return _context50.abrupt("return", backendErrorResponse);
7075
- case 42:
7164
+ case 43:
7076
7165
  this.store.syncState = 'failed';
7077
7166
  this.logError('submitTempOrder failed', {
7078
7167
  error: _context50.t2 instanceof Error ? _context50.t2.message : String(_context50.t2),
@@ -7082,15 +7171,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7082
7171
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
7083
7172
  });
7084
7173
  throw _context50.t2;
7085
- case 45:
7174
+ case 46:
7086
7175
  if (!this.isSubmitResponseRejected(result)) {
7087
- _context50.next = 49;
7176
+ _context50.next = 50;
7088
7177
  break;
7089
7178
  }
7090
7179
  this.store.syncState = 'failed';
7091
7180
  this.logSubmitBackendRejected(result, payload);
7092
7181
  return _context50.abrupt("return", result);
7093
- case 49:
7182
+ case 50:
7094
7183
  isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
7095
7184
  if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
7096
7185
  salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
@@ -7105,27 +7194,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7105
7194
  })
7106
7195
  });
7107
7196
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
7108
- _context50.next = 58;
7197
+ _context50.next = 59;
7109
7198
  break;
7110
7199
  }
7111
7200
  tempOrder.order_id = submittedOrderId;
7112
7201
  resultRecord = result;
7113
- _context50.next = 58;
7202
+ _context50.next = 59;
7114
7203
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
7115
- case 58:
7204
+ case 59:
7116
7205
  if (isLocalPendingSubmit) {
7117
7206
  this.store.syncState = 'local';
7118
7207
  } else if (submittedOrderId === null || submittedOrderId === undefined) {
7119
7208
  this.store.syncState = 'submitted';
7120
7209
  }
7121
7210
  return _context50.abrupt("return", result);
7122
- case 60:
7211
+ case 61:
7123
7212
  case "end":
7124
7213
  return _context50.stop();
7125
7214
  }
7126
- }, _callee47, this, [[28, 35]]);
7215
+ }, _callee47, this, [[29, 36]]);
7127
7216
  }));
7128
- function runSubmitTempOrder(_x53) {
7217
+ function runSubmitTempOrder(_x54) {
7129
7218
  return _runSubmitTempOrder.apply(this, arguments);
7130
7219
  }
7131
7220
  return runSubmitTempOrder;
@@ -7152,7 +7241,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7152
7241
  }
7153
7242
  }, _callee48, this);
7154
7243
  }));
7155
- function markLocalOrderSynced(_x54, _x55) {
7244
+ function markLocalOrderSynced(_x55, _x56) {
7156
7245
  return _markLocalOrderSynced.apply(this, arguments);
7157
7246
  }
7158
7247
  return markLocalOrderSynced;
@@ -7195,10 +7284,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7195
7284
  value: function extractSubmitErrorResponse(error) {
7196
7285
  var _error$response,
7197
7286
  _error$response2,
7198
- _this48 = this;
7287
+ _this49 = this;
7199
7288
  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];
7200
7289
  return candidates.find(function (candidate) {
7201
- return _this48.isSubmitErrorResponse(candidate);
7290
+ return _this49.isSubmitErrorResponse(candidate);
7202
7291
  }) || null;
7203
7292
  }
7204
7293
  }, {
@@ -7226,7 +7315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7226
7315
  key: "syncPaymentsToOrder",
7227
7316
  value: function () {
7228
7317
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
7229
- var _this49 = this,
7318
+ var _this50 = this,
7230
7319
  _params$confirmPendin;
7231
7320
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
7232
7321
  return _regeneratorRuntime().wrap(function _callee49$(_context52) {
@@ -7251,7 +7340,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7251
7340
  case 9:
7252
7341
  devicePrefix = _context52.t0;
7253
7342
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
7254
- return _this49.normalizePaymentSource(payment, {
7343
+ return _this50.normalizePaymentSource(payment, {
7255
7344
  defaultPaid: false,
7256
7345
  devicePrefix: devicePrefix
7257
7346
  });
@@ -7322,7 +7411,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7322
7411
  }
7323
7412
  }, _callee49, this);
7324
7413
  }));
7325
- function syncPaymentsToOrder(_x56) {
7414
+ function syncPaymentsToOrder(_x57) {
7326
7415
  return _syncPaymentsToOrder.apply(this, arguments);
7327
7416
  }
7328
7417
  return syncPaymentsToOrder;
@@ -7330,7 +7419,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7330
7419
  }, {
7331
7420
  key: "createOrder",
7332
7421
  value: function createOrder(params) {
7333
- var _this50 = this;
7422
+ var _this51 = this;
7334
7423
  var order = _objectSpread({
7335
7424
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
7336
7425
  // 要从外面拿,virtual
@@ -7362,7 +7451,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7362
7451
 
7363
7452
  // 为预约补齐 holder 信息
7364
7453
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
7365
- ensureCartItemOriginHolder(item, _this50.window);
7454
+ ensureCartItemOriginHolder(item, _this51.window);
7366
7455
  }
7367
7456
 
7368
7457
  // 购物车是否为普通商品
@@ -7450,7 +7539,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7450
7539
  }
7451
7540
  }, _callee50, this);
7452
7541
  }));
7453
- function submitOrder(_x57) {
7542
+ function submitOrder(_x58) {
7454
7543
  return _submitOrder.apply(this, arguments);
7455
7544
  }
7456
7545
  return submitOrder;
@@ -7489,7 +7578,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7489
7578
  }
7490
7579
  }, _callee51, this);
7491
7580
  }));
7492
- function cancelOrder(_x58) {
7581
+ function cancelOrder(_x59) {
7493
7582
  return _cancelOrder.apply(this, arguments);
7494
7583
  }
7495
7584
  return cancelOrder;
@@ -7533,7 +7622,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7533
7622
  }
7534
7623
  }, _callee52, this);
7535
7624
  }));
7536
- function changeBookingStatus(_x59) {
7625
+ function changeBookingStatus(_x60) {
7537
7626
  return _changeBookingStatus.apply(this, arguments);
7538
7627
  }
7539
7628
  return changeBookingStatus;
@@ -7653,7 +7742,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7653
7742
  }
7654
7743
  }, _callee53, this, [[3, 15]]);
7655
7744
  }));
7656
- function createOrderByCheckout(_x60) {
7745
+ function createOrderByCheckout(_x61) {
7657
7746
  return _createOrderByCheckout.apply(this, arguments);
7658
7747
  }
7659
7748
  return createOrderByCheckout;
@@ -7679,7 +7768,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7679
7768
  }
7680
7769
  }, _callee54, this);
7681
7770
  }));
7682
- function submitSalesOrder(_x61) {
7771
+ function submitSalesOrder(_x62) {
7683
7772
  return _submitSalesOrder.apply(this, arguments);
7684
7773
  }
7685
7774
  return submitSalesOrder;
@@ -7736,7 +7825,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7736
7825
  }
7737
7826
  }, _callee55, this);
7738
7827
  }));
7739
- function sendCustomerPayLink(_x62) {
7828
+ function sendCustomerPayLink(_x63) {
7740
7829
  return _sendCustomerPayLink.apply(this, arguments);
7741
7830
  }
7742
7831
  return sendCustomerPayLink;
@@ -7778,7 +7867,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7778
7867
  }
7779
7868
  }, _callee56, this);
7780
7869
  }));
7781
- function getSalesOrderByLookup(_x63) {
7870
+ function getSalesOrderByLookup(_x64) {
7782
7871
  return _getSalesOrderByLookup.apply(this, arguments);
7783
7872
  }
7784
7873
  return getSalesOrderByLookup;
@@ -7950,7 +8039,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7950
8039
  }
7951
8040
  }, _callee57, this);
7952
8041
  }));
7953
- function hydrateTempOrderFromRecord(_x64, _x65) {
8042
+ function hydrateTempOrderFromRecord(_x65, _x66) {
7954
8043
  return _hydrateTempOrderFromRecord.apply(this, arguments);
7955
8044
  }
7956
8045
  return hydrateTempOrderFromRecord;
@@ -7999,12 +8088,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7999
8088
  if (!raw || _typeof(raw) !== 'object') return {};
8000
8089
  if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
8001
8090
  var bookingUidsByProductUid = new Map();
8002
- var _iterator22 = _createForOfIteratorHelper(raw.products),
8003
- _step22;
8091
+ var _iterator24 = _createForOfIteratorHelper(raw.products),
8092
+ _step24;
8004
8093
  try {
8005
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
8094
+ for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
8006
8095
  var _product$metadata13;
8007
- var product = _step22.value;
8096
+ var product = _step24.value;
8008
8097
  var productUid = getOrderCollectionUid('product', product);
8009
8098
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
8010
8099
  if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
@@ -8015,18 +8104,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8015
8104
  bookingUidsByProductUid.set(productUid, candidates);
8016
8105
  }
8017
8106
  } catch (err) {
8018
- _iterator22.e(err);
8107
+ _iterator24.e(err);
8019
8108
  } finally {
8020
- _iterator22.f();
8109
+ _iterator24.f();
8021
8110
  }
8022
8111
  if (bookingUidsByProductUid.size === 0) return raw;
8023
8112
  var anonymousBookingCountByProductUid = new Map();
8024
- var _iterator23 = _createForOfIteratorHelper(raw.bookings),
8025
- _step23;
8113
+ var _iterator25 = _createForOfIteratorHelper(raw.bookings),
8114
+ _step25;
8026
8115
  try {
8027
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
8116
+ for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
8028
8117
  var _booking$metadata9;
8029
- var booking = _step23.value;
8118
+ var booking = _step25.value;
8030
8119
  if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
8031
8120
  continue;
8032
8121
  }
@@ -8036,9 +8125,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8036
8125
  anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
8037
8126
  }
8038
8127
  } catch (err) {
8039
- _iterator23.e(err);
8128
+ _iterator25.e(err);
8040
8129
  } finally {
8041
- _iterator23.f();
8130
+ _iterator25.f();
8042
8131
  }
8043
8132
  return _objectSpread(_objectSpread({}, raw), {}, {
8044
8133
  bookings: raw.bookings.map(function (booking) {
@@ -8064,7 +8153,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8064
8153
  }, {
8065
8154
  key: "normalizeTempOrderForRuntime",
8066
8155
  value: function normalizeTempOrderForRuntime(raw, options) {
8067
- var _this51 = this,
8156
+ var _this52 = this,
8068
8157
  _raw$_extend;
8069
8158
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
8070
8159
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -8092,12 +8181,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8092
8181
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
8093
8182
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
8094
8183
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
8095
- return _this51.normalizeHydratedOrderProduct(p, {
8184
+ return _this52.normalizeHydratedOrderProduct(p, {
8096
8185
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
8097
8186
  });
8098
8187
  }) : [];
8099
8188
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
8100
- var booking = _this51.normalizeHydratedBookingHolder(b || {});
8189
+ var booking = _this52.normalizeHydratedBookingHolder(b || {});
8101
8190
  return _objectSpread(_objectSpread({}, booking), {}, {
8102
8191
  is_all: normalizeBookingIsAll(booking),
8103
8192
  sub_type: normalizeBookingSubType(booking)
@@ -8143,14 +8232,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8143
8232
  dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
8144
8233
  };
8145
8234
  var productsByUid = tempOrderExtend.productsByUid || {};
8146
- var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
8147
- _step24;
8235
+ var _iterator26 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
8236
+ _step26;
8148
8237
  try {
8149
- for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
8238
+ for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
8150
8239
  var _product$metadata14, _ref95, _ref96, _existed$origin, _rawProduct$metadata;
8151
- var _step24$value = _slicedToArray(_step24.value, 2),
8152
- index = _step24$value[0],
8153
- product = _step24$value[1];
8240
+ var _step26$value = _slicedToArray(_step26.value, 2),
8241
+ index = _step26$value[0],
8242
+ product = _step26$value[1];
8154
8243
  var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
8155
8244
  if (!uid) continue;
8156
8245
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
@@ -8171,14 +8260,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8171
8260
  });
8172
8261
  }
8173
8262
  } catch (err) {
8174
- _iterator24.e(err);
8263
+ _iterator26.e(err);
8175
8264
  } finally {
8176
- _iterator24.f();
8265
+ _iterator26.f();
8177
8266
  }
8178
8267
  tempOrderExtend.productsByUid = productsByUid;
8179
8268
  this.hydrateLinkedBookingIdentity(nextTempOrder);
8180
8269
  nextTempOrder.products.forEach(function (product) {
8181
- return _this51.sanitizeOrderProductForTempOrder(product);
8270
+ return _this52.sanitizeOrderProductForTempOrder(product);
8182
8271
  });
8183
8272
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
8184
8273
  this.ensureExternalSaleNumber(nextTempOrder);
@@ -8268,18 +8357,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8268
8357
  var segments = [];
8269
8358
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
8270
8359
  if (Array.isArray(sku.variant)) {
8271
- var _iterator25 = _createForOfIteratorHelper(sku.variant),
8272
- _step25;
8360
+ var _iterator27 = _createForOfIteratorHelper(sku.variant),
8361
+ _step27;
8273
8362
  try {
8274
- for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
8275
- var variant = _step25.value;
8363
+ for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
8364
+ var variant = _step27.value;
8276
8365
  var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
8277
8366
  if (segment) segments.push(segment);
8278
8367
  }
8279
8368
  } catch (err) {
8280
- _iterator25.e(err);
8369
+ _iterator27.e(err);
8281
8370
  } finally {
8282
- _iterator25.f();
8371
+ _iterator27.f();
8283
8372
  }
8284
8373
  }
8285
8374
  return segments.join(', ');
@@ -8307,7 +8396,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8307
8396
  }, {
8308
8397
  key: "normalizeHydratedOrderProduct",
8309
8398
  value: function normalizeHydratedOrderProduct(product, options) {
8310
- var _this52 = this;
8399
+ var _this53 = this;
8311
8400
  var row = _objectSpread({}, product || {});
8312
8401
  if (row.num === undefined && row.product_quantity !== undefined) {
8313
8402
  row.num = row.product_quantity;
@@ -8315,7 +8404,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8315
8404
  var productSku = ensureProductSku(row);
8316
8405
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
8317
8406
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
8318
- return _this52.normalizeHydratedProductOptionItem(optionItem || {});
8407
+ return _this53.normalizeHydratedProductOptionItem(optionItem || {});
8319
8408
  }))
8320
8409
  });
8321
8410
  delete row["product_".concat('option', "_item")];
@@ -8395,7 +8484,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8395
8484
  }
8396
8485
  }, _callee58, this);
8397
8486
  }));
8398
- function getOrderInfo(_x66) {
8487
+ function getOrderInfo(_x67) {
8399
8488
  return _getOrderInfo.apply(this, arguments);
8400
8489
  }
8401
8490
  return getOrderInfo;
@@ -8403,8 +8492,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8403
8492
  }, {
8404
8493
  key: "getVouchers",
8405
8494
  value: function getVouchers() {
8406
- var _this$store$tempOrder9;
8407
- return ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.vouchers) || [];
8495
+ var _this$store$tempOrder10;
8496
+ return ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.vouchers) || [];
8408
8497
  }
8409
8498
  }], [{
8410
8499
  key: "populateSavedAmounts",
@@ -8431,69 +8520,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8431
8520
  addDiscountAmount(savedMap, discountKey, amount);
8432
8521
  addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
8433
8522
  };
8434
- var _iterator26 = _createForOfIteratorHelper(productList),
8435
- _step26;
8523
+ var _iterator28 = _createForOfIteratorHelper(productList),
8524
+ _step28;
8436
8525
  try {
8437
- for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
8438
- var product = _step26.value;
8526
+ for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
8527
+ var product = _step28.value;
8439
8528
  var qty = product.num || 1;
8440
8529
  var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
8441
- var _iterator28 = _createForOfIteratorHelper(product.discount_list || []),
8442
- _step28;
8530
+ var _iterator30 = _createForOfIteratorHelper(product.discount_list || []),
8531
+ _step30;
8443
8532
  try {
8444
- for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
8445
- var pd = _step28.value;
8533
+ for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
8534
+ var pd = _step30.value;
8446
8535
  addProductDiscountAmount(pd, qty, isPersistedProduct);
8447
8536
  }
8448
8537
  } catch (err) {
8449
- _iterator28.e(err);
8538
+ _iterator30.e(err);
8450
8539
  } finally {
8451
- _iterator28.f();
8540
+ _iterator30.f();
8452
8541
  }
8453
- var _iterator29 = _createForOfIteratorHelper(product.product_bundle || []),
8454
- _step29;
8542
+ var _iterator31 = _createForOfIteratorHelper(product.product_bundle || []),
8543
+ _step31;
8455
8544
  try {
8456
- for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
8457
- var bundle = _step29.value;
8545
+ for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
8546
+ var bundle = _step31.value;
8458
8547
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
8459
8548
  var bundleQty = Number(qty) || 1;
8460
- var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
8461
- _step30;
8549
+ var _iterator32 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
8550
+ _step32;
8462
8551
  try {
8463
- for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
8464
- var _pd = _step30.value;
8552
+ for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
8553
+ var _pd = _step32.value;
8465
8554
  addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
8466
8555
  }
8467
8556
  } catch (err) {
8468
- _iterator30.e(err);
8557
+ _iterator32.e(err);
8469
8558
  } finally {
8470
- _iterator30.f();
8559
+ _iterator32.f();
8471
8560
  }
8472
8561
  }
8473
8562
  } catch (err) {
8474
- _iterator29.e(err);
8563
+ _iterator31.e(err);
8475
8564
  } finally {
8476
- _iterator29.f();
8565
+ _iterator31.f();
8477
8566
  }
8478
8567
  }
8479
8568
  } catch (err) {
8480
- _iterator26.e(err);
8569
+ _iterator28.e(err);
8481
8570
  } finally {
8482
- _iterator26.f();
8571
+ _iterator28.f();
8483
8572
  }
8484
- var _iterator27 = _createForOfIteratorHelper(discountList),
8485
- _step27;
8573
+ var _iterator29 = _createForOfIteratorHelper(discountList),
8574
+ _step29;
8486
8575
  try {
8487
- for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
8488
- var d = _step27.value;
8576
+ for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
8577
+ var d = _step29.value;
8489
8578
  var key = d.id;
8490
8579
  var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
8491
8580
  d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
8492
8581
  }
8493
8582
  } catch (err) {
8494
- _iterator27.e(err);
8583
+ _iterator29.e(err);
8495
8584
  } finally {
8496
- _iterator27.f();
8585
+ _iterator29.f();
8497
8586
  }
8498
8587
  }
8499
8588
  }]);