@pisell/pisellos 2.2.284 → 2.2.285

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -157,11 +157,13 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
160
161
  * 清空时整个 payload 为 null。
161
162
  */
162
163
  export interface OrderCustomerChangePayload {
163
164
  patch: OrderCustomerView;
164
165
  snapshot: ICustomer | null;
166
+ source?: 'detailHydrate';
165
167
  }
166
168
  export interface OrderScanCodeResult {
167
169
  isAvailable: boolean;
@@ -60,6 +60,7 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
60
60
  * 下单客户变更事件 payload。
61
61
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
62
62
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
63
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
63
64
  * 清空时整个 payload 为 null。
64
65
  */
65
66
 
@@ -131,8 +131,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
131
131
  }, {
132
132
  key: "loadProducts",
133
133
  value: function () {
134
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
135
- var _this$otherParams;
134
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
135
+ var _this$otherParams,
136
+ _this2 = this;
136
137
  var _ref,
137
138
  _ref$category_ids,
138
139
  category_ids,
@@ -161,14 +162,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
161
162
  rawApplicationCode,
162
163
  mappedApplicationCode,
163
164
  queryPayload,
165
+ originalCallback,
166
+ subscriptionCallback,
164
167
  productsData,
165
168
  sortedList,
166
- _args4 = arguments;
167
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
168
- while (1) switch (_context4.prev = _context4.next) {
169
+ _args5 = arguments;
170
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
171
+ while (1) switch (_context5.prev = _context5.next) {
169
172
  case 0:
170
- _ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
171
- options = _args4.length > 1 ? _args4[1] : undefined;
173
+ _ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
174
+ options = _args5.length > 1 ? _args5[1] : undefined;
172
175
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
173
176
  // if (!schedule_ids?.length) {
174
177
  // const schedule_ids_data = this.store.schedule
@@ -228,15 +231,38 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
231
  extension_type: extension_type,
229
232
  strategy_context: strategy_context
230
233
  });
231
- _context4.next = 11;
234
+ originalCallback = options === null || options === void 0 ? void 0 : options.callback;
235
+ subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
236
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
237
+ var _result$data;
238
+ var products;
239
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
240
+ while (1) switch (_context4.prev = _context4.next) {
241
+ case 0:
242
+ products = Array.isArray(result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list) ? result.data.list : [];
243
+ _context4.next = 3;
244
+ return _this2.addProduct(products);
245
+ case 3:
246
+ originalCallback(result);
247
+ case 4:
248
+ case "end":
249
+ return _context4.stop();
250
+ }
251
+ }, _callee4);
252
+ }));
253
+ return function (_x5) {
254
+ return _ref2.apply(this, arguments);
255
+ };
256
+ }()) : undefined;
257
+ _context5.next = 13;
232
258
  return this.request.post("/product/query", queryPayload, {
233
259
  osServer: true,
234
- callback: options === null || options === void 0 ? void 0 : options.callback,
260
+ callback: subscriptionCallback,
235
261
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
236
262
  customToast: function customToast() {}
237
263
  });
238
- case 11:
239
- productsData = _context4.sent;
264
+ case 13:
265
+ productsData = _context5.sent;
240
266
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
241
267
  return Number(b.sort) - Number(a.sort);
242
268
  }); // if (sortedList.length) {
@@ -247,12 +273,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
247
273
  // })
248
274
  // }
249
275
  this.addProduct(sortedList);
250
- return _context4.abrupt("return", sortedList);
251
- case 15:
276
+ return _context5.abrupt("return", sortedList);
277
+ case 17:
252
278
  case "end":
253
- return _context4.stop();
279
+ return _context5.stop();
254
280
  }
255
- }, _callee4, this);
281
+ }, _callee5, this);
256
282
  }));
