BF-202210271038\Administrator 3 سال پیش
والد
کامیت
fdeaedab1c

+ 3 - 13
app/Console/Commands/TestCommand.php

@@ -38,6 +38,7 @@ use App\Servers\Electricity\TbElectricityServer;
 use App\Servers\ExpressServer;
 use App\Servers\GrantPondServer;
 use App\Servers\HxServer;
+use App\Servers\Icon\BanRPC;
 use App\Servers\Icon\TronRPC;
 use App\Servers\ImgServer;
 use App\Servers\ImServer;
@@ -97,19 +98,8 @@ class TestCommand extends Command
      */
     public function handle()
     {
-        dd(date('Y-m-d 00:00:00',strtotime(date('Y-m-1 00:00:00',strtotime('+1 month')))-1));
-        dd(urldecode('https%3A%2F%2Fwealfavor-1257406827.cos.ap-beijing.myqcloud.com%2Fapp-serve%2F2022-10-24%2Fgeraov3msn.jpg'));
-//        for ($i=1;$i<=20;++$i){
-//            MemberServer::creatServer()->register($i.'abc', 1, '', '');
-//        }
-        $list=Member::where('id','>',12)->select(['id'])->get();
-        foreach ($list as $value){
-            MemberClanServer::creatServer()->creatBoth($value->{'id'},1);
-        }
-//
-        dd(1);
-       $address=TronRPC::CreationTron()->getContract('41a614f803b6fd780986a42c78ec9c7f77e6ded13c');
-       dd($address);
+        $ret=BanRPC::creatServer()->getTransactionReceipt('0xc47a91e730e44c1beb80182f69c117b74dfdf9e6b2fdbb81def8bc704cd0cb5b');
+        dd($ret);
 
     }
 }

+ 0 - 49
app/Console/Commands/TronAnalyze.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Servers\TronAnalyzeServer;
-use Illuminate\Console\Command;
-
-class TronAnalyze extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'analyze:tron';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = '波场区块分析';
-
-    /**
-     * Create a new command instance.
-     *
-     * @return void
-     */
-    public function __construct()
-    {
-        parent::__construct();
-    }
-
-    /**
-     * Execute the console command.
-     *
-     * @return mixed
-     */
-    public function handle()
-    {
-        //
-        $this->info('start------------------');
-        while (true){
-            $ret=TronAnalyzeServer::tronAnalyze();
-            if(empty($ret))sleep(3);
-        }
-        $this->info('end------------------');
-    }
-}

+ 2 - 1
app/Http/Controllers/Api/CommonController.php

@@ -10,6 +10,7 @@ use App\Models\AgencySet;
 use App\Models\Config;
 use App\Models\Region;
 use App\Servers\CommonServer;
+use App\Servers\Icon\BanRPC;
 use App\Servers\ShopServer;
 use App\Servers\SmsServer;
 use App\Servers\TronAnalyzeServer;
@@ -30,7 +31,7 @@ class CommonController extends FrontController
 
     function index()
     {
-        $ret=TronAnalyzeServer::tronAnalyze();
+        $ret=BanRPC::creatServer()->getTransactionReceipt('0xc47a91e730e44c1beb80182f69c117b74dfdf9e6b2fdbb81def8bc704cd0cb5b');
         dd($ret);
     }
 

+ 3 - 0
app/Http/Controllers/HomeController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 
 use App\Servers\AdminLogsServer;
+use App\Servers\Icon\BanRPC;
 use App\Servers\IndentNumServer;
 use App\Servers\PassServer;
 use App\Servers\RedisDataServer;
@@ -22,6 +23,8 @@ class HomeController extends FrontController
      */
     public function index()
     {
+        $ret=BanRPC::creatServer()->getTransactionReceipt('0xc47a91e730e44c1beb80182f69c117b74dfdf9e6b2fdbb81def8bc704cd0cb5b');
+        dd($ret);
         dd(1212);
 //        $user_info = PassServer::creatServer(123456)->creatPassword();
 //        dd($user_info);

+ 3 - 0
app/Servers/BroadcastServer.php

@@ -139,4 +139,7 @@ class BroadcastServer
 
 
 
+
+
+
 }

