Index.php 4.0 KB

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