@pisell/pisellos 2.2.184 → 2.2.186

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.
@@ -2105,6 +2105,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2105
2105
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
2106
2106
  while (1) switch (_context18.prev = _context18.next) {
2107
2107
  case 0:
2108
+ debugger;
2108
2109
  tempOrder = this.ensureTempOrder();
2109
2110
  linked = booking ? this.createLinkedProductAndBooking({
2110
2111
  product: product,
@@ -2126,10 +2127,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2126
2127
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
2127
2128
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
2128
2129
  if (!matchedProduct) {
2129
- _context18.next = 17;
2130
+ _context18.next = 18;
2130
2131
  break;
2131
2132
  }
2132
- _context18.next = 14;
2133
+ _context18.next = 15;
2133
2134
  return this.shouldMergeProductToOrder({
2134
2135
  incomingProduct: productToAdd,
2135
2136
  normalizedIncoming: normalizedIncoming,
@@ -2140,13 +2141,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2140
2141
  tempOrder: tempOrder,
2141
2142
  booking: booking
2142
2143
  });
2143
- case 14:
2144
+ case 15:
2144
2145
  _context18.t0 = _context18.sent;
2145
- _context18.next = 18;
2146
+ _context18.next = 19;
2146
2147
  break;
2147
- case 17:
2148
- _context18.t0 = false;
2149
2148
  case 18:
2149
+ _context18.t0 = false;
2150
+ case 19:
2150
2151
  shouldMerge = _context18.t0;
2151
2152
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
2152
2153
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
@@ -2179,18 +2180,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2179
2180
  if (linked) {
2180
2181
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
2181
2182
  }
2182
- _context18.next = 23;
2183
+ _context18.next = 24;
2183
2184
  return this.applyPromotion();
2184
- case 23:
2185
+ case 24:
2185
2186
  this.applyDiscount();
2186
- _context18.next = 26;
2187
+ _context18.next = 27;
2187
2188
  return this.recalculateSummary({
2188
2189
  createIfMissing: true
2189
2190
  });
2190
- case 26:
2191
+ case 27:
2191
2192
  this.persistTempOrder();
2192
2193
  return _context18.abrupt("return", tempOrder.products);
2193
- case 28:
2194
+ case 29:
2194
2195
  case "end":
2195
2196
  return _context18.stop();
2196
2197
  }
@@ -2224,8 +2225,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2224
2225
  key: "updateOrderProduct",
2225
2226
  value: function () {
2226
2227
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
2227
- var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
2228
- var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, _normalizedProduct$me, _targetProduct$metada3, productUid, linked;
2228
+ var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _nextProduct$metadata, _targetProduct$metada3, _tempOrder$products$p;
2229
+ var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada4, productUid, linked;
2229
2230
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
2230
2231
  while (1) switch (_context19.prev = _context19.next) {
2231
2232
  case 0:
@@ -2292,8 +2293,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2292
2293
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
2293
2294
  normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
2294
2295
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
2296
+ preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.booking_uid);
2297
+ if (!booking && preservedBookingUid) {
2298
+ normalizedProduct.booking_uid = preservedBookingUid;
2299
+ normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
2300
+ booking_uid: preservedBookingUid
2301
+ });
2302
+ }
2295
2303
  if (booking) {
2296
- productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.unique_identification_number) || unique_identification_number || createUuidV4());
2304
+ productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number || createUuidV4());
2297
2305
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
2298
2306
  unique_identification_number: productUid
2299
2307
  });
@@ -2315,18 +2323,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2315
2323
  }
2316
2324
  tempOrder.products[productIndex] = normalizedProduct;
2317
2325
  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);
2318
- _context19.next = 25;
2326
+ _context19.next = 27;
2319
2327
  return this.applyPromotion();
2320
- case 25:
2328
+ case 27:
2321
2329
  this.applyDiscount();
2322
- _context19.next = 28;
2330
+ _context19.next = 30;
2323
2331
  return this.recalculateSummary({
2324
2332
  createIfMissing: true
2325
2333
  });
2326
- case 28:
2334
+ case 30:
2327
2335
  this.persistTempOrder();
2328
2336
  return _context19.abrupt("return", tempOrder.products);
2329
- case 30:
2337
+ case 32:
2330
2338
  case "end":
2331
2339
  return _context19.stop();
2332
2340
  }
@@ -2341,7 +2349,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2341
2349
  key: "updateOrderProductQuantity",
2342
2350
  value: function () {
2343
2351
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
2344
- var _targetProduct$metada4;
2352
+ var _targetProduct$metada5;
2345
2353
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
2346
2354
  return _regeneratorRuntime().wrap(function _callee18$(_context20) {
2347
2355
  while (1) switch (_context20.prev = _context20.next) {
@@ -2382,7 +2390,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2382
2390
  normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
2383
2391
  num: getSafeProductNum(num),
2384
2392
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
2385
- unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
2393
+ unique_identification_number: ((_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.unique_identification_number) || unique_identification_number
2386
2394
  })
2387
2395
  }));
2388
2396
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
@@ -2556,11 +2564,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2556
2564
  channel: params === null || params === void 0 ? void 0 : params.channel,
2557
2565
  type: params === null || params === void 0 ? void 0 : params.type,
2558
2566
  enhance: enhancePayload
2559
- });
2560
- _context23.next = 10;
2567
+ }); // TODO: 前端生成的时间现在是有问题的,后面要统一优化
2568
+ payload.created_at = undefined;
2569
+ _context23.next = 11;
2561
2570
  return this.saveDraft();
2562
- case 10:
2563
- _context23.prev = 10;
2571
+ case 11:
2572
+ _context23.prev = 11;
2564
2573
  this.logInfo('submitTempOrder calling sales checkout', {
2565
2574
  orderId: payload.order_id,
2566
2575
  externalSaleNumber: payload.external_sale_number,
@@ -2569,26 +2578,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2569
2578
  paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
2570
2579
  smallTicketDataFlag: payload.small_ticket_data_flag
2571
2580
  });
2572
- _context23.next = 14;
2581
+ _context23.next = 15;
2573
2582
  return this.submitSalesOrder({
2574
2583
  query: payload
2575
2584
  });
2576
- case 14:
2585
+ case 15:
2577
2586
  result = _context23.sent;
2578
- _context23.next = 27;
2587
+ _context23.next = 28;
2579
2588
  break;
2580
- case 17:
2581
- _context23.prev = 17;
2582
- _context23.t0 = _context23["catch"](10);
2589
+ case 18:
2590
+ _context23.prev = 18;
2591
+ _context23.t0 = _context23["catch"](11);
2583
2592
  backendErrorResponse = this.extractSubmitErrorResponse(_context23.t0);
2584
2593
  if (!backendErrorResponse) {
2585
- _context23.next = 24;
2594
+ _context23.next = 25;
2586
2595
  break;
2587
2596
  }
2588
2597
  this.store.syncState = 'failed';
2589
2598
  this.logSubmitBackendRejected(backendErrorResponse, payload);
2590
2599
  return _context23.abrupt("return", backendErrorResponse);
2591
- case 24:
2600
+ case 25:
2592
2601
  this.store.syncState = 'failed';
2593
2602
  this.logError('submitTempOrder failed', {
2594
2603
  error: _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0),
@@ -2598,31 +2607,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2598
2607
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
2599
2608
  });
2600
2609
  throw _context23.t0;
2601
- case 27:
2610
+ case 28:
2602
2611
  if (!this.isSubmitResponseRejected(result)) {
2603
- _context23.next = 31;
2612
+ _context23.next = 32;
2604
2613
  break;
2605
2614
  }
2606
2615
  this.store.syncState = 'failed';
2607
2616
  this.logSubmitBackendRejected(result, payload);
2608
2617
  return _context23.abrupt("return", result);
2609
- case 31:
2618
+ case 32:
2610
2619
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
2611
2620
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
2612
- _context23.next = 37;
2621
+ _context23.next = 38;
2613
2622
  break;
2614
2623
  }
2615
2624
  tempOrder.order_id = submittedOrderId;
2616
2625
  resultRecord = result;
2617
- _context23.next = 37;
2626
+ _context23.next = 38;
2618
2627
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
2619
- case 37:
2620
- return _context23.abrupt("return", result);
2621
2628
  case 38:
2629
+ return _context23.abrupt("return", result);
2630
+ case 39:
2622
2631
  case "end":
2623
2632
  return _context23.stop();
2624
2633
  }
2625
- }, _callee21, this, [[10, 17]]);
2634
+ }, _callee21, this, [[11, 18]]);
2626
2635
  }));
2627
2636
  function submitTempOrder(_x21) {
2628
2637
  return _submitTempOrder.apply(this, arguments);
@@ -3370,6 +3379,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3370
3379
  row.product_option_item = this.resolveHydratedProductOptions(row);
3371
3380
  if (!Array.isArray(row.product_bundle)) row.product_bundle = [];
3372
3381
  if (!row.metadata || _typeof(row.metadata) !== 'object') row.metadata = {};
3382
+ if (row.booking_uid && !row.metadata.booking_uid) {
3383
+ row.metadata.booking_uid = row.booking_uid;
3384
+ }
3373
3385
  var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
3374
3386
  if (!existingIdentity) {
3375
3387
  row.metadata.unique_identification_number = createUuidV4();
@@ -267,8 +267,9 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
267
267
  payment_price: string;
268
268
  product_sku: Record<string, any>;
269
269
  }
270
- export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list'> {
270
+ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
271
271
  platform: string;
272
+ created_at?: string | undefined;
272
273
  request_unique_idempotency_token?: string;
273
274
  form_record_ids?: Array<{
274
275
  form_id: number | string;
@@ -393,7 +394,7 @@ export interface SubmitSalesOrderParams {
393
394
  delivery_type?: string;
394
395
  table_number?: Record<string, any>;
395
396
  schedule_date: string;
396
- created_at: string;
397
+ created_at?: string | undefined;
397
398
  products: OrderSubmitProduct[];
398
399
  bookings: OrderSubmitBooking[];
399
400
  payments: any[];
@@ -825,7 +825,7 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
825
825
  metadata[key] = item[key];
826
826
  }
827
827
  }
828
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
828
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
829
829
  amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
830
830
  code: String(item.code || ''),
831
831
  custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0),
@@ -853,8 +853,6 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
853
853
  service_charge: item.service_charge
854
854
  } : {}), item.order_payment_type !== undefined ? {
855
855
  order_payment_type: item.order_payment_type
856
- } : {}), item.created_at !== undefined ? {
857
- created_at: item.created_at
858
856
  } : {}), item.updated_at !== undefined ? {
859
857
  updated_at: item.updated_at
860
858
  } : {});
@@ -992,7 +992,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
992
992
  // 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
993
993
  // 🔥 使用扁平化后的列表进行处理
994
994
  sortedFlattenedList.forEach(function (flatItem, index) {
995
- var _product10, _product$discount_lis2, _product11;
995
+ var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product11;
996
996
  // 获取商品数据
997
997
  var product, originProduct;
998
998
  if (flatItem.type === 'main') {
@@ -1016,11 +1016,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1016
1016
  };
1017
1017
  originProduct = flatItem.originProduct;
1018
1018
  }
1019
+ var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
1020
+ var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
1021
+ var _discount$id, _discount$discount4;
1022
+ var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
1023
+ var discountType = discount.tag || discount.type;
1024
+ return Boolean(discountIdentity && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType));
1025
+ }));
1019
1026
 
1020
- // 已有优惠的商品跳过
1021
- if ((_product10 = product) !== null && _product10 !== void 0 && _product10.booking_id && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.length && (_product11 = product) !== null && _product11 !== void 0 && (_product11 = _product11.discount_list) !== null && _product11 !== void 0 && _product11.every(function (discount) {
1022
- return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
1023
- })) {
1027
+ // 已持久化且已有钱包券/折扣卡的商品行跳过,保留后端历史折扣结果。
1028
+ if (isPersistedProduct && hasExistingWalletDiscount) {
1024
1029
  if (flatItem.type === 'main') {
1025
1030
  processedProductsMap.set(product._id, [originProduct]);
1026
1031
  } else {
@@ -1115,12 +1120,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1115
1120
  // 如果是手动折扣,则不适用优惠券
1116
1121
  var isManualDiscount = false;
1117
1122
  if (flatItem.type === 'main') {
1118
- var _product$discount_lis5, _product12, _product12$every;
1123
+ var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
1119
1124
  // 主商品:判断自身是否手动折扣
1120
- isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
1125
+ isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
1126
+ return item.type === 'product';
1127
+ })) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
1121
1128
  var _ref11;
1122
1129
  return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
1123
- }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
1130
+ }) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
1124
1131
  return item.type === 'product';
1125
1132
  })));
1126
1133
  if (product.inPromotion) {
@@ -1130,11 +1137,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1130
1137
  // bundle子商品:判断父主商品是否手动折扣
1131
1138
  var parentProduct = flatItem.parentProduct;
1132
1139
  if (parentProduct) {
1133
- var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
1134
- isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
1140
+ var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3, _parentProduct$discou4;
1141
+ isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
1142
+ return item.type === 'product';
1143
+ })) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
1135
1144
  var _ref12;
1136
1145
  return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1137
- }) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
1146
+ }) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
1138
1147
  return item.type === 'product';
1139
1148
  })));
1140
1149
  }
@@ -1142,9 +1151,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1142
1151
 
1143
1152
  // 勾选时覆盖手动折扣
1144
1153
  if (options !== null && options !== void 0 && options.discountId) {
1145
- var _product$discount_lis6;
1154
+ var _product$discount_lis7;
1146
1155
  // 主商品:检查自己的 discount_list
1147
- if (flatItem.type === 'main' && (_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.some(function (item) {
1156
+ if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
1148
1157
  var _item$discount;
1149
1158
  return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
1150
1159
  })) {
@@ -1152,8 +1161,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1152
1161
  }
1153
1162
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
1154
1163
  if (flatItem.type === 'bundle') {
1155
- var _product$discount_lis7, _flatItem$parentProdu7;
1156
- if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
1164
+ var _product$discount_lis8, _flatItem$parentProdu7;
1165
+ if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
1157
1166
  var _item$discount2;
1158
1167
  return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
1159
1168
  }) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
@@ -1165,9 +1174,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1165
1174
  }
1166
1175
  }
1167
1176
  if (options !== null && options !== void 0 && options.selectedList) {
1168
- var _product$discount_lis8;
1177
+ var _product$discount_lis9;
1169
1178
  // 主商品:检查自己的 discount_list
1170
- if (flatItem.type === 'main' && (_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
1179
+ if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
1171
1180
  var _options$selectedList;
1172
1181
  return options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.some(function (n) {
1173
1182
  var _item$discount4;
@@ -1178,8 +1187,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1178
1187
  }
1179
1188
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
1180
1189
  if (flatItem.type === 'bundle') {
1181
- var _product$discount_lis9, _flatItem$parentProdu8;
1182
- if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
1190
+ var _product$discount_lis10, _flatItem$parentProdu8;
1191
+ if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
1183
1192
  var _options$selectedList2;
1184
1193
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
1185
1194
  var _item$discount5;
@@ -1301,7 +1310,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1301
1310
  }));
1302
1311
  }
1303
1312
  for (var i = 0; i < splitCount; i++) {
1304
- var _originProduct, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1313
+ var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1305
1314
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1306
1315
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1307
1316
  // 标记优惠券为已使用
@@ -1322,7 +1331,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1322
1331
  productOriginTotal = product.origin_total;
1323
1332
  }
1324
1333
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
1325
- if (Number(((_originProduct = originProduct) === null || _originProduct === void 0 || (_originProduct = _originProduct._productInit) === null || _originProduct === void 0 ? void 0 : _originProduct.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
1334
+ if (Number(((_originProduct4 = originProduct) === null || _originProduct4 === void 0 || (_originProduct4 = _originProduct4._productInit) === null || _originProduct4 === void 0 ? void 0 : _originProduct4.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
1326
1335
  productOriginTotal = product.total;
1327
1336
  }
1328
1337
 
@@ -33,7 +33,7 @@ function normalizeOptionItems(optionItems) {
33
33
  if (!Array.isArray(optionItems)) return [];
34
34
  return optionItems.map(function (optionItem) {
35
35
  var _ref, _optionItem$price, _optionItem$num;
36
- var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id);
36
+ var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
37
37
  var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
38
38
  return {
39
39
  option_group_item_id: optionGroupItemId,
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -609,10 +609,14 @@ export function normalizeOrderProduct(product) {
609
609
  metadata: metadata,
610
610
  lineOriginalPrice: product.original_price
611
611
  }, composedOriginalPrice);
612
+ var hasManualProductDiscount = (product.discount_list || []).some(function (item) {
613
+ return (item === null || item === void 0 ? void 0 : item.type) === 'product';
614
+ });
615
+ var manualOriginalPrice = hasManualProductDiscount && product.original_price != null ? String(product.original_price) : finalOriginalPrice;
612
616
  var discountList = ensureManualProductDiscountList({
613
617
  discountList: product.discount_list,
614
618
  metadata: metadata,
615
- originalPrice: finalOriginalPrice,
619
+ originalPrice: manualOriginalPrice,
616
620
  sellingPrice: composedSellingPrice,
617
621
  quantity: getSafeProductNum(product.num)
618
622
  });
@@ -623,7 +627,7 @@ export function normalizeOrderProduct(product) {
623
627
  product_variant_id: product.product_variant_id,
624
628
  product_option_item: normalizedOptions,
625
629
  selling_price: composedSellingPrice,
626
- original_price: finalOriginalPrice,
630
+ original_price: manualOriginalPrice,
627
631
  tax_fee: product.tax_fee || '0.00',
628
632
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
629
633
  discount_list: discountList,
@@ -1436,6 +1436,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1436
1436
  // ─── TempOrder: 商品 CRUD ───
1437
1437
  async addProductToOrder(product, booking) {
1438
1438
  var _a;
1439
+ debugger;
1439
1440
  const tempOrder = this.ensureTempOrder();
1440
1441
  const linked = booking ? this.createLinkedProductAndBooking({ product, booking }) : null;
1441
1442
  const productToAdd = (linked == null ? void 0 : linked.product) || product;
@@ -1559,7 +1560,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1559
1560
  );
1560
1561
  }
1561
1562
  async updateOrderProduct(params) {
1562
- var _a, _b, _c, _d, _e, _f, _g;
1563
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1563
1564
  const {
1564
1565
  product_id,
1565
1566
  product_variant_id,
@@ -1634,9 +1635,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1634
1635
  normalizedProduct.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
1635
1636
  normalizedProduct.discount_list
1636
1637
  );
1638
+ const preservedBookingUid = nextProduct.booking_uid || ((_e = nextProduct.metadata) == null ? void 0 : _e.booking_uid) || targetProduct.booking_uid || ((_f = targetProduct.metadata) == null ? void 0 : _f.booking_uid);
1639
+ if (!booking && preservedBookingUid) {
1640
+ normalizedProduct.booking_uid = preservedBookingUid;
1641
+ normalizedProduct.metadata = {
1642
+ ...normalizedProduct.metadata || {},
1643
+ booking_uid: preservedBookingUid
1644
+ };
1645
+ }
1637
1646
  if (booking) {
1638
1647
  const productUid = String(
1639
- ((_e = normalizedProduct.metadata) == null ? void 0 : _e.unique_identification_number) || ((_f = targetProduct.metadata) == null ? void 0 : _f.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1648
+ ((_g = normalizedProduct.metadata) == null ? void 0 : _g.unique_identification_number) || ((_h = targetProduct.metadata) == null ? void 0 : _h.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1640
1649
  );
1641
1650
  normalizedProduct.metadata = {
1642
1651
  ...normalizedProduct.metadata || {},
@@ -1666,7 +1675,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1666
1675
  tempOrder,
1667
1676
  updates,
1668
1677
  tempOrder.products[productIndex],
1669
- (_g = tempOrder.products[productIndex].metadata) == null ? void 0 : _g.unique_identification_number
1678
+ (_i = tempOrder.products[productIndex].metadata) == null ? void 0 : _i.unique_identification_number
1670
1679
  );
1671
1680
  await this.applyPromotion();
1672
1681
  this.applyDiscount();
@@ -1840,6 +1849,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1840
1849
  type: params == null ? void 0 : params.type,
1841
1850
  enhance: enhancePayload
1842
1851
  });
1852
+ payload.created_at = void 0;
1843
1853
  await this.saveDraft();
1844
1854
  let result;
1845
1855
  try {
@@ -2365,6 +2375,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2365
2375
  row.product_bundle = [];
2366
2376
  if (!row.metadata || typeof row.metadata !== "object")
2367
2377
  row.metadata = {};
2378
+ if (row.booking_uid && !row.metadata.booking_uid) {
2379
+ row.metadata.booking_uid = row.booking_uid;
2380
+ }
2368
2381
  const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
2369
2382
  if (!existingIdentity) {
2370
2383
  row.metadata.unique_identification_number = (0, import_utils.createUuidV4)();
@@ -267,8 +267,9 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
267
267
  payment_price: string;
268
268
  product_sku: Record<string, any>;
269
269
  }
270
- export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list'> {
270
+ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
271
271
  platform: string;
272
+ created_at?: string | undefined;
272
273
  request_unique_idempotency_token?: string;
273
274
  form_record_ids?: Array<{
274
275
  form_id: number | string;
@@ -393,7 +394,7 @@ export interface SubmitSalesOrderParams {
393
394
  delivery_type?: string;
394
395
  table_number?: Record<string, any>;
395
396
  schedule_date: string;
396
- created_at: string;
397
+ created_at?: string | undefined;
397
398
  products: OrderSubmitProduct[];
398
399
  bookings: OrderSubmitBooking[];
399
400
  payments: any[];
@@ -769,7 +769,6 @@ function mapPaymentItemToOrderPayment(paymentItem) {
769
769
  ...item.rounding_amount !== void 0 ? { rounding_amount: String(item.rounding_amount) } : {},
770
770
  ...item.service_charge !== void 0 ? { service_charge: item.service_charge } : {},
771
771
  ...item.order_payment_type !== void 0 ? { order_payment_type: item.order_payment_type } : {},
772
- ...item.created_at !== void 0 ? { created_at: item.created_at } : {},
773
772
  ...item.updated_at !== void 0 ? { updated_at: item.updated_at } : {}
774
773
  };
775
774
  }
@@ -680,7 +680,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
680
680
  }, 0);
681
681
  };
682
682
  sortedFlattenedList.forEach((flatItem, index) => {
683
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
683
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
684
684
  let product, originProduct;
685
685
  if (flatItem.type === "main") {
686
686
  product = flatItem.product;
@@ -701,11 +701,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
701
701
  };
702
702
  originProduct = flatItem.originProduct;
703
703
  }
704
- if ((product == null ? void 0 : product.booking_id) && ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every(
705
- (discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(
706
- discount.tag || discount.type
707
- )
708
- ))) {
704
+ const isPersistedProduct = (product == null ? void 0 : product.booking_id) || (originProduct == null ? void 0 : originProduct.order_detail_id) || (originProduct == null ? void 0 : originProduct.orderDetailId) || (originProduct == null ? void 0 : originProduct.booking_id);
705
+ const hasExistingWalletDiscount = ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every((discount) => {
706
+ var _a2;
707
+ const discountIdentity = discount.id ?? ((_a2 = discount.discount) == null ? void 0 : _a2.resource_id);
708
+ const discountType = discount.tag || discount.type;
709
+ return Boolean(
710
+ discountIdentity && ["good_pass", "discount_card", "product_discount_card"].includes(
711
+ discountType
712
+ )
713
+ );
714
+ }));
715
+ if (isPersistedProduct && hasExistingWalletDiscount) {
709
716
  if (flatItem.type === "main") {
710
717
  processedProductsMap.set(product._id, [originProduct]);
711
718
  } else {
@@ -786,13 +793,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
786
793
  const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
787
794
  let isManualDiscount = false;
788
795
  if (flatItem.type === "main") {
789
- isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(
796
+ isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : ((_g = product.discount_list) == null ? void 0 : _g.some((item) => item.type === "product")) || product.total != product.origin_total && (product.bundle || []).every(
790
797
  (item) => {
791
798
  var _a2;
792
799
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
793
800
  }
794
- ) && (!((_g = product.discount_list) == null ? void 0 : _g.length) || ((_i = (_h = product == null ? void 0 : product.discount_list) == null ? void 0 : _h.every) == null ? void 0 : _i.call(
795
- _h,
801
+ ) && (!((_h = product.discount_list) == null ? void 0 : _h.length) || ((_j = (_i = product == null ? void 0 : product.discount_list) == null ? void 0 : _i.every) == null ? void 0 : _j.call(
802
+ _i,
796
803
  (item) => item.type === "product"
797
804
  )));
798
805
  if (product.inPromotion) {
@@ -801,19 +808,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
801
808
  } else {
802
809
  const parentProduct = flatItem.parentProduct;
803
810
  if (parentProduct) {
804
- isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(
811
+ isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : ((_k = parentProduct.discount_list) == null ? void 0 : _k.some((item) => item.type === "product")) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(
805
812
  (item) => {
806
813
  var _a2;
807
814
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
808
815
  }
809
- ) && (!((_j = parentProduct.discount_list) == null ? void 0 : _j.length) || ((_l = (_k = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _k.every) == null ? void 0 : _l.call(
810
- _k,
816
+ ) && (!((_l = parentProduct.discount_list) == null ? void 0 : _l.length) || ((_n = (_m = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _m.every) == null ? void 0 : _n.call(
817
+ _m,
811
818
  (item) => item.type === "product"
812
819
  )));
813
820
  }
814
821
  }
815
822
  if (options == null ? void 0 : options.discountId) {
816
- if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some(
823
+ if (flatItem.type === "main" && ((_o = product.discount_list) == null ? void 0 : _o.some(
817
824
  (item) => {
818
825
  var _a2;
819
826
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
@@ -822,12 +829,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
822
829
  isManualDiscount = false;
823
830
  }
824
831
  if (flatItem.type === "bundle") {
825
- if (((_n = product.discount_list) == null ? void 0 : _n.some(
832
+ if (((_p = product.discount_list) == null ? void 0 : _p.some(
826
833
  (item) => {
827
834
  var _a2;
828
835
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
829
836
  }
830
- )) || ((_p = (_o = flatItem.parentProduct) == null ? void 0 : _o.discount_list) == null ? void 0 : _p.some(
837
+ )) || ((_r = (_q = flatItem.parentProduct) == null ? void 0 : _q.discount_list) == null ? void 0 : _r.some(
831
838
  (item) => {
832
839
  var _a2;
833
840
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
@@ -838,7 +845,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
838
845
  }
839
846
  }
840
847
  if (options == null ? void 0 : options.selectedList) {
841
- if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some(
848
+ if (flatItem.type === "main" && ((_s = product.discount_list) == null ? void 0 : _s.some(
842
849
  (item) => {
843
850
  var _a2;
844
851
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
@@ -852,7 +859,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
852
859
  isManualDiscount = false;
853
860
  }
854
861
  if (flatItem.type === "bundle") {
855
- if (((_r = product.discount_list) == null ? void 0 : _r.some(
862
+ if (((_t = product.discount_list) == null ? void 0 : _t.some(
856
863
  (item) => {
857
864
  var _a2;
858
865
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
@@ -862,7 +869,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
862
869
  }
863
870
  );
864
871
  }
865
- )) || ((_t = (_s = flatItem.parentProduct) == null ? void 0 : _s.discount_list) == null ? void 0 : _t.some(
872
+ )) || ((_v = (_u = flatItem.parentProduct) == null ? void 0 : _u.discount_list) == null ? void 0 : _v.some(
866
873
  (item) => {
867
874
  var _a2;
868
875
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some(
@@ -907,7 +914,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
907
914
  })
908
915
  ]);
909
916
  } else {
910
- let total = product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
917
+ let total = product.inPromotion ? ((_w = product == null ? void 0 : product._promotion) == null ? void 0 : _w.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
911
918
  let main_product_selling_price = product.price;
912
919
  if ((product.discount_list || []).some((item) => item.type === "promotion") || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
913
920
  total = product.total ?? product.origin_total;
@@ -932,7 +939,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
932
939
  } else {
933
940
  processedFlatItemsMap.set(flatItem._id, [{
934
941
  ...flatItem,
935
- discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(((_v = flatItem.bundleItem) == null ? void 0 : _v.discount_list) || []) : this.filterDiscountListByType(((_w = flatItem.bundleItem) == null ? void 0 : _w.discount_list) || [], "promotion"),
942
+ discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(((_x = flatItem.bundleItem) == null ? void 0 : _x.discount_list) || []) : this.filterDiscountListByType(((_y = flatItem.bundleItem) == null ? void 0 : _y.discount_list) || [], "promotion"),
936
943
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
937
944
  processed: true
938
945
  }]);
@@ -983,13 +990,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
983
990
  if (this.filterDiscountListByType(product.discount_list, "promotion").length && product.origin_total) {
984
991
  productOriginTotal = product.origin_total;
985
992
  }
986
- if (Number(((_x = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _x.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
993
+ if (Number(((_z = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _z.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
987
994
  productOriginTotal = product.total;
988
995
  }
989
996
  const isOrderLevel = (0, import_utils3.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
990
997
  const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
991
998
  const productAllocation = orderLevelAllocation == null ? void 0 : orderLevelAllocation.get(flatItem._id);
992
- const isDeductOptionPrice = !!((_y = selectedDiscount2.config) == null ? void 0 : _y.deductOptionPrice);
999
+ const isDeductOptionPrice = !!((_A = selectedDiscount2.config) == null ? void 0 : _A.deductOptionPrice);
993
1000
  let mainProductSellingPrice;
994
1001
  let amount;
995
1002
  let productDiscountDifference;
@@ -1007,7 +1014,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1007
1014
  );
1008
1015
  amount = new import_decimal.default(product.price).minus(new import_decimal.default(mainProductSellingPrice)).toNumber();
1009
1016
  }
1010
- if (isDeductOptionPrice && ((_z = product.options) == null ? void 0 : _z.length)) {
1017
+ if (isDeductOptionPrice && ((_B = product.options) == null ? void 0 : _B.length)) {
1011
1018
  const optionResult = applyDiscountToOptions(
1012
1019
  product.options,
1013
1020
  selectedDiscount2
@@ -1015,7 +1022,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1015
1022
  discountedOptions = optionResult.discountedOptions;
1016
1023
  optionDiscountAmount = optionResult.optionDiscountAmount;
1017
1024
  }
1018
- const optionsForLineTotal = isDeductOptionPrice && ((_A = product.options) == null ? void 0 : _A.length) ? discountedOptions : product.options;
1025
+ const optionsForLineTotal = isDeductOptionPrice && ((_C = product.options) == null ? void 0 : _C.length) ? discountedOptions : product.options;
1019
1026
  const optionsLineTotal = getOptionTotal(optionsForLineTotal || []);
1020
1027
  const total = new import_decimal.default(mainProductSellingPrice).plus(optionsLineTotal).toNumber();
1021
1028
  const mainProductDiscountAmount = amount;
@@ -1026,9 +1033,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1026
1033
  amount: lineDiscountAmount,
1027
1034
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
1028
1035
  discount: {
1029
- discount_card_type: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_card_type,
1036
+ discount_card_type: (_D = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _D.discount_card_type,
1030
1037
  fixed_amount: lineDiscountAmount,
1031
- discount_calculation_mode: (_C = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _C.discount_calculation_mode,
1038
+ discount_calculation_mode: (_E = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _E.discount_calculation_mode,
1032
1039
  resource_id: selectedDiscount2.id,
1033
1040
  title: selectedDiscount2.format_title,
1034
1041
  original_amount: product.price,
@@ -1110,7 +1117,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1110
1117
  type: "good_pass",
1111
1118
  discount: {
1112
1119
  fixed_amount: product.origin_total,
1113
- discount_calculation_mode: (_D = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _D.discount_calculation_mode,
1120
+ discount_calculation_mode: (_F = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _F.discount_calculation_mode,
1114
1121
  resource_id: selectedDiscount2.id,
1115
1122
  title: selectedDiscount2.format_title,
1116
1123
  original_amount: product.origin_total,
@@ -1184,9 +1191,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1184
1191
  amount: fixedAmountPerItem * (product.num || 1),
1185
1192
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
1186
1193
  discount: {
1187
- discount_card_type: (_E = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _E.discount_card_type,
1194
+ discount_card_type: (_G = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _G.discount_card_type,
1188
1195
  fixed_amount: fixedAmountPerItem,
1189
- discount_calculation_mode: (_F = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _F.discount_calculation_mode,
1196
+ discount_calculation_mode: (_H = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _H.discount_calculation_mode,
1190
1197
  resource_id: selectedDiscount2.id,
1191
1198
  title: selectedDiscount2.format_title,
1192
1199
  original_amount: product.original_price,
@@ -1202,7 +1209,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1202
1209
  ...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
1203
1210
  },
1204
1211
  config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
1205
- _num: (product.num || 1) * (((_G = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _G.num) || 1)
1212
+ _num: (product.num || 1) * (((_I = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _I.num) || 1)
1206
1213
  };
1207
1214
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
1208
1215
  appliedProducts.push(discountDetail);
@@ -53,7 +53,7 @@ function normalizeOptionItems(optionItems) {
53
53
  if (!Array.isArray(optionItems))
54
54
  return [];
55
55
  return optionItems.map((optionItem) => {
56
- const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.option_group_item_id);
56
+ const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.id);
57
57
  const price = (optionItem == null ? void 0 : optionItem.price) ?? (optionItem == null ? void 0 : optionItem.add_price) ?? 0;
58
58
  return {
59
59
  option_group_item_id: optionGroupItemId,
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -511,10 +511,14 @@ function normalizeOrderProduct(product) {
511
511
  { num: product.num, metadata, lineOriginalPrice: product.original_price },
512
512
  composedOriginalPrice
513
513
  );
514
+ const hasManualProductDiscount = (product.discount_list || []).some(
515
+ (item) => (item == null ? void 0 : item.type) === "product"
516
+ );
517
+ const manualOriginalPrice = hasManualProductDiscount && product.original_price != null ? String(product.original_price) : finalOriginalPrice;
514
518
  const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
515
519
  discountList: product.discount_list,
516
520
  metadata,
517
- originalPrice: finalOriginalPrice,
521
+ originalPrice: manualOriginalPrice,
518
522
  sellingPrice: composedSellingPrice,
519
523
  quantity: getSafeProductNum(product.num)
520
524
  });
@@ -525,7 +529,7 @@ function normalizeOrderProduct(product) {
525
529
  product_variant_id: product.product_variant_id,
526
530
  product_option_item: normalizedOptions,
527
531
  selling_price: composedSellingPrice,
528
- original_price: finalOriginalPrice,
532
+ original_price: manualOriginalPrice,
529
533
  tax_fee: product.tax_fee || "0.00",
530
534
  is_charge_tax: product.is_charge_tax ?? 0,
531
535
  discount_list: discountList,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.184",
4
+ "version": "2.2.186",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",