超级签充值流程修改

master
zhengchanglong 5 years ago
parent e2fc2e5128
commit 5f5be5d57e

@ -118,11 +118,22 @@ class Ipa365Controller extends BaseController{
'id' => $gameId,
))->find();
$this->assign("price", self::signprice);
//$this->assign("order_id", $orderId);
$this->assign("game_id",$gameId);
$this->assign("game_name",$gameInfo['game_name']);
$this->display('pay');
$payLog = M('game_supersign', 'tab_')->where(array(
'user_id' => $userId,
'game_id' => $gameId
))->find();
if($payLog && $payLog['pay_status']==1){
$this->assign("msg","亲~您已购买过了~请到【订单查询】查看订单信息哟~");
$this->display('blank');
}else{
$this->assign("price", self::signprice);
//$this->assign("order_id", $orderId);
$this->assign("game_id",$gameId);
$this->assign("game_name",$gameInfo['game_name']);
$this->display('pay');
}
}
@ -155,13 +166,15 @@ class Ipa365Controller extends BaseController{
if ($payLog && $payLog['pay_status']==0) {
$orderId = $payLog['order_id'];
}elseif ($payLog && $payLog['pay_status']==1){
$orderId = $payLog['order_id'];
/*$orderId = $payLog['order_id'];
if(stripos($_SERVER['HTTP_HOST'], '.wmtxkj.cn') || $_SERVER['HTTP_HOST']=='127.0.0.1' || stripos($_SERVER['HTTP_HOST'], '.free.idcfengye.com')){
redirect("http://".$_SERVER['HTTP_HOST']."/sdk.php/Ipa365/install_show/user_id/$userId/game_id/$gameId/order_id/$orderId");
}else{
redirect("https://".$_SERVER['HTTP_HOST']."/sdk.php/Ipa365/install_show/user_id/$userId/game_id/$gameId/order_id/$orderId");
}
$this->error("亲~您已购买过了~请到【订单查询】查看订单信息哟~");
}*/
$this->assign("msg","亲~您已购买过了~请到【订单查询】查看订单信息哟~");
$this->display('blank');
//$this->error("亲~您已购买过了~请到【订单查询】查看订单信息哟~");
} else {
$orderId = "SS_" . date('Ymd') . date('His') . sp_random_string(4); // 超级签
if (!$gameInfo['supersign_token']) {
@ -380,200 +393,200 @@ class Ipa365Controller extends BaseController{
* 下载页面 判断订单是否支付成功
*/
public function install_show() {
$orderId = I('order_id', 0);
$gameId = I('game_id', 0);
/* $userId = I('user_id', 0);
$user = M('user', 'tab_')->where(array(
'id' => $userId
))->find(); */
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
$orderId = I('order_id', 0);
$gameId = I('game_id', 0);
/* $userId = I('user_id', 0);
$user = M('user', 'tab_')->where(array(
'id' => $userId
))->find(); */
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
// $userId = $_SESSION['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
if (!$orderId || !$gameId || !$userId) {
$this->error("参数校验失败,请重试");
}
$supersign = M('game_supersign', 'tab_')->where(array('order_id' => $orderId,"game_id"=>$gameId))->find();
if (!$supersign) {
$this->error("订单不存在");
}
if ($supersign['pay_status'] != 1) {
$this->error("订单未支付");
}
$game = M('game', 'tab_')->where(array('id' => $gameId))->find();
$this->assign('game', $game);
$this->assign('url', U('Ipa365/install', array(
'order_id' => $orderId,
'user_id' => $userId,
'game_id' => $gameId
)));
//获取礼包码
$giftbag = M('giftbag', 'tab_')->field("*")->where(array("game_id"=>$gameId,"giftbag_version"=>3))->find();
if(empty($giftbag)){
$giftbag = false;
}else{
$desribe = $giftbag['desribe'];
$mygif = $this->checkAccountGiftExist($userId,$giftbag['id']);
if(!empty($mygif)){
//已经领取
$giftbag =$mygif;
}else{
if($giftbag['novice_num']>0){
//领取
$giftbag = $this->getNovice($userId,$this->userinfo['account'],$giftbag['id']);
}
}
$giftbag['desribe'] = $desribe;
}
//验证是否领取
$this->assign('giftbag', $giftbag);
$this->display();
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
if (!$orderId || !$gameId || !$userId) {
$this->error("参数校验失败,请重试");
}
$supersign = M('game_supersign', 'tab_')->where(array('order_id' => $orderId,"game_id"=>$gameId))->find();
if (!$supersign) {
$this->error("订单不存在");
}
if ($supersign['pay_status'] != 1) {
$this->error("订单未支付");
}
$game = M('game', 'tab_')->where(array('id' => $gameId))->find();
$this->assign('game', $game);
$this->assign('url', U('Ipa365/install', array(
'order_id' => $orderId,
'user_id' => $userId,
'game_id' => $gameId
)));
//获取礼包码
$giftbag = M('giftbag', 'tab_')->field("*")->where(array("game_id"=>$gameId,"giftbag_version"=>3))->find();
if(empty($giftbag)){
$giftbag = false;
}else{
$desribe = $giftbag['desribe'];
$mygif = $this->checkAccountGiftExist($userId,$giftbag['id']);
if(!empty($mygif)){
//已经领取
$giftbag =$mygif;
}else{
if($giftbag['novice_num']>0){
//领取
$giftbag = $this->getNovice($userId,$this->userinfo['account'],$giftbag['id']);
}
}
$giftbag['desribe'] = $desribe;
}
//验证是否领取
$this->assign('giftbag', $giftbag);
$this->display();
}
/**
* 获取用户安装历史url
*/
public function get_install_list() {
/* $gameId = I('game_id', 0);
$where = array(
'pay_status' => 1,
'ticket' => array('neq', '')
);
if ($id) $where['game_id'] = $gameId;
$list = M('game_supersign', 'tab_')->where($where)->select();
/* $gameId = I('game_id', 0);
$where = array(
'pay_status' => 1,
'ticket' => array('neq', '')
);
if ($id) $where['game_id'] = $gameId;
$list = M('game_supersign', 'tab_')->where($where)->select();
// pp($list);
$url = $game['supersign_url']."?code={$code}";
pp($url);
redirect($url); */
$url = $game['supersign_url']."?code={$code}";
pp($url);
redirect($url); */
}
/**
* 用户点击安装
*/
public function install() {
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
$gameId = I('game_id', 0);
$orderId = I('order_id', 0);
if (!$userId || !$gameId || !$orderId) {
$this->error("参数有误!");
}
M()->startTrans();
// 获取支付记录
$gamesign = M('game_supersign', 'tab_')->where(array(
'order_id' => $orderId,
'user_id' => $userId,
'game_id' => $gameId,
'pay_status' => 1,
))->find();
if (!$gamesign) {
// pp(M('game_supersign', 'tab_')->_sql());
$this->error("支付记录不存在");
}
if ($gamesign['url']) {
redirect($gamesign['url']);
}
$token = $gamesign['token'];
$ipa365 = new Ipa365();
$i = 1;
while (1) {
// 获取授权码
$list = $ipa365->ticketList(array(
'token' => $token,
'limit' => $i,
)); // @todo: 并发授权码已分配的情况
$code = $list['data']['list'][$i-1]['code'];
$codeExists = M('game_supersign', 'tab_')->field('id')->where(array(
'ticket' => $code,
))->find();
if (!$codeExists) {
break;
}
$i ++;
}
$game = M('game', 'tab_')->where(array(
'id' => $gameId,
))->find();
$url = $game['supersign_url']."?code={$code}";
$r = M('game_supersign', 'tab_')->where(array(
'user_id' => $userId,
'game_id' => $gameId,
'pay_status' => 1
))->save(array(
'ticket' => $code, // 调用安装的时候分配
'url' => $url,
));
if (!$r) {
pp(M('game_supersign', 'tab_')->_sql());
M()->rollback();
return -1;
}
M()->commit();
// 调用第三方连接
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
$gameId = I('game_id', 0);
$orderId = I('order_id', 0);
if (!$userId || !$gameId || !$orderId) {
$this->error("参数有误!");
}
M()->startTrans();
// 获取支付记录
$gamesign = M('game_supersign', 'tab_')->where(array(
'order_id' => $orderId,
'user_id' => $userId,
'game_id' => $gameId,
'pay_status' => 1,
))->find();
if (!$gamesign) {
// pp(M('game_supersign', 'tab_')->_sql());
$this->error("支付记录不存在");
}
if ($gamesign['url']) {
redirect($gamesign['url']);
}
$token = $gamesign['token'];
$ipa365 = new Ipa365();
$i = 1;
while (1) {
// 获取授权码
$list = $ipa365->ticketList(array(
'token' => $token,
'limit' => $i,
)); // @todo: 并发授权码已分配的情况
$code = $list['data']['list'][$i-1]['code'];
$codeExists = M('game_supersign', 'tab_')->field('id')->where(array(
'ticket' => $code,
))->find();
if (!$codeExists) {
break;
}
$i ++;
}
$game = M('game', 'tab_')->where(array(
'id' => $gameId,
))->find();
$url = $game['supersign_url']."?code={$code}";
$r = M('game_supersign', 'tab_')->where(array(
'user_id' => $userId,
'game_id' => $gameId,
'pay_status' => 1
))->save(array(
'ticket' => $code, // 调用安装的时候分配
'url' => $url,
));
if (!$r) {
pp(M('game_supersign', 'tab_')->_sql());
M()->rollback();
return -1;
}
M()->commit();
// 调用第三方连接
// pp($url);
redirect($url);
redirect($url);
}
/*
* 打包列表
*/
public function pay_list() {
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
public function pay_list() {
$userId = $this->userinfo['user_id'];
if (!$userId ) {
$this->error("请登入", "/mobile.php/ssg/login");
}
$list = M('game_supersion', 'tab_')->where(array(
'user_id' => $userId,
))->select();
$list = M('game_supersion', 'tab_')->where(array(
'user_id' => $userId,
))->select();
$this->assign("list", $list);
$this->display();
}
$this->assign("list", $list);
$this->display();
}
// alipay
public function alipay($param) {
$pay = new \Think\Pay($param['apitype'],C($param['config']));
$vo = new \Think\Pay\PayVo();
$vo->setBody("超级签消费")
->setFee($param['price'])//支付金额
->setTitle($param['title'])
->setOrderNo($param['order_id'])
->setService($param['server'])
->setSignType($param['signtype'])
->setPayMethod("wap")
->setTable("supersign")
->setPayWay($param['payway'])
->setCallback($param['callback'])
->setNotifyUrl($param['notifyurl'])
->setGameName(get_game_name($param['game_id']))
->setServerId(0)
->setUserId($param['user_id'])
->setSdkVersion($param['sdk_version']);
//$pay_['url']= $pay->buildRequestForm($vo);
//$pay_['out_trade_no']= $out_trade_no;
return $pay->buildRequestForm($vo);
// alipay
public function alipay($param) {
$pay = new \Think\Pay($param['apitype'],C($param['config']));
$vo = new \Think\Pay\PayVo();
$vo->setBody("超级签消费")
->setFee($param['price'])//支付金额
->setTitle($param['title'])
->setOrderNo($param['order_id'])
->setService($param['server'])
->setSignType($param['signtype'])
->setPayMethod("wap")
->setTable("supersign")
->setPayWay($param['payway'])
->setCallback($param['callback'])
->setNotifyUrl($param['notifyurl'])
->setGameName(get_game_name($param['game_id']))
->setServerId(0)
->setUserId($param['user_id'])
->setSdkVersion($param['sdk_version']);
$pay_['url']= $pay->buildRequestForm($vo);
//$pay_['out_trade_no']= $out_trade_no;
return $pay_;
}
//领取礼包码
public function getNovice($user_id,$account,$gift_id){
}
//领取礼包码
public function getNovice($user_id,$account,$gift_id){
$data =M("giftbag",'tab_')->find($gift_id);
$novice_str = $data['novice'];
$novice_arr = str2arr($novice_str,",");
@ -611,16 +624,10 @@ class Ipa365Controller extends BaseController{
M("giftbag",'tab_')->commit();
return $record;
}
}
public function checkAccountGiftExist($user_id,$gift_id){
}
public function checkAccountGiftExist($user_id,$gift_id){
$map['user_id'] = $user_id;
$map['gift_id'] = $gift_id;
return M("gift_record",'tab_')->field('*')->where($map)->find();
}
//前往空白页
public function blank()
{
$this->display();
# code...
}
}
}

Loading…
Cancel
Save