| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Servers;
- use App\Jobs\BusinessFileJob;
- use App\Jobs\MsgFileJob;
- use App\Models\BlockItems;
- use App\Models\Contract;
- use App\Models\ErrorRecord;
- use App\Models\Member;
- use App\Servers\Icon\TronRPC;
- /**
- * Redis数据缓存类
- */
- class ContractServer
- {
- static private $server = '';
- private function __construct()
- {
- }
- /**
- * 创建对象
- * @return ContractServer
- */
- static function creatServer()
- {
- if (empty(self::$server)) {
- self::$server = new ContractServer();
- }
- return self::$server;
- }
- /**
- * 报单信息检测
- * @param BlockItems $blockItem
- */
- function broadcastDetection(BlockItems $blockItem){
- //检测报单信息
- $contract=Contract::where('hash',$blockItem->{'hash'})->first();
- if($contract){
- if($contract->{'status'}!=1){
- ErrorRecord::create([
- 'm_id' => 0,
- 'msg' => '合约状态从异常',
- 'data' => json_encode($contract)
- ]);
- }else{
- $ret = TronRPC::CreationTron()->getTransaction($contract->{'hash'});
- if (!empty($ret['ret'][0]['contractRet']) && $ret['ret'][0]['contractRet'] == 'SUCCESS') {
- //检测交易信息
- if($contract->{'type'}==1){
- //初始合约
- //生成双轨关系
- $member=Member::where('id',$contract->{'m_id'})->select(['id','recom_id'])->first();
- JobServer::creatServer()->creatBothJob($member->{'id'},$member->{'recom_id'});
- //报单拆分
- $this->oneSettle($contract);
- }else{
- //复投合约
- $this->twoSettle($contract);
- }
- } else {
- ErrorRecord::create([
- 'm_id' => 0,
- 'msg' => '交易失败',
- 'data' => json_encode($contract)
- ]);
- }
- }
- }
- }
- function oneSettle(Contract $contract){
- }
- function twoSettle(Contract $contract){
- }
- }
|