@pisell/pisellos 2.2.167 → 2.2.169

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 (54) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +51 -15
  2. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  3. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +26 -2
  4. package/dist/modules/Customer/index.d.ts +6 -0
  5. package/dist/modules/Customer/index.js +122 -77
  6. package/dist/modules/Customer/types.d.ts +2 -0
  7. package/dist/modules/Discount/types.d.ts +1 -0
  8. package/dist/modules/Order/index.d.ts +5 -10
  9. package/dist/modules/Order/index.js +53 -9
  10. package/dist/modules/Order/types.d.ts +8 -0
  11. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  12. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  13. package/dist/modules/Order/utils.d.ts +4 -0
  14. package/dist/modules/Order/utils.js +25 -10
  15. package/dist/modules/Rules/index.d.ts +4 -0
  16. package/dist/modules/Rules/index.js +26 -10
  17. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  18. package/dist/solution/BaseSales/index.js +11 -5
  19. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +37 -6
  20. package/dist/solution/BaseSales/utils.js +11 -2
  21. package/dist/solution/BookingByStep/index.d.ts +1 -1
  22. package/dist/solution/BookingTicket/index.d.ts +9 -0
  23. package/dist/solution/BookingTicket/index.js +372 -192
  24. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
  25. package/dist/solution/ScanOrder/utils.js +11 -2
  26. package/dist/solution/VenueBooking/index.d.ts +1 -6
  27. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  28. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +42 -9
  29. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  30. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +22 -1
  31. package/lib/modules/Customer/index.d.ts +6 -0
  32. package/lib/modules/Customer/index.js +18 -3
  33. package/lib/modules/Customer/types.d.ts +2 -0
  34. package/lib/modules/Discount/types.d.ts +1 -0
  35. package/lib/modules/Order/index.d.ts +5 -10
  36. package/lib/modules/Order/index.js +52 -5
  37. package/lib/modules/Order/types.d.ts +8 -0
  38. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  39. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  40. package/lib/modules/Order/utils.d.ts +4 -0
  41. package/lib/modules/Order/utils.js +46 -10
  42. package/lib/modules/Rules/index.d.ts +4 -0
  43. package/lib/modules/Rules/index.js +22 -14
  44. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  45. package/lib/solution/BaseSales/index.js +6 -0
  46. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +42 -4
  47. package/lib/solution/BaseSales/utils.js +10 -2
  48. package/lib/solution/BookingByStep/index.d.ts +1 -1
  49. package/lib/solution/BookingTicket/index.d.ts +9 -0
  50. package/lib/solution/BookingTicket/index.js +78 -1
  51. package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -1
  52. package/lib/solution/ScanOrder/utils.js +10 -2
  53. package/lib/solution/VenueBooking/index.d.ts +1 -6
  54. package/package.json +1 -1
@@ -1,16 +1,17 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
2
  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."); }
4
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  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; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  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); }
13
13
  import dayjs from 'dayjs';
14
+ import { resolveManualDiscountMessage } from "../../Order/utils/manualProductDiscount";
14
15
  function safeFormat(value, fmt) {
15
16
  if (value === undefined || value === null) return undefined;
16
17
  var d = dayjs(value);
@@ -52,16 +53,37 @@ function unflattenResourceMap(resources) {
52
53
  });
53
54
  return map;
54
55
  }
