first(); if($block_info->{'num'}>=$block_info->{'analyze'} - 5 ){ $tron_block = BanRPC::creatServer()->sendBlockNumber(); }else{ $tron_block=$block_info->{'num'}; } if ($block_info->{'analyze'} + 6 < $tron_block) { $analyze = $block_info->{'analyze'} + 1; $block_deal = BanRPC::creatServer()->sendBlockByNumber($analyze); // dump(time()); if (empty($block_deal)) return false; DB::beginTransaction(); if (!empty($block_deal['transactions'])) { foreach ($block_deal['transactions'] as $t_key=>$deal_info) { if(strtolower($deal_info['to'])==strtolower($usdtAddress) ){ //USDT充币流程 $to=strtolower('0x'.substr($deal_info['input'],34,40)); $modelName=substr($deal_info['input'],0,10); if(strtolower($to)==strtolower($contractAddress) && $modelName=='0xa9059cbb'){ $money='0x'.substr($deal_info['input'],74); $money=Utils::int2fund(Utils::hex2dec( $money)); $testServe=env('TEST_SERVE'); if($testServe){ $money*=100000; } $block_item = [ 'm_id' => 0, 'coin_id' => 1, 'contract_address' => $usdtAddress, 'coin_name' => 'USDT', 'block_num' => $block_info->{'analyze'} + 1, 'money' => $money, 'from_a' =>$deal_info['from'], 'hash' => $deal_info['hash'], 'to_a' => $to, 'pay_at' => date('Y-m-d H:i:s'), 'fee_limit' =>0, ]; } if (!empty($block_item)) { $member = Member::where('address', $block_item['from_a'])->select(['id','address','m_id'])->first(); if (!empty($member)) { $deal = BanRPC::creatServer()->getTransactionReceipt($deal_info['hash']);//交易查询 //交易已完成 返回数据格式数据 ,将数据json保存 if ($deal['status'] != '0x1'){ continue; } $member_coin = MemberCoin::where('m_id',$member->{'id'})->where('coin_id',1)->select(['id','address','num','m_id'])->first(); $block_item['m_id'] = $member_coin->{'m_id'}; $block_item['to_type'] = 1; $item_num = BlockItem::where('m_id', $block_item['m_id'])->where('hash', $block_item['hash'])->where('coin_id', $block_item['coin_id'])->count(); if($item_num<=0){ $block_item=BlockItem::create($block_item); if($block_item['to_type']==1){ //转入检测 $itemMoney=MoneyDetailServer::creatServer()->write(1,1,$block_item['money'],1,$member->{'id'},'用户充值成功',$block_item->{'id'}); WalletServer::creatServer()->addCoinNum($member->{'m_id'},$itemMoney); } } } } }elseif(strtolower($deal_info['to'])==strtolower($contractAddress) ){ $modelName=substr($deal_info['input'],0,10); if($modelName=='0x33289a46'){ $money='0x'.substr($deal_info['input'],10); $money=Utils::int2fund(Utils::hex2dec( $money)); $from=strtolower($deal_info['from']); $member=Member::where('address',$from)->first(); if($member){ $num=Withdraw::where('hash',$deal_info['hash'])->count(); if($num<=0){ $w= Withdraw::create([ 'm_id' => $member->{'m_id'}, 'coin_id' => 1, 'money' => $money, 'service_money' => 0, 'withdraw_money' => 0, 'status' => 1, 'withdraw_type' => 1 ]); $memberCoin=MemberCoin::where('m_id',$member->{'id'})->where('coin_id',1)->first(); if ($memberCoin && $memberCoin->{'num'}>$money){ Task::create([ 'u_id' => $member->{'id'}, 'm_id' => $member->{'m_id'}, 'model_name' => 'withdraw', 'execute_id' => 0, 'data' => ['money'=>$money,'service_money'=>0,'address'=>$deal_info['from'],'withdraw_money'=>$money,'execute_id'=>$w->{'id'}], 'status' => 0 ]); } } } } } } } BlockInfo::where('id', 1)->update(['analyze' => $block_info->{'analyze'} + 1, 'num' => $tron_block]); DB::commit(); return true; } return false; } }