|
@@ -0,0 +1,47 @@
|
|
|
+<?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]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|