IndexController.php 3.6 KB

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