257
283
  function loadProducts() {
258
284
  return _loadProducts.apply(this, arguments);
@@ -262,13 +288,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
262
288
  }, {
263
289
  key: "loadProductsPrice",
264
290
  value: function () {
265
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
266
- var _ref2$ids, ids, customer_id, schedule_date, channel, productsData;
267
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
268
- while (1) switch (_context5.prev = _context5.next) {
291
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
292
+ var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
293
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
294
+ while (1) switch (_context6.prev = _context6.next) {
269
295
  case 0:
270
- _ref2$ids = _ref2.ids, ids = _ref2$ids === void 0 ? [] : _ref2$ids, customer_id = _ref2.customer_id, schedule_date = _ref2.schedule_date, channel = _ref2.channel;
271
- _context5.next = 3;
296
+ _ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
297
+ _context6.next = 3;
272
298
  return this.request.post("/product/query/price", {
273
299
  ids: ids,
274
300
  customer_id: customer_id,
@@ -278,15 +304,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
278
304
  useCache: true
279
305
  });
280
306
  case 3:
281
- productsData = _context5.sent;
282
- return _context5.abrupt("return", productsData.data);
307
+ productsData = _context6.sent;
308
+ return _context6.abrupt("return", productsData.data);
283
309
  case 5:
284
310
  case "end":
285
- return _context5.stop();
311
+ return _context6.stop();
286
312
  }
287
- }, _callee5, this);
313
+ }, _callee6, this);
288
314
  }));
289
- function loadProductsPrice(_x5) {
315
+ function loadProductsPrice(_x6) {
290
316
  return _loadProductsPrice.apply(this, arguments);
291
317
  }
292
318
  return loadProductsPrice;
@@ -294,19 +320,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
294
320
  }, {
295
321
  key: "getProducts",
296
322
  value: function () {
297
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
298
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
299
- while (1) switch (_context6.prev = _context6.next) {
323
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
324
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
325
+ while (1) switch (_context7.prev = _context7.next) {
300
326
  case 0:
301
- _context6.next = 2;
327
+ _context7.next = 2;
302
328
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
303
329
  case 2:
304
- return _context6.abrupt("return", cloneDeep(this.store.list));
330
+ return _context7.abrupt("return", cloneDeep(this.store.list));
305
331
  case 3:
306
332
  case "end":
307
- return _context6.stop();
333
+ return _context7.stop();
308
334
  }
309
- }, _callee6, this);
335
+ }, _callee7, this);
310
336
  }));
311
337
  function getProducts() {
312
338
  return _getProducts.apply(this, arguments);
@@ -316,25 +342,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
316
342
  }, {
317
343
  key: "getProduct",
318
344
  value: function () {
319
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
345
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
320
346
  var product;
321
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
322
- while (1) switch (_context7.prev = _context7.next) {
347
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
348
+ while (1) switch (_context8.prev = _context8.next) {
323
349
  case 0:
324
- _context7.next = 2;
350
+ _context8.next = 2;
325
351
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
326
352
  case 2:
327
353
  product = this.store.list.find(function (product) {
328
354
  return product.id === id;
329
355
  });
330
- return _context7.abrupt("return", product ? cloneDeep(product) : undefined);
356
+ return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
331
357
  case 4:
332
358
  case "end":
333
- return _context7.stop();
359
+ return _context8.stop();
334
360
  }
335
- }, _callee7, this);
361
+ }, _callee8, this);
336
362
  }));
337
- function getProduct(_x6) {
363
+ function getProduct(_x7) {
338
364
  return _getProduct.apply(this, arguments);
339
365
  }
340
366
  return getProduct;
@@ -342,25 +368,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
342
368
  }, {
343
369
  key: "getProductByIds",
344
370
  value: function () {
345
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
371
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ids) {
346
372
  var products;
347
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
348
- while (1) switch (_context8.prev = _context8.next) {
373
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
+ while (1) switch (_context9.prev = _context9.next) {
349
375
  case 0:
350
- _context8.next = 2;
376
+ _context9.next = 2;
351
377
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
352
378
  case 2:
353
379
  products = this.store.list.filter(function (product) {
354
380
  return ids.includes(product.id);
355
381
  });
356
- return _context8.abrupt("return", products);
382
+ return _context9.abrupt("return", products);
357
383
  case 4:
358
384
  case "end":
359
- return _context8.stop();
385
+ return _context9.stop();
360
386
  }
361
- }, _callee8, this);
387
+ }, _callee9, this);
362
388
  }));
