123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?php
- namespace service;
- use app\routine\model\routine\RoutineServer;
- use think\Db;
- class RoutineTemplateService{
-
- const ORDER_PAY_SUCCESS = 'AT0009';
-
- const BARGAIN_SUCCESS = 'AT1173';
-
- const ORDER_REFUND_STATUS = 'AT0036';
-
- const ORDER_REFUND_SUCCESS = 'AT0787';
-
- const ORDER_POSTAGE_SUCCESS = 'AT0007';
-
- const ORDER_DELIVER_SUCCESS = 'AT0177';
-
- const PROFIT_SUCCESS = 'AT0035';
-
- const VERIFY='AT0146';
-
- public static function setTemplateId($tempKey = ''){
- if($tempKey == '')return '';
- return Db::name('RoutineTemplate')->where('tempkey',$tempKey)->where('status',1)->value('tempid');
- }
-
- public static function getTemplateListAll($offset = 0,$count = 20){
- $accessToken = RoutineServer::get_access_token();
- $url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list?access_token=".$accessToken;
- $data['access_token'] = $accessToken;
- $data['offset'] = $offset;
- $data['count'] = $count;
- return json_decode(RoutineServer::curlPost($url,json_encode($data)),true);
- }
-
- public static function getTemplateKeyword($templateId = 'AT0005'){
- $accessToken = RoutineServer::get_access_token();
- $url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=".$accessToken;
- $data['access_token'] = $accessToken;
- $data['id'] = $templateId;
- return json_decode(RoutineServer::curlPost($url,json_encode($data)),true);
- }
-
- public static function getTemplateList($offset = 0,$count = 20){
- $accessToken = RoutineServer::get_access_token();
- $url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/list?access_token=".$accessToken;
- $data['access_token'] = $accessToken;
- $data['offset'] = $offset;
- $data['count'] = $count;
- return json_decode(RoutineServer::curlPost($url,json_encode($data)),true);
- }
-
- public static function delTemplate($templateId = ''){
- if($templateId == '') return false;
- $accessToken = RoutineServer::get_access_token();
- $url = "https://api.weixin.qq.com/cgi-bin/wxopen/template/del?access_token=".$accessToken;
- $data['access_token'] = $accessToken;
- $data['template_id'] = $templateId;
- return json_decode(RoutineServer::curlPost($url,json_encode($data)),true);
- }
-
- public static function sendTemplate($openId = '',$templateId = '',$link = '',$dataKey = array(),$formId = '',$emphasisKeyword = ''){
- if($openId == '' || $templateId == '' || $formId == '') return false;
- $accessToken = RoutineServer::get_access_token();
- $url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=".$accessToken;
- $data['touser'] = $openId;
- $data['template_id'] = $templateId;
- $data['page'] = $link;
- $data['form_id'] = $formId;
- $data['data'] = $dataKey;
- $data['emphasis_keyword'] = $emphasisKeyword;
- return json_decode(RoutineServer::curlPost($url,json_encode($data)),true);
- }
- }
|