ConsoleController.php 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\stat\classes\StatSaleClass;
  4. use biz\stat\services\StatOutService;
  5. use bizGhs\order\classes\OrderClass;
  6. use bizHd\stat\classes\StatVisitClass;
  7. use common\components\dict;
  8. use common\components\util;
  9. use Yii;
  10. class ConsoleController extends BaseController
  11. {
  12. public $guestAccess = ['init', 'profile'];
  13. //今日实收统计和欠款统计等
  14. public function actionStat()
  15. {
  16. $todayDate = date('Y-m-d');
  17. $todayStartTime = $todayDate . ' 00:00:00';
  18. $todayEndTime = $todayDate . ' 23:59:59';
  19. $where = ['shopId' => $this->shopId, 'debt' => 0];
  20. $where['payStatus'] = ['in', [2,3,4]];
  21. $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
  22. $todayActIncome = OrderClass::sum($where, 'actPrice'); // 今日实收
  23. $todayActIncome = $todayActIncome === null ? 0 : $todayActIncome;
  24. $where = ['shopId' => $this->shopId, 'debt' => 1]; // 查询条件重新赋值
  25. $where['addTime'] = ['between', [$todayStartTime, $todayEndTime]];
  26. $todayDebt = OrderClass::sum($where, 'debtPrice'); // 今日欠款
  27. $todayDebt = $todayDebt === null ? 0 : $todayDebt;
  28. $where = ['shopId' => $this->shopId, 'debt' => 1]; // 重新赋值
  29. $totalDebt = OrderClass::sum($where, 'remainDebtPrice'); // 总欠款
  30. $totalDebt = $totalDebt === null ? 0 : $totalDebt;
  31. util::success(['todayActIncome' => $todayActIncome, 'todayDebt' => $todayDebt, 'totalDebt' => $totalDebt]);
  32. }
  33. //概况 ssh 2019.12.19
  34. public function actionProfile()
  35. {
  36. $get = Yii::$app->request->get();
  37. $isMini = $get['isMini'] ?? 0;
  38. $notice = [];
  39. $admin = $this->admin;
  40. if ($isMini == 1 && !empty($admin)) {
  41. $miniOpenId = $admin['ghsMiniOpenId'] ?? '';
  42. if (empty($miniOpenId)) {
  43. $notice = [['title' => '绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']];
  44. }
  45. }
  46. //今天销售
  47. $sale = StatSaleClass::getByCondition(['mainId' => $this->mainId, 'time' => date('Ymd')]);
  48. $todaySale = $sale['amount'] ?? 0;
  49. $orderNum = $sale['num'] ?? 0;
  50. //2021.4.14 lqh 今日支出
  51. $outData = StatOutService::getTodayNum($this->mainId);
  52. $todayOut = $outData['amount'] ?? '0.00';
  53. //访客数
  54. $visitCustom = StatVisitClass::getVisitNum($this->mainId);
  55. $todayData = ['income' => $todaySale, 'order' => $orderNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
  56. $incomeStat = [];
  57. $menu = [
  58. ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
  59. ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
  60. ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
  61. ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
  62. ["name" => "采购单", "img" => "ghs/home/icon_caigou.png", "url" => "/pagesPurchase/order"],
  63. ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
  64. ["name" => "预订单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/statBook"],
  65. ["name" => "新增出库", "img" => "ghs/home/dbck.png", "url" => "/admin/shop/selectShop"],
  66. ["name" => "出库记录", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
  67. ["name" => "入库记录", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"],
  68. ["name" => "销售结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/customList"],
  69. ["name" => "采购结账单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/clear/list"],
  70. ];
  71. util::success(['asset' => $this->main, 'notice' => $notice, 'todayData' => $todayData, 'incomeStat' => $incomeStat, 'menu' => $menu,]);
  72. }
  73. //常用初始化
  74. public function actionInit()
  75. {
  76. $dict = dict::get();
  77. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  78. util::success(['dict' => $dict, 'shop' => $shop]);
  79. }
  80. }