IndexController.php 2.8 KB

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