@pisell/pisellos 2.2.181 → 2.2.183

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 (173) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.d.ts +6 -0
  32. package/dist/modules/Customer/index.js +129 -83
  33. package/dist/modules/Customer/types.d.ts +2 -0
  34. package/dist/modules/Discount/index.js +4 -3
  35. package/dist/modules/Discount/types.d.ts +1 -0
  36. package/dist/modules/Order/index.d.ts +100 -9
  37. package/dist/modules/Order/index.js +1447 -499
  38. package/dist/modules/Order/types.d.ts +201 -18
  39. package/dist/modules/Order/types.js +31 -0
  40. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  41. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  42. package/dist/modules/Order/utils.d.ts +83 -1
  43. package/dist/modules/Order/utils.js +405 -61
  44. package/dist/modules/Product/index.d.ts +1 -1
  45. package/dist/modules/Quotation/index.d.ts +0 -1
  46. package/dist/modules/Quotation/index.js +23 -21
  47. package/dist/modules/Rules/index.d.ts +4 -0
  48. package/dist/modules/Rules/index.js +43 -39
  49. package/dist/modules/Rules/types.d.ts +1 -0
  50. package/dist/modules/SalesSummary/index.js +4 -2
  51. package/dist/modules/SalesSummary/utils.js +21 -7
  52. package/dist/modules/Schedule/index.js +6 -2
  53. package/dist/modules/index.d.ts +1 -0
  54. package/dist/modules/index.js +2 -1
  55. package/dist/server/index.js +87 -29
  56. package/dist/server/modules/order/index.d.ts +23 -0
  57. package/dist/server/modules/order/index.js +123 -46
  58. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  59. package/dist/server/modules/products/index.d.ts +1 -1
  60. package/dist/server/modules/products/index.js +130 -113
  61. package/dist/server/modules/schedule/index.js +13 -6
  62. package/dist/solution/BaseSales/index.d.ts +89 -7
  63. package/dist/solution/BaseSales/index.js +1504 -380
  64. package/dist/solution/BaseSales/types.d.ts +67 -1
  65. package/dist/solution/BaseSales/types.js +3 -1
  66. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  67. package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
  68. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  69. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  70. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
  71. package/dist/solution/BaseSales/utils.js +46 -8
  72. package/dist/solution/BookingByStep/index.d.ts +1 -1
  73. package/dist/solution/BookingTicket/index.d.ts +151 -1
  74. package/dist/solution/BookingTicket/index.js +848 -184
  75. package/dist/solution/BookingTicket/types.d.ts +2 -0
  76. package/dist/solution/BookingTicket/types.js +3 -0
  77. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  78. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  79. package/dist/solution/BookingTicket/utils/cartView.js +4 -2
  80. package/dist/solution/ScanOrder/index.d.ts +9 -3
  81. package/dist/solution/ScanOrder/index.js +231 -128
  82. package/dist/solution/ScanOrder/utils.js +46 -8
  83. package/dist/solution/VenueBooking/index.d.ts +5 -2
  84. package/dist/solution/VenueBooking/index.js +103 -55
  85. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  86. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  87. package/lib/modules/BookingContext/index.d.ts +37 -0
  88. package/lib/modules/BookingContext/index.js +297 -0
  89. package/lib/modules/BookingContext/types.d.ts +102 -0
  90. package/lib/modules/BookingContext/types.js +34 -0
  91. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  92. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +271 -0
  93. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  94. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  95. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  96. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  97. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  98. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  99. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  100. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  101. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  102. package/lib/modules/BookingContext/utils/index.js +43 -0
  103. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  104. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  105. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  106. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  107. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  108. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  109. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  110. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  111. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  112. package/lib/modules/BookingContext/utils/resources.js +377 -0
  113. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  114. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  115. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  116. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  117. package/lib/modules/Customer/index.d.ts +6 -0
  118. package/lib/modules/Customer/index.js +26 -11
  119. package/lib/modules/Customer/types.d.ts +2 -0
  120. package/lib/modules/Discount/index.js +5 -1
  121. package/lib/modules/Discount/types.d.ts +1 -0
  122. package/lib/modules/Order/index.d.ts +100 -9
  123. package/lib/modules/Order/index.js +751 -160
  124. package/lib/modules/Order/types.d.ts +201 -18
  125. package/lib/modules/Order/types.js +1 -0
  126. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  127. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  128. package/lib/modules/Order/utils.d.ts +83 -1
  129. package/lib/modules/Order/utils.js +340 -22
  130. package/lib/modules/Product/index.d.ts +1 -1
  131. package/lib/modules/Quotation/index.d.ts +0 -1
  132. package/lib/modules/Quotation/index.js +18 -15
  133. package/lib/modules/Rules/index.d.ts +4 -0
  134. package/lib/modules/Rules/index.js +26 -27
  135. package/lib/modules/Rules/types.d.ts +1 -0
  136. package/lib/modules/SalesSummary/index.js +4 -2
  137. package/lib/modules/SalesSummary/utils.js +21 -7
  138. package/lib/modules/Schedule/index.js +3 -1
  139. package/lib/modules/index.d.ts +1 -0
  140. package/lib/modules/index.js +3 -1
  141. package/lib/server/index.js +41 -4
  142. package/lib/server/modules/order/index.d.ts +23 -0
  143. package/lib/server/modules/order/index.js +46 -14
  144. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  145. package/lib/server/modules/products/index.d.ts +1 -1
  146. package/lib/server/modules/products/index.js +30 -20
  147. package/lib/server/modules/schedule/index.js +2 -1
  148. package/lib/solution/BaseSales/index.d.ts +89 -7
  149. package/lib/solution/BaseSales/index.js +743 -23
  150. package/lib/solution/BaseSales/types.d.ts +67 -1
  151. package/lib/solution/BaseSales/types.js +3 -1
  152. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  153. package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
  154. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  155. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
  157. package/lib/solution/BaseSales/utils.js +46 -6
  158. package/lib/solution/BookingByStep/index.d.ts +1 -1
  159. package/lib/solution/BookingTicket/index.d.ts +151 -1
  160. package/lib/solution/BookingTicket/index.js +389 -9
  161. package/lib/solution/BookingTicket/types.d.ts +2 -0
  162. package/lib/solution/BookingTicket/types.js +6 -0
  163. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  164. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  165. package/lib/solution/BookingTicket/utils/cartView.js +4 -2
  166. package/lib/solution/ScanOrder/index.d.ts +9 -3
  167. package/lib/solution/ScanOrder/index.js +147 -66
  168. package/lib/solution/ScanOrder/utils.js +46 -6
  169. package/lib/solution/VenueBooking/index.d.ts +5 -2
  170. package/lib/solution/VenueBooking/index.js +50 -14
  171. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  172. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  173. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/BookingContext/utils/timeSlices.ts
