@pisell/pisellos 2.2.256 → 2.2.258

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 (52) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
  3. package/dist/modules/Order/index.d.ts +29 -1
  4. package/dist/modules/Order/index.js +508 -241
  5. package/dist/modules/Order/types.d.ts +20 -2
  6. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  7. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  8. package/dist/modules/Order/utils.d.ts +4 -0
  9. package/dist/modules/Order/utils.js +114 -28
  10. package/dist/modules/Product/index.d.ts +1 -1
  11. package/dist/modules/Product/types.d.ts +6 -0
  12. package/dist/modules/Rules/index.d.ts +3 -3
  13. package/dist/modules/Rules/index.js +8 -3
  14. package/dist/modules/Rules/types.d.ts +2 -1
  15. package/dist/server/index.d.ts +12 -2
  16. package/dist/server/index.js +1227 -923
  17. package/dist/server/modules/order/index.d.ts +22 -3
  18. package/dist/server/modules/order/index.js +397 -314
  19. package/dist/solution/BaseSales/index.d.ts +16 -2
  20. package/dist/solution/BaseSales/index.js +484 -314
  21. package/dist/solution/BaseSales/types.d.ts +1 -0
  22. package/dist/solution/BaseSales/types.js +2 -1
  23. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
  24. package/dist/solution/BookingByStep/index.d.ts +1 -1
  25. package/dist/solution/BookingTicket/index.d.ts +9 -1
  26. package/dist/solution/BookingTicket/index.js +162 -6
  27. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
  28. package/lib/modules/Order/index.d.ts +29 -1
  29. package/lib/modules/Order/index.js +340 -57
  30. package/lib/modules/Order/types.d.ts +20 -2
  31. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  32. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  33. package/lib/modules/Order/utils.d.ts +4 -0
  34. package/lib/modules/Order/utils.js +84 -2
  35. package/lib/modules/Product/index.d.ts +1 -1
  36. package/lib/modules/Product/types.d.ts +6 -0
  37. package/lib/modules/Rules/index.d.ts +3 -3
  38. package/lib/modules/Rules/index.js +4 -3
  39. package/lib/modules/Rules/types.d.ts +2 -1
  40. package/lib/server/index.d.ts +12 -2
  41. package/lib/server/index.js +218 -12
  42. package/lib/server/modules/order/index.d.ts +22 -3
  43. package/lib/server/modules/order/index.js +102 -51
  44. package/lib/solution/BaseSales/index.d.ts +16 -2
  45. package/lib/solution/BaseSales/index.js +143 -31
  46. package/lib/solution/BaseSales/types.d.ts +1 -0
  47. package/lib/solution/BaseSales/types.js +2 -1
  48. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
  49. package/lib/solution/BookingByStep/index.d.ts +1 -1
  50. package/lib/solution/BookingTicket/index.d.ts +9 -1
  51. package/lib/solution/BookingTicket/index.js +112 -0
  52. 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 } from "./examples";
@@ -1,7 +1,3 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -132,6 +128,14 @@ function resolveMainProductPrice(product, fallback) {
132
128
  var parsed = Number(value);
133
129
  return Number.isFinite(parsed) ? parsed : fallback;
134
130
  }
