IndexController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. $from = request()->post('from','');
  77. $to = request()->post('to','');
  78. $amount = request()->post('amount','');
  79. $result = UsdtWalletService::make()->getWebAddress();
  80. var_dump($result);
  81. }
  82. public function transfer(){
  83. $from = request()->post('from','');
  84. $to = request()->post('to','');
  85. $amount = request()->post('amount','');
  86. $result = UsdtWalletService::make()->usdtTrcTransfer($from, $to, $amount);
  87. var_dump($result);
  88. var_dump(UsdtWalletService::make()->getError());
  89. }
  90. public function balance(){
  91. $address = request()->post('address','');
  92. $result = UsdtWalletService::make()->getUsdtByTrc20($address);
  93. var_dump($result);
  94. var_dump(UsdtWalletService::make()->getError());
  95. }
  96. public function transferLog()
  97. {
  98. $uid = request()->post('uid',0);
  99. $address = request()->post('address',0);
  100. $result = UsdtWalletService::make()->getTransferInLog($uid, $address);
  101. var_dump($result);
  102. var_dump(UsdtWalletService::make()->getError());
  103. }
  104. }