vgpastor/discounts-calculator

管理不同类型的折扣并计算相关数据的辅助库

1.0.0 2022-10-08 21:03 UTC

This package is auto-updated.

Last update: 2024-09-09 01:17:51 UTC


README

应用中计算折扣的辅助库。

安装

此库是为PHP 8.1开发的,使用枚举,因此不能用于之前的版本。如果您喜欢,可以提交一个PR来使其兼容之前的版本。 composer install vgpastor/discounts-calculator

用法

您可以在example.php文件中查看如何使用。

必需参数包括

  • $type: 折扣类型。可以是 'percentage' 或 'amount',基于基本金额或总金额(参见DiscountTypeEnum)
  • $base (float) - 基本价格
  • $discount (float) - 折扣百分比或金额

可选参数包括

  • $tax (float) - 税率百分比。默认为0%
  • $precision (int) - 结果的精度。默认为2
  • $roundingMode (int) - 四舍五入模式。默认为PHP_ROUND_HALF_UP