| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | 
							- <?php
 
- namespace App\Service\Weixin;
 
- use App\Service\Service;
 
- use Illuminate\Support\Facades\Log;
 
- class WxSendMessageService extends WeixinService
 
- {
 
-     public function sendSalaryMessage($openid,$tempid,$data)
 
-     {
 
-         $reload_url = $data['reload_url'] ?? '';
 
-         list($status, $token) = $this->getToken();
 
-         if (!$status) return [false, $token];
 
-         $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $token;
 
-         $post = '{
 
-            "touser":"' . $openid . '",
 
-            "template_id":"' . $tempid . '",
 
-            "url":"' . $reload_url . '",
 
-            "data":{
 
-                    "first": {
 
-                        "value":"1",
 
-                        "color":"#173177"
 
-                    },
 
-                    %s
 
-                    "remark":{
 
-                        "value":"1",
 
-                        "color":"#173177"
 
-                    }
 
-            }
 
-        }';
 
-         $content = "";
 
-         foreach ($data['detail'] as $k => $v) {
 
-             $content .= '"' . $k . '": {
 
-                        "value":"' . $v . '",
 
-                        "color":"#173177"
 
-                    },';
 
-         }
 
-         $post = sprintf($post, $content);
 
-         $res = $this->curlOpen($url, ['post' => $post]);
 
-         $res = json_decode($res, true);
 
-         if (isset($res['errcode']) && $res['errcode'] != 0) return [false, $res['errmsg']];
 
-         if (isset($res['errcode']) && $res['errcode'] === 0) return [true, ''];
 
-         return [false, json_encode($res)];
 
-     }
 
- }
 
 
  |