小程序支付

优先抵扣平台币
微信支付限额
支付回调客户端
master
tpingzhang 5 years ago
parent 1a2ffac6be
commit 60fb35a8b3

@ -28,7 +28,7 @@ class BaseController extends RestController{
// #判断数据是否为空
if(empty($data) || empty($data['game_id'])){
echo base64_encode(json_encode(array("status"=>0,"return_msg"=>"操作数据或游戏ID不能为空")));exit();
echo base64_encode(json_encode(array("status"=>10,"return_msg"=>"操作数据或游戏ID不能为空")));exit();
}
$md5Sign = $data['md5_sign'];
unset($data['md5_sign']);
@ -41,7 +41,9 @@ class BaseController extends RestController{
if(empty($game_data)){
$this->set_message(0,"fail","游戏不存在或未通过审核");
}
if (isset($data['openid'])) // 小程序支付增加参数
unset($data['openid']);
$md5_sign = $this->encrypt_md5($data,$game_data["access_key"]);//mengchuang DZQkkiz!@#9527
if($md5Sign !== $md5_sign){
$this->set_message(0,"fail","验签失败");
@ -694,7 +696,7 @@ class BaseController extends RestController{
* $request $discountAmount 折扣价格
*/
public function other_price(&$request, $discountAmount=0) {
return $request;
// return $request;
// 优先扣除绑定币平台币
if ($request['code'] == '0') return $request; // 平台币充值 不做判断
$deductionAmount = 0;

@ -73,7 +73,7 @@ class PayController extends BaseController
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
file_put_contents(dirname(__FILE__) . '/alipay_payapp.txt',json_encode($request));
file_put_contents(dirname(__FILE__) . '/alipay_payapp.txt',json_encode($request));
C(api('Config/lists'));
if ($request['price']*1 < 0) {
@ -386,7 +386,11 @@ class PayController extends BaseController
$user_play_map['user_id'] = $request['user_id'];
$user_play_map['game_id'] = $request['game_id'];
$user_play_data = $user_play->where($user_play_map)->find();
$balance = $user->where(array('id' => $request['user_id']))->getField("balance");
if ($balance + $user_play_data['bind_balance'] < $request['price']) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'您金额不足,请退出重试.')));exit;
}
if ($user_play_data['bind_balance'] < $request['price']) {
$price = $request['price'];
if ($user_play_data['bind_balance'] > 0) {

@ -20,7 +20,6 @@ class UserController extends BaseController
*/
public function user_login()
{
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
$user = json_decode(base64_decode(file_get_contents("php://input")), true);
#判断数据是否为空
@ -1709,7 +1708,7 @@ class UserController extends BaseController
} else if (pay_set_status('wei_xin_app') == 0 && pay_set_status('weixin') == 0 && pay_set_status('jft_wap') == 0) {
$wx_game = 0;
}
if ($request['price'] > C('WX_PAY_LIMIT')) $wx_game = 0;
if ($request['price'] >= C('WX_PAY_LIMIT')) $wx_game = 0;
if (pay_set_status('alipay') == 1 || (pay_set_status('goldpig') == 1 && C('goldpig.zfb'))
|| (pay_set_status('sqpay') == 1 && C('sqpay.zfb'))
) {

@ -452,7 +452,7 @@ class WapPayController extends BaseController{
$game_id = $request['game_id'];
$data = array(
'status' => 200,
"url" => 'http://api.wmtxkj.com'."/sdk.php/WapPay/wap_shortcut_pay/user_id/{$user_id}/game_id/{$game_id}",
"url" => 'http://' . $_SERVER ['HTTP_HOST'] ."/sdk.php/WapPay/wap_shortcut_pay/user_id/{$user_id}/game_id/{$game_id}",
"html" => '',
"return_msg" => '',
"paytype" => 'shortcut',
@ -497,7 +497,7 @@ class WapPayController extends BaseController{
C(api('Config/lists'));
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'game_id'=>$request['game_id'],'game_status'=>1))->find();
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'game_id'=>$request['game_id'],'pay_status'=>1))->find();
if($extend_data){
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$request['game_id'].'订单号重复,请关闭支付页面重新支付'.$request['extend'])));exit;
}
@ -545,7 +545,7 @@ class WapPayController extends BaseController{
$this->assign("pay_amount", $request['actual_amount']);
$this->assign("user_id", $request['user_id']);
$this->assign("game_id", $request['game_id']);
$this->display("index");
$this->display();
}
/**
@ -566,14 +566,14 @@ class WapPayController extends BaseController{
$this->set_message(1088, "fail", $payCheck['msg']);
}
C(api('Config/lists'));
if($request['price']*1<=0 || $request['price'] > C('WX_PAY_LIMIT')){
if($request['price']*1<=0 || $request['price'] >= C('WX_PAY_LIMIT')){
$this->set_message(1011,"fail","充值金额有误");
}
$game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find();
if($game['pay_status'] == 0){
$this->set_message(0,"fail","该游戏暂时无法充值,请联系客服!");
}
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'pay_status'=>1,'game_id'=>$request['game_id']))->find();
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'pay_status'=>1,'game_id'=>$request['game_id']))->find();
if($extend_data){
$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
}
@ -599,6 +599,7 @@ class WapPayController extends BaseController{
}
// 绑币平台币优先处理
$this->other_price($request, $discountAmount);
$pay_amount = $request['price'];
$game_set_data = get_game_set_info($request['game_id']);
//$request['game_name']
@ -905,7 +906,7 @@ class WapPayController extends BaseController{
$discount = $discount['discount'];
$pay_amount = $discount * $request['price'] / 10;
if ($pay_amount < 0.01) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'充值金额有误.'.$pay_amount)));exit;
redirect(U('Spend/notice',array('user_id'=>$request['user_id'],'game_id'=>$request['game_id'],'msg'=>'充值金额有误.'.$pay_amount)));exit;
}
$this->other_price($request, $request['price']-$pay_amount);
@ -917,7 +918,7 @@ class WapPayController extends BaseController{
if($request['code']==1){
$this->add_spend($request,1);
}else{
$this->add_deposit($request);
$this->add_deposit($request, 1);
}
$sqpay=new Sqpay();
$returl = 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success2/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
@ -947,4 +948,93 @@ class WapPayController extends BaseController{
}
// redirect($json_data['url']);
}
/**
* 双乾小程序支付
* 流程1.app端唤起小程序 2小程序请求服务端拿到支付参数 3小程序发起支付之后 回调服务端 4服务端通知客户端
* return 相关支付参数 回调url
*/
public function small_program() {
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
if (empty($request)) {
$this->set_message(1001, "fail", "登录数据不能为空");
}
if (!$request['openid'] || !$request['price'] || !$request['game_id']) {
$this->set_message(1001, "fail", "小程序参数有误");
}
$game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find();
if($game['pay_status'] == 0){
$this->set_message(0, "fail","该游戏暂时无法充值,请联系客服!");
}
if($request['price']*1<=0){
$this->set_message(1011,"fail","充值金额有误");
}
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'game_id'=>$request['game_id'],'pay_status'=>1))->find();
if($extend_data){
$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
}
$prefix = ($request['code'] == 1) ? "SP_" : "PF_";
$request['pay_order_number'] = $prefix . date('Ymd') . date('His') . sp_random_string(4);
$request['pay_way'] = C('PAY_WAY.SQ_SMALL_PROGRAM');
$request['pay_status'] = 0;
$request['spend_ip'] = get_client_ip();
//折扣
$user = get_user_entity($request['user_id']);
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
$discount = $discount['discount'];
$discountAmount = 0;
if($prefix=='PF_'){
$pay_amount = $request['price'];
}else{
$pay_amount = $discount * $request['price'] / 10;
$discountAmount = $request['price'] - $pay_amount;
}
if(!empty($request['scheme'])) {
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$request['scheme']);
}
// 绑币平台币优先处理
$this->other_price($request, $discountAmount);
$pay_amount = $request['price'];
if($request['code']==1){
$this->add_spend($request,1);
}else{
$this->add_deposit($request, 1);
}
$sqpay = new Sqpay();
$data['userId'] = $request['openid'];
$data['order_no'] = $request['pay_order_number'];
$data['merno'] = C('sqpay.partner');
$data['subject'] = '游戏充值';
$data['ip'] = get_client_ip();
$data['returnurl'] = C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
$data['amount'] = $request['price'];
$data['appId'] = C('wei_xin.email');
$data['secret'] = C('sqpay.key');
$data['MerRemark'] = $data['order_no'];
$ret = $sqpay->sq_wxsmallpay($data);
if ($ret[0]['respCode'] == "000000") {
echo json_encode(array(
'code' => 1,
'Amount' => $ret[0]['Amount'],
'orderNo' => $ret[0]['orderNo'], // 微信生成的订单号
'platformNumber' => $request['pay_order_number'], // 平台订单号
'wxjsapiStr' => $ret[0]['wxjsapiStr']
));
exit();
}
echo json_encode(array(
'code' => 1,
'msg' => $ret[0]['respMess'],
));
exit();
}
}

