|
|
@@ -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];
|
|
|
+ }
|
|
|
+
|
|
|
}
|