| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- <?php
 
- namespace App\Service\Weixin;
 
- use App\Service\Service;
 
- use Illuminate\Support\Facades\Log;
 
- class WxSendMessageService extends Service
 
- {
 
-     public function sendSalaryMessage($data,$temple_id){
 
-         list($status,$token) = (new WeixinService())->getToken();
 
-         if(! $status) return [false,'TOKEN错误,发送失败!'];
 
-         $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$token;
 
-         foreach ($data as $value){
 
-             $post = '{
 
-            "touser":"'.$value['openid'].'",
 
-            "template_id":"'.$temple_id.'",
 
-            "url":"'.$value['url'].'",            
 
-                "data":{
 
-                        "thing1":{
 
-                            "value":"'.$value['emp_name'].'",
 
-                            "color":"#173177"
 
-                        },
 
-                        "amount2": {
 
-                            "value":"'.$value['amount'].'",
 
-                            "color":"#173177"
 
-                        },
 
-                        "time3": {
 
-                            "value":"'.$value['salary_time'].'",
 
-                            "color":"#173177"
 
-                        },
 
-                         "thing4":{
 
-                            "value":"'.$value['cagetoryanddepart'].'",
 
-                            "color":"#173177"
 
-                        }
 
-                }
 
-            }';
 
-             $data = array('url'=>$url,'post'=>$post);
 
-             $res = $this->curlOpen($url,['post'=>$post]);
 
-             $res = json_decode($res,true);
 
-             if(isset($res['errcode']) && $res['errcode'] == 0){
 
-             }
 
-             Log::channel('request')->info('request', ['res_send'=>$res]);
 
-         }
 
-     }
 
- }
 
 
  |