示例#1
0
 function actionSendMsgToAwardUsers()
 {
     $uid_secs = self::getParam('uid_secs');
     $content = self::getParam('content');
     $desc = self::getParam('desc');
     $items = self::getParam('items');
     $task_num = self::getParam('num');
     error_log("====接受到奖励信息==" . json_encode($uid_secs));
     if (!$uid_secs) {
         return;
     }
     foreach ((array) $items as $value) {
         $tag = $value['tag'];
         $num = intval($value['num']);
         if ($tag == 'gem' && $num > 100000) {
             echo "error, 元宝不能大于100000";
             exit;
         }
     }
     $key = uniqid();
     $msg = array('key' => $key, 'time' => app()->now, 'content' => $content, 'type' => 'system');
     //福利号总服务器地址
     $all_config = (include_once ROOT . "/admin/view/public_const_config.php");
     //设置作废福利号接口
     $server_url = $all_config['server_api_url'] . "?action=setRepeal&mod=admin";
     $DEBUG = true;
     foreach ((array) $uid_secs as $uid => $sec) {
         //if( $uid != 3879133 )continue;//temp
         //error_log("send[$uid][$sec]");
         //check 是否合服 改变UID
         $sec_config = getApp()->getSectionConfig($sec);
         if (isset($sec_config['merge'])) {
             $uid = "{$sec}_{$uid}";
             $sec = $sec_config['merge'];
         }
         if ($DEBUG) {
             error_log("开始发送元宝:{$uid}--{$sec}");
         }
         $player = new model_Player($uid, $sec);
         $player->getFields(array('level', 'test_status', 'login_t', 'gem'));
         $level = $player->numberGet("base", "level");
         $gem = $player->objectGet("base", "gem");
         $login = $player->objectGet("base", "login_t");
         //只执行一次  执行一次没有句号的描述 就可以将大于20w的置为20w
         $bool = $content == "鉴于掌门对武林做出了卓越贡献,特此奖励掌门一些物件,方便行走江湖,还望掌门笑纳" ? true : false;
         if ($bool && $gem > 200000) {
             //当前元宝大于20w 且 不是单次发送 将该玩家元宝置为20w 不给发此次元宝
             error_log("change_gem:uid:{$uid},{$sec},gem:{$gem}");
             $player->numberPut('base', 'gem', 200000);
             $player->commit();
             if ($DEBUG) {
                 error_log("error.20w");
             }
             continue;
         }
         if ($task_num != 1 && $gem > 50000) {
             //现有元宝数量大于N不给发 且 不是单次发送
             if ($DEBUG) {
                 error_log("{$gem}元宝大于5w,{$task_num}");
             }
             continue;
         }
         if ($_SERVER['REQUEST_TIME'] - $login > 10 * 86400) {
             //10天没登陆 设置为作废福利号
             model_Util::send_post($server_url, array('uid' => $uid, 'sec' => $sec));
             if ($DEBUG) {
                 error_log("大于10天没登录");
             }
             continue;
         }
         foreach ($items as $key => $value) {
             $tag = $value['tag'];
             $num = intval($value['num']);
             if ($tag == 'qiyu_zhidian') {
                 $zhidian_lvl = max(1, $level * 3 - 34);
                 for ($i = 0; $i < $num; $i++) {
                     $items[] = array('tag' => 'qiyu_zhidian', 'level' => $zhidian_lvl, 'num' => 1);
                 }
                 unset($items[$key]);
             }
         }
         if ($DEBUG) {
             error_log("====={$value['tag']}={$value['num']}");
         }
         if ($value['tag'] == 'gem') {
             if ($DEBUG) {
                 error_log("enter");
             }
             $player->checkVipUpgradeAward($value['num']);
             $player->commit();
         }
         if (is_array($items) && count($items) > 0) {
             $msg['status'] = 'award';
             #$msg['content'].="\n$desc";
             $cdkey = model_Cdkey::gen($items, $desc, 1, 'def');
             $msg['cdkey'] = $cdkey;
         }
         $r = model_Chat::sendMsg($msg, $uid, 'origin', $sec);
     }
 }
