Browse Source

采购业绩

shish 2 years ago
parent
commit
63cfea12c6
2 changed files with 64 additions and 0 deletions
  1. 17 0
      app-ghs/controllers/StatCgController.php
  2. 47 0
      biz-ghs/stat/classes/StatCgClass.php

+ 17 - 0
app-ghs/controllers/StatCgController.php

@@ -26,4 +26,21 @@ class StatCgController extends BaseController
         util::success(['list' => $list, 'staffCg' => $staffCg]);
     }
 
+
+    //采购人业绩 ssh 2024412
+    public function actionYj()
+    {
+        ini_set('memory_limit', '2045M');
+        set_time_limit(0);
+        //查看财务的权限
+        $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
+        if ($lookMoney == 0) {
+            //util::fail('无法查看');
+        }
+        $mainId = $this->mainId;
+        $respond = StatCgClass::statCgYj($mainId);
+        $staffCg = $respond['staffCg'] ?? [];
+        util::success(['staffCg' => $staffCg]);
+    }
+
 }

+ 47 - 0
biz-ghs/stat/classes/StatCgClass.php

@@ -99,4 +99,51 @@ class StatCgClass extends BaseClass
         return ['itemList' => $arr, 'staffCg' => $cgData];
     }
 
+    //采购人业绩 ssh 20240412
+    public static function statCgYj($mainId)
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['mainId'] = $mainId;
+        $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'];
+        $where['time'] = ['between', [$start, $end]];
+
+        $currentStartDate = date('Y-m-d', strtotime($start));
+        $currentEndDate = date('Y-m-d', strtotime($end));
+        $currentStartTime = $currentStartDate . ' 00:00:00';
+        $currentEndTime = $currentEndDate . ' 23:59:59';
+
+        $cgWhere = ['mainId' => $mainId, 'status' => 4];
+        $cgWhere['entryTime'] = ['between', [$currentStartTime, $currentEndTime]];
+        $cgList = PurchaseOrderClass::getAllByCondition($cgWhere, null, '*');
+
+        $cgData = [];
+        if (!empty($cgList)) {
+            foreach ($cgList as $cgKey => $cgInfo) {
+                $cgStaffId = $cgInfo['cgStaffId'] ?? 0;
+                $cgStaffName = $cgInfo['cgStaffName'] ?? '';
+                $actPrice = $cgInfo['actPrice'] ?? 0;
+                if (isset($cgData[$cgStaffId])) {
+                    $cgData[$cgStaffId]['amount'] = bcadd($cgData[$cgStaffId]['amount'], $actPrice, 2);
+                } else {
+                    $cgData[$cgStaffId]['cgStaffId'] = $cgStaffId;
+                    $cgData[$cgStaffId]['cgStaffName'] = $cgStaffName;
+                    $cgData[$cgStaffId]['amount'] = $actPrice;
+                    $cgData[$cgStaffId]['num'] = 1;
+                }
+            }
+        }
+
+        if (!empty($cgData)) {
+            $cgData = array_values($cgData);
+        }
+        return ['staffCg' => $cgData];
+    }
+
 }