@pisell/pisellos 2.2.281 → 2.2.282

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.
@@ -157,13 +157,11 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
- * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
161
160
  * 清空时整个 payload 为 null。
162
161
  */
163
162
  export interface OrderCustomerChangePayload {
164
163
  patch: OrderCustomerView;
165
164
  snapshot: ICustomer | null;
166
- source?: 'detailHydrate';
167
165
  }
168
166
  export interface OrderScanCodeResult {
169
167
  isAvailable: boolean;
@@ -60,7 +60,6 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
60
60
  * 下单客户变更事件 payload。
61
61
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
62
62
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
63
- * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
64
63
  * 清空时整个 payload 为 null。
65
64
  */
66
65
 
@@ -1124,7 +1124,12 @@ export function buildSubmitPayload(params) {
1124
1124
  var _tempOrder$bookings;
1125
1125
  // 如果外部没有传递 types,根据订单里当前是否有 bookings 来决定是 appointment_booking 还是 virtual
1126
1126
  if (tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length) {
1127
- submitType = 'appointment_booking';
1127
+ // 260807 如果 biz 是堂食,type 使用table-order
1128
+ if (businessCode === 'dine_in') {
1129
+ submitType = 'table-order';
1130
+ } else {
1131
+ submitType = 'appointment_booking';
1132
+ }
1128
1133
  } else {
1129
1134
  submitType = 'virtual';
1130
1135
  }
@@ -2126,23 +2126,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2126
2126
  return !_this12.isPersistedOrderProduct(product);
2127
2127
  });
2128
2128
  if (hasDraftProduct) return false;
2129
-
2130
- // 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
2131
- // isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
2132
- // 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
2133
- // 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
2134
- // 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
2135
- // 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
2136
- var hasRuntimeDiscountSelection = params.currentDiscountList.some(function (discount) {
2137
- return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2129
+ var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
2130
+ return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2138
2131
  });
2139
- if (hasRuntimeDiscountSelection) return false;
2140
-
2141
- // nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
2142
- // 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
2143
- // 才允许继续进入折扣重算。
2132
+ if (hasSelectedDiscount) return false;
2144
2133
  return !params.nextDiscountList.some(function (discount) {
2145
- return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2134
+ return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2146
2135
  });
2147
2136
  }
2148
2137
  }, {
@@ -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, OrderCustomerChangePayload } from '../../modules/Order/types';
6
+ import type { OrderCustomerView } 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,9 +260,7 @@ 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, options?: {
264
- source?: OrderCustomerChangePayload['source'];
265
- }): void;
263
+ setOrderCustomer(customer: ICustomer | null): void;
266
264
  /**
267
265
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
268
266
  */
@@ -542,12 +542,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
542
542
  country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
543
543
  });
544
544
  customerModule.setSelectedCustomer(customer);
545
- // 详情 hydrate 后仍需广播一次,让 CustomerContext 等 UI 订阅方拿到刚补齐的
546
- // customerSnapshot;但它不是用户主动切换客户。通过 source 明确标记初始化事件,
547
- // 商品报价/折扣订阅方即可跳过 prepare/config,其他旧订阅方仍可照常刷新 UI。
548
- this.setOrderCustomer(customer, {
549
- source: 'detailHydrate'
550
- });
545
+ this.setOrderCustomer(customer);
551
546
  // await this.store.order.saveDraft();
552
547
  }
553
548
  return _context6.abrupt("return", sales);
@@ -1563,7 +1558,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1563
1558
  */
1564
1559
  }, {
1565
1560
  key: "setOrderCustomer",
1566
- value: function setOrderCustomer(customer, options) {
1561
+ value: function setOrderCustomer(customer) {
1567
1562
  var _this$store$order$get3,
1568
1563
  _this3 = this;
1569
1564
  if (!customer) {
@@ -1586,16 +1581,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1586
1581
  var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
1587
1582
  if (snapshotReplenished) {
1588
1583
  var _next2 = this.buildOrderCustomerPayload();
1589
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2 && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, _next2), {}, {
1590
- source: options.source
1591
- }) : _next2);
1584
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
1592
1585
  }
1593
1586
  return;
1594
1587
  }
