作者 郭文星

123

... ... @@ -97,6 +97,7 @@ class Order extends Backend
$response = json_decode($response, true);
file_put_contents("pcl_repay_v2.log", date("Y-m-d H:i:s") . "::" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
if (!empty($response['return_code'] == 'SUCCESS')) {
refundSendMessage($id);//发送订阅消息
//退款成功,更新退款记录
$relogs['update_time'] = time();
$relogs['is_pay'] = 3;
... ...
... ... @@ -167,6 +167,27 @@ if (!function_exists('getOrderSn')) {
}
if(!function_exists('beingPushed')){
/**
* 发送模板消息
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
function refundSendMessage($order_id){
$order=\think\Db::name("order")->find($order_id);
$wxxcxpush=new WxxcxPush();
$user=new User();
$user=$user->find($order['user_id']);
$res=$wxxcxpush->refundMessage($user['wx_xcx_openid'],$order_id);
if ($res !== false) {
return $res;
}
}
}
if (!function_exists('beingPushed')) {
/**
* 小程序模板推送选择类型
... ... @@ -239,16 +260,22 @@ if (!function_exists('beingPushed')) {
break;
case 4:
//审核结果通知(老版本的一次性订阅)
$data['template_id'] = "yJRK0DZFuEPqaWwyS0DegT0r2p5be0bm2eE59oroGME";
$data['template_id'] = "qR9reAuv_Ulelyg1H2xbN-GoWGWFRhS0t4nhtvnFr5Q";
$data['data'] = [
"phrase2" => [
"character_string1" => [
'value' => $temp['value1'],//审核结果
],
"name1" => [
"date3" => [
'value' => $temp['value2'],//审核人
],
"date4" => [
"thing5" => [
'value' => $temp['value3'],//审批时间
],
"thing6" => [
'value' => $temp['value4'],//审批时间
],
"thing7" => [
'value' => $temp['value5'],//审批时间
]
];
break;
... ... @@ -273,6 +300,27 @@ if (!function_exists('beingPushed')) {
]
];
break;
case 6:
//预约结果通知
$data['template_id'] = "Dfvkyn3So2YE5aVJtkUTFWdjgzpo6VvWkNHZBOMb_n4";
$data['data'] = [
"character_string1" => [
'value' => $temp['value1'],//备注
],
"number2" => [
'value' =>$temp['value2'],//日期
],
"name3" => [
'value' => $temp['value3'],//就诊人
],
"date4" => [
'value' => $temp['value4'],//就诊人
],
"thing9" => [
'value' => $temp['value5'],//就诊人
]
];
break;
}
return sendSubscribeMessage($data);
... ...
... ... @@ -592,6 +592,7 @@ class Car extends Base
$response = json_decode($response, true);
file_put_contents("pcl_repay_v2.log", date("Y-m-d H:i:s") . "::" . json_encode($response, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
if (!empty($response['return_code'] == 'SUCCESS')) {
refundSendMessage($id);//发送订阅消息
//退款成功,更新退款记录
$relogs['update_time'] = time();
$relogs['is_pay'] = 3;
... ...
... ... @@ -417,4 +417,51 @@ class WxxcxPush extends Base
}
}
//小程序发送一次性订阅消息
public function refundMessage($openid,$reservation_id){
$reservation=Db::name("order")->find($reservation_id);
if(!empty($reservation)){
// 启动事务
Db::startTrans();
try {
//查询线路
$route=Db::name("route")->find($reservation['route_id']);
$user=Db::name("user")->find($reservation['user_id']);
$createtime = time();
if(!$reservation['remarks']){
$reservation['remarks']="暂无";
}
//通知
$page = '/pageOne/moreRes/moreRes';
$temp='oczyQ_SabASMQRRhDedXRGUEzCAuGh1xBw8sp2HVPvQ';
$insert_message_log_data = array(
'value1' => $reservation['order_no'],
'value2' => 1,
'value3' => $user['username'],
'value4' => date("Y-m-d H:i:s",$reservation['reservation_time']),
'value5' => $reservation['remarks'],
);
$res = beingPushed(6, $openid, $page, $insert_message_log_data);
file_put_contents("kevin_wx_xcx_push.log", date("Y-m-d H:i:s") . "《" . $reservation_id . "》" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
$res_arr = !empty($res) ? json_decode($res, true) : [];
if (!empty($res_arr) && $res_arr['errcode'] == "0") {
} else {
//推送失败,记录问题
return array_callback(true, "推1送成功".json_encode($res_arr));
$insert_message_log_data['error_tips'] = json_encode($res_arr, JSON_UNESCAPED_UNICODE);
}
// 执行提交操作
Db::commit();
return array_callback(true, "推送成功");
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
}
}
}
}
... ...