113 lines
3.4 KiB
PHP
113 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2019-2029 成都SAAS云科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.gobuysaas.com
|
|
* =========================================================
|
|
*/
|
|
namespace app\pay\controller;
|
|
use app\Controller;
|
|
use app\model\system\Cron;
|
|
use app\model\system\Pay as PayModel;
|
|
use think\facade\Db;
|
|
use think\facade\Log;
|
|
/**
|
|
* 支付控制器
|
|
*/
|
|
class Pay extends Controller{
|
|
|
|
// 支付异步通知
|
|
public function notify(){
|
|
// 参数获取
|
|
$param = input();
|
|
$postStr = request()->getContent();
|
|
$postData = request()->post();
|
|
$param['paytype'] = input('paytype','');
|
|
$param['app_type'] = input('app_type','');
|
|
$res = 0;
|
|
try{
|
|
$data = [
|
|
'site_id' => $param['site_id'],
|
|
'pay_type' => $param['paytype'],
|
|
'create_time' => time(),
|
|
'update_time' => time(),
|
|
];
|
|
// 通知数据获取
|
|
$data['notify_data'] = !empty($postData) ? json_encode($postData) : $postStr;
|
|
$res = Db::name('pay_notify_log')->insert($data,TRUE);
|
|
event('PayNotify',$param);
|
|
}
|
|
catch(\Exception $e){
|
|
Log::write('notifyerrar'.'----'.$e->getMessage());
|
|
event('PayNotify',$param);
|
|
}
|
|
finally{
|
|
$cron_model = new Cron();//添加支付验证任务
|
|
$cron_model->addCron(1,1,'支付验证任务','PayNotifyListens',time() + 30,$res);
|
|
}
|
|
}
|
|
|
|
public function payReturn()
|
|
{
|
|
$param = input();
|
|
event('payReturn', $param);
|
|
}
|
|
|
|
/***
|
|
* 支付宝网关通知
|
|
*/
|
|
public function alinotify()
|
|
{
|
|
$param = input();
|
|
Log::log('info', '支付宝网关通知:' . json_encode($param));
|
|
event('AliAuthNotify', $param);
|
|
}
|
|
|
|
/***
|
|
* 芝麻行业云回调
|
|
* @return void
|
|
*/
|
|
public function cloudnotify()
|
|
{
|
|
$param = input();
|
|
Log::log('info', '支付宝行业云:' . json_encode($param));
|
|
event('AliZmCloudPayNotify', $param);
|
|
}
|
|
/**
|
|
* 付款码支付
|
|
*/
|
|
public function authcodePay()
|
|
{
|
|
$param = input();
|
|
$result = event('AuthcodePay', $param, true);
|
|
if (empty($result)) {
|
|
$pay_model = new PayModel();
|
|
return json($pay_model->error([], '付款码未通过校验!'));
|
|
}
|
|
return json($result);
|
|
}
|
|
// 微信相关回调处理 https://cloud.sopvip.com/pay/pay/weChatNotify
|
|
public function weChatNotify()
|
|
{
|
|
// 参数获取
|
|
$params = input();
|
|
$params = is_array($params) ? $params : (array)$params;
|
|
$params['request_url'] = $_SERVER['REQUEST_URI'] ?? $_SERVER['QUERY_STRING'];
|
|
if ($params) {
|
|
Log::debug('微信相关回调处理' . json_encode($params));
|
|
event('weChatNotifyHandle', $params);
|
|
}
|
|
}
|
|
/***
|
|
* 微信服务市场通用消息推送
|
|
*/
|
|
public function wxfuwunotify()
|
|
{
|
|
$param = input();
|
|
Log::log('info', '微信服务市场网关通知:' . json_encode($param));
|
|
event('WxFuwuNotify', $param);
|
|
}
|
|
}
|