553 lines
20 KiB
PHP
553 lines
20 KiB
PHP
<?php
|
||
header("Access-Control-Allow-Origin: *");
|
||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||
header("Access-Control-Allow-Credentials: true");
|
||
header("Content-Type: text/html; charset=utf-8");
|
||
|
||
/**
|
||
* 消息发送相关接口
|
||
*/
|
||
use phprs\util\Verify;
|
||
use phprs\util\exceptions\Forbidden;
|
||
use phprs\util\Logger;
|
||
use phprs\util\exceptions\NotFound;
|
||
use phprs\ezsql\Sql;
|
||
use phprs\util\exceptions\BadRequest;
|
||
|
||
require_once 'templateMessageBase.php';
|
||
|
||
class DataItem
|
||
{
|
||
var $value;
|
||
var $color;
|
||
|
||
public function __construct($value, $color = '#7B68EE')
|
||
{
|
||
$this->value = $value;
|
||
$this->color = $color;
|
||
}
|
||
}
|
||
|
||
/**
|
||
*
|
||
* 消息管理
|
||
* @path("/tplmessage")
|
||
*/
|
||
class templateMessage extends templateMessageBase
|
||
{
|
||
/**
|
||
* 模板消息发送(错误代码:12500-12550)
|
||
* @route({"POST","/rawsend"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"market_key","$._POST.market_key"}) 门店key
|
||
* @param({"touser","$._POST.touser"}) 接收人的openid
|
||
* @param({"template_id","$._POST.tid"}) 模板编号
|
||
* @param({"data","$._POST.data"}) 模板参数
|
||
* @param({"url","$._POST.url"}) url
|
||
* @return string
|
||
*/
|
||
public function rawsend($appid, $devkey, $market_key, $touser, $template_id, $data, $url)
|
||
{
|
||
/// 验证公共参数是否合法
|
||
$this->init($appid, $devkey);
|
||
$verify_result = $this->verify_admin($market_key);
|
||
if (is_error_api($verify_result))
|
||
{
|
||
if ($verify_result instanceof returnObject)
|
||
return $verify_result;
|
||
|
||
$return = new returnObject();
|
||
$return->from_array((array)$verify_result);
|
||
return $verify_result;
|
||
}
|
||
|
||
/// 验证其他参数是否合法 begin
|
||
if (empty($template_id)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12501;
|
||
$result["msg"] = "未传入tid参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
if (AUTHTYPE_WECHAT != $this->userInfo["auth_type"]) {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12502;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
|
||
/// 参数
|
||
if (empty($data))
|
||
$data = [];
|
||
else
|
||
$data = (array)json_decode($data);
|
||
|
||
$wechat = [
|
||
'appid' => $this->marketInfo['weixin_appid'], /// 微信公众号APPID
|
||
'secret' => $this->marketInfo['weixin_secret_appid'],
|
||
'mchid' => $this->marketInfo['weixin_mchid'], /// 微信公众号商户号
|
||
'signkey' => $this->marketInfo['weixin_paykey'], /// 支付秘钥
|
||
];
|
||
|
||
/// 初始化微信信息
|
||
parent::init_weixin($wechat['appid'], $wechat['secret']);
|
||
/// openid
|
||
$openid = $touser;
|
||
/// 发送模板消息
|
||
$sendResult = parent::SendMessage($openid, $template_id, $url, $data);
|
||
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12505; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||
* @route({"POST","/send"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"sid","$._POST.sid"}) sid
|
||
* @param({"scode","$._POST.scode"}) scode
|
||
* @param({"template_id","$._POST.tid"}) 模板编号
|
||
* @param({"data","$._POST.data"}) 模板参数
|
||
* @param({"url","$._POST.url"}) url
|
||
* @return string
|
||
*/
|
||
public function send($appid, $devkey, $sid, $scode, $template_id, $data, $url)
|
||
{
|
||
/// 验证公共参数是否合法
|
||
parent::init($appid, $devkey, $sid, $scode);
|
||
$verify_result = parent::verify();
|
||
|
||
if (is_error_api($verify_result))
|
||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||
|
||
/// 验证其他参数是否合法 begin
|
||
if (empty($template_id)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12501;
|
||
$result["msg"] = "未传入tid参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
if (AUTHTYPE_WECHAT != $this->userInfo["auth_type"]) {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12502;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
|
||
/// 参数
|
||
if (empty($data))
|
||
$data = [];
|
||
else
|
||
$data = (array)json_decode($data);
|
||
|
||
$wechat = [
|
||
'appid' => $this->marketInfo['weixin_appid'], /// 微信公众号APPID
|
||
'secret' => $this->marketInfo['weixin_secret_appid'],
|
||
'mchid' => $this->marketInfo['weixin_mchid'], /// 微信公众号商户号
|
||
'signkey' => $this->marketInfo['weixin_paykey'], /// 支付秘钥
|
||
];
|
||
|
||
/// 初始化微信信息
|
||
parent::init_weixin($wechat['appid'], $wechat['secret']);
|
||
/// openid
|
||
$openid = $this->userInfo['openid'];
|
||
/// 发送模板消息
|
||
$sendResult = parent::SendMessage($openid, $template_id, $url, $data);
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12505; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||
* @route({"POST","/send/buy_succ_msg"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"sid","$._POST.sid"}) sid
|
||
* @param({"scode","$._POST.scode"}) scode
|
||
* @param({"first","$._POST.first"}) 头部内容
|
||
* @param({"productname","$._POST.productname"}) 产品名称
|
||
* @param({"price","$._POST.price"}) 订单价格
|
||
* @param({"time","$._POST.time"}) 时间
|
||
* @param({"remark","$._POST.remark"}) 购买正文
|
||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||
*/
|
||
public function sendBuySuccessMsg($appid = '', $devkey = '', $sid = '', $scode = '', $first = '', $productname = '', $price = '', $time = '', $remark = '', $target_url = '')
|
||
{
|
||
// 验证公共参数是否合法
|
||
parent::init($appid, $devkey, $sid, $scode);
|
||
$verify_result = parent::verify();
|
||
|
||
if (!is_error_api($verify_result)) {
|
||
// 验证其他参数是否合法 begin
|
||
if (empty($first)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12500; // 未传入first参数
|
||
$result["msg"] = "未传入first参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($productname)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12501; // 未传入productname参数
|
||
$result["msg"] = "未传入productname参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($price)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12502; // 未传入price参数
|
||
$result["msg"] = "未传入price参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($remark)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12503; // 未传入remark参数
|
||
$result["msg"] = "未传入remark参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
// 假如没有传入时间,则使用系统默认时间
|
||
if (empty($time)) {
|
||
$time = date('Y-m-d H:i', strtotime('now'));
|
||
}
|
||
|
||
if ($this->userInfo["auth_type"] == 0) {
|
||
$data = array(
|
||
'first' => new DataItem($first, '#ff0000'),
|
||
'product' => new DataItem($productname, '#ff0000'),
|
||
'price' => new DataItem($price, '#ff0000'),
|
||
'time' => new DataItem($time, '#ff0000'),
|
||
'remark' => new DataItem($remark, '#ff0000'),
|
||
);
|
||
|
||
// 初始化微信信息
|
||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||
// 发送模板消息
|
||
$openid = $this->userInfo["weixin"]['openid'];
|
||
$template_id = $this->businessInfo['templatemsg']['msg_buy_succ'];
|
||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12505; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12504;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 配送处理模板消息发送(错误代码:12551-12600)
|
||
* @route({"POST","/send/dispatch_process_msg"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"sid","$._POST.sid"}) sid
|
||
* @param({"scode","$._POST.scode"}) scode
|
||
* @param({"first","$._POST.first"}) 头部内容
|
||
* @param({"time","$._POST.time"}) 时间
|
||
* @param({"ordersn","$._POST.ordersn"}) 订单号
|
||
* @param({"remark","$._POST.remark"}) 正文
|
||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||
*/
|
||
public function sendDispatchProcessMsg($appid = '', $devkey = '', $sid = '', $scode = '', $first = '', $time = '', $ordersn = '', $remark = '', $target_url = '')
|
||
{
|
||
// 验证公共参数是否合法
|
||
parent::init($appid, $devkey, $sid, $scode);
|
||
$verify_result = parent::verify();
|
||
|
||
if (!is_error_api($verify_result)) {
|
||
// 验证其他参数是否合法 begin
|
||
if (empty($first)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12551; // 未传入first参数
|
||
$result["msg"] = "未传入first参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($ordersn)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12552; // 未传入ordersn参数
|
||
$result["msg"] = "未传入ordersn参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($remark)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12553; // 未传入remark参数
|
||
$result["msg"] = "未传入remark参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
// 假如没有传入时间,则使用系统默认时间
|
||
if (empty($time)) {
|
||
$time = date('Y-m-d H:i', strtotime('now'));
|
||
}
|
||
|
||
if ($this->userInfo["auth_type"] == 0) {
|
||
$data = array(
|
||
'first' => new DataItem($first, '#ff0000'),
|
||
'keyword1' => new DataItem($time, '#ff0000'),
|
||
'keyword2' => new DataItem($ordersn, '#ff0000'),
|
||
'remark' => new DataItem($remark, '#ff0000'),
|
||
);
|
||
|
||
// 初始化微信信息
|
||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||
// 发送模板消息
|
||
$openid = $this->userInfo["weixin"]['openid'];
|
||
$template_id = $this->businessInfo['templatemsg']['msg_dispatch_process'];
|
||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12555; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12554;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息 ";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||
* @route({"POST","/send/admin/buy_succ_msg"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"businessid","$._POST.businessid"}) 商户ID
|
||
* @param({"openid","$._POST.openid"}) 微信openId
|
||
* @param({"first","$._POST.first"}) 头部内容
|
||
* @param({"productname","$._POST.productname"}) 产品名称
|
||
* @param({"price","$._POST.price"}) 订单价格
|
||
* @param({"time","$._POST.time"}) 时间
|
||
* @param({"remark","$._POST.remark"}) 购买正文
|
||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||
*/
|
||
public function sendBuySuccessMsgByAdmin($appid = '', $devkey = '', $businessid = '', $openid = '', $first = '', $productname = '', $price = '', $time = '', $remark = '', $target_url = '')
|
||
{
|
||
|
||
// 验证公共参数是否合法
|
||
parent::init($appid, $devkey, '', '');
|
||
$verify_result = parent::verify_admin($businessid);
|
||
|
||
if (!is_error_api($verify_result)) {
|
||
// 验证其他参数是否合法 begin
|
||
if (empty($first)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12500; // 未传入first参数
|
||
$result["msg"] = "未传入first参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($productname)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12501; // 未传入productname参数
|
||
$result["msg"] = "未传入productname参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($price)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12502; // 未传入price参数
|
||
$result["msg"] = "未传入price参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($remark)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12503; // 未传入remark参数
|
||
$result["msg"] = "未传入remark参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($openid)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12506; // 未传入openid参数
|
||
$result["msg"] = "未传入openid参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
// 假如没有传入时间,则使用系统默认时间
|
||
if (empty($time)) {
|
||
$time = date('Y-m-d H:i', strtotime('now'));
|
||
}
|
||
|
||
if ($this->userInfo["auth_type"] == 0) {
|
||
$data = array(
|
||
'first' => new DataItem($first, '#ff0000'),
|
||
'product' => new DataItem($productname, '#ff0000'),
|
||
'price' => new DataItem($price, '#ff0000'),
|
||
'time' => new DataItem($time, '#ff0000'),
|
||
'remark' => new DataItem($remark, '#ff0000'),
|
||
);
|
||
|
||
// 初始化微信信息
|
||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||
// 发送模板消息
|
||
$template_id = $this->businessInfo['templatemsg']['msg_buy_succ'];
|
||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12505; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12504;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 配送处理模板消息发送(错误代码:12551-12600)
|
||
* @route({"POST","/send/admin/dispatch_process_msg"})
|
||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||
* @param({"businessid","$._POST.businessid"}) 商户ID
|
||
* @param({"openid","$._POST.openid"}) 微信openId
|
||
* @param({"first","$._POST.first"}) 头部内容
|
||
* @param({"time","$._POST.time"}) 时间
|
||
* @param({"ordersn","$._POST.ordersn"}) 订单号
|
||
* @param({"remark","$._POST.remark"}) 正文
|
||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||
*/
|
||
public function sendDispatchProcessMsgByAdmin($appid = '', $devkey = '', $businessid = '', $openid = '', $first = '', $time = '', $ordersn = '', $remark = '', $target_url = '')
|
||
{
|
||
// 验证公共参数是否合法
|
||
parent::init($appid, $devkey, '', '');
|
||
$verify_result = parent::verify_admin($openid);
|
||
|
||
if (!is_error_api($verify_result)) {
|
||
// 验证其他参数是否合法 begin
|
||
if (empty($first)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12551; // 未传入first参数
|
||
$result["msg"] = "未传入first参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($ordersn)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12552; // 未传入ordersn参数
|
||
$result["msg"] = "未传入ordersn参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($remark)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12553; // 未传入remark参数
|
||
$result["msg"] = "未传入remark参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
if (empty($openid)) {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12556; // 未传入openid参数
|
||
$result["msg"] = "未传入openid参数";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
// 验证其他参数是否合法 end
|
||
|
||
// 假如没有传入时间,则使用系统默认时间
|
||
if (empty($time)) {
|
||
$time = date('Y-m-d H:i', strtotime('now'));
|
||
}
|
||
|
||
if ($this->userInfo["auth_type"] == 0) {
|
||
$data = array(
|
||
'first' => new DataItem($first, '#ff0000'),
|
||
'keyword1' => new DataItem($time, '#ff0000'),
|
||
'keyword2' => new DataItem($ordersn, '#ff0000'),
|
||
'remark' => new DataItem($remark, '#ff0000'),
|
||
);
|
||
|
||
// 初始化微信信息
|
||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||
// 发送模板消息
|
||
$template_id = $this->businessInfo['templatemsg']['msg_dispatch_process'];
|
||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||
if (!is_error($sendResult)) {
|
||
$result["error"] = "0";
|
||
$result["msg"] = "发送模板消息成功。";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
} else {
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12555; // 发送模板消息失败
|
||
$result["msg"] = "发送模板消息失败";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
// 非微信登录方式,无法发送模板消息
|
||
$result["error"] = "1";
|
||
$result["error_code"] = 12554;
|
||
$result["msg"] = "非微信登录方式,无法发送模板消息 ";
|
||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
} else {
|
||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||
}
|
||
}
|
||
|
||
/** @inject("ioc_factory") */
|
||
private $factory;
|
||
/**
|
||
* @property({"default":"@db"})
|
||
* @var PDO
|
||
*/
|
||
public $db;
|
||
// 此处删除了代码
|
||
} |