master
elf 7 months ago
parent 888ba7e300
commit db80309949

@ -11,7 +11,6 @@ use Sdk\Controller\Ipa365Controller;
use Base\Tool\Redis; use Base\Tool\Redis;
use Org\Kudian\Response as KDResponse; use Org\Kudian\Response as KDResponse;
use Org\Kudian\Log as KDLog; use Org\Kudian\Log as KDLog;
use Org\OuterPay\Log as OuterPayLog;
/** /**
* 支付回调控制器 * 支付回调控制器
@ -969,42 +968,4 @@ class NotifyController extends BaseController
} }
echo 'SUCCESS'; echo 'SUCCESS';
} }
/**
* 外部支付宝回调
*/
public function out_alipay_callback() {
$params = file_get_contents('php://input');
OuterPayLog::write('NOTIFY_INPUT:' . file_get_contents('php://input'));
$params = json_decode($params, true);
if ($params['trade_status'] != 'TRADE_SUCCESS' || $params['pay_status'] == 'TRADE_FINISHED') {
echo 'success';
return;
}
$orderInfo['trade_no'] = $params['trade_no'];
$orderInfo['out_trade_no'] = $params['out_trade_no'];
$orderInfo['money'] = $params['total_amount'];
$payWhere = substr($params['out_trade_no'], 0, 2);
switch ($payWhere) {
case 'SP':
$result = $this->set_spend($orderInfo);
break;
case 'PF':
$result = $this->set_deposit($orderInfo);
break;
case 'AG':
$result = $this->set_agent($orderInfo);
break;
default:
exit('accident order data');
break;
}
echo 'success';
}
} }

@ -2016,18 +2016,6 @@ function get_payment_config($way=1, $game=0, $user_id=0, $pay_amount = 0, $skipO
return ['code' => -3, 'msg' => '找不到游戏ID'.$game['id'], 'data' => []]; return ['code' => -3, 'msg' => '找不到游戏ID'.$game['id'], 'data' => []];
} }
// $monthBegin = strtotime(date('Y-m-01 00:00:00'));
// $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();
// $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])) {
$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' => '{}']];
}
}
$payment_rule = M('payment_rule', 'tab_')->where($map)->select(); $payment_rule = M('payment_rule', 'tab_')->where($map)->select();
$find_rule = false; $find_rule = false;
$rule = array(); $rule = array();

