shish 3 жил өмнө
parent
commit
8c40873cf1

+ 12 - 0
app-ghs/controllers/StatItemController.php

@@ -81,6 +81,15 @@ class StatItemController extends BaseController
                 }
             }
         }
+        //增加毛利率
+        foreach ($stat as $key => $val) {
+            $profit = $val['gross'] ?? 0;
+            $price = $val['amount'] ?? 0;
+            $mll = bcdiv($profit, $price, 3);
+            $mll = bcmul($mll, 100);
+            $mll = round($mll, 1);
+            $stat[$key]['mll'] = $mll;
+        }
         $rank = 'num';
         if ($sort == 'gross') {
             $rank = 'gross';
@@ -88,6 +97,9 @@ class StatItemController extends BaseController
         if ($sort == 'amount') {
             $rank = 'amount';
         }
+        if ($sort == 'mll') {
+            $rank = 'mll';
+        }
         $stat = arrayUtil::arraySort($stat, $rank);
         util::success(['list' => $stat]);
     }