Index.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\Config;
  5. use app\common\model\MoneyLog;
  6. use app\common\model\News;
  7. /**
  8. * 首页接口
  9. */
  10. class Index extends Api
  11. {
  12. protected $noNeedLogin = ['base'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 首页
  16. *
  17. */
  18. public function base()
  19. {
  20. $data['logo'] = (new Config())->getValue('logo');
  21. $data['app_name'] = (new Config())->getValue('name');
  22. $data['code'] = [
  23. ['code' => '86', 'country' => __('中国')],
  24. ['code' => '1', 'country' => __('美国')],
  25. ['code' => '66', 'country' => __('泰国')],
  26. ['code' => '00966', 'country' => __('阿拉伯')],
  27. ['code' => '81', 'country' => __('日本')],
  28. ['code' => '82', 'country' => __('韩国')],
  29. ['code' => '60', 'country' => __('马来西亚')],
  30. ['code' => '84', 'country' => __('越南')],
  31. ];
  32. $this->success('', $data);
  33. }
  34. /**
  35. * 首页
  36. *
  37. */
  38. public function index()
  39. {
  40. $user = $this->auth->getUser();
  41. $data = [];
  42. $data['notice'] = News::where('type_id', 4)->order('id desc')->value('title'); //type_id = 4 公告管理
  43. $data['banner_list'] = News::where('type_id', 1)->order('id desc')->column('img_url'); //type_id = 1 banner管理
  44. $data['balance'] = $user['freeze'] < 0 ? $user['freeze']: $user['balance'];
  45. $data['bonus_sum'] = $user['bonus_sum'];
  46. $data['service_link'] = $user['service_link'];
  47. $data['icon_list'] = [
  48. 'https://www.estyzl38.com/static/img/binance.ebc27893.png',
  49. 'https://www.estyzl38.com/static/img/ibank.11f8808d.png',
  50. 'https://www.estyzl38.com/static/img/gate.ef718121.png',
  51. 'https://www.estyzl38.com/static/img/trustwallet.3e39f1f7.png',
  52. 'https://www.estyzl38.com/static/img/gemini.90d29b68.png',
  53. 'https://www.estyzl38.com/static/img/11.png',
  54. 'https://www.estyzl38.com/static/img/metamask.5cc72a6d.png',
  55. 'https://www.estyzl38.com/static/img/22.png',
  56. ];
  57. $this->success(__('请求成功'), $data);
  58. }
  59. /**
  60. * 团队
  61. * @return void
  62. */
  63. public function team()
  64. {
  65. $user = $this->auth->getUser();
  66. $info_list = (new \app\common\model\Users())
  67. ->alias('u')
  68. ->join('users_path p', 'p.user_id = u.id')
  69. ->where('p.parent_id', $user['id'])
  70. ->field('u.avatar,u.bonus_sum,u.mobile,u.nickname')
  71. ->order('u.bonus_sum DESC')
  72. ->paginate($this->pageSize);
  73. // foreach ($info_list as $k => $v) {
  74. // $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
  75. // }
  76. $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
  77. $res_data['bonus_today'] = MoneyLog::where('user_id', $user['id'])
  78. ->where('create_time', '>=', strtotime('today'))
  79. ->where('action', 'in', [1,2])
  80. ->sum('amount');
  81. $res_data['bonus_sum'] = $user['bonus_sum'];
  82. $res_data['team_num'] = $user['team_num'];
  83. $this->success('', $res_data);
  84. }
  85. public function news_list()
  86. {
  87. $info_list = (new News())
  88. ->field('img_url,content', true)
  89. ->where('type_id', 2)//常见问题
  90. ->order('id DESC')
  91. ->paginate($this->pageSize);
  92. // foreach ($info_list as $k => $v) {
  93. // $paginator[$k]['status_name'] = (new OrderModel())->getStatusNames($v['status']);
  94. // }
  95. $res_data = $this->buildResp($info_list->total(), $info_list->currentPage(), $info_list->items());
  96. $this->success('', $res_data);
  97. }
  98. public function news()
  99. {
  100. $news_id = $this->request->post('id');
  101. $type_id = $this->request->post('type_id');
  102. $where['type_id'] = $type_id;
  103. if(!empty($news_id)){
  104. $where['id'] = $news_id;
  105. }
  106. $info_list = (new News())
  107. //->field('title,content')
  108. ->where($where)
  109. ->order('id desc')
  110. ->find();
  111. $this->success('', $info_list);
  112. }
  113. }