作者 黄超

Merge branch 'master' of 47.108.67.251:lubenwei/wyc.tenyes.cn

... ... @@ -12,4 +12,8 @@ public/.htaccess
public/.user.ini
public/nginx.htaccess
.htaccess
public/.well-known/
\ No newline at end of file
public/.well-known/
public/kevin_wx_xcx_push.log
public/pcl_pay_logs.log
public/pcl_pay_p.log
public/pcl_repay_v2.log
\ No newline at end of file
... ...
... ... @@ -82,13 +82,21 @@ class Order extends Backend
public function refund($id)
{
$res=$this->refundSendMessage($id);
print_r($res);return;
//查询订单
$order = Db::name("order")->where("id", $id)->find();
if ($order['is_pay'] != 1) {
$this->error("该订单无法退款");
}
if($order['pay_type']="offlinepay"){
$relogs['update_time'] = time();
$relogs['is_pay'] = 3;
$relogs['refund_time'] = time();
$rs2 = Db::name('order')
->where(['id' => $order['id']])
->update($relogs);
$this->success("退款成功");
}
//拼接退款参数
$pay_fee = $order['price'];
$refund_fee = $pay_fee;
... ...
... ... @@ -165,6 +165,29 @@ if (!function_exists('getOrderSn')) {
}
}
}
if(!function_exists('OrderSendMessage')){
/**
* 发送模板消息
* @return void
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
function OrderSendMessage($order_id){
$order=\think\Db::name("order")->find($order_id);
$wxxcxpush=new WxxcxPush();
$user=new User();
$user=$user->find($order['user_id']);
$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($user['wx_xcx_openid'],$order_id);
if ($res !== false) {
return $res;
}
}
}
if(!function_exists('beingPushed')){
... ...
... ... @@ -24,7 +24,9 @@ class Car extends Base
*/
public function selectroute()
{
$res = Db::name("route")->field("id,name,price,start_address,end_address")->limit(2)->select();
$res = Db::name("route")
->field("id,name,price,start_address,end_address")
->select();
return $this->success($res);
}
... ... @@ -1615,7 +1617,7 @@ class Car extends Base
$this->success("请求成功",$data);
}
public function SendMessage($id){
$res=SendMessage($id);
$res=OrderSendMessage(229);
$this->success("推送成功",$res);
}
... ...
... ... @@ -26,7 +26,7 @@ class WxxcxPush extends Base
public function sendDealApplyMessage($openid_arr, $apply_info)
{
if (empty($openid_arr)) {
return array_callback(false, "未找到需要推送的人员");
return $this->array_callback(false, "未找到需要推送的人员");
}
$sum_count = 0;//总共需要推送的人
$react_count = 0;//实际推送人数
... ... @@ -90,15 +90,15 @@ class WxxcxPush extends Base
// 执行提交操作
Db::commit();
return array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
return $this->array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->array_callback(false, "请求异常" . $e->getMessage());
}
} else {
return array_callback(false, "未找到可通知的社区管理员!");
return $this->array_callback(false, "未找到可通知的社区管理员!");
}
... ... @@ -110,7 +110,7 @@ class WxxcxPush extends Base
public function sendDealSuccessMessage($openid_arr, $deal_info)
{
if (empty($openid_arr)) {
return array_callback(false, "未找到需要推送的人员");
return $this->array_callback(false, "未找到需要推送的人员");
}
$sum_count = 0;//总共需要推送的人
$react_count = 0;//实际推送人数
... ... @@ -168,15 +168,15 @@ class WxxcxPush extends Base
// 执行提交操作
Db::commit();
return array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
return $this->array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->array_callback(false, "请求异常" . $e->getMessage());
}
} else {
return array_callback(false, "未找到可通知的申报用户!");
return $this->array_callback(false, "未找到可通知的申报用户!");
}
}
... ... @@ -187,7 +187,7 @@ class WxxcxPush extends Base
public function sendUploadReportMessage($openid_arr, $deal_info,$report)
{
if (empty($openid_arr)) {
return array_callback(false, "未找到需要推送的人员");
return $this->array_callback(false, "未找到需要推送的人员");
}
$sum_count = 0;//总共需要推送的人
$react_count = 0;//实际推送人数
... ... @@ -244,15 +244,15 @@ class WxxcxPush extends Base
// 执行提交操作
Db::commit();
return array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
return $this->array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->array_callback(false, "请求异常" . $e->getMessage());
}
} else {
return array_callback(false, "未找到可通知的监测人员!");
return $this->array_callback(false, "未找到可通知的监测人员!");
}
}
... ... @@ -264,7 +264,7 @@ class WxxcxPush extends Base
public function sendWorkorderMessage($id,$temp)
{
if (empty($id)) {
return array_callback(false, "id不能为空");
return $this->array_callback(false, "id不能为空");
}
$workorderInfo = Db::name("workorder_orders")->where("id", $id)->find();
... ... @@ -315,24 +315,24 @@ class WxxcxPush extends Base
// 执行提交操作
Db::commit();
return array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
return $this->array_callback(true, "推送成功", ["sum_count" => $sum_count, "react_count" => $react_count]);
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->array_callback(false, "请求异常" . $e->getMessage());
}
} else {
return array_callback(false, "未找到可通知的成员!");
return $this->array_callback(false, "未找到可通知的成员!");
}
} else {
return array_callback(false, "未找到推送人员");
return $this->array_callback(false, "未找到推送人员");
}
} else {
return array_callback(false, "未查找到有效的工单数据");
return $this->array_callback(false, "未查找到有效的工单数据");
}
... ... @@ -402,16 +402,16 @@ class WxxcxPush extends Base
if (!empty($res_arr) && $res_arr['errcode'] == "0") {
} else {
//推送失败,记录问题
return array_callback(true, "推1送成功".json_encode($res_arr));
return $this->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, "推送成功");
return $this->array_callback(true, "推送成功");
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->array_callback(false, "请求异常" . $e->getMessage());
}
... ... @@ -442,26 +442,228 @@ class WxxcxPush extends Base
'value5' => $reservation['remarks'],
);
$res = beingPushed(6, $openid, $page, $insert_message_log_data);
$res = $this->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));
return $this->$this->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, "推送成功");
return $this->$this->array_callback(true, "推送成功");
} catch (PDOException $e) {
Db::rollback();
return array_callback(false, "请求异常" . $e->getMessage());
return $this->$this->array_callback(false, "请求异常" . $e->getMessage());
}
}
}
/**
* 小程序模板推送选择类型
* @param $type @模板类型
* @param $openid @接收人ID
* @param $page @跳转页面
* @param $temp @具体提醒参数
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
function beingPushed($type, $openid, $page, $temp)
{
$data = [];
$data['touser'] = $openid;
$data['page'] = $page;
//模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
switch ($type) {
case 1:
//待审批事项提醒(新版本的长期订阅)
$data['template_id'] = "ws6bz6-WyHHA-upU2oRzc_C5toDUexe9ZicQ-ITtImA";
$data['data'] = [
"thing10" => [
'value' =>$temp['value1'],//审核状态(待处理)
],
"thing12" => [
'value' => $temp['value2'],//申请人(测试黄超)
],
"thing8" => [
'value' => $temp['value3'],//原因(入州报备审核)
]
];
break;
case 2:
//审核结果通知(新版本的长期订阅)
$data['template_id'] = "Qt2xqfH8uQyTm1A0ReNxeybtAydAhfhi4HinnyB5f0s";
$data['data'] = [
"thing1" => [
'value' => $temp['value1'],//提醒内容(已审核)
],
// "name1" => [
// 'value' => $temp['value2'],//审核人
// ],
"thing4" => [
'value' => $temp['value3'],//提示说明
]
];
break;
case 3:
//待审批事项提醒(老版本的一次性订阅)
$data['template_id'] = "vVOonN76AFjxgz77iG-hcWrH6HJ-vPGKyIyAK0VzPIk";
$data['data'] = [
"thing1" => [
'value' => $temp['value1'],//待办事项
],
"thing4" => [
'value' => $temp['value2'],//流程状态
],
"thing2" => [
'value' => $temp['value3'],//申请人
],
"time3" => [
'value' => $temp['value4'],//申请时间
],
"thing5" => [
'value' => $temp['value5'],//备注描述
]
];
break;
case 4:
//审核结果通知(老版本的一次性订阅)
$data['template_id'] = "qR9reAuv_Ulelyg1H2xbN-GoWGWFRhS0t4nhtvnFr5Q";
$data['data'] = [
"character_string1" => [
'value' => $temp['value1'],//审核结果
],
"date3" => [
'value' => $temp['value2'],//审核人
],
"thing5" => [
'value' => $temp['value3'],//审批时间
],
"thing6" => [
'value' => $temp['value4'],//审批时间
],
"thing7" => [
'value' => $temp['value5'],//审批时间
]
];
break;
case 5:
//预约结果通知
$data['template_id'] = "oczyQ_SabASMQRRhDedXRGUEzCAuGh1xBw8sp2HVPvQ";
$data['data'] = [
"thing1" => [
'value' => $temp['value1'],//备注
],
"thing2" => [
'value' =>$temp['value2'],//日期
],
"number3" => [
'value' => $temp['value3'],//就诊人
],
"time4" => [
'value' => $temp['value4'],//就诊人
],
"thing6" => [
'value' => $temp['value5'],//就诊人
]
];
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 $this->sendSubscribeMessage($data);
}
/**
* 小程序订阅消息推送
* @param $data
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
function sendSubscribeMessage($data)
{
//access_token
$access_token =$this->getAccessToken();
//请求url
$url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' . $access_token;
//file_put_contents('notify.txt',$data.PHP_EOL,FILE_APPEND);
//跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
$data['miniprogram_state'] = 'formal';
return $this->curlPost($url, json_encode($data));
}
/**
* 获取access_token
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
function getAccessToken()
{
$wx_xcx_token = \think\Db::name("wechat_token")->where("type", "wx_xcx")->find();
if (empty($wx_xcx_token) || empty($wx_xcx_token['access_token']) || $wx_xcx_token['over_time'] <= time()) {
//微信小程序失效
//当前时间戳
$now_time = strtotime(date('Y-m-d H:i:s', time()));
//获取新的access_token
$appid = config("site.wxxcx_AppID");
$secret = config("site.wxxcx_AppSecret");
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
$res = json_decode(file_get_contents($url), true);
$access_token = $res['access_token'];
if (!empty($access_token)) {
$time = time();
$update_data = [
"access_token" => $access_token,
"over_time" => $time + 7200,
"type" => "wx_xcx",
"updatetime" => $time
];
if (!empty($wx_xcx_token)) {
//更新
\think\Db::name("wechat_token")->where("id", $wx_xcx_token['id'])->update($update_data);
} else {
//新增
\think\Db::name("wechat_token")->insertGetId($update_data);
}
}
} else {
$access_token = $wx_xcx_token['access_token'];
}
return $access_token;
}
function array_callback($state = true, $msg = '', $data = array())
{
return array('state' => $state, 'msg' => $msg, 'data' => $data);
}
}
... ...