AccCallbackController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Facade\TableName;
  4. use App\Http\helper\HttpCurl;
  5. use App\Http\helper\NumConfig;
  6. use App\Models\GamePhoneVerityCode;
  7. use App\Models\PrivateMail;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\DB;
  10. use Illuminate\Support\Facades\Log;
  11. use Illuminate\Support\Facades\Redis;
  12. class AccCallbackController
  13. {
  14. private $plantsConfig;
  15. // 验证码查询
  16. public function send()
  17. {
  18. $lastid=0;
  19. $key="taskCallbackrun_013";
  20. if(Redis::exists($key)){
  21. $lastid=Redis::get($key);
  22. }
  23. $list=DB::table("QPRecordDB.dbo.AccountsCallbackRecords")
  24. ->where("State",1)
  25. ->where("ID",'>',$lastid)
  26. ->where('PhoneNum','>',0)
  27. ->orderBy('ID')
  28. ->limit(100)->get();
  29. foreach ($list as $item) {
  30. if($item->ID>$lastid)$lastid=$item->ID;
  31. DB::connection("write")->table("QPRecordDB.dbo.AccountsCallbackRecords")
  32. ->where('ID',$item->ID)
  33. ->update(['State'=>9]);
  34. }
  35. Redis::set($key,$lastid);
  36. // $this->plantsConfig = config('InterfaceAPI.plant_message');
  37. $this->plantsConfig = config('InterfaceAPI.plant_message_notify');
  38. foreach ($list as $item) {
  39. $res=$this->plants_send($item->PhoneNum,$item->Msg);
  40. DB::connection("write")->table("QPRecordDB.dbo.AccountsCallbackRecords")
  41. ->where('ID',$item->ID)
  42. ->update(['State'=>$res?2:0,'SendDate'=> date('Y-m-d H:i:s',time())]);
  43. }
  44. // $record = [
  45. // 'UserID' => $item->UserID,
  46. // 'Channel' => $item->Channel,
  47. // 'Msg' => $msg,
  48. // 'PhoneNum' => $item->PhoneNum,
  49. // 'Reason' => $reason,
  50. // 'Recharge' => $pay,
  51. // 'Profit' => $pay - $item->Withdraw / 100,
  52. // 'State' => 1,
  53. // 'LeftCoin' => $item->Score,
  54. // 'Bonus' => $bonus,
  55. // 'TrackToken' => $this->from10_to62($lastid),
  56. ////'SendDate'=>$item->,
  57. ////'Result'=>$item->,
  58. // ];
  59. }
  60. public function plants_send($phone, $Content)
  61. {
  62. $accesskey = $this->plantsConfig['appKey'];
  63. $secret = $this->plantsConfig['secretKey'];
  64. $time = time();
  65. $data = [
  66. 'appkey' => $accesskey,
  67. 'secretkey' => $secret,
  68. 'phone' => '55' . $phone,
  69. 'content' => $Content,
  70. ];
  71. $build = http_build_query($data);
  72. Log::info('plants发送回call ' . $build);
  73. $gateway = $this->plantsConfig['gateway'] ;
  74. // $header = ['sign' => $sign, 'Timestamp' =>$time, 'Api-Key' => $appKey];
  75. // Log::info('header-签名 ' . json_encode($header)."###".$appKey .'-'. $password .'-'. $time);
  76. $HttpCurl = new HttpCurl();
  77. $res = $HttpCurl->curlPost($gateway, $build);
  78. Log::info('plants发送回call结果:' . $res);
  79. $data = \GuzzleHttp\json_decode($res, true);
  80. if (isset($data['code']) && $data['code'] == 0){
  81. return true;
  82. }
  83. return false;
  84. }
  85. }