|
|
@ -11,7 +11,7 @@ use Org\GoldPig\GoldPig;
|
|
|
|
use Org\SqpaySDK\Sqpay;
|
|
|
|
use Org\SqpaySDK\Sqpay;
|
|
|
|
use Qiniu\json_decode;
|
|
|
|
use Qiniu\json_decode;
|
|
|
|
use Think\Log;
|
|
|
|
use Think\Log;
|
|
|
|
class WapPayController extends BaseController{
|
|
|
|
class WapPayController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
private function pay($param=array()){
|
|
|
|
private function pay($param=array()){
|
|
|
|
$table = $param['code'] == 1 ? "spend" : "deposit";
|
|
|
|
$table = $param['code'] == 1 ? "spend" : "deposit";
|
|
|
@ -41,7 +41,8 @@ class WapPayController extends BaseController{
|
|
|
|
->setGameId($param['game_id'])
|
|
|
|
->setGameId($param['game_id'])
|
|
|
|
->setGameName(get_game_name($param['game_id']))
|
|
|
|
->setGameName(get_game_name($param['game_id']))
|
|
|
|
->setGameAppid($param['game_appid'])
|
|
|
|
->setGameAppid($param['game_appid'])
|
|
|
|
->setServerId(0)
|
|
|
|
->setServerId($param['server_id'])
|
|
|
|
|
|
|
|
->setGamePlayerId($param['game_player_id'])
|
|
|
|
->setGameplayerName($param['game_player_name'])
|
|
|
|
->setGameplayerName($param['game_player_name'])
|
|
|
|
->setServerName($param['server_name'])
|
|
|
|
->setServerName($param['server_name'])
|
|
|
|
->setUserId($param['user_id'])
|
|
|
|
->setUserId($param['user_id'])
|
|
|
@ -452,7 +453,7 @@ class WapPayController extends BaseController{
|
|
|
|
$game_id = $request['game_id'];
|
|
|
|
$game_id = $request['game_id'];
|
|
|
|
$data = array(
|
|
|
|
$data = array(
|
|
|
|
'status' => 200,
|
|
|
|
'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" => '',
|
|
|
|
"html" => '',
|
|
|
|
"return_msg" => '',
|
|
|
|
"return_msg" => '',
|
|
|
|
"paytype" => 'shortcut',
|
|
|
|
"paytype" => 'shortcut',
|
|
|
@ -497,7 +498,7 @@ class WapPayController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
C(api('Config/lists'));
|
|
|
|
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){
|
|
|
|
if($extend_data){
|
|
|
|
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$request['game_id'].'订单号重复,请关闭支付页面重新支付'.$request['extend'])));exit;
|
|
|
|
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$request['game_id'].'订单号重复,请关闭支付页面重新支付'.$request['extend'])));exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -545,7 +546,7 @@ class WapPayController extends BaseController{
|
|
|
|
$this->assign("pay_amount", $request['actual_amount']);
|
|
|
|
$this->assign("pay_amount", $request['actual_amount']);
|
|
|
|
$this->assign("user_id", $request['user_id']);
|
|
|
|
$this->assign("user_id", $request['user_id']);
|
|
|
|
$this->assign("game_id", $request['game_id']);
|
|
|
|
$this->assign("game_id", $request['game_id']);
|
|
|
|
$this->display("index");
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -566,14 +567,14 @@ class WapPayController extends BaseController{
|
|
|
|
$this->set_message(1088, "fail", $payCheck['msg']);
|
|
|
|
$this->set_message(1088, "fail", $payCheck['msg']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
C(api('Config/lists'));
|
|
|
|
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","充值金额有误");
|
|
|
|
$this->set_message(1011,"fail","充值金额有误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find();
|
|
|
|
$game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find();
|
|
|
|
if($game['pay_status'] == 0){
|
|
|
|
if($game['pay_status'] == 0){
|
|
|
|
$this->set_message(0,"fail","该游戏暂时无法充值,请联系客服!");
|
|
|
|
$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){
|
|
|
|
if($extend_data){
|
|
|
|
$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
|
|
|
|
$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -599,6 +600,7 @@ class WapPayController extends BaseController{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 绑币平台币优先处理
|
|
|
|
// 绑币平台币优先处理
|
|
|
|
$this->other_price($request, $discountAmount);
|
|
|
|
$this->other_price($request, $discountAmount);
|
|
|
|
|
|
|
|
$pay_amount = $request['price'];
|
|
|
|
|
|
|
|
|
|
|
|
$game_set_data = get_game_set_info($request['game_id']);
|
|
|
|
$game_set_data = get_game_set_info($request['game_id']);
|
|
|
|
//$request['game_name']
|
|
|
|
//$request['game_name']
|
|
|
@ -633,10 +635,9 @@ class WapPayController extends BaseController{
|
|
|
|
$json_data['status'] = 500;
|
|
|
|
$json_data['status'] = 500;
|
|
|
|
$json_data['url'] = "http://" . $_SERVER['HTTP_HOST'];
|
|
|
|
$json_data['url'] = "http://" . $_SERVER['HTTP_HOST'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$json_data['cal_url'] = C("pay_header");
|
|
|
|
$json_data['cal_url'] = $_SERVER ['HTTP_HOST'];
|
|
|
|
|
|
|
|
echo base64_encode(json_encode($json_data));exit;
|
|
|
|
echo base64_encode(json_encode($json_data));exit;
|
|
|
|
// $this->redirect('WapPay/weixin_pay_view',['user_id'=>$request['user_id'],'game_id'=>$request['game_id']]);
|
|
|
|
// $this->redirect('WapPay/weixin_pay_view',['user_id'=>$request['user_id'],'game_id'=>$request['game_id']]);
|
|
|
|
|
|
|
|
} else if(get_wx_pay_type() == 1){ // 威富通
|
|
|
|
} else if(get_wx_pay_type() == 1){ // 威富通
|
|
|
|
if( empty(C('heepay.partner'))||empty(C('heepay.key'))){
|
|
|
|
if( empty(C('heepay.partner'))||empty(C('heepay.key'))){
|
|
|
|
$this->set_message(1009, "fail", "支付参数未配置");
|
|
|
|
$this->set_message(1009, "fail", "支付参数未配置");
|
|
|
@ -905,7 +906,7 @@ class WapPayController extends BaseController{
|
|
|
|
$discount = $discount['discount'];
|
|
|
|
$discount = $discount['discount'];
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
if ($pay_amount < 0.01) {
|
|
|
|
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);
|
|
|
|
$this->other_price($request, $request['price']-$pay_amount);
|
|
|
|
|
|
|
|
|
|
|
@ -917,7 +918,7 @@ class WapPayController extends BaseController{
|
|
|
|
if($request['code']==1){
|
|
|
|
if($request['code']==1){
|
|
|
|
$this->add_spend($request,1);
|
|
|
|
$this->add_spend($request,1);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$this->add_deposit($request);
|
|
|
|
$this->add_deposit($request, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$sqpay=new Sqpay();
|
|
|
|
$sqpay=new Sqpay();
|
|
|
|
$returl = 'http://' . $_SERVER ['HTTP_HOST'] . "/sdk.php/Spend/pay_success2/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
|
|
|
|
$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']);
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|