StatKindController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. $kindList = KindClass::getAllByCondition(['mainId' => $mainId, 'flower' => 1, 'delStatus' => 0, 'status' => 1], null, '*', 'id');
  27. $arr = [];
  28. $where = ['mainId' => $mainId, 'status' => 1];
  29. $where['finishTime'] = ['between', [$currentStartTime, $currentEndTime]];
  30. $workList = WorkClass::getAllByCondition($where, null, '*', null, true);
  31. if (!empty($workList)) {
  32. foreach ($workList as $work) {
  33. $kindId = $work->kindId ?? 0;
  34. if (empty($kindId)) {
  35. continue;
  36. }
  37. $kindName = $kindList[$kindId]['name'] ?? '';
  38. $num = $work->num ?? 0;
  39. if (isset($arr[$kindId]['makeNum'])) {
  40. $arr[$kindId]['makeNum'] = bcadd($arr[$kindId]['makeNum'], $num);
  41. } else {
  42. $arr[$kindId]['makeNum'] = $num;
  43. $arr[$kindId]['name'] = $kindName;
  44. }
  45. }
  46. }
  47. //util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
  48. }
  49. }