HongbaoController.class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace bibidd\Controller;
  3. use Bibidd\Controller\CommonBaseController;
  4. /**
  5. * 口令红包,人工充值通道
  6. */
  7. class HongbaoController extends CommonBaseController
  8. {
  9. /**
  10. * 发起口令红包,50-> 50,100->135,200->300
  11. * @return void
  12. */
  13. public function send()
  14. {
  15. $this->addHeaders(); //添加头部请求
  16. $user_info = $this->checkUserIsExist($_POST['uid']); //检查用户
  17. //视频id
  18. $uid= $_POST['uid'];
  19. $amount= $_POST['amount']; //充值金额
  20. $pwd= $_POST['pwd']; //口令红包1
  21. $pwd1= $_POST['pwd1']; //口令红包2
  22. $user_name = $user_info['name'];
  23. if(empty($amount) || !is_numeric($amount))
  24. {
  25. $this->returnDataAndSendMsg("请选择充值金额.");
  26. die();
  27. }
  28. if(empty($pwd)||empty($pwd1))
  29. {
  30. $this->returnDataAndSendMsg("请输入口令.");
  31. die();
  32. }
  33. if(mb_strlen($pwd)!=8 || mb_strlen($pwd1)!=8 )
  34. {
  35. $this->returnDataAndSendMsg("口令长度不正确.");
  36. die();
  37. }
  38. if(!is_numeric($pwd) || !is_numeric($pwd1))
  39. {
  40. $this->returnDataAndSendMsg("口令格式不正确.");
  41. die();
  42. }
  43. if($pwd!=$pwd1)
  44. {
  45. $this->returnDataAndSendMsg("口令红包输入不一致.");
  46. die();
  47. }
  48. //验证用户当天只能提交5次
  49. $count_submit = M("pay_test")->where("uid='$uid' AND order_str='人工通道:支付宝口令红包' AND TO_DAYS(apply_date)=TO_DAYS(NOW())")->count();
  50. if($count_submit>5)
  51. {
  52. $this->returnDataAndSendMsg("人工充值,每天最多提交5次.");
  53. die();
  54. }
  55. //连续错误5次永久封禁
  56. $count_submit1 = M("pay_test")->where("uid='$uid' AND order_str='人工通道:支付宝口令红包' AND order_type = '红包失效'")->count();
  57. if($count_submit1>10)
  58. {
  59. $this->returnDataAndSendMsg("发送错误红包口令10次以上<br>已永久禁用人工充值");
  60. die();
  61. }
  62. //一分钟内不能重复发
  63. $check_info = M("pay_test")->where("uid='$uid' AND order_str='人工通道:支付宝口令红包' AND apply_date > NOW() - INTERVAL 1 MINUTE")->find();
  64. if(!empty($check_info))
  65. {
  66. $this->returnDataAndSendMsg("口令红包发送需间隔1分钟");
  67. die();
  68. }
  69. $pay_info['uid'] = $uid;
  70. $pay_info['order_str'] = "人工通道:支付宝口令红包";
  71. $pay_info['apply_date'] = date('Y-m-d H:i:s');
  72. $pay_info['apply_time'] = time();
  73. $pay_info['order_type'] = '待支付';
  74. $pay_info['order_id'] = $pwd;
  75. $pay_info['order_ip'] = $this->getIp();
  76. $pay_info['amount'] = $amount;
  77. $rs = M("pay_test")->add($pay_info);
  78. $data['code'] = '200';
  79. $data['message'] = 'ok';
  80. $data['data'] = $rs;
  81. echo json_encode($data);
  82. //发送机器人
  83. $text = "口令红包🧧🧧🧧\n"."9169用户: ".$user_name."\n"."口令红包: ".$pwd."\n"."充值".$amount."元\n加金币".$amount."\n\n请尽快收红包·加金币";
  84. // 11 22 用户ID : 6199511960
  85. //群id
  86. $this->send_msg_to_telegram("6543542631:AAGRvYWAXAk4VV45yEHtQY3mG8h13MhLT-k","-4190639794",$text);
  87. }
  88. }