@pisell/private-materials 6.6.68 → 6.6.69

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.
@@ -787,7 +787,20 @@ var Info = function Info(_, ref) {
787
787
  }
788
788
  var origin_total = _total;
789
789
  if (item.discount_amount) {
790
+ var _item$_extend14, _item$_extend15;
790
791
  origin_total = getProductOriginTotalPrice(cacheItem);
792
+ var previousOriginTotal = Number((item === null || item === void 0 || (_item$_extend14 = item._extend) === null || _item$_extend14 === void 0 ? void 0 : _item$_extend14.origin_total) || 0);
793
+ var previousTotal = Number((item === null || item === void 0 || (_item$_extend15 = item._extend) === null || _item$_extend15 === void 0 ? void 0 : _item$_extend15.total) || 0);
794
+ var productAllDiscountList = getProductAllDiscountList(item);
795
+ var hasNonManualDiscount = productAllDiscountList.some(function (discountItem) {
796
+ return (discountItem === null || discountItem === void 0 ? void 0 : discountItem.type) !== 'product';
797
+ });
798
+ if (previousOriginTotal > 0 && Number.isFinite(previousOriginTotal) && Number.isFinite(previousTotal) && !hasNonManualDiscount) {
799
+ // 手动折扣编辑套餐时只延续旧折后比例,不改子商品单价,避免后续重复折扣。
800
+ var sellingRatio = new Decimal(previousTotal).div(previousOriginTotal);
801
+ _total = new Decimal(origin_total).mul(sellingRatio).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
802
+ cacheItem._extend.total = _total;
803
+ }
791
804
  }
792
805
 
793
806
  // 用于储存原价
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -299,8 +299,8 @@ export declare const backUpFree: (payload: Partial<State>) => {
299
299
  amount?: string | number | undefined;
300
300
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | undefined;
303
- action?: "amount" | "pay" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | undefined;
303
+ action?: "pay" | "amount" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
@@ -542,7 +542,7 @@ var Info = (_, ref) => {
542
542
  }
543
543
  },
544
544
  callback: (e2, extension_type, detail) => {
545
- var _a3, _b3, _c3, _d3, _e3, _f3, _g3, _h3, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2;
545
+ var _a3, _b3, _c3, _d3, _e3, _f3, _g3, _h3, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2;
546
546
  isEditedRef.current = true;
547
547
  const _detail = detail || item;
548
548
  let other = JSON.parse(JSON.stringify(e2));
@@ -613,9 +613,20 @@ var Info = (_, ref) => {
613
613
  let origin_total = _total;
614
614
  if (item.discount_amount) {
615
615
  origin_total = (0, import_utils6.getProductOriginTotalPrice)(cacheItem);
616
+ const previousOriginTotal = Number(((_p2 = item == null ? void 0 : item._extend) == null ? void 0 : _p2.origin_total) || 0);
617
+ const previousTotal = Number(((_q2 = item == null ? void 0 : item._extend) == null ? void 0 : _q2.total) || 0);
618
+ const productAllDiscountList = (0, import_utils8.getProductAllDiscountList)(item);
619
+ const hasNonManualDiscount = productAllDiscountList.some(
620
+ (discountItem) => (discountItem == null ? void 0 : discountItem.type) !== "product"
621
+ );
622
+ if (previousOriginTotal > 0 && Number.isFinite(previousOriginTotal) && Number.isFinite(previousTotal) && !hasNonManualDiscount) {
623
+ const sellingRatio = new import_decimal.default(previousTotal).div(previousOriginTotal);
624
+ _total = new import_decimal.default(origin_total).mul(sellingRatio).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
625
+ cacheItem._extend.total = _total;
626
+ }
616
627
  }
617
628
  cacheItem._extend.origin_total = origin_total;
618
- (((_p2 = cacheItem._extend) == null ? void 0 : _p2.items) || []).forEach((item2) => item2._extend.origin_total = origin_total);
629
+ (((_r2 = cacheItem._extend) == null ? void 0 : _r2.items) || []).forEach((item2) => item2._extend.origin_total = origin_total);
619
630
  dispatch({
620
631
  type: "setService",
621
632
  payload: {
@@ -624,7 +635,7 @@ var Info = (_, ref) => {
624
635
  });
625
636
  form.setFieldsValue({
626
637
  total: _total,
627
- capacity: (_q2 = cacheItem._extend) == null ? void 0 : _q2.capacity,
638
+ capacity: (_s2 = cacheItem._extend) == null ? void 0 : _s2.capacity,
628
639
  quantity: (e2 == null ? void 0 : e2.quantity) || (values == null ? void 0 : values.quantity) || 1
629
640
  });
630
641
  }
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu">;
22
+ readonly eftposRef: React.MutableRefObject<"stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  readonly dataRef: React.MutableRefObject<import("./store").State>;
25
25
  };
@@ -299,8 +299,8 @@ export declare const backUpFree: (payload: Partial<State>) => {
299
299
  amount?: string | number | undefined;
300
300
  mode?: "pay" | "refund" | "fullPay" | "query" | undefined;
301
301
  order_id?: string | number | undefined;
302
- eftpos?: "stripe" | "tyro" | "windcave" | "mx51" | "payo" | "linkly" | "huifu" | undefined;
303
- action?: "amount" | "pay" | "deviceList" | undefined;
302
+ eftpos?: "stripe" | "tyro" | "mx51" | "payo" | "windcave" | "linkly" | "huifu" | undefined;
303
+ action?: "pay" | "amount" | "deviceList" | undefined;
304
304
  key?: number | undefined;
305
305
  step?: number | undefined;
306
306
  title?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.6.68",
3
+ "version": "6.6.69",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -63,8 +63,8 @@
63
63
  "@use-gesture/react": "^10.3.1",
64
64
  "@pisell/utils": "3.0.2",
65
65
  "@pisell/materials": "6.6.17",
66
- "@pisell/icon": "0.0.11",
67
- "@pisell/date-picker": "3.0.7"
66
+ "@pisell/date-picker": "3.0.7",
67
+ "@pisell/icon": "0.0.11"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0",