30
+ var timeSlices_exports = {};
31
+ __export(timeSlices_exports, {
32
+ findNextDuration: () => findNextDuration,
33
+ findNextSlice: () => findNextSlice,
34
+ getDurationValue: () => import_flexible.getDurationValue,
35
+ getEndDate: () => getEndDate,
36
+ sliceDayIntoFiveMinutes: () => sliceDayIntoFiveMinutes
37
+ });
38
+ module.exports = __toCommonJS(timeSlices_exports);
39
+ var import_dayjs = __toESM(require("dayjs"));
40
+ var import_flexible = require("./flexible");
41
+ function sliceDayIntoFiveMinutes(config, isDay) {
42
+ const startTime = (0, import_dayjs.default)().startOf("day");
43
+ const endTime = (0, import_dayjs.default)().endOf("day");
44
+ const timeSlice = config && config.value || 5;
45
+ const timeSlices = [];
46
+ const durationSlicesBasedOnTime = [];
47
+ let currentTime = startTime;
48
+ if (isDay) {
49
+ let currentDay = 1;
50
+ while (currentDay <= 30) {
51
+ timeSlices.push({
52
+ label: currentTime.format("hh:mm A"),
53
+ value: currentTime.format("HH:mm")
54
+ });
55
+ durationSlicesBasedOnTime.push({
56
+ label: String(currentDay),
57
+ value: currentDay
58
+ });
59
+ currentDay += 1;
60
+ }
61
+ return { timeSlices, durationSlicesBasedOnTime };
62
+ }
63
+ while (currentTime.isBefore(endTime)) {
64
+ timeSlices.push({
65
+ label: currentTime.format("hh:mm A"),
66
+ value: currentTime.format("HH:mm")
67
+ });
68
+ const nextTime = currentTime.add(timeSlice, "minute");
69
+ const durationValue = nextTime.diff(startTime, "minute");
70
+ durationSlicesBasedOnTime.push({
71
+ label: String(durationValue),
72
+ value: durationValue
73
+ });
74
+ currentTime = nextTime;
75
+ }
76
+ return { timeSlices, durationSlicesBasedOnTime };
77
+ }
78
+ function findNextDuration(current, array, defaultValue) {
79
+ if (defaultValue !== void 0 && defaultValue !== null)
80
+ return defaultValue;
81
+ if (!array || array.length === 0)
82
+ return void 0;
83
+ for (let i = 0; i < array.length; i += 1) {
84
+ if (array[i].value === (current == null ? void 0 : current.value))
85
+ return array[i].value;
86
+ }
87
+ return array[0].value;
88
+ }
89
+ function findNextSlice(params) {
90
+ var _a;
91
+ const { timeSlices, index = 0, date = "" } = params;
92
+ const currentTimeValue = date || (0, import_dayjs.default)().format("HH:mm");
93
+ for (let i = 0; i < timeSlices.length; i += 1) {
94
+ if (timeSlices[i].value !== "now" && timeSlices[i].value >= currentTimeValue) {
95
+ return timeSlices[i].value;
96
+ }
97
+ }
98
+ return (_a = timeSlices[index]) == null ? void 0 : _a.value;
99
+ }
100
+ function getEndDate(startDate, duration, endDate, shopOpeningHours) {
101
+ if (duration === "flexible") {
102
+ let openingDate = (0, import_dayjs.default)(
103
+ `${startDate.format("YYYY-MM-DD")} ${shopOpeningHours || "23:59"}`
104
+ );
105
+ if ((0, import_dayjs.default)(startDate).isAfter(openingDate)) {
106
+ openingDate = openingDate.add(1, "day");
107
+ }
108
+ if (!endDate)
109
+ return openingDate;
110
+ const endDateObj = (0, import_dayjs.default)(endDate);
111
+ if (endDateObj.isAfter(openingDate))
112
+ return openingDate;
113
+ return endDateObj;
114
+ }
115
+ return startDate.add(Number(duration), "minute");
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ findNextDuration,
120
+ findNextSlice,
121
+ getDurationValue,
122
+ getEndDate,
123
+ sliceDayIntoFiveMinutes
124
+ });
@@ -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 查询参数
@@ -169,10 +183,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
169
183
  this.store.total = total;
