@pisell/pisellos 2.2.223 → 2.2.225

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
  3. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
  4. package/dist/modules/Customer/index.d.ts +7 -0
  5. package/dist/modules/Customer/index.js +16 -0
  6. package/dist/modules/OpenData/index.d.ts +7 -0
  7. package/dist/modules/OpenData/index.js +15 -0
  8. package/dist/modules/Order/index.d.ts +44 -0
  9. package/dist/modules/Order/index.js +306 -113
  10. package/dist/modules/Order/types.d.ts +16 -0
  11. package/dist/modules/Order/utils.js +7 -4
  12. package/dist/modules/Payment/index.d.ts +7 -0
  13. package/dist/modules/Payment/index.js +12 -0
  14. package/dist/modules/ProductList/index.d.ts +7 -0
  15. package/dist/modules/ProductList/index.js +11 -0
  16. package/dist/modules/SalesSummary/index.d.ts +7 -0
  17. package/dist/modules/SalesSummary/index.js +58 -23
  18. package/dist/modules/Schedule/index.d.ts +7 -0
  19. package/dist/modules/Schedule/index.js +16 -0
  20. package/dist/server/index.d.ts +6 -0
  21. package/dist/server/index.js +519 -355
  22. package/dist/server/modules/order/types.d.ts +2 -0
  23. package/dist/server/modules/order/utils/filterBookings.js +25 -2
  24. package/dist/server/utils/small-ticket.js +160 -30
  25. package/dist/solution/BaseSales/index.d.ts +17 -0
  26. package/dist/solution/BaseSales/index.js +524 -439
  27. package/dist/solution/BaseSales/utils/cartPromotion.js +26 -7
  28. package/dist/solution/BookingByStep/index.d.ts +1 -1
  29. package/dist/solution/BookingTicket/index.d.ts +1 -9
  30. package/dist/solution/BookingTicket/index.js +42 -76
  31. package/dist/types/index.d.ts +10 -0
  32. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
  33. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
  34. package/lib/modules/Customer/index.d.ts +7 -0
  35. package/lib/modules/Customer/index.js +12 -0
  36. package/lib/modules/OpenData/index.d.ts +7 -0
  37. package/lib/modules/OpenData/index.js +12 -0
  38. package/lib/modules/Order/index.d.ts +44 -0
  39. package/lib/modules/Order/index.js +150 -3
  40. package/lib/modules/Order/types.d.ts +16 -0
  41. package/lib/modules/Order/utils.js +6 -2
  42. package/lib/modules/Payment/index.d.ts +7 -0
  43. package/lib/modules/Payment/index.js +9 -0
  44. package/lib/modules/ProductList/index.d.ts +7 -0
  45. package/lib/modules/ProductList/index.js +9 -0
  46. package/lib/modules/SalesSummary/index.d.ts +7 -0
  47. package/lib/modules/SalesSummary/index.js +13 -0
  48. package/lib/modules/Schedule/index.d.ts +7 -0
  49. package/lib/modules/Schedule/index.js +12 -0
  50. package/lib/server/index.d.ts +6 -0
  51. package/lib/server/index.js +136 -3
  52. package/lib/server/modules/order/types.d.ts +2 -0
  53. package/lib/server/modules/order/utils/filterBookings.js +17 -2
  54. package/lib/server/utils/small-ticket.js +141 -32
  55. package/lib/solution/BaseSales/index.d.ts +17 -0
  56. package/lib/solution/BaseSales/index.js +48 -10
  57. package/lib/solution/BaseSales/utils/cartPromotion.js +31 -2
  58. package/lib/solution/BookingByStep/index.d.ts +1 -1
  59. package/lib/solution/BookingTicket/index.d.ts +1 -9
  60. package/lib/solution/BookingTicket/index.js +1 -13
  61. package/lib/types/index.d.ts +10 -0
  62. package/package.json +1 -1
@@ -79,6 +79,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
79
79
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
80
80
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
81
81
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
82
+ _defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
82
83
  _defineProperty(_assertThisInitialized(_this), "orderHooks", void 0);
83
84
  _defineProperty(_assertThisInitialized(_this), "otherParams", void 0);
84
85
  // ─── 促销/赠品 ────────────────────────────────────
@@ -258,11 +259,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
258
259
  this.cacheId = otherParams.cacheId;
259
260
  this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
260
261
  this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
261
- this.orderHooks = options.hooks || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
262
+ this.moduleHooksOverride = options.hooks;
263
+ this.orderHooks = this.moduleHooksOverride || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
262
264
  this.otherParams = otherParams;
263
265
  this.registerDiscountModules(options);
264
266
  this.logInfo('OrderModule initialized successfully');
265
- case 19:
267
+ case 20:
266
268
  case "end":
267
269
  return _context.stop();
268
270
  }
@@ -273,6 +275,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
273
275
  }
274
276
  return initialize;
275
277
  }()
