|
|
@@ -0,0 +1,47 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace bizGhs\stat\classes;
|
|
|
+
|
|
|
+use common\components\dateUtil;
|
|
|
+use Yii;
|
|
|
+use bizGhs\base\classes\BaseClass;
|
|
|
+
|
|
|
+class StatCgClass extends BaseClass
|
|
|
+{
|
|
|
+
|
|
|
+ public static function statCg($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, '*');
|
|
|
+ $cg = 0;
|
|
|
+ if (!empty($cgList)) {
|
|
|
+ foreach ($cgList as $cgKey => $cgItem) {
|
|
|
+ $actPrice = $cgItem['actPrice'] ?? 0;
|
|
|
+ $paidPrice = $cgItem['paidPrice'] ?? 0;
|
|
|
+ $total = bcadd($actPrice, $paidPrice, 2);
|
|
|
+ $cg = bcadd($cg, $total, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cg = floatval($cg);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|