Kaynağa Gözat

各渠道收入统计开始

shish 4 yıl önce
ebeveyn
işleme
3587316e57
1 değiştirilmiş dosya ile 58 ekleme ve 0 silme
  1. 58 0
      app-ghs/controllers/StatKdController.php

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

@@ -4,13 +4,71 @@ namespace ghs\controllers;
 
 use biz\stat\classes\StatKdClass;
 use biz\stat\classes\StatRefundClass;
+use bizGhs\order\classes\OrderClass;
+use bizHd\order\classes\SettleClass;
 use common\components\dateUtil;
 use Yii;
 use common\components\util;
+use bizHd\order\classes\OrderClass as HdOrderClass;
+use bizGhs\clear\classes\ClearClass;
 
 class StatKdController extends BaseController
 {
 
+    //各渠道收入 ssh 20220711
+    public function actionChannel()
+    {
+        //批发开单 零售开单 批发结账 零售结账
+
+        $todayDate = date('Y-m-d');
+        $todayStartTime = $todayDate . ' 00:00:00';
+        $todayEndTime = $todayDate . ' 23:59:59';
+
+        //批发开单
+        $where = ['shopId' => $this->shopId, 'status' => ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]]];
+        $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $ghsOrderList = OrderClass::getAllByCondition($where, null, '*');
+        if (!empty($ghsOrderList)) {
+            foreach ($ghsOrderList as $ghsKey => $ghsOrder) {
+                $payWay = $ghsOrder['payWay'] ?? 0;
+                $actPrice = $ghsOrder['actPrice'] ?? 0;
+            }
+        }
+
+        //零售开单
+        $hdWhere = ['shopId' => $this->shop['lsShopId'], 'status' => ['in', [HdOrderClass::ORDER_STATUS_UN_SEND, HdOrderClass::ORDER_STATUS_SENDING, HdOrderClass::ORDER_STATUS_COMPLETE]]];
+        $hdWhere['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $hdOrderList = HdOrderClass::getAllByCondition($hdWhere, null, '*');
+        foreach ($hdOrderList as $hdKey => $hdOrder) {
+            $payWay = $hdOrder['payWay'] ?? 0;
+            $mainPay = $hdOrder['mainPay'] ?? 0;
+            $cash = $hdOrder['cash'] ?? 0;
+        }
+
+        //批发结帐收入
+        $clearWhere = ['ghsShopId' => $this->shopId, 'status' => 2];
+        $clearWhere['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $clearList = ClearClass::getAllByCondition($clearWhere, null, '*');
+        if (!empty($clearList)) {
+            foreach ($clearList as $cKey => $clear) {
+                $payWay = $clear['payWay'] ?? 0;
+                $actPrice = $clear['actPrice'] ?? 0;
+            }
+        }
+
+        //零售结账收入
+        $settleWhere = ['shopId' => $this->shopId, 'status' => 2];
+        $settleWhere['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
+        $settleList = SettleClass::getAllByCondition($settleWhere, null, '*');
+        if (!empty($settleList)) {
+            foreach ($settleList as $sKey => $settle) {
+                $payWay = $settle['payWay'] ?? 0;
+                $actPrice = $settle['actPrice'] ?? 0;
+            }
+        }
+
+    }
+
     //开单收入统计 ssh 20211017
     public function actionProfile()
     {