"; 发送短信 $rsign = $sqpay->sign_contract(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'reqMsgId' => date('YmdHis').rand(0, 9999), 'authMsg' => '', 'custType' => '01', // 认证 发短信 'secret' => C('sqpay.key'), )); //echo "调用认证 签约==》".time()."
"; if ($rsign['respCode'] == 'success') { // 认证成功发送短信 $this->success('签约短信发送成功', '', true); } else { if (strlen($rsign['respMessage']) > 100) { $this->error('填写信息有误,请核对!', '', true); } else { $this->error($rsign['respMessage'], '', true); } } // var_dump($rsign); exit(); } if (IS_POST && $param['signCode']) { $rauth = $sqpay->sign_contract(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'reqMsgId' => date('YmdHis').rand(0, 9999), 'authMsg' => $param['signCode'], 'custType' => '02', // 签约 'secret' => C('sqpay.key'), )); if ($rauth['respCode'] == 'success') { // 签约成功 $this->success('签约成功', '', true); $signContract = true; } else { $this->error($rauth['respMessage'], '', true); } } } /**\ * 快捷支付'merNo' => $data['merNo'], 'merOrderNo' => $data['merOrderNo'], 'cardNo' => $data['cardNo'], 'custName' => $data['custName'], 'idType' => '0', 'idNo' => $data['idNo'], 'phone' => $data['phoneNo'], 'purpose' => $data['purpose'], 'payAmount' => $data['payAmount'], 'bankCode' => $bankInfo['bank'], 'payType' => 'XYPAY', 'NotifyURL' => $data['NotifyURL'], 'txnTime' => $data['txnTime'], 'smsCode' => $data['smsCode'], */ public function shortcut_pay() { $sqpay = new Sqpay(); $param = I("request."); $signContract = false; // 签约标记 if (!$param['user_id'] || !$param['game_id']) { $this->error("参数有误", '', true); } // 支付验证 是否让支付 $payCheck = pay_check($param['user_id']); if (!$payCheck['code']) { $this->set_message(1088, "fail", $payCheck['msg']); } $payInfo = M('pay_info', 'tab_')->where(array( 'user_id' => $param['user_id'], 'game_id' => $param['game_id'], 'extend' => $param['extend'] ))->order('id desc')->find(); // $info = json_decode($payInfo['info'], true); if ($payInfo['type'] == 'sq_shortcut') { $spend = M('spend', 'tab_')->where([ 'pay_order_number' => $payInfo['order_id'] ])->find(); $orderPrice = $spend['pay_amount']; } else { $deposit = M('deposit', 'tab_')->where([ 'pay_order_number' => $payInfo['order_id'] ])->find(); $orderPrice = $deposit['pay_amount']; } if ($orderPrice != $payInfo['price']) { $this->error($orderPrice."数据有误.".$payInfo['price'], '', true); } if ($payInfo['type'] == 'sq_shortcut_platform' && $payInfo['price'] < 1) { $this->error("数据有误", '', true); } if ($payInfo['status'] == 'payed') { $this->error("订单已支付"); } // 发起支付 if (IS_POST && $param['smsCode']) { //echo "发起支付==》".time()."
"; $rsp = $sqpay->shortcut_pay(array( 'merNo' => C('sqpay.partner'), 'merOrderNo' => $payInfo['order_id'], 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'purpose' => 'purpose', 'payAmount' => $payInfo['price'], 'txnTime' => $payInfo['txnTime'], 'smsCode' => $param['smsCode'], 'secret' => C('sqpay.key'), 'NotifyURL' => C('PAY_DOMAIN')."/callback.php/Notify/sq_callback",//通知 )); //echo "发起支付==》".time()."
"; if ($rsp['responseCode'] == '88') { // sleep(5); echo json_encode([ 'status' => 1, 'info' => '请求成功', 'url' => U('Spend/shortcut_notice',array('status'=> 1, 'orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])), ]); exit(); // redirect(U('Spend/shortcut_notice',array('status'=> 1, 'orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])));exit; } else { // 支付失败 echo json_encode([ 'status' => 0, 'info' => $rsp['resMess'] ]); exit(); // redirect(U('Spend/pay_success',array('status'=> 0, 'orderno' => $payInfo['order_id'], 'user_id'=>$param['user_id'],'game_id'=>$param['game_id'])));exit; } } // 发送短信 if (IS_POST && !isset($param['smsCode'])) { // 查看是否签约 //echo "查看是否签约==》".time()."
"; $rcs = $sqpay->contract_status(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'payAmount' => $payInfo['price'], 'secret' => C('sqpay.key'), )); // pp($rcs); //echo "查看是否签约==》".time()."
"; if ($rcs['respCode'] == 4) { $this->error($rcs['respMessage'], '', true); pp($rcs); pp($rcs['respMessage']); } if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) { echo json_encode([ 'status' => 2, // 'info' => '未签约' ]); exit(); } /* // 调用认证 签约 6222031402001028203 500236199608024075 if ($rcs['respCode'] == 1 || $rcs['respCode'] == 2 || $rcs['respCode'] == 3) { //echo "调用认证 签约==》".time()."
"; 发送短信 $rsign = $sqpay->sign_contract(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'reqMsgId' => date('YmdHis').rand(0, 9999), 'authMsg' => 'ok', 'custType' => '01', 'secret' => C('sqpay.key'), )); //echo "调用认证 签约==》".time()."
"; if ($rsign['respCode'] == 'success') { // 认证成功 接着签约 $rauth = $sqpay->sign_contract(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'], 'idNo' => $param['idNo'], 'reqMsgId' => date('YmdHis').rand(0, 9999), 'authMsg' => $rsign['authMsg'], 'custType' => '02', 'secret' => C('sqpay.key'), )); pp($rauth); if ($rauth['respCode'] == 'success') { $signContract = true; } else { $this->error($rauth['respMessage'], '', true); } } else { $this->error($r['respMessage'], '', true); } }*/ // 无需签约 发送短信 if ($rcs['respCode'] == 0 || $rcs['respCode'] == 10) { //echo "发送短信==》".time()."
"; $ret = $sqpay->protocol_pay_send_sms(array( 'merNo' => C('sqpay.partner'), 'custName' => $param['custName'], 'phoneNo' => $param['phoneNo'], 'cardNo' => $param['cardNo'],//'6214855913999401', 'idNo' => $param['idNo'], 'payAmount' => $payInfo['price'], 'secret' => C('sqpay.key'), 'merOrderNo' => $payInfo['order_id'], 'NotifyURL' => "http://api.wmtxkj.cn"."/callback.php?Notify/sq_callback", 'purpose' => '游戏充值' )); //echo "发送短信==》".time()."
"; if ($ret['resFlag'] == 'success') { M('pay_info', 'tab_')->where(array( 'id' => $payInfo['id'], ))->save(array( 'txn_time' => $ret['txnTime'] )); $this->success('发送成功', '', true); } else { $this->error($ret['resMess'], '', true); } } } $this->display(); } /** * android获取 支付url */ public function android_shortcut_pay() { $request = json_decode(base64_decode(file_get_contents("php://input")), true); file_put_contents("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request))); // 支付验证 是否让支付 $payCheck = pay_check($request['user_id']); if (!$payCheck['code']) { $this->set_message(1088, "fail", $payCheck['msg']); } $user_id = $request['user_id']; $game_id = $request['game_id']; $data = array( 'status' => 200, "url" => 'http://' . $_SERVER ['HTTP_HOST'] ."/sdk.php/WapPay/wap_shortcut_pay/user_id/{$user_id}/game_id/{$game_id}", "html" => '', "return_msg" => '', "paytype" => 'shortcut', ); echo base64_encode(json_encode($data)); exit(); } /** * 快捷支付 用户点击 */ public function wap_shortcut_pay($user_id,$game_id) { // $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); $is_platform = 0; if (I('request.code') == 0 && I('request.type') == 'platform') { $is_platform = 1; // 平台币充值 } $prefix = ($is_platform == 1) ? 'PF_' : 'SP_'; $request['pay_order_number'] = $prefix . date('Ymd') . date('His') . sp_random_string(4); $request['game_id'] = I('request.game_id'); $game_id = $request['game_id']; $request['user_id'] = I('request.user_id'); $user_id = $request['user_id']; $request['code'] = I('request.code'); if ($is_platform) { $request['price'] = I('request.price'); } else { $payInfo = M('pay_info', 'tab_')->where([ 'user_id' => I('user_id'), 'game_id' => I('game_id'), 'extend' => I('extend'), ])->order('id desc')->find(); $request['price'] = $payInfo['price']; } $userToken = I('request.user_token'); /* $request['user_id'] = 232; $request['game_id'] = 78; $request['price'] = 0.02; $request['code'] = 1; $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,'is_platform'=> $is_platform,'msg'=>'登录数据不能为空', 'user_token' => $userToken)));exit; } // 支付验证 是否让支付 $payCheck = pay_check($request['user_id']); if (!$payCheck['code']) { $this->set_message(1088, "fail", $payCheck['msg']); } $game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find(); if($game['pay_status'] == 0){ redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'is_platform'=> $is_platform,'msg'=>'该游戏暂时无法充值,请联系客服!', 'user_token' => $userToken)));exit; } if($request['price']*1<=0){ redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'is_platform'=> $is_platform,'msg'=>'充值金额有误', 'user_token' => $userToken)));exit; } C(api('Config/lists')); if (!$is_platform) { $request['extend'] = I('request.extend'); $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,'is_platform'=> $is_platform,'msg'=>$request['game_id'].'订单号重复,请关闭支付页面重新支付'.$request['extend'], 'user_token' => $userToken)));exit; } } //折扣 $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; if ($pay_amount < 0.01) { redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'is_platform'=> $is_platform, 'msg'=>'充值金额有误.'.$pay_amount, 'user_token' => $userToken)));exit; } if (!$is_platform) { $this->other_price($request, $request['price']-$pay_amount); } // 平台币充值 if ($is_platform) { $request['code'] = 0; $request['user_id'] = I('request.user_id'); $request['price'] = intval(I('request.price')); $request['game_id'] = I('request.game_id'); $type = "platform"; $request['pay_way'] = C("PAY_WAY.SQ_SHORTCUT"); // 支付方式(-1绑币 0:平台币,1:支付宝,2:微信(扫码)3微信app 4 威富通 5聚宝云 6竣付通 7苹果支付8金猪支付 9双乾支付-支付宝 10双乾支付-银联 15双乾支付-快捷 $request['pay_status'] = 0; $request['spend_ip'] = get_client_ip(); $out_trade_no = $request['pay_order_number']; $ret = M('pay_info', 'tab_')->add(array( 'user_id' => $request['user_id'], 'game_id' => $request['game_id'], 'order_id' => $request['pay_order_number'], 'extend' => $request['pay_order_number'], 'price' => $request['price'], 'type' => 'sq_shortcut_platform', // 平台币充值 'info' => json_encode($request), 'status' => 'normal', 'create_time' => time(), )); if (!$ret) { return ; } } else { // 游戏充值 $request['code'] = 1; $payInfo = M('pay_info', 'tab_')->where([ 'user_id' => I('user_id'), 'game_id' => I('game_id'), 'extend' => I('extend'), ])->order('id desc')->find(); if ($payInfo) { $info = json_decode($payInfo['info'], true); $info['deduction_amount'] = $request['deduction_amount']; $info['actual_amount'] = $request['actual_amount']; $info['discount_amount'] = $request['discount_amount']; $info['price'] = $request['price']; $infosave = json_encode($info); M('pay_info', 'tab_')->where([ 'id' => $payInfo['id'] ])->save([ 'type' => 'sq_shortcut', // 游戏充值 'order_id' => $request['pay_order_number'], 'price' => $request['actual_amount'] ? $request['actual_amount'] : $request['price'], 'info' => $infosave ]); $info['code'] = $request['code']; $info['pay_order_number'] = $request['pay_order_number']; $request = $info; $request['pay_way'] = C("PAY_WAY.SQ_SHORTCUT"); $request['pay_status'] = 0; $request['spend_ip'] = get_client_ip(); } } //0 官方 1双乾 if (get_shortcut_pay_type() == 0) { // 暂时只有双乾 }elseif(get_shortcut_pay_type() == 1){ if($request['code']==1){ $this->add_spend($request,1); }else{ $this->add_deposit($request,1); } } $this->assign("pay_amount", $request['actual_amount']?$request['actual_amount']:$request['price']); $this->assign("user_id", $request['user_id']); $this->assign("game_id", $request['game_id']); $this->assign("extend", $is_platform ? $request['pay_order_number'] : I('extend')); $this->display(); } }