@pisell/pisellos 2.3.7 → 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.
@@ -380,6 +380,42 @@ function normalizeOrderProductDiscountList(discountList) {
380
380
  return normalized;
381
381
  });
382
382
  }
383
+ function resolveSubmitBundleMapId(bundle) {
384
+ var _a;
385
+ const metadataMapId = (_a = bundle.metadata) == null ? void 0 : _a.custom_product_bundle_map_id;
386
+ if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
387
+ return metadataMapId;
388
+ }
389
+ if (bundle._id !== void 0 && bundle._id !== null && bundle._id !== "") {
390
+ return bundle._id;
391
+ }
392
+ return void 0;
393
+ }
394
+ function collectSubmitProductDiscountList(product) {
395
+ const submitDiscountList = Array.isArray(product == null ? void 0 : product.discount_list) ? [...product.discount_list] : [];
396
+ for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
397
+ if (!bundle || typeof bundle !== "object")
398
+ continue;
399
+ const bundleMapId = resolveSubmitBundleMapId(bundle);
400
+ const bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
401
+ for (const discount of bundleDiscountList) {
402
+ if (!discount || typeof discount !== "object")
403
+ continue;
404
+ const discountMetadata = discount.metadata && typeof discount.metadata === "object" ? discount.metadata : {};
405
+ const discountMapId = discountMetadata.custom_product_bundle_map_id !== void 0 && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== "" ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
406
+ submitDiscountList.push({
407
+ ...discount,
408
+ ...discountMapId !== void 0 ? {
409
+ metadata: {
410
+ ...discountMetadata,
411
+ custom_product_bundle_map_id: discountMapId
412
+ }
413
+ } : {}
414
+ });
415
+ }
416
+ }
417
+ return normalizeOrderProductDiscountList(submitDiscountList);
418
+ }
383
419
  function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
384
420
  var _a, _b;
385
421
  const metadata = params.metadata || {};
