StatKdController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. $return = \bizGhs\stat\classes\StatKdClass::eachChannelIncome($this->mainId, $this->shop, $contain);
  28. $incomeList = $return['incomeList'];
  29. $totalIncome = 0;
  30. if (!empty($incomeList)) {
  31. foreach ($incomeList as $item) {
  32. $amount = $item['amount'] ?? 0;
  33. $totalIncome = bcadd($totalIncome, $amount, 2);
  34. $totalIncome = floatval($totalIncome);
  35. }
  36. }
  37. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome]);
  38. }
  39. }