ConsoleController.php 4.2 KB

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