@pisell/pisellos 2.2.185 → 2.2.187

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -264,7 +264,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
264
264
  private logSubmitBackendRejected;
265
265
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
266
266
  createOrder(params: CommitOrderParams['query']): {
267
- type: "appointment_booking" | "virtual";
267
+ type: "virtual" | "appointment_booking";
268
268
  platform: string;
269
269
  sales_channel: string;
270
270
  order_sales_channel: string;
@@ -1,3 +1,7 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
5
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
6
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
7
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -1152,12 +1156,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1152
1156
  key: "updateTempOrderPaymentStatus",
1153
1157
  value: function updateTempOrderPaymentStatus(tempOrder) {
1154
1158
  var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
1159
+ var targetAmount = this.getPaymentTargetAmount();
1160
+ if (targetAmount.lte(0)) {
1161
+ tempOrder.payment_status = 'paid';
1162
+ return;
1163
+ }
1155
1164
  if (paymentTotal.lte(0)) {
1156
1165
  tempOrder.payment_status = tempOrder.payment_status || 'payment_processing';
1157
1166
  return;
1158
1167
  }
1159
- var targetAmount = this.getPaymentTargetAmount();
1160
- tempOrder.payment_status = targetAmount.gt(0) && paymentTotal.gte(targetAmount) ? 'paid' : 'partially_paid';
1168
+ tempOrder.payment_status = paymentTotal.gte(targetAmount) ? 'paid' : 'partially_paid';
1161
1169
  }
1162
1170
  }, {
1163
1171
  key: "calculatePaidPaymentSummary",
@@ -2101,6 +2109,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2101
2109
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
2102
2110
  while (1) switch (_context18.prev = _context18.next) {
2103
2111
  case 0:
2112
+ debugger;
2104
2113
  tempOrder = this.ensureTempOrder();
2105
2114
  linked = booking ? this.createLinkedProductAndBooking({
2106
2115
  product: product,
@@ -2122,10 +2131,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2122
2131
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
2123
2132
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
2124
2133
  if (!matchedProduct) {
2125
- _context18.next = 17;
2134
+ _context18.next = 18;
2126
2135
  break;
2127
2136
  }
2128
- _context18.next = 14;
2137
+ _context18.next = 15;
2129
2138
  return this.shouldMergeProductToOrder({
2130
2139
  incomingProduct: productToAdd,
2131
2140
  normalizedIncoming: normalizedIncoming,
@@ -2136,13 +2145,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2136
2145
  tempOrder: tempOrder,
2137
2146
  booking: booking
2138
2147
  });
2139
- case 14:
2148
+ case 15:
2140
2149
  _context18.t0 = _context18.sent;
2141
- _context18.next = 18;
2150
+ _context18.next = 19;
2142
2151
  break;
2143
- case 17:
2144
- _context18.t0 = false;
2145
2152
  case 18:
2153
+ _context18.t0 = false;
2154
+ case 19:
2146
2155
  shouldMerge = _context18.t0;
2147
2156
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
2148
2157
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
@@ -2175,18 +2184,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2175
2184
  if (linked) {
2176
2185
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
2177
2186
  }
2178
- _context18.next = 23;
2187
+ _context18.next = 24;
2179
2188
  return this.applyPromotion();
2180
- case 23:
2189
+ case 24:
2181
2190
  this.applyDiscount();
2182
- _context18.next = 26;
2191
+ _context18.next = 27;
2183
2192
  return this.recalculateSummary({
2184
2193
  createIfMissing: true
2185
2194
  });
2186
- case 26:
2195
+ case 27:
2187
2196
  this.persistTempOrder();
2188
2197
  return _context18.abrupt("return", tempOrder.products);
2189
- case 28:
2198
+ case 29:
2190
2199
  case "end":
2191
2200
  return _context18.stop();
2192
2201
  }
@@ -2559,11 +2568,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2559
2568
  channel: params === null || params === void 0 ? void 0 : params.channel,
2560
2569
  type: params === null || params === void 0 ? void 0 : params.type,
2561
2570
  enhance: enhancePayload
2562
- });
2563
- _context23.next = 10;
2571
+ }); // TODO: 前端生成的时间现在是有问题的,后面要统一优化
2572
+ payload.created_at = undefined;
2573
+ _context23.next = 11;
2564
2574
  return this.saveDraft();
