StatKdController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace hd\controllers;
  3. use Yii;
  4. use common\components\util;
  5. class StatKdController extends BaseController
  6. {
  7. //各渠道收入 ssh 20220711
  8. public function actionProfile()
  9. {
  10. $shopAdmin = $this->shopAdmin;
  11. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  12. util::fail('超管才能查看');
  13. }
  14. //惠雅鲜花员工不能看收入情况
  15. $shopAdmin = $this->shopAdmin;
  16. $adminId = $shopAdmin->adminId ?? 0;
  17. if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
  18. util::fail('暂无权限');
  19. }
  20. $get = Yii::$app->request->get();
  21. $contain = $get['contain'] ?? 0;
  22. $incomeList = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
  23. $totalIncome = 0;
  24. if (!empty($incomeList)) {
  25. foreach ($incomeList as $item) {
  26. $amount = $item['amount'] ?? 0;
  27. $totalIncome = bcadd($totalIncome, $amount, 2);
  28. $totalIncome = floatval($totalIncome);
  29. }
  30. }
  31. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
  32. }
  33. }