where("State",1) ->where("ID",'>',$lastid) ->where('PhoneNum','>',0) ->orderBy('ID') ->limit(100)->get(); foreach ($list as $item) { if($item->ID>$lastid)$lastid=$item->ID; DB::connection("write")->table("QPRecordDB.dbo.AccountsCallbackRecords") ->where('ID',$item->ID) ->update(['State'=>9]); } Redis::set($key,$lastid); // $this->plantsConfig = config('InterfaceAPI.plant_message'); $this->plantsConfig = config('InterfaceAPI.plant_message_notify'); foreach ($list as $item) { $res=$this->plants_send($item->PhoneNum,$item->Msg); DB::connection("write")->table("QPRecordDB.dbo.AccountsCallbackRecords") ->where('ID',$item->ID) ->update(['State'=>$res?2:0,'SendDate'=> date('Y-m-d H:i:s',time())]); } // $record = [ // 'UserID' => $item->UserID, // 'Channel' => $item->Channel, // 'Msg' => $msg, // 'PhoneNum' => $item->PhoneNum, // 'Reason' => $reason, // 'Recharge' => $pay, // 'Profit' => $pay - $item->Withdraw / 100, // 'State' => 1, // 'LeftCoin' => $item->Score, // 'Bonus' => $bonus, // 'TrackToken' => $this->from10_to62($lastid), ////'SendDate'=>$item->, ////'Result'=>$item->, // ]; } public function plants_send($phone, $Content) { $accesskey = $this->plantsConfig['appKey']; $secret = $this->plantsConfig['secretKey']; $time = time(); $data = [ 'appkey' => $accesskey, 'secretkey' => $secret, 'phone' => '55' . $phone, 'content' => $Content, ]; $build = http_build_query($data); Log::info('plants发送回call ' . $build); $gateway = $this->plantsConfig['gateway'] ; // $header = ['sign' => $sign, 'Timestamp' =>$time, 'Api-Key' => $appKey]; // Log::info('header-签名 ' . json_encode($header)."###".$appKey .'-'. $password .'-'. $time); $HttpCurl = new HttpCurl(); $res = $HttpCurl->curlPost($gateway, $build); Log::info('plants发送回call结果:' . $res); $data = \GuzzleHttp\json_decode($res, true); if (isset($data['code']) && $data['code'] == 0){ return true; } return false; } }