shish 3 lat temu
rodzic
commit
ffb286aebd

+ 58 - 0
app-hd/controllers/StatKindController.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\goods\classes\KindClass;
+use bizHd\work\classes\WorkClass;
+use bizHd\work\classes\WorkItemClass;
+use common\components\dateUtil;
+use Yii;
+use common\components\util;
+
+class StatKindController extends BaseController
+{
+
+    //各渠道收入 ssh 20220711
+    public function actionProfile()
+    {
+        $get = Yii::$app->request->get();
+
+        $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
+        $startTime = $get['startTime'] ?? '';
+        $endTime = $get['endTime'] ?? '';
+        $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
+        $start = $period['startTime'];
+        $end = $period['endTime'];
+        $currentStartDate = date('Y-m-d', strtotime($start));
+        $currentEndDate = date('Y-m-d', strtotime($end));
+        $currentStartTime = $currentStartDate . ' 00:00:00';
+        $currentEndTime = $currentEndDate . ' 23:59:59';
+
+        $mainId = $this->mainId;
+
+        $list = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
+
+        $where = ['mainId' => $mainId, 'status' => 1];
+        $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]];
+        $workList = WorkClass::getAllByCondition($where, null, '*', null, true);
+        if (!empty($workList)) {
+            foreach ($workList as $work) {
+                $workSn = $work->workSn ?? '';
+            }
+        }
+
+
+        $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);
+            }
+        }
+        util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
+    }
+
+}

+ 4 - 0
biz-hd/goods/classes/GoodsClass.php

@@ -715,6 +715,8 @@ class GoodsClass extends BaseClass
             $anonymity = $params['anonymity'] ?? 0;
             $manyType = $params['manyType'] ?? 0;
             $sendNum = $params['sendNum'] ?? '';
+            $kindId = $params['kindId'] ?? 0;
+            $kindName = $params['kindName'] ?? '';
             $hasReachTime = 0;
             $reachPeriod = 0;
             $reachDate = '0000-00-00';
@@ -759,6 +761,8 @@ class GoodsClass extends BaseClass
                 'sh' => $sh,
                 'manyType' => $manyType,
                 'sendNum' => $sendNum,
+                'kindId' => $kindId,
+                'kindName' => $kindName,
             ];
             $main = MainClass::getById($mainId, true);
             if (empty($main)) {

+ 4 - 0
biz-hd/work/classes/WorkClass.php

@@ -130,6 +130,8 @@ class WorkClass extends BaseClass
         $sh = $data['sh'] ?? 0;
         $manyType = $data['manyType'] ?? 0;
         $sendNum = $data['sendNum'] ?? '';
+        $kindId = $data['kindId'] ?? 0;
+        $kindName = $data['kindName'] ?? '';
 
         $ids = array_column($goods, 'productId');
         $info = GoodsClass::getByIds($ids, null, 'id');
@@ -199,6 +201,8 @@ class WorkClass extends BaseClass
                 'sh' => $sh,
                 'manyType' => $manyType,
                 'sendNum' => $sendNum,
+                'kindId' => $kindId,
+                'kindName' => $kindName,
             ];
             self::createFinish($current, $main);
         }

+ 4 - 1
biz-mall/order/classes/OrderGoodsClass.php

@@ -29,6 +29,8 @@ class OrderGoodsClass extends BaseClass
 
                 $goodsId = $goods->goodsId ?? 0;
                 $num = $goods->num ?? 0;
+                $kindId = $goods->kindId ?? 0;
+                $kindName = $goods->kindName ?? '';
                 $orderPrice = $order->orderPrice ?? 0;
                 $fromType = $order->fromType ?? 1;
                 $remark = $order->remark ?? '';
@@ -40,7 +42,8 @@ class OrderGoodsClass extends BaseClass
                 $manyType = $order->manyType ?? 0;
                 $sendNum = $order->sendNum ?? '';
                 $params = ['orderId' => $orderId, 'orderSn' => $orderSn, 'shopId' => $shopId, 'sendType' => $sendType, 'thirdSn' => $thirdSn, 'cardInfo' => $cardInfo, 'anonymity' => $anonymity,
-                    'fromType' => $fromType, 'orderPrice' => $orderPrice, 'remark' => $remark, 'orderDebtPrice' => $orderDebtPrice, 'manyType' => $manyType, 'sendNum' => $sendNum];
+                    'fromType' => $fromType, 'orderPrice' => $orderPrice, 'remark' => $remark, 'orderDebtPrice' => $orderDebtPrice, 'manyType' => $manyType, 'sendNum' => $sendNum,
+                    'kindId' => $kindId, 'kindName' => $kindName];
                 $flower = $goods->flower ?? 0;
                 //鲜花类不需要验证库存,库存可以负数,并相应生成制作单
                 $checkStock = $flower == 0 ? true : false;