public function get_rewards($player_id, $questionnaire_id) { $questionnaire_info = $this->get_data('ActivityQuestions')->get_questionnaire_info($questionnaire_id); if (empty($questionnaire_info) || empty($questionnaire_info['reward'])) { $this->throw_error('71610'); # 获取问卷信息异常 } # 判断是否已经领取过 $reward_log = $this->get_data('ActivityQuestions')->get_questionnaire_reward_log($player_id, $questionnaire_id, 1); if (!empty($reward_log)) { $this->throw_error('71611'); # 已领取过该问卷奖励 } $rewards = json_decode($questionnaire_info['reward'], true); if (!empty($rewards['base_reward'])) { $this->start_trans(); $reward = array(); $reward_detail = $this->get_game('Reward')->get_reward_detail($rewards['base_reward']); $this->get_game('Reward')->gen_reward_array($reward_detail, $reward); if (!empty($reward)) { $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 796, 'bind_flag' => 0)); $this->write_check_strict($re, 3010238); } # 记录领奖日志 $reward_log = array('player_id' => $player_id, 'questionnaire_id' => $questionnaire_id, 'reward_type' => 1, 'reg_time' => $this->current_time, 'reward_info' => "'" . json_encode($reward_detail) . "'"); $re = $this->get_data('ActivityQuestions')->record_questionnaire_reward_log($reward_log); $this->write_check($re, 3010250); $this->commit(); $this->get_game('Reward')->add_reward_log(); } # 添加一个定时器,用于延迟发奖,由于玩家可以重复答题,故不能置于答题后发送定时器 $params = array(); $params['type'] = 170003; $params['id'] = $this->get_data('ActivityQuestions')->get_new_alarm_timer_seq(); $params['timeout'] = $this->delay_reward_time; $params['param1'] = $player_id; $params['param2'] = $questionnaire_id; $params['param3'] = 0; $params['param4'] = 0; Protocol::input(0, 7, 4, 516, $params); # 条件式问卷重新推送列表 $this->get_cond_ids($player_id, 1); # 判断是否关闭全民问卷功能 $open_flag = $this->check_open_status($player_id); if (empty($open_flag)) { $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('func_open')); if (!empty($player_detail['func_open']) && isset($player_detail['func_open'][$this->func_id])) { unset($player_detail['func_open'][$this->func_id]); $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('func_open' => $player_detail['func_open'])); $this->write_check($re, 3010278); } # 告知Flash关闭功能 Protocol_Func::sync_func_data($player_id, $this->func_id); } return array('result' => 1); }
private function gain_auth_reward($player_id, $auth_type) { $player_info = $this->get_data('Player')->get_player_info($player_id); # 获取认证奖励配置信息 $auth_reward_info = Cache_AuthReward::getInstance()->get_auth_reward_info($auth_type, $player_info['career_type']); if (empty($auth_reward_info)) { $this->throw_error('10227'); # 未配置认证奖励信息 } # 获取奖励领取记录 $auth_reward_log = $this->get_data('AuthReward')->get_player_auth_reward_log($player_id, $auth_type); # 验证是否已经通过手机|微信认证 if (empty($auth_reward_log) || empty($auth_reward_log['auth_status'])) { $error_code = $auth_type == 1 ? '10232' : 10235; $this->throw_error($error_code); # 未通过手机|微信认证 } # 验证是否已经领取过认证奖励 if (!empty($auth_reward_log['reward_status'])) { $this->throw_error('10228'); # 已领取过该类型认证奖励 } # 发奖 $auth_reward = array(); foreach ($auth_reward_info as $val) { if ($val['item_type'] == 1) { # 发送道具 $item_key = Cache_Currency::getInstance()->get_key($val['item_id']); if (!empty($item_key)) { # 虚拟货币 $auth_reward[] = array('type' => $item_key, 'item_id' => $val['item_id'], 'item_num' => $val['item_num']); } else { # 道具 $auth_reward[] = array('type' => 'prop', 'item_id' => $val['item_id'], 'item_num' => $val['item_num']); } } elseif ($val['item_type'] == 2) { # 发送翅膀 } elseif ($val['item_type'] == 3) { # 发送时装 $this->get_game('PlayerFashion')->send_fashion($player_id, $val['item_id']); } } // Com_Log::write("gain_auth_reward.".$player_id,var_export($auth_reward,true)); $re = $this->get_game('Reward')->send_reward($player_id, $auth_reward, array('cmd_id' => '1908', 'bind_flag' => 0), 1); $this->write_check_strict($re, 3010462); # 该方法会自动推送843协议告知前端显示奖励信息 $ret = $this->get_game('Reward')->add_reward_log(); # 更新领奖日志 $auth_reward_log['reward_status'] = 1; $auth_reward_log['mod_date'] = $this->current_time; $re = $this->get_data('AuthReward')->record_player_auth_reward_log($auth_reward_log); $this->write_check($re, 3010471); # 判断是否关闭认证功能 $is_completed = $this->check_for_completion($player_id); if (!empty($is_completed)) { $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('func_open')); if (!empty($player_detail['func_open']) && isset($player_detail['func_open'][$this->func_id])) { unset($player_detail['func_open'][$this->func_id]); $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('func_open' => $player_detail['func_open'])); $this->write_check($re, 3010480); } # 告知Flash关闭认证功能 Protocol_Func::sync_func_data($player_id, $this->func_id); } return $auth_reward; }