@ -15,7 +15,6 @@ use Sdk\Model\PayLimitConfModel;
use Sdk\Model\PayChannelInterntionModel; use Sdk\Model\PayChannelInterntionModel;
use Sdk\Model\PayChannelIntentionModel; use Sdk\Model\PayChannelIntentionModel;
use Org\Kudian\Api as KDApi; use Org\Kudian\Api as KDApi;
use Org\OuterPay\AlipayApi;
class PayH5Controller extends BaseController{ class PayH5Controller extends BaseController{
const ALI_PAY = 1; const ALI_PAY = 1;
@ -227,32 +226,6 @@ class PayH5Controller extends BaseController{
} else { } else {
echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response->getMsg()}】,请选择其他支付方式或联系客服"]);exit; echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response->getMsg()}】,请选择其他支付方式或联系客服"]);exit;
} }
} elseif ($pay_info['channel'] == 11) { // 外部支付宝
$request['pay_way'] = 41;
$request['pay_status'] = 0;
$request['spend_ip'] = get_client_ip();
$this->add_deposit($request, 1);
$notifyUrl = C('PAY_DOMAIN')."/callback.php/Notify/kd_callback";
$backUrl = C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/user_token/".$this->userToken."/paytype/weixinpay/game_id/{$game_id}";
$userInfo = get_user_entity($request['user_id']);
$response = AlipayApi::pay($request, $userInfo, $notifyUrl, $backUrl);
if($response['code'] == '0000'){
// 存入pay_url 继续支付
M("deposit", "tab_")->where([
'extend' => $request['extend'],
'game_id' => $request['game_id'],
'pay_order_number' => $request["pay_order_number"]
])->save([
'pay_url' => $response['data']['pay_url']
]);
$orderno = $request['pay_order_number'];
} else {
echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response['message']}】,请选择其他支付方式或联系客服"]);exit;
}
} else{ // 支付宝第三方 } else{ // 支付宝第三方
if( empty(C('goldpig.partner'))||empty(C('goldpig.wooolid'))){ if( empty(C('goldpig.partner'))||empty(C('goldpig.wooolid'))){
// $this->set_message(1009, "fail", "支付参数未配置"); // $this->set_message(1009, "fail", "支付参数未配置");
@ -615,44 +588,6 @@ class PayH5Controller extends BaseController{
} else { } else {
echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response->getMsg()}】,请选择其他支付方式或联系客服"]);exit; echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response->getMsg()}】,请选择其他支付方式或联系客服"]);exit;
// redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$ret[0]['respMess'], 'user_token' => $this->userToken)));exit;
}
} elseif ($pay_info['channel'] == 11) { // 外部支付宝
$request['pay_way'] = 41;
$request['pay_status'] = 0;
$request['spend_ip'] = get_client_ip();
$request['merchant_id'] = $pay_info['id'];
$request['merchant_way'] = 1;
$request['main_id'] = $main_id;
$userInfo = get_user_entity($request['user_id']);
$request['game_name'] = $request['game_name'] ?: get_game_name($request["game_id"]);
$ordercheck = M("spend","tab_")->where(array('pay_order_number'=>$request["pay_order_number"]))->find();
if ($ordercheck) {
$returl = U('Spend/notice',array('user_id'=>$ordercheck['user_id'],'game_id'=>$ordercheck['game_id'],'msg'=>'订单已经存在,请刷新充值页面重新下单!'));
echo json_encode(['code'=>0,'msg'=>'订单已经存在,请刷新充值页面重新下单!','wap'=>1]);
exit;
}
$this->add_spend($request,1);
$notifyUrl = C('PAY_DOMAIN')."/callback.php/Notify/out_alipay_callback";
$backUrl = C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/user_token/".$this->userToken."/paytype/weixinpay/game_id/{$game_id}";
$response = AlipayApi::pay($request, $userInfo, $notifyUrl, $backUrl);
if($response['code'] == '0000'){
// 存入pay_url 继续支付
M("spend", "tab_")->where([
'extend' => $request['extend'],
'game_id' => $request['game_id'],
'pay_order_number' => $request["pay_order_number"]
])->save([
'pay_url' => $response['data']['pay_url']
]);
$orderno = $request['pay_order_number'];
} else {
echo json_encode(['code'=>1001,'msg'=> "请求发起失败【{$response['message']}】,请选择其他支付方式或联系客服"]);exit;
// redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$ret[0]['respMess'], 'user_token' => $this->userToken)));exit; // redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$ret[0]['respMess'], 'user_token' => $this->userToken)));exit;
} }
} else { // 支付宝第三方 } else { // 支付宝第三方

@ -1,65 +0,0 @@
<?php
namespace Org\OuterPay;
class AlipayApi
{
public static function pay($data, $userInfo, $notifyUrl, $returnUrl) {
$url = "http://pay.hexidongkeji.top/pay";
$params = [];
$params['user_id'] = (int)$data["user_id"];
$params['user_account'] = $userInfo["account"];
$params['game_id'] = (int)$data["game_id"];
$params['game_name'] = $data['game_name'];
$params['server_id'] = $data["server_id"];
$params['server_name'] = $data["server_name"];
$params['role_id'] = $data["game_player_id"];
$params['role_name'] = $data["game_player_name"];
$params['promote_id'] = (int)$userInfo["promote_id"];
$params['promote_account'] = $userInfo["promote_account"];
$params['order_no'] = $data["pay_order_number"];
$params['pay_amount'] = (int)($data["price"] * 100);
$params['notify_url'] = $notifyUrl;
$params['return_url'] = $returnUrl;
$params['subject'] = '消费_' . $data["pay_order_number"];
return self::request($url, $params);
}
private static function request($url, $params): array
{
try {
$response = self::post($url, $params);
Log::write('REQUEST_RESPONSE: ' . $response);
return json_decode($response, true);
} catch (\Exception $e) {
Log::write('REQUEST_ERROR: ' . $e->getMessage());
return [
'code' => -999,
'message' => '网络错误',
];
}
}
private static function post($url, $params): string
{
Log::write('REQUEST_URL: ' . json_encode($url));
Log::write('REQUEST_DATA: ' . json_encode($params));
$curl = curl_init();
if (stripos($url, 'https://') !== false){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true);
$headers = ['Content-type: application/json'];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
$response = curl_exec($curl);
curl_close($curl);
return $response;
var_dump(urldecode('https://openapi.alipay.com/gateway.do?app_id=2021004129619376&biz_content=%7B%22subject%22%3A%22%E6%B6%88%E8%B4%B9_SP_20231212143602pGYx%22%2C%22out_trade_no%22%3A%22SP_20231212143602pGYx%22%2C%22total_amount%22%3A%226E%2B00%22%2C%22product_code%22%3A%22%22%7D&charset=utf-8&format=JSON&method=alipay.trade.wap.pay&notify_url=http%3A%2F%2Fpay.hexidongkeji.top%2Fnotify&return_url=http%3A%2F%2Fpay.hexidongkeji.top%2Freturn&sign=H44Ll1KLmiE8ogbypyHb1cw7kHTmefLgN6vOOcTS1yxSRMaKHIpdT8e%2F030Bok2bQQiueVXzymEVeMUFs5NS9bvc7m6%2FoyaWpmmIUwNuqYJDgx8hof6qFVEsifWEhRTBgPbzVU9NPuwzP84FTqsVtahfSEaPVkdIcaBao8RC7pgoXCwcNGCG4JK6J0ZQNgIwWdccpKWWmMlXVNaXCJoAdnYTb3VUucBL3o7osRShFP3Z8UTFBW1Uo1jQ2wIuF%2BREQwj3til3CWCU6PEvkIbq4NPRmMxy4sEJGWE8gdjV0Y5pSsXOp1xwq125YqS%2BcGufgtmx7P5%2FlKL99drZEy%2FC7Q%3D%3D&sign_type=RSA2&timestamp=2023-12-12+14%3A36%3A03&version=1.0'));
}
}

@ -1,12 +0,0 @@
<?php
namespace Org\OuterPay;
use Think\Log as ThinkLog;
class Log
{
public static function write($message, $level = ThinkLog::INFO) {
$destination = C('LOG_PATH'). 'outer_pay/' . date('y_m_d').'.log';
ThinkLog::write($message, $level, '', $destination);
}
}
Loading…
Cancel
Save