DashboardController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers;
  8. use app\models\CommonOperation;
  9. use app\modules\admin\models\AnalysisDataForm;
  10. use yii\helpers\Json;
  11. /**
  12. * 数据面板统计
  13. * Class DashboardController
  14. * @package app\modules\admin\controllers
  15. */
  16. class DashboardController extends BaseController
  17. {
  18. /**
  19. * 总销售额,商品总数,用户总量,订单总数
  20. * @return \yii\web\Response
  21. */
  22. public function actionData()
  23. {
  24. $form = new AnalysisDataForm();
  25. $form->attributes = post_params();
  26. $form->attributes = get_params();
  27. $form->store_id = get_store_id();
  28. $form->user_id = get_user_id();
  29. $form->mch_id = get_mch_id();
  30. return $this->asJson($form->getData());
  31. }
  32. /**
  33. * 商品订单数据和店铺销售总体排行
  34. * @return \yii\web\Response
  35. */
  36. public function actionOrderData()
  37. {
  38. $form = new AnalysisDataForm();
  39. $form->start_time = get_params('start_time');
  40. $form->end_time = get_params('end_time');
  41. $form->store_id = get_store_id();
  42. $form->user_id = get_user_id();
  43. $form->mch_id = get_mch_id();
  44. return $this->asJson($form->getOrderData());
  45. }
  46. /**
  47. * 商品销量数据
  48. * @return \yii\web\Response
  49. */
  50. public function actionGoodsData()
  51. {
  52. $form = new AnalysisDataForm();
  53. $form->store_id = get_store_id();
  54. $form->mch_id = get_mch_id();
  55. return $this->asJson($form->GoodsSearch());
  56. }
  57. /**
  58. * 常用操作表
  59. * @return \yii\web\Response
  60. */
  61. public function actionOperations()
  62. {
  63. $mch_id = get_mch_id();
  64. $store_id = get_store_id();
  65. $text = input_params('text', array());
  66. $operations = CommonOperation::findOne(['store_id' => $store_id, 'mch_id' => $mch_id]);
  67. if (\Yii::$app->request->isPost) {
  68. $form = new AnalysisDataForm();
  69. $form->store_id = $store_id;
  70. $form->mch_id = $mch_id;
  71. $form->text = $text;
  72. $form->model = $operations ? $operations : new CommonOperation();
  73. return $this->asJson($form->operations());
  74. }
  75. if (!$operations) {
  76. return $this->asJson([
  77. 'code' => 0,
  78. 'msg' => 'success',
  79. 'data' => []
  80. ]);
  81. } else {
  82. if (empty($operations->text)) {
  83. return $this->asJson([
  84. 'code' => 0,
  85. 'msg' => 'success',
  86. 'data' => []
  87. ]);
  88. } else {
  89. return $this->asJson([
  90. 'code' => 0,
  91. 'msg' => 'success',
  92. 'data' => Json::decode($operations->text)
  93. ]);
  94. }
  95. }
  96. }
  97. }