作者 郭文星

123123

... ... @@ -280,8 +280,8 @@ class Api extends Controller
$orderlog['createtime'] = time();
Db::name('order_log')->insert($orderlog);
$this->SendMessage($cks['id']);
SendMessage();
$index=new \app\api\controller\Index();
$index->senWxmsgToDriverUser($cks['id']);
}
}
... ...
... ... @@ -6,6 +6,7 @@ use app\admin\model\User;
use app\api\controller\v1\WxxcxPush;
use app\common\controller\Backend;
use think\Db;
use app\api\controller\Index;
use think\exception\DbException;
use think\exception\PDOException;
use think\exception\ValidateException;
... ... @@ -97,6 +98,8 @@ class Order extends Backend
->where(['id' => $order['id']])
->update($relogs);
if($order['pay_type']="offlinepay"){
$index=new Index();
$index->refundToDriverUser($order['id']);
$this->refundSendMessage($id);//发送订阅消息
}
$this->success("退款成功");
... ... @@ -126,6 +129,8 @@ class Order extends Backend
} else {
$this->error('退款失败');
}
$index=new Index();
$index->refundToDriverUser($id);
$this->refundSendMessage($id);//发送订阅消息
$this->success("退款成功");
... ...
... ... @@ -620,6 +620,8 @@ class Car extends Base
}
refundSendMessage($id);//发送订阅消息
$index=new Index();
$index->senWxmsgToDriverUser($id);
$this->success("退款成功");
} else {
$relogs['is_pay'] = 4;
... ... @@ -627,6 +629,8 @@ class Car extends Base
->where(['id' => $order['id']])
->update($relogs);
refundSendMessage($id);//发送订阅消息
$index=new Index();
$index->senWxmsgToDriverUser($id);
$this->success("取消成功");
}
}
... ... @@ -1050,7 +1054,7 @@ class Car extends Base
}
/**
* 创建包车订单
* 创建包车订单线下支付
* @return void
*/
public function createcharterorderofflinepay()
... ...
... ... @@ -121,6 +121,39 @@ class Index extends Api
}
}
}
function refundToDriverUser($order_id)
{
$order=Db::name("order")->find($order_id);
if($order['driver_id']){
$driver=Db::name("driver")->find($order['driver_id']);
$user=Db::name("user")->find($driver['user_id']);
$wct_user=Db::name("wct_user")->where("unionid",$user['unionid'])->find();
$wxopenid=$wct_user['wx_openid'];
$sendInfo = array(
'first' => array('value' => "客户退票通知", 'color' => "#743A3A"),
'thing1' => 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'),
'thing6' => array('value' =>"{$order['position']}", 'color' => '#173177'),
'thing7' => array('value' =>"{$order['end_point']}", 'color' => '#173177'),
);
if ($wxopenid) {
$config = get_addon_config('wechat');
$tourl = '';
$ywt_appid = 'wxb7dd0c03865a94e0';
$pagepath = '';
$res = $this->refundAstuWxMsgToAgent($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();
... ... @@ -139,7 +172,33 @@ class Index extends Api
/**
* 微信公众号
* 经纪人审核 消息推送
* 退款 消息推送
*/
function refundAstuWxMsgToAgent($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' => 'u8oGieaB8DiwkoK-smIC7nqBQjABAQ-jZsT3aV7HUGs', //模板消息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;
}
/**
* 微信公众号
* 用户下订单 消息推送
*/
function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
{
... ...