IndexController.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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()->getConfigOptionByGroup(5);
  72. return message(1010, true, compact('trade'));
  73. }
  74. }