@pisell/pisellos 2.2.164 → 2.2.165

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 (34) hide show
  1. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +45 -15
  2. package/dist/modules/Order/index.d.ts +10 -3
  3. package/dist/modules/Order/index.js +272 -142
  4. package/dist/modules/Order/types.d.ts +14 -2
  5. package/dist/modules/Order/types.js +2 -0
  6. package/dist/modules/Order/utils.d.ts +10 -0
  7. package/dist/modules/Order/utils.js +67 -15
  8. package/dist/server/index.js +1 -0
  9. package/dist/solution/BaseSales/index.d.ts +9 -1
  10. package/dist/solution/BaseSales/index.js +369 -240
  11. package/dist/solution/BaseSales/types.d.ts +3 -0
  12. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
  13. package/dist/solution/BaseSales/utils.js +36 -7
  14. package/dist/solution/BookingTicket/index.d.ts +3 -0
  15. package/dist/solution/BookingTicket/index.js +155 -86
  16. package/dist/solution/BookingTicket/utils/addProductDecision.js +19 -11
  17. package/dist/solution/ScanOrder/utils.js +36 -7
  18. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +35 -9
  19. package/lib/modules/Order/index.d.ts +10 -3
  20. package/lib/modules/Order/index.js +104 -4
  21. package/lib/modules/Order/types.d.ts +14 -2
  22. package/lib/modules/Order/utils.d.ts +10 -0
  23. package/lib/modules/Order/utils.js +58 -9
  24. package/lib/server/index.js +1 -0
  25. package/lib/solution/BaseSales/index.d.ts +9 -1
  26. package/lib/solution/BaseSales/index.js +65 -3
  27. package/lib/solution/BaseSales/types.d.ts +3 -0
  28. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
  29. package/lib/solution/BaseSales/utils.js +37 -5
  30. package/lib/solution/BookingTicket/index.d.ts +3 -0
  31. package/lib/solution/BookingTicket/index.js +48 -6
  32. package/lib/solution/BookingTicket/utils/addProductDecision.js +16 -8
  33. package/lib/solution/ScanOrder/utils.js +37 -5
  34. package/package.json +1 -1
@@ -406,12 +406,40 @@ function getProductIdentityIndex(products, identity) {
406
406
  return products.findIndex((item) => isIdentityMatch(item, identity));
407
407
  }
408
408
  function normalizeOrderProduct(product) {
409
- var _a, _b, _c;
409
+ var _a, _b, _c, _d, _e, _f;
410
410
  const metadata = { ...product.metadata || {} };
411
411
  const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
412
412
  metadata.unique_identification_number = resolvedIdentityKey;
413
- const normalizedBundle = (product.product_bundle || []).map((item) => ({
413
+ const priceOverride = metadata.price_override;
414
+ const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
415
+ let bundleInput = product.product_bundle || [];
416
+ if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
417
+ const priceById = /* @__PURE__ */ new Map();
418
+ originOtherBundle.forEach((item) => {
419
+ if ((item == null ? void 0 : item.id) == null)
420
+ return;
421
+ const unit = item.price ?? item.bundle_selling_price;
422
+ if (unit === void 0 || unit === null)
423
+ return;
424
+ priceById.set(String(item.id), String(unit));
425
+ });
426
+ const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
427
+ bundleInput = base.map((item) => {
428
+ const unit = priceById.get(String(item == null ? void 0 : item.id));
429
+ if (unit === void 0)
430
+ return item;
431
+ return {
432
+ ...item,
433
+ price: unit,
434
+ bundle_selling_price: unit
435
+ };
436
+ });
437
+ }
438
+ const normalizedBundle = bundleInput.map((item) => ({
414
439
  ...item,
440
+ bundle_id: item.bundle_id ?? item.id,
441
+ bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
442
+ bundle_group_id: item.bundle_group_id ?? item.group_id,
415
443
  bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
416
444
  price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
417
445
  price_type: item.price_type ?? item.custom_price_type ?? "",
@@ -421,8 +449,8 @@ function normalizeOrderProduct(product) {
421
449
  const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
422
450
  const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
423
451
  const variantId = Number(product.product_variant_id || 0);
424
- const variantList = variantId ? (_b = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _b.variant : null;
425
- const variantPrice = Array.isArray(variantList) ? (_c = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _c.price : void 0;
452
+ const variantList = variantId ? (_e = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _e.variant : null;
453
+ const variantPrice = Array.isArray(variantList) ? (_f = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _f.price : void 0;
426
454
  const resolvedSource = (() => {
427
455
  var _a2, _b2;
428
456
  if (metadata.source_product_price !== void 0) {
@@ -478,6 +506,10 @@ function normalizeOrderProduct(product) {
478
506
  bundle: normalizedBundle,
479
507
  useOriginalBundle: true
480
508
  });
509
+ const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
510
+ { num: product.num, metadata },
511
+ composedOriginalPrice
512
+ );
481
513
  return {
482
514
  order_detail_id: product.order_detail_id || null,
483
515
  product_id: product.product_id,
@@ -485,7 +517,7 @@ function normalizeOrderProduct(product) {
485
517
  product_variant_id: product.product_variant_id,
486
518
  product_option_item: normalizedOptions,
487
519
  selling_price: composedSellingPrice,
488
- original_price: composedOriginalPrice,
520
+ original_price: finalOriginalPrice,
489
521
  tax_fee: product.tax_fee || "0.00",
490
522
  is_charge_tax: product.is_charge_tax ?? 0,
491
523
  discount_list: product.discount_list || [],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.164",
4
+ "version": "2.2.165",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",