增加日志 更新项目详情
This commit is contained in:
parent
04923944dc
commit
8b8958d71e
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace App\Utils\API;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use support\Log;
|
||||
|
||||
/**
|
||||
* 第三方api转账
|
||||
*/
|
||||
class PaymentNew
|
||||
{
|
||||
public static function generate_encrypt_value($data, $secret_key)
|
||||
{
|
||||
// 1. 过滤掉 EncryptValue 和值为 null 的参数
|
||||
$filtered_data = array_filter($data, function ($v, $k) {
|
||||
return $k !== "EncryptValue" && $v !== null;
|
||||
}, ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
// 2. 按照 A~Z 顺序排序 key
|
||||
ksort($filtered_data);
|
||||
|
||||
// 3. 拼接 key=value 形式的字符串,并加上 HashKey=密钥
|
||||
$param_str = http_build_query($filtered_data) . "&HashKey=$secret_key";
|
||||
|
||||
// 4. 转换为小写
|
||||
$param_str = strtolower($param_str);
|
||||
|
||||
// 5. 计算 sha256 哈希
|
||||
$hash_value = hash('sha256', $param_str);
|
||||
|
||||
// 6. 转换为大写返回
|
||||
return strtoupper($hash_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
public static function pushMoney($money, $payeeAccountName, $payeeAccountNumber, $payeeBankName)
|
||||
{
|
||||
$secret_key = "sZ2wAfh1lMkxBVrlY4uZY8Fj92E4scFf";
|
||||
$url = "https://mdf.hr5688.com/api/createPaymentOrder";
|
||||
|
||||
// Guzzle HTTP client
|
||||
$client = new Client();
|
||||
|
||||
// 请求数据
|
||||
$payload = [
|
||||
"Amount" => $money,
|
||||
"CurrencyId" => 11,
|
||||
"IsTest" => false,
|
||||
"PayeeAccountName" => $payeeAccountName,
|
||||
"PayeeAccountNumber" => $payeeAccountNumber,
|
||||
"PayeeBankName" => $payeeBankName,
|
||||
"PayeeIFSCCode" => "abc123",
|
||||
"PaymentChannelId" => 34,
|
||||
"ShopInformUrl" => "https://www.google.com",
|
||||
"ShopOrderId" => "10",
|
||||
"ShopRemark" => "", // 留空时可不给此参数
|
||||
"ShopUserLongId" => "776ae472-d4fc-435c-9639-be5763138d95"
|
||||
];
|
||||
|
||||
// 生成加密值
|
||||
$encrypt_value = self::generate_encrypt_value($payload, $secret_key);
|
||||
$payload["EncryptValue"] = $encrypt_value;
|
||||
|
||||
try {
|
||||
// 发送 POST 请求
|
||||
$response = $client->post($url, [
|
||||
'json' => $payload,
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
]
|
||||
]);
|
||||
|
||||
// 获取响应内容
|
||||
$responseBody = $response->getBody()->getContents();
|
||||
$httpCode = $response->getStatusCode();
|
||||
|
||||
if ($httpCode == 200) {
|
||||
echo $responseBody;
|
||||
} else {
|
||||
echo "Error: HTTP Code $httpCode\n";
|
||||
echo $responseBody;
|
||||
}
|
||||
|
||||
return $responseBody;
|
||||
} catch (\GuzzleHttp\Exception\RequestException $e) {
|
||||
echo "Request failed: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,14 @@ namespace app\controller;
|
|||
use support\Request;
|
||||
|
||||
use App\Utils\ApiResponse;
|
||||
|
||||
use support\Log;
|
||||
class IndexController
|
||||
{
|
||||
protected $noNeedLogin = ['index'];
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
Log::channel('plugin.admin.default')->info('test');
|
||||
static $readme;
|
||||
if (!$readme) {
|
||||
$readme = file_get_contents(base_path('README.md'));
|
||||
|
|
Loading…
Reference in New Issue