+ 0 - 107
app/Servers/ContractServer.php

@@ -101,114 +101,7 @@ class ContractServer
         }
     }
 
-    /**
-     * 首单清分
-     * @param Contract $contract
-     */
-    function oneSettle(Contract $contract){
-        if($contract->{'direct_proportion'}>0){
-            //直推金额分化
-            $directId=Member::where('id',$contract->{'m_id'})->value('recom_id');
-            if($directId){
-                $this->addDistribution($contract,$directId,1,$contract->{'direct_proportion'},0);
-            }else{
-                $this->addContractLog($contract,'直推人信息异常,跳出首单直推奖');
-            }
-        }
-        if($contract->{'grant_proportion'}>0){
-            //均富池清分
-            $distribution= $this->addDistribution($contract,0,2,$contract->{'grant_proportion'},1);
-            if($distribution){
-                GrantPondServer::creatServer()->grandPond($distribution);
-            }
-        }
-        if($contract->{'point_proportion'}>0){
-            //见点清分
-            $distribution= $this->addDistribution($contract,0,3,$contract->{'point_proportion'},1);
-            if($distribution){
-
-            }
-        }
-        if($contract->{'dao_proportion'}>0){
-            //dao池
-            $distribution= $this->addDistribution($contract,0,4,$contract->{'dao_proportion'},1);
-            if($distribution){
 
-            }
-        }
-        if($contract->{'technology_proportion'}>0){
-            //技术奖
-            $distribution= $this->addDistribution($contract,0,5,$contract->{'technology_proportion'},0);
-            if($distribution){
-
-            }
-        }
-        if($contract->{'reveal_proportion'}>0){
-            //托底池
-            $distribution= $this->addDistribution($contract,0,6,$contract->{'reveal_proportion'},1);
-            if($distribution){
-
-            }
-        }
-
-
-    }
-
-
-    /**
-     * 复投清分
-     * @param Contract $contract
-     */
-    function twoSettle(Contract $contract){
-        if($contract->{'dao_proportion'}>0){
-            //dao池
-            $distribution= $this->addDistribution($contract,0,4,$contract->{'dao_proportion'},1);
-            if($distribution){
-
-            }
-        }
-        if($contract->{'reveal_proportion'}>0){
-            //托底池
-            $distribution= $this->addDistribution($contract,0,6,$contract->{'reveal_proportion'},1);
-            if($distribution){
-
-            }
-        }
-        if($contract->{'parent_proportion'}>0){
-            //dao池
-            $parentProportion=$contract->{'parent_proportion'};
-            $myBothData=MemberBoth::where('m_id',$contract->{'m_id'})->first();
-            $distribution= $this->addDistribution($contract,0,7,$contract->{'parent_proportion'},1);
-            if($distribution){
-
-            }
-        }
-    }
-
-    /**
-     * 添加清分信息
-     * @param Contract $contract
-     * @param $toMid
-     * @param $type
-     * @param $money
-     * @param int $isTransition
-     * @return ContractDistribution|\Illuminate\Database\Eloquent\Model
-     */
-    function addDistribution(Contract $contract,$toMid,$type,$money,$isTransition=1){
-        $lkMoney=CommonServer::creatServer()->getConfigValue('lk_money');
-        $lkNum=$lkMoney*$money;
-        return ContractDistribution::create([
-            'contract_id'=>$contract->{'id'},
-            'm_id'=>$contract->{'m_id'},
-            'broadcast_id'=>0,
-            'is_transition'=>$isTransition,
-            'usdt_num'=>$money,
-            'lk_num'=>$lkNum,
-            'lk_money'=>$lkMoney,
-            'type'=>$type,
-            'to_m_id'=>$toMid,
-        ]);
-    }
 
     /**
      * 合约日志记录

+ 138 - 0
app/Servers/Icon/BanRPC.php

@@ -0,0 +1,138 @@
+<?php
+
+namespace App\Servers\Icon;
+
+
+
+/**
+ * Class EthereumRPC
+ * @package common\models\ethereum
+ */
+class BanRPC
+{
+    /**
+     * @var string RPC URL
+     */
+    public $url='https://bsc-dataseed1.ninicoin.io/';
+
+    public $chainId='56';
+
+    // request id
+    protected $id = 0;
+
+    /**
+     * RPC timeout
+     * @var int
+     */
+    public $timeout = 60;
+
+    static private $server = null;
+    /**
+     * 创建对象
+     * @return BanRPC
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new BanRPC();
+        return self::$server;
+    }
+
+    // 执行eth_call
+    public function call($params)
+    {
+        return $this->send('eth_call', [$params, 'latest']);
+    }
+
+    // 执行sendRawTransaction
+    public function sendTransaction($data, &$error = null)
+    {
+        return $this->send('sendTransaction', $data, $error);
+    }
+
+    // 执行sendRawTransaction
+    public function sendRawTransaction($sign, &$error = null)
+    {
+        return $this->send('eth_sendRawTransaction', [$sign], $error);
+    }
+
+    // 执行getTransactionReceipt
+    public function getTransactionReceipt($hash)
+    {
+        return $this->send('eth_getTransactionReceipt', [$hash]);
+    }
+
+    // 获取交易笔数
+    public function getTransactionCount($address)
+    {
+        return $this->send('eth_getTransactionCount', [$address, 'pending']);
+    }
+
+    // 获取gas单价
+    protected $gasPrice;
+
+    public function getGasPrice()
+    {
+        if ($this->gasPrice === null) {
+            $gasPrice = $this->send('eth_gasPrice');
+            $range = [15, 20]; // 单位gwei
+            $gasPrice = Utils::hex2dec($gasPrice);
+            $gasPrice = Utils::convertUnit($gasPrice, 'wei', 'gwei');
+            $gasPrice = max($gasPrice, $range[0]);
+            $gasPrice = min($gasPrice, $range[1]);
+            $gasPrice = Utils::convertUnit($gasPrice, 'gwei', 'wei');
+
+            $this->gasPrice = Utils::dec2hex($gasPrice);
+        }
+        return $this->gasPrice;
+    }
+
+    // 预估tx消耗的gas
+    public function estimateGas($tx)
+    {
+        $limit = $this->send('eth_estimateGas', [$tx]);
+        if (!$limit) {
+            $limit = 100000;
+        }
+        if(is_numeric($limit))$limit=Utils::dec2hex($limit);
+        return $limit;
+    }
+
+    // 获取eth余额
+    public function getBalance($address)
+    {
+        return $this->send('eth_getBalance', [$address, 'latest']);
+    }
+
+    /**
+     *
+     * @param string $method The method of jsonrpc
+     * @param array $params The params of jsonrpc
+     * @return bool|mixed
+     */
+    public function send($method, $params = [], &$error = null)
+    {
+        $query = [];
+        $query['jsonrpc'] = '2.0';
+        $query['method'] = $method;
+        $query['params'] = $params;
+        $query['id'] = ++$this->id;
+
+        $rawResp = Utils::post($this->url, json_encode($query), $this->timeout);
+        $resp = @json_decode($rawResp, true);
+        if ($resp === false || !is_array($resp)) {
+            $error = $resp;
+            return false;
+        }
+        if (isset($resp['error'])) {
+            $error = $resp['error'];
+            return false;
+        }
+
+        return $resp['result'];
+    }
+
+    public function __call($name, $params)
+    {
+        return $this->send($name, $params);
+    }
+}