快捷支付

master
tpingzhang 5 years ago
parent 2003c388d1
commit 3283f5e3bd

@ -53,8 +53,39 @@ class WapPayController extends BaseController{
->setDiscount($discount)
->setSmallId($param['small_user_id'])
->setSmallAccount(get_user_account_by_id($param['small_user_id']));
return $pay->buildRequestForm($vo);
return $pay->buildRequestForm($vo, 0, $param);
}
/**
* 优先扣除绑币 和平台 处理
* $request $discountAmount 折扣价格
*/
public function other_price(&$request, $discountAmount=0) {
// 优先扣除绑定币平台币
$deductionAmount = 0;
$user_id = $request['user_id'];
$game_id = $request['game_id'];
$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');
// 够抵扣的情况 不走这个接口
$deductionAmount = $bind_balance + $balance;
if ($deductionAmount > $request['price']) {
$this->set_message(1089,"fail",$deductionAmount."平台币足够,请关闭支付页面重新支付".$pay_amount);
}
// 实际支付金额 = 支付总金额 - 折扣抵扣价格 - 绑币和平台币抵扣金额
$request['actual_amount'] = round($request['price'] - $discountAmount - $deductionAmount, 2).'';
$request['discount_amount'] = round($discountAmount, 2).'';
$request['deduction_amount'] = round($deductionAmount, 2).'';
$request['price'] = round($request['actual_amount'], 2).'';
return $request;
//$this->set_message(1089,"fail",$request['price']."新支付".$pay_amount);
}
/**
*支付宝移动支付
*/
@ -83,27 +114,8 @@ class WapPayController extends BaseController{
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
// 优先扣除绑定币平台币
$deductionAmount = 0;
$user_id = $request['user_id'];
$game_id = $request['game_id'];
$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');
// 够抵扣的情况 不走这个接口
$deductionAmount = $bind_balance + $balance;
if ($deductionAmount > $pay_amount) {
$this->set_message(1089,"fail","平台币足够,请关闭支付页面重新支付");
}
// 实际支付金额 = 支付总金额 - 折扣抵扣价格 - 绑币和平台币抵扣金额
$request['actual_amount'] = $request['price'] - $discountAmount - $deductionAmount;
$pay_amount = $request['actual_amount'];
$request['discount_amount'] = $discountAmount;
$request['deduction_amount'] = $deductionAmount;
$request = $this->other_price($request);
Log::write(serialize($request), Log::DEBUG);
if(get_zfb_type()==0){
$game_set_data = get_game_set_info($request['game_id']);
@ -254,9 +266,10 @@ class WapPayController extends BaseController{
if ($payInfo['status'] == 'payed') {
$this->error("订单已支付");
}
// 发起支付
if (IS_POST && $param['smsCode']) {
echo "发起支付==》".time()."<br>";
//echo "发起支付==》".time()."<br>";
$rsp = $sqpay->shortcut_pay(array(
'merNo' => C('sqpay.partner'),
'merOrderNo' => $payInfo['order_id'],
@ -270,7 +283,7 @@ class WapPayController extends BaseController{
'smsCode' => $param['smsCode'],
'secret' => C('sqpay.key'),
));
echo "发起支付==》".time()."<br>";
//echo "发起支付==》".time()."<br>";
sleep(5);
if ($rsp['responseCode'] == '88') {
redirect(U('Spend/pay_success',array('orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])));exit;
@ -283,7 +296,7 @@ class WapPayController extends BaseController{
// 发送短信
if (IS_POST && !isset($param['smsCode'])) {
// 查看是否签约
echo "查看是否签约==》".time()."<br>";
//echo "查看是否签约==》".time()."<br>";
$rcs = $sqpay->contract_status(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@ -293,7 +306,7 @@ class WapPayController extends BaseController{
'payAmount' => $payInfo['price'],
'secret' => C('sqpay.key'),
));
echo "查看是否签约==》".time()."<br>";
//echo "查看是否签约==》".time()."<br>";
if ($rcs['respCode'] == 4) {
$this->error($rcs['respMessage'], '', true);
pp($rcs);
@ -301,7 +314,7 @@ class WapPayController extends BaseController{
}
// 调用认证 签约
if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) {
echo "调用认证 签约==》".time()."<br>";
//echo "调用认证 签约==》".time()."<br>";
$rsign = $sqpay->sign_contract(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@ -313,7 +326,7 @@ class WapPayController extends BaseController{
'custType' => '01',
'secret' => C('sqpay.key'),
));
echo "调用认证 签约==》".time()."<br>";
//echo "调用认证 签约==》".time()."<br>";
if ($rsign['respCode'] == 'success') { // 认证成功 接着签约
$rauth = $sqpay->sign_contract(array(
'merNo' => C('sqpay.partner'),
@ -337,7 +350,7 @@ class WapPayController extends BaseController{
}
// 无需签约 发送短信
if ($rcs['respCode'] == 0 || $rcs['respCode'] == 10) {
echo "发送短信==》".time()."<br>";
//echo "发送短信==》".time()."<br>";
$ret = $sqpay->protocol_pay_send_sms(array(
'merNo' => C('sqpay.partner'),
'custName' => $param['custName'],
@ -350,7 +363,7 @@ class WapPayController extends BaseController{
'NotifyURL' => "http://api.wmtxkj.com"."/callback.php?Notify/sq_callback",
'purpose' => 'aaaa'
));
echo "发送短信==》".time()."<br>";
//echo "发送短信==》".time()."<br>";
if ($ret['resFlag'] == 'success') {
M('pay_info', 'tab_')->where(array(
'id' => $payInfo['id'],
@ -470,12 +483,12 @@ class WapPayController extends BaseController{
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
$request = json_decode(think_decrypt($file),true);
Log::write(serialize($request), Log::DEBUG);
/* $request['user_id'] = 232;
$request['user_id'] = 232;
$request['game_id'] = 78;
$request['price'] = 0.02;
$request['code'] = 1;
$request['extend'] = "SP_52299233958";
$request['pay_order_number'] = "SP_2452299233958"; */
$request['extend'] = "SP_522992339581";
$request['pay_order_number'] = "SP_24522992339581";
if (empty($request)) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit;
@ -511,6 +524,8 @@ class WapPayController extends BaseController{
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'充值金额有误.'.$pay_amount)));exit;
}
$this->other_price($request, $request['price']-$pay_amount);
//0 官方 1双乾
if (get_shortcut_pay_type() == 0) {
// 暂时只有双乾
@ -520,23 +535,23 @@ class WapPayController extends BaseController{
'user_id' => $request['user_id'],
'game_id' => $request['game_id'],
'order_id' => $request['pay_order_number'],
'price' => $request['price'],
'price' => $request['actual_amount'],
'type' => 'sq_shortcut',
'info' => json_encode($request),
'status' => 'normal',
'create_time' => time(),
));
if($request['code']==1){
/* if($request['code']==1){
$this->add_spend($request,1);
}else{
$this->add_deposit($request);
}
} */
}
$this->assign("pay_amount", $pay_amount);
$this->assign("pay_amount", $request['actual_amount']);
$this->assign("user_id", $request['user_id']);
$this->assign("game_id", $request['game_id']);
$this->display();
$this->display("index");
}
/**
@ -583,26 +598,8 @@ class WapPayController extends BaseController{
if(!empty($request['scheme'])) {
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
}
$deductionAmount = 0;
$user_id = $request['user_id'];
$game_id = $request['game_id'];
$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');
// 够抵扣的情况 不走这个接口
$deductionAmount = $bind_balance + $balance;
if ($deductionAmount > $pay_amount) {
$this->set_message(1089,"fail","平台币足够,请关闭支付页面重新支付");
}
// 实际支付金额 = 支付总金额 - 折扣抵扣价格 - 绑币和平台币抵扣金额
$request['actual_amount'] = $request['price'] - $discountAmount - $deductionAmount;
$pay_amount = $request['actual_amount'];
$request['discount_amount'] = $discountAmount;
$request['deduction_amount'] = $deductionAmount;
// 绑币平台币优先处理
$this->other_price($request, $discountAmount);
$game_set_data = get_game_set_info($request['game_id']);
//$request['game_name']
@ -835,6 +832,8 @@ class WapPayController extends BaseController{
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
$discount = $discount['discount'];
$pay_amount = $discount * $request['price'] / 10;
// 绑币平台币处理
$this->other_price($request, $request['price']-$pay_amount);
if($request['code']==1){
$this->add_spend($request);
@ -897,6 +896,7 @@ class WapPayController extends BaseController{
if ($pay_amount < 0.01) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'充值金额有误.'.$pay_amount)));exit;
}
$this->other_price($request, $request['price']-$pay_amount);
//0 官方 1双乾
if (get_union_pay_type() == 0) {

@ -0,0 +1,207 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
.sbtn1{
font-size: 20px;
color: #ffffff;
padding: 0;
border:none;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>在线订单</title>
<script type="text/javascript" src="__JS__/jquery.js"></script>
<Script type="text/javascript">
function GetUrlName(name)
{
var strs = [];
var url = decodeURI(window.location.search); //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape((strs[i].split("=")[1]));
}
}
return(theRequest[name]);
}
var validCode=true;
function getSms() {
if ($("#custName").val() == '' || $("#idNo").val() == '' || $("#phoneNo").val() == '') {
alert('参数不能为空');
return ;
}
if (validCode == false) return ;
validCode = false;
//获取短信验证码
$.ajax({
type: "POST",
url: "/sdk.php/WapPay/shortcut_pay",
dataType:'json',
data: {
'user_id' : $("#user_id").val(),
'game_id' : $("#game_id").val(),
'custName' : $("#custName").val(),
'cardNo' : $("#cardNo").val(),
'idNo' : $("#idNo").val(),
'phoneNo' : $("#phoneNo").val()
},
success:function(res){
// 返回列表数组,构造数据流模块
if (res.status == 1) {
var time=60;
if (1) {
validCode=false;
var sms=document.getElementById("btn1");
var t=setInterval(function () {
time--;
sms.innerText=time+"秒"
if (time==0) {
clearInterval(t);
sms.innerText="获取短信验证码";
juege.inherit="";
validCode=true;
}
},1000);
}
}
else {
alert(res.info);
}
}
});
}
var btnpay = false;
function sendform() {
if (btnpay == true) return false;
btnpay = true;
var isok = false;
if ($("#custName").val() != '' && $("#idNo").val() != '' && $("#phoneNo").val() != '' && $("#smsCode").val() != '') {
isok = true;
$("#wfsubmit").val("支付中...");
} else {
alert("参数有误");
isok = false;
}
return isok;
}
</Script>
<script type="text/javascript">
</script>
<script type="text/javascript" src="__JS__/demo.js"></script>
<style type="text/css">
</style>
<br>
<br>
<br>
</head>
<body >
<img src="__IMG__/bag_yellow.png" align="center" style="position:absolute; align:center;width:100%;height:610px;top: -200px;" />
<div class="wfwarp" style=" margin:0 auto;width:708px;height:900px;top: 10px;" >
<div style="position:absolute; align:center ;top:0px;" >
<br><br><br>
<span style=" text-align: left; " ><font size="6" color="#4a4a4a" face="verdana">待支付......</font></span>
<br>
<br>
<br>
<span style="float:left;"><font size="5" color="#4a4a4a" face="verdana">订单超过30分钟自动取消请在30分钟内完成支付</font></span>
<br>
<br>
<br>
<br>
<div align="center" class="wforderl" style=" width:708px;height:1000px;top: 10px;">
<div class="wfforml" id="wfforml" style=" width:708px;height:1000px;top: 10px;">
<div style=" position: relative; width:708px;height:819px;top: 10px;">
<img src="__IMG__/form_bag1.png" style="width:100%; height:100%" />
<form id="wfform" name="wfform" method="post" action="{:U('WapPay/shortcut_pay')}" target="_parent">
<input type="hidden" name="user_id" id="user_id" value="{$user_id}" />
<input type="hidden" name="game_id" id="game_id" value="{$game_id}" />
<div class="wfbdbox" style=" position: absolute; top:80px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:-25px;"><font size="5" >姓名:</font></label>
<div class="wftextbox" style=" position: absolute;right:5px;">
<input type="text" name="custName" id="custName" style="border:0px; outline: none; background-repeat:no-repeat;background-image:url('__IMG__/input.png') ;width:460px;height:50px;"/><em>*</em>
</div>
</div>
<div class="wfbdbox" style=" position: absolute; top: 180px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:20px;"><font size="5" >银行卡号:</font></label>
<div class="wftextbox" style=" position: absolute;right:5px;">
<input type="text" name="cardNo" id="cardNo" style="border:0px; outline: none; background-repeat:no-repeat;background-image:url('__IMG__/input.png') ;width:460px;height:50px"/><em>*</em>
</div>
</div>
<div class="wfbdbox" style=" position: absolute; top: 280px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:20px;"><font size="5" >身份证号:</font></label>
<div class="wftextbox" style=" position: absolute;right:5px;">
<input type="text" name="idNo" id="idNo" style="border:0px; outline: none; background-repeat:no-repeat;background-image:url('__IMG__/input.png') ;width:460px;height:50px" /><em>*</em>
</div>
</div>
<div class="wfbdbox" style=" position: absolute; top: 380px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:0px;"><font size="5" >手机号:</font></label>
<div class="wftextbox" style=" position: absolute;right:5px;">
<input type="text" name="phoneNo" id="phoneNo" style="border:0px; outline: none; background-repeat:no-repeat;background-image:url('__IMG__/input.png') ;width:460px;height:50px;" /><em>*</em>
</div>
</div>
<div class="wfbdbox" style=" position: absolute; top: 480px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:0px;" ><font size="5" >验证码:</font></label>
<input type="text" name="smsCode" id="smsCode" class="c_code_msg" style="border:0px; outline: none; background-repeat:no-repeat;background-image:url('__IMG__/input2.png') ;width:48%;height:50px;">
<button type="button"class='sbtn1' id="btn1" onClick="getSms()" style="color:#ffffff;outline: none;background:url(__IMG__/anniu.png);position: absolute;right:20px; border-style:none; width:190px;height:50px; background-repeat:no-repeat;background-size: 100% 100%;" >获取短信验证码</button>
</div>
<div class="wfbdbox" style=" position: absolute; top: 580px; right:5px;">
<label class="wfbdxx" style=" position: absolute;top: 10px;left:20px;"><font size="5" >支付金额:</font></label>
<div class="wftextbox">
<span class="rt" style=" position: absolute; top: 0px; right:30px;"><font id="money" size="8" color="#d42008" face="verdana">{$pay_amount}元</font></span>
</div>
</div>
<div class="wfsubbox" style=" position: absolute; top: 880px; right:20px;">
<input onclick="return sendform()" style=" font-size:30px;border:0px; outline: none; background-repeat:no-repeat;color:#000000;background-image:url('__IMG__/submit.png');width:750px;height:100px;" type="submit" name="wfsubmit" id="wfsubmit" value="立即提交订单" />
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Loading…
Cancel
Save