2565
- case 10:
2566
- _context23.prev = 10;
2575
+ case 11:
2576
+ _context23.prev = 11;
2567
2577
  this.logInfo('submitTempOrder calling sales checkout', {
2568
2578
  orderId: payload.order_id,
2569
2579
  externalSaleNumber: payload.external_sale_number,
@@ -2572,26 +2582,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2572
2582
  paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
2573
2583
  smallTicketDataFlag: payload.small_ticket_data_flag
2574
2584
  });
2575
- _context23.next = 14;
2585
+ _context23.next = 15;
2576
2586
  return this.submitSalesOrder({
2577
2587
  query: payload
2578
2588
  });
2579
- case 14:
2589
+ case 15:
2580
2590
  result = _context23.sent;
2581
- _context23.next = 27;
2591
+ _context23.next = 28;
2582
2592
  break;
2583
- case 17:
2584
- _context23.prev = 17;
2585
- _context23.t0 = _context23["catch"](10);
2593
+ case 18:
2594
+ _context23.prev = 18;
2595
+ _context23.t0 = _context23["catch"](11);
2586
2596
  backendErrorResponse = this.extractSubmitErrorResponse(_context23.t0);
2587
2597
  if (!backendErrorResponse) {
2588
- _context23.next = 24;
2598
+ _context23.next = 25;
2589
2599
  break;
2590
2600
  }
2591
2601
  this.store.syncState = 'failed';
2592
2602
  this.logSubmitBackendRejected(backendErrorResponse, payload);
2593
2603
  return _context23.abrupt("return", backendErrorResponse);
2594
- case 24:
2604
+ case 25:
2595
2605
  this.store.syncState = 'failed';
2596
2606
  this.logError('submitTempOrder failed', {
2597
2607
  error: _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0),
@@ -2601,31 +2611,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2601
2611
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
2602
2612
  });
2603
2613
  throw _context23.t0;
2604
- case 27:
2614
+ case 28:
2605
2615
  if (!this.isSubmitResponseRejected(result)) {
2606
- _context23.next = 31;
2616
+ _context23.next = 32;
2607
2617
  break;
2608
2618
  }
2609
2619
  this.store.syncState = 'failed';
2610
2620
  this.logSubmitBackendRejected(result, payload);
2611
2621
  return _context23.abrupt("return", result);
2612
- case 31:
2622
+ case 32:
2613
2623
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
2614
2624
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
2615
- _context23.next = 37;
2625
+ _context23.next = 38;
2616
2626
  break;
2617
2627
  }
2618
2628
  tempOrder.order_id = submittedOrderId;
2619
2629
  resultRecord = result;
2620
- _context23.next = 37;
2630
+ _context23.next = 38;
2621
2631
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
2622
- case 37:
2623
- return _context23.abrupt("return", result);
2624
2632
  case 38:
2633
+ return _context23.abrupt("return", result);
2634
+ case 39:
2625
2635
  case "end":
2626
2636
  return _context23.stop();
2627
2637
  }
2628
- }, _callee21, this, [[10, 17]]);
2638
+ }, _callee21, this, [[11, 18]]);
2629
2639
  }));
2630
2640
  function submitTempOrder(_x21) {
2631
2641
  return _submitTempOrder.apply(this, arguments);
@@ -2709,7 +2719,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2709
2719
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
2710
2720
  paymentTotal = this.calculatePaymentTotal(mappedPayments);
2711
2721
  targetAmount = this.getPaymentTargetAmount();
2712
- isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
2722
+ isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
2713
2723
  paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
2714
2724
  tempOrder.payments = mappedPayments;
2715
2725
  tempOrder.payment_status = paymentStatus;
@@ -3275,7 +3285,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3275
3285
  delete nextTempOrder.holder_id;
3276
3286
  nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
3277
3287
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
3278
- nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
3288
+ var rawProducts = Array.isArray(raw.products) ? raw.products : [];
3289
+ nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
3279
3290
  return _this10.normalizeHydratedOrderProduct(p);
3280
3291
  }) : [];
3281
3292
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
@@ -3302,6 +3313,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3302
3313
  }) : {
3303
3314
  productsByUid: {}
3304
3315
  };
