|
|
|
@ -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']
|
|
|
|
@ -815,8 +812,8 @@ class WapPayController extends BaseController{
|
|
|
|
|
* @return [type] [description]
|
|
|
|
|
*/
|
|
|
|
|
public function jft_wap(){
|
|
|
|
|
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
|
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
|
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
|
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
|
if (empty($request)) {
|
|
|
|
|
$this->set_message(1001, "fail", "登录数据不能为空");
|
|
|
|
|
}
|
|
|
|
@ -824,27 +821,29 @@ class WapPayController extends BaseController{
|
|
|
|
|
if($request['price']<0){
|
|
|
|
|
$this->set_message(1011,"fail","充值金额有误");
|
|
|
|
|
}
|
|
|
|
|
$table = $request['code'] == 1 ? "spend" : "deposit";
|
|
|
|
|
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
|
|
|
|
|
$request['pay_order_number'] = $prefix . date('Ymd') . date('His') . sp_random_string(4);
|
|
|
|
|
$request['pay_way'] = 3;
|
|
|
|
|
$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'];
|
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
|
$table = $request['code'] == 1 ? "spend" : "deposit";
|
|
|
|
|
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
|
|
|
|
|
$request['pay_order_number'] = $prefix . date('Ymd') . date('His') . sp_random_string(4);
|
|
|
|
|
$request['pay_way'] = 3;
|
|
|
|
|
$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'];
|
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
|
// 绑币平台币处理
|
|
|
|
|
$this->other_price($request, $request['price']-$pay_amount);
|
|
|
|
|
|
|
|
|
|
if($request['code']==1){
|
|
|
|
|
$this->add_spend($request);
|
|
|
|
|
}else{
|
|
|
|
|
$this->add_deposit($request);
|
|
|
|
|
}
|
|
|
|
|
file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request)));
|
|
|
|
|
if($request['code']==1){
|
|
|
|
|
$this->add_spend($request);
|
|
|
|
|
}else{
|
|
|
|
|
$this->add_deposit($request);
|
|
|
|
|
}
|
|
|
|
|
file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request)));
|
|
|
|
|
|
|
|
|
|
$sss="http://".$_SERVER['HTTP_HOST'].'/sdk.php/Spend/pay_way/user_id/'.$request['user_id'].'/game_id/'.$request['game_id'].'/type/3';
|
|
|
|
|
redirect($sss);
|
|
|
|
|
$sss="http://".$_SERVER['HTTP_HOST'].'/sdk.php/Spend/pay_way/user_id/'.$request['user_id'].'/game_id/'.$request['game_id'].'/type/3';
|
|
|
|
|
redirect($sss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -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) {
|
|
|
|
|