363
- function getProductByIds(_x7) {
389
+ function getProductByIds(_x8) {
364
390
  return _getProductByIds.apply(this, arguments);
365
391
  }
366
392
  return getProductByIds;
@@ -368,23 +394,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
368
394
  }, {
369
395
  key: "addProduct",
370
396
  value: function () {
371
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
372
- var _this2 = this;
373
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
- while (1) switch (_context9.prev = _context9.next) {
397
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
398
+ var _this3 = this;
399
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
400
+ while (1) switch (_context10.prev = _context10.next) {
375
401
  case 0:
376
402
  // list 需要根据 id 去重
377
403
  if (!this.store.list) {
378
404
  this.store.list = [];
379
405
  }
380
406
  products.forEach(function (n) {
381
- var index = _this2.store.list.findIndex(function (m) {
407
+ var index = _this3.store.list.findIndex(function (m) {
382
408
  return m.id === n.id;
383
409
  });
384
410
  if (index === -1) {
385
- _this2.store.list.push(n);
411
+ _this3.store.list.push(n);
386
412
  } else {
387
- _this2.store.list[index] = n;
413
+ _this3.store.list[index] = n;
388
414
  }
389
415
  });
390
416
  // 根据 sort 值做降序排序(数字越大越靠前)
@@ -394,11 +420,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
394
420
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
395
421
  case 4:
396
422
  case "end":
397
- return _context9.stop();
423
+ return _context10.stop();
398
424
  }
399
- }, _callee9, this);
425
+ }, _callee10, this);
400
426
  }));
401
- function addProduct(_x8) {
427
+ function addProduct(_x9) {
402
428
  return _addProduct.apply(this, arguments);
403
429
  }
404
430
  return addProduct;
@@ -406,18 +432,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
406
432
  }, {
407
433
  key: "selectProducts",
408
434
  value: function () {
409
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
410
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
411
- while (1) switch (_context10.prev = _context10.next) {
435
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
436
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
437
+ while (1) switch (_context11.prev = _context11.next) {
412
438
  case 0:
413
439
  this.store.selectProducts = products;
414
440
  case 1:
415
441
  case "end":
416
- return _context10.stop();
442
+ return _context11.stop();
417
443
  }
418
- }, _callee10, this);
444
+ }, _callee11, this);
419
445
  }));
420
- function selectProducts(_x9) {
446
+ function selectProducts(_x10) {
421
447
  return _selectProducts.apply(this, arguments);
422
448
  }
423
449
  return selectProducts;
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -2157,12 +2157,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2157
2157
  return !_this12.isPersistedOrderProduct(product);
2158
2158
  });
2159
2159
  if (hasDraftProduct) return false;
2160
- var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
2161
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2160
+
2161
+ // 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
2162
+ // isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
2163
+ // 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
2164
+ // 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
2165
+ // 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
2166
+ // 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
2167
+ var hasRuntimeDiscountSelection = params.currentDiscountList.some(function (discount) {
2168
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2162
2169
  });
2163
- if (hasSelectedDiscount) return false;
2170
+ if (hasRuntimeDiscountSelection) return false;
2171
+
2172
+ // nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
2173
+ // 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
2174
+ // 才允许继续进入折扣重算。
2164
2175
  return !params.nextDiscountList.some(function (discount) {
2165
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2176
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2166
2177
  });
2167
2178
  }
