|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Sdk\Controller;
|
|
|
|
|
|
|
|
use Base\Tool\Log as ToolLog;
|
|
|
|
use Think\Controller;
|
|
|
|
use Org\JtpaySDK\Jtpay;
|
|
|
|
use Org\SqpaySDK\Sqpay;
|
|
|
|
use Think\Log;
|
|
|
|
use Qiniu\json_decode;
|
|
|
|
use Sdk\Model\ValueDetailLogModel;
|
|
|
|
use Sdk\Model\PayChannelIntentionModel;
|
|
|
|
|
|
|
|
class SpendController extends Controller {
|
|
|
|
|
|
|
|
public static $arr_pay_way = ['alipay','wxpay','sqpay','yeepay'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 转发支付url
|
|
|
|
*/
|
|
|
|
public function get_pay_url($user_id, $game_id) {
|
|
|
|
$file = file_get_contents ( "./Application/Sdk/OrderNo/" . $user_id . "-" . $game_id . ".txt" );
|
|
|
|
$info = json_decode ( think_decrypt ( $file ), true );
|
|
|
|
redirect ( $info ['pay_url'] );
|
|
|
|
}
|
|
|
|
public function jft_pay($user_id, $game_id, $type) {
|
|
|
|
$file = file_get_contents ( "./Application/Sdk/OrderNo/" . $user_id . "-" . $game_id . ".txt" );
|
|
|
|
$request = json_decode ( think_decrypt ( $file ), true );
|
|
|
|
|
|
|
|
$jtpay = new Jtpay ();
|
|
|
|
if ($request ['sdk_version'] == 1) { // 1 安卓 2苹果
|
|
|
|
$p25_terminal = 3;
|
|
|
|
$p26_iswappay = 3;
|
|
|
|
} else {
|
|
|
|
$p25_terminal = 2;
|
|
|
|
$p26_iswappay = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($type == "3") { // 3支付宝 4微信
|
|
|
|
$url = $jtpay->jt_pay ( $request ['pay_order_number'], $request ['price'], $request ['user_id'], get_client_ip (), "sdk", 4, 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success", $p26_iswappay, $p25_terminal ); // 安卓
|
|
|
|
} else {
|
|
|
|
$url = $jtpay->jt_pay ( $request ['pay_order_number'], $request ['price'], $request ['user_id'], get_client_ip (), "sdk", 3, 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success", 3, 2 ); // 安卓
|
|
|
|
}
|
|
|
|
redirect ( $url );
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 支付页面
|
|
|
|
*
|
|
|
|
* @return [type] [description]
|
|
|
|
*/
|
|
|
|
public function pay_way() {
|
|
|
|
$user_id = I ('user_id');
|
|
|
|
$game_id = I ('game_id');
|
|
|
|
|
|
|
|
$user_token = I('user_token');
|
|
|
|
if (!$user_token) {
|
|
|
|
echo "access deny!";
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolLog::write('user_token: ' . $user_token, Log::INFO, 'payment');
|
|
|
|
ToolLog::write('user_id: ' . $user_id, Log::INFO, 'payment');
|
|
|
|
ToolLog::write('game_id: ' . $game_id, Log::INFO, 'payment');
|
|
|
|
|
|
|
|
$userId = M('user_token', 'tab_')->where([
|
|
|
|
'user_token'=>$user_token,
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
])->getField('id');
|
|
|
|
ToolLog::write('sql: ' . M('user_token','tab_')->getLastSql(), 'payment');
|
|
|
|
ToolLog::write('userId: ' . $userId, Log::INFO, 'payment');
|
|
|
|
if (!$userId) {
|
|
|
|
echo $user_token."请重新登入!".$user_id.$game_id;
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
C(BaseController::get_tool());
|
|
|
|
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where([
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
])->order("id desc")->find();
|
|
|
|
$request = json_decode($pay_info['info'], true);
|
|
|
|
$data = array(
|
|
|
|
'coin' => $request ['body'],
|
|
|
|
'price' => $request ['price'] + $request['deduction_amount'] + $request['discount_amount'],
|
|
|
|
'game_name' => $request ['game_name'],
|
|
|
|
'code' => $request ['code']
|
|
|
|
);
|
|
|
|
$balance = M ( 'user', 'tab_' )->where ( array (
|
|
|
|
'id' => $user_id
|
|
|
|
) )->getField ( 'balance' );
|
|
|
|
$bind_balance = M ( 'user_play', 'tab_' )->where ( array (
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
) )->getField ( 'bind_balance' );
|
|
|
|
$this->assign ( 'balance', $balance );
|
|
|
|
$this->assign ( 'bind_balance', $bind_balance );
|
|
|
|
$this->assign ( 'data', $data );
|
|
|
|
$this->assign ( 'game_id', $game_id );
|
|
|
|
$this->assign ( 'btncolor', isset($request['btncolor']) ? $request['btncolor'] : '' );
|
|
|
|
|
|
|
|
// 折扣
|
|
|
|
$discount = get_discount($game_id, $user_id);
|
|
|
|
$discount_amount = 0;
|
|
|
|
if ($discount['discount'] < 10) {
|
|
|
|
$discount_amount = round($data['price'] - $data['price'] * $discount['discount'] / 10, 2);
|
|
|
|
}
|
|
|
|
$this->assign('discount', $discount['discount']);
|
|
|
|
$this->assign('discount_amount', $discount_amount);
|
|
|
|
|
|
|
|
if ($balance + $bind_balance > $data['price'] - $discount_amount) {
|
|
|
|
$apply_money = $data['price'] - $discount_amount;
|
|
|
|
$this->assign ('pay_price', 0); // 是否第三方支付
|
|
|
|
} else {
|
|
|
|
$apply_money = $balance + $bind_balance;
|
|
|
|
$payPrice = round($data['price'] - $discount_amount - $balance - $bind_balance, 2);
|
|
|
|
$this->assign ('pay_price', $payPrice ? $payPrice : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = $request;
|
|
|
|
unset($data['pay_order_number']);
|
|
|
|
unset($data['pay_status']);
|
|
|
|
unset($data['spend_ip']);
|
|
|
|
unset($data['pay_way']);
|
|
|
|
$this->assign('apply_money',$apply_money); //适用平台金额
|
|
|
|
$this->assign('sdk_version', $request['sdk_version']);
|
|
|
|
$this->assign('small_json', json_encode(array(
|
|
|
|
'appId' => 'wx8419130aa4ff123b',
|
|
|
|
'userName' => 'gh_e3bff77d318e',
|
|
|
|
'path' => 'pages/pay/pay?kx='.base64_encode(json_encode($data)),
|
|
|
|
'miniprogramType' => 2, // 0正式版 1开发版 2体验版
|
|
|
|
)));
|
|
|
|
|
|
|
|
$this->assign('user_token', $user_token);
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pay_way_v1() {
|
|
|
|
$user_id = I ('user_id');
|
|
|
|
$game_id = I ('game_id');
|
|
|
|
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where([
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
])->order("id desc")->find();
|
|
|
|
$request = json_decode($pay_info['info'], true);
|
|
|
|
|
|
|
|
/* $file = file_get_contents ( "./Application/Sdk/OrderNo/" . $user_id . "-" . $game_id . ".txt" );
|
|
|
|
$request = json_decode ( think_decrypt ( $file ), true ); */
|
|
|
|
|
|
|
|
C(BaseController::get_tool());
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'coin' => $request ['body'],
|
|
|
|
'price' => $request ['price'],
|
|
|
|
'game_name' => $request ['game_name'],
|
|
|
|
'code' => $request ['code']
|
|
|
|
);
|
|
|
|
$balance = M ( 'user', 'tab_' )->where ( array (
|
|
|
|
'id' => $user_id
|
|
|
|
) )->getField ( 'balance' );
|
|
|
|
$bind_balance = M ( 'user_play', 'tab_' )->where ( array (
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
) )->getField ( 'bind_balance' );
|
|
|
|
// $data['price'] = 1;
|
|
|
|
|
|
|
|
$this->assign ( 'balance', $balance );
|
|
|
|
$this->assign ( 'bind_balance', $bind_balance );
|
|
|
|
$this->assign ( 'data', $data );
|
|
|
|
$this->assign ( 'btncolor', $request ['btncolor'] );
|
|
|
|
if ($balance + $bind_balance > $data['price']) {
|
|
|
|
$this->assign ('pay_price', 0); // 是否第三方支付
|
|
|
|
} else {
|
|
|
|
$payPrice = $data['price'] - $balance - $bind_balance;
|
|
|
|
$this->assign ('pay_price', $payPrice ? $payPrice : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* $this->assign ( 'alipayurl', $ret[0]['payURL']);
|
|
|
|
header("Access-Control-Allow-Origin: *"); */
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 支付页面
|
|
|
|
*
|
|
|
|
* @return [type] [description]
|
|
|
|
*/
|
|
|
|
/* public function pay_way_v2() {
|
|
|
|
$user_id = I ('user_id');
|
|
|
|
$game_id = I ('game_id');
|
|
|
|
|
|
|
|
$file = file_get_contents ( "./Application/Sdk/OrderNo/" . $user_id . "-" . $game_id . ".txt" );
|
|
|
|
$request = json_decode ( think_decrypt ( $file ), true );
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
'coin' => $request ['body'],
|
|
|
|
'price' => $request ['price'],
|
|
|
|
'game_name' => $request ['game_name'],
|
|
|
|
'code' => $request ['code']
|
|
|
|
);
|
|
|
|
$balance = M ( 'user', 'tab_' )->where ( array (
|
|
|
|
'id' => $user_id
|
|
|
|
) )->getField ( 'balance' );
|
|
|
|
$bind_balance = M ( 'user_play', 'tab_' )->where ( array (
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
) )->getField ( 'bind_balance' );
|
|
|
|
// $data['price'] = 1;
|
|
|
|
|
|
|
|
$this->assign ( 'balance', $balance );
|
|
|
|
$this->assign ( 'bind_balance', $bind_balance );
|
|
|
|
$this->assign ( 'data', $data );
|
|
|
|
$this->assign ( 'btncolor', $request ['btncolor'] );
|
|
|
|
if ($balance + $bind_balance > $data['price']) {
|
|
|
|
$this->assign ('pay_price', 0); // 是否第三方支付
|
|
|
|
} else {
|
|
|
|
$payPrice = $data['price'] - $balance - $bind_balance;
|
|
|
|
$this->assign ('pay_price', $payPrice ? $payPrice : 0);
|
|
|
|
}
|
|
|
|
$this->assign ('pay_price', $data['price']);
|
|
|
|
|
|
|
|
// $this->assign ( 'alipayurl', $ret[0]['payURL']);
|
|
|
|
// header("Access-Control-Allow-Origin: *");
|
|
|
|
|
|
|
|
$this->assign ('sdk_version', $request['sdk_version']);
|
|
|
|
$this->display();
|
|
|
|
} */
|
|
|
|
|
|
|
|
public function pay_success() {
|
|
|
|
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
|
|
|
|
$pay_where = substr($orderno, 0, 2);
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where(['order_id' => $orderno])->find();
|
|
|
|
$json = json_decode($pay_info['info'], true);
|
|
|
|
$Scheme = $json['scheme'];
|
|
|
|
// $Scheme = file_get_contents ( "./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt" );
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
switch ($pay_where) {
|
|
|
|
case 'SP' :
|
|
|
|
$result = M ( 'Spend', 'tab_' )->field ( "pay_status" )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'PF' :
|
|
|
|
$result = M ( 'deposit', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'TB' :
|
|
|
|
$result = M ( 'balance', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'BR' :
|
|
|
|
$result = M ( 'bind_recharge', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$this->assign ( 'Scheme', $Scheme );
|
|
|
|
$this->assign ( 'paystatus', $result ['pay_status'] );
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pay_success2() {
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
|
|
|
|
$pay_where = substr($orderno, 0, 2);
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where(['order_id' => $orderno])->find();
|
|
|
|
$json = json_decode($pay_info['info'], true);
|
|
|
|
$Scheme = $json['scheme'];
|
|
|
|
|
|
|
|
//$orderno = $_GET ['orderno'] == "" ? $_GET ['out_trade_no'] : $_GET ['orderno'];
|
|
|
|
$pay_where = substr ( $orderno, 0, 2 );
|
|
|
|
//$Scheme = file_get_contents ( "./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt" );
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
switch ($pay_where) {
|
|
|
|
case 'SP' :
|
|
|
|
$result = M ( 'Spend', 'tab_' )->field ( "pay_status" )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'PF' :
|
|
|
|
$result = M ( 'deposit', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'TB' :
|
|
|
|
$result = M ( 'balance', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'BR' :
|
|
|
|
$result = M ( 'bind_recharge', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$this->assign ( 'paystatus', $result ['pay_status'] );
|
|
|
|
$this->assign ( 'Scheme', $Scheme );
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
public function pay_success3() {
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
|
|
|
|
// $orderno = $_GET ['orderno'] == "" ? $_GET ['out_trade_no'] : $_GET ['orderno'];
|
|
|
|
// if (! empty ( $_GET ['jinzhue'] )) {
|
|
|
|
// $orderno = $_GET ['jinzhue'];
|
|
|
|
// }
|
|
|
|
$pay_where = substr ( $orderno, 0, 2 );
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
$result = M ( 'Spend', 'tab_' )->field ("*")->where ( $map )->find ();
|
|
|
|
|
|
|
|
$this->assign("game_id", $result['game_id']);
|
|
|
|
$this->assign("paytype", 'platform');
|
|
|
|
$this->assign("pay_amount", $result['cost']+$result['deduction_amount']);
|
|
|
|
$this->assign("goods", $result['props_name']);
|
|
|
|
$this->assign("order_id", $result['pay_order_number']);
|
|
|
|
|
|
|
|
$this->assign ( 'paystatus', $result ['pay_status'] );
|
|
|
|
$this->display ( 'pay_success3' );
|
|
|
|
}
|
|
|
|
public function pay_error() {
|
|
|
|
$Scheme = file_get_contents ( "./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt" );
|
|
|
|
|
|
|
|
$this->assign ('Scheme', $Scheme?$Scheme:'txplatformsdk');
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
public function notice($user_id = 0, $game_id = 0, $is_platform=0, $msg = '') {
|
|
|
|
if ($is_platform) {
|
|
|
|
$this->assign("gourl", U('UserH/get_user_money',array('user_id'=>I('user_id'),'game_id'=>I('game_id'), 'user_token' => I('user_token'))));
|
|
|
|
} else {
|
|
|
|
$this->assign("gourl", U('Spend/pay_way',array('user_id'=>I('user_id'),'game_id'=>I('game_id'), 'user_token' => I('user_token'))));
|
|
|
|
}
|
|
|
|
$msg = urldecode($msg);
|
|
|
|
$this->assign("msg", $msg);
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function notice_v1($user_id = 0, $game_id = 0, $msg = '') {
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ALTER TABLE `tab_deposit`
|
|
|
|
ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`;
|
|
|
|
* 支付中转页
|
|
|
|
*/
|
|
|
|
public function paycallback() {
|
|
|
|
$userToken = I('user_token');
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
// $orderno = $_GET['orderno'] == "" ? $_GET ['out_trade_no'] : $_GET ['orderno'];
|
|
|
|
$pay_where = substr($orderno, 0, 2);
|
|
|
|
// $Scheme = file_get_contents("./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt");
|
|
|
|
$gameId = $_GET ['game_id'];
|
|
|
|
$Scheme = "txgame".$gameId;
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
$paytype = I('request.paytype', 0); // 支付方式 weixinpay alipay
|
|
|
|
$gopay = I('request.gopay');
|
|
|
|
|
|
|
|
switch ($pay_where) {
|
|
|
|
case 'SP' :
|
|
|
|
$result = M('Spend', 'tab_')->field ("*")->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'PF' :
|
|
|
|
$result = M('deposit', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'TB' :
|
|
|
|
$result = M('balance', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'BR' :
|
|
|
|
$result = M('bind_recharge', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// 支付成功跳转页面
|
|
|
|
if ($result['pay_status'] == 1) {
|
|
|
|
// $this->success("支付成功", U("userH/get_user_money", ['user_token' => $userToken]));
|
|
|
|
}
|
|
|
|
|
|
|
|
// 微信 支付宝 快捷
|
|
|
|
if ($pay_where == "SP") {
|
|
|
|
/* if ($result['pay_way'] == C('PAY_WAY.WEIXIN') || $result['pay_way'] == C('PAY_WAY.WEIXIN_APP') || $result['pay_way'] == C('PAY_WAY.SQ_SMALL_PROGRAM'))
|
|
|
|
$gopayUrl = "/sdk.php/Apple/apple_weixin_pay/user_id/{$result['user_id']}/game_id/{$result['game_id']}/user_token/{$userToken}";
|
|
|
|
if ($result['pay_way'] == C('PAY_WAY.ALIPAY') || $result['pay_way'] == C('PAY_WAY.SQ_ALIPAY'))
|
|
|
|
$gopayUrl = "/sdk.php/Apple/apple_alipay_pay/user_id/{$result['user_id']}/game_id/{$result['game_id']}/user_token/{$userToken}";
|
|
|
|
*/
|
|
|
|
$gopayUrl = $result['pay_url'];
|
|
|
|
}
|
|
|
|
if ($pay_where == "PF") {
|
|
|
|
$gopayUrl = $result['pay_url'];
|
|
|
|
// if ($result['pay_way'] == C('PAY_WAY.WEIXIN') || $result['pay_way'] == C('PAY_WAY.WEIXIN_APP') || $result['pay_way'] == C('PAY_WAY.SQ_SMALL_PROGRAM'))
|
|
|
|
// $gopayUrl = "/sdk.php/PayH5/platform_weixin_pay/pay_order_number/{$result['pay_order_number']}/price/{$result['pay_amount']}/user_token/{$userToken}";
|
|
|
|
// if ($result['pay_way'] == C('PAY_WAY.ALIPAY') || $result['pay_way'] == C('PAY_WAY.SQ_ALIPAY'))
|
|
|
|
// $gopayUrl = "/sdk.php/PayH5/platform_alipay_pay/pay_order_number/{$result['pay_order_number']}/game_id/{$result['game_id']}/user_token/{$userToken}";
|
|
|
|
}
|
|
|
|
// 如果是json格式 且是alipay 则 alipay app
|
|
|
|
if (json_decode($gopayUrl) && $paytype == 'alipay') {
|
|
|
|
$this->assign("aliapp", 1);
|
|
|
|
} else {
|
|
|
|
$this->assign("aliapp", 0);
|
|
|
|
}
|
|
|
|
if(get_zfb_type() == 2) {
|
|
|
|
$this->assign("sqzfb", 1);
|
|
|
|
} else {
|
|
|
|
$this->assign("sqzfb", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// pp($orderno);
|
|
|
|
// $this->assign('payway', $payway);
|
|
|
|
$this->assign("orderno", $orderno);
|
|
|
|
$this->assign("paytype", $paytype);
|
|
|
|
$this->assign("pay_amount", $result['cost']+$result['deduction_amount']);
|
|
|
|
$this->assign("order_id", $result['pay_order_number']);
|
|
|
|
$this->assign("goods", $result['props_name']);
|
|
|
|
$this->assign ('pay_url', $result['pay_url']);
|
|
|
|
$this->assign("sdk_version", $result['sdk_version']?:0);
|
|
|
|
$this->assign ('Scheme', $Scheme);
|
|
|
|
$this->assign ('gopay', $gopay);
|
|
|
|
$this->assign ('user_token', $userToken);
|
|
|
|
$this->assign ('game_id', $gameId);
|
|
|
|
|
|
|
|
$this->assign ('gopay_url', $gopayUrl);
|
|
|
|
$this->assign ('paystatus', $result ['pay_status']);
|
|
|
|
$this->display ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 订单状态 return 0未支付 1已支付
|
|
|
|
*/
|
|
|
|
public function order_status() {
|
|
|
|
$userToken = I('user_token');
|
|
|
|
$orderno = I('orderno');
|
|
|
|
$gameId = I('game_id');
|
|
|
|
$pay_where = substr ($orderno, 0, 2);
|
|
|
|
$payStatus = 0;
|
|
|
|
$table = "spend";
|
|
|
|
if ($pay_where == "SP") {
|
|
|
|
$table = "spend";
|
|
|
|
}
|
|
|
|
if ($pay_where == "PF") {
|
|
|
|
$table = "deposit";
|
|
|
|
}
|
|
|
|
|
|
|
|
$order = M($table, "tab_")->where(['pay_order_number' => $orderno])->find();
|
|
|
|
$payStatus = $order["pay_status"];
|
|
|
|
|
|
|
|
echo json_encode([
|
|
|
|
'type' => $table,
|
|
|
|
'payStatus' => $payStatus?'1':'0',
|
|
|
|
'game_id' => $gameId,
|
|
|
|
'url' => "/sdk.php/userH/get_user_money/user_token/{$userToken}/game_id/{$gameId}/sdk_version/{$order['sdk_version']}api_ver/2", //?action=pay&nav_title=%E4%BD%99%E9%A2%9D
|
|
|
|
]);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 快捷支付通知
|
|
|
|
public function shortcut_notice() {
|
|
|
|
$status = $_GET['status'];
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
|
|
|
|
$pay_where = substr($orderno, 0, 2);
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where(['order_id' => $orderno])->find();
|
|
|
|
$json = json_decode($pay_info['info'], true);
|
|
|
|
$Scheme = $json['scheme'];
|
|
|
|
|
|
|
|
// $Scheme = file_get_contents ( "./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt" );
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
switch ($pay_where) {
|
|
|
|
case 'SP' :
|
|
|
|
$result = M ( 'Spend', 'tab_' )->field ( "pay_status" )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'PF' :
|
|
|
|
$result = M ( 'deposit', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'TB' :
|
|
|
|
$result = M ( 'balance', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
case 'BR' :
|
|
|
|
$result = M ( 'bind_recharge', 'tab_' )->field ( 'pay_status' )->where ( $map )->find ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$this->assign('Scheme', $Scheme);
|
|
|
|
$this->assign('status', $status);
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 通知下线
|
|
|
|
public function notice_logout() {
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 易宝快捷支付 通知页面
|
|
|
|
public function shortcut_payed() {
|
|
|
|
|
|
|
|
$userToken = I('user_token');
|
|
|
|
$orderno = I('request.orderno');
|
|
|
|
if (!$orderno) $orderno = I('request.out_trade_no');
|
|
|
|
// $orderno = $_GET['orderno'] == "" ? $_GET ['out_trade_no'] : $_GET ['orderno'];
|
|
|
|
$pay_where = substr($orderno, 0, 2);
|
|
|
|
// $Scheme = file_get_contents("./Application/Sdk/Scheme/" . $_GET ['game_id'] . ".txt");
|
|
|
|
$gameId = $_GET ['game_id'];
|
|
|
|
$Scheme = "txgame".$gameId;
|
|
|
|
$map ['pay_order_number'] = $orderno;
|
|
|
|
$paytype = I('request.paytype', 0); // 支付方式 weixinpay alipay
|
|
|
|
$gopay = I('request.gopay');
|
|
|
|
|
|
|
|
switch ($pay_where) {
|
|
|
|
case 'SP' :
|
|
|
|
$result = M('Spend', 'tab_')->field ("*")->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'PF' :
|
|
|
|
$result = M('deposit', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'TB' :
|
|
|
|
$result = M('balance', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
case 'BR' :
|
|
|
|
$result = M('bind_recharge', 'tab_')->field ('*')->where ($map)->find();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// 支付成功跳转页面
|
|
|
|
if ($result['pay_status'] == 1) {
|
|
|
|
// $this->success("支付成功", U("userH/get_user_money", ['user_token' => $userToken]));
|
|
|
|
}
|
|
|
|
|
|
|
|
// 微信 支付宝 快捷
|
|
|
|
if ($pay_where == "SP") {
|
|
|
|
$gopayUrl = $result['pay_url'];
|
|
|
|
}
|
|
|
|
if ($pay_where == "PF") {
|
|
|
|
$gopayUrl = $result['pay_url'];
|
|
|
|
}
|
|
|
|
// 如果是json格式 且是alipay 则 alipay app
|
|
|
|
if (json_decode($gopayUrl) && $paytype == 'alipay') {
|
|
|
|
$this->assign("aliapp", 1);
|
|
|
|
} else {
|
|
|
|
$this->assign("aliapp", 0);
|
|
|
|
}
|
|
|
|
if(get_zfb_type() == 2) {
|
|
|
|
$this->assign("sqzfb", 1);
|
|
|
|
} else {
|
|
|
|
$this->assign("sqzfb", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// pp($orderno);
|
|
|
|
// $this->assign('payway', $payway);
|
|
|
|
$this->assign("orderno", $orderno);
|
|
|
|
$this->assign("paytype", $paytype);
|
|
|
|
$this->assign("price", $result['pay_amount']);
|
|
|
|
$this->assign ('pay_url', $result['pay_url']);
|
|
|
|
$this->assign("sdk_version", $result['sdk_version']?:0);
|
|
|
|
$this->assign ('Scheme', $Scheme);
|
|
|
|
$this->assign ('gopay', $gopay);
|
|
|
|
$this->assign ('user_token', $userToken);
|
|
|
|
$this->assign ('game_id', $gameId);
|
|
|
|
|
|
|
|
$this->assign ('gopay_url', $gopayUrl);
|
|
|
|
$this->assign ('paystatus', $result ['pay_status']);
|
|
|
|
$this->display ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addPayChannelIntention() {
|
|
|
|
$user_token = I('request.user_token');
|
|
|
|
$pay_way = I('request.payway');
|
|
|
|
$game_id = I('request.game_id');
|
|
|
|
|
|
|
|
if (!$user_token) {
|
|
|
|
echo "access deny!";
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
$user_id = M("user_token", "tab_")->where(array(
|
|
|
|
'user_token' => $user_token,
|
|
|
|
'game_id' => $game_id
|
|
|
|
))->getField("user_id");
|
|
|
|
// var_dump($game_id);die();
|
|
|
|
if (!$game_id) {
|
|
|
|
echo json_encode(['code'=>0,'msg'=>'参数错误']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$user_id) {
|
|
|
|
echo json_encode(['code'=>0,'msg'=>'参数错误']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pay_info = M('pay_info', 'tab_')->where([
|
|
|
|
'user_id' => $user_id,
|
|
|
|
'game_id' => $game_id
|
|
|
|
])->order("id desc")->find();
|
|
|
|
// var_dump($pay_info);die();
|
|
|
|
|
|
|
|
if (!$pay_info['order_id']) {
|
|
|
|
echo json_encode(['code'=>0,'msg'=>'error']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($pay_way == 'sqshorcut') {
|
|
|
|
$pay_way = 'sqpay';
|
|
|
|
} else if($pay_way == 'shorcut') {
|
|
|
|
$pay_way = 'yeepay';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array($pay_way,self::$arr_pay_way)) {
|
|
|
|
echo json_encode(['code'=>0,'msg'=>'支付方式参数错误']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$payChannelIntention = new PayChannelIntentionModel();
|
|
|
|
$intentionLog = $payChannelIntention->where(array(
|
|
|
|
'pay_order_number' => $pay_info['order_id']
|
|
|
|
))->order('id desc')->find();
|
|
|
|
if ($intentionLog['pay_way'] == $pay_way) {
|
|
|
|
// 前后两次类型一样不做记录
|
|
|
|
echo json_encode(['code'=>200,'msg'=>'']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$pay_intention_num = M('pay_intention_num','tab_')->field('num')->where(['pay_order_number' => $pay_info['order_id']])->find();
|
|
|
|
if ($pay_intention_num&&$pay_intention_num['num']>9) {
|
|
|
|
// 超过十条不做记录
|
|
|
|
echo json_encode(['code'=>200,'msg'=>'']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$insert['user_id'] = $user_id;
|
|
|
|
$insert['user_account'] = $pay_info['user_account'];
|
|
|
|
$insert['pay_way'] = $pay_way;
|
|
|
|
$insert['pay_amount'] = $pay_info['price'];
|
|
|
|
$insert['pay_order_number'] = $pay_info['order_id'];
|
|
|
|
$insert['create_time'] = time();
|
|
|
|
$is_success = M('pay_channel_intention','tab_')->add($insert);
|
|
|
|
|
|
|
|
if ($is_success) {
|
|
|
|
if (!$pay_intention_num) {
|
|
|
|
M('pay_intention_num','tab_')->add(['num'=>1,'pay_order_number'=>$pay_info['order_id']]);
|
|
|
|
} else {
|
|
|
|
M('pay_intention_num','tab_')->where(['pay_order_number' => $pay_info['order_id']])->setInc('num');
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode(['code'=>200,'msg'=>"success"]);
|
|
|
|
die();
|
|
|
|
} else {
|
|
|
|
echo json_encode(['code'=>0,'msg'=>"error"]);
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|