1595
1588
  var next = this.buildOrderCustomerPayload();
1596
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, next), {}, {
1597
- source: options.source
1598
- }) : next);
1589
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1599
1590
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1600
1591
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1601
1592
  var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
@@ -157,13 +157,11 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
- * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
161
160
  * 清空时整个 payload 为 null。
162
161
  */
163
162
  export interface OrderCustomerChangePayload {
164
163
  patch: OrderCustomerView;
165
164
  snapshot: ICustomer | null;
166
- source?: 'detailHydrate';
167
165
  }
168
166
  export interface OrderScanCodeResult {
169
167
  isAvailable: boolean;
@@ -994,7 +994,11 @@ function buildSubmitPayload(params) {
994
994
  let submitType = type ?? tempOrder.type;
995
995
  if (!submitType) {
996
996
  if ((_a = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _a.length) {
997
- submitType = "appointment_booking";
997
+ if (businessCode === "dine_in") {
998
+ submitType = "table-order";
999
+ } else {
1000
+ submitType = "appointment_booking";
1001
+ }
998
1002
  } else {
999
1003
  submitType = "virtual";
1000
1004
  }
@@ -1494,13 +1494,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1494
1494
  const hasDraftProduct = params.products.some((product) => !this.isPersistedOrderProduct(product));
1495
1495
  if (hasDraftProduct)
1496
1496
  return false;
1497
- const hasRuntimeDiscountSelection = params.currentDiscountList.some(
1498
- (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1497
+ const hasSelectedDiscount = params.currentDiscountList.some(
1498
+ (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1499
1499
  );
1500
- if (hasRuntimeDiscountSelection)
1500
+ if (hasSelectedDiscount)
1501
1501
  return false;
1502
1502
  return !params.nextDiscountList.some(
1503
- (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1503
+ (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1504
1504
  );
1505
1505
  }
1506
1506
  mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
@@ -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, OrderCustomerChangePayload } from '../../modules/Order/types';
6
+ import type { OrderCustomerView } 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,9 +260,7 @@ 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, options?: {
264
- source?: OrderCustomerChangePayload['source'];
265
- }): void;
263
+ setOrderCustomer(customer: ICustomer | null): void;
266
264
  /**
267
265
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
268
266
  */
@@ -343,7 +343,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
343
343
  country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
344
344
  };
345
345
  customerModule.setSelectedCustomer(customer);
346
- this.setOrderCustomer(customer, { source: "detailHydrate" });
346
+ this.setOrderCustomer(customer);
347
347
  }
348
348
  return sales;
349
349
  }
@@ -891,7 +891,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
891
891
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
892
892
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
893
893
  */
894
- setOrderCustomer(customer, options) {
894
+ setOrderCustomer(customer) {
895
895
  var _a;
896
896
  if (!customer) {
897
897
  this.clearOrderCustomer();
@@ -911,18 +911,12 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
911
911
  const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
912
912
  if (snapshotReplenished) {
913
913
  const next2 = this.buildOrderCustomerPayload();
914
- this.core.effects.emit(
915
- `${this.name}:onOrderCustomerChange`,
916
- next2 && (options == null ? void 0 : options.source) ? { ...next2, source: options.source } : next2
917
- );
914
+ this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next2);
918
915
  }
919
916
  return;
920
917
  }
921
918
  const next = this.buildOrderCustomerPayload();
922
- this.core.effects.emit(
923
- `${this.name}:onOrderCustomerChange`,
924
- next && (options == null ? void 0 : options.source) ? { ...next, source: options.source } : next
925
- );
919
+ this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
926
920
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
927
921
  const promotionRefreshTask = this.store.order.applyPromotion().then(() => void 0);
928
922
  this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.281",
4
+ "version": "2.2.282",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",