|
|
|
@ -291,8 +291,22 @@ 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();
|
|
|
|
|
}
|
|
|
|
@ -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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|