278
+ /**
279
+ * 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
280
+ *
281
+ * @example
282
+ * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
283
+ */
284
+ }, {
285
+ key: "updateOtherParams",
286
+ value: function updateOtherParams(params) {
287
+ var _otherParams$rules2, _otherParams$order2, _otherParams$hooks2;
288
+ var otherParams = params || {};
289
+ this.cacheId = otherParams.cacheId;
290
+ this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
291
+ this.rulesHooksOverride = (_otherParams$rules2 = otherParams.rules) === null || _otherParams$rules2 === void 0 ? void 0 : _otherParams$rules2.hooks;
292
+ this.orderHooks = this.moduleHooksOverride || ((_otherParams$order2 = otherParams.order) === null || _otherParams$order2 === void 0 ? void 0 : _otherParams$order2.hooks) || ((_otherParams$hooks2 = otherParams.hooks) === null || _otherParams$hooks2 === void 0 ? void 0 : _otherParams$hooks2.order);
293
+ this.otherParams = otherParams;
294
+ }
295
+
276
296
  /**
277
297
  * 记录信息日志
278
298
  */
@@ -2052,6 +2072,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2052
2072
  var bookingUid = String(bookingMetadata.unique_identification_number || createUuidV4());
2053
2073
  productMetadata.unique_identification_number = productUid;
2054
2074
  bookingMetadata.unique_identification_number = bookingUid;
2075
+ this.syncBookingMetadataHolder(params.booking, bookingMetadata);
2055
2076
  return {
2056
2077
  productUid: productUid,
2057
2078
  bookingUid: bookingUid,
@@ -2070,11 +2091,155 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2070
2091
  })
2071
2092
  };
2072
2093
  }