3316
+ var tempOrderExtend = nextTempOrder._extend;
3317
+ var productsByUid = tempOrderExtend.productsByUid || {};
3318
+ var _iterator8 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
3319
+ _step8;
3320
+ try {
3321
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3322
+ var _product$metadata6, _ref23, _ref24, _existed$origin, _rawProduct$metadata;
3323
+ var _step8$value = _slicedToArray(_step8.value, 2),
3324
+ index = _step8$value[0],
3325
+ product = _step8$value[1];
3326
+ var uid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
3327
+ if (!uid) continue;
3328
+ var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
3329
+ var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
3330
+ var origin = (_ref23 = (_ref24 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref24 !== void 0 ? _ref24 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref23 !== void 0 ? _ref23 : rawProduct;
3331
+ productsByUid[uid] = _objectSpread(_objectSpread({}, existed), {}, {
3332
+ origin: cloneDeep(origin)
3333
+ });
3334
+ }
3335
+ } catch (err) {
3336
+ _iterator8.e(err);
3337
+ } finally {
3338
+ _iterator8.f();
3339
+ }
3340
+ tempOrderExtend.productsByUid = productsByUid;
3305
3341
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
3306
3342
  this.ensureExternalSaleNumber(nextTempOrder);
3307
3343
  }
@@ -3311,10 +3347,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3311
3347
  }, {
3312
3348
  key: "normalizeHydratedProductOptionItem",
3313
3349
  value: function normalizeHydratedProductOptionItem(optionItem) {
3314
- var _ref23, _optionItem$num, _ref24, _optionItem$price;
3315
- var rawNum = (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : 1;
3350
+ var _ref25, _optionItem$num, _ref26, _optionItem$price;
3351
+ var rawNum = (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : 1;
3316
3352
  var parsedNum = Number(rawNum);
3317
- var rawPrice = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 0;
3353
+ var rawPrice = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : 0;
3318
3354
  var parsedPrice = Number(rawPrice);
3319
3355
  return {
3320
3356
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -3412,67 +3448,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3412
3448
  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);
3413
3449
  savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
3414
3450
  };
3415
- var _iterator8 = _createForOfIteratorHelper(productList),
3416
- _step8;
3451
+ var _iterator9 = _createForOfIteratorHelper(productList),
3452
+ _step9;
3417
3453
  try {
3418
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3419
- var product = _step8.value;
3454
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3455
+ var product = _step9.value;
3420
3456
  var qty = product.num || 1;
3421
- var _iterator10 = _createForOfIteratorHelper(product.discount_list || []),
3422
- _step10;
3457
+ var _iterator11 = _createForOfIteratorHelper(product.discount_list || []),
3458
+ _step11;
3423
3459
  try {
3424
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3425
- var pd = _step10.value;
3460
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3461
+ var pd = _step11.value;
3426
3462
  addDiscountAmount(pd, qty);
3427
3463
  }
3428
3464
  } catch (err) {
3429
- _iterator10.e(err);
3465
+ _iterator11.e(err);
3430
3466
  } finally {
3431
- _iterator10.f();
3467
+ _iterator11.f();
3432
3468
  }
3433
- var _iterator11 = _createForOfIteratorHelper(product.product_bundle || []),
3434
- _step11;
3469
+ var _iterator12 = _createForOfIteratorHelper(product.product_bundle || []),
3470
+ _step12;
3435
3471
  try {
3436
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3437
- var _ref25, _bundle$num;
3438
- var bundle = _step11.value;
3439
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref25 = (_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref25 !== void 0 ? _ref25 : 1) || 1).toNumber();
3440
- var _iterator12 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
3441
- _step12;
3472
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3473
+ var _ref27, _bundle$num;
3474
+ var bundle = _step12.value;
3475
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref27 = (_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref27 !== void 0 ? _ref27 : 1) || 1).toNumber();
3476
+ var _iterator13 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
3477
+ _step13;
3442
3478
  try {
3443
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3444
- var _pd = _step12.value;
3479
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
3480
+ var _pd = _step13.value;
3445
3481
  addDiscountAmount(_pd, bundleQty);
3446
3482
  }
3447
3483
  } catch (err) {
3448
- _iterator12.e(err);
3484
+ _iterator13.e(err);
3449
3485
  } finally {
3450
- _iterator12.f();
3486
+ _iterator13.f();
3451
3487
  }
3452
3488
  }
