Esempio n. 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);
     }
 }
Esempio n. 2
0
 public function action_check_chongzhi()
 {
     $mon = getApp()->getPaymentMongoConnection();
     $rows = $mon->find(array('status' => StatusCode::payment_finished, 'action' => 'recharge_gem'), array(), array('_tm' => 1));
     $payments = array();
     $payments_check = array();
     foreach ($rows as $r) {
         $uid = $r['_u'];
         $section_id = $r['_sec'];
         $payments_check[$section_id][$uid] += $r['agem'];
     }
     foreach ($payments_check as $section_id => $xxx) {
         foreach ($xxx as $uid => $added_gem) {
             $player = new model_Player($uid, $section_id);
             $total_gem_added = $player->numberGet('base', 'total_gem_added');
             if ($total_gem_added != $added_gem) {
                 $login_model = new model_LoginUser($uid);
                 $login_model->get(array('pid' => 1, 'istest' => 1));
                 $d = $login_model->doc();
                 echo "{$uid},{$section_id},{$total_gem_added},{$added_gem},{$d['pid']},{$d['istest']}\n";
             }
         }
     }
 }