ConsoleController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\stat\classes\StatSaleClass;
  4. use biz\stat\services\StatOutService;
  5. use bizHd\stat\classes\StatViewClass;
  6. use bizHd\stat\classes\StatVisitClass;
  7. use bizHd\stat\services\StatIncomeMonthService;
  8. use bizHd\stat\services\StatIncomeService;
  9. use bizHd\stat\services\StatUserService;
  10. use common\components\dict;
  11. use common\components\httpUtil;
  12. use common\components\util;
  13. use Yii;
  14. class ConsoleController extends BaseController
  15. {
  16. public $guestAccess = ['init', 'profile'];
  17. //概况 ssh 2019.12.19
  18. public function actionProfile()
  19. {
  20. $get = Yii::$app->request->get();
  21. $isMini = $get['isMini'] ?? 0;
  22. $notice = [];
  23. $admin = $this->admin;
  24. if ($isMini == 1 && !empty($admin)) {
  25. $miniOpenId = $admin['miniOpenId'] ?? '';
  26. if (empty($miniOpenId)) {
  27. $notice = [['title' => '绑定微信,下次自动登录后台', 'action' => '去绑定', 'page' => '/admin/staff/miniAutoLogin']];
  28. }
  29. }
  30. //今天客户与粉丝数
  31. $userData = StatUserService::getTodayNum($this->mainId);
  32. $customNum = isset($userData['riseUserNum']) ? $userData['riseUserNum'] : 0;
  33. //今天销售
  34. $sale = StatSaleClass::getByCondition(['mainId' => $this->mainId, 'time' => date('Ymd')]);
  35. $todaySale = $sale['amount'] ?? 0;
  36. $orderNum = $sale['num'] ?? 0;
  37. //2021.4.14 linqh 今日支出
  38. $outData = StatOutService::getTodayNum($this->mainId);
  39. $todayOut = $outData['amount'] ?? '0.00';
  40. //访客数
  41. $visitCustom = StatVisitClass::getVisitNum($this->mainId);
  42. $todayData = ['income' => $todaySale, 'order' => $orderNum, 'custom' => $customNum, 'expend' => $todayOut, 'visitCustom' => $visitCustom];
  43. $incomeStat = [];
  44. $shopInfo = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  45. $menu = [
  46. ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
  47. ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
  48. ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
  49. ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
  50. ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
  51. ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
  52. ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
  53. ["name" => "调拨入库", "img" => "ghs/home/dbrk.png", "url" => "/pagesStorehouse/allot/allotPut"]
  54. ];
  55. $agent = $shopInfo['agentLevel'] ?? 0;
  56. if ($agent == 1) {
  57. //代理商显示邀请开店按钮
  58. $menu = [
  59. ["name" => "商城", "img" => "ghs/home/shop.png", "url" => "/admin/home/mall"],
  60. ["name" => "改价", "img" => "ghs/home/gj.png", "url" => "/admin/changePrice/list"],
  61. ["name" => "供应商", "img" => "ghs/home/icon_ghs.png", "url" => "/pagesPurchase/supplier"],
  62. ["name" => "报损单", "img" => "ghs/home/kcyjs.png", "url" => "/admin/breakage/list"],
  63. ["name" => "库存预警", "img" => "ghs/home/kcyjs.png", "url" => "/pagesStorehouse/stockWarn/manage"],
  64. ["name" => "花材", "img" => "ghs/home/hcgl.png", "url" => "/admin/item/list"],
  65. ["name" => "调拨出库", "img" => "ghs/home/dbck.png", "url" => "/pagesStorehouse/allot/allotEx"],
  66. ["name" => "邀请开店", "img" => "ghs/home/yqyl.png", "url" => "/pagesInvite/list"]
  67. ];
  68. }
  69. util::success([
  70. 'asset' => $shopInfo,
  71. 'notice' => $notice,
  72. 'todayData' => $todayData,
  73. 'incomeStat' => $incomeStat,
  74. 'menu' => $menu,
  75. ]);
  76. }
  77. //常用初始化
  78. public function actionInit()
  79. {
  80. $dict = dict::get();
  81. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  82. util::success(['dict' => $dict, 'shop' => $shop]);
  83. }
  84. }