|
|
@@ -14,6 +14,46 @@ use common\components\util;
|
|
|
class StatController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //按月统计损耗情况
|
|
|
+ public function actionWaste()
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+ $mainId = $this->mainId;
|
|
|
+ $list = \bizGhs\order\classes\StockWastageOrderClass::getAllByCondition(['mainId' => $mainId], null, '*');
|
|
|
+ $arr = [];
|
|
|
+ $totalNum = 0;
|
|
|
+ $totalCost = 0;
|
|
|
+ $totalPrice = 0;
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $order) {
|
|
|
+ $addTime = $order['addTime'];
|
|
|
+ $time = date("Ym", strtotime($addTime));
|
|
|
+ $date = date("Y年n月", strtotime($addTime));
|
|
|
+ $bigNum = $order['bigNum'] ?? 0;
|
|
|
+ $cost = $order['cost'] ?? 0;
|
|
|
+ $price = $order['price'] ?? 0;
|
|
|
+ if (isset($arr[$time])) {
|
|
|
+ $arr[$time]['num'] = bcadd($arr[$time]['num'], $bigNum);
|
|
|
+ $arr[$time]['cost'] = bcadd($arr[$time]['cost'], $cost, 2);
|
|
|
+ $arr[$time]['price'] = bcadd($arr[$time]['price'], $price, 2);
|
|
|
+ $arr[$time]['time'] = $date;
|
|
|
+ } else {
|
|
|
+ $arr[$time]['num'] = $bigNum;
|
|
|
+ $arr[$time]['cost'] = $cost;
|
|
|
+ $arr[$time]['price'] = $price;
|
|
|
+ $arr[$time]['time'] = $date;
|
|
|
+ }
|
|
|
+ $totalNum = bcadd($totalNum, $bigNum);
|
|
|
+ $totalCost = bcadd($totalCost, $cost, 2);
|
|
|
+ $totalPrice = bcadd($totalPrice, $price, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $totalCost = floatval($totalCost);
|
|
|
+ $totalPrice = floatval($totalPrice);
|
|
|
+ util::success(['list' => $arr, 'totalNum' => $totalNum, 'totalCost' => $totalCost, 'totalPrice' => $totalPrice]);
|
|
|
+ }
|
|
|
+
|
|
|
//利润表 ssh 20230303
|
|
|
public function actionProfit()
|
|
|
{
|