master
elf 8 months ago
parent e5781b8bf2
commit 888ba7e300

@ -2020,9 +2020,13 @@ function get_payment_config($way=1, $game=0, $user_id=0, $pay_amount = 0, $skipO
// $monthEnd = date('Y-m-d', strtotime(date('Y-m-01') . '+1 month -1 day')); // $monthEnd = date('Y-m-d', strtotime(date('Y-m-01') . '+1 month -1 day'));
// $payAmountRow = M('spend','tab_')->field('SUM(pay_amount) as sum_amount')->where(array('pay_way'=>41, 'pay_real_status'=>1, 'payed_time' => ['gt', $monthBegin], 'payed_time' => ['lt', $monthEnd]))->find(); // $payAmountRow = M('spend','tab_')->field('SUM(pay_amount) as sum_amount')->where(array('pay_way'=>41, 'pay_real_status'=>1, 'payed_time' => ['gt', $monthBegin], 'payed_time' => ['lt', $monthEnd]))->find();
// $payAmount = intval($payAmountRow['sum_amount']); // $payAmount = intval($payAmountRow['sum_amount']);
/* if (($pay_amount > 2000 && !$skipOuterPay && in_array($game['id'], [7, 8, 9, 10, 11, 12, 13, 14])) || in_array($user_id, [6, 186, 18925])) { if (($pay_amount > 2000 && !$skipOuterPay && in_array($game['id'], [7, 8, 9, 10, 11, 12, 13, 14])) || in_array($user_id, [6, 186, 18925])) {
$ip = get_client_ip();
$result = getIpInfo($ip);
if ($result['code'] == 200 && $result['success'] && $result['data']['city'] != '福州') {
return ['code' => 0, 'msg' => '', 'data' => ['id' => 3, 'channel' => 11, 'config' => '{}']]; return ['code' => 0, 'msg' => '', 'data' => ['id' => 3, 'channel' => 11, 'config' => '{}']];
} */ }
}
$payment_rule = M('payment_rule', 'tab_')->where($map)->select(); $payment_rule = M('payment_rule', 'tab_')->where($map)->select();
$find_rule = false; $find_rule = false;
@ -3244,3 +3248,65 @@ function discountInfo($gameId, $time=0)
return $discount; return $discount;
} }
function getIpInfo($ip) {
// 云市场分配的密钥Id
$secretId = 'AKID5tH3om0m0dPG4KMBLFLp03E4zrOF0a1qTCXh';
// 云市场分配的密钥Key
$secretKey = 'J06iJMIphW7P6j2KvOr9lMk3EuD9UkJ1ltVo2R3p';
$source = 'market';
// 签名
$datetime = gmdate('D, d M Y H:i:s T');
$signStr = sprintf("x-date: %s\nx-source: %s", $datetime, $source);
$sign = base64_encode(hash_hmac('sha1', $signStr, $secretKey, true));
$auth = sprintf('hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"', $secretId, $sign);
// 请求方法
$method = 'POST';
// 请求头
$headers = array(
'X-Source' => $source,
'X-Date' => $datetime,
'Authorization' => $auth,
);
// 查询参数
$queryParams = array (
);
// body参数POST方法下
$bodyParams = array (
'ip' => $ip,
);
// url参数拼接
$url = 'https://service-hnhpr5tw-1305308687.gz.apigw.tencentcs.com/release/ip/query';
if (count($queryParams) > 0) {
$url .= '?' . http_build_query($queryParams);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) {
return $k . ': ' . $v;
}, array_values($headers), array_keys($headers)));
if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams));
}
$data = curl_exec($ch);
if (curl_errno($ch)) {
return [
"success" => false,
"code" => 800,
"data" => null,
"msg" => "请求失败"
];
} else {
return json_decode($data, true);
}
curl_close($ch);
}

@ -1,5 +1,5 @@
<?php <?php
getIpInfo('120.32.100.138'); var_dump(getIpInfo('120.32.100.138'));
function getIpInfo($ip) { function getIpInfo($ip) {
// 云市场分配的密钥Id // 云市场分配的密钥Id
@ -51,9 +51,14 @@ function getIpInfo($ip) {
$data = curl_exec($ch); $data = curl_exec($ch);
if (curl_errno($ch)) { if (curl_errno($ch)) {
echo "Error: " . curl_error($ch); return [
"success" => false,
"code" => 800,
"data" => null,
"msg" => "请求失败"
];
} else { } else {
print_r($data); return json_decode($data, true);
} }
curl_close($ch); curl_close($ch);
} }

Loading…
Cancel
Save