支付意向功能提交

master
zhengyongxing 5 years ago
parent ea2c6e8482
commit e79871e056

@ -11,6 +11,8 @@ use Sdk\Model\ValueDetailLogModel;
class SpendController extends Controller {
public static $arr_pay_way = ['alipay','wxpay','sqshorcut','shorcut'];
/**
* 转发支付url
*/
@ -532,5 +534,58 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`;
$this->display ();
}
public function addPayChannelIntention() {
$user_token = I('user_token');
$pay_way = I('payway');
if (!$user_token) {
echo "access deny!";
die();
}
$user_info = M('user_token','tab_')->field('user_id,game_id')->where(['user_token'=>$user_token])->find();
if (!$user_info) {
echo json_encode(['code'=>0,'msg'=>'用户信息不存在']);
exit;
}
$pay_info = M('pay_info', 'tab_')->where([
'user_id' => $user_info['user_id'],
'game_id' => $user_info['game_id']
])->order("id desc")->find();
if (!$pay_info['order_id']) {
echo json_encode(['code'=>0,'msg'=>'error']);
exit;
}
if (!in_array($pay_way,self::$arr_pay_way)) {
echo json_encode(['code'=>0,'msg'=>'支付方式参数错误']);
exit;
}
// $user_info = M('user','tab_')->field('account')->where(['id'=>$user_id])->find();
$insert['user_id'] = $user_info['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) {
echo json_encode(['code'=>200,'msg'=>"success"]);
die();
} else {
echo json_encode(['code'=>0,'msg'=>"error"]);
die();
}
}
}

@ -109,7 +109,7 @@
</div>
</div>
</div>
<input style="display: none" id="user_token" value="{$_REQUEST['user_token']}">
<!-- 横屏 -->
<div class="payment_heng">
<!-- <div class="heard">
@ -235,6 +235,8 @@
function defaultInit(){
try {
var pay_price = '{$pay_price}';
var user_token = $('#user_token').val();
if (pay_price == 0) {
payway="platform_pay";
payurl = "{:U('PayH5/platform_coin_deduction',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'), 'api_ver' => 2))}";
@ -242,12 +244,37 @@
} else {
payway="alipay";
payurl="{:U('PayH5/ali_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id'),'user_token'=>I('user_token'),'api_ver'=>2))}";
payChannelIntentionInit(user_token);
}
} catch (error) {
alert("初始化错误");
}
}
function payChannelIntentionInit(user_token) {
$.ajax({
type:'post',
dataType:'json',
data:{user_token:user_token,payway:payway},
url:'/sdk.php/Spend/addPayChannelIntention',
success:function(result) {
if(result.code==0) {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
}
},
error: function(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
}
});
}
var timefun;
@ -275,6 +302,10 @@
payway = $(this).data("type");
payurl = $(this).data("url");
var user_token = $('#user_token').val();
payChannelIntentionInit(user_token);
$(".select_pay_info").children(".slide").attr("src",img);
$(".select_pay_info").children("div").text(text);
$(".payment_rest").hide();

@ -104,7 +104,7 @@
</div>
</div>
</div>
<input style="display: none" id="user_token" value="{$_REQUEST['user_token']}">
<!-- 横屏 -->
<div class="payment_heng">
<!-- <div class="heard">
@ -211,7 +211,36 @@
function defaultInit(){
payway="alipay";
payurl="{:U('PayH5/platform_alipay_pay', array('user_token' => I('user_token'), 'api_ver' => 2, 'game_id' => $game_id, 'price' => $money))}";
var user_token = $('#user_token').val();
payChannelIntentionInit(user_token);
}
function payChannelIntentionInit(user_token) {
$.ajax({
type:'post',
dataType:'json',
data:{user_token:user_token,payway:payway},
url:'/sdk.php/Spend/addPayChannelIntention',
success:function(result) {
if(result.code==0) {
flag=false;
$(".tipmsg").html(result.msg);
$(".msgdialog").show();
}
},
error: function(){
flag=false;
$(".tipmsg").html("接口请求错误");
$(".msgdialog").show();
}
});
}
defaultInit();
$(".select_pay_info").click(function(){
@ -231,6 +260,11 @@
$(".select_pay_info").children(".slide").attr("src",img);
$(".select_pay_info").children("div").text(text);
$(".payment_rest").hide();
var user_token = $('#user_token').val();
payChannelIntentionInit(user_token);
})
//拉起支付
var flag = false;

Loading…
Cancel
Save