HandleShanduiBonus.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Task;
  3. use App\Service\Bus\ShanduiBonusServices;
  4. use App\Model\Transit\TransitWalletTradeList;
  5. use App\Library\Log;
  6. class HandleShanduiBonus
  7. {
  8. public function execute()
  9. {
  10. try {
  11. $data = TransitWalletTradeList::from('transit_wallet_trade_list as twtl')
  12. ->leftJoin('transit_wallet as tw','twtl.transferto_address','tw.receive_wallet')
  13. ->where('twtl.process_status',1)
  14. ->select('twtl.rid','twtl.tx_hash','twtl.transferto_address','twtl.coin_name','twtl.amount','twtl.sendback_address','twtl.sendback_amount','twtl.sendback_coin_name','tw.rid as transit_wallet_id','tw.send_wallet','tw.send_wallet_privatekey')
  15. ->limit(100)
  16. ->get();
  17. if($data->count() > 0){
  18. // $this->log('shanduibonus','-----------开始执行:闪兑币种,总数:'.$data->count().'期--------------');
  19. $shanduiBonus_services = new ShanduiBonusServices();
  20. // 转账
  21. $res = $shanduiBonus_services->handleGrant($data);
  22. }else{
  23. // $this->log('shanduibonus','----------没有数据需要闪兑----------');
  24. }
  25. }catch (\Exception $e){
  26. // $this->log('shanduibonus','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  27. }
  28. }
  29. /**
  30. * 记入日志
  31. * @param $log_title [日志路径]
  32. * @param $message [内容,不支持数组]
  33. * @param $remarks [备注]
  34. */
  35. protected function log($log_title,$message,$remarks='info'){
  36. Log::get($remarks,$log_title)->info($message);
  37. }
  38. }