StatKindController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\goods\classes\KindClass;
  4. use bizHd\work\classes\WorkClass;
  5. use bizHd\work\classes\WorkItemClass;
  6. use common\components\dateUtil;
  7. use Yii;
  8. use common\components\util;
  9. class StatKindController extends BaseController
  10. {
  11. //各渠道收入 ssh 20220711
  12. public function actionProfile()
  13. {
  14. $get = Yii::$app->request->get();
  15. $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
  16. $startTime = $get['startTime'] ?? '';
  17. $endTime = $get['endTime'] ?? '';
  18. $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
  19. $start = $period['startTime'];
  20. $end = $period['endTime'];
  21. $currentStartDate = date('Y-m-d', strtotime($start));
  22. $currentEndDate = date('Y-m-d', strtotime($end));
  23. $currentStartTime = $currentStartDate . ' 00:00:00';
  24. $currentEndTime = $currentEndDate . ' 23:59:59';
  25. $mainId = $this->mainId;
  26. $list = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
  27. $where = ['mainId' => $mainId, 'status' => 1];
  28. $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]];
  29. $workList = WorkClass::getAllByCondition($where, null, '*', null, true);
  30. if (!empty($workList)) {
  31. foreach ($workList as $work) {
  32. $workSn = $work->workSn ?? '';
  33. }
  34. }
  35. $contain = $get['contain'] ?? 0;
  36. $incomeList = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
  37. $totalIncome = 0;
  38. if (!empty($incomeList)) {
  39. foreach ($incomeList as $item) {
  40. $amount = $item['amount'] ?? 0;
  41. $totalIncome = bcadd($totalIncome, $amount, 2);
  42. $totalIncome = floatval($totalIncome);
  43. }
  44. }
  45. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
  46. }
  47. }