@pisell/pisellos 2.2.168 → 2.2.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +51 -15
  3. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  4. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +26 -2
  5. package/dist/modules/Customer/index.d.ts +6 -0
  6. package/dist/modules/Customer/index.js +122 -77
  7. package/dist/modules/Customer/types.d.ts +2 -0
  8. package/dist/modules/Order/index.d.ts +3 -2
  9. package/dist/modules/Order/index.js +47 -7
  10. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  11. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  12. package/dist/modules/Order/utils.d.ts +4 -0
  13. package/dist/modules/Order/utils.js +26 -10
  14. package/dist/modules/Rules/index.d.ts +4 -0
  15. package/dist/modules/Rules/index.js +26 -10
  16. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +37 -6
  17. package/dist/solution/BaseSales/utils.js +11 -2
  18. package/dist/solution/BookingByStep/index.d.ts +1 -1
  19. package/dist/solution/BookingTicket/index.js +4 -4
  20. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
  21. package/dist/solution/ScanOrder/utils.js +11 -2
  22. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +42 -9
  23. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  24. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +22 -1
  25. package/lib/modules/Customer/index.d.ts +6 -0
  26. package/lib/modules/Customer/index.js +18 -3
  27. package/lib/modules/Customer/types.d.ts +2 -0
  28. package/lib/modules/Order/index.d.ts +3 -2
  29. package/lib/modules/Order/index.js +46 -3
  30. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  31. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  32. package/lib/modules/Order/utils.d.ts +4 -0
  33. package/lib/modules/Order/utils.js +46 -9
  34. package/lib/modules/Rules/index.d.ts +4 -0
  35. package/lib/modules/Rules/index.js +22 -14
  36. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +42 -4
  37. package/lib/solution/BaseSales/utils.js +10 -2
  38. package/lib/solution/BookingByStep/index.d.ts +1 -1
  39. package/lib/solution/BookingTicket/index.js +2 -2
  40. package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -1
  41. package/lib/solution/ScanOrder/utils.js +10 -2
  42. package/package.json +1 -1
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
7
8
  function toNumber(value) {
8
9
  var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
9
10
  var parsedValue = Number(value);
@@ -74,7 +75,7 @@ function findVariantById(origin, variantId) {
74
75
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
75
76
  */
76
77
  export function transformBaseProductToOrderProduct(params) {
77
- var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _payload$option, _payload$bundle, _payload$unique_ident, _payload$quantity, _ref25, _ref26, _payload$tax_fee, _ref27, _ref28, _payload$is_charge_ta;
78
+ var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _payload$option, _payload$bundle, _payload$unique_ident, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref25, _ref26, _origin$base_price, _ref27, _ref28, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref29, _ref30, _payload$tax_fee, _ref31, _ref32, _payload$is_charge_ta;
78
79
  var payload = params.payload,
79
80
  _params$fallbackProdu = params.fallbackProductId,
80
81
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
@@ -92,6 +93,34 @@ export function transformBaseProductToOrderProduct(params) {
92
93
  var productOptionItem = normalizeOptionItems((_ref24 = (_payload$option = payload.option) !== null && _payload$option !== void 0 ? _payload$option : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item);
93
94
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
94
95
  var uniqueIdentificationNumber = (_payload$unique_ident = payload.unique_identification_number) !== null && _payload$unique_ident !== void 0 ? _payload$unique_ident : payload.unique;
96
+ var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
97
+ var originTotal = resolveManualDiscountOriginTotal({
98
+ originTotal: payload.origin_total,
99
+ extendOriginTotal: (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.origin_total,
100
+ originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
101
+ sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
102
+ catalogUnitPrice: (_ref25 = (_ref26 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref26 !== void 0 ? _ref26 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref25 !== void 0 ? _ref25 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
103
+ quantity: resolvedQuantity
104
+ });
105
+ var sellingTotal = Number((_ref27 = (_ref28 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref28 !== void 0 ? _ref28 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total) !== null && _ref27 !== void 0 ? _ref27 : lineCompositeTotal);
106
+ var discountReason = resolveManualDiscountReasonFromSources({
107
+ discountReason: payload.discount_reason,
108
+ extendDiscountReason: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.discount_reason,
109
+ originExtendDiscountReason: origin === null || origin === void 0 || (_extend3 = origin._extend) === null || _extend3 === void 0 ? void 0 : _extend3.discount_reason
110
+ });
111
+ var lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
112
+ var manualDiscountList = shouldBuildManualProductDiscount({
113
+ hasPriceOverride: hasPriceOverride,
114
+ originTotal: originTotal,
115
+ sellingTotal: sellingTotal
116
+ }) ? mergeManualProductDiscountIntoList(payload.discount_list, buildManualProductDiscountItem({
117
+ originTotal: Number.isFinite(originTotal) ? originTotal : Number(lineOriginalPrice),
118
+ sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
119
+ quantity: resolvedQuantity,
120
+ message: discountReason,
121
+ discountway: (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.discountway,
122
+ discount_per: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_per
123
+ })) : payload.discount_list || [];
95
124
  var metadata = _objectSpread(_objectSpread({
96
125
  unique: payload.unique,
97
126
  session: payload.session,
@@ -107,7 +136,8 @@ export function transformBaseProductToOrderProduct(params) {
107
136
  main_product_selling_price: sourceProductPrice,
108
137
  main_product_original_price: sourceProductPrice
109
138
  }, hasPriceOverride ? {
110
- price_override: String(payload.price_override)
139
+ price_override: String(payload.price_override),
140
+ is_manual_discount: 1
111
141
  } : {}), payload.bundle_edit !== undefined ? {
112
142
  bundle_edit: payload.bundle_edit
113
143
  } : {});
@@ -118,14 +148,15 @@ export function transformBaseProductToOrderProduct(params) {
118
148
  product_id: productId,
119
149
  product_variant_id: productVariantId,
120
150
  unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
121
- num: toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1),
151
+ num: resolvedQuantity,
122
152
  product_option_item: productOptionItem,
123
153
  product_bundle: productBundle,
154
+ discount_list: manualDiscountList,
124
155
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
125
156
  selling_price: lineCompositeTotal,
126
- original_price: lineCompositeTotal,
127
- tax_fee: toPriceString((_ref25 = (_ref26 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref26 !== void 0 ? _ref26 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref25 !== void 0 ? _ref25 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
128
- is_charge_tax: toNumber((_ref27 = (_ref28 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref28 !== void 0 ? _ref28 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref27 !== void 0 ? _ref27 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
157
+ original_price: lineOriginalPrice,
158
+ tax_fee: toPriceString((_ref29 = (_ref30 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref30 !== void 0 ? _ref30 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
159
+ is_charge_tax: toNumber((_ref31 = (_ref32 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref32 !== void 0 ? _ref32 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref31 !== void 0 ? _ref31 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
129
160
  metadata: metadata,
130
161
  note: payload.note != null ? String(payload.note) : '',
131
162
  _origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
@@ -6,6 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import Decimal from 'decimal.js';
8
8
  import { composeLinePrice, createUuidV4, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
9
+ import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
9
10
 
10
11
  /**
11
12
  * 构建金额全为 0 的空 summary。
@@ -231,8 +232,16 @@ export function normalizeOrderProduct(product) {
231
232
  });
232
233
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
233
234
  num: product.num,
234
- metadata: metadata
235
+ metadata: metadata,
236
+ lineOriginalPrice: product.original_price
235
237
  }, composedOriginalPrice);
238
+ var discountList = ensureManualProductDiscountList({
239
+ discountList: product.discount_list,
240
+ metadata: metadata,
241
+ originalPrice: finalOriginalPrice,
242
+ sellingPrice: composedSellingPrice,
243
+ quantity: getSafeProductNum(product.num)
244
+ });
236
245
  return {
237
246
  order_detail_id: product.order_detail_id || null,
238
247
  product_id: product.product_id,
@@ -243,7 +252,7 @@ export function normalizeOrderProduct(product) {
243
252
  original_price: finalOriginalPrice,
244
253
  tax_fee: product.tax_fee || '0.00',
245
254
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
246
- discount_list: product.discount_list || [],
255
+ discount_list: discountList,
247
256
  product_bundle: normalizedBundle,
248
257
  metadata: metadata,
249
258
  note: product.note != null ? String(product.note) : ''
@@ -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 | 1 | 2 | 6 | 3 | 5 | 4;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -311,7 +311,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
311
311
  return _context5.abrupt("return", normalizedLocalCustomer);
312
312
  case 5:
313
313
  _context5.next = 7;
314
- return this.store.customer.getCustomerList({
314
+ return this.store.customer.queryCustomerList({
315
315
  ids: [customerId],
316
316
  skip: 1,
317
317
  num: 1
@@ -520,9 +520,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
520
520
  case 0:
521
521
  params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
522
522
  options = _args8.length > 1 ? _args8[1] : undefined;
523
- schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // products 格式化器对齐日历日(YYYY-MM-DD);勿写入 schedule_datetime 全串,
524
- // 否则 requiresDetail 会把带时分秒的 date 传给弹窗,handleOpenProductModal 无法打开。
525
- bookingDate = schedule_date || (schedule_datetime ? String(schedule_datetime).slice(0, 10) : '');
523
+ schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // 优先写入 schedule_datetime(含时分),供加购 presetStartTime TimeBar 对齐;
524
+ // requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
525
+ bookingDate = schedule_datetime || schedule_date || '';
526
526
  if (bookingDate) {
527
527
  this.setBookingDate(bookingDate);
528
528
  }
@@ -200,7 +200,7 @@ export function buildRequiresDetailPayload(item, ctx) {
200
200
  number: Boolean(item === null || item === void 0 ? void 0 : item.open_sold_weight)
201
201
  },
202
202
  isOnlySession: isOnlySession,
203
- isEject: isEject,
203
+ isEject: isEject ? 1 : 0,
204
204
  customerId: ctx === null || ctx === void 0 ? void 0 : ctx.customerId,
205
205
  date: formatBookingDateForUI(ctx === null || ctx === void 0 ? void 0 : ctx.date),
206
206
  productData: item
@@ -339,6 +339,8 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
339
339
  origin_total: extend === null || extend === void 0 ? void 0 : extend.origin_total,
340
340
  price_override: extend === null || extend === void 0 ? void 0 : extend.priceOverride,
341
341
  bundle_edit: extend === null || extend === void 0 ? void 0 : extend.bundle_edit,
342
+ discount_reason: extend === null || extend === void 0 ? void 0 : extend.discount_reason,
343
+ discount_list: cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.discount_list,
342
344
  _extend: extend
343
345
  };
344
346
  }
@@ -14,6 +14,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
14
14
  import dayjs from 'dayjs';
15
15
  import Decimal from 'decimal.js';
16
16
  import { composeLinePrice, createUuidV4, resolveManualOverrideLineOriginalPrice, sumOptionUnitPrice } from "../../modules/Order/utils";
17
+ import { ensureManualProductDiscountList } from "../../modules/Order/utils/manualProductDiscount";
17
18
 
18
19
  /**
19
20
  * 构建金额全为 0 的空 summary。
@@ -605,8 +606,16 @@ export function normalizeOrderProduct(product) {
605
606
  });
606
607
  var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
607
608
  num: product.num,
608
- metadata: metadata
609
+ metadata: metadata,
610
+ lineOriginalPrice: product.original_price
609
611
  }, composedOriginalPrice);
612
+ var discountList = ensureManualProductDiscountList({
613
+ discountList: product.discount_list,
614
+ metadata: metadata,
615
+ originalPrice: finalOriginalPrice,
616
+ sellingPrice: composedSellingPrice,
617
+ quantity: getSafeProductNum(product.num)
618
+ });
610
619
  return {
611
620
  order_detail_id: product.order_detail_id || null,
612
621
  product_id: product.product_id,
@@ -617,7 +626,7 @@ export function normalizeOrderProduct(product) {
617
626
  original_price: finalOriginalPrice,
618
627
  tax_fee: product.tax_fee || '0.00',
619
628
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
620
- discount_list: product.discount_list || [],
629
+ discount_list: discountList,
621
630
  product_bundle: normalizedBundle,
622
631
  metadata: metadata,
623
632
  note: product.note != null ? String(product.note) : ''
@@ -33,6 +33,7 @@ __export(buildCacheItemFromOrderLine_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(buildCacheItemFromOrderLine_exports);
35
35
  var import_dayjs = __toESM(require("dayjs"));
36
+ var import_manualProductDiscount = require("../../Order/utils/manualProductDiscount");
36
37
  function safeFormat(value, fmt) {
37
38
  if (value === void 0 || value === null)
38
39
  return void 0;
@@ -79,10 +80,28 @@ function unflattenResourceMap(resources) {
79
80
  });
80
81
  return map;
81
82
  }
82
- function buildCapacityFromBooking(resources) {
83
- if (!Array.isArray(resources))
84
- return [];
85
- return resources.filter((r) => (r == null ? void 0 : r.relation_id) !== void 0 && (r == null ? void 0 : r.relation_id) !== null && r.capacity !== void 0).map((r) => ({ id: r.relation_id, value: Number(r.capacity || 0) }));
83
+ function resolveCapacityFromBooking(booking) {
84
+ var _a;
85
+ const metaCap = (_a = booking.metadata) == null ? void 0 : _a.capacity;
86
+ if (Array.isArray(metaCap) && metaCap.length > 0) {
87
+ return metaCap.map((item) => {
88
+ if (!item || typeof item !== "object")
89
+ return null;
90
+ if (item.id === void 0 || item.id === null)
91
+ return null;
92
+ const row = {
93
+ id: item.id,
94
+ value: Number(item.value ?? 0)
95
+ };
96
+ if (item.name !== void 0)
97
+ row.name = item.name;
98
+ return row;
99
+ }).filter((item) => item != null);
100
+ }
101
+ if (typeof metaCap === "number" && Number.isFinite(metaCap)) {
102
+ return [{ id: 0, value: metaCap, name: "" }];
103
+ }
104
+ return [];
86
105
  }
87
106
  function resolveDurationForExtend(booking) {
88
107
  const duration = booking.duration;
@@ -95,7 +114,7 @@ function resolveDurationForExtend(booking) {
95
114
  return duration;
96
115
  }
97
116
  function buildCacheItemFromOrderLine(input) {
98
- var _a, _b, _c, _d, _e, _f;
117
+ var _a, _b, _c, _d, _e, _f, _g, _h;
99
118
  const { product, booking, sourceProduct } = input;
100
119
  const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
101
120
  const selling = Number(product.selling_price ?? 0);
@@ -105,7 +124,7 @@ function buildCacheItemFromOrderLine(input) {
105
124
  const startTime = normalizeTimeString(booking.start_time);
106
125
  const endTime = normalizeTimeString(booking.end_time);
107
126
  const resource = unflattenResourceMap(booking.resources);
108
- const capacity = buildCapacityFromBooking(booking.resources);
127
+ const capacity = resolveCapacityFromBooking(booking);
109
128
  const holderId = ((_a = booking.metadata) == null ? void 0 : _a.holder_id) ?? booking.holder_id;
110
129
  const other = {
111
130
  product_variant_id: product.product_variant_id ?? 0,
@@ -131,8 +150,22 @@ function buildCacheItemFromOrderLine(input) {
131
150
  capacity,
132
151
  holder_id: holderId,
133
152
  other,
134
- like_status: booking.like_status || "common"
153
+ like_status: booking.like_status || "common",
154
+ discount_reason: (0, import_manualProductDiscount.resolveManualDiscountMessage)(
155
+ product.discount_list,
156
+ (_e = product.metadata) == null ? void 0 : _e.product_discount_reason
157
+ ) || void 0
135
158
  };
159
+ const manualDiscount = (product.discount_list || []).find((d) => (d == null ? void 0 : d.type) === "product");
160
+ if (manualDiscount && extend.origin_total === selling) {
161
+ const manualAmount = Number(manualDiscount.amount ?? 0);
162
+ if (Number.isFinite(manualAmount) && manualAmount > 0) {
163
+ extend.origin_total = selling + manualAmount;
164
+ }
165
+ }
166
+ if (((_f = product.metadata) == null ? void 0 : _f.price_override) != null || manualDiscount) {
167
+ extend.priceOverride = selling;
168
+ }
136
169
  if (booking.holder !== void 0) {
137
170
  extend.holder = booking.holder;
138
171
  }
@@ -143,8 +176,8 @@ function buildCacheItemFromOrderLine(input) {
143
176
  ...sourceProduct || {},
144
177
  id: resolvedId,
145
178
  product_id: resolvedId,
146
- extension_type: (sourceProduct == null ? void 0 : sourceProduct.extension_type) ?? ((_e = booking == null ? void 0 : booking.product) == null ? void 0 : _e.extension_type) ?? (sourceProduct == null ? void 0 : sourceProduct.extension_type),
147
- title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_f = booking == null ? void 0 : booking.product) == null ? void 0 : _f.title),
179
+ extension_type: (sourceProduct == null ? void 0 : sourceProduct.extension_type) ?? ((_g = booking == null ? void 0 : booking.product) == null ? void 0 : _g.extension_type) ?? (sourceProduct == null ? void 0 : sourceProduct.extension_type),
180
+ title: (sourceProduct == null ? void 0 : sourceProduct.title) ?? ((_h = booking == null ? void 0 : booking.product) == null ? void 0 : _h.title),
148
181
  price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? selling,
149
182
  selling_price: product.selling_price,
150
183
  original_price: product.original_price,
@@ -50,11 +50,21 @@ export interface BookingResourceInput {
50
50
  metadata?: Record<string, any>;
51
51
  children?: any[];
52
52
  }
53
+ /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
54
+ export interface BookingCapacityMetadataItem {
55
+ id: string | number;
56
+ value: number;
57
+ name?: Record<string, any> | string;
58
+ }
53
59
  export interface BookingMetadataInput {
54
60
  /** 由 OS createLinkedProductAndBooking 统一改写,这里不生成。 */
55
61
  unique_identification_number?: string;
56
62
  collect_pax?: number;
57
- capacity?: number;
63
+ /**
64
+ * 资源容量快照:custom 多维度时为 `{ id, value, name? }[]`;
65
+ * 仅总和场景可为 number(capacity_snapshot 兼容)。
66
+ */
67
+ capacity?: number | BookingCapacityMetadataItem[];
58
68
  /** 协议要求始终提交(即使为 null)。 */
59
69
  holder_id: any;
60
70
  resource_select_type?: 'single' | 'multiple' | string;
@@ -36,6 +36,24 @@ var import_dayjs = __toESM(require("dayjs"));
36
36
  var import_serviceTimes = require("./serviceTimes");
37
37
  var import_resources = require("./resources");
38
38
  var import_flexible = require("./flexible");
39
+ function normalizeExtendCapacityForMetadata(capacity) {
40
+ if (!Array.isArray(capacity) || capacity.length === 0)
41
+ return void 0;
42
+ const normalized = capacity.map((item) => {
43
+ if (!item || typeof item !== "object")
44
+ return null;
45
+ if (item.id === void 0 || item.id === null)
46
+ return null;
47
+ const row = {
48
+ id: item.id,
49
+ value: Number(item.value ?? 0)
50
+ };
51
+ if (item.name !== void 0)
52
+ row.name = item.name;
53
+ return row;
54
+ }).filter((item) => item != null);
55
+ return normalized.length > 0 ? normalized : void 0;
56
+ }
39
57
  function safeFormat(value, fmt) {
40
58
  if (value === void 0 || value === null)
41
59
  return void 0;
@@ -158,7 +176,10 @@ function cacheItemToBookingInput(cacheItem, options) {
158
176
  }
159
177
  if (ext.collect_pax !== void 0)
160
178
  metadata.collect_pax = ext.collect_pax;
161
- if (ext.capacity_snapshot !== void 0) {
179
+ const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
180
+ if (extendCapacity) {
181
+ metadata.capacity = extendCapacity;
182
+ } else if (ext.capacity_snapshot !== void 0) {
162
183
  metadata.capacity = ext.capacity_snapshot;
163
184
  }
164
185
  const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
@@ -24,6 +24,12 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
24
24
  * @param operation 操作名称
25
25
  */
26
26
  private handleCustomerListError;
27
+ /**
28
+ * 查询客户列表但不写入 customerList / pagination 状态。
29
+ *
30
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
31
+ */
32
+ queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
27
33
  /**
28
34
  * 获取客户列表
29
35
  * @param params 查询参数
@@ -75,7 +75,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
75
75
  } else {
76
76
  this.store.currentPage = 1;
77
77
  }
78
- if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number") {
78
+ if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number" && options.initialState.pageSize > 1) {
79
79
  this.store.pageSize = options.initialState.pageSize;
80
80
  } else {
81
81
  this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
@@ -152,6 +152,20 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
152
152
  this.store.error
153
153
  );
154
154
  }
155
+ /**
156
+ * 查询客户列表但不写入 customerList / pagination 状态。
157
+ *
158
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
159
+ */
160
+ async queryCustomerList(params = {}) {
161
+ const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
162
+ return {
163
+ list: customerList,
164
+ total,
165
+ page,
166
+ pageSize
167
+ };
168
+ }
155
169
  /**
156
170
  * 获取客户列表
157
171
  * @param params 查询参数
@@ -352,12 +366,13 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
352
366
  try {
353
367
  this.store.loadingMore = true;
354
368
  this.store.error = null;
355
- const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
369
+ const loadMoreParams = {
356
370
  skip: nextPage,
357
371
  num: this.store.pageSize,
358
372
  ...this.store.searchParams
359
373
  // 使用存储的搜索条件
360
- });
374
+ };
375
+ const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData(loadMoreParams);
361
376
  const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
362
377
  this.store.customerList = updatedCustomerList;
363
378
  this.store.currentPage = page;
@@ -110,6 +110,8 @@ export interface CustomerState {
110
110
  export interface CustomerModuleAPI {
111
111
  /** 获取客户列表 */
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
+ /** 查询客户列表但不更新列表分页状态 */
114
+ queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
115
  /** 设置客户列表 */
114
116
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
115
117
  /** 设置当前选择的客户 */
@@ -103,10 +103,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
103
103
  updateTempOrderShopDiscount(amount: string | number): string;
104
104
  updateTempOrderBuzzer(buzzer: string): string;
105
105
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
106
+ private buildTempOrderCustomer;
106
107
  /**
107
108
  * 更新当前 tempOrder 的客户协议字段。
108
109
  *
109
- * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
110
+ * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
110
111
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
111
112
  */
112
113
  updateTempOrderCustomer(customer: UpdateTempOrderCustomerInput): OrderSnapshot['customer'];
@@ -184,7 +185,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
184
185
  private logSubmitBackendRejected;
185
186
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
186
187
  createOrder(params: CommitOrderParams['query']): {
187
- type: "appointment_booking" | "virtual";
188
+ type: "virtual" | "appointment_booking";
188
189
  platform: string;
189
190
  sales_channel: string;
190
191
  order_sales_channel: string;
@@ -38,6 +38,7 @@ var import_utils = require("./utils");
38
38
  var import_utils2 = require("../Product/utils");
39
39
  var import_dayjs = __toESM(require("dayjs"));
40
40
  var import_utils3 = require("../../solution/ScanOrder/utils");
41
+ var import_manualProductDiscount = require("./utils/manualProductDiscount");
41
42
  var import_Discount = require("../Discount");
42
43
  var import_Rules = require("../Rules");
43
44
  var import_types2 = require("../Rules/types");
@@ -272,7 +273,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
272
273
  orderTotalAmount: Number(((_d = this.store.summary) == null ? void 0 : _d.total_amount) || 0)
273
274
  });
274
275
  if (result == null ? void 0 : result.productList) {
275
- tempOrder.products = result.productList;
276
+ tempOrder.products = (result.productList || []).map((product) => ({
277
+ ...product,
278
+ discount_list: (0, import_manualProductDiscount.syncManualProductDiscountProductNum)(
279
+ product.discount_list,
280
+ product.num
281
+ )
282
+ }));
276
283
  }
277
284
  if (result == null ? void 0 : result.discountList) {
278
285
  OrderModule.populateSavedAmounts(
@@ -878,10 +885,29 @@ var OrderModule = class extends import_BaseModule.BaseModule {
878
885
  this.persistTempOrder();
879
886
  return tempOrder.contacts_info;
880
887
  }
888
+ buildTempOrderCustomer(params) {
889
+ if (!params.customerId)
890
+ return null;
891
+ const source = params.source ? (0, import_lodash_es.cloneDeep)(params.source) : {};
892
+ const name = source.name ?? source.display_name ?? source.customerName ?? source.customer_name ?? params.customerName;
893
+ const customerName = source.customer_name ?? source.customerName ?? source.display_name ?? source.name ?? params.customerName;
894
+ return {
895
+ ...source,
896
+ id: source.id ?? params.customerId,
897
+ customer_id: source.customer_id ?? params.customerId,
898
+ name: String(name || ""),
899
+ customer_name: String(customerName || ""),
900
+ country_calling_code: String(
901
+ source.country_calling_code ?? source.countryCallingCode ?? params.countryCallingCode
902
+ ),
903
+ phone: String(source.phone ?? params.phone),
904
+ email: String(source.email ?? params.email)
905
+ };
906
+ }
881
907
  /**
882
908
  * 更新当前 tempOrder 的客户协议字段。
883
909
  *
884
- * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
910
+ * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
885
911
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
886
912
  */
887
913
  updateTempOrderCustomer(customer) {
@@ -895,6 +921,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
895
921
  );
896
922
  tempOrder.phone = String(customer.phone || "");
897
923
  tempOrder.email = String(customer.email || "");
924
+ tempOrder.customer = this.buildTempOrderCustomer({
925
+ source: customer,
926
+ customerId: tempOrder.customer_id,
927
+ customerName: tempOrder.customer_name,
928
+ countryCallingCode: tempOrder.country_calling_code,
929
+ phone: tempOrder.phone,
930
+ email: tempOrder.email
931
+ });
898
932
  this.persistTempOrder();
899
933
  return {
900
934
  customerId: tempOrder.customer_id,
@@ -914,6 +948,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
914
948
  tempOrder.country_calling_code = String(patch.country_calling_code || "");
915
949
  tempOrder.phone = String(patch.phone || "");
916
950
  tempOrder.email = String(patch.email || "");
951
+ tempOrder.customer = this.buildTempOrderCustomer({
952
+ source: snapshot || null,
953
+ customerId: tempOrder.customer_id,
954
+ customerName: tempOrder.customer_name,
955
+ countryCallingCode: tempOrder.country_calling_code,
956
+ phone: tempOrder.phone,
957
+ email: tempOrder.email
958
+ });
917
959
  if (snapshot !== void 0) {
918
960
  const extend = this.ensureExtend(tempOrder);
919
961
  if (snapshot === null)
@@ -945,11 +987,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
945
987
  }
946
988
  clearOrderCustomer() {
947
989
  const tempOrder = this.ensureTempOrder();
948
- tempOrder.customer_id = 0;
990
+ tempOrder.customer_id = null;
949
991
  tempOrder.customer_name = "";
950
992
  tempOrder.country_calling_code = "";
951
993
  tempOrder.phone = "";
952
994
  tempOrder.email = "";
995
+ tempOrder.customer = null;
953
996
  if (tempOrder._extend)
954
997
  delete tempOrder._extend.customerSnapshot;
955
998
  this.persistTempOrder();