@ -49,11 +49,10 @@ border: 1px solid #999;
<h3>支付失败</h3>
<!-- <p>商品名称: 赤月传说</p> -->
<!-- <p>商品金额: 8887845</p> -->
<a href="{$Scheme}://showWapPayResult_btnType_?0&back">返回</a>
<a href="javascript:void(0)" id="back">返回</a>
</div>
<!--未绑定结束-->
</div>
</body>
@ -78,6 +77,15 @@ $(function(){
}
// location.href = $("#scheme").val()+"://showWapPayResult_btnType_?0&ss";
$("#back").click(function() {
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if (isAndroid) {
window.mengchuang.getPayResult('fail');
} else {
window.location.href = "{$Scheme}://showWapPayResult_btnType_?0&back";
}
});
})
</script>

@ -1,249 +1,270 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="__CSS__/index.css" rel="stylesheet" />
<style>input{outline:none;-webkit-appearance:none;}
html{font-size:12px;}
body {background:#F3F2F7;font-size:inherit;}
i{font-style:normal;font-weight:normal;}
.recharge_table {display:table;width:100%;}
.recharge_table .recharge_cell {display:table-cell;vertical-align:middle;text-align:center;}
.recharge_content {margin:0 auto;}
.recharge_content span {display:block;}
.recharge_money {height:5.818rem;background:#FFF;}
.recharge_content_number {color:#01B1EC;font-size:1.3rem;}
.recharge_content_coin,.recharge_game_name {color:#999;}
.recharge_content_number i {font-size:1.636rem;}
.recharge_game {background:#FFF;font-size:1.2rem;height:3.727rem;line-height:3.737rem;border-top:2px solid #DEE2E5;}
.recharge_game .recharge_value {padding:0 1.13rem;}
.recharge_way {height:10.8rem;}
.recharge_way_title {height:2.7rem;line-height:2.7rem;text-align:center;font-size:1.07rem;}
.recharge_way_content,.recharge_way_wrap {height:8rem;}
.recharge_way_btn {height:7.2rem;display:inline-block;}
.recharge_way_btn img{width:6.84rem;height:6.84rem;display:inline-block;margin-top:.18rem;}
.recharge_way_btn_alipay img{width:6.84rem;height:6.84rem;margin-top:0;}
.platform_pop {position:absolute;top:0;left:0;width:100%;height:100%;display:none;}
.platform_pop_table {width:100%;height:100%;}
.platform_box {color:#999;position:relative;top:0;left:auto;right:auto;width:24rem;display:block;margin:0 auto;background:#FFF;border-radius:.3rem;}
.platform_pop_close {position:absolute;top:0.8rem;right:0.8rem;color:#999;}
.platform_pop_close img {width:1.7rem;height:1.7rem;}
.platform_title {line-height:3.4rem;font-size:1.8rem;}
.platform_content {padding:0 0.8rem;text-align:left;font-size:1.5rem;}
.platform_notice {color:#333;line-height:1.4;}
.platform_notice span {color:red;}
.platform_radio {padding-top:.2rem;padding-bottom:0.2rem;}
.platform_radio .platform_radio_item {display:block;line-height:1.8;position:relative;}
.platform_radio_item input {position:absolute;top:0;left:0;z-index:-1;width:1.8rem;height:1.8rem;}
.platform_radio_item input~i{width:1.6rem;height:1.6rem;background:url(__IMG__/btn_check_n.png) center center no-repeat;background-size:100% 100%;display:inline-block;vertical-align:middle;margin-top:-.3rem;margin-right:0.2rem;}
.platform_radio_item input:checked~i{background-image:url(__IMG__/btn_check_s.png);}
.platform_btn {padding:0.2rem .8rem 1rem;}
.platform_btn input {background:#F9AB42;color:#FFF;line-height:1.8;font-size:1.8rem;border:none;width:100%;border-radius:.3rem;}
@media screen and (max-width:400px) {
.recharge_game {border-top-width:1px;}
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<script src="__JS__/flex.min.js"></script>
<script src="__JS__/jquery-1.11.1.min.js"></script>
<script src="__STATIC__/layer_mobile/layer.js"></script>
<title>支付中心</title>
</head>
<style>
html,
body {
background-color: #F5F5F5;
min-height: 100vh;
</head>
}
<body>
<div class="containers">
<div class="recharge_money recharge_table">
<div class="recharge_cell">
<div class="recharge_content">
<span class="recharge_content_number"><i>{$data.price}</i></span>
<span class="recharge_content_coin">{$data.coin}</span>
</div>
</div>
</div>
<eq name="data.code" value="1">
<div class="recharge_game">
<div class="recharge_value">
<span class="recharge_game_name">游戏名称:</span>
<span>{$data.game_name}</span>
</div>
</div>
</eq>
<div class="recharge_way">
<div class="recharge_way_title">请选择支付方式</div>
<div class="recharge_way_content">
<div class="recharge_way_wrap recharge_table">
<if condition="C('wei_xin.status') eq 1 or C('weixin_gf.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.wx') eq 1) or (C('heepay.status') eq 1 and C('heepay.wxp') eq 1)">
<div class="recharge_cell">
<a href="{:U('Apple/apple_weixin_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_wechat"><img src="__IMG__/btn_pay_wechat@3x.png"></a>
</div>
</if>
<if condition="C('alipay.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.zfb') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.zfb') eq 1)">
<div class="recharge_cell">
<!-- <a href="{:U('Apple/apple_alipay_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_alipay"><img src="__IMG__/btn_pay_alipay@3x.png"></a>
-->
<a href="javascript:;" data-url="/sdk.php?s=/Apple/apple_alipay_pay&user_id={:I('user_id')}&game_id={:I('game_id')}" id="alipaybtn" class="recharge_way_btn recharge_way_btn_alipay"><img src="__IMG__/btn_pay_alipay@3x.png"></a>
<!--
<a href="{$alipayurl}" data-url="" id="alipaybtn" class="recharge_way_btn recharge_way_btn_alipay"><img src="__IMG__/btn_pay_alipay@3x.png"></a>
-->
</div>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.union') eq 1">
<div class="recharge_cell">
<a href="{:U('Apple/apple_union_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_alipay">
<img src="__IMG__/unionpay.png"></a>
</div>
</if>
.weui-cells {
border-radius: .2rem;
box-shadow: 0px 0px .05rem rgba(0, 0, 0, .2);
margin-top: 0px;
}
<if condition="pay_set_status('ptb_pay') eq 1 and $data['code'] eq 1">
<div class="recharge_cell">
<a href="javascript:;" id="platform_id" class="recharge_way_btn recharge_way_btn_platform"><img src="__IMG__/btn_pay_platform@3x.png"></a>
</div>
</if>
.weui-cell {
height: 0.85rem;
font-size: .28rem;
color: #292929;
padding: 0px .3rem;
}
<if condition="pay_set_status('bind_pay') eq 1 and $data['code'] eq 1">
<div class="recharge_cell">
<a href="javascript:;" id="platform_id1" class="recharge_way_btn recharge_way_btn_platform"><img src="__IMG__/icon_bangbi@3x.png"></a>
</div>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.shortcut') eq 1">
<div class="recharge_cell">
<a href="{:U('WapPay/wap_shortcut_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_alipay">
<img src="__IMG__/unionpay.png"></a>
</div>
</if>
</div>
</div>
</div>
<div class="platform_pop" id="platform_pop">
<div class="platform_pop_table recharge_table">
<div class="recharge_cell">
<form class="platform_box" action="{:U('Apple/apple_platform_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" enctype="multipart/form-data" method="post">
<a href="javascript:;" id="platform_pop_close" class="platform_pop_close"><img src="__IMG__/icon_close@3x.png" ></a>
<div class="platform_title">平台币</div>
<div class="platform_content">
<div class="platform_notice">应付款平台币数量:<span>{$data.price}</span></div>
<div class="platform_radio">
<label class="platform_radio_item"><input type="radio" name="way" value="1" checked><i></i>平台币余额:<span>{$balance}</span></label>
</div>
</div>
<div class="platform_btn">
<input type="submit" value="立即支付" style="background-color:<notempty name='btncolor'>#{$btncolor}<else />#F9AB42</notempty>">
</div>
</form>
</div>
</div>
</div>
<div class="platform_pop" id="platform_pop1">
<div class="platform_pop_table recharge_table">
<div class="recharge_cell">
<form class="platform_box" action="{:U('Apple/apple_platform_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" enctype="multipart/form-data" method="post">
<a href="javascript:;" id="platform_pop_close1" class="platform_pop_close"><img src="__IMG__/icon_close@3x.png" ></a>
<div class="platform_title">绑币平台币</div>
<div class="platform_content">
<div class="platform_notice">应付款绑币数量:<span>{$data.price}</span></div>
<div class="platform_radio">
<label class="platform_radio_item"><input type="radio" name="way" value="2" checked><i></i>绑定平台币余额:<span>{$bind_balance}</span></label>
</div>
</div>
<div class="platform_btn">
<input type="submit" value="立即支付" style="background-color:<notempty name='btncolor'>#{$btncolor}<else />#F9AB42</notempty>">
</div>
</form>
</div>
</div>
</div>
</div>
</body>
<script>
var html=document.getElementsByTagName('html')[0];
function fontsizechange() {
var rate = html.clientWidth/640;
var basesize = 22;
html.style.fontSize = (rate>1?basesize:basesize*rate)+'px';
}
fontsizechange();
window.onresize = function() {
fontsizechange();
}
$(function() {
$(".recharge_way_wrap a").one("click",function(){
$(this).click(function (){return false;});
});
$('#platform_id').on('click',function() {
$('#platform_pop').fadeIn().find('#platform_pop_close').on('click',function() {
$(this).closest('#platform_pop').fadeOut();
return false;
});
return false;
});
img {
width: .72rem;
height: .72rem;
margin-right: .2rem;
/* margin: .3rem; */
}
.paylist .weui-cell {
padding: .2rem .3rem;
height: 1rem;
}
.paylist .weui-cell__hd {
display: flex;
}
.weui-cells:after {
border: 0px;
}
.weui-cells:before {
border: 0px;
}
@media screen and (orientation: portrait) {
.box{
padding:.3rem;
}
.bottombutton{
height:1rem;background-color: #21B1EB;color: #ffffff;font-size: .32rem;text-align: center;line-height:1rem;bottom: 0px;
position: fixed;left: 0;right: 0;
}
}
@media screen and (orientation: landscape) {
/*横屏 css*/
.box{
padding:.3rem .5rem;
}
.bottombutton{
height:1rem;background-color: #21B1EB;color: #ffffff;font-size: .32rem;text-align: center;line-height:1rem;
width: 7.5rem;border-radius: .2rem;position: absolute;left: 50%;margin: .5rem 0 .5rem -3.75rem;
}
body{
padding-bottom: .50rem;
}
.paylist-box{
display: flex;
height: auto;
flex-wrap:wrap;
}
.paylist-box .weui-cell{
min-width: 30%;
box-sizing: content-box;
margin-left: 3%;
padding: .2rem .0rem;
/* padding: .4rem .3rem; */
}
.paylist-box .weui-cell:before{
content: none;
}
}
.border-half-line{
width: 97%;
margin-left: 3%;
float:left;
height:1px;
background-color: #e5e5e5;
-webkit-transform:scale(1,0.5);
transform:scale(1,0.5);
-webkit-transform-origin:top center;
transform-origin: top center
}
$('#platform_id1').on('click',function() {
$('#platform_pop1').fadeIn().find('#platform_pop_close1').on('click',function() {
$(this).closest('#platform_pop1').fadeOut();
return false;
});
@media screen and (orientation: portrait) {
.box{
padding:.3rem;
}
}
@media screen and (orientation: landscape) {
/*横屏 css*/
.box{
padding:.3rem .5rem;
}
.bottombutton{
height:1rem;background-color: #21B1EB;color: #ffffff;font-size: .32rem;text-align: center;line-height:1rem;
width: 7.5rem;border-radius: .2rem;position: absolute;left: 50%;margin: .5rem 0 .5rem -3.75rem;
}
body{
padding-bottom: .50rem;
}
}
return false;
});
$('#alipaybtn').on('click',function() {
var that = $(this),url = $.trim(that.attr('data-url'));
if(that.hasClass('disabledbtn')){return false;}
that.addClass('disabled');
$.ajax({
type:'post',
dataType:'json',
data:{},
url:url,
success:function(result) {
if(result.code==200) {
var data = result.data;
if(data.wap==1) {
location.href = data.url;
} else if (data.wap==1) {
window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
}
else {
</style>
window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
<body>
<div class="box">
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__bd">
<p>订单金额:</p>
</div>
<div class="weui-cell__ft" style="color: red">¥{$data['price']}元</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<p>您的账户余额:</p>
</div>
<div class="weui-cell__ft" style="color: #A9A9A9;">{$balance+$bind_balance}平台币</div>
</div>
</div>
<div class="weui-cells" style="margin-top: .3rem;">
<div class="weui-cell">
<div class="weui-cell__bd">
<p>适用平台余额:</p>
</div>
<div class="weui-cell__ft" style="color: #292929">-¥{$balance+$bind_balance}</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<p>还需支付:</p>
</div>
<div data-pay_price="{$pay_price}" id="pay_price" class="weui-cell__ft" style="color: red">¥{$pay_price}</div>
</div>
</div>
<div class="weui-cells paylist" style="margin-top: .3rem;">
<div class="weui-cells__title" style="line-height: .85rem;color: #a9a9a9;font-size:.28rem;margin: 0px;">
请选择支付方式</div>
<div class="border-half-line" style="position: absolute;"></div>
<div class="paylist-box">
<if condition="C('alipay.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.zfb') eq 1) or (C('sqpay.status') eq 1 and C('sqpay.zfb') eq 1)">
<a id="alipaybtn" class="weui-cell" href="javascript:;" data-url="/sdk.php?s=/Apple/apple_alipay_pay&user_id={:I('user_id')}&game_id={:I('game_id')}" id="alipaybtn" class="recharge_way_btn recharge_way_btn_alipay">
<div class="weui-cell__hd"><img src="__IMG__/alipay.png"></div>
<div class="weui-cell__bd">
<p style="color: #292929;font-size:.28rem;">支付宝支付</p>
<p style="color: #a9a9a9;font-size:.2rem;">推荐支付宝用户使用</p>
</div>
</a>
</if>
<if condition="$pay_price elt C('WX_PAY_LIMIT')">
<if condition="C('wei_xin.status') eq 1 or C('weixin_gf.status') eq 1 or (C('goldpig.status') eq 1 and C('goldpig.wx') eq 1) or (C('heepay.status') eq 1 and C('heepay.wxp') eq 1)">
<a class="weui-cell" href="{:U('Apple/apple_weixin_pay',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_wechat">
<div class="weui-cell__hd"><img src="__IMG__/wxpay.png"></div>
<div class="weui-cell__bd">
<p style="color: #292929;font-size:.28rem;">微信支付</p>
<p style="color: #a9a9a9;font-size:.2rem;">推荐微信用户使用</p>
</div>
</a>
</if>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.union') eq 1">
<a class="weui-cell" href="{:U('Apple/apple_union_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_alipay">
<div class="weui-cell__hd"><img src="__IMG__/cardpay.png"></div>
<div class="weui-cell__bd">
<p style="color: #292929;font-size:.28rem;">银行卡支付</p>
<p style="color: #a9a9a9;font-size:.2rem;">使用银行卡支付</p>
</div>
</a>
</if>
<if condition="C('sqpay.status') eq 1 and C('sqpay.shortcut') eq 1">
<a class="weui-cell" href="{:U('WapPay/wap_shortcut_pay', array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}" class="recharge_way_btn recharge_way_btn_alipay">
<div class="weui-cell__hd"><img src="__IMG__/onlinepay.png"></div>
<div class="weui-cell__bd">
<p style="color: #292929;font-size:.28rem;">快捷支付</p>
<p style="color: #a9a9a9;font-size:.2rem;">可在线快捷支付</p>
</div>
</a>
</if>
</div>
</div>
}
} else {
layer.open({
content: result.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
},error:function() {
that.removeClass('disabledbtn');
}
</div>
<botton id="platform_pay" class="bottombutton">
确认支付
</botton>
</body>
<script>
$(function() {
if ($("#pay_price").data("pay_price") == 0) {
$("#platform_pay").show();
$(".paylist").hide();
} else {
$("#platform_pay").hide();
$(".paylist").show();
}
$("#platform_pay").click(function() {
var url = "{:U('Apple/platform_coin_deduction',array('user_id'=>I('user_id'),'game_id'=>I('game_id')))}";
window.location.href = url;
});
$('#alipaybtn').on('click',function() {
var that = $(this),url = $.trim(that.attr('data-url'));
if(that.hasClass('disabledbtn')){return false;}
that.addClass('disabled');
$.ajax({
type:'post',
dataType:'json',
data:{},
url:url,
success:function(result) {
if(result.code==200) {
var data = result.data;
if(data.wap==1) {
location.href = data.url;
} else if (data.wap==1) {
window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
}
else {
window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
}
} else {
layer.open({
content: result.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
return false;
});
});
}
},error:function() {
that.removeClass('disabledbtn');
}
</script>
});
return false;
});
});
</script>
</html>

@ -1,16 +1,135 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>在线订单</title>
<script type="text/javascript" src="__JS__/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<script src="__JS__/flex.min.js"></script>
<script type="text/javascript" src="__JS__/jquery.js"></script>
<title>支付中心</title>
</head>
<style>
html,
body {
background-color: #F5F5F5;
min-height: 100vh;
}
.weui-cells {
border-radius: .2rem;
box-shadow: 0px 0px .05rem rgba(0, 0, 0, .2);
margin-top: 0px;
}
.weui-cell {
height: 0.85rem;
font-size: .28rem;
color: #292929;
padding: 0px .3rem;
}
.bottombutton {
height: 1rem;
background-color: #21B1EB;
color: #ffffff;
font-size: .32rem;
text-align: center;
line-height: 1rem;
bottom: 0px;
}
img {
width: .72rem;
height: .72rem;
margin-right: .2rem;
/* margin: .3rem; */
}
.paylist .weui-cell {
padding: .2rem .3rem;
height: 1rem;
}
.paylist .weui-cell__hd {
display: flex;
}
.weui-cells:after {
border: 0px;
}
.weui-cells:before {
border: 0px;
}
/**/
.weui-label {
font-size: .32rem;
}
.weui-cell__bd{
padding-right: .2rem;
}
.weui-input {
background-color: #EDEDED;
height: .6rem;
border-radius: .1rem;
padding-left: .2rem;
}
.weui-cell {
margin: .3rem 0rem;
/* padding:0 .3rem; */
}
.weui-cell:before {
height: 0px;
content: none;
}
.redtxt.weui-cell__ft {
color: red;
font-size: .28rem;
margin-left: .17rem;
}
.paymoney:after{
content: " ";
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1px solid #e5e5e5;
color: #e5e5e5;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scaleY(.5);
transform: scaleY(.5);
left: .3rem;
right:.3rem;
z-index: 2;
}
.bottombutton{
height:1rem;background-color: #21B1EB;color: #ffffff;font-size: .32rem;text-align: center;line-height:1rem;bottom: 0px;
}
</style>
<script type="text/javascript">
var validCode=true;
var smsstatus = true;
function getSms() {
if ($("#custName").val() == '' || $("#idNo").val() == '' || $("#phoneNo").val() == '') {
alert('参数不能为空');
return ;
}
if (!smsstatus) return;
$("#sms").html("请求中");
smsstatus = false;
//获取短信验证码
$.ajax({
@ -42,6 +161,7 @@ function getSms() {
juege.inherit="";
validCode=true;
smsstatus = true;
}
},1000);
@ -49,6 +169,7 @@ function getSms() {
}
else {
alert(res.info);
smsstatus = true;
}
}
});
@ -70,6 +191,7 @@ function sendform() {
if ($("#custName").val() != '' && $("#idNo").val() != '' && $("#phoneNo").val() != '' && $("#smsCode").val() != '')
isok = true;
if (!isok) {
btnpay = false;
alert('参数不能为空');
}
return isok;
@ -77,86 +199,74 @@ function sendform() {
</script>
<script type="text/javascript" src="__JS__/demo.js"></script>
<style type="text/css">
body{background:#FFF;}
#wbag{width:100%;background:#EBF7FF;}
.wfwarp{border:1px solid #B8E3FF;}
.wftitle{border-bottom:0px solid #B8E3FF;}
.wfrxian{border-right:0px solid #B8E3FF;}
.wfsubbox input{background:#09F;}
label{font-size:14px;color:#555;line-height:40px;margin-right:0px;}
input{width:212px;height:38px;border-style:none;padding:0 4px;border:1px solid #C8C8C8;margin-right:10px;outline:none;}
.msgs{display:inline-block;width:104px;color:#fff;font-size:12px;border:1px solid #0697DA;text-align:center;height:30px;line-height:30px;background:#0697DA;cursor:pointer;}
form .msgs1{background:#E6E6E6;color:#818080;border:1px solid #CCCCCC;}
</style>
</head>
<body>
<div id="wbag" align="center">
<div class="wfwarp">
<div class="wforderl">
<div class="wfforml" id="wfforml">
<div class="wfrxian">
<form id="wfform" name="wfform" method="post" action="{:U('WapPay/shortcut_pay')}" target="_parent">
<input type="hidden" id="wfddll" name="wfddll" value="wfddll" />
<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="wftitle" align="center"><!-- <img src="__IMG__/tita.gif" /> --></div>
<div class="wftitle" align="center">
<span>支付金额:{$pay_amount}</span>
</div>
<div class="wfbdbox">
<label class="wfbdxx"><em>*</em>姓名</label>
<div class="wftextbox">
<input id="custName" type="text" name="custName" />
</div>
<div
style="height: 3.1rem;background-color: #21B1EB;color: #fff;border-bottom-left-radius:40%;border-bottom-right-radius:40%;padding: .43rem .3rem;">
<p style="font-size: .4rem;">待支付……</p>
<p style="font-size: .24rem;margin-top:.32rem;">订单超过30分钟自动取消请在20分钟18秒内完成支付</p>
</div>
<form id="wfform" name="wfform" method="post" action="{:U('WapPay/shortcut_pay')}" target="_parent">
<input type="hidden" id="wfddll" name="wfddll" value="wfddll" />
<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 style="padding: 0 .3rem;margin-top:-1.8rem;">
<div class="weui-cells weui-cells_form" style="padding: .3rem 0 0;">
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">姓名:</label></div>
<div class="weui-cell__bd">
<input id="custName" name="custName" class="weui-input" type="text">
</div>
<div class="wfbdbox">
<label class="wfbdxx"><em>*</em>银行卡号</label>
<div class="wftextbox">
<input id="cardNo" type="text" name="cardNo" />
</div>
<div class="redtxt weui-cell__ft">
*
</div>
<div class="wfbdbox">
<label class="wfbdxx"><em>*</em>身份证号</label>
<div class="wftextbox">
<input id="idNo" type="text" name="idNo" />
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">银行卡号:</label></div>
<div class="weui-cell__bd">
<input id="cardNo" name="cardNo" class="weui-input" type="text">
</div>
<div class="wfbdbox">
<label class="wfbdxx"><em>*</em>手机号</label>
<div class="wftextbox">
<input id="phoneNo" type="text" name="phoneNo" />
</div>
<div class="redtxt weui-cell__ft">
*
</div>
<div class="wfbdbox">
<label class="wfbdxx">验证码</label>
<input id="smsCode" type="text" name="smsCode" class="c_code_msg" style="width:55%;">
<span class="msgs" onclick="getSms()"><font id="sms">获取短信验证码</span>
<span class="juege" type="hidden"><font id="judge"></span>
</div>
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">身份证号:</label></div>
<div class="weui-cell__bd">
<input id="idNo" name="idNo" class="weui-input" type="text">
</div>
<div class="wfsubbox">
<input onclick="return sendform()" type="submit" id="wfsubmit" name="wfsubmit" value="立即提交订单"/>
<div class="redtxt weui-cell__ft">
*
</div>
</form>
</div>
<div class="weui-cell">
<div class="weui-cell__hd"><label class="weui-label">手机号:</label></div>
<div class="weui-cell__bd">
<input id="phoneNo" name="phoneNo" class="weui-input" type="text">
</div>
<div class="redtxt weui-cell__ft">
*
</div>
</div>
<div class="weui-cell weui-cell_vcode">
<div class="weui-cell__hd"><label class="weui-label">验证码:</label></div>
<div class="weui-cell__bd">
<input id="smsCode" name="smsCode" class="weui-input" type="number">
</div>
<div class="weui-cell__ft" style="margin-right: .24rem;margin-left:.3rem;">
<a id="sms" onclick="getSms()" href="javascript:;" class="weui-btn" style="font-size: .28rem;;background-color: #21B1EB;color: #fff;border-radius: .1rem;height: .6rem;line-height:.6rem;">获取验证码</a>
</div>
</div>
<div class="weui-cell paymoney" style="height:1.4rem;">
<div class="weui-cell__bd" >
<p style="font-size: .32rem;">支付金额:</p>
</div>
<div class="weui-cell__ft" style="font-size: .48rem;color: red;">{$pay_amount}</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
<input onclick="return sendform()" type="submit" id="wfsubmit" name="wfsubmit" value="立即提交订单" class="weui-footer_fixed-bottom bottombutton"/>
</form>
</body>
</html>

@ -41,36 +41,30 @@ class Sqpay
}
// 小程序支付 双乾
public function sq_wxsmallpay($order_no,$amount=0.01,$merno="168885",$paymenttype="WXZF", $subject="测试产品1", $ip=0,$returnurl=""){
$merno = "204121";
$secret = "NsyJOE!e";
$returnurl = empty($returnurl)?"http://".$_SERVER['HTTP_HOST']:$returnurl;//成功跳转
public function sq_wxsmallpay($data){
Log::write("wxpay:".serialize($_REQUEST), Log::DEBUG);
$returnurl = empty($data['returnurl'])?"http://".$_SERVER['HTTP_HOST']:$data['returnurl'];//成功跳转
$notifyurl = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/sq_callback";//通知
$notifyurl = "http://".$_SERVER['HTTP_HOST']."/callback.php/Notify/sq_callback"; //通知
$ordertime =date("Ymdhms",time());
// 168885 12345678
$sign = md5("Amount={$amount}&BillNo={$order_no}&MerNo={$merno}&PayType=SMZF&".strtoupper(md5($secret)));
$sign = md5("Amount={$data['amount']}&BillNo={$data['order_no']}&MerNo={$data['merno']}&PayType=SMZF&".strtoupper(md5($data['secret'])));
$sign = strtoupper($sign);
$params=[
'MerNo' => $merno,
'MerNo' => $data['merno'],
'isSubMerPay' => 0,
// 'subMerNo' => $merno,
'appId' => 'wx0ba5be5c8bb9f1b7',
'Amount'=>$amount,
'BillNo'=>$order_no,
// 'subMerNo' => $data['merno'],
'appId' => $data['appId'],//'wx0ba5be5c8bb9f1b7',
'Amount'=> $data['amount'],
'BillNo'=> $data['order_no'],
'TranCode'=>"SMZF010",
'PayType'=> "SMZF",
'PaymentType'=> $paymenttype,//"UNION","ZFBZF",
'MerRemark' => 'MerRemark',
'subject' => $subject,
'userId' => 'oqFwC5TRQX1wpM8KfBQHy5FI6yJM',
'PaymentType'=> "WXZF",
'MerRemark' => $data['MerRemark'],
'subject' => $data['subject'],
'userId' => $data['userId']?$data['userId']:'oqFwC5TRQX1wpM8KfBQHy5FI6yJM',//'oqFwC5TRQX1wpM8KfBQHy5FI6yJM',
'NotifyURL' => $notifyurl,
// 'ReturnURL' => $returnurl,
// 'mchAppId' => 'https://www.95epay.cn',
// 'mchAppName' => '追梦',
// 'deviceInfo' => 'iOS_WAP',
// 'clientIp' => $ip,
// MD5("Amount=0.01&BillNo=1481093236896&MerNo=168885&PayType=SMZF &"+MD5("12345678").toUpperCase()).toUpperCase();
'MD5info' => $sign,
];
$ret = curl_post("https://scan.95epay.cn/ScanCodePayment.action", $params);

Loading…
Cancel
Save