shish 3 년 전
부모
커밋
b221b6fded
4개의 변경된 파일63개의 추가작업 그리고 121개의 파일을 삭제
  1. 0 5
      app-ghs/controllers/StatKdController.php
  2. 18 56
      app-hd/controllers/StatController.php
  3. 16 59
      app-hd/controllers/StatKdController.php
  4. 29 1
      biz-ghs/stat/classes/StatSaleClass.php

+ 0 - 5
app-ghs/controllers/StatKdController.php

@@ -12,23 +12,19 @@ class StatKdController extends BaseController
     //各渠道收入 ssh 20220711
     public function actionProfile()
     {
-
         $shopAdmin = $this->shopAdmin;
         if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
             util::fail('超管才能查看');
         }
-
         //惠雅鲜花员工不能看收入情况
         $shopAdmin = $this->shopAdmin;
         $adminId = $shopAdmin->adminId ?? 0;
         if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
             util::fail('暂无权限');
         }
-
         $get = Yii::$app->request->get();
         $contain = $get['contain'] ?? 0;
         $incomeList = StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
-
         $totalIncome = 0;
         if (!empty($incomeList)) {
             foreach ($incomeList as $item) {
@@ -37,7 +33,6 @@ class StatKdController extends BaseController
                 $totalIncome = floatval($totalIncome);
             }
         }
-
         util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
     }
 

+ 18 - 56
app-hd/controllers/StatController.php

