TrongasIoController.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Api;
  4. use App\Controller\AbstractController;
  5. use App\Model\Energy\EnergyAiBishu;
  6. use Hyperf\HttpServer\Contract\RequestInterface;
  7. use App\Library\Log;
  8. class TrongasIoController extends AbstractController
  9. {
  10. // trongas笔数回调通知
  11. public function notice(RequestInterface $request)
  12. {
  13. $receiveAddress = $request->input('receiveAddress');
  14. $residue = $request->input('residue');
  15. if(!empty($receiveAddress)){
  16. //查地址通知
  17. $bishu = EnergyAiBishu::from('energy_ai_bishu as a')
  18. ->leftJoin('energy_platform_bot as b','a.bot_rid','b.bot_rid')
  19. ->leftJoin('telegram_bot as c','a.bot_rid','c.rid')
  20. ->where('a.wallet_addr',$receiveAddress)
  21. ->select('a.rid','a.tg_uid','a.wallet_addr','c.bot_token','a.is_notice_admin','a.is_notice','b.tg_admin_uid','b.tg_notice_obj_send','c.bot_username','c.bot_admin_username','b.per_bishu_energy_quantity','a.bot_rid','a.max_buy_quantity','a.total_buy_quantity')
  22. ->first();
  23. //内联按钮
  24. $keyboard = [
  25. 'inline_keyboard' => [
  26. [
  27. ['text' => '笔数套餐', 'url' => 'https://t.me/'.$bishu->bot_username]
  28. ],
  29. [
  30. ['text' => '联系客服', 'url' => 'https://t.me/'.mb_substr($bishu->bot_admin_username,1)],
  31. ['text' => 'TRX闪兑', 'url' => 'https://t.me/'.$bishu->bot_username]
  32. ]
  33. ]
  34. ];
  35. $encodedKeyboard = json_encode($keyboard);
  36. if(!empty($bishu) && isset($bishu->tg_uid) && !empty($bishu->tg_uid)){
  37. $replytextuid = "🖌<b>新的笔数能量订单成功</b> \n"
  38. ."➖➖➖➖➖➖➖➖\n"
  39. ."<b>下单模式</b>:笔数套餐\n"
  40. ."<b>能量数量</b>:".$bishu->per_bishu_energy_quantity." \n"
  41. ."<b>能量地址</b>:<code>". $receiveAddress ."</code>\n\n"
  42. ."<b>能量已经到账!请在时间范围内使用!</b>\n"
  43. ."发送 /buyenergy 继续购买能量!\n\n"
  44. ."⚠️<u>预计剩余:</u>".($residue + ($bishu->max_buy_quantity - $bishu->total_buy_quantity))." 次\n"
  45. ."➖➖➖➖➖➖➖➖";
  46. $sendlistuid = explode(',',$bishu->tg_uid);
  47. foreach ($sendlistuid as $x => $y) {
  48. $sendmessageurl = 'https://api.telegram.org/bot'.$bishu->bot_token.'/sendMessage?chat_id='.$y.'&text='.urlencode($replytextuid).'&parse_mode=HTML&reply_markup='.urlencode($encodedKeyboard);
  49. Get_Pay($sendmessageurl);
  50. }
  51. }
  52. //通知到群
  53. if(!empty($bishu->tg_notice_obj_send) && $bishu->tg_notice_obj_send != ''){
  54. if($bishu->bot_rid == 12 && $residue <= 10){
  55. $replytext = "🖌<b>新的笔数能量订单成功</b> \n"
  56. ."➖➖➖➖➖➖➖➖\n"
  57. ."<b>下单模式</b>:笔数套餐\n"
  58. ."<b>能量数量</b>:".$bishu->per_bishu_energy_quantity." \n"
  59. ."<b>能量地址</b>:<code>". $receiveAddress ."</code>\n\n"
  60. ."<b>能量已经到账!请在时间范围内使用!</b>\n"
  61. ."发送 /buyenergy 继续购买能量!\n\n"
  62. ."⚠️<u>预计剩余:</u>".($residue + ($bishu->max_buy_quantity - $bishu->total_buy_quantity))." 次\n"
  63. ."➖➖➖➖➖➖➖➖";
  64. $sendlist = explode(',',$bishu->tg_notice_obj_send);
  65. foreach ($sendlist as $x => $y) {
  66. $sendmessageurl = 'https://api.telegram.org/bot'.$bishu->bot_token.'/sendMessage?chat_id='.$y.'&text='.urlencode($replytext).'&parse_mode=HTML&reply_markup='.urlencode($encodedKeyboard);
  67. Get_Pay($sendmessageurl);
  68. }
  69. }elseif($bishu->bot_rid != 12){
  70. $replytext = "🖌<b>新的笔数能量订单成功</b> \n"
  71. ."➖➖➖➖➖➖➖➖\n"
  72. ."<b>下单模式</b>:笔数套餐\n"
  73. ."<b>能量数量</b>:".$bishu->per_bishu_energy_quantity." \n"
  74. ."<b>能量地址</b>:<code>". $receiveAddress ."</code>\n\n"
  75. ."<b>能量已经到账!请在时间范围内使用!</b>\n"
  76. ."发送 /buyenergy 继续购买能量!\n\n"
  77. ."⚠️<u>预计剩余:</u>".($residue + ($bishu->max_buy_quantity - $bishu->total_buy_quantity))." 次\n"
  78. ."➖➖➖➖➖➖➖➖";
  79. $sendlist = explode(',',$bishu->tg_notice_obj_send);
  80. foreach ($sendlist as $x => $y) {
  81. $sendmessageurl = 'https://api.telegram.org/bot'.$bishu->bot_token.'/sendMessage?chat_id='.$y.'&text='.urlencode($replytext).'&parse_mode=HTML&reply_markup='.urlencode($encodedKeyboard);
  82. Get_Pay($sendmessageurl);
  83. }
  84. }
  85. }
  86. }
  87. return $this->responseApi(200,'success');
  88. }
  89. /**
  90. * 记入日志
  91. * @param $log_title [日志路径]
  92. * @param $message [内容,不支持数组]
  93. * @param $remarks [备注]
  94. */
  95. protected function log($log_title,$message,$remarks='info'){
  96. Log::get($remarks,$log_title)->info($message);
  97. }
  98. }