ContractServer.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Servers;
  3. use App\Jobs\BusinessFileJob;
  4. use App\Jobs\MsgFileJob;
  5. use App\Models\BlockItems;
  6. use App\Models\Contract;
  7. use App\Models\ErrorRecord;
  8. use App\Servers\Icon\TronRPC;
  9. /**
  10. * Redis数据缓存类
  11. */
  12. class ContractServer
  13. {
  14. static private $server = '';
  15. private function __construct()
  16. {
  17. }
  18. /**
  19. * 创建对象
  20. * @return ContractServer
  21. */
  22. static function creatServer()
  23. {
  24. if (empty(self::$server)) {
  25. self::$server = new ContractServer();
  26. }
  27. return self::$server;
  28. }
  29. function broadcastDetection(BlockItems $blockItem){
  30. //检测报单信息
  31. $contract=Contract::where('hash',$blockItem->{'hash'})->first();
  32. if($contract){
  33. if($contract->{'status'}!=1){
  34. ErrorRecord::create([
  35. 'm_id' => 0,
  36. 'msg' => '合约状态从异常',
  37. 'data' => json_encode($contract)
  38. ]);
  39. }else{
  40. $ret = TronRPC::CreationTron()->getTransaction($contract->{'hash'});
  41. if (!empty($ret['ret'][0]['contractRet']) && $ret['ret'][0]['contractRet'] == 'SUCCESS') {
  42. //检测交易信息
  43. if($contract->{'type'}==1){
  44. //初始合约
  45. }else{
  46. //复投合约
  47. }
  48. } else {
  49. ErrorRecord::create([
  50. 'm_id' => 0,
  51. 'msg' => '交易失败',
  52. 'data' => json_encode($contract)
  53. ]);
  54. }
  55. }
  56. }
  57. }
  58. }