IndexController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. $locale = request()->get('locale');
  28. if($locale){
  29. RedisService::set("stores:locale:lang_{$this->userId}", $locale, 24 * 3600);
  30. session('lang_locale', $locale);
  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. $type = request()->post('type', 1);
  75. if($type == 1){
  76. $trade = ConfigService::make()->getConfigOptionByGroup(5);
  77. }else if ($type == 2){
  78. $trade = ConfigService::make()->getConfigOptionByGroup(6);
  79. }
  80. return message(1010, true, compact('trade'));
  81. }
  82. public function address(){
  83. $from = request()->post('from','');
  84. $to = request()->post('to','');
  85. $amount = request()->post('amount','');
  86. $result = UsdtWalletService::make()->getWebAddress();
  87. var_dump($result);
  88. }
  89. public function transfer(){
  90. $from = request()->post('from','');
  91. $to = request()->post('to','');
  92. $amount = request()->post('amount','');
  93. $result = UsdtWalletService::make()->usdtTrcTransfer($from, $to, $amount);
  94. var_dump($result);
  95. var_dump(UsdtWalletService::make()->getError());
  96. }
  97. public function balance(){
  98. $address = request()->post('address','');
  99. $result = UsdtWalletService::make()->getUsdtByTrc20($address);
  100. var_dump($result);
  101. var_dump(UsdtWalletService::make()->getError());
  102. }
  103. public function transferLog()
  104. {
  105. $uid = request()->post('uid',0);
  106. $address = request()->post('address',0);
  107. $result = UsdtWalletService::make()->getTransferInLog($uid, $address);
  108. var_dump($result);
  109. var_dump(UsdtWalletService::make()->getError());
  110. }
  111. }