3453
3489
  } catch (err) {
3454
- _iterator11.e(err);
3490
+ _iterator12.e(err);
3455
3491
  } finally {
3456
- _iterator11.f();
3492
+ _iterator12.f();
3457
3493
  }
3458
3494
  }
3459
3495
  } catch (err) {
3460
- _iterator8.e(err);
3496
+ _iterator9.e(err);
3461
3497
  } finally {
3462
- _iterator8.f();
3498
+ _iterator9.f();
3463
3499
  }
3464
- var _iterator9 = _createForOfIteratorHelper(discountList),
3465
- _step9;
3500
+ var _iterator10 = _createForOfIteratorHelper(discountList),
3501
+ _step10;
3466
3502
  try {
3467
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3468
- var d = _step9.value;
3503
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3504
+ var d = _step10.value;
3469
3505
  var key = d.id;
3470
3506
  d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
3471
3507
  }
3472
3508
  } catch (err) {
3473
- _iterator9.e(err);
3509
+ _iterator10.e(err);
3474
3510
  } finally {
3475
- _iterator9.f();
3511
+ _iterator10.f();
3476
3512
  }
3477
3513
  }
3478
3514
  }]);
@@ -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
 
@@ -180,6 +180,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
180
180
  smallTicketDataFlag?: number;
181
181
  enhancePayload?: SubmitPayloadEnhancer;
182
182
  }): Promise<T>;
183
+ private getSubmitPaymentStatus;
183
184
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
184
185
  /** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
185
186
  getOrderPayments(): OrderPaymentData[];
@@ -1790,7 +1790,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1790
1790
  value: (function () {
1791
1791
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1792
1792
  var _this$otherParams6, _this$otherParams7, _this$otherParams8;
1793
- var submitParams;
1793
+ var inferredPaymentStatus, submitParams;
1794
1794
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1795
1795
  while (1) switch (_context18.prev = _context18.next) {
1796
1796
  case 0:
@@ -1801,6 +1801,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1801
1801
  throw new Error('BaseSales 解决方案需要 order 模块支持');
1802
1802
  case 2:
1803
1803
  this.store.order.persistTempOrder();
1804
+ inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
1804
1805
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
1805
1806
  cacheId: this.cacheId,
1806
1807
  platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
@@ -1809,8 +1810,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1809
1810
  type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type
1810
1811
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
1811
1812
  payments: params.payments
1812
- } : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
1813
- paymentStatus: params.paymentStatus
1813
+ } : {}), inferredPaymentStatus !== undefined ? {
1814
+ paymentStatus: inferredPaymentStatus
1814
1815
  } : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
1815
1816
  smallTicketDataFlag: params.smallTicketDataFlag
1816
1817
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
@@ -1818,7 +1819,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1818
1819
  } : {});
1819
1820
  console.log(submitParams, 'submitParams123');
1820
1821
  return _context18.abrupt("return", this.store.order.submitTempOrder(submitParams));
1821
- case 6:
1822
+ case 7:
1822
1823
  case "end":
1823
1824
  return _context18.stop();
1824
1825
  }
@@ -1829,6 +1830,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1829
1830
  }
1830
1831
  return submitSalesOrder;
1831
1832
  }())
1833
+ }, {
1834
+ key: "getSubmitPaymentStatus",
1835
+ value: function getSubmitPaymentStatus(paymentStatus) {
1836
+ var _this$store$order3, _this$store$order3$ge;
1837
+ if (paymentStatus !== undefined) return paymentStatus;
1838
+ var amountSnapshot = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getOrderAmountSnapshot) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
1839
+ if (!amountSnapshot) return undefined;
1840
+ try {
1841
+ return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
1842
+ } catch (_unused2) {
1843
+ return undefined;
1844
+ }
1845
+ }
1832
1846
  }, {
1833
1847
  key: "syncPaymentsToOrder",
1834
1848
  value: function () {
@@ -1978,8 +1992,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1978
1992
  }, {
1979
1993
  key: "getWalletProductList",
1980
1994
  value: function getWalletProductList() {
1981
- var _this$store$order3, _tempOrder$products, _tempOrder$products2;
1982
- var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
1995
+ var _this$store$order4, _tempOrder$products, _tempOrder$products2;
1996
+ var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1983
1997
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
1984
1998
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
1985
1999
  var products = tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.filter(function (n) {
@@ -2555,16 +2569,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2555
2569
  }, {
2556
2570
  key: "getUnfulfilledPromotions",
2557
2571
  value: function getUnfulfilledPromotions() {
2558
- var _this$store$order4;
2559
- return ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getUnfulfilledPromotions()) || [];
2572
+ var _this$store$order5;
2573
+ return ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getUnfulfilledPromotions()) || [];
2560
2574
  }
2561
2575
 
2562
2576
  /** 最近一次促销计算输出的赠品操作 diff。 */
