StatKdController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. $staffAmountList = $return['staffAmountList'];
  30. $payCodeIncome = $return['payCodeIncome'];
  31. $totalIncome = 0;
  32. if (!empty($incomeList)) {
  33. foreach ($incomeList as $item) {
  34. $amount = $item['amount'] ?? 0;
  35. $totalIncome = bcadd($totalIncome, $amount, 2);
  36. $totalIncome = floatval($totalIncome);
  37. }
  38. }
  39. util::success(['list' => $incomeList, 'totalIncome' => $totalIncome, 'staffAmountList' => $staffAmountList, 'payCodeIncome' => $payCodeIncome]);
  40. }
  41. }