正在显示
4 个修改的文件
包含
72 行增加
和
4 行删除
@@ -280,8 +280,8 @@ class Api extends Controller | @@ -280,8 +280,8 @@ class Api extends Controller | ||
280 | $orderlog['createtime'] = time(); | 280 | $orderlog['createtime'] = time(); |
281 | Db::name('order_log')->insert($orderlog); | 281 | Db::name('order_log')->insert($orderlog); |
282 | $this->SendMessage($cks['id']); | 282 | $this->SendMessage($cks['id']); |
283 | - SendMessage(); | ||
284 | - | 283 | + $index=new \app\api\controller\Index(); |
284 | + $index->senWxmsgToDriverUser($cks['id']); | ||
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 |
@@ -6,6 +6,7 @@ use app\admin\model\User; | @@ -6,6 +6,7 @@ use app\admin\model\User; | ||
6 | use app\api\controller\v1\WxxcxPush; | 6 | use app\api\controller\v1\WxxcxPush; |
7 | use app\common\controller\Backend; | 7 | use app\common\controller\Backend; |
8 | use think\Db; | 8 | use think\Db; |
9 | +use app\api\controller\Index; | ||
9 | use think\exception\DbException; | 10 | use think\exception\DbException; |
10 | use think\exception\PDOException; | 11 | use think\exception\PDOException; |
11 | use think\exception\ValidateException; | 12 | use think\exception\ValidateException; |
@@ -97,6 +98,8 @@ class Order extends Backend | @@ -97,6 +98,8 @@ class Order extends Backend | ||
97 | ->where(['id' => $order['id']]) | 98 | ->where(['id' => $order['id']]) |
98 | ->update($relogs); | 99 | ->update($relogs); |
99 | if($order['pay_type']="offlinepay"){ | 100 | if($order['pay_type']="offlinepay"){ |
101 | + $index=new Index(); | ||
102 | + $index->refundToDriverUser($order['id']); | ||
100 | $this->refundSendMessage($id);//发送订阅消息 | 103 | $this->refundSendMessage($id);//发送订阅消息 |
101 | } | 104 | } |
102 | $this->success("退款成功"); | 105 | $this->success("退款成功"); |
@@ -126,6 +129,8 @@ class Order extends Backend | @@ -126,6 +129,8 @@ class Order extends Backend | ||
126 | } else { | 129 | } else { |
127 | $this->error('退款失败'); | 130 | $this->error('退款失败'); |
128 | } | 131 | } |
132 | + $index=new Index(); | ||
133 | + $index->refundToDriverUser($id); | ||
129 | $this->refundSendMessage($id);//发送订阅消息 | 134 | $this->refundSendMessage($id);//发送订阅消息 |
130 | 135 | ||
131 | $this->success("退款成功"); | 136 | $this->success("退款成功"); |
@@ -620,6 +620,8 @@ class Car extends Base | @@ -620,6 +620,8 @@ class Car extends Base | ||
620 | } | 620 | } |
621 | 621 | ||
622 | refundSendMessage($id);//发送订阅消息 | 622 | refundSendMessage($id);//发送订阅消息 |
623 | + $index=new Index(); | ||
624 | + $index->senWxmsgToDriverUser($id); | ||
623 | $this->success("退款成功"); | 625 | $this->success("退款成功"); |
624 | } else { | 626 | } else { |
625 | $relogs['is_pay'] = 4; | 627 | $relogs['is_pay'] = 4; |
@@ -627,6 +629,8 @@ class Car extends Base | @@ -627,6 +629,8 @@ class Car extends Base | ||
627 | ->where(['id' => $order['id']]) | 629 | ->where(['id' => $order['id']]) |
628 | ->update($relogs); | 630 | ->update($relogs); |
629 | refundSendMessage($id);//发送订阅消息 | 631 | refundSendMessage($id);//发送订阅消息 |
632 | + $index=new Index(); | ||
633 | + $index->senWxmsgToDriverUser($id); | ||
630 | $this->success("取消成功"); | 634 | $this->success("取消成功"); |
631 | } | 635 | } |
632 | } | 636 | } |
@@ -1050,7 +1054,7 @@ class Car extends Base | @@ -1050,7 +1054,7 @@ class Car extends Base | ||
1050 | } | 1054 | } |
1051 | 1055 | ||
1052 | /** | 1056 | /** |
1053 | - * 创建包车订单 | 1057 | + * 创建包车订单线下支付 |
1054 | * @return void | 1058 | * @return void |
1055 | */ | 1059 | */ |
1056 | public function createcharterorderofflinepay() | 1060 | public function createcharterorderofflinepay() |
@@ -121,6 +121,39 @@ class Index extends Api | @@ -121,6 +121,39 @@ class Index extends Api | ||
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
124 | + | ||
125 | + | ||
126 | + function refundToDriverUser($order_id) | ||
127 | + { | ||
128 | + $order=Db::name("order")->find($order_id); | ||
129 | + if($order['driver_id']){ | ||
130 | + $driver=Db::name("driver")->find($order['driver_id']); | ||
131 | + $user=Db::name("user")->find($driver['user_id']); | ||
132 | + $wct_user=Db::name("wct_user")->where("unionid",$user['unionid'])->find(); | ||
133 | + $wxopenid=$wct_user['wx_openid']; | ||
134 | + $sendInfo = array( | ||
135 | + 'first' => array('value' => "客户退票通知", 'color' => "#743A3A"), | ||
136 | + 'thing1' => array('value' => "{$order['starting_point']}-{$order['end_point']}", 'color' => '#173177'), | ||
137 | + 'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', $order['reservation_time'])), 'color' => '#173177'), | ||
138 | + 'thing6' => array('value' =>"{$order['position']}", 'color' => '#173177'), | ||
139 | + 'thing7' => array('value' =>"{$order['end_point']}", 'color' => '#173177'), | ||
140 | + ); | ||
141 | + | ||
142 | + | ||
143 | + if ($wxopenid) { | ||
144 | + $config = get_addon_config('wechat'); | ||
145 | + $tourl = ''; | ||
146 | + $ywt_appid = 'wxb7dd0c03865a94e0'; | ||
147 | + $pagepath = ''; | ||
148 | + $res = $this->refundAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath); | ||
149 | + | ||
150 | + print_r($res);return; | ||
151 | + //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); | ||
152 | + } | ||
153 | + } | ||
154 | + } | ||
155 | + | ||
156 | + | ||
124 | function http_request($url, $data = array()) | 157 | function http_request($url, $data = array()) |
125 | { | 158 | { |
126 | $ch = curl_init(); | 159 | $ch = curl_init(); |
@@ -139,7 +172,33 @@ class Index extends Api | @@ -139,7 +172,33 @@ class Index extends Api | ||
139 | 172 | ||
140 | /** | 173 | /** |
141 | * 微信公众号 | 174 | * 微信公众号 |
142 | - * 经纪人审核 消息推送 | 175 | + * 退款 消息推送 |
176 | + */ | ||
177 | + function refundAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath) | ||
178 | + { | ||
179 | + $myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret; | ||
180 | + $json_token = $this->http_request($myurl); | ||
181 | + $access_tokens = json_decode($json_token, true); | ||
182 | + $access_token = $access_tokens['access_token']; | ||
183 | + $template = array( | ||
184 | + 'touser' => $openid, // | ||
185 | + 'template_id' => 'u8oGieaB8DiwkoK-smIC7nqBQjABAQ-jZsT3aV7HUGs', //模板消息id 必须修改 | ||
186 | + 'url' => $tourl, //点击链接 | ||
187 | + "miniprogram" => [], | ||
188 | + 'topcolor' => "#173177", | ||
189 | + 'data' => $info | ||
190 | + ); | ||
191 | + | ||
192 | + $json_template = json_encode($template); | ||
193 | + $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token; | ||
194 | + $json = $this->http_request($url, urldecode($json_template)); | ||
195 | + $rs = json_decode($json, true); | ||
196 | + return $rs; | ||
197 | + } | ||
198 | + | ||
199 | + /** | ||
200 | + * 微信公众号 | ||
201 | + * 用户下订单 消息推送 | ||
143 | */ | 202 | */ |
144 | function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath) | 203 | function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath) |
145 | { | 204 | { |
-
请 注册 或 登录 后发表评论