2168
2179
  }, {
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -3,7 +3,7 @@ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketSt
3
3
  import type { ProductData } from '../../modules';
4
4
  import type { OpenDataConfig } from '../../modules/OpenData';
5
5
  import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
6
- import type { OrderCustomerView } from '../../modules/Order/types';
6
+ import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
7
7
  import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
@@ -260,7 +260,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
261
261
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
262
262
  */
263
- setOrderCustomer(customer: ICustomer | null): void;
263
+ setOrderCustomer(customer: ICustomer | null, options?: {
264
+ source?: OrderCustomerChangePayload['source'];
265
+ }): void;
264
266
  /**
265
267
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
266
268
  */
@@ -332,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
332
334
  * 获取当前的客户搜索条件
333
335
  * @returns 当前搜索条件
334
336
  */
335
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
337
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
336
338
  /**
337
339
  * 获取客户列表状态(包含滚动加载相关状态)
338
340
  * @returns 客户状态
@@ -540,7 +540,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
540
540
  country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
541
541
  });
542
542
  customerModule.setSelectedCustomer(customer);
543
- this.setOrderCustomer(customer);
543
+ // 详情 hydrate 后仍需广播一次,让 CustomerContext 等 UI 订阅方拿到刚补齐的
544
+ // customerSnapshot;但它不是用户主动切换客户。通过 source 明确标记初始化事件,
545
+ // 商品报价/折扣订阅方即可跳过 prepare/config,其他旧订阅方仍可照常刷新 UI。
546
+ this.setOrderCustomer(customer, {
547
+ source: 'detailHydrate'
548
+ });
544
549
  // await this.store.order.saveDraft();
545
550
  }
546
551
  return _context6.abrupt("return", sales);
@@ -1562,7 +1567,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1562
1567
  */
1563
1568
  }, {
1564
1569
  key: "setOrderCustomer",
1565
- value: function setOrderCustomer(customer) {
1570
+ value: function setOrderCustomer(customer, options) {
1566
1571
  var _this$store$order$get3,
1567
1572
  _this3 = this;
1568
1573
  if (!customer) {
@@ -1585,12 +1590,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1585
1590
  var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
1586
1591
  if (snapshotReplenished) {
1587
1592
  var _next2 = this.buildOrderCustomerPayload();
1588
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
1593
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2 && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, _next2), {}, {
1594
+ source: options.source
1595
+ }) : _next2);
1589
1596
  }
1590
1597
  return;
1591
1598
  }
1592
1599
  var next = this.buildOrderCustomerPayload();
1593
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1600
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, next), {}, {
1601
+ source: options.source
1602
+ }) : next);
1594
1603
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1595
1604
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1596
1605
  var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -157,11 +157,13 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
160
161
  * 清空时整个 payload 为 null。
161
162
  */
162
163
  export interface OrderCustomerChangePayload {
163
164
  patch: OrderCustomerView;
164
165
  snapshot: ICustomer | null;
166
+ source?: 'detailHydrate';
165
167
  }