131
+ function mapOrderBundleToOtherBundle(bundle) {
132
+ return bundle.map(function (item) {
133
+ var _ref6, _item$original_price;
134
+ return _objectSpread(_objectSpread({}, item), {}, {
135
+ original_price: (_ref6 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : item.price
136
+ });
137
+ });
138
+ }
135
139
 
136
140
  /**
137
141
  * catalog 缺 product_resource 时,从 booking.resources 反推最小 product_resource 结构,
@@ -159,10 +163,10 @@ function synthesizeProductResourceFromBooking(booking) {
159
163
  });
160
164
  if (relationIdsByForm.size === 0) return undefined;
161
165
  return {
162
- resources: Array.from(relationIdsByForm.entries()).map(function (_ref6) {
163
- var _ref7 = _slicedToArray(_ref6, 2),
164
- formId = _ref7[0],
165
- relationIds = _ref7[1];
166
+ resources: Array.from(relationIdsByForm.entries()).map(function (_ref7) {
167
+ var _ref8 = _slicedToArray(_ref7, 2),
168
+ formId = _ref8[0],
169
+ relationIds = _ref8[1];
166
170
  return {
167
171
  id: formId,
168
172
  status: 1,
@@ -182,7 +186,7 @@ function synthesizeProductResourceFromBooking(booking) {
182
186
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
183
187
  */
184
188
  export function buildCacheItemFromOrderLine(input) {
185
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref8, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref9, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref10, _booking$id;
189
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref9, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref10, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref11, _booking$id;
186
190
  var product = input.product,
187
191
  booking = input.booking,
188
192
  sourceProduct = input.sourceProduct;
@@ -202,7 +206,7 @@ export function buildCacheItemFromOrderLine(input) {
202
206
  var other = {
203
207
  product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
204
208
  option: getProductSkuOptions(product),
205
- bundle: Array.isArray(product.product_bundle) ? _toConsumableArray(product.product_bundle) : []
209
+ bundle: mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [])
206
210
  };
207
211
  var extend = _objectSpread({
208
212
  start_date: startDate ? dayjs(startDate) : undefined,
@@ -215,7 +219,7 @@ export function buildCacheItemFromOrderLine(input) {
215
219
  sub_type: booking.sub_type,
216
220
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
217
221
  product_name: productTitle,
218
- note: (_ref8 = (_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 && _ref8 !== void 0 ? _ref8 : '',
222
+ note: (_ref9 = (_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 && _ref9 !== void 0 ? _ref9 : '',
219
223
  price: mainProductPrice,
220
224
  total: selling,
221
225
  origin_total: original,
@@ -250,7 +254,7 @@ export function buildCacheItemFromOrderLine(input) {
250
254
  var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
251
255
  id: resolvedId,
252
256
  product_id: resolvedId,
253
- extension_type: (_ref9 = (_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 && _ref9 !== void 0 ? _ref9 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
257
+ extension_type: (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
254
258
  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),
255
259
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
256
260
  selling_price: product.selling_price,
@@ -262,7 +266,7 @@ export function buildCacheItemFromOrderLine(input) {
262
266
  new: 0,
263
267
  autoClose: false,
264
268
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
265
- booking_id: (_ref10 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref10 !== void 0 ? _ref10 : 0
269
+ booking_id: (_ref11 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref11 !== void 0 ? _ref11 : 0
266
270
  });
267
271
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
268
272
  base.capacity = sourceProduct.capacity;
@@ -154,10 +154,21 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
154
154
  private calculatePaymentTotal;
155
155
  private getDepositAmount;
156
156
  private normalizeDepositAmount;
157
+ private getLastOrderDepositSnapshot;
158
+ private getLastOrderSubmitSnapshot;
157
159
  private applyDepositAmountToSummary;
160
+ private applyLastOrderDepositSnapshot;
158
161
  private isDepositOrder;
159
162
  private getOrderExpectedAmount;
160
163
  private isDepositCovered;
164
+ getPaymentCompletion(payments?: OrderPaymentSource[]): {
165
+ isFullyPaid: boolean;
166
+ isOrderFullyPaid: boolean;
167
+ isDepositFullyPaid: boolean;
168
+ paymentStage: 'deposit' | 'normal';
169
+ depositAmount: string;
170
+ orderExpectedAmount: string;
171
+ };
161
172
  private calculateDepositPaidAmount;
162
173
  private resolveNextOrderPaymentType;
163
174
  private normalizePaymentSource;
@@ -301,13 +312,27 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
301
312
  updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
302
313
  /** 从当前订单支付项中移除指定支付项。 */
303
314
  deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
315
+ private confirmPendingVoucherPaymentsInList;
316
+ private discardPendingVoucherPaymentsFromList;
317
+ private prepareVoucherPaymentsForSubmit;
318
+ private applyPaymentLifecycleChange;
319
+ confirmPendingVoucherPayments(options?: {
320
+ persist?: boolean;
321
+ recalculateSummary?: boolean;
322
+ }): OrderPaymentData[];
323
+ discardPendingVoucherPayments(options?: {
324
+ persist?: boolean;
325
+ recalculateSummary?: boolean;
326
+ }): OrderPaymentData[];
304
327
  /**
305
328
  * 覆盖当前订单中的 wallet pass 支付项。
306
329
  *
307
330
  * 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
308
331
  * 视为 wallet pass;其它支付项保持不变。
309
332
  */
310
- updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
333
+ updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
334
+ status?: 'paid' | 'payment_pending';
335
+ }): OrderPaymentData[];
311
336
  private shouldMergeProductToOrder;
312
337
  private hasOrderProductLineNote;
313
338
  /**
@@ -407,6 +432,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
407
432
  payments?: OrderPaymentSource[];
408
433
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
409
434
  smallTicketDataFlag?: number;
435
+ confirmPendingVoucherPayments?: boolean;
410
436
  enhancePayload?: SubmitPayloadEnhancer;
411
437
  }): Promise<T>;
412
438
  submitTempOrderAsync<T = any>(params?: {
@@ -418,6 +444,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
418
444
  payments?: OrderPaymentSource[];
419
445
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
420
446
  smallTicketDataFlag?: number;
447
+ confirmPendingVoucherPayments?: boolean;
421
448
  enhancePayload?: SubmitPayloadEnhancer;
422
449
  }): Promise<T>;
423
450
  private runSubmitTempOrder;
@@ -497,5 +524,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
497
524
  private normalizeHydratedOrderProduct;
498
525
  getLastOrderInfo(): Record<string, any> | undefined;
499
526
  getOrderInfo(order_id: number): Promise<any>;
527
+ getVouchers(): any[];
500
528
  }
501
529
  export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';