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