StatKdController.php 1.2 KB

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