Просмотр исходного кода

增加税额计算公用方法;移除无用文件

kevin_zhangl 3 лет назад
Родитель
Сommit
e9a9ba470e
3 измененных файлов с 14 добавлено и 7 удалено
  1. 0 5
      common/helpers/Constant.php
  2. 13 0
      common/helpers/Tool.php
  3. 1 2
      composer.json

+ 0 - 5
common/helpers/Constant.php

@@ -1,5 +0,0 @@
-<?php
-
-/* ********************【服务通用状态码】************************* */
-const SUCCESS_CODE = 200;   // 成功
-const FAILED_CODE = 500;    // 失败

+ 13 - 0
common/helpers/Tool.php

@@ -72,6 +72,19 @@ class Tool {
         }
     }
 
+    /**
+     * 计算商品税额
+     * @param $amount
+     * @param $taxRate
+     * @param int $buyNo
+     * @return float
+     */
+    public static function calculateTax($amount, $taxRate, int $buyNo = 1): float
+    {
+        $taxAmount = $amount - $amount / (1 + $taxRate / 100) * $buyNo;
+        return floatval(self::formatPrice($taxAmount));
+    }
+
     /**
      * 前台业绩格式化
      * @param $perf

+ 1 - 2
composer.json

@@ -49,8 +49,7 @@
     },
     "autoload": {
         "files": [
-            "common/helpers/LoggerTool.php",
-            "common/helpers/Constant.php"
+            "common/helpers/LoggerTool.php"
         ]
     },
     "repositories": {