|
|
@ -83,6 +83,28 @@ class WapPayController extends BaseController{
|
|
|
|
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
|
|
|
|
$prefix = $request['code'] == 1 ? "SP_" : "PF_";
|
|
|
|
$out_trade_no = $prefix.date('Ymd').date('His').sp_random_string(4);
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
|
|
if(get_zfb_type()==0){
|
|
|
|
if(get_zfb_type()==0){
|
|
|
|
$game_set_data = get_game_set_info($request['game_id']);
|
|
|
|
$game_set_data = get_game_set_info($request['game_id']);
|
|
|
|
|
|
|
|
|
|
|
@ -103,7 +125,7 @@ class WapPayController extends BaseController{
|
|
|
|
"url" => $pay_url,
|
|
|
|
"url" => $pay_url,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
} elseif (get_zfb_type() == 2) {
|
|
|
|
} elseif (get_zfb_type() == 2) { // 双乾支付H5
|
|
|
|
$request['pay_order_number'] = $out_trade_no;
|
|
|
|
$request['pay_order_number'] = $out_trade_no;
|
|
|
|
$request['pay_way'] = C('PAY_WAY.SQ_ALIPAY');
|
|
|
|
$request['pay_way'] = C('PAY_WAY.SQ_ALIPAY');
|
|
|
|
$request['pay_status'] = 0;
|
|
|
|
$request['pay_status'] = 0;
|
|
|
@ -115,7 +137,7 @@ class WapPayController extends BaseController{
|
|
|
|
$this->add_deposit($request);
|
|
|
|
$this->add_deposit($request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$sqpay=new Sqpay();
|
|
|
|
$sqpay=new Sqpay();
|
|
|
|
$returl = 'http://' .C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
|
|
|
|
$returl = C('pay_header'). "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
|
|
|
|
$data['secret'] = C("sqpay.key");
|
|
|
|
$data['secret'] = C("sqpay.key");
|
|
|
|
$data['merno'] = C("sqpay.partner");
|
|
|
|
$data['merno'] = C("sqpay.partner");
|
|
|
|
$data['amount'] = $request['price'];
|
|
|
|
$data['amount'] = $request['price'];
|
|
|
@ -123,7 +145,7 @@ class WapPayController extends BaseController{
|
|
|
|
$data['paymenttype'] = "ZFBZF";
|
|
|
|
$data['paymenttype'] = "ZFBZF";
|
|
|
|
$data['MerRemark'] = "mark";
|
|
|
|
$data['MerRemark'] = "mark";
|
|
|
|
$data['subject'] = "subject";
|
|
|
|
$data['subject'] = "subject";
|
|
|
|
$data['notifyurl'] = "http://".C('pay_header')."/callback.php/Notify/sq_callback";//通知
|
|
|
|
$data['notifyurl'] = C('pay_header')."/callback.php/Notify/sq_callback";//通知
|
|
|
|
$data['returnurl'] = $returl;
|
|
|
|
$data['returnurl'] = $returl;
|
|
|
|
$data['mchAppId'] = "wmtxkj.com";
|
|
|
|
$data['mchAppId'] = "wmtxkj.com";
|
|
|
|
$data['mchAppName'] = "mchAppName";
|
|
|
|
$data['mchAppName'] = "mchAppName";
|
|
|
@ -232,8 +254,9 @@ class WapPayController extends BaseController{
|
|
|
|
if ($payInfo['status'] == 'payed') {
|
|
|
|
if ($payInfo['status'] == 'payed') {
|
|
|
|
$this->error("订单已支付");
|
|
|
|
$this->error("订单已支付");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 发起支付
|
|
|
|
if (IS_POST && $param['smsCode']) {
|
|
|
|
if (IS_POST && $param['smsCode']) {
|
|
|
|
|
|
|
|
echo "发起支付==》".time()."<br>";
|
|
|
|
$rsp = $sqpay->shortcut_pay(array(
|
|
|
|
$rsp = $sqpay->shortcut_pay(array(
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merOrderNo' => $payInfo['order_id'],
|
|
|
|
'merOrderNo' => $payInfo['order_id'],
|
|
|
@ -247,7 +270,7 @@ class WapPayController extends BaseController{
|
|
|
|
'smsCode' => $param['smsCode'],
|
|
|
|
'smsCode' => $param['smsCode'],
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
echo "发起支付==》".time()."<br>";
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
if ($rsp['responseCode'] == '88') {
|
|
|
|
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;
|
|
|
|
redirect(U('Spend/pay_success',array('orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])));exit;
|
|
|
@ -260,6 +283,7 @@ class WapPayController extends BaseController{
|
|
|
|
// 发送短信
|
|
|
|
// 发送短信
|
|
|
|
if (IS_POST && !isset($param['smsCode'])) {
|
|
|
|
if (IS_POST && !isset($param['smsCode'])) {
|
|
|
|
// 查看是否签约
|
|
|
|
// 查看是否签约
|
|
|
|
|
|
|
|
echo "查看是否签约==》".time()."<br>";
|
|
|
|
$rcs = $sqpay->contract_status(array(
|
|
|
|
$rcs = $sqpay->contract_status(array(
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'custName' => $param['custName'],
|
|
|
|
'custName' => $param['custName'],
|
|
|
@ -269,6 +293,7 @@ class WapPayController extends BaseController{
|
|
|
|
'payAmount' => $payInfo['price'],
|
|
|
|
'payAmount' => $payInfo['price'],
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
echo "查看是否签约==》".time()."<br>";
|
|
|
|
if ($rcs['respCode'] == 4) {
|
|
|
|
if ($rcs['respCode'] == 4) {
|
|
|
|
$this->error($rcs['respMessage'], '', true);
|
|
|
|
$this->error($rcs['respMessage'], '', true);
|
|
|
|
pp($rcs);
|
|
|
|
pp($rcs);
|
|
|
@ -276,6 +301,7 @@ class WapPayController extends BaseController{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 调用认证 签约
|
|
|
|
// 调用认证 签约
|
|
|
|
if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) {
|
|
|
|
if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) {
|
|
|
|
|
|
|
|
echo "调用认证 签约==》".time()."<br>";
|
|
|
|
$rsign = $sqpay->sign_contract(array(
|
|
|
|
$rsign = $sqpay->sign_contract(array(
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'custName' => $param['custName'],
|
|
|
|
'custName' => $param['custName'],
|
|
|
@ -287,6 +313,7 @@ class WapPayController extends BaseController{
|
|
|
|
'custType' => '01',
|
|
|
|
'custType' => '01',
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
'secret' => C('sqpay.key'),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
echo "调用认证 签约==》".time()."<br>";
|
|
|
|
if ($rsign['respCode'] == 'success') { // 认证成功 接着签约
|
|
|
|
if ($rsign['respCode'] == 'success') { // 认证成功 接着签约
|
|
|
|
$rauth = $sqpay->sign_contract(array(
|
|
|
|
$rauth = $sqpay->sign_contract(array(
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
@ -310,6 +337,7 @@ class WapPayController extends BaseController{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 无需签约 发送短信
|
|
|
|
// 无需签约 发送短信
|
|
|
|
if ($rcs['respCode'] == 0 || $rcs['respCode'] == 10) {
|
|
|
|
if ($rcs['respCode'] == 0 || $rcs['respCode'] == 10) {
|
|
|
|
|
|
|
|
echo "发送短信==》".time()."<br>";
|
|
|
|
$ret = $sqpay->protocol_pay_send_sms(array(
|
|
|
|
$ret = $sqpay->protocol_pay_send_sms(array(
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'merNo' => C('sqpay.partner'),
|
|
|
|
'custName' => $param['custName'],
|
|
|
|
'custName' => $param['custName'],
|
|
|
@ -322,6 +350,7 @@ class WapPayController extends BaseController{
|
|
|
|
'NotifyURL' => "http://api.wmtxkj.com"."/callback.php?Notify/sq_callback",
|
|
|
|
'NotifyURL' => "http://api.wmtxkj.com"."/callback.php?Notify/sq_callback",
|
|
|
|
'purpose' => 'aaaa'
|
|
|
|
'purpose' => 'aaaa'
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
echo "发送短信==》".time()."<br>";
|
|
|
|
if ($ret['resFlag'] == 'success') {
|
|
|
|
if ($ret['resFlag'] == 'success') {
|
|
|
|
M('pay_info', 'tab_')->where(array(
|
|
|
|
M('pay_info', 'tab_')->where(array(
|
|
|
|
'id' => $payInfo['id'],
|
|
|
|
'id' => $payInfo['id'],
|
|
|
@ -516,9 +545,8 @@ class WapPayController extends BaseController{
|
|
|
|
public function weixin_pay()
|
|
|
|
public function weixin_pay()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
|
|
|
|
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
$request = json_decode(base64_decode(file_get_contents("php://input")), true);
|
|
|
|
|
|
|
|
/* file_put_contents(dirname(__FILE__) . '/weixin_paywap.txt',json_encode($request)); */
|
|
|
|
/* file_put_contents(dirname(__FILE__) . '/weixin_paywap.txt',json_encode($request)); */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($request)) {
|
|
|
|
if (empty($request)) {
|
|
|
|
$this->set_message(1001, "fail", "登录数据不能为空");
|
|
|
|
$this->set_message(1001, "fail", "登录数据不能为空");
|
|
|
@ -545,15 +573,36 @@ class WapPayController extends BaseController{
|
|
|
|
$user = get_user_entity($request['user_id']);
|
|
|
|
$user = get_user_entity($request['user_id']);
|
|
|
|
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
|
|
|
|
$discount = $this->get_discount($request['game_id'],$user['promote_id'],$request['user_id']);
|
|
|
|
$discount = $discount['discount'];
|
|
|
|
$discount = $discount['discount'];
|
|
|
|
|
|
|
|
$discountAmount = 0;
|
|
|
|
if($prefix=='PF_'){
|
|
|
|
if($prefix=='PF_'){
|
|
|
|
$pay_amount = $request['price'];
|
|
|
|
$pay_amount = $request['price'];
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
$pay_amount = $discount * $request['price'] / 10;
|
|
|
|
|
|
|
|
$discountAmount = $request['price'] - $pay_amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!empty($request['scheme'])) {
|
|
|
|
if(!empty($request['scheme'])) {
|
|
|
|
file_put_contents("./Application/Sdk/Scheme/".$request['game_id'].".txt",$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;
|
|
|
|
|
|
|
|
|
|
|
|
$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']
|
|
|
|