StatKdController.php 1.3 KB

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