作者 郭文星

123

... ... @@ -196,33 +196,86 @@ if (!function_exists('build_heading')) {
}
/**
* 微信公众号
* 经纪人审核 消息推送
*/
function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
{
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
$json_token = http_request($myurl);
$access_tokens = json_decode($json_token, true);
$access_token = $access_tokens['access_token'];
$template = array(
'touser' => $openid, //
'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
'url' => $tourl, //点击链接
"miniprogram" => [
"appid" => $ywt_appid,
"pagepath" => $pagepath
],
'topcolor' => "#173177",
'data' => $info
);
$json_template = json_encode($template);
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
$json = http_request($url, urldecode($json_template));
$rs = json_decode($json, true);
return $rs;
}
if (!function_exists('sendAstuWxMsgToAgent')) {
/**
* 微信公众号
* 经纪人审核 消息推送
*/
function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
{
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
$json_token = http_request($myurl);
$access_tokens = json_decode($json_token, true);
$access_token = $access_tokens['access_token'];
$template = array(
'touser' => $openid, //
'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
'url' => $tourl, //点击链接
"miniprogram" => [
"appid" => $ywt_appid,
"pagepath" => $pagepath
],
'topcolor' => "#173177",
'data' => $info
);
$json_template = json_encode($template);
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
$json = http_request($url, urldecode($json_template));
$rs = json_decode($json, true);
return $rs;
}
}
if (!function_exists('senWxmsgToAgentUser')) {
/***
* 公众号推送审核信息给经纪人
*/
function senWxmsgToAgentUser($order_id)
{
$order=Db::name("order")->find($order_id);
if($order['driver_id']){
$user=Db::name("user")->find($order['driver_id']);
$wct_user=Db::name("wct_user")->where("unionid",$user['unionid'])->find();
$wxopenid=$wct_user['wx_openid'];
$sendInfo = array(
'first' => array('value' => "汽车票出票状态通知", 'color' => "#743A3A"),
'thing2' => array('value' => "{$order['starting_point']}-{$order['end_point']}", 'color' => '#173177'),
'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', $order['reservation_time'])), 'color' => '#173177'),
'thing7' => array('value' =>"{$order['starting_point']}", 'color' => '#173177'),
'phone_number5' => array('value' => "{$order['phone']}", 'color' => '#173177'),
);
if ($wxopenid) {
$config = get_addon_config('wechat');
$tourl = '';
$ywt_appid = 'wxb7dd0c03865a94e0';
$pagepath = '';
$res = sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
print_r($res);return;
//file_put_contents("pcl_wct_send.log", date("Y-m-d H:i:s") . "1-2-" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
}
}
}
}
if (!function_exists('http_request')) {
function http_request($url, $data = array())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// 我们在POST数据哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
}
... ...
... ... @@ -1370,6 +1370,8 @@ class Car extends Base
}
$res = Db::name("order")->insertGetId($data);
OrderSendMessage($res);
senWxmsgToAgentUser($res);
$this->success("请求成功", $res);
}
... ...
... ... @@ -89,70 +89,4 @@ class Index extends Api
}
}
/***
* 公众号推送审核信息给经纪人
*/
public function senWxmsgToAgentUser()
{
$wxopenid="oYhYi6fEAxSnlAV1qNm2BwaJdQOQ";
$sendInfo = array(
'first' => array('value' => "123111111123", 'color' => "#743A3A"),
'thing2' => array('value' => "行程", 'color' => '#173177'),
'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', time())), 'color' => '#173177'),
'thing7' => array('value' =>"乘车地点", 'color' => '#173177'),
'phone_number5' => array('value' => "13529343345", 'color' => '#173177'),
);
if ($wxopenid) {
$config = get_addon_config('wechat');
$tourl = '';
$ywt_appid = 'wxb7dd0c03865a94e0';
$pagepath = '';
$res = $this->sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
print_r($res);return;
//file_put_contents("pcl_wct_send.log", date("Y-m-d H:i:s") . "1-2-" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
}
}
function http_request($url, $data = array())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// 我们在POST数据哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
/**
* 微信公众号
* 经纪人审核 消息推送
*/
function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
{
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
$json_token = $this->http_request($myurl);
$access_tokens = json_decode($json_token, true);
$access_token = $access_tokens['access_token'];
$template = array(
'touser' => $openid, //
'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
'url' => $tourl, //点击链接
"miniprogram" => [],
'topcolor' => "#173177",
'data' => $info
);
$json_template = json_encode($template);
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
$json = $this->http_request($url, urldecode($json_template));
$rs = json_decode($json, true);
return $rs;
}
}
... ...
... ... @@ -181,7 +181,8 @@ if (!function_exists('getOrderSn')) {
$driver=new \app\admin\model\Driver();
$driver=$driver->find($order['driver_id']);
$driver_user=$user->find($driver['user_id']);
$res=$wxxcxpush->Message($driver_user['wx_xcx_openid'],$order_id);
//$res=$wxxcxpush->Message($driver_user['wx_xcx_openid'],$order_id);
$res=$wxxcxpush->Message($user['wx_xcx_openid'],$order_id);
if ($res !== false) {
return $res;
... ...