DataOverviewController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace addons\HiGo\backend\controllers;
  3. use addons\HiGo\common\models\HigoHibeiLog;
  4. use addons\HiGo\common\models\HigoMall;
  5. use addons\HiGo\common\models\HigoWallet;
  6. use common\enums\StatusEnum;
  7. use Yii;
  8. /**
  9. * 默认控制器
  10. *
  11. * Class DataOverviewController
  12. * @package addons\HiGo\backend\controllers
  13. */
  14. class DataOverviewController extends BaseController
  15. {
  16. /**
  17. * 首页
  18. *
  19. * @return string
  20. */
  21. public function actionIndex()
  22. {
  23. if (Yii::$app->request->isAjax) {
  24. if (Yii::$app->request->isGet) {
  25. $hi_bei_data = HigoWallet::find()
  26. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  27. ->andWhere(['>', 'hi_bei', 0])
  28. ->select('user_id, hi_bei')
  29. ->with([
  30. 'user' => function ($query) {
  31. $query->select('id,nickname,avatar_url');
  32. }
  33. ])
  34. ->limit(10)
  35. ->orderBy('hi_bei DESC')
  36. ->asArray()
  37. ->all();
  38. $hi_value_data = HigoWallet::find()
  39. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  40. ->andWhere(['>', 'hi_value', 0])
  41. ->select('user_id, hi_value')
  42. ->with([
  43. 'user' => function ($query) {
  44. $query->select('id,nickname,avatar_url');
  45. }
  46. ])
  47. ->limit(10)
  48. ->orderBy('hi_value DESC')
  49. ->asArray()
  50. ->all();
  51. //嗨呗
  52. $total = HigoMall::getOne([['mall_id' => $this->mall_id], ['status' => StatusEnum::ENABLED]],true);
  53. $log = HigoHibeiLog::find()->where(['mall_id' => $this->mall_id,'from_type' => HigoHibeiLog::FROM_TYPE_AIRDROP,'status' => StatusEnum::ENABLED])->andWhere(['>','created_at',strtotime(date('Y-m-d'))])->one();
  54. $total['airdrops_today'] = $log['change_num'] ?? 0;
  55. $update_time = date('Y-m-d H:i:s');
  56. return $this->success('success', compact('hi_bei_data', 'hi_value_data','total', 'update_time'));
  57. }
  58. }
  59. return $this->render('index', []);
  60. }
  61. }