55
- function buildCapacityFromBooking(resources) {
56
- if (!Array.isArray(resources)) return [];
57
- return resources.filter(function (r) {
58
- return (r === null || r === void 0 ? void 0 : r.relation_id) !== undefined && (r === null || r === void 0 ? void 0 : r.relation_id) !== null && r.capacity !== undefined;
59
- }).map(function (r) {
60
- return {
61
- id: r.relation_id,
62
- value: Number(r.capacity || 0)
63
- };
64
- });
56
+
57
+ /**
58
+ * 从 booking.metadata.capacity 还原 `_extend.capacity`(与 info2 ticketBooking getCapacity 对齐)。
59
+ * 勿用 resources[].relation_id 反推人数维度 id。
60
+ */
61
+ function resolveCapacityFromBooking(booking) {
62
+ var _booking$metadata;
63
+ var metaCap = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.capacity;
64
+ if (Array.isArray(metaCap) && metaCap.length > 0) {
65
+ return metaCap.map(function (item) {
66
+ var _item$value;
67
+ if (!item || _typeof(item) !== 'object') return null;
68
+ if (item.id === undefined || item.id === null) return null;
69
+ var row = {
70
+ id: item.id,
71
+ value: Number((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0)
72
+ };
73
+ if (item.name !== undefined) row.name = item.name;
74
+ return row;
75
+ }).filter(function (item) {
76
+ return item != null;
77
+ });
78
+ }
79
+ if (typeof metaCap === 'number' && Number.isFinite(metaCap)) {
80
+ return [{
81
+ id: 0,
82
+ value: metaCap,
83
+ name: ''
84
+ }];
85
+ }
86
+ return [];
65
87
  }
66
88
  function resolveDurationForExtend(booking) {
67
89
  var duration = booking.duration;
@@ -81,7 +103,7 @@ function resolveDurationForExtend(booking) {
81
103
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
82
104
  */
83
105
  export function buildCacheItemFromOrderLine(input) {
84
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata, _product$product_vari, _product$num, _ref, _ref2, _title, _booking$product, _booking$detail, _ref3, _product$note, _booking$detail2, _ref4, _extension_type, _booking$product2, _title2, _booking$product3, _price, _product$order_detail, _ref5, _booking$id;
106
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref, _ref2, _title, _booking$product, _booking$detail, _ref3, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref4, _extension_type, _booking$product2, _title2, _booking$product3, _price, _product$order_detail, _ref5, _booking$id;
85
107
  var product = input.product,
86
108
  booking = input.booking,
87
109
  sourceProduct = input.sourceProduct;
@@ -93,8 +115,8 @@ export function buildCacheItemFromOrderLine(input) {
93
115
  var startTime = normalizeTimeString(booking.start_time);
94
116
  var endTime = normalizeTimeString(booking.end_time);
95
117
  var resource = unflattenResourceMap(booking.resources);
96
- var capacity = buildCapacityFromBooking(booking.resources);
97
- var holderId = (_booking$metadata$hol = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
118
+ var capacity = resolveCapacityFromBooking(booking);
119
+ var holderId = (_booking$metadata$hol = (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.holder_id) !== null && _booking$metadata$hol !== void 0 ? _booking$metadata$hol : booking.holder_id;
98
120
  var other = {
99
121
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
100
122
  option: Array.isArray(product.product_option_item) ? _toConsumableArray(product.product_option_item) : [],
@@ -119,8 +141,22 @@ export function buildCacheItemFromOrderLine(input) {
119
141
  capacity: capacity,
120
142
  holder_id: holderId,
121
143
  other: other,
122
- like_status: booking.like_status || 'common'
144
+ like_status: booking.like_status || 'common',
145
+ discount_reason: resolveManualDiscountMessage(product.discount_list, (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_reason) || undefined
123
146
  };
147
+ var manualDiscount = (product.discount_list || []).find(function (d) {
148
+ return (d === null || d === void 0 ? void 0 : d.type) === 'product';
149
+ });
150
+ if (manualDiscount && extend.origin_total === selling) {
151
+ var _manualDiscount$amoun;
152
+ var manualAmount = Number((_manualDiscount$amoun = manualDiscount.amount) !== null && _manualDiscount$amoun !== void 0 ? _manualDiscount$amoun : 0);
153
+ if (Number.isFinite(manualAmount) && manualAmount > 0) {
154
+ extend.origin_total = selling + manualAmount;
155
+ }
156
+ }
157
+ if (((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.price_override) != null || manualDiscount) {
158
+ extend.priceOverride = selling;
159
+ }
124
160
  if (booking.holder !== undefined) {
125
161
  extend.holder = booking.holder;
126
162
  }
@@ -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;
@@ -1,9 +1,9 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
2
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
3
  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
4
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
5
  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); }
6
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
7
  import dayjs from 'dayjs';
8
8
  import { isMultiDayProduct, isSessionProduct, getDays } from "./serviceTimes";
9
9
  import { getSumCapacity } from "./resources";
@@ -28,6 +28,26 @@ import { flexibleObj } from "./flexible";
28
28
  * 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
29
29
  */
30
30
 
31
+ /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
32
+
33
+ /** 将 UI `_extend.capacity[]` 规范化为 booking.metadata.capacity。 */
34
+ function normalizeExtendCapacityForMetadata(capacity) {
35
+ if (!Array.isArray(capacity) || capacity.length === 0) return undefined;
36
+ var normalized = capacity.map(function (item) {
37
+ var _item$value;
38
+ if (!item || _typeof(item) !== 'object') return null;
39
+ if (item.id === undefined || item.id === null) return null;
40
+ var row = {
41
+ id: item.id,
42
+ value: Number((_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0)
43
+ };
44
+ if (item.name !== undefined) row.name = item.name;
45
+ return row;
46
+ }).filter(function (item) {
47
+ return item != null;
48
+ });
49
+ return normalized.length > 0 ? normalized : undefined;
50
+ }
31
51
  function safeFormat(value, fmt) {
32
52
  if (value === undefined || value === null) return undefined;
33
53
  var d = dayjs(value);
@@ -174,7 +194,11 @@ export function cacheItemToBookingInput(cacheItem, options) {
174
194
  metadata.holder_id = ext.holder_id;
175
195
  }
176
196
  if (ext.collect_pax !== undefined) metadata.collect_pax = ext.collect_pax;
177
- if (ext.capacity_snapshot !== undefined) {
197
+ // info2 formatMetaData 一致:优先写入完整人数维度数组,供编辑回显 / 详情回灌。
198
+ var extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
199
+ if (extendCapacity) {
200
+ metadata.capacity = extendCapacity;
201
+ } else if (ext.capacity_snapshot !== undefined) {
178
202
  metadata.capacity = ext.capacity_snapshot;
179
203
  }
180
204
  var selectType = deriveResourceSelectType(cacheItem) || (options === null || options === void 0 || (_options$bookingConfi = options.bookingConfig) === null || _options$bookingConfi === void 0 ? void 0 : _options$bookingConfi.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 查询参数
@@ -95,7 +95,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
95
95
  } else {
96
96
  this.store.currentPage = 1;
97
97
  }
98
- if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number') {
98
+ if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number' && options.initialState.pageSize > 1) {
99
99
  this.store.pageSize = options.initialState.pageSize;
100
100
  } else {
101
101
  this.store.pageSize = DEFAULT_PAGE_SIZE;
@@ -236,6 +236,52 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
236
236
  }
237
237
  return handleCustomerListError;
238
238
  }()
239
+ /**
240
+ * 查询客户列表但不写入 customerList / pagination 状态。
241
+ *
242
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
243
+ */
244
+ )
245
+ }, {
246
+ key: "queryCustomerList",
247
+ value: (function () {
248
+ var _queryCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
249
+ var params,
250
+ _yield$this$fetchCust,
251
+ customerList,
252
+ total,
253
+ page,
254
+ pageSize,
255
+ _args4 = arguments;
256
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
257
+ while (1) switch (_context4.prev = _context4.next) {
258
+ case 0:
259
+ params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
260
+ _context4.next = 3;
261
+ return this.fetchCustomerListData(params);
262
+ case 3:
263
+ _yield$this$fetchCust = _context4.sent;
264
+ customerList = _yield$this$fetchCust.customerList;
265
+ total = _yield$this$fetchCust.total;
266
+ page = _yield$this$fetchCust.page;
267
+ pageSize = _yield$this$fetchCust.pageSize;
268
+ return _context4.abrupt("return", {
269
+ list: customerList,
270
+ total: total,
271
+ page: page,
272
+ pageSize: pageSize
273
+ });
274
+ case 9:
275
+ case "end":
276
+ return _context4.stop();
277
+ }
278
+ }, _callee4, this);
279
+ }));
280
+ function queryCustomerList() {
281
+ return _queryCustomerList.apply(this, arguments);
282
+ }
283
+ return queryCustomerList;
284
+ }()
239
285
  /**
240
286
  * 获取客户列表
241
287
  * @param params 查询参数
@@ -245,9 +291,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
245
291
  }, {
246
292
  key: "getCustomerList",
247
293
  value: (function () {
248
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
294
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
249
295
  var params,
250
- _yield$this$fetchCust,
296
+ _yield$this$fetchCust2,
251
297
  customerList,
252
298
  total,
253
299
  page,
@@ -256,22 +302,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
256
302
  num,
257
303
  searchParams,
258
304
  response,
259
- _args4 = arguments;
260
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
261
- while (1) switch (_context4.prev = _context4.next) {
305
+ _args5 = arguments;
306
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
307
+ while (1) switch (_context5.prev = _context5.next) {
262
308
  case 0:
263
- params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
264
- _context4.prev = 1;
309
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
310
+ _context5.prev = 1;
265
311
  this.store.loading = true;
266
312
  this.store.error = null;
267
- _context4.next = 6;
313
+ _context5.next = 6;
268
314
  return this.fetchCustomerListData(params);
269
315
  case 6:
270
- _yield$this$fetchCust = _context4.sent;
271
- customerList = _yield$this$fetchCust.customerList;
272
- total = _yield$this$fetchCust.total;
273
- page = _yield$this$fetchCust.page;
274
- pageSize = _yield$this$fetchCust.pageSize;
316
+ _yield$this$fetchCust2 = _context5.sent;
317
+ customerList = _yield$this$fetchCust2.customerList;
318
+ total = _yield$this$fetchCust2.total;
319
+ page = _yield$this$fetchCust2.page;
320
+ pageSize = _yield$this$fetchCust2.pageSize;
275
321
  // 保存搜索条件(排除skip和num)
276
322
  skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
277
323
  this.store.searchParams = cloneDeep(searchParams);
@@ -300,27 +346,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
300
346
  page: page,
301
347
  pageSize: pageSize
302
348
  };
303
- return _context4.abrupt("return", response);
349
+ return _context5.abrupt("return", response);
304
350
  case 23:
305
- _context4.prev = 23;
306
- _context4.t0 = _context4["catch"](1);
307
- _context4.next = 27;
308
- return this.handleCustomerListError(_context4.t0, 'fetch customer list');
351
+ _context5.prev = 23;
352
+ _context5.t0 = _context5["catch"](1);
353
+ _context5.next = 27;
354
+ return this.handleCustomerListError(_context5.t0, 'fetch customer list');
309
355
  case 27:
310
- throw _context4.t0;
356
+ throw _context5.t0;
311
357
  case 28:
312
- _context4.prev = 28;
358
+ _context5.prev = 28;
313
359
  this.store.loading = false;
314
360
  this.storeChange();
315
- _context4.next = 33;
361
+ _context5.next = 33;
316
362
  return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
317
363
  case 33:
318
- return _context4.finish(28);
364
+ return _context5.finish(28);
319
365
  case 34:
320
366
  case "end":
321
- return _context4.stop();
367
+ return _context5.stop();
322
368
  }
323
- }, _callee4, this, [[1, 23, 28, 34]]);
369
+ }, _callee5, this, [[1, 23, 28, 34]]);
324
370
  }));
325
371
  function getCustomerList() {
326
372
  return _getCustomerList.apply(this, arguments);
@@ -494,10 +540,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
494
540
  }, {
495
541
  key: "changeCustomerPage",
496
542
  value: (function () {
497
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
543
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, pageSize) {
498
544
  var targetPageSize, skip, num;
499
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
500
- while (1) switch (_context5.prev = _context5.next) {
545
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
546
+ while (1) switch (_context6.prev = _context6.next) {
501
547
  case 0:
502
548
  targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
503
549
  this.setPaginationInfo(page, targetPageSize);
@@ -505,18 +551,18 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
505
551
  // skip直接使用page,num使用pageSize
506
552
  skip = page;
507
553
  num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
508
- _context5.next = 6;
554
+ _context6.next = 6;
509
555
  return this.getCustomerList(_objectSpread({
510
556
  skip: skip,
511
557
  num: num
512
558
  }, this.store.searchParams));
513
559
  case 6:
514
- return _context5.abrupt("return", _context5.sent);
560
+ return _context6.abrupt("return", _context6.sent);
515
561
  case 7:
516
562
  case "end":
517
- return _context5.stop();
563
+ return _context6.stop();
518
564
  }
519
- }, _callee5, this);
565
+ }, _callee6, this);
520
566
  }));
521
567
  function changeCustomerPage(_x5, _x6) {
522
568
  return _changeCustomerPage.apply(this, arguments);
@@ -531,16 +577,16 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
531
577
  }, {
532
578
  key: "loadMoreCustomers",
533
579
  value: (function () {
534
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
535
- var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
536
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
537
- while (1) switch (_context6.prev = _context6.next) {
580
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
581
+ var nextPage, loadMoreParams, _yield$this$fetchCust3, newCustomers, total, page, pageSize, updatedCustomerList, response;
582
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
583
+ while (1) switch (_context7.prev = _context7.next) {
538
584
  case 0:
539
585
  if (!(!this.store.hasMore || this.store.loadingMore)) {
540
- _context6.next = 2;
586
+ _context7.next = 2;
541
587
  break;
542
588
  }
543
- return _context6.abrupt("return", {
589
+ return _context7.abrupt("return", {
544
590
  list: [],
545
591
  total: this.store.total,
546
592
  page: this.store.currentPage,
@@ -549,22 +595,21 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
549
595
  case 2:
550
596
  // 计算下一页
551
597
  nextPage = this.store.currentPage + 1;
552
- _context6.prev = 3;
598
+ _context7.prev = 3;
553
599
  this.store.loadingMore = true;
554
600
  this.store.error = null;
555
-
556
- // 使用公共方法获取数据,传入存储的搜索条件
557
- _context6.next = 8;
558
- return this.fetchCustomerListData(_objectSpread({
601
+ loadMoreParams = _objectSpread({
559
602
  skip: nextPage,
560
603
  num: this.store.pageSize
561
- }, this.store.searchParams));
562
- case 8:
563
- _yield$this$fetchCust2 = _context6.sent;
564
- newCustomers = _yield$this$fetchCust2.customerList;
565
- total = _yield$this$fetchCust2.total;
566
- page = _yield$this$fetchCust2.page;
567
- pageSize = _yield$this$fetchCust2.pageSize;
604
+ }, this.store.searchParams); // 使用公共方法获取数据,传入存储的搜索条件
605
+ _context7.next = 9;
606
+ return this.fetchCustomerListData(loadMoreParams);
607
+ case 9:
608
+ _yield$this$fetchCust3 = _context7.sent;
609
+ newCustomers = _yield$this$fetchCust3.customerList;
610
+ total = _yield$this$fetchCust3.total;
611
+ page = _yield$this$fetchCust3.page;
612
+ pageSize = _yield$this$fetchCust3.pageSize;
568
613
  // 将新数据追加到现有列表(追加模式)
569
614
  updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
570
615
  this.store.customerList = updatedCustomerList;
@@ -573,14 +618,14 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
573
618
  this.store.hasMore = page * pageSize < total;
574
619
 
575
620
  // 触发滚动加载特定事件
576
- _context6.next = 20;
621
+ _context7.next = 21;
577
622
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
578
623
  newCustomers: newCustomers,
579
624
  allCustomers: this.store.customerList,
580
625
  currentPage: page,
581
626
  hasMore: this.store.hasMore
582
627
  });
583
- case 20:
628
+ case 21:
584
629
  // 触发分页变化事件
585
630
  this.triggerPaginationChange({
586
631
  page: page,
@@ -595,27 +640,27 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
595
640
  page: page,
596
641
  pageSize: pageSize
597
642
  };
598
- return _context6.abrupt("return", response);
599
- case 25:
600
- _context6.prev = 25;
601
- _context6.t0 = _context6["catch"](3);
602
- _context6.next = 29;
603
- return this.handleCustomerListError(_context6.t0, 'load more customers');
604
- case 29:
605
- throw _context6.t0;
643
+ return _context7.abrupt("return", response);
644
+ case 26:
645
+ _context7.prev = 26;
646
+ _context7.t0 = _context7["catch"](3);
647
+ _context7.next = 30;
648
+ return this.handleCustomerListError(_context7.t0, 'load more customers');
606
649
  case 30:
607
- _context6.prev = 30;
650
+ throw _context7.t0;
651
+ case 31:
652
+ _context7.prev = 31;
608
653
  this.store.loadingMore = false;
609
654
  this.storeChange();
610
- _context6.next = 35;
655
+ _context7.next = 36;
611
656
  return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
612
- case 35:
613
- return _context6.finish(30);
614
657
  case 36:
658
+ return _context7.finish(31);
659
+ case 37:
615
660
  case "end":
616
- return _context6.stop();
661
+ return _context7.stop();
617
662
  }
618
- }, _callee6, this, [[3, 25, 30, 36]]);
663
+ }, _callee7, this, [[3, 26, 31, 37]]);
619
664
  }));
620
665
  function loadMoreCustomers() {
621
666
  return _loadMoreCustomers.apply(this, arguments);
@@ -631,15 +676,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
631
676
  }, {
632
677
  key: "resetAndLoadCustomers",
633
678
  value: (function () {
634
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
679
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
635
680
  var params,
636
681
  resetParams,
637
682
  response,
638
- _args7 = arguments;
639
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
640
- while (1) switch (_context7.prev = _context7.next) {
683
+ _args8 = arguments;
684
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
685
+ while (1) switch (_context8.prev = _context8.next) {
641
686
  case 0:
642
- params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
687
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
643
688
  // 重置状态
644
689
  this.store.customerList = [];
645
690
  this.store.currentPage = 1;
@@ -651,23 +696,23 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
651
696
  skip: 1,
652
697
  num: params.num || this.store.pageSize
653
698
  }); // 调用普通的获取列表方法
654
- _context7.next = 8;
699
+ _context8.next = 8;
655
700
  return this.getCustomerList(resetParams);
656
701
  case 8:
657
- response = _context7.sent;
658
- _context7.next = 11;
702
+ response = _context8.sent;
703
+ _context8.next = 11;
659
704
  return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
660
705
  customers: this.store.customerList,
661
706
  total: this.store.total,
662
707
  hasMore: this.store.hasMore
663
708
  });
664
709
  case 11:
665
- return _context7.abrupt("return", response);
710
+ return _context8.abrupt("return", response);
666
711
  case 12:
667
712
  case "end":
668
- return _context7.stop();
713
+ return _context8.stop();
669
714
  }
670
- }, _callee7, this);
715
+ }, _callee8, this);
671
716
  }));
672
717
  function resetAndLoadCustomers() {
673
718
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -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
  /** 设置当前选择的客户 */
@@ -135,6 +135,7 @@ export interface Discount {
135
135
  appliedProductDetails: ApplicableProductDetails[];
136
136
  isDisabledForProductUsed?: boolean;
137
137
  amount?: number;
138
+ customer_id?: number | string | null;
138
139
  extension_data?: ExtensionData[];
139
140
  total_order_behavior_count?: number;
140
141
  today_order_behavior_count?: number;
@@ -3,10 +3,9 @@ import { BaseModule } from '../BaseModule';
3
3
  import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
- import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderScanCodeResult, ReplaceTempOrderOptions } from './types';
7
7
  import type { ICustomer } from '../AccountList/types';
8
8
  import type { Discount } from '../Discount/types';
9
- import { UnavailableReason } from '../Rules/types';
10
9
  export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
11
10
  protected defaultName: string;
12
11
  protected defaultVersion: string;
@@ -48,12 +47,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
48
47
  apply?: boolean;
49
48
  }): Promise<Discount[]>;
50
49
  getDiscountList(): Discount[];
51
- scanCode(code: string, customerId?: number): Promise<{
52
- isAvailable: boolean;
53
- discountList: Discount[];
54
- type: 'server' | 'clientCalc';
55
- unavailableReason?: UnavailableReason;
56
- }>;
50
+ scanCode(code: string, customerId?: number): Promise<OrderScanCodeResult>;
57
51
  applyDiscount(): void;
58
52
  initTempOrder(params: {
59
53
  cacheId?: string;
@@ -109,10 +103,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
109
103
  updateTempOrderShopDiscount(amount: string | number): string;
110
104
  updateTempOrderBuzzer(buzzer: string): string;
111
105
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
106
+ private buildTempOrderCustomer;
112
107
  /**
113
108
  * 更新当前 tempOrder 的客户协议字段。
114
109
  *
115
- * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
110
+ * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
116
111
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
117
112
  */
118
113
  updateTempOrderCustomer(customer: UpdateTempOrderCustomerInput): OrderSnapshot['customer'];
@@ -190,7 +185,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
190
185
  private logSubmitBackendRejected;
191
186
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
192
187
  createOrder(params: CommitOrderParams['query']): {
193
- type: "virtual" | "appointment_booking";
188
+ type: "appointment_booking" | "virtual";
194
189
  platform: string;
195
190
  sales_channel: string;
196
191
  order_sales_channel: string;