示例#2
0
 public function actionBuchangGem()
 {
     glog::info(json_encode($_REQUEST), 'addgem');
     glog::info(json_encode($_SERVER), 'addgem');
     $hour = date("H");
     if ($hour < 10 || $hour > 21) {
         // 10:00 ~ 21:59 才能使用这个接口,防止阿里云的云盾自动发起回调...
         // 有没有更好的处理方法...
         return $this->response(array('s' => 'ERROR', 'msg' => '操作时间不合法'));
     }
     $keys = array('section_id', 'product_id', 'platform', 'operator', 'optime');
     $params = array();
     foreach ($keys as $key) {
         ${$key} = trim(self::getParam($key));
         if (empty(${$key})) {
             $msg = "need param [{$key}]";
             glog::info($msg, 'addgem');
             return $this->response(array('s' => 'ERROR', 'msg' => $msg));
         }
         $params[$key] = ${$key};
     }
     $now = time();
     if ($now - $params['optime'] > 60 || $params['optime'] - $now > 60) {
         return $this->response(array('s' => 'ERROR', 'msg' => '操作已过期'));
     }
     $pid = self::getParam('pid');
     if ($pid) {
         $um = model_LoginUser::searchUniq('pid', $pid);
         if (!$um) {
             return $this->response(array('ErrorCode' => 0, 'ErrorDesc' => "用户[{$pid}]不存在"));
         }
         $uid = $um->id();
     } else {
         $uid = self::getParam('uid');
     }
     if (empty($uid)) {
         return $this->response(array('s' => 'ERROR', 'msg' => "需要UID参数"));
     }
     if ($params['platform'] != P_PLATFORM) {
         return $this->response(array('s' => StatusCode::error, 'msg' => "平台信息不匹配"));
     }
     if ($product_id == 'custom') {
         if (!in_array(P_PLATFORM, array('qqandroid', 'kunlun'))) {
             return $this->response(array('s' => StatusCode::error, 'msg' => P_PLATFORM . "平台不支持自定义额度支付"));
         }
         $params['cash'] = trim(self::getParam('cash'));
         if (!is_numeric($params['cash']) || $params['cash'] <= 0) {
             return $this->response(array('s' => StatusCode::error, 'msg' => "自定义额度{$params['cash']}不合法"));
         }
     } else {
         $payment_config = getApp()->getPaymentConifg();
         if (!isset($payment_config[$product_id])) {
             $msg = "product_id[{$product_id}] not exists";
             glog::info($msg, 'addgem');
             return $this->response(array('s' => 'ERROR', 'msg' => $msg));
         }
     }
     // 验证参数
     if (0 && !isset($_REQUEST['__no_sig__']) && !$this->verify_signature($params, 'qxs%Mt6v@nVdUb9d')) {
         return $this->response(array('s' => 'ERROR', 'msg' => "signature verification failed"));
     }
     PL_Session::$usecookie = false;
     $_REQUEST['cid'] = PL_Session::gencid($uid, $section_id);
     $player = getApp()->getPlayer();
     $mon = getApp()->getPaymentMongoConnection();
     $mongoid = new MongoID();
     $transaction_id = $mongoid->{'$id'};
     // 生成新的订单信息
     $payment_info = $player->createPaymentInfo($product_id);
     if ($product_id == 'custom') {
         $payment_info['cash'] = $params['cash'];
         if (P_PLATFORM == 'kunlun') {
             $payment_info['sumGem'] = $payment_info['cash'] * 15;
         }
     }
     $payment_info['transaction_id'] = $transaction_id;
     $payment_info['create_t'] = getApp()->now;
     $payment_info['source'] = 'buchang';
     $payment_info['msg'] = $params['operator'] . "给玩家补偿未到账的支付,";
     $old_vip = $payment_info['_vip'];
     $old_gem = $payment_info['ogem'];
     // 订单上次处理异常 或者 新的订单
     $ret = $player->process_payment($payment_info);
     if ($ret['s'] == StatusCode::ok) {
         $msg = "transaction [{$transaction_id}] processed";
         glog::info($msg, 'addgem');
         if (1) {
             $gem_add_and_reward = $ret['info']['gem_add_and_reward'];
             // 补发传书
             $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,祝您游戏愉快~");
             model_Chat::sendMsg($msg, $uid, 'origin', $section_id);
         } else {
             $gem_add_and_reward = $ret['info']['gem_add_and_reward'];
             $reward_gem = ceil($gem_add_and_reward * 0.1);
             // 补发传书
             $msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "您未到账的{$gem_add_and_reward}元宝已经补发到账,现在额外补偿您{$reward_gem}元宝,祝您游戏愉快~");
             $awards = array(array('tag' => 'gem', 'num' => $reward_gem));
             $msg['status'] = 'award';
             $cdkey = model_Cdkey::gen($awards, "{$reward_gem}元宝");
             $msg['cdkey'] = $cdkey;
             model_Chat::sendMsg($msg, $uid, 'origin', $section_id);
         }
         // 发邮件
         $login_model = new model_LoginUser($uid);
         $login_model->get(array('pid' => 1, 'email' => 1));
         $pid = $login_model['pid'];
         $email = $login_model['email'];
         $login_model->opOne('buchange_gem_t', getApp()->now);
         $login_model->save();
         $new_gem = $player->numberGet('base', 'gem');
         $new_vip = $player->numberGet('vip', 'lvl');
         $platform = P_PLATFORM;
         $name = $player->stringGet('base', 'name');
         $cash = $payment_config[$product_id]['cash'];
         $operator = $params['operator'];
         $subject = "[{$operator}]BuChangChongZhi[{$platform}][{$section_id}][{$uid}][{$cash} yuan]";
         $time = date("Y-m-d H:i:s");
         $content = "操作时间: {$time} \n";
         $content .= "操作人:{$operator}\n平台: {$platform}\nPID:{$pid}\nemail:{$email}\nUID:{$uid}\n分区:{$section_id}\n门派名:{$name}\n";
         $content .= "充值前:\nvip:{$old_vip}\ngem:{$old_gem}\n";
         $content .= "充值后:\nvip:{$new_vip}\ngem:{$new_gem}\n";
         model_Util::sendemail('*****@*****.**', $subject, $content);
         return $this->response(array('s' => 'OK', 'msg' => $msg, 'ret' => $ret));
     } else {
         $msg = "transaction[{$transaction_id}] failed," . $ret['msg'];
         glog::info($msg, 'addgem');
         return $this->response(array('s' => 'ERROR', 'msg' => $msg, 'ret' => $ret));
     }
 }
