diff --git a/Application/Admin/Model/UserModel.class.php b/Application/Admin/Model/UserModel.class.php index 54364aaa..12597eda 100644 --- a/Application/Admin/Model/UserModel.class.php +++ b/Application/Admin/Model/UserModel.class.php @@ -1097,9 +1097,31 @@ class UserModel extends Model{ $data["last_login_ip"] = $user['login_ip']; $data["last_device_number"] = $user['device_number']; $data["token"] = $this->generateToken($uid,$account,$password); - if (!$user['user_token']) { - $data["user_token"] = $this->generateToken($uid,$account,$password); + + $userToken = $this->generateToken($uid,$account,$password); + $userTokens = M('user_token','tab_')->where([ + 'user_id' => $uid, + 'game_id' => $game_id + ])->find(); + if (!$userTokens) { + M('user_token', 'tab_')->add([ + 'user_id' => $uid, + 'game_id' => $game_id, + 'user_token' => $userToken, + 'login_cnt' => 0, + 'create_time' => time(), + 'update_time' => time() + ]); + } else { + M('user_token', 'tab_')->where([ + 'id' => $userTokens['id'] + ])->save([ + 'user_token' => $userToken, + 'login_cnt' => $userTokens['login_cnt'] + 1, + 'update_time' => time() + ]); } + if($user_fgame_id){ $model->save($data); }else{ diff --git a/Application/Sdk/Controller/BaseController.class.php b/Application/Sdk/Controller/BaseController.class.php index bffe1d66..3e03d0b6 100644 --- a/Application/Sdk/Controller/BaseController.class.php +++ b/Application/Sdk/Controller/BaseController.class.php @@ -10,9 +10,9 @@ class BaseController extends RestController{ 'Apple.apple_alipay_pay','Apple.apple_weixin_pay','User.get_alipay_zmxy_return', 'Apple.apple_platform_pay','Spend.notice','Apple.apple_union_pay','WapPay.wap_shortcut_pay', 'WapPay.shortcut_pay','WapPay.android_shortcut_pay','WapPay.wap_shortcut_pay','WapPay.wap_shortcut_pay', - 'Apple.apple_weixin_pay','Ipa365','User.user_login','platform_coin_deduction','get_user_money', - 'file_pay','pay','GameGiftPage','UserH', 'PayH5','init_sdk','sign_contract', 'Apple' -// 'test','Game.get_suspend', + 'Apple.apple_weixin_pay','Ipa365','User.user_login','user_register','platform_coin_deduction','get_user_money', + 'file_pay','pay','GameGiftPage','UserH', 'PayH5','init_sdk','sign_contract', 'Apple','Shortcut' +// 'test','Game.get_suspend', ]; // 不需要验证TOKEN的接口 @@ -34,13 +34,24 @@ class BaseController extends RestController{ $a = ACTION_NAME; $data = json_decode ( base64_decode ( file_get_contents ( "php://input" ) ), true ); - if (!(in_array($c, $this->noNeedGame) || in_array($a, $this->noNeedGame) || in_array($c.".".$a, $this->noNeedGame))) { - // 解决在游戏中未退出的用户 user_token 不存在问题 - $userToken = M('user', 'tab_')->where(['id' => $data['user_id']])->getField('user_token'); - if (!$userToken) { - $str = $data['user_id'].NOW_TIME.sp_random_string(7); - $userToken = MD5($str); - M('user', 'tab_')->where(['id' => $data['user_id']])->save(['user_token' => $userToken]); + if (!(in_array($c, $this->noNeedGame) + || in_array($a, $this->noNeedGame) + || in_array($c.".".$a, $this->noNeedGame))) { + if ($data['api_ver'] == 2) { + $userToken = M('user_token', 'tab_')->where([ + 'user_id' => $data['user_id'], + 'game_id' => $data['game_id'] + ])->getField('user_token'); + if (!$userToken || $userToken != $data['user_token']) { + echo base64_encode (json_encode(array( + "code" => 9999, + "msg" => $data['user_token']."您已下线,请重新登入".$userToken, + "return_msg" => $data['user_token']."您已下线,请重新登入".$userToken, + "data" => "" + ))); + exit (); + // 退出 + } } $this->userToken = $userToken; @@ -49,11 +60,11 @@ class BaseController extends RestController{ */ // #判断数据是否为空 if (empty ( $data ) || empty ( $data ['game_id'] )) { - echo base64_encode ( json_encode ( array ( - "status" => 10, - "return_msg" => "操作数据或游戏ID不能为空" - ) ) ); - exit (); + echo base64_encode (json_encode(array( + "status" => 10, + "return_msg" => "操作数据或游戏ID不能为空" + ))); + exit(); } /* if (!$data['timestamp'] || !$data['nonce']) { @@ -82,21 +93,51 @@ class BaseController extends RestController{ } - if (!(in_array($c, $this->noNeedToken) || in_array($a, $this->noNeedToken) || in_array($c.".".$a, $this->noNeedToken))) { - $userToken = I("request.user_token"); - if (!$userToken) { - re_msg(11, "参数有误,请重新登入获取!"); - } - - $this->userId = M("user", "tab_")->where(['user_token' => $userToken])->getField("id"); - $this->userToken = $userToken; - if (!$this->userId) { - re_msg(12, $userToken."Token失效"); - } - + if (I('request.api_ver') == 2) { + if (!(in_array($c, $this->noNeedToken) || in_array($a, $this->noNeedToken) || in_array($c.".".$a, $this->noNeedToken))) { + $user = self::webH5Vetify(); + $this->userId = $user['userId']; + $this->userToken = $user['userToken']; + } } } + + public static function webH5Vetify() { + $userToken = I("request.user_token"); + if (!$userToken) { + echo "token not found!!!"; + die(); + // re_msg(11, "参数有误,请重新登入获取!"); + } + + $where['user_token'] = $userToken; + if (I("request.game_id", 0)) { + $where['game_id'] = I("request.game_id"); + } + if (I("request.user_id", 0)) { + $where['user_id'] = I("request.user_id"); + } + + $user = []; + $user['userId'] = M("user_token", "tab_")->where($where)->getField("user_id"); + $user['userToken'] = $userToken; + if (!$user['userId']) { + if (IS_AJAX) { + echo json_encode([ + 'code' => 200, + 'url' => U('Spend/notice_logout',array('user_id'=>$user['userId'],'game_id'=>I("request.game_id", 0),'msg'=>'您已下线', 'user_token' => $userToken)) + ]); + exit(); + } else { + redirect(U('Spend/notice_logout',array('user_id'=>$user['userId'],'game_id'=>I("request.game_id", 0),'msg'=>'您已下线', 'user_token' => $userToken))); + exit; + } + + // re_msg(12, $userToken."Token失效"); + } + return $user; + } /** * 获取数据库中的配置列表 diff --git a/Application/Sdk/Controller/ExchangeController.class.php b/Application/Sdk/Controller/ExchangeController.class.php index f0836bf8..3c3f3ce9 100644 --- a/Application/Sdk/Controller/ExchangeController.class.php +++ b/Application/Sdk/Controller/ExchangeController.class.php @@ -52,7 +52,8 @@ class ExchangeController extends BaseController{ } // 用户 - $userToken = M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token'); + $userToken = $request['user_token']; +// M('user', 'tab_')->where(['id' => $request['user_id']])->getField('user_token'); if (!$userToken) { $this->set_message(0,"fail","请重新登入"); } diff --git a/Application/Sdk/Controller/GameController.class.php b/Application/Sdk/Controller/GameController.class.php index 65ae8574..29e2915b 100644 --- a/Application/Sdk/Controller/GameController.class.php +++ b/Application/Sdk/Controller/GameController.class.php @@ -157,10 +157,13 @@ class GameController extends BaseController{ if(empty($data['user_id'])) { re_msg(1004, 'fail', '用户不存在'); } + $user = M('user','tab_')->field('user_token,balance')->where(['id' => $data['user_id']])->find(); + $user['user_token'] = $data['user_token']; if (!$user['user_token']) { re_msg(1004, 'fail', '数据有误'); - } + } + $sdkMenus = M('tool','tab_')->where(['name' => 'sdk_menu'])->find(); $menus = json_decode($sdkMenus['config'],true); foreach($menus as $k => $v) { diff --git a/Application/Sdk/Controller/GameGiftPageController.class.php b/Application/Sdk/Controller/GameGiftPageController.class.php index f2058cda..abbfaf37 100644 --- a/Application/Sdk/Controller/GameGiftPageController.class.php +++ b/Application/Sdk/Controller/GameGiftPageController.class.php @@ -2,21 +2,15 @@ namespace Sdk\Controller; use Think\Controller; use Common\Api\GaemApi; + class GameGiftPageController extends Controller{ public $userId; public function _initialize() { - $userToken = I("request.user_token"); - if (!$userToken) { - re_msg(11, "参数有误,请重新登入获取!"); - } - - $this->userId = M("user", "tab_")->where(['user_token' => $userToken])->getField("id"); - $this->userToken = $userToken; - if (!$this->userId) { - re_msg(12, $userToken."Token失效"); - } +// if (I("request.api_ver") == 2) { + BaseController::webH5Vetify(); +// } } public function gift_list(){ $gameId = I('game_id'); @@ -24,9 +18,9 @@ class GameGiftPageController extends Controller{ if (!$gameId || $sdkVersion == -1) { $this->error("参数有误"); } - if (I("debug") == 1) { +/* if (I("debug") == 1) { $data['user_token'] = 'b9c9739f7e3dc0b338dc3f4a4f02cb29'; - } + } */ $gift = M("Giftbag","tab_"); $map['game_id'] = $gameId; diff --git a/Application/Sdk/Controller/ShortcutController.class.php b/Application/Sdk/Controller/ShortcutController.class.php new file mode 100644 index 00000000..2d5a3c02 --- /dev/null +++ b/Application/Sdk/Controller/ShortcutController.class.php @@ -0,0 +1,450 @@ +"; 发送短信 + $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(); + } + + +} \ No newline at end of file diff --git a/Application/Sdk/Controller/SpendController.class.php b/Application/Sdk/Controller/SpendController.class.php index 1eac887d..71cb9e57 100644 --- a/Application/Sdk/Controller/SpendController.class.php +++ b/Application/Sdk/Controller/SpendController.class.php @@ -51,9 +51,13 @@ class SpendController extends Controller { echo "access deny!"; die(); } - $userId = M('user', 'tab_')->where(['user_token'=>$user_token])->getField('id'); - if ($userId != $user_id) { - echo "请重新登入!"; + $userId = M('user_token', 'tab_')->where([ + 'user_token'=>$user_token, + 'user_id' => $user_id, + 'game_id' => $game_id + ])->getField('id'); + if (!$userId) { + echo $user_token."请重新登入!".$user_id.$game_id; die(); } C(BaseController::get_tool()); @@ -392,6 +396,7 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`; exit(); } + // 快捷支付通知 public function shortcut_notice() { $status = $_GET['status']; $orderno = $_GET ['orderno'] == "" ? $_GET ['out_trade_no'] : $_GET ['orderno']; @@ -419,4 +424,9 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`; } + // 通知下线 + public function notice_logout() { + $this->display(); + } + } diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index e95ce83c..81a0e8ff 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -304,6 +304,11 @@ class UserController extends BaseController $buddies_request = get_buddies_unagree_count($user['user_id']); $unread_count += $buddies_request; M('nearby', 'tab_') -> where(['user_id' => $user['user_id']]) -> setField(['game_status' => 1, 'update_time' => time(), 'user_nickname' => $user_res['nickname'], 'head_img' => $user_res['head_img']]); + + $userToken = M('user_token', 'tab_') ->where([ + 'user_id' => $user['user_id'], + 'game_id' => $user['game_id'] + ])->getField('user_token'); $res_msg = array( "status" => 200, "return_code" => "success", @@ -314,7 +319,7 @@ class UserController extends BaseController "sex" => $user_res["sex"] ? $user_res["sex"] : 0, "is_platform" => $platform, "token" => $result['token'], - "user_token" => $user_res['user_token'], + "user_token" => $userToken, "OTP_token" => think_encrypt(json_encode(array('uid' => $user["user_id"], 'time' => time())), 1), 'is_uc' => 0, "is_open_small_account" => C('IS_OPEN_SMALL_ACCOUNT'), @@ -954,7 +959,7 @@ class UserController extends BaseController $this -> new_set_message(1027, "密码必须6-15位字母和数字组合"); } */ if(!preg_match('/^[0-9a-zA-Z]{6,15}$/', $user['password'])){ - $this -> set_message(1027, "fail", "密码6-15位字母或数字"); + $this -> new_set_message(1027, "fail", "密码6-15位字母或数字"); } if ($user['old_password'] == $user['password']) { diff --git a/Application/Sdk/Controller/UserHController.class.php b/Application/Sdk/Controller/UserHController.class.php index d038ae9c..8239a029 100644 --- a/Application/Sdk/Controller/UserHController.class.php +++ b/Application/Sdk/Controller/UserHController.class.php @@ -7,21 +7,13 @@ use Think\Log; class UserHController extends Controller { - - public $userId; + public $userToken; public function _initialize() { - $userToken = I("request.user_token"); - if (!$userToken) { - re_msg(11, "参数有误,请重新登入获取!"); - } - - $this->userId = M("user", "tab_")->where(['user_token' => $userToken])->getField("id"); - $this->userToken = $userToken; - if (!$this->userId) { - re_msg(12, $userToken."Token失效"); - } + $user = BaseController::webH5Vetify(); + $this->userId = $user['userId']; + $this->userToken = $user['userToken']; } @@ -33,7 +25,7 @@ class UserHController extends Controller { $data['user_token'] = I('user_token'); - $user_info = M('user','tab_')->where(['user_token' => $data['user_token']])->field('id,account,balance')->find(); + $user_info = M('user','tab_')->where(['id' => $this->userId])->field('id,account,balance')->find(); $user_play = M('user_play','tab_')->alias('user') ->join('tab_game as game on user.game_id = game.id') diff --git a/Application/Sdk/View/default/WapPay/wap_shortcut_pay.html b/Application/Sdk/View/default/Shortcut/wap_shortcut_pay.html similarity index 98% rename from Application/Sdk/View/default/WapPay/wap_shortcut_pay.html rename to Application/Sdk/View/default/Shortcut/wap_shortcut_pay.html index 0693de76..5ed3a182 100644 --- a/Application/Sdk/View/default/WapPay/wap_shortcut_pay.html +++ b/Application/Sdk/View/default/Shortcut/wap_shortcut_pay.html @@ -254,7 +254,7 @@

支付结果将在一分钟内反馈,请稍后在游戏内查看

-
+ @@ -350,7 +350,7 @@ //获取短信验证码 $.ajax({ type: "POST", - url: "/sdk.php/WapPay/shortcut_pay", + url: "/sdk.php/Shortcut/shortcut_pay", dataType:'json', data: { 'user_id' : $("#user_id").val(), @@ -420,7 +420,7 @@ //获取短信验证码 $.ajax({ type: "POST", - url: "/sdk.php/WapPay/sign_contract", + url: "/sdk.php/Shortcut/sign_contract", dataType:'json', data: { 'user_id' : $("#user_id").val(), @@ -478,7 +478,7 @@ } $.ajax({ type: "POST", - url: "/sdk.php/WapPay/sign_contract", + url: "/sdk.php/Shortcut/sign_contract", dataType:'json', data: { 'user_id' : $("#user_id").val(), @@ -543,7 +543,7 @@ $.ajax({ type: "POST", dataType: "json", - url: "{:U('WapPay/shortcut_pay')}" , + url: "{:U('Shortcut/shortcut_pay')}" , data: $('#wfform').serialize(), success: function (result) { btnpay = false; diff --git a/Application/Sdk/View/default/Spend/notice_logout.html b/Application/Sdk/View/default/Spend/notice_logout.html new file mode 100644 index 00000000..b04c9206 --- /dev/null +++ b/Application/Sdk/View/default/Spend/notice_logout.html @@ -0,0 +1,34 @@ + + + + + + + +您已下线 + + + + + + + + + + + + + diff --git a/Application/Sdk/View/default/Spend/pay_way.html b/Application/Sdk/View/default/Spend/pay_way.html index 4d86d7c2..f1029388 100644 --- a/Application/Sdk/View/default/Spend/pay_way.html +++ b/Application/Sdk/View/default/Spend/pay_way.html @@ -163,7 +163,7 @@
- +