@pisell/pisellos 2.3.6 → 2.3.8

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 (38) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
  2. package/dist/modules/Order/index.d.ts +18 -2
  3. package/dist/modules/Order/index.js +392 -222
  4. package/dist/modules/Order/types.d.ts +15 -2
  5. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  6. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  7. package/dist/modules/Order/utils.d.ts +4 -0
  8. package/dist/modules/Order/utils.js +114 -28
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Rules/index.d.ts +3 -3
  11. package/dist/modules/Rules/index.js +8 -3
  12. package/dist/modules/Rules/types.d.ts +2 -1
  13. package/dist/server/index.js +1 -0
  14. package/dist/server/modules/order/index.d.ts +4 -4
  15. package/dist/server/modules/order/index.js +4 -4
  16. package/dist/solution/BaseSales/index.d.ts +8 -1
  17. package/dist/solution/BaseSales/index.js +145 -104
  18. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
  21. package/lib/modules/Order/index.d.ts +18 -2
  22. package/lib/modules/Order/index.js +229 -40
  23. package/lib/modules/Order/types.d.ts +15 -2
  24. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  25. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  26. package/lib/modules/Order/utils.d.ts +4 -0
  27. package/lib/modules/Order/utils.js +84 -2
  28. package/lib/modules/Product/index.d.ts +1 -1
  29. package/lib/modules/Rules/index.d.ts +3 -3
  30. package/lib/modules/Rules/index.js +4 -3
  31. package/lib/modules/Rules/types.d.ts +2 -1
  32. package/lib/server/modules/order/index.d.ts +4 -4
  33. package/lib/server/modules/order/index.js +4 -4
  34. package/lib/solution/BaseSales/index.d.ts +8 -1
  35. package/lib/solution/BaseSales/index.js +58 -22
  36. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
  37. package/lib/solution/BookingByStep/index.d.ts +1 -1
  38. package/package.json +1 -1
@@ -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;
@@ -312,13 +312,27 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
312
312
  updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
313
313
  /** 从当前订单支付项中移除指定支付项。 */
314
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[];
315
327
  /**
316
328
  * 覆盖当前订单中的 wallet pass 支付项。
317
329
  *
318
330
  * 判断口径与 PaymentModal 保持一致:voucher_id 存在且不为 0 的支付项
319
331
  * 视为 wallet pass;其它支付项保持不变。
320
332
  */
321
- updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
333
+ updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
334
+ status?: 'paid' | 'payment_pending';
335
+ }): OrderPaymentData[];
322
336
  private shouldMergeProductToOrder;
323
337
  private hasOrderProductLineNote;
324
338
  /**
@@ -418,6 +432,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
418
432
  payments?: OrderPaymentSource[];
419
433
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
420
434
  smallTicketDataFlag?: number;
435
+ confirmPendingVoucherPayments?: boolean;
421
436
  enhancePayload?: SubmitPayloadEnhancer;
422
437
  }): Promise<T>;
423
438
  submitTempOrderAsync<T = any>(params?: {
@@ -429,6 +444,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
429
444
  payments?: OrderPaymentSource[];
430
445
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
431
446
  smallTicketDataFlag?: number;
447
+ confirmPendingVoucherPayments?: boolean;
432
448
  enhancePayload?: SubmitPayloadEnhancer;
433
449
  }): Promise<T>;
434
450
  private runSubmitTempOrder;
@@ -442,7 +458,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
442
458
  generateIdempotencyToken(): string;
443
459
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
444
460
  createOrder(params: CommitOrderParams['query']): {
445
- type: "virtual" | "appointment_booking";
461
+ type: "appointment_booking" | "virtual";
446
462
  platform: string;
447
463
  sales_channel: string;
448
464
  order_sales_channel: string;