170
184
  this.store.hasMore = page * pageSize < total;
171
185
  this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
172
- await this.core.effects.emit(
173
- `${this.name}:onCustomerListUpdate`,
174
- this.store
175
- );
176
186
  this.triggerPaginationChange({
177
187
  page,
178
188
  pageSize,
@@ -192,6 +202,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
192
202
  } finally {
193
203
  this.store.loading = false;
194
204
  this.storeChange();
205
+ await this.core.effects.emit(
206
+ `${this.name}:onCustomerListUpdate`,
207
+ this.store
208
+ );
195
209
  }
196
210
  }
197
211
  /**
@@ -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;
@@ -372,10 +387,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
372
387
  hasMore: this.store.hasMore
373
388
  }
374
389
  );
375
- await this.core.effects.emit(
376
- `${this.name}:onCustomerListUpdate`,
377
- this.store
378
- );
379
390
  this.triggerPaginationChange({
380
391
  page,
381
392
  pageSize,
@@ -396,6 +407,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
396
407
  } finally {
397
408
  this.store.loadingMore = false;
398
409
  this.storeChange();
410
+ await this.core.effects.emit(
411
+ `${this.name}:onCustomerListUpdate`,
412
+ this.store
413
+ );
399
414
  }
400
415
  }
401
416
  /**
@@ -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
  /** 设置当前选择的客户 */
@@ -97,8 +97,12 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
97
97
  `/order/prepare/config`,
98
98
  params
99
99
  );
100
+ const rawDiscountList = [
101
+ ...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [],
102
+ ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []
103
+ ];
100
104
  const goodPassList = this.filterEnabledDiscountList(
101
- [...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
105
+ rawDiscountList
102
106
  ) || [];
103
107
  return goodPassList;
104
108
  }
