IndexController.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Helpers\Jwt;
  4. use App\Http\Validator\MemberValidator;
  5. use App\Services\Api\AdService;
  6. use App\Services\Api\MemberService;
  7. use App\Services\ConfigService;
  8. use App\Services\EmailService;
  9. use App\Services\RedisService;
  10. use App\Services\SmsService;
  11. /**
  12. * 会员控制器基类
  13. * Class IndexController
  14. * @package App\Http\Controllers
  15. */
  16. class IndexController extends webApp
  17. {
  18. /**
  19. * IndexController constructor.
  20. */
  21. public function __construct()
  22. {
  23. }
  24. /**
  25. * 首页数据
  26. * @return array
  27. */
  28. public function index(int $userId=0)
  29. {
  30. // 广告幻灯片
  31. $banners = [
  32. 'top'=> AdService::make()->getList(1, 6),
  33. 'middle'=> AdService::make()->getList(2, 1),
  34. ];
  35. // 交易参数
  36. $trade = ConfigService::make()->getConfigByGroup(5);
  37. $trade = [
  38. 'buy_price'=> isset($trade['usdt_buy_price']['value'])? floatval($trade['usdt_buy_price']['value']) : '0.00',
  39. 'sell_price'=> isset($trade['usdt_sell_price']['value'])? floatval($trade['usdt_sell_price']['value']) : '0.00',
  40. 'total'=> rand(100000,999999)+(rand(10,50)/100),
  41. 'count'=> rand(1000,9999),
  42. 'rate'=> rand(10,90)+(rand(10,50)/100),
  43. ];
  44. $notices = [];
  45. return message(1010, true, compact('banners','trade','notices'));
  46. }
  47. /**
  48. * 获取实时交易数据
  49. * @return array
  50. */
  51. public function trade()
  52. {
  53. // 交易参数
  54. $trade = ConfigService::make()->getConfigByGroup(5);
  55. $trade = [
  56. 'buy_price'=> isset($trade['usdt_buy_price']['value'])? floatval($trade['usdt_buy_price']['value']) : '0.00',
  57. 'sell_price'=> isset($trade['usdt_sell_price']['value'])? floatval($trade['usdt_sell_price']['value']) : '0.00',
  58. 'total'=> rand(100000,999999)+(rand(10,50)/100),
  59. 'count'=> rand(1000,9999),
  60. 'rate'=> rand(10,90)+(rand(10,50)/100),
  61. ];
  62. return message(1010, true, compact('trade'));
  63. }
  64. /**
  65. * 获取平台交易配置
  66. * @return array
  67. */
  68. public function config()
  69. {
  70. // 交易参数
  71. $trade = ConfigService::make()->getConfigByGroup(5);
  72. $trade = [
  73. 'buy_price'=> isset($trade['usdt_buy_price']['value'])? floatval($trade['usdt_buy_price']['value']) : '0.00',
  74. 'sell_price'=> isset($trade['usdt_sell_price']['value'])? floatval($trade['usdt_sell_price']['value']) : '0.00',
  75. 'trade_min'=> isset($trade['trade_min']['value'])? floatval($trade['trade_min']['value']) : '0.00',
  76. 'trade_max'=> isset($trade['trade_max']['value'])? floatval($trade['trade_max']['value']) : '0.00',
  77. ];
  78. return message(1010, true, compact('trade'));
  79. }
  80. }