@pisell/pisellos 2.2.273 → 2.2.275

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 (74) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
  3. package/dist/modules/Order/index.d.ts +7 -6
  4. package/dist/modules/Order/index.js +217 -115
  5. package/dist/modules/Order/types.d.ts +23 -3
  6. package/dist/modules/Order/types.js +11 -0
  7. package/dist/modules/Payment/index.js +1 -1
  8. package/dist/modules/Payment/types.d.ts +81 -4
  9. package/dist/modules/Payment/types.js +18 -3
  10. package/dist/modules/Payment/walletpass.d.ts +38 -1
  11. package/dist/modules/Payment/walletpass.js +917 -114
  12. package/dist/modules/Rules/index.d.ts +2 -0
  13. package/dist/modules/Rules/index.js +78 -64
  14. package/dist/modules/SalesSummary/utils.js +7 -1
  15. package/dist/server/index.d.ts +4 -0
  16. package/dist/server/index.js +27 -18
  17. package/dist/server/modules/index.d.ts +1 -1
  18. package/dist/server/modules/order/index.d.ts +16 -0
  19. package/dist/server/modules/order/index.js +964 -776
  20. package/dist/server/modules/order/types.d.ts +14 -0
  21. package/dist/server/modules/order/types.js +6 -0
  22. package/dist/solution/BaseSales/index.d.ts +80 -15
  23. package/dist/solution/BaseSales/index.js +1498 -444
  24. package/dist/solution/BaseSales/types.d.ts +55 -1
  25. package/dist/solution/BaseSales/types.js +2 -1
  26. package/dist/solution/BaseSales/utils/cartPromotion.js +8 -3
  27. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  28. package/dist/solution/BookingByStep/index.d.ts +1 -1
  29. package/dist/solution/BookingTicket/index.d.ts +1 -1
  30. package/dist/solution/BookingTicket/index.js +12 -3
  31. package/dist/solution/BookingTicket/types.d.ts +4 -0
  32. package/dist/solution/BookingTicket/utils/cartView.js +44 -32
  33. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  34. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  35. package/dist/solution/Sales/index.d.ts +1 -0
  36. package/dist/solution/Sales/index.js +16 -2
  37. package/dist/solution/VenueBooking/index.d.ts +1 -0
  38. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  39. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
  40. package/lib/modules/Order/index.d.ts +7 -6
  41. package/lib/modules/Order/index.js +127 -20
  42. package/lib/modules/Order/types.d.ts +23 -3
  43. package/lib/modules/Payment/index.js +1 -1
  44. package/lib/modules/Payment/types.d.ts +81 -4
  45. package/lib/modules/Payment/types.js +4 -3
  46. package/lib/modules/Payment/walletpass.d.ts +38 -1
  47. package/lib/modules/Payment/walletpass.js +730 -21
  48. package/lib/modules/Rules/index.d.ts +2 -0
  49. package/lib/modules/Rules/index.js +24 -14
  50. package/lib/modules/SalesSummary/utils.js +5 -1
  51. package/lib/server/index.d.ts +4 -0
  52. package/lib/server/index.js +14 -6
  53. package/lib/server/modules/index.d.ts +1 -1
  54. package/lib/server/modules/order/index.d.ts +16 -0
  55. package/lib/server/modules/order/index.js +140 -4
  56. package/lib/server/modules/order/types.d.ts +14 -0
  57. package/lib/server/modules/order/types.js +1 -0
  58. package/lib/solution/BaseSales/index.d.ts +80 -15
  59. package/lib/solution/BaseSales/index.js +712 -48
  60. package/lib/solution/BaseSales/types.d.ts +55 -1
  61. package/lib/solution/BaseSales/types.js +2 -1
  62. package/lib/solution/BaseSales/utils/cartPromotion.js +8 -2
  63. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  64. package/lib/solution/BookingByStep/index.d.ts +1 -1
  65. package/lib/solution/BookingTicket/index.d.ts +1 -1
  66. package/lib/solution/BookingTicket/index.js +4 -1
  67. package/lib/solution/BookingTicket/types.d.ts +4 -0
  68. package/lib/solution/BookingTicket/utils/cartView.js +43 -30
  69. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  70. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  71. package/lib/solution/Sales/index.d.ts +1 -0
  72. package/lib/solution/Sales/index.js +15 -3
  73. package/lib/solution/VenueBooking/index.d.ts +1 -0
  74. package/package.json +1 -1
@@ -0,0 +1,9 @@
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";
@@ -134,9 +134,11 @@ function resolveMainProductPrice(product, fallback) {
134
134
  }