@@ -675,6 +711,10 @@ function formatSubmitBundleItems(bundle) {
675
711
  return bundle.map((b) => {
676
712
  const rawBundle = b && typeof b === "object" ? b : {};
677
713
  const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
714
+ const {
715
+ custom_product_bundle_map_id: _customProductBundleMapId,
716
+ ...submitMetadata
717
+ } = existedMetadata;
678
718
  const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
679
719
  const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
680
720
  const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
@@ -687,6 +727,8 @@ function formatSubmitBundleItems(bundle) {
687
727
  0
688
728
  );
689
729
  const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
730
+ const bundleMapId = resolveSubmitBundleMapId(rawBundle);
731
+ const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
690
732
  return {
691
733
  is_charge_tax: rawBundle.is_charge_tax ?? 0,
692
734
  bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
@@ -704,7 +746,8 @@ function formatSubmitBundleItems(bundle) {
704
746
  bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
705
747
  bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
706
748
  metadata: {
707
- ...existedMetadata,
749
+ ...submitMetadata,
750
+ ...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
708
751
  surcharge_fee: surchargeFee,
709
752
  relation_surcharge_ids: relationSurchargeIds,
710
753
  product_discount_difference: productDiscountDifference
@@ -769,7 +812,7 @@ function normalizeSubmitProduct(product) {
769
812
  ...bookingUid ? { booking_uid: bookingUid } : {},
770
813
  product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
771
814
  product_sku: productSku,
772
- discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
815
+ discount_list: collectSubmitProductDiscountList(submitProduct),
773
816
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
774
817
  metadata: cleanMetadata,
775
818
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
@@ -195,6 +195,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
195
195
  payments?: OrderPaymentSource[];
196
196
  paymentStatus?: BaseSalesPaymentStatus;
197
197
  smallTicketDataFlag?: number;
198
+ confirmPendingVoucherPayments?: boolean;
198
199
  enhancePayload?: SubmitPayloadEnhancer;
199
200
  }): Promise<T>;
200
201
  /**
@@ -207,12 +208,14 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
207
208
  payments?: OrderPaymentSource[];
208
209
  paymentStatus?: BaseSalesPaymentStatus;
209
210
  smallTicketDataFlag?: number;
211
+ confirmPendingVoucherPayments?: boolean;
210
212
  enhancePayload?: SubmitPayloadEnhancer;
211
213
  }): Promise<T>;
212
214
  submitTempOrderAsync<T = any>(params?: {
213
215
  payments?: OrderPaymentSource[];
214
216
  paymentStatus?: BaseSalesPaymentStatus;
215
217
  smallTicketDataFlag?: number;
218
+ confirmPendingVoucherPayments?: boolean;
216
219
  enhancePayload?: SubmitPayloadEnhancer;
217
220
  }): Promise<T>;
218
221
  printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
@@ -229,7 +232,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
229
232
  /** 删除当前订单中的指定支付项。 */
230
233
  deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
231
234
  /** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
232
- updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
235
+ updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
236
+ status?: 'paid' | 'payment_pending';
237
+ }): OrderPaymentData[];
238
+ confirmPendingVoucherPayments(): OrderPaymentData[];
239
+ discardPendingVoucherPayments(): OrderPaymentData[];
233
240
  private getWalletProductList;
234
241
  initWalletData(params?: {
235
242
  order_wait_pay_amount?: number;
@@ -165,10 +165,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
165
165
  return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
166
166
  }
167
167
  getReusableSharedSubModule(moduleName) {
168
- var _a;
168
+ var _a, _b;
169
169
  if (moduleName !== "schedule" && moduleName !== "quotation")
170
170
  return null;
171
- return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
171
+ return ((_b = (_a = this.core) == null ? void 0 : _a.getModule) == null ? void 0 : _b.call(_a, moduleName)) || null;
172
172
  }
173
173
  isScheduleListLoaded(scheduleModule) {
174
174
  if (!scheduleModule)
@@ -1283,6 +1283,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1283
1283
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
1284
1284
  d.isSelected = false;
1285
1285
  d.isManualSelect = true;
1286
+ d.appliedProductDetails = [];
1286
1287
  }
1287
1288
  }
1288
1289
  }
@@ -1291,16 +1292,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1291
1292
  const selectedResourceIds = new Set(
1292
1293
  nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
1293
1294
  );
1295
+ const filterSelectedDiscountDetails = (discountList) => (discountList || []).filter((pd) => {
1296
+ var _a2;
1297
+ const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
1298
+ return rid != null && selectedResourceIds.has(rid);
1299
+ });
1294
1300
  for (const product of tempOrder.products) {
1295
1301
  const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
1296
1302
  const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
1297
1303
  if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
1298
1304
  continue;
1299
- product.discount_list = (product.discount_list || []).filter((pd) => {
1300
- var _a2;
1301
- const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
1302
- return rid != null && selectedResourceIds.has(rid);
1303
- });
1305
+ product.discount_list = filterSelectedDiscountDetails(product.discount_list);
1306
+ if (Array.isArray(product.product_bundle)) {
1307
+ product.product_bundle = product.product_bundle.map((bundle) => {
1308
+ const nextBundleDiscountList = filterSelectedDiscountDetails(bundle == null ? void 0 : bundle.discount_list);
1309
+ const shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
1310
+ const restoredBundlePrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
1311
+ return {
1312
+ ...bundle,
1313
+ ...shouldRestoreBundlePrice ? {
1314
+ price: restoredBundlePrice,
1315
+ bundle_selling_price: restoredBundlePrice
1316
+ } : {},
1317
+ discount_list: nextBundleDiscountList
1318
+ };
1319
+ });
1320
+ }
1304
1321
  const totalPerUnitDiscount = (product.discount_list || []).reduce(
1305
1322
  (sum, pd) => sum + (pd.amount || 0),
1306
1323
  0
@@ -1389,6 +1406,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1389
1406
  ...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
1390
1407
  ...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
1391
1408
  ...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
1409
+ ...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
1392
1410
  ...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
1393
1411
  };
1394
1412
  return this.store.order.submitTempOrder(submitParams);
@@ -1408,6 +1426,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1408
1426
  ...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
1409
1427
  ...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
1410
1428
  ...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
1429
+ ...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
1411
1430
  ...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
1412
1431
  };
1413
1432
  return this.store.order.submitTempOrderAsync(submitParams);
@@ -1599,10 +1618,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1599
1618
  return this.store.order.deleteOrderPayment(paymentIdentity);
1600
1619
  }
1601
1620
  /** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
1602
- updateVoucherOrderPayments(payments) {
1621
+ updateVoucherOrderPayments(payments, options) {
1622
+ if (!this.store.order)
1623
+ throw new Error("order 模块未初始化");
1624
+ return this.store.order.updateVoucherOrderPayments(payments, options);
1625
+ }
1626
+ confirmPendingVoucherPayments() {
1627
+ if (!this.store.order)
1628
+ throw new Error("order 模块未初始化");
1629
+ return this.store.order.confirmPendingVoucherPayments();
1630
+ }
1631
+ discardPendingVoucherPayments() {
1603
1632
  if (!this.store.order)
1604
1633
  throw new Error("order 模块未初始化");
1605
- return this.store.order.updateVoucherOrderPayments(payments);
1634
+ return this.store.order.discardPendingVoucherPayments();
1606
1635
  }
1607
1636
  getWalletProductList() {
1608
1637
  var _a, _b, _c;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.7",
4
+ "version": "2.3.8",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",