StatKdController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. ini_set('memory_limit', '5045M');
  13. set_time_limit(0);
  14. //查看财务的权限
  15. $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
  16. if ($lookMoney == 0) {
  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. $return = StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
  28. $incomeList = $return['incomeList'];
  29. $staffAmountList = $return['staffAmountList'];
  30. $totalIncome = 0;
  31. if (!empty($incomeList)) {
  32. foreach ($incomeList as $item) {
  33. $amount = $item['amount'] ?? 0;
  34. $totalIncome = bcadd($totalIncome, $amount, 2);
  35. $totalIncome = floatval($totalIncome);
  36. }
  37. }
  38. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome, 'staffAmountList' => $staffAmountList]);
  39. }
  40. }