|
@@ -4,6 +4,7 @@ namespace liuniu;
|
|
|
|
|
|
|
|
use app\admin\model\Company;
|
|
use app\admin\model\Company;
|
|
|
use app\admin\model\WechatPlanRecord;
|
|
use app\admin\model\WechatPlanRecord;
|
|
|
|
|
+use app\api\controller\Lave;
|
|
|
use app\common\model\LaveMonth;
|
|
use app\common\model\LaveMonth;
|
|
|
use app\common\model\WechatContext;
|
|
use app\common\model\WechatContext;
|
|
|
use EasyWeChat\Factory;
|
|
use EasyWeChat\Factory;
|
|
@@ -381,6 +382,8 @@ class WechatService
|
|
|
$params = [$cid, $notify['contract_code']];
|
|
$params = [$cid, $notify['contract_code']];
|
|
|
Hook::exec("\\liuniu\\repositories\\PaymentRepositories", "wechat" . ucfirst('MonthLave'), $params);
|
|
Hook::exec("\\liuniu\\repositories\\PaymentRepositories", "wechat" . ucfirst('MonthLave'), $params);
|
|
|
@file_put_contents("quanju.txt", json_encode($params)."-不知道行不行\r\n", 8);
|
|
@file_put_contents("quanju.txt", json_encode($params)."-不知道行不行\r\n", 8);
|
|
|
|
|
+ $tf = Lave::paySignPap($notify['contract_code']);
|
|
|
|
|
+ @file_put_contents("quanju3.txt", $tf."-第一次扣款\r\n", 8);
|
|
|
}elseif ($notify['change_type']=='DELETE'){
|
|
}elseif ($notify['change_type']=='DELETE'){
|
|
|
@file_put_contents("quanju.txt", "-关闭签约\r\n", 8);
|
|
@file_put_contents("quanju.txt", "-关闭签约\r\n", 8);
|
|
|
$cs=WechatPlanRecord::where('contract_code',$notify['contract_code'])->Update(['is_signing' => 1,'deletetime'=>time()]);
|
|
$cs=WechatPlanRecord::where('contract_code',$notify['contract_code'])->Update(['is_signing' => 1,'deletetime'=>time()]);
|
|
@@ -650,49 +653,49 @@ class WechatService
|
|
|
$url = 'https://api.mch.weixin.qq.com/papay/entrustweb?' . rtrim($queryString, '&');
|
|
$url = 'https://api.mch.weixin.qq.com/papay/entrustweb?' . rtrim($queryString, '&');
|
|
|
|
|
|
|
|
// 记录请求URL
|
|
// 记录请求URL
|
|
|
- @file_put_contents("quanju3.txt", "请求URL: " . $url . "\n");
|
|
|
|
|
- return $url;
|
|
|
|
|
-// 发送请求(禁止自动重定向)
|
|
|
|
|
- $ch = curl_init();
|
|
|
|
|
- curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
|
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
|
|
|
|
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // 关键:禁止自动重定向
|
|
|
|
|
- curl_setopt($ch, CURLOPT_HEADER, true); // 获取响应头
|
|
|
|
|
-
|
|
|
|
|
- $response = curl_exec($ch);
|
|
|
|
|
- $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
-
|
|
|
|
|
-// 记录完整响应
|
|
|
|
|
- @file_put_contents("quanju3.txt", "HTTP状态码: " . $http_code . "\n响应内容: " . $response . "\n", FILE_APPEND);
|
|
|
|
|
-
|
|
|
|
|
-// 分析响应
|
|
|
|
|
- if ($http_code == 302) {
|
|
|
|
|
- // 解析重定向地址
|
|
|
|
|
- preg_match('/Location: (.*)/i', $response, $matches);
|
|
|
|
|
- $redirect_url = trim($matches[1] ?? '');
|
|
|
|
|
-
|
|
|
|
|
- if ($redirect_url) {
|
|
|
|
|
- // 成功重定向到微信签约页面
|
|
|
|
|
- @file_put_contents("quanju3.txt", "签约URL: " . $redirect_url . "\n", FILE_APPEND);
|
|
|
|
|
- } else {
|
|
|
|
|
- @file_put_contents("quanju3.txt", "错误:未找到重定向地址\n", FILE_APPEND);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 提取可能的错误信息
|
|
|
|
|
- preg_match('/<error_description><!\[CDATA\[(.*?)\]\]><\/error_description>/', $response, $error_matches);
|
|
|
|
|
- $error_msg = $error_matches[1] ?? '未知错误';
|
|
|
|
|
-
|
|
|
|
|
- @file_put_contents("quanju3.txt", "错误信息: " . $error_msg . "\n", FILE_APPEND);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- curl_close($ch);
|
|
|
|
|
- if (curl_errno($ch)) {
|
|
|
|
|
- echo 'CURL Error: ' . curl_error($ch);
|
|
|
|
|
- } else {
|
|
|
|
|
- echo "Response:\n" . $response;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// @file_put_contents("quanju3.txt", "请求URL: " . $url . "\n");
|
|
|
|
|
+// return $url;
|
|
|
|
|
+//// 发送请求(禁止自动重定向)
|
|
|
|
|
+// $ch = curl_init();
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // 关键:禁止自动重定向
|
|
|
|
|
+// curl_setopt($ch, CURLOPT_HEADER, true); // 获取响应头
|
|
|
|
|
+//
|
|
|
|
|
+// $response = curl_exec($ch);
|
|
|
|
|
+// $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
+//
|
|
|
|
|
+//// 记录完整响应
|
|
|
|
|
+// @file_put_contents("quanju3.txt", "HTTP状态码: " . $http_code . "\n响应内容: " . $response . "\n", FILE_APPEND);
|
|
|
|
|
+//
|
|
|
|
|
+//// 分析响应
|
|
|
|
|
+// if ($http_code == 302) {
|
|
|
|
|
+// // 解析重定向地址
|
|
|
|
|
+// preg_match('/Location: (.*)/i', $response, $matches);
|
|
|
|
|
+// $redirect_url = trim($matches[1] ?? '');
|
|
|
|
|
+//
|
|
|
|
|
+// if ($redirect_url) {
|
|
|
|
|
+// // 成功重定向到微信签约页面
|
|
|
|
|
+// @file_put_contents("quanju3.txt", "签约URL: " . $redirect_url . "\n", FILE_APPEND);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// @file_put_contents("quanju3.txt", "错误:未找到重定向地址\n", FILE_APPEND);
|
|
|
|
|
+// }
|
|
|
|
|
+// } else {
|
|
|
|
|
+// // 提取可能的错误信息
|
|
|
|
|
+// preg_match('/<error_description><!\[CDATA\[(.*?)\]\]><\/error_description>/', $response, $error_matches);
|
|
|
|
|
+// $error_msg = $error_matches[1] ?? '未知错误';
|
|
|
|
|
+//
|
|
|
|
|
+// @file_put_contents("quanju3.txt", "错误信息: " . $error_msg . "\n", FILE_APPEND);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// curl_close($ch);
|
|
|
|
|
+// if (curl_errno($ch)) {
|
|
|
|
|
+// echo 'CURL Error: ' . curl_error($ch);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// echo "Response:\n" . $response;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// $request_serial = time();
|
|
// $request_serial = time();
|
|
|
// $timestamp = time();
|
|
// $timestamp = time();
|
|
@@ -703,8 +706,8 @@ class WechatService
|
|
|
// $order
|
|
// $order
|
|
|
// );
|
|
// );
|
|
|
// var_dump($result);die();
|
|
// var_dump($result);die();
|
|
|
- @file_put_contents("quanju3.txt", json_encode($response) . "-签约返回结果测试\r\n", 8);
|
|
|
|
|
- return $response;
|
|
|
|
|
|
|
+// @file_put_contents("quanju3.txt", json_encode($response) . "-签约返回结果测试\r\n", 8);
|
|
|
|
|
+ return $url;
|
|
|
}
|
|
}
|
|
|
public static function generateWechatMD5Sign($params, $key) {
|
|
public static function generateWechatMD5Sign($params, $key) {
|
|
|
// 1. 过滤空值和签名参数
|
|
// 1. 过滤空值和签名参数
|