Ejemplo 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);
     }
 }
Ejemplo n.º 2
0
 public function action_chongzhi()
 {
     $mon = getApp()->getPaymentMongoConnection();
     //$begin = 1351530000;
     $begin = strtotime("2012-12-02 01:00:00");
     $rows = $mon->find(array('status' => StatusCode::payment_finished, 'action' => 'recharge_gem', '_sec' => 's1', 'finish_t' => array('$gte' => $begin)), array(), array('_tm' => 1));
     //$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'];
         if (0) {
             if ($r['finish_t'] >= $begin) {
                 if (empty($payments[$section_id][$uid])) {
                     $player = new model_Player($uid, $section_id);
                     $payments[$section_id][$uid] = $player->numberGet('base', 'total_gem_added');
                 }
                 $payments[$section_id][$uid] += $r['agem'];
             }
             $payments_check[$section_id][$uid] += $r['agem'];
         } else {
             //echo json_encode($r)."\n";
             $player = new model_Player($uid, $section_id);
             $data = $player->getFields(array('vip', 'gem', 'total_gem_added', 'total_gem_rewarded', 'total_gem_rewarded2', 'total_gem_used'));
             echo "before: {$uid},{$section_id}," . json_encode($data) . "\n";
             $player->process_payment2($r);
             foreach (array('vip', 'gem', 'total_gem_added', 'total_gem_rewarded', 'total_gem_rewarded2', 'total_gem_used') as $k) {
                 $data2[$k] = $player->objectGet('base', $k);
             }
             echo "after: " . json_encode($data2) . "\n";
             $player->commit();
             echo "======\n\n";
         }
     }
     /*
             foreach($payments as $section_id=>$xxx){
        foreach($xxx as $uid=>$added_gem){
            if($payments_check[$section_id][$uid]!=$added_gem){
                echo "$section_id,$uid, right :{$payments_check[$section_id][$uid]}, $added_gem\n";
            }
        }
             }
     */
     /*
      */
     /*
             var_dump($payments);
             foreach($payments 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');
            //$total_gem_added + $added_gem 
     
            $rows = $mon->find(array('_sec'=>$section_id),'status'=>StatusCode::payment_finished,'action'=>'recharge_gem','finish_t'=>array('$gte'=>$begin)),array(),array('_tm'=>1));
     
        }
             }
     */
 }