StatKdController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. //查看财务的权限
  11. $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
  12. if ($lookMoney == 0) {
  13. util::fail('无法查看');
  14. }
  15. $shopAdmin = $this->shopAdmin;
  16. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  17. util::fail('超管才能查看');
  18. }
  19. //惠雅鲜花员工不能看收入情况
  20. $shopAdmin = $this->shopAdmin;
  21. $adminId = $shopAdmin->adminId ?? 0;
  22. if (in_array($adminId, [2366, 2812, 4004, 3405, 3407])) {
  23. util::fail('暂无权限');
  24. }
  25. $get = Yii::$app->request->get();
  26. $contain = $get['contain'] ?? 0;
  27. $incomeList = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
  28. $totalIncome = 0;
  29. if (!empty($incomeList)) {
  30. foreach ($incomeList as $item) {
  31. $amount = $item['amount'] ?? 0;
  32. $totalIncome = bcadd($totalIncome, $amount, 2);
  33. $totalIncome = floatval($totalIncome);
  34. }
  35. }
  36. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
  37. }
  38. }