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