2094
+
2095
+ /**
2096
+ * booking.holder 是提交真源;metadata.holder 作为详情/回显冗余字段同步保存。
2097
+ *
2098
+ * @example
2099
+ * this.syncBookingMetadataHolder(booking, metadata);
2100
+ */
2101
+ }, {
2102
+ key: "syncBookingMetadataHolder",
2103
+ value: function syncBookingMetadataHolder(booking, metadata) {
2104
+ if ((booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined) {
2105
+ metadata.holder = booking.holder;
2106
+ }
2107
+ }
2108
+
2109
+ /**
2110
+ * 从单条 booking 的 holder / metadata 中收集 holder form_record。
2111
+ *
2112
+ * @example
2113
+ * const ids = this.collectBookingHolderRecords(booking);
2114
+ */
2115
+ }, {
2116
+ key: "collectBookingHolderRecords",
2117
+ value: function collectBookingHolderRecords(booking) {
2118
+ var _holder$form_record, _booking$metadata;
2119
+ var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
2120
+ var source = (_holder$form_record = holder === null || holder === void 0 ? void 0 : holder.form_record) !== null && _holder$form_record !== void 0 ? _holder$form_record : booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id;
2121
+ var records = Array.isArray(source) ? source : [source];
2122
+ return records.filter(function (record) {
2123
+ return record !== undefined && record !== null && record !== '';
2124
+ });
2125
+ }
2126
+
2127
+ /**
2128
+ * 按 form_record 顺序读取 booking holder 的主字段名称。
2129
+ *
2130
+ * @example
2131
+ * const names = this.collectBookingHolderNames(booking);
2132
+ */
2133
+ }, {
2134
+ key: "collectBookingHolderNames",
2135
+ value: function collectBookingHolderNames(booking) {
2136
+ var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
2137
+ var rawName = holder === null || holder === void 0 ? void 0 : holder.name;
2138
+ if (Array.isArray(rawName)) {
2139
+ return rawName.map(function (name) {
2140
+ return String(name || '').trim();
2141
+ });
2142
+ }
2143
+ if (typeof rawName === 'string') {
2144
+ return rawName.split(',').map(function (name) {
2145
+ return name.trim();
2146
+ });
2147
+ }
2148
+ return [];
2149
+ }
2150
+
2151
+ /**
2152
+ * 按老 ticketBooking `formatHolder` 语义汇总订单顶层 holder。
2153
+ *
2154
+ * @example
2155
+ * const holder = this.buildTempOrderHolderFromBookings(tempOrder);
2156
+ */
2157
+ }, {
2158
+ key: "buildTempOrderHolderFromBookings",
2159
+ value: function buildTempOrderHolderFromBookings(tempOrder) {
2160
+ var _baseHolder$customer_, _baseHolder, _ref44, _baseHolder$form_id, _baseHolder2, _tempOrder$holder5, _baseHolder3, _this$otherParams;
2161
+ var holderRecords = [];
2162
+ var holderNames = [];
2163
+ var baseHolder = null;
2164
+ var seen = new Set();
2165
+ var _iterator18 = _createForOfIteratorHelper(tempOrder.bookings || []),
2166
+ _step18;
2167
+ try {
2168
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
2169
+ var booking = _step18.value;
2170
+ var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
2171
+ if (!baseHolder && holder) {
2172
+ baseHolder = holder;
2173
+ }
2174
+ var records = this.collectBookingHolderRecords(booking);
2175
+ var names = this.collectBookingHolderNames(booking);
2176
+ var _iterator19 = _createForOfIteratorHelper(records.entries()),
2177
+ _step19;
2178
+ try {
2179
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
2180
+ var _step19$value = _slicedToArray(_step19.value, 2),
2181
+ index = _step19$value[0],
2182
+ record = _step19$value[1];
2183
+ var key = String(record);
2184
+ if (seen.has(key)) continue;
2185
+ seen.add(key);
2186
+ holderRecords.push(record);
2187
+ if (names[index]) {
2188
+ holderNames.push(names[index]);
2189
+ }
2190
+ }
2191
+ } catch (err) {
2192
+ _iterator19.e(err);
2193
+ } finally {
2194
+ _iterator19.f();
2195
+ }
2196
+ }
2197
+ } catch (err) {
2198
+ _iterator18.e(err);
2199
+ } finally {
2200
+ _iterator18.f();
2201
+ }
2202
+ if (!holderRecords.length) {
2203
+ return null;
2204
+ }
2205
+ var nextHolder = {
2206
+ customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
2207
+ form_id: (_ref44 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder5 = tempOrder.holder) === null || _tempOrder$holder5 === void 0 ? void 0 : _tempOrder$holder5.form_id) !== null && _ref44 !== void 0 ? _ref44 : 0,
2208
+ form_record: holderRecords
2209
+ };
2210
+ if (holderNames.length) {
2211
+ nextHolder.name = holderNames.join(',');
2212
+ }
2213
+ if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.isFranchisee) {
2214
+ nextHolder.is_source_shop = 1;
2215
+ }
2216
+ return nextHolder;
2217
+ }
2218
+
2219
+ /**
2220
+ * 将 booking 级 holder 汇总到 tempOrder 顶层 holder。
2221
+ *
2222
+ * @example
2223
+ * this.syncTempOrderHolderFromBookings(tempOrder);
2224
+ */
2225
+ }, {
2226
+ key: "syncTempOrderHolderFromBookings",
2227
+ value: function syncTempOrderHolderFromBookings(tempOrder) {
2228
+ var bookings = tempOrder.bookings || [];
2229
+ var hasHolderSource = bookings.some(function (booking) {
2230
+ var _booking$metadata2;
2231
+ return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== undefined;
2232
+ });
2233
+ var nextHolder = this.buildTempOrderHolderFromBookings(tempOrder);
2234
+ if (nextHolder || hasHolderSource || bookings.length === 0) {
2235
+ tempOrder.holder = nextHolder;
2236
+ }
2237
+ }
2073
2238
  }, {
2074
2239
  key: "getBookingUniqueIdentificationNumber",
2075
2240
  value: function getBookingUniqueIdentificationNumber(booking) {
2076
- var _booking$metadata;
2077
- var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
2241
+ var _booking$metadata3;
2242
+ var uid = booking === null || booking === void 0 || (_booking$metadata3 = booking.metadata) === null || _booking$metadata3 === void 0 ? void 0 : _booking$metadata3.unique_identification_number;
2078
2243
  if (uid === undefined || uid === null || uid === '') return null;
2079
2244
  return String(uid);
2080
2245
  }
@@ -2114,7 +2279,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2114
2279
  key: "recalculateSummary",
2115
2280
  value: function () {
2116
2281
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
2117
- var _ref44, _salesSummaryResult$e;
2282
+ var _ref45, _salesSummaryResult$e;
2118
2283
  var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2119
2284
  return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2120
2285
  while (1) switch (_context12.prev = _context12.next) {
@@ -2184,7 +2349,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2184
2349
  roundingAmount = paidPaymentSummary.roundingAmount;
2185
2350
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2186
2351
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2187
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref44 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref44 !== void 0 ? _ref44 : 0) : null;
2352
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref45 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref45 !== void 0 ? _ref45 : 0) : null;
2188
2353
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2189
2354
  rounding_amount: roundingAmount.toFixed(2)
2190
2355
  }, expectAmount ? {
@@ -2340,17 +2505,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2340
2505
  }, {
2341
2506
  key: "buildTempOrderCustomer",
2342
2507
  value: function buildTempOrderCustomer(params) {
2343
- var _ref45, _ref46, _ref47, _source$name, _ref48, _ref49, _ref50, _source$customer_name, _source$id, _source$customer_id, _ref51, _source$country_calli, _source$phone, _source$email;
2508
+ var _ref46, _ref47, _ref48, _source$name, _ref49, _ref50, _ref51, _source$customer_name, _source$id, _source$customer_id, _ref52, _source$country_calli, _source$phone, _source$email;
2344
2509
  if (!params.customerId) return null;
2345
2510
  var source = params.source ? cloneDeep(params.source) : {};
2346
- var name = (_ref45 = (_ref46 = (_ref47 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref47 !== void 0 ? _ref47 : source.customerName) !== null && _ref46 !== void 0 ? _ref46 : source.customer_name) !== null && _ref45 !== void 0 ? _ref45 : params.customerName;
2347
- var customerName = (_ref48 = (_ref49 = (_ref50 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref50 !== void 0 ? _ref50 : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
2511
+ var name = (_ref46 = (_ref47 = (_ref48 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref48 !== void 0 ? _ref48 : source.customerName) !== null && _ref47 !== void 0 ? _ref47 : source.customer_name) !== null && _ref46 !== void 0 ? _ref46 : params.customerName;
2512
+ var customerName = (_ref49 = (_ref50 = (_ref51 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref51 !== void 0 ? _ref51 : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.name) !== null && _ref49 !== void 0 ? _ref49 : params.customerName;
2348
2513
  return _objectSpread(_objectSpread({}, source), {}, {
2349
2514
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
2350
2515
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
2351
2516
  name: String(name || ''),
2352
2517
  customer_name: String(customerName || ''),
2353
- country_calling_code: String((_ref51 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref51 !== void 0 ? _ref51 : params.countryCallingCode),
2518
+ country_calling_code: String((_ref52 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref52 !== void 0 ? _ref52 : params.countryCallingCode),
2354
2519
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
2355
2520
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
2356
2521
  });
@@ -2415,14 +2580,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2415
2580
  }, {
2416
2581
  key: "updateTempOrderCustomer",
2417
2582
  value: function updateTempOrderCustomer(customer) {
2418
- var _tempOrder$customer_i2, _ref52, _ref53, _customer$customer_id, _ref54, _ref55, _ref56, _customer$customer_na, _ref57, _customer$country_cal, _tempOrder$customer_i3;
2583
+ var _tempOrder$customer_i2, _ref53, _ref54, _customer$customer_id, _ref55, _ref56, _ref57, _customer$customer_na, _ref58, _customer$country_cal, _tempOrder$customer_i3;
2419
2584
  var tempOrder = this.ensureTempOrder();
2420
2585
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
2421
- var customerId = (_ref52 = (_ref53 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref53 !== void 0 ? _ref53 : customer.id) !== null && _ref52 !== void 0 ? _ref52 : null;
2422
- var customerName = (_ref54 = (_ref55 = (_ref56 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref56 !== void 0 ? _ref56 : customer.display_name) !== null && _ref55 !== void 0 ? _ref55 : customer.name) !== null && _ref54 !== void 0 ? _ref54 : '';
2586
+ var customerId = (_ref53 = (_ref54 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref54 !== void 0 ? _ref54 : customer.id) !== null && _ref53 !== void 0 ? _ref53 : null;
2587
+ var customerName = (_ref55 = (_ref56 = (_ref57 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref57 !== void 0 ? _ref57 : customer.display_name) !== null && _ref56 !== void 0 ? _ref56 : customer.name) !== null && _ref55 !== void 0 ? _ref55 : '';
2423
2588
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
2424
2589
  tempOrder.customer_name = String(customerName || '');
2425
- tempOrder.country_calling_code = String((_ref57 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref57 !== void 0 ? _ref57 : '');
2590
+ tempOrder.country_calling_code = String((_ref58 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref58 !== void 0 ? _ref58 : '');
2426
2591
  tempOrder.phone = String(customer.phone || '');
2427
2592
  tempOrder.email = String(customer.email || '');
2428
2593
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -2746,7 +2911,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2746
2911
  return _shouldMergeProductToOrder.apply(this, arguments);
2747
2912
  }
2748
2913
  return shouldMergeProductToOrder;
2749
- }() // ─── TempOrder: 商品 CRUD ───
2914
+ }()
2915
+ }, {
2916
+ key: "hasOrderProductLineNote",
2917
+ value: function hasOrderProductLineNote(product) {
2918
+ return typeof (product === null || product === void 0 ? void 0 : product.note) === 'string' && product.note.trim().length > 0;
2919
+ }
2920
+
2921
+ // ─── TempOrder: 商品 CRUD ───
2922
+
2750
2923
  /**
2751
2924
  * 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
2752
2925
  *
@@ -2760,21 +2933,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2760
2933
  return _regeneratorRuntime().wrap(function _callee14$(_context16) {
2761
2934
  while (1) switch (_context16.prev = _context16.next) {
2762
2935
  case 0:
2763
- _context16.next = 2;
2936
+ this.syncTempOrderHolderFromBookings(tempOrder);
2937
+ _context16.next = 3;
2764
2938
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
2765
- case 2:
2766
- _context16.next = 4;
2939
+ case 3:
2940
+ _context16.next = 5;
2767
2941
  return this.applyPromotion();
2768
- case 4:
2942
+ case 5:
2769
2943
  this.applyDiscount();
2770
2944
  this.sanitizeTempOrderProducts(tempOrder);
2771
- _context16.next = 8;
2945
+ _context16.next = 9;
2772
2946
  return this.recalculateSummary({
2773
2947
  createIfMissing: true
2774
2948
  });
2775
- case 8:
2776
- this.persistTempOrder();
2777
2949
  case 9:
2950
+ this.persistTempOrder();
2951
+ case 10:
2778
2952
  case "end":
2779
2953
  return _context16.stop();
2780
2954
  }
@@ -2797,7 +2971,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2797
2971
  value: (function () {
2798
2972
  var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, product, booking) {
2799
2973
  var _this16 = this;
2800
- var linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
2974
+ var linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, hasIncomingProductNote, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
2801
2975
  return _regeneratorRuntime().wrap(function _callee15$(_context17) {
2802
2976
  while (1) switch (_context17.prev = _context17.next) {
2803
2977
  case 0:
@@ -2810,9 +2984,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2810
2984
  normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
2811
2985
  normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
2812
2986
  hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
2813
- shouldForceNewLine = !!booking;
2987
+ hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
2988
+ shouldForceNewLine = !!booking || hasIncomingProductNote;
2814
2989
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
2815
2990
  if (_this16.hasGoodPassDiscount(item)) return false;
2991
+ if (_this16.hasOrderProductLineNote(item)) return false;
2816
2992
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
2817
2993
  if (item.product_id !== productToAdd.product_id) return false;
2818
2994
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -2822,10 +2998,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2822
2998
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
2823
2999
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
2824
3000
  if (!matchedProduct) {
2825
- _context17.next = 16;
3001
+ _context17.next = 17;
2826
3002
  break;
2827
3003
  }
2828
- _context17.next = 13;
3004
+ _context17.next = 14;
2829
3005
  return this.shouldMergeProductToOrder({
2830
3006
  incomingProduct: productToAdd,
2831
3007
  normalizedIncoming: normalizedIncoming,
@@ -2836,13 +3012,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2836
3012
  tempOrder: tempOrder,
2837
3013
  booking: booking
2838
3014
  });
2839
- case 13:
3015
+ case 14:
2840
3016
  _context17.t0 = _context17.sent;
2841
- _context17.next = 17;
3017
+ _context17.next = 18;
2842
3018
  break;
2843
- case 16:
2844
- _context17.t0 = false;
2845
3019
  case 17:
3020
+ _context17.t0 = false;
3021
+ case 18:
2846
3022
  shouldMerge = _context17.t0;
2847
3023
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
2848
3024
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
@@ -2894,7 +3070,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2894
3070
  if (linked) {
2895
3071
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
2896
3072
  }
2897
- case 20:
3073
+ case 21:
2898
3074
  case "end":
2899
3075
  return _context17.stop();
2900
3076
  }
@@ -2917,7 +3093,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2917
3093
  key: "addProductToOrder",
2918
3094
  value: (function () {
2919
3095
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
2920
- var tempOrder, _ref58, _productRecord$num, productRecord, splitCount, i, singleLine;
3096
+ var tempOrder, _ref59, _productRecord$num, productRecord, splitCount, i, singleLine;
2921
3097
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
2922
3098
  while (1) switch (_context18.prev = _context18.next) {
2923
3099
  case 0:
@@ -2927,7 +3103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2927
3103
  break;
2928
3104
  }
2929
3105
  productRecord = product;
2930
- splitCount = getSafeProductNum((_ref58 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref58 !== void 0 ? _ref58 : 1);
3106
+ splitCount = getSafeProductNum((_ref59 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref59 !== void 0 ? _ref59 : 1);
2931
3107
  if (!(splitCount > 1)) {
2932
3108
  _context18.next = 18;
2933
3109
  break;
@@ -2993,9 +3169,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2993
3169
  }, {
2994
3170
  key: "getBundleRuntimeIdentity",
2995
3171
  value: function getBundleRuntimeIdentity(bundle) {
2996
- var _ref59, _bundle$bundle_id2, _ref60, _bundle$bundle_group_2, _ref61, _ref62, _bundle$bundle_produc3, _ref63, _bundle$bundle_varian3;
3172
+ var _ref60, _bundle$bundle_id2, _ref61, _bundle$bundle_group_2, _ref62, _ref63, _bundle$bundle_produc3, _ref64, _bundle$bundle_varian3;
2997
3173
  if (!bundle || _typeof(bundle) !== 'object') return '';
2998
- return [(_ref59 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref59 !== void 0 ? _ref59 : '', (_ref60 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref60 !== void 0 ? _ref60 : '', (_ref61 = (_ref62 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref62 !== void 0 ? _ref62 : bundle.product_id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref63 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref63 !== void 0 ? _ref63 : 0].join('|');
3174
+ return [(_ref60 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref60 !== void 0 ? _ref60 : '', (_ref61 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref62 = (_ref63 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref63 !== void 0 ? _ref63 : bundle.product_id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref64 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref64 !== void 0 ? _ref64 : 0].join('|');
2999
3175
  }
3000
3176
  }, {
3001
3177
  key: "preservePersistedBundlePriceFields",
@@ -3027,7 +3203,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3027
3203
  value: function () {
3028
3204
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
3029
3205
  var _targetProduct$metada2, _product_sku, _metadata, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
3030
- var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
3206
+ var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, callerAllowsBookingReprice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
3031
3207
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3032
3208
  while (1) switch (_context19.prev = _context19.next) {
3033
3209
  case 0:
@@ -3090,7 +3266,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3090
3266
  isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
3091
3267
  callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
3092
3268
  callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.product_discount_reason) !== undefined || callerChangesDiscountList;
3093
- if (isPersistedOrderLine && !callerUpdatesManualPrice) {
3269
+ callerAllowsBookingReprice = function () {
3270
+ if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
3271
+ return false;
3272
+ }
3273
+ var hasChangedPrice = function hasChangedPrice(nextValue, currentValue) {
3274
+ if (nextValue === undefined || nextValue === null || nextValue === '') {
3275
+ return false;
3276
+ }
3277
+ return !new Decimal(Number(nextValue) || 0).equals(new Decimal(Number(currentValue) || 0));
3278
+ };
3279
+ return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
3280
+ }();
3281
+ if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
3094
3282
  nextProduct.selling_price = targetProduct.selling_price;
3095
3283
  nextProduct.original_price = targetProduct.original_price;
3096
3284
  nextProduct.payment_price = targetProduct.payment_price;
@@ -3142,20 +3330,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3142
3330
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
3143
3331
  }
3144
3332
  tempOrder.products[productIndex] = normalizedProduct;
3333
+ this.syncTempOrderHolderFromBookings(tempOrder);
3145
3334
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
3146
- _context19.next = 30;
3335
+ _context19.next = 32;
3147
3336
  return this.applyPromotion();
3148
- case 30:
3337
+ case 32:
3149
3338
  this.applyDiscount();
3150
3339
  this.sanitizeTempOrderProducts(tempOrder);
3151
- _context19.next = 34;
3340
+ _context19.next = 36;
3152
3341
  return this.recalculateSummary({
3153
3342
  createIfMissing: true
3154
3343
  });
3155
- case 34:
3344
+ case 36:
3156
3345
  this.persistTempOrder();
3157
3346
  return _context19.abrupt("return", tempOrder.products);
3158
- case 36:
3347
+ case 38:
3159
3348
  case "end":
3160
3349
  return _context19.stop();
3161
3350
  }
@@ -3256,9 +3445,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3256
3445
  unique_identification_number: bookingUid
3257
3446
  })
3258
3447
  });
3448
+ this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
3259
3449
  nextBooking.is_all = normalizeBookingIsAll(nextBooking);
3260
3450
  nextBooking.sub_type = normalizeBookingSubType(nextBooking);
3261
3451
  tempOrder.bookings[bookingIndex] = nextBooking;
3452
+ this.syncTempOrderHolderFromBookings(tempOrder);
3262
3453
  this.persistTempOrder();
3263
3454
  return tempOrder.bookings;
3264
3455
  }
@@ -3277,18 +3468,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3277
3468
  return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3278
3469
  while (1) switch (_context21.prev = _context21.next) {
3279
3470
  case 0:
3280
- _context21.next = 2;
3471
+ this.syncTempOrderHolderFromBookings(tempOrder);
3472
+ _context21.next = 3;
3281
3473
  return this.applyPromotion();
3282
- case 2:
3474
+ case 3:
3283
3475
  this.applyDiscount();
3284
3476
  this.sanitizeTempOrderProducts(tempOrder);
3285
- _context21.next = 6;
3477
+ _context21.next = 7;
3286
3478
  return this.recalculateSummary({
3287
3479
  createIfMissing: true
3288
3480
  });
3289
- case 6:
3290
- this.persistTempOrder();
3291
3481
  case 7:
3482
+ this.persistTempOrder();
3483
+ case 8:
3292
3484
  case "end":
3293
3485
  return _context21.stop();
3294
3486
  }
@@ -3382,24 +3574,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3382
3574
  tempOrder = this.ensureTempOrder();
3383
3575
  tempOrder.products = [];
3384
3576
  tempOrder.bookings = [];
3577
+ this.syncTempOrderHolderFromBookings(tempOrder);
3385
3578
  if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
3386
3579
  tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
3387
3580
  productsByUid: {}
3388
3581
  });
3389
3582
  }
3390
- _context24.next = 6;
3583
+ _context24.next = 7;
3391
3584
  return this.applyPromotion();
3392
- case 6:
3585
+ case 7:
3393
3586
  this.applyDiscount();
3394
3587
  this.sanitizeTempOrderProducts(tempOrder);
3395
- _context24.next = 10;
3588
+ _context24.next = 11;
3396
3589
  return this.recalculateSummary({
3397
3590
  createIfMissing: true
3398
3591
  });
3399
- case 10:
3592
+ case 11:
3400
3593
  this.persistTempOrder();
3401
3594
  return _context24.abrupt("return", tempOrder);
3402
- case 12:
3595
+ case 13:
3403
3596
  case "end":
3404
3597
  return _context24.stop();
3405
3598
  }
@@ -3414,23 +3607,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3414
3607
  }, {
3415
3608
  key: "buildCurrentSubmitPayloadForLocalPrint",
3416
3609
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
3417
- var _params$cacheId, _this$otherParams, _ref64, _params$businessCode, _this$otherParams2, _this$otherParams3;
3610
+ var _params$cacheId, _this$otherParams2, _ref65, _params$businessCode, _this$otherParams3, _this$otherParams4;
3418
3611
  var tempOrder = this.ensureTempOrder();
3419
3612
  this.persistTempOrder();
3420
3613
  var payload = buildSubmitPayload({
3421
3614
  tempOrder: tempOrder,
3422
3615
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
3423
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform),
3424
- businessCode: (_ref64 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _ref64 !== void 0 ? _ref64 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code,
3616
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
3617
+ businessCode: (_ref65 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref65 !== void 0 ? _ref65 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
3425
3618
  channel: params === null || params === void 0 ? void 0 : params.channel,
3426
3619
  type: params === null || params === void 0 ? void 0 : params.type,
3427
3620
  summary: this.store.summary || createEmptySummary(),
3428
3621
  enhance: function enhance(nextPayload) {
3429
- var _ref65, _tempOrder$order_numb, _ref66, _tempOrder$shop_order, _ref67, _tempOrder$shop_full_;
3622
+ var _ref66, _tempOrder$order_numb, _ref67, _tempOrder$shop_order, _ref68, _tempOrder$shop_full_;
3430
3623
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
3431
- order_number: (_ref65 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref65 !== void 0 ? _ref65 : null,
3432
- shop_order_number: (_ref66 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref66 !== void 0 ? _ref66 : null,
3433
- shop_full_order_number: (_ref67 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref67 !== void 0 ? _ref67 : null,
3624
+ order_number: (_ref66 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref66 !== void 0 ? _ref66 : null,
3625
+ shop_order_number: (_ref67 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref67 !== void 0 ? _ref67 : null,
3626
+ shop_full_order_number: (_ref68 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
3434
3627
  small_ticket_data_flag: 1
3435
3628
  });
3436
3629
  }
@@ -3487,7 +3680,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3487
3680
  key: "submitTempOrder",
3488
3681
  value: (function () {
3489
3682
  var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
3490
- var _params$cacheId2, _this$otherParams4, _ref68, _params$businessCode2, _this$otherParams5, _this$otherParams6;
3683
+ var _params$cacheId2, _this$otherParams5, _ref69, _params$businessCode2, _this$otherParams6, _this$otherParams7;
3491
3684
  var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
3492
3685
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
3493
3686
  while (1) switch (_context26.prev = _context26.next) {
@@ -3532,8 +3725,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3532
3725
  payload = buildSubmitPayload({
3533
3726
  tempOrder: tempOrder,
3534
3727
  cacheId: effectiveCacheId,
3535
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform),
3536
- businessCode: (_ref68 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.business_code,
3728
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
3729
+ businessCode: (_ref69 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
3537
3730
  channel: params === null || params === void 0 ? void 0 : params.channel,
3538
3731
  type: params === null || params === void 0 ? void 0 : params.type,
3539
3732
  summary: latestSummary,
@@ -4346,19 +4539,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4346
4539
  };
4347
4540
  var tempOrderExtend = nextTempOrder._extend;
4348
4541
  var productsByUid = tempOrderExtend.productsByUid || {};
4349
- var _iterator18 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
4350
- _step18;
4542
+ var _iterator20 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
4543
+ _step20;
4351
4544
  try {
4352
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
4353
- var _product$metadata7, _ref69, _ref70, _existed$origin, _rawProduct$metadata;
4354
- var _step18$value = _slicedToArray(_step18.value, 2),
4355
- index = _step18$value[0],
4356
- product = _step18$value[1];
4545
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
4546
+ var _product$metadata7, _ref70, _ref71, _existed$origin, _rawProduct$metadata;
4547
+ var _step20$value = _slicedToArray(_step20.value, 2),
4548
+ index = _step20$value[0],
4549
+ product = _step20$value[1];
4357
4550
  var uid = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number;
4358
4551
  if (!uid) continue;
4359
4552
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
4360
4553
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
4361
- var origin = (_ref69 = (_ref70 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref70 !== void 0 ? _ref70 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref69 !== void 0 ? _ref69 : rawProduct;
4554
+ var origin = (_ref70 = (_ref71 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref71 !== void 0 ? _ref71 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref70 !== void 0 ? _ref70 : rawProduct;
4362
4555
  var originSnapshot = cloneDeep(origin);
4363
4556
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
4364
4557
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -4374,9 +4567,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4374
4567
  });
4375
4568
  }
4376
4569
  } catch (err) {
4377
- _iterator18.e(err);
4570
+ _iterator20.e(err);
4378
4571
  } finally {
4379
- _iterator18.f();
4572
+ _iterator20.f();
4380
4573
  }
4381
4574
  tempOrderExtend.productsByUid = productsByUid;
4382
4575
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
@@ -4407,18 +4600,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4407
4600
  var segments = [];
4408
4601
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
4409
4602
  if (Array.isArray(sku.variant)) {
4410
- var _iterator19 = _createForOfIteratorHelper(sku.variant),
4411
- _step19;
4603
+ var _iterator21 = _createForOfIteratorHelper(sku.variant),
4604
+ _step21;
4412
4605
  try {
4413
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
4414
- var variant = _step19.value;
4606
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
4607
+ var variant = _step21.value;
4415
4608
  var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
4416
4609
  if (segment) segments.push(segment);
4417
4610
  }
4418
4611
  } catch (err) {
4419
- _iterator19.e(err);
4612
+ _iterator21.e(err);
4420
4613
  } finally {
4421
- _iterator19.f();
4614
+ _iterator21.f();
4422
4615
  }
4423
4616
  }
4424
4617
  return segments.join(', ');
@@ -4426,10 +4619,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4426
4619
  }, {
4427
4620
  key: "normalizeHydratedProductOptionItem",
4428
4621
  value: function normalizeHydratedProductOptionItem(optionItem) {
4429
- var _ref71, _optionItem$num, _ref72, _optionItem$add_price;
4430
- var rawNum = (_ref71 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref71 !== void 0 ? _ref71 : 1;
4622
+ var _ref72, _optionItem$num, _ref73, _optionItem$add_price;
4623
+ var rawNum = (_ref72 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref72 !== void 0 ? _ref72 : 1;
4431
4624
  var parsedNum = Number(rawNum);
4432
- var rawPrice = (_ref72 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref72 !== void 0 ? _ref72 : 0;
4625
+ var rawPrice = (_ref73 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref73 !== void 0 ? _ref73 : 0;
4433
4626
  var parsedPrice = Number(rawPrice);
4434
4627
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
4435
4628
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -4520,67 +4713,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4520
4713
  var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
4521
4714
  savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
4522
4715
  };
4523
- var _iterator20 = _createForOfIteratorHelper(productList),
4524
- _step20;
4716
+ var _iterator22 = _createForOfIteratorHelper(productList),
4717
+ _step22;
4525
4718
  try {
4526
- for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
4527
- var product = _step20.value;
4719
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
4720
+ var product = _step22.value;
4528
4721
  var qty = product.num || 1;
4529
- var _iterator22 = _createForOfIteratorHelper(product.discount_list || []),
4530
- _step22;
4722
+ var _iterator24 = _createForOfIteratorHelper(product.discount_list || []),
4723
+ _step24;
4531
4724
  try {
4532
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
4533
- var pd = _step22.value;
4725
+ for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
4726
+ var pd = _step24.value;
4534
4727
  addDiscountAmount(pd, qty);
4535
4728
  }
4536
4729
  } catch (err) {
4537
- _iterator22.e(err);
4730
+ _iterator24.e(err);
4538
4731
  } finally {
4539
- _iterator22.f();
4732
+ _iterator24.f();
4540
4733
  }
4541
- var _iterator23 = _createForOfIteratorHelper(product.product_bundle || []),
4542
- _step23;
4734
+ var _iterator25 = _createForOfIteratorHelper(product.product_bundle || []),
4735
+ _step25;
4543
4736
  try {
4544
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
4545
- var _ref73, _bundle$num3;
4546
- var bundle = _step23.value;
4547
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref73 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref73 !== void 0 ? _ref73 : 1) || 1).toNumber();
4548
- var _iterator24 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
4549
- _step24;
4737
+ for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
4738
+ var _ref74, _bundle$num3;
4739
+ var bundle = _step25.value;
4740
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref74 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref74 !== void 0 ? _ref74 : 1) || 1).toNumber();
4741
+ var _iterator26 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
4742
+ _step26;
4550
4743
  try {
4551
- for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
4552
- var _pd = _step24.value;
4744
+ for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
4745
+ var _pd = _step26.value;
4553
4746
  addDiscountAmount(_pd, bundleQty);
4554
4747
  }
4555
4748
  } catch (err) {
4556
- _iterator24.e(err);
4749
+ _iterator26.e(err);
4557
4750
  } finally {
4558
- _iterator24.f();
4751
+ _iterator26.f();
4559
4752
  }
4560
4753
  }
4561
4754
  } catch (err) {
4562
- _iterator23.e(err);
4755
+ _iterator25.e(err);
4563
4756
  } finally {
4564
- _iterator23.f();
4757
+ _iterator25.f();
4565
4758
  }
4566
4759
  }
4567
4760
  } catch (err) {
4568
- _iterator20.e(err);
4761
+ _iterator22.e(err);
4569
4762
  } finally {
4570
- _iterator20.f();
4763
+ _iterator22.f();
4571
4764
  }
4572
- var _iterator21 = _createForOfIteratorHelper(discountList),
4573
- _step21;
4765
+ var _iterator23 = _createForOfIteratorHelper(discountList),
4766
+ _step23;
4574
4767
  try {
4575
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
4576
- var d = _step21.value;
4768
+ for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
4769
+ var d = _step23.value;
4577
4770
  var key = d.id;
4578
4771
  d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
4579
4772
  }
4580
4773
  } catch (err) {
4581
- _iterator21.e(err);
4774
+ _iterator23.e(err);
4582
4775
  } finally {
4583
- _iterator21.f();
4776
+ _iterator23.f();
4584
4777
  }
4585
4778
  }
4586
4779
  }]);