From 8f5f4ba9bc3b9edb5a74787542211a65e20e9fa4 Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Thu, 17 Oct 2019 21:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E5=8C=85=E9=A2=86=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Mobile/Controller/SsgController.class.php | 19 ++++++ .../Sdk/Controller/Ipa365Controller.class.php | 65 ++++++++++++++++++- .../Sdk/View/default/Ipa365/install_show.html | 2 +- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/Application/Mobile/Controller/SsgController.class.php b/Application/Mobile/Controller/SsgController.class.php index 4562344ff..1a0ac4bfe 100644 --- a/Application/Mobile/Controller/SsgController.class.php +++ b/Application/Mobile/Controller/SsgController.class.php @@ -399,4 +399,23 @@ class SsgController extends BaseController { } } + /** + * 领取激活码 + * @param $token + * @param $gift_id + * author: xmy 280564871@qq.com + */ + public function get_novice($user_id,$gift_id){ + + $model = D("Giftbag"); + $exist = $model->checkAccountGiftExist($logininfo['user_id'],$gift_id); + if($exist){ + $this->error("您已经领取过该礼包!"); + } + $novice = $model->getNovice($logininfo['user_id'],$logininfo['account'],$gift_id); + if(empty($novice)){ + $this->error("暂无激活码"); + } + $this->success("领取成功",$novice); + } } diff --git a/Application/Sdk/Controller/Ipa365Controller.class.php b/Application/Sdk/Controller/Ipa365Controller.class.php index 77813802a..7b1755189 100644 --- a/Application/Sdk/Controller/Ipa365Controller.class.php +++ b/Application/Sdk/Controller/Ipa365Controller.class.php @@ -291,12 +291,26 @@ class Ipa365Controller extends BaseController{ $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 */ @@ -338,7 +352,7 @@ class Ipa365Controller extends BaseController{ 'pay_status' => 1, ))->find(); if (!$gamesign) { -// pp(M('game_supersign', 'tab_')->_sql()); + // pp(M('game_supersign', 'tab_')->_sql()); $this->error("支付记录不存在"); } if ($gamesign['url']) { @@ -430,4 +444,49 @@ class Ipa365Controller extends BaseController{ return $pay_; } + //领取礼包码 + public function getNovice($user_id,$account,$gift_id){ + $data =M("giftbag",'tab_')->find($gift_id); + $novice_str = $data['novice']; + $novice_arr = str2arr($novice_str,","); + if (empty($novice_arr)){ + return ""; + } + $novice_arr = array_filter($novice_arr); + $novice = array_pop($novice_arr); + $data['novice_num'] = count($novice_arr); + $data['novice'] = arr2str($novice_arr,","); + M("giftbag",'tab_')->startTrans(); + $novice_result = M("giftbag",'tab_')->save($data); + if(!empty($novice)){ + //记录领取 + $record['game_id'] = $data['game_id']; + $record['game_name'] = $data['game_name'];//get_game_name($data['game_id']); + $record['gift_id'] = $gift_id; + $record['gift_name'] = $data['giftbag_name']; + $record['status'] = 0; + $record['novice'] = $novice; + $record['user_id'] = $user_id; + $record['user_account'] = $account; + $record['create_time'] = time(); + $record['start_time'] = $data['start_time']; + $record['end_time'] = $data['end_time']; + $record_result = M("gift_record",'tab_')->add($record); + }else{ + $novice_result = false; + } + + if($novice_result === false || $record_result === false){ + M("giftbag",'tab_')->rollback(); + return ""; + }else{ + M("giftbag",'tab_')->commit(); + return $record; + } + } + 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(); + } } diff --git a/Application/Sdk/View/default/Ipa365/install_show.html b/Application/Sdk/View/default/Ipa365/install_show.html index ed9ab7605..8705725b0 100644 --- a/Application/Sdk/View/default/Ipa365/install_show.html +++ b/Application/Sdk/View/default/Ipa365/install_show.html @@ -136,7 +136,7 @@ p,input{
{$giftbag['desribe']}