示例#3
0
 public function action_buchang_worldboss()
 {
     $section = $this->get_param('sec');
     $today = $this->get_param('date');
     //指定日期,格式:1030,代表十月30号
     if (empty($section)) {
         $section_list = array_keys(getApp()->getSectionConfig());
     } else {
         $section_list = (array) $section;
     }
     if (empty($section_list)) {
         throw new Exception('section error');
         return;
     }
     $now = getApp()->now;
     $redis = DbConfig::getRedis('worldboss');
     $redis_set = DbConfig::getRedis('cache');
     if (empty($today)) {
         $today = date('md', $now);
     }
     if (P_PLATFORM == "kunlun" || P_PLATFORM == 'qqandroid') {
         echo "昆仑平台暂无补偿";
         return;
     }
     $world_boss_conf = PL_Config_Numeric::get('worldboss');
     $worldboss_zhidian_offset = PL_Config_Numeric::get('setting', 'worldboss_zhidian_level_offset');
     echo "================[ 补偿日期 : {$today} ]===============\n";
     foreach ($section_list as $section) {
         echo "===== 分区: {$section} =====\n";
         foreach ($world_boss_conf as $tag => $conf) {
             echo "===== boss: {$tag} =====\n";
             $activityConfig = getApp()->getactivityconfig("act_worldboss_{$tag}");
             if ($activityConfig) {
                 if ($now < $activityConfig['start_t'] || $now > $activityConfig['end_t']) {
                     echo "[{$tag}] 不在活动时间内\n";
                     continue;
                 }
             }
             $boss_key = "worldboss_boss_{$tag}_{$section}_{$today}";
             $boss_info = $redis->hgetall($boss_key);
             if ($boss_info['buchang_reward_time']) {
                 $msg = "补偿时间 : " . date('Y-m-d H:i:s', $boss_info['buchang_reward_time']) . "\n";
                 echo $msg . "\n";
                 continue;
             }
             $rank_key = "worldboss_rank_{$tag}_{$section}_{$today}";
             $boss_name = model_Translate::getTransConfig($conf['bossname']);
             $rank_list = $redis->zrevrange($rank_key, 0, -1);
             if (!$rank_list) {
                 continue;
             }
             $rank_uids = array_values($rank_list);
             $user_info = model_CacheUtil::getUserInfoByIdsWithFileds($rank_uids, $section, array('level'));
             foreach ($user_info as $r_uid => $r_udata) {
                 $rank_awards = array(array('tag' => '601001', 'num' => 4), array('tag' => '601002', 'num' => 4), array('tag' => '601019', 'num' => 200), array('tag' => 'money', 'num' => 500000), array('tag' => 'qiyu_zhidian', 'level' => max(1, $r_udata['level'] * 3 + $worldboss_zhidian_offset), 'num' => 1), array('tag' => 'qiyu_zhidian', 'level' => max(1, $r_udata['level'] * 3 + $worldboss_zhidian_offset), 'num' => 1), array('tag' => 'qiyu_zhidian', 'level' => max(1, $r_udata['level'] * 3 + $worldboss_zhidian_offset), 'num' => 1), array('tag' => 'qiyu_zhidian', 'level' => max(1, $r_udata['level'] * 3 + $worldboss_zhidian_offset), 'num' => 1), array('tag' => 'qiyu_zhidian', 'level' => max(1, $r_udata['level'] * 3 + $worldboss_zhidian_offset), 'num' => 1));
                 $desc_str = model_Cdkey::descriptItems($rank_awards);
                 $rank_msg = array('type' => 'system', 'key' => uniqid(), 'time' => getApp()->now, 'content' => "由于3月15日掌门参加群雄破阵时出现了游戏意外退出的情况。大掌门团队对此表示歉意并补偿给掌门:叫花鸡x4, 补元丹x4, 培养丹x200, 银两x500000, 指点x5");
                 $rank_msg['status'] = 'award';
                 //print_r($rank_awards);
                 $cdkey = model_Cdkey::gen($rank_awards, $desc_str);
                 $rank_msg['cdkey'] = $cdkey;
                 model_Chat::sendMsg($rank_msg, $r_uid, 'origin', $section);
                 echo "uid = [{$r_uid}], 获取补偿,cdkey = [{$cdkey}]\n";
             }
             $redis->hset($boss_key, 'buchang_reward_time', $now);
         }
     }
 }