Эх сурвалжийг харах

线上收入、现金收入、欠款的总笔数与总金额

shizhongqi 4 жил өмнө
parent
commit
af9c61d34f

+ 64 - 0
app-ghs/controllers/ConsoleController.php

@@ -5,6 +5,7 @@ namespace ghs\controllers;
 use biz\stat\classes\StatSaleClass;
 use biz\stat\services\StatOutService;
 use bizGhs\order\classes\OrderClass;
+use bizHd\order\classes\OrderClass as HdOrderClass;
 use bizHd\stat\classes\StatVisitClass;
 use common\components\dict;
 use common\components\util;
@@ -39,6 +40,69 @@ class ConsoleController extends BaseController
         util::success(['todayActIncome' => $todayActIncome, 'todayDebt' => $todayDebt, 'totalDebt' => $totalDebt]);
     }
 
+    //今日笔数和总金额
+    public function actionStrokeCount()
+    {
+        $todayDate = date('Y-m-d');
+        $todayStartTime = $todayDate . ' 00:00:00';
+        $todayEndTime = $todayDate . ' 23:59:59';
+
+        //线上收入 180笔  12000元
+        //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4)  and payWay in (0,1)
+        //xhOrder    actPrice 字段,条件 status in (2,3,4)  and payWay in (0,1)
+        $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00'];
+        $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
+        $where['payWay'] = ['in', [0, 1]];
+        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $ghActualCount = OrderClass::getCount($where); // 批发今日收入总笔数
+        $ghActIncome = OrderClass::sum($where, 'actPrice'); // 批发今日实收总数
+        Yii::info('批发今日收入总笔数:' . $ghActualCount . ', 批发今日实收总数:' . $ghActIncome);
+
+        unset($where['debt']);
+        unset($where['debtPrice']);
+        $hdActualCount = HdOrderClass::getCount($where); // 花店今日收入总笔数
+        $hdActualIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日收入金额总数
+        Yii::info('花店今日收入总笔数:' . $hdActualCount . ', 花店今日收入金额总数:' . $hdActualIncome);
+        $actualCount = $ghActualCount + $hdActualCount;
+        $actualIncome = $ghActIncome + $hdActualIncome;
+
+
+        //现金收入 23笔  5980元
+        //xhGhsOrder actPrice 字段,条件:debtPrice=0 and status in (2,3,4)  and payWay=4
+        //xhOrder    actPrice 字段,条件 status in (2,3,4)  and payWay=4
+        $where = ['shopId' => $this->shopId, 'debt' => 0, 'debtPrice' => '0.00'];
+        $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
+        $where['payWay'] = 4;
+        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $ghCachCount = OrderClass::getCount($where); // 批发今日现金总笔数
+        $ghCachIncome = OrderClass::sum($where, 'actPrice'); // 批发今日现金金额总数
+        Yii::info('批发今日现金总笔数:' . $ghCachCount . ', 批发今日现金金额总数:' . $ghCachIncome);
+
+        unset($where['debt']);
+        unset($where['debtPrice']);
+        $hdCachCount = HdOrderClass::getCount($where); // 花店今日现金总笔数
+        $hdCachIncome = HdOrderClass::sum($where, 'actPrice'); // 花店今日现金金额总数
+        Yii::info('花店今日现金总笔数:' . $hdCachCount . ', 花店今日现金金额总数:' . $hdCachIncome);
+        $cachCount = $ghCachCount + $hdCachCount;
+        $cachIncome = $ghCachIncome + $hdCachIncome;
+
+
+        //批发欠款 39笔 13980元
+        $where = ['shopId' => $this->shopId, 'debt' => 1]; // 重新赋值
+        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $ghDebtCount = OrderClass::getCount($where); // 批发今日欠款总笔数
+        $ghAllDebt = OrderClass::sum($where, 'remainDebtPrice'); // 批发今日总欠款
+
+        util::success([
+            'actualCount' => $actualCount,
+            'actualIncome' => $actualIncome,
+            'cachCount' => $cachCount,
+            'cachIncome' => $cachIncome,
+            'debtCount' => $ghDebtCount,
+            'allDebt' => $ghAllDebt,
+        ]);
+    }
+
     //概况 ssh 2019.12.19
     public function actionProfile()
     {