加redis日志

This commit is contained in:
2025-09-30 18:11:36 +08:00
parent e0004eb216
commit 8d014150a2
2 changed files with 18 additions and 0 deletions

View File

@@ -230,8 +230,10 @@ class Payment extends Controller
$timestamp = input("timestamp", "");
$sign = input("sign", "");
Log::record("云账户回调信息".json_encode($_POST),"info");
write_log_redis("yunzhanghu_huidiao_原始数据",$_POST);
$yun_pay = new YunPay();
$result = $yun_pay->yun_callback($data,$mess,$timestamp,$sign);
write_log_redis("yunzhanghu_huidiao_解密后数据",$result);
if($result['code']==1){
$data = $result['data'];
if($data){

View File

@@ -1281,6 +1281,22 @@ function getMillisecond() {
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
/*
* 写入日志到redis
* @param string $key 日志key
* @param array $logData 日志数据
*/
function write_log_redis($key = 'log',$logData = [],$time = 7){
$redis = new \Redis();
// 连接到Redis服务器
$redis->connect(config('redis.host'), config('redis.port')); // 根据实际配置调整主机和端口
// 选择数据库2
$redis->select(2);
$key = $key.'_'.date('Y-m-d-H-i-s');
$expire = 86400 * $time;
$redis->setex($key, $expire, json_encode($logData));
}