| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- namespace App\Servers;
- use App\Jobs\BusinessFileJob;
- use App\Jobs\MsgFileJob;
- use App\Models\BlockItems;
- use App\Models\Contract;
- use App\Models\ContractDistribution;
- use App\Models\ContractLog;
- use App\Models\ErrorRecord;
- use App\Models\Invest;
- use App\Models\Member;
- use App\Models\MemberBoth;
- use App\Servers\Icon\BanRPC;
- use App\Servers\Icon\TronRPC;
- /**
- * Redis数据缓存类
- */
- class ContractServer
- {
- static private $server = '';
- private $distributionArr=[
- 1=>'直推奖',
- 2=>'均富池',
- 3=>'见点奖',
- 4=>'dao池',
- 5=>'技术奖',
- 6=>'托底池',
- 7=>'推荐奖',
- ];
- private function __construct()
- {
- }
- /**
- * 创建对象
- * @return ContractServer
- */
- static function creatServer()
- {
- if (empty(self::$server)) {
- self::$server = new ContractServer();
- }
- return self::$server;
- }
- /**
- * 报单信息检测
- */
- function broadcastDetection(){
- //检测报单信息
- $contractList=Contract::where('status',1)->select(['id','hash','m_id'])->limit(50)->get();
- foreach ($contractList as $contract){
- $broadcastData=BanRPC::creatServer()->getTransactionReceipt($contract->{'hash'});
- if (empty($broadcastData)) {
- //交易正在广播中,下次继续查询
- continue;
- } else {
- //交易已完成 返回数据格式数据 ,将数据json保存
- $updateInfo['broadcast_data'] = json_encode($broadcastData);
- if ($broadcastData['status'] == '0x1') {
- $updateInfo['status'] = 2;
- } else {
- $updateInfo['status'] = 3;
- }
- dd($updateInfo);
- }
- }
- }
- /**
- * 合约日志记录
- * @param Contract $contract
- * @param $msg
- * @param array $data
- */
- function addContractLog(Contract $contract,$msg,$data=[]){
- ContractLog::create([
- 'contract_id'=> $contract->{'id'},
- 'm_id'=> $contract->{'m_id'},
- 'msg'=> $msg,
- 'contract_data'=> json_encode($contract),
- 'data'=> json_encode($data),
- ]);
- }
- }
|