135
135
  function mapOrderBundleToOtherBundle(bundle) {
136
136
  return bundle.map(function (item) {
137
- var _ref7, _item$original_price;
137
+ var _ref7, _ref8, _item$original_price;
138
138
  return _objectSpread(_objectSpread({}, item), {}, {
139
- original_price: (_ref7 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref7 !== void 0 ? _ref7 : item.price
139
+ // 后端历史订单可能没有 original_price;此时 price 是折前毛价,
140
+ // bundle_selling_price 已包含折扣,不能把它当成编辑时的新原价。
141
+ original_price: (_ref7 = (_ref8 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : item.bundle_selling_price
140
142
  });
141
143
  });
142
144
  }
@@ -167,10 +169,10 @@ function synthesizeProductResourceFromBooking(booking) {
167
169
  });
168
170
  if (relationIdsByForm.size === 0) return undefined;
169
171
  return {
170
- resources: Array.from(relationIdsByForm.entries()).map(function (_ref8) {
171
- var _ref9 = _slicedToArray(_ref8, 2),
172
- formId = _ref9[0],
173
- relationIds = _ref9[1];
172
+ resources: Array.from(relationIdsByForm.entries()).map(function (_ref9) {
173
+ var _ref10 = _slicedToArray(_ref9, 2),
174
+ formId = _ref10[0],
175
+ relationIds = _ref10[1];
174
176
  return {
175
177
  id: formId,
176
178
  status: 1,
@@ -190,7 +192,7 @@ function synthesizeProductResourceFromBooking(booking) {
190
192
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
191
193
  */
192
194
  export function buildCacheItemFromOrderLine(input) {
193
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref12, _booking$id;
195
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref11, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref12, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref13, _booking$id;
194
196
  var product = input.product,
195
197
  booking = input.booking,
196
198
  sourceProduct = input.sourceProduct;
@@ -225,7 +227,7 @@ export function buildCacheItemFromOrderLine(input) {
225
227
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
226
228
  product_name: productTitle,
227
229
  product_cover: productCover,
228
- note: (_ref10 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref10 !== void 0 ? _ref10 : '',
230
+ note: (_ref11 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref11 !== void 0 ? _ref11 : '',
229
231
  price: mainProductPrice,
230
232
  total: selling,
231
233
  origin_total: original,
@@ -260,7 +262,7 @@ export function buildCacheItemFromOrderLine(input) {
260
262
  var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
261
263
  id: resolvedId,
262
264
  product_id: resolvedId,
263
- extension_type: (_ref11 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
265
+ extension_type: (_ref12 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
264
266
  title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
265
267
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
266
268
  selling_price: product.selling_price,
@@ -274,7 +276,7 @@ export function buildCacheItemFromOrderLine(input) {
274
276
  new: 0,
275
277
  autoClose: false,
276
278
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
277
- booking_id: (_ref12 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref12 !== void 0 ? _ref12 : 0
279
+ booking_id: (_ref13 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref13 !== void 0 ? _ref13 : 0
278
280
  });
279
281
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
280
282
  base.capacity = sourceProduct.capacity;
@@ -3,7 +3,7 @@ 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, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } 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';
@@ -81,6 +81,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
81
81
  private ensureEditDiscountConfigForProductChange;
82
82
  scanCode(code: string, customerId?: number): Promise<{
83
83
  isAvailable: boolean;
84
+ isAccepted?: boolean;
84
85
  discountList: Discount[];
85
86
  type: 'server' | 'clientCalc';
86
87
  unavailableReason?: UnavailableReason;
@@ -383,7 +384,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
383
384
  * await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
384
385
  * // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
385
386
  */
386
- addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
387
+ addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
387
388
  /**
388
389
  * 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
389
390
  *
@@ -421,8 +422,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
421
422
  * @example
422
423
  * await order.removeProductsFromOrder([identityA, identityB]);
423
424
  */
424
- removeProductsFromOrder(identities: OrderProductIdentity[]): Promise<OrderProduct[]>;
425
- removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
425
+ removeProductsFromOrder(identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
426
+ removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
426
427
  /**
427
428
  * 仅清空购物车行(products / bookings),不重置整单。
428
429
  * 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
@@ -485,7 +486,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
485
486
  generateIdempotencyToken(): string;
486
487
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
487
488
  createOrder(params: CommitOrderParams['query']): {
488
- type: "virtual" | "appointment_booking";
489
+ type: "appointment_booking" | "virtual";
489
490
  platform: string;
490
491
  sales_channel: string;
491
492
  order_sales_channel: string;
@@ -560,4 +561,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
560
561
  getOrderInfo(order_id: number): Promise<any>;
561
562
  getVouchers(): any[];
562
563
  }
563
- export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
564
+ export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';