166
168
  export interface OrderScanCodeResult {
167
169
  isAvailable: boolean;
@@ -56,6 +56,7 @@ let OrderHooks = exports.OrderHooks = /*#__PURE__*/function (OrderHooks) {
56
56
  * 下单客户变更事件 payload。
57
57
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
58
58
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
59
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
59
60
  * 清空时整个 payload 为 null。
60
61
  */
61
62
  /**
@@ -149,9 +149,15 @@ class ProductList extends _BaseModule.BaseModule {
149
149
  extension_type,
150
150
  strategy_context
151
151
  };
152
+ const originalCallback = options?.callback;
153
+ const subscriptionCallback = originalCallback ? async result => {
154
+ const products = Array.isArray(result?.data?.list) ? result.data.list : [];
155
+ await this.addProduct(products);
156
+ originalCallback(result);
157
+ } : undefined;
152
158
  const productsData = await this.request.post(`/product/query`, queryPayload, {
153
159
  osServer: true,
154
- callback: options?.callback,
160
+ callback: subscriptionCallback,
155
161
  subscriberId: options?.subscriberId,
156
162
  customToast: () => {}
157
163
  });
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -1398,9 +1398,20 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1398
1398
  if (!params.products.length) return false;
1399
1399
  const hasDraftProduct = params.products.some(product => !this.isPersistedOrderProduct(product));
1400
1400
  if (hasDraftProduct) return false;
1401
- const hasSelectedDiscount = params.currentDiscountList.some(discount => discount.isSelected || discount.isEditMode || discount.isManualSelect);
1402
- if (hasSelectedDiscount) return false;
1403
- return !params.nextDiscountList.some(discount => discount.isSelected || discount.isEditMode || discount.isManualSelect);
1401
+
1402
+ // 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
1403
+ // isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
1404
+ // 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
1405
+ // 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
1406
+ // 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
1407
+ // 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
1408
+ const hasRuntimeDiscountSelection = params.currentDiscountList.some(discount => !discount.isEditMode && (discount.isSelected || discount.isManualSelect));
1409
+ if (hasRuntimeDiscountSelection) return false;
1410
+
1411
+ // nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
1412
+ // 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
1413
+ // 才允许继续进入折扣重算。
1414
+ return !params.nextDiscountList.some(discount => !discount.isEditMode && (discount.isSelected || discount.isManualSelect));
1404
1415
  }
1405
1416
  mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
1406
1417
  if (!currentDiscountList.length) return discountList;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -3,7 +3,7 @@ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketSt
3
3
  import type { ProductData } from '../../modules';
4
4
  import type { OpenDataConfig } from '../../modules/OpenData';
5
5
  import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
6
- import type { OrderCustomerView } from '../../modules/Order/types';
6
+ import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
7
7
  import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
@@ -260,7 +260,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
261
261
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
262
262
  */
263
- setOrderCustomer(customer: ICustomer | null): void;
263
+ setOrderCustomer(customer: ICustomer | null, options?: {
264
+ source?: OrderCustomerChangePayload['source'];
265
+ }): void;
264
266
  /**
265
267
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
266
268
  */
@@ -332,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
332
334
  * 获取当前的客户搜索条件
333
335
  * @returns 当前搜索条件
334
336
  */
335
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
337
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
336
338
  /**
337
339
  * 获取客户列表状态(包含滚动加载相关状态)
338
340
  * @returns 客户状态
@@ -349,7 +349,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
349
349
  country_calling_code: selectedCustomer?.country_calling_code
350
350
  };
351
351
  customerModule.setSelectedCustomer(customer);
352
- this.setOrderCustomer(customer);
352
+ // 详情 hydrate 后仍需广播一次,让 CustomerContext 等 UI 订阅方拿到刚补齐的
353
+ // customerSnapshot;但它不是用户主动切换客户。通过 source 明确标记初始化事件,
354
+ // 商品报价/折扣订阅方即可跳过 prepare/config,其他旧订阅方仍可照常刷新 UI。
355
+ this.setOrderCustomer(customer, {
356
+ source: 'detailHydrate'
357
+ });
353
358
  // await this.store.order.saveDraft();
354
359
  }
355
360
  return sales;
@@ -926,7 +931,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
926
931
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
927
932
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
928
933
  */
929
- setOrderCustomer(customer) {
934
+ setOrderCustomer(customer, options) {
930
935
  if (!customer) {
931
936
  this.clearOrderCustomer();
932
937
  return;
@@ -947,12 +952,18 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
947
952
  const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
948
953
  if (snapshotReplenished) {
949
954
  const next = this.buildOrderCustomerPayload();
950
- this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
955
+ this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next && options?.source ? {
956
+ ...next,
957
+ source: options.source
958
+ } : next);
951
959
  }
952
960
  return;
953
961
  }
954
962
  const next = this.buildOrderCustomerPayload();
955
- this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
963
+ this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next && options?.source ? {
964
+ ...next,
965
+ source: options.source
966
+ } : next);
956
967
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
957
968
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
958
969
  const promotionRefreshTask = this.store.order.applyPromotion().then(() => undefined);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.284",
4
+ "version": "2.2.285",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",