身份认证

master
tpingzhang 5 years ago
parent 1afa561d9b
commit 098860c384

@ -12,7 +12,7 @@
* @param sting $idcard 身份证号码 * @param sting $idcard 身份证号码
* @author 鹿文学 * @author 鹿文学
*/ */
function is_adult($idcard) { function is_adult($idcard, $adult=16) {
$id = substr($idcard,6,8); $id = substr($idcard,6,8);
$year = substr($id,0,4); $year = substr($id,0,4);
@ -21,7 +21,7 @@ function is_adult($idcard) {
$old = (time()-strtotime($year.'-'.$month.'-'.$day))/31536000; $old = (time()-strtotime($year.'-'.$month.'-'.$day))/31536000;
if(intval($old)>=16) { if(intval($old)>=$adult) {
return true; return true;
} else { } else {
return false; return false;
@ -29,6 +29,33 @@ function is_adult($idcard) {
} }
/* 支付验证 当前只有未成年
* return: array code 1成功 0失败 msg :错误消息
*/
function pay_check($user_id) {
$ret = array(
'code' => 1,
'msg' => '',
);
$idcard = M("user", "tab_")->where(array('id' => $user_id))->getField("idcard");
if (!$idcard) {
$ret['code'] = 1;
$ret['msg'] = '身份证不存在';
return $ret;
}
if (is_adult($idcard, 18)) {
$ret['code'] = 1;
$ret['msg'] = '';
return $ret;
} else {
$ret['code'] = 0;
$ret['msg'] = '未成年,不能充值!';
return $ret;
}
}
/* //获取支付方式 */ /* //获取支付方式 */
function get_pay_way($id=null) function get_pay_way($id=null)
{ {

@ -12,47 +12,7 @@ use Qiniu\json_decode;
class AppleController extends BaseController{ class AppleController extends BaseController{
/**
* 'MerNo' => $data['merno'],
'Amount'=>$data['amount'],
'BillNo'=>$data['order_no'],
'TranCode'=>"SMZF012",
'PayType'=> "SMZF",
'PaymentType'=> $data['paymenttype'],//"UNION","ZFBZF",
'MerRemark' => 'MerRemark',
'subject' => $data['subject'],
'NotifyURL' => $data['notifyurl'],
'ReturnURL' => $data['returnurl'],
'mchAppId' => $data['mchAppId'],
'mchAppName' => $data['mchAppName'],
'deviceInfo' => $data['deviceInfo'],
'clientIp' => $data['clientIp'],
*/
public function test() {
$sqpay=new Sqpay();
$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['merno'] = C("sqpay.partner");
$data['amount'] = 0.01;
$data['order_no'] = '111111';
$data['paymenttype'] = "ZFBZF";
$data['MerRemark'] = "mark";
$data['subject'] = "subject";
$data['notifyurl'] = C('pay_header')."/callback.php/Notify/sq_callback";//通知
$data['returnurl'] = $returl;
$data['mchAppId'] = "wmtxkj.com";
$data['mchAppName'] = "mchAppName";
$data['deviceInfo'] = "AND_WAP";
$data['clientIp'] = get_client_ip();
$ret = $sqpay->sq_pay($data);
$ret = json_decode($ret, true);
pp($ret);
$json_data['url']=$ret[0]['payHtml'];
echo ($json_data['url']);
exit();
}
/** /**
*ios移动支付 *ios移动支付
*/ */
@ -70,6 +30,11 @@ class AppleController extends BaseController{
if(!is_array(find_uc_account($request['account']))){ if(!is_array(find_uc_account($request['account']))){
$this->set_message(0,"fail","Uc用户暂不支持"); $this->set_message(0,"fail","Uc用户暂不支持");
} }
}
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
$this->set_message(1088, "fail", $payCheck['msg']);
} }
$extend_data = M('spend','tab_')->where(array('extend'=>$request['extend'],'game_id'=>$request['game_id'],'pay_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){
@ -126,9 +91,18 @@ class AppleController extends BaseController{
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt"); $file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
$request = json_decode(think_decrypt($file),true); $request = json_decode(think_decrypt($file),true);
C(api('Config/lists')); C(api('Config/lists'));
if (empty($request)) { if (empty($request)) {
echo json_encode(['code'=>0,'msg'=>'登录数据不能为空']);exit; echo json_encode(['code'=>0,'msg'=>'登录数据不能为空']);exit;
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
echo json_encode(['code'=>0,'msg'=> $payCheck['msg']]);exit;
}
$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){
echo json_encode(['code'=>0,'msg'=>'该游戏暂时无法充值,请联系客服!']);exit; echo json_encode(['code'=>0,'msg'=>'该游戏暂时无法充值,请联系客服!']);exit;
@ -152,7 +126,10 @@ class AppleController extends BaseController{
$request['payway'] = 1; $request['payway'] = 1;
$request['title']=$request['price']; $request['title']=$request['price'];
$request['body']=$request['price']; $request['body']=$request['price'];
$request['callback'] = 'http://'.$_SERVER['HTTP_HOST']. "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
$request['notifyurl'] = 'http://'.$_SERVER['HTTP_HOST']. "/callback.php/Notify/notify/apitype/alipay/method/notify";
$pay_url=$this->pay($request); $pay_url=$this->pay($request);
//echo $pay_url['url'];die;
//redirect($pay_url['url']); //redirect($pay_url['url']);
echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>$pay_url['url'],'wap'=>1]]);exit; echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>$pay_url['url'],'wap'=>1]]);exit;
} else {/* app */ } else {/* app */
@ -339,6 +316,8 @@ class AppleController extends BaseController{
->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(0)
->setCallback($param['callback'])
->setNotifyUrl($param['notifyurl'])
->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'])
@ -366,10 +345,23 @@ class AppleController extends BaseController{
{ {
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt"); $file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
$request = json_decode(think_decrypt($file),true); $request = json_decode(think_decrypt($file),true);
/*$request['user_id'] = 1;
$request['game_id'] = 1;
$request['price'] = 0.01;
$request['extend'] = 21111177;
$request['pay_order_number'] = 21111177;
$request['code'] =1;
*/
if (empty($request)) { if (empty($request)) {
// $this->set_message(0, "fail", "登录数据不能为空"); // $this->set_message(0, "fail", "登录数据不能为空");
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit;
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=> $payCheck['msg'])));exit;
}
C(api('Config/lists')); C(api('Config/lists'));
$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){
@ -400,6 +392,7 @@ class AppleController extends BaseController{
if (get_wx_pay_type() == 0) { if (get_wx_pay_type() == 0) {
$weixn = new Weixin(); $weixn = new Weixin();
$is_pay = json_decode($weixn->weixin_pay("充值", $request['pay_order_number'], $pay_amount, 'MWEB'), true); $is_pay = json_decode($weixn->weixin_pay("充值", $request['pay_order_number'], $pay_amount, 'MWEB'), true);
if($is_pay['status']==1){ if($is_pay['status']==1){
if($request['code']==1){ if($request['code']==1){
$this->add_spend($request,1); $this->add_spend($request,1);
@ -550,6 +543,11 @@ class AppleController extends BaseController{
if (empty($request)) { if (empty($request)) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit;
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>$payCheck['msg'])));exit;
}
$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){
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'该游戏暂时无法充值,请联系客服!')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'该游戏暂时无法充值,请联系客服!')));exit;
@ -628,6 +626,11 @@ class AppleController extends BaseController{
if (empty($request)) { if (empty($request)) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'参数错误')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'参数错误')));exit;
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=> $payCheck['msg'])));exit;
}
C(api('Config/lists')); C(api('Config/lists'));
$user_info = get_user_entity($request['user_id']); $user_info = get_user_entity($request['user_id']);
if($user_info['lock_status'] == 0 || $user_info['check_status'] == 0){ if($user_info['lock_status'] == 0 || $user_info['check_status'] == 0){

@ -836,7 +836,7 @@ class UserController extends BaseController
$request = json_decode(base64_decode(file_get_contents("php://input")), true); $request = json_decode(base64_decode(file_get_contents("php://input")), true);
$user = get_user_entity($request['user_id']); $user = get_user_entity($request['user_id']);
if($user['lock_status'] == 0 || $user['check_status'] == 0){ if($user['lock_status'] == 0 || $user['check_status'] == 0){
$this->set_message(0,"fail","账号被禁用,无法充值,请联系客服!"); $this->set_message(0,"fail","账号被禁用,无法充值,请联系客服!2");
} }
$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){
@ -1981,7 +1981,7 @@ class UserController extends BaseController
$cardd = M('User', 'tab_') -> where(array('idcard' => $data['idcard'])) -> find(); $cardd = M('User', 'tab_') -> where(array('idcard' => $data['idcard'])) -> find();
if ($cardd) { if ($cardd) {
$this -> set_message(1087, "fail", "身份证号码已被使用!"); // $this -> set_message(1087, "fail", "身份证号码已被使用!"); // 去掉身份证唯一验证
} }
@ -1990,9 +1990,9 @@ class UserController extends BaseController
if (C('tool_age.status') == 0) { if (C('tool_age.status') == 0) {
if (is_adult($data['idcard'])) { if (is_adult($data['idcard'])) {
$data['age_status'] = 2; $data['age_status'] = 2; // 成年
} else { } else {
$data['age_status'] = 3; $data['age_status'] = 3; // 未成年
} }
} else { } else {

@ -12,6 +12,7 @@ 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";
$user = get_user_entity($param['user_id']); $user = get_user_entity($param['user_id']);
@ -91,19 +92,23 @@ class WapPayController extends BaseController{
*/ */
public function alipay_pay(){ public function alipay_pay(){
$request = json_decode(base64_decode(file_get_contents("php://input")),true); $request = json_decode(base64_decode(file_get_contents("php://input")),true);
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
$this->set_message(1088, "fail", $payCheck['msg']);
}
file_put_contents(dirname(__FILE__) . '/alipay_paywap.txt',json_encode($request)); file_put_contents(dirname(__FILE__) . '/alipay_paywap.txt',json_encode($request));
C(api('Config/lists')); C(api('Config/lists'));
if (empty($request)) { if (empty($request)) {
$this->set_message(1001, "fail", "登录数据不能为空"); $this->set_message(1001, "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){die('a'); if($game['pay_status'] == 0){
$this->set_message(0,"fail","该游戏暂时无法充值,请联系客服!"); $this->set_message(0,"fail","该游戏暂时无法充值,请联系客服!");
} }
if($request['code'] == 1){ if($request['code'] == 1){
$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){die('a'); if($extend_data){
$this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付"); $this->set_message(1089,"fail","订单号重复,请关闭支付页面重新支付");
} }
} }
@ -256,6 +261,12 @@ Log::write(serialize($request), Log::DEBUG);
$this->error("参数有误", '', true); $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( $payInfo = M('pay_info', 'tab_')->where(array(
'user_id' => $param['user_id'], 'user_id' => $param['user_id'],
'game_id' => $param['game_id'] 'game_id' => $param['game_id']
@ -460,6 +471,11 @@ Log::write(serialize($request), Log::DEBUG);
$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("./Application/Sdk/OrderNo/".$request['user_id']."-".$request['game_id'].".txt",think_encrypt(json_encode($request))); 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']; $user_id = $request['user_id'];
$game_id = $request['game_id']; $game_id = $request['game_id'];
$data = array( $data = array(
@ -483,16 +499,22 @@ Log::write(serialize($request), Log::DEBUG);
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt"); $file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
$request = json_decode(think_decrypt($file),true); $request = json_decode(think_decrypt($file),true);
Log::write(serialize($request), Log::DEBUG); Log::write(serialize($request), Log::DEBUG);
$request['user_id'] = 232; /* $request['user_id'] = 232;
$request['game_id'] = 78; $request['game_id'] = 78;
$request['price'] = 0.02; $request['price'] = 0.02;
$request['code'] = 1; $request['code'] = 1;
$request['extend'] = "SP_522992339581"; $request['extend'] = "SP_522992339581";
$request['pay_order_number'] = "SP_24522992339581"; $request['pay_order_number'] = "SP_24522992339581"; */
if (empty($request)) { if (empty($request)) {
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'登录数据不能为空')));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(); $game = M('Game','tab_')->where(['id'=>$request['game_id']])->field('pay_status')->find();
if($game['pay_status'] == 0){ if($game['pay_status'] == 0){
redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'该游戏暂时无法充值,请联系客服!')));exit; redirect(U('Spend/notice',array('user_id'=>$user_id,'game_id'=>$game_id,'msg'=>'该游戏暂时无法充值,请联系客服!')));exit;
@ -541,11 +563,11 @@ Log::write(serialize($request), Log::DEBUG);
'status' => 'normal', 'status' => 'normal',
'create_time' => time(), 'create_time' => time(),
)); ));
/* 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);
} */ }
} }
$this->assign("pay_amount", $request['actual_amount']); $this->assign("pay_amount", $request['actual_amount']);
@ -566,6 +588,11 @@ Log::write(serialize($request), Log::DEBUG);
if (empty($request)) { if (empty($request)) {
$this->set_message(1001, "fail", "登录数据不能为空"); $this->set_message(1001, "fail", "登录数据不能为空");
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
$this->set_message(1088, "fail", $payCheck['msg']);
}
C(api('Config/lists')); C(api('Config/lists'));
if($request['price']*1<=0){ if($request['price']*1<=0){
$this->set_message(1011,"fail","充值金额有误"); $this->set_message(1011,"fail","充值金额有误");
@ -817,6 +844,12 @@ Log::write(serialize($request), Log::DEBUG);
if (empty($request)) { if (empty($request)) {
$this->set_message(1001, "fail", "登录数据不能为空"); $this->set_message(1001, "fail", "登录数据不能为空");
} }
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
$this->set_message(1088, "fail", $payCheck['msg']);
}
C(api('Config/lists')); C(api('Config/lists'));
if($request['price']<0){ if($request['price']<0){
$this->set_message(1011,"fail","充值金额有误"); $this->set_message(1011,"fail","充值金额有误");
@ -860,6 +893,12 @@ Log::write(serialize($request), Log::DEBUG);
$request['extend'] = "11212452299229"; $request['extend'] = "11212452299229";
$request['pay_order_number'] = "11212452299229"; */ $request['pay_order_number'] = "11212452299229"; */
// 支付验证 是否让支付
$payCheck = pay_check($request['user_id']);
if (!$payCheck['code']) {
$this->set_message(1088, "fail", $payCheck['msg']);
}
if (empty($request)) { if (empty($request)) {
$this->set_message(1001, "fail","登录数据不能为空"); $this->set_message(1001, "fail","登录数据不能为空");
} }

Loading…
Cancel
Save