@@ -14,74 +14,36 @@ use common\components\util;
 class StatController extends BaseController
 {
 
-    //利润表 ssh 20210829
+    //利润表 ssh 20230303
     public function actionProfit()
     {
-        $get = Yii::$app->request->get();
-        $where = [];
-        $where['mainId'] = $this->mainId;
-        $searchTime = $get['searchTime'] ?? 'today';
-        if (!empty($searchTime)) {
-            $startTime = $get['startTime'] ?? '';
-            $endTime = $get['endTime'] ?? '';
-            $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
-            $where['time'] = ['between', [$period['startTime'], $period['endTime']]];
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('超管才能查看');
         }
 
         //惠雅鲜花员工不能看利润表
         $shopAdmin = $this->shopAdmin;
         $adminId = $shopAdmin->adminId ?? 0;
-        if (in_array($adminId, [2366, 2812, 4004])) {
+        if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
             util::fail('暂无权限');
         }
 
-        //开单
-        $sale = StatSaleClass::getSum($where);
-
-        //调拨出库
-        $stockOut = StatStockOutClass::getSum($where);
-        //盘盈
-        //$pdAdd = StatPdAddClass::getSum($where);
-
-        //采购入库
-        $cg = StatCgClass::getSum($where);
-        //报损
-        //$wast = StatWastClass::getSum($where);
-        //调拨入库
-        $stockIn = StatStockInClass::getSum($where);
-        //盘亏
-        //$pdSub = StatPdSubClass::getSum($where);
-        //退款
-        $refund = StatRefundClass::getSum($where);
-
-        $in = $sale;
-        $in = bcadd($in, $stockOut, 2);
-        //$in = bcadd($in, $pdAdd, 2);
-        $out = $cg;
-        //$out = bcadd($out, $wast, 2);
-        $out = bcadd($out, $stockIn, 2);
-        //$out = bcadd($out, $pdSub, 2);
-        $out = bcadd($out, $refund, 2);
-        $balance = bcsub($in, $out, 2);
-
-        $out = [
-            'income' => [
-                ['name' => '销售', 'amount' => $sale],
-                ['name' => '调拨出库', 'amount' => $stockOut],
-                //['name' => '盘盈', 'amount' => $pdAdd],
-            ],
-            'expend' => [
-                ['name' => '采购', 'amount' => $cg],
-                //['name' => '损耗', 'amount' => $wast],
-                ['name' => '调拨入库', 'amount' => $stockIn],
-                //['name' => '盘亏', 'amount' => $pdSub],
-                ['name' => '退款', 'amount' => $refund],
-            ],
-            'balance' => $balance,
-        ];
+        $mainId = $this->mainId;
+        $respond = \bizGhs\stat\classes\StatSaleClass::profile($mainId);
+        $income = $respond['income'] ?? 0;
+        $expend = $respond['expend'] ?? 0;
+        $balance = $respond['balance'] ?? 0;
 
-        util::success($out);
+        //由于损耗而造成少赚的钱
+        $wastageRespond = \bizGhs\stat\classes\StatSaleClass::wastage($mainId);
+        $wastagePrice = $wastageRespond['totalPrice'] ?? 0;
+        $wastagePrice = floatval($wastagePrice);
 
+        util::success(['income' => $income, 'expend' => $expend, 'balance' => floatval($balance), 'wastagePrice' => $wastagePrice]);
     }
 
     //统计列表 ssh 2020.1.5

+ 16 - 59
app-hd/controllers/StatKdController.php

@@ -1,79 +1,36 @@
 <?php
 
 namespace hd\controllers;
-
-use biz\stat\classes\StatKdClass;
-use biz\stat\classes\StatRefundClass;
-use common\components\dateUtil;
 use Yii;
 use common\components\util;
-
 class StatKdController extends BaseController
 {
 
-    //开单收入统计 ssh 20211017
+    //各渠道收入 ssh 20220711
     public function actionProfile()
     {
-        $get = Yii::$app->request->get();
-        $where = [];
-        $where['shopId'] = $this->shopId;
-        if (isset($get['shopId']) && !empty($get['shopId'])) {
-            $where['shopId'] = $get['shopId'];
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('超管才能查看');
         }
-
-        //惠雅鲜花员工不能看利润表
+        //惠雅鲜花员工不能看收入情况
         $shopAdmin = $this->shopAdmin;
         $adminId = $shopAdmin->adminId ?? 0;
-        if (in_array($adminId, [2366, 2812, 4004])) {
+        if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
             util::fail('暂无权限');
         }
-
-        $searchTime = $get['searchTime'] ?? 'today';
-        if (!empty($searchTime)) {
-            $startTime = $get['startTime'] ?? '';
-            $endTime = $get['endTime'] ?? '';
-            $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
-            $where['time'] = ['between', [$period['startTime'], $period['endTime']]];
-        }
-        $kdList = StatKdClass::getAllByCondition($where, null, '*');
-
-        $kd = ['wx' => 0, 'alipay' => 0, 'balance' => 0, 'cash' => 0, 'bank' => 0, 'debt' => 0, 'amount' => 0];
-        if (!empty($kdList)) {
-            foreach ($kdList as $key => $item) {
-                $kd['wx'] = bcadd($kd['wx'], $item['wx']);
-                $kd['alipay'] = bcadd($kd['alipay'], $item['alipay']);
-                $kd['balance'] = bcadd($kd['balance'], $item['balance']);
-                $kd['cash'] = bcadd($kd['cash'], $item['cash']);
-                $kd['bank'] = bcadd($kd['bank'], $item['bank']);
-                $kd['debt'] = bcadd($kd['debt'], $item['debt']);
-                $kd['amount'] = bcadd($kd['amount'], $item['amount']);
-            }
-        }
-
-        $refund = ['wx' => 0, 'alipay' => 0, 'balance' => 0, 'cash' => 0, 'bank' => 0, 'debt' => 0, 'amount' => 0];
-        $refundList = StatRefundClass::getAllByCondition($where, null, '*');
-        if (!empty($refundList)) {
-            foreach ($refundList as $key => $item) {
-                $refund['wx'] = bcadd($refund['wx'], $item['wx']);
-                $refund['alipay'] = bcadd($refund['alipay'], $item['alipay']);
-                $refund['balance'] = bcadd($refund['balance'], $item['balance']);
-                $refund['cash'] = bcadd($refund['cash'], $item['cash']);
-                $refund['bank'] = bcadd($refund['bank'], $item['bank']);
-                $refund['debt'] = bcadd($refund['debt'], $item['debt']);
-                $refund['amount'] = bcadd($refund['amount'], $item['amount']);
+        $get = Yii::$app->request->get();
+        $contain = $get['contain'] ?? 0;
+        $incomeList = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
+        $totalIncome = 0;
+        if (!empty($incomeList)) {
+            foreach ($incomeList as $item) {
+                $amount = $item['amount'] ?? 0;
+                $totalIncome = bcadd($totalIncome, $amount, 2);
+                $totalIncome = floatval($totalIncome);
             }
         }
-        $arr = [
-            ['name' => '微信支付', 'kd' => $kd['wx'], 'refund' => $refund['wx']],
-            ['name' => '支付宝', 'kd' => $kd['alipay'], 'refund' => $refund['alipay']],
-            ['name' => '欠账', 'kd' => $kd['debt'], 'refund' => $refund['debt']],
-            ['name' => '余额', 'kd' => $kd['balance'], 'refund' => $refund['balance']],
-            ['name' => '现金', 'kd' => $kd['cash'], 'refund' => $refund['cash']],
-            ['name' => '银行卡', 'kd' => $kd['bank'], 'refund' => $refund['bank']],
-            ['name' => '总计', 'kd' => $kd['amount'], 'refund' => $refund['amount']],
-        ];
-        $income = floatval(bcsub($kd['amount'], $refund['amount'], 2));
-        util::success(['list' => $arr, 'income' => $income]);
+        util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
     }
 
 }

+ 29 - 1
biz-ghs/stat/classes/StatSaleClass.php

@@ -9,8 +9,10 @@ use bizGhs\expend\classes\ExpendClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\order\classes\StockWastageOrderClass;
 use bizGhs\staff\classes\SalaryClass;
+use bizHd\goods\classes\PlantCgClass;
 use bizHd\order\classes\OrderClass as HdOrderClass;
 use bizGhs\order\classes\OrderClass;
+use bizHd\purchase\classes\PurchaseClass;
 use common\components\dateUtil;
 use common\components\dict;
 use Yii;
@@ -89,6 +91,30 @@ class StatSaleClass extends BaseClass
         }
         $cg = floatval($cg);
 
+        $lsCgWhere = ['mainId' => $mainId, 'status' => 4];
+        $lsCgWhere['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
+        $lsCgList = PurchaseClass::getAllByCondition($lsCgWhere, null, '*');
+        $lsCgAmount = 0;
+        if (!empty($lsCgList)) {
+            foreach ($lsCgList as $lsCgItem) {
+                $actPrice = $lsCgItem['actPrice'] ?? 0;
+                $lsCgAmount = bcadd($lsCgAmount, $actPrice, 2);
+            }
+        }
+        $lsCgAmount = floatval($lsCgAmount);
+
+        $lzWhere = ['mainId' => $mainId, 'status' => 3];
+        $lzWhere['entryTime'] = ['between', [$currentStartTime, $currentEndTime]];
+        $lzCgList = PlantCgClass::getAllByCondition($lzWhere, null, '*');
+        $lzCgAmount = 0;
+        if (!empty($lzCgList)) {
+            foreach ($lzCgList as $lzInfo) {
+                $actPrice = $lzInfo['actPrice'] ?? 0;
+                $lzCgAmount = bcadd($actPrice, $lzCgAmount, 2);
+            }
+        }
+        $lzCgAmount = floatval($lzCgAmount);
+
         //调拨入库
         $stockIn = StatStockInClass::getSum($where);
 
@@ -166,7 +192,9 @@ class StatSaleClass extends BaseClass
             ['name' => '批发运费', 'id' => 'pfSendCost', 'amount' => floatval($pfSendCost)],
             ['name' => '零售运费', 'id' => 'lsSendCost', 'amount' => floatval($lsSendCost)],
             ['name' => '美团手续费', 'id' => 'mtFee', 'amount' => floatval($lsServiceFee)],
-            ['name' => '采购', 'id' => 'cg', 'amount' => floatval($cg)],
+            ['name' => '花材采购', 'id' => 'cg', 'amount' => floatval($cg)],
+            ['name' => '绿植资材采购', 'id' => 'cg', 'amount' => floatval($lzCgAmount)],
+            ['name' => '零售花材采购', 'id' => 'cg', 'amount' => floatval($lsCgAmount)],
             ['name' => '调拨入库', 'id' => 'allot', 'amount' => floatval($stockIn)],
             ['name' => '员工工资', 'id' => 'salary', 'amount' => floatval($salary)],
         ];