@@ -140,6 +140,7 @@ export interface Discount {
140
140
  appliedProductDetails: ApplicableProductDetails[];
141
141
  isDisabledForProductUsed?: boolean;
142
142
  amount?: number;
143
+ customer_id?: number | string | null;
143
144
  extension_data?: ExtensionData[];
144
145
  total_order_behavior_count?: number;
145
146
  today_order_behavior_count?: number;
@@ -1,9 +1,9 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { OrderModuleAPI, CommitOrderParams, UpdateProductInOrderParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
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 } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
7
7
  import type { ICustomer } from '../AccountList/types';
8
8
  import type { Discount } from '../Discount/types';
9
9
  import { UnavailableReason } from '../Rules/types';
@@ -20,11 +20,27 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
20
20
  private rulesHooksOverride?;
21
21
  private orderHooks?;
22
22
  private otherParams?;
23
+ /** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
24
+ private promotionEvaluator;
25
+ /** 赠品选择 resolver;由 SDK host bridge 注入 */
26
+ private giftSelectResolver;
27
+ /** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
28
+ private isApplyingPromotion;
29
+ /** 最近一次 applyPromotion 的未满足促销提示 */
30
+ private lastUnfulfilledPromotions;
31
+ /** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
32
+ private lastGiftActions;
33
+ /**
34
+ * 是否将 tempOrder 写入 IndexedDB 草稿(orders store)。
35
+ * BigSale 弹窗等短生命周期场景通过 setEnableTempOrderPersist(false) 关闭。
36
+ */
37
+ private draftPersistEnabled;
23
38
  /**
24
39
  * Populate `savedAmount` on each discount based on product-level discount details.
25
40
  * Only selected discounts get a non-zero value.
26
41
  */
27
42
  static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
43
+ private applyProductDiscountPrices;
28
44
  constructor(name?: string, version?: string);
29
45
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
30
46
  /**
@@ -43,8 +59,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
43
59
  private createDefaultRulesHooks;
44
60
  loadDiscountConfig(params: {
45
61
  customerId: number;
46
- action?: 'create';
47
- }): Promise<void>;
62
+ action?: 'create' | 'edit';
63
+ orderId?: number;
64
+ apply?: boolean;
65
+ }): Promise<Discount[]>;
48
66
  getDiscountList(): Discount[];
49
67
  scanCode(code: string, customerId?: number): Promise<{
50
68
  isAvailable: boolean;
@@ -52,34 +70,92 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
52
70
  type: 'server' | 'clientCalc';
53
71
  unavailableReason?: UnavailableReason;
54
72
  unavailableReasonKey?: string | null;
73
+ scannedDiscountList?: Discount[];
55
74
  }>;
56
75
  applyDiscount(): void;
76
+ /**
77
+ * 注入促销评估器。
78
+ *
79
+ * @example
80
+ * order.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
81
+ */
82
+ setPromotionEvaluator(evaluator: OrderPromotionEvaluator | null): void;
83
+ /**
84
+ * 注入赠品选择 resolver。OS 需要补赠品时会 await 调用 resolver;缺省时跳过新增并 console.warn。
85
+ *
86
+ * @example
87
+ * order.setGiftSelectResolver(async (ctx) => {
88
+ * // SDK 内部决定弹窗 or 自动选第一项,返回完整 OrderProduct[]
89
+ * return giftSelectBridge.request(ctx);
90
+ * });
91
+ */
92
+ setGiftSelectResolver(resolver: OrderGiftSelectResolver | null): void;
93
+ /**
94
+ * 为商品目录追加促销标签,供上层 Sales 门面复用。
95
+ *
96
+ * @example
97
+ * const products = order.appendPromotionTags(catalogProducts);
98
+ */
99
+ appendPromotionTags<T extends Record<string, any>>(products: T[]): T[];
100
+ /**
101
+ * 应用购物车促销:计算 → 差异化赠品 → 写回 tempOrder.products → emit onPromotionApplied。
102
+ *
103
+ * 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
104
+ *
105
+ * 关键约束:
106
+ * - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
107
+ * - 用 `isApplyingPromotion` 防递归;
108
+ * - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
109
+ * - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进。
110
+ */
111
+ applyPromotion(): Promise<void>;
112
+ /** 最近一次 applyPromotion 输出的未满足促销列表 */
113
+ getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
114
+ /** 最近一次 applyPromotion 输出的赠品操作 diff */
115
+ getLastGiftActions(): OrderLastGiftActions | null;
57
116
  initTempOrder(params: {
58
117
  cacheId?: string;
59
118
  salesSummaryModuleName?: string;
60
119
  }): void;
61
- private getTempOrderStorageKey;
62
- private restoreTempOrderFromStorage;
120
+ /**
121
+ * 控制 IndexedDB 草稿(saveDraft)是否写入。
122
+ * localStorage 版 tempOrder 持久化已废弃,此方法仅影响 saveDraft。
123
+ *
124
+ * @example
125
+ * order.setEnableTempOrderPersist(false); // BigSale 弹窗:跳过 ~1s 的 dbUpdate
126
+ */
127
+ setEnableTempOrderPersist(enabled: boolean): void;
128
+ /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
129
+ isTempOrderPersistEnabled(): boolean;
130
+ /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
63
131
  persistTempOrder(): void;
64
132
  private createDefaultTempOrderInstance;
65
133
  private createExternalSaleNumber;
66
134
  private ensureExternalSaleNumber;
67
135
  private ensureRequestUniqueIdempotencyToken;
136
+ private buildPaymentSyncIdempotencyToken;
68
137
  hasLocalDatabase(): boolean;
69
138
  private buildLocalOrderRecord;
70
139
  getLocalOrderByOrderId(orderId: number | string): Promise<Record<string, any> | null>;
71
140
  getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
72
141
  getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
73
142
  saveDraft(): Promise<void>;
143
+ private saveDraftInBackground;
74
144
  private hydrateTempOrderFromLocalRecord;
75
145
  private extractOrderIdFromSubmitResult;
76
146
  private calculatePaymentTotal;
147
+ private normalizePaymentSource;
148
+ private updateTempOrderPaymentStatus;
77
149
  private calculatePaidPaymentSummary;
78
150
  private calculatePaymentServiceFee;
151
+ private formatSummaryMetadataMoney;
152
+ private syncSummaryProductMetadata;
153
+ private calculateSummaryAmountGap;
79
154
  private getPaymentTargetAmount;
80
155
  ensureTempOrder(): OrderTempOrder;
81
156
  restoreOrder(): OrderTempOrder;
82
157
  getTempOrder(): OrderTempOrder | null;
158
+ replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
83
159
  getOrderIdentity(): OrderIdentitySnapshot | null;
84
160
  getOrderSyncState(): OrderSyncState;
85
161
  getOrderAmountSnapshot(): OrderAmountSnapshot | null;
@@ -90,20 +166,27 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
90
166
  private ensureExtend;
91
167
  private captureProductRuntime;
92
168
  private createLinkedProductAndBooking;
169
+ private getBookingUniqueIdentificationNumber;
170
+ private findBookingIndexByUniqueIdentificationNumber;
171
+ private removeLinkedBookingsForProduct;
93
172
  private getSalesSummary;
94
173
  recalculateSummary(options?: {
95
174
  createIfMissing?: boolean;
96
175
  }): Promise<OrderSummary | null>;
97
176
  getOrderSummary(): Promise<OrderSummary>;
98
177
  updateTempOrderNote(note: string): string;
178
+ updateTempOrderNote(note: string, sync: true): Promise<string>;
179
+ updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
180
+ syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
99
181
  getTempOrderNote(): string;
100
182
  updateTempOrderShopDiscount(amount: string | number): string;
101
183
  updateTempOrderBuzzer(buzzer: string): string;
102
184
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
185
+ private buildTempOrderCustomer;
103
186
  /**
104
187
  * 更新当前 tempOrder 的客户协议字段。
105
188
  *
106
- * PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
189
+ * PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
107
190
  * 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
108
191
  */
109
192
  updateTempOrderCustomer(customer: UpdateTempOrderCustomerInput): OrderSnapshot['customer'];
@@ -148,8 +231,15 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
148
231
  private shouldMergeProductToOrder;
149
232
  addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
150
233
  private hasGoodPassDiscount;
151
- updateProductInOrder(params: UpdateProductInOrderParams): Promise<OrderProduct[]>;
234
+ updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
235
+ updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
236
+ updateOrderBooking(params: UpdateOrderBookingParams): any[];
152
237
  removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
238
+ /**
239
+ * 仅清空购物车行(products / bookings),不重置整单。
240
+ * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
241
+ */
242
+ clearOrderCartLines(): Promise<OrderTempOrder>;
153
243
  /**
154
244
  * 提交当前 Sales tempOrder。
155
245
  *
@@ -221,8 +311,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
221
311
  hydrateTempOrderFromRecord(record: Record<string, any>, options?: {
222
312
  recalcOnHydrate?: boolean;
223
313
  }): Promise<OrderTempOrder>;
314
+ private normalizeTempOrderForRuntime;
224
315
  private normalizeHydratedOrderProduct;
225
316
  getLastOrderInfo(): Record<string, any> | undefined;
226
317
  getOrderInfo(order_id: number): Promise<any>;
227
318
  }
228
- export type { UpdateProductInOrderParams } from './types';
319
+ export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';