2563
2577
  }, {
2564
2578
  key: "getLastGiftActions",
2565
2579
  value: function getLastGiftActions() {
2566
- var _this$store$order5;
2567
- return ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getLastGiftActions()) || null;
2580
+ var _this$store$order6;
2581
+ return ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getLastGiftActions()) || null;
2568
2582
  }
2569
2583
 
2570
2584
  // 获取商品列表
@@ -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 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
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,
@@ -264,7 +264,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
264
264
  private logSubmitBackendRejected;
265
265
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
266
266
  createOrder(params: CommitOrderParams['query']): {
267
- type: "appointment_booking" | "virtual";
267
+ type: "virtual" | "appointment_booking";
268
268
  platform: string;
269
269
  sales_channel: string;
270
270
  order_sales_channel: string;
@@ -719,12 +719,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
719
719
  }
720
720
  updateTempOrderPaymentStatus(tempOrder) {
721
721
  const paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
722
+ const targetAmount = this.getPaymentTargetAmount();
723
+ if (targetAmount.lte(0)) {
724
+ tempOrder.payment_status = "paid";
725
+ return;
726
+ }
722
727
  if (paymentTotal.lte(0)) {
723
728
  tempOrder.payment_status = tempOrder.payment_status || "payment_processing";
724
729
  return;
725
730
  }
726
- const targetAmount = this.getPaymentTargetAmount();
727
- tempOrder.payment_status = targetAmount.gt(0) && paymentTotal.gte(targetAmount) ? "paid" : "partially_paid";
731
+ tempOrder.payment_status = paymentTotal.gte(targetAmount) ? "paid" : "partially_paid";
728
732
  }
729
733
  calculatePaidPaymentSummary(payments) {
730
734
  return (payments || []).reduce(
@@ -1436,6 +1440,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1436
1440
  // ─── TempOrder: 商品 CRUD ───
1437
1441
  async addProductToOrder(product, booking) {
1438
1442
  var _a;
1443
+ debugger;
1439
1444
  const tempOrder = this.ensureTempOrder();
1440
1445
  const linked = booking ? this.createLinkedProductAndBooking({ product, booking }) : null;
1441
1446
  const productToAdd = (linked == null ? void 0 : linked.product) || product;
@@ -1848,6 +1853,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1848
1853
  type: params == null ? void 0 : params.type,
1849
1854
  enhance: enhancePayload
1850
1855
  });
1856
+ payload.created_at = void 0;
1851
1857
  await this.saveDraft();
1852
1858
  let result;
1853
1859
  try {
@@ -1943,7 +1949,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1943
1949
  );
1944
1950
  const paymentTotal = this.calculatePaymentTotal(mappedPayments);
1945
1951
  const targetAmount = this.getPaymentTargetAmount();
1946
- const isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
1952
+ const isFullyPaid = targetAmount.lte(0) ? true : paymentTotal.gte(targetAmount);
1947
1953
  const paymentStatus = isFullyPaid ? params.paymentStatus || "paid" : "partially_paid";
1948
1954
  tempOrder.payments = mappedPayments;
1949
1955
  tempOrder.payment_status = paymentStatus;
@@ -2282,6 +2288,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2282
2288
  return nextTempOrder;
2283
2289
  }
2284
2290
  normalizeTempOrderForRuntime(raw, options) {
2291
+ var _a, _b;
2285
2292
  const nextTempOrder = {
2286
2293
  ...this.createDefaultTempOrderInstance(),
2287
2294
  ...raw || {}
@@ -2301,7 +2308,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2301
2308
  delete nextTempOrder.holder_id;
2302
2309
  nextTempOrder.metadata = raw.metadata && typeof raw.metadata === "object" ? { ...raw.metadata } : {};
2303
2310
  nextTempOrder.holder = raw.holder && typeof raw.holder === "object" ? { ...raw.holder } : null;
2304
- nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map((p) => this.normalizeHydratedOrderProduct(p)) : [];
2311
+ const rawProducts = Array.isArray(raw.products) ? raw.products : [];
2312
+ nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map((p) => this.normalizeHydratedOrderProduct(p)) : [];
2305
2313
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map((b) => ({
2306
2314
  ...b || {},
2307
2315
  is_all: (0, import_utils.normalizeBookingIsAll)(b || {}),
@@ -2316,6 +2324,21 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2316
2324
  ...raw._extend,
2317
2325
  productsByUid: raw._extend.productsByUid || {}
2318
2326
  } : { productsByUid: {} };
2327
+ const tempOrderExtend = nextTempOrder._extend;
2328
+ const productsByUid = tempOrderExtend.productsByUid || {};
2329
+ for (const [index, product] of nextTempOrder.products.entries()) {
2330
+ const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
2331
+ if (!uid)
2332
+ continue;
2333
+ const existed = productsByUid[uid] && typeof productsByUid[uid] === "object" ? productsByUid[uid] : {};
2334
+ const rawProduct = rawProducts[index] && typeof rawProducts[index] === "object" ? rawProducts[index] : product;
2335
+ const origin = existed.origin ?? rawProduct._origin ?? ((_b = rawProduct.metadata) == null ? void 0 : _b.origin) ?? rawProduct;
2336
+ productsByUid[uid] = {
2337
+ ...existed,
2338
+ origin: (0, import_lodash_es.cloneDeep)(origin)
2339
+ };
2340
+ }
2341
+ tempOrderExtend.productsByUid = productsByUid;
2319
2342
  if ((options == null ? void 0 : options.ensureIdentity) !== false) {
2320
2343
  this.ensureExternalSaleNumber(nextTempOrder);
2321
2344
  }
@@ -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);
@@ -180,6 +180,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
180
180
  smallTicketDataFlag?: number;
181
181
  enhancePayload?: SubmitPayloadEnhancer;
182
182
  }): Promise<T>;
183
+ private getSubmitPaymentStatus;
183
184
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
184
185
  /** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
185
186
  getOrderPayments(): OrderPaymentData[];
@@ -1073,6 +1073,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1073
1073
  throw new Error("BaseSales 解决方案需要 order 模块支持");
1074
1074
  }
1075
1075
  this.store.order.persistTempOrder();
1076
+ const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
1076
1077
  const submitParams = {
1077
1078
  cacheId: this.cacheId,
1078
1079
  platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
@@ -1080,13 +1081,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1080
1081
  channel: this.getSubmitOrderSalesChannel(),
1081
1082
  type: (_c = this.otherParams) == null ? void 0 : _c.type,
1082
1083
  ...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
1083
- ...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
1084
+ ...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
1084
1085
  ...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
1085
1086
  ...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
1086
1087
  };
1087
1088
  console.log(submitParams, "submitParams123");
1088
1089
  return this.store.order.submitTempOrder(submitParams);
1089
1090
  }
1091
+ getSubmitPaymentStatus(paymentStatus) {
1092
+ var _a, _b;
1093
+ if (paymentStatus !== void 0)
1094
+ return paymentStatus;
1095
+ const amountSnapshot = (_b = (_a = this.store.order) == null ? void 0 : _a.getOrderAmountSnapshot) == null ? void 0 : _b.call(_a);
1096
+ if (!amountSnapshot)
1097
+ return void 0;
1098
+ try {
1099
+ return new import_decimal.default(amountSnapshot.amountGap || 0).lte(0) ? "paid" : void 0;
1100
+ } catch {
1101
+ return void 0;
1102
+ }
1103
+ }
1090
1104
  async syncPaymentsToOrder(params) {
1091
1105
  if (!this.store.order)
1092
1106
  throw new Error("order 模块未初始化");
@@ -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 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
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.185",
4
+ "version": "2.2.187",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",