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