Exemplo n.º 1
0
 /**
  * actionCashierGetInfo
  * @author cq
  * @date 2014/07/01
  * @param
  *      id:uid或者pid
  * @return
  *      s
  *      info
  *          uid
  *          create_t
  *          pid
  *          istest
  *          sections
  *              s1
  *                  name
  *                  level
  *                  vip
  *                  gem
  *                  defaul
  *              s2
  *                  ...
  *      payment_config
  *          系统的payment_config
  */
 public function actionCashierGetInfo()
 {
     $now = getApp()->now;
     //$ip = getApp()->getClientIP();
     //验证消息来源是否合法
     $valid_ip_list = array('115.29.193.89', '115.29.225.243', '115.29.229.132', '115.29.229.113', '117.121.10.35');
     /*
     		if(!in_array($ip, $valid_ip_list)){
     		return array('s'=>StatusCode::invalid_ip);
     		}*/
     $id = $_POST['id'];
     if (empty($id)) {
         echo json_encode(array('s' => StatusCode::invalid_param));
         return;
     }
     $mon = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
     $um = $mon->findOne(array('email' => $id));
     if (!$um) {
         $um = $mon->findOne(array('pid' => $id));
     }
     if (!$um) {
         echo json_encode(array('s' => StatusCode::invalid_param));
         return;
     }
     $ret = array();
     $ret['s'] = StatusCode::ok;
     //获取用户登录信息
     $ret['info'] = array();
     $ret['info']['uid'] = $um['_id'];
     //接口中需要添加pid by zhangjun
     $ret['info']['pid'] = $um['pid'];
     $ret['info']['create_t'] = $um['_ct'];
     $ret['info']['istest'] = 0;
     $ret['info']['istest'] = $um['istest'] ? 'istest' : 0;
     $ret['info']['istest'] = $um['isdev'] ? 'isdev' : $ret['info']['istest'];
     //获取用户各个分区信息
     $section_config = getApp()->getSectionConfig();
     $ret['info']['sections'] = array();
     if (isset($um['secs'])) {
         foreach ($um['secs'] as $sec => $last_t) {
             $um_mc = new model_Player($um['_id'], $sec);
             $um_data = $um_mc->getFields(array('name', 'level', 'vip', 'gem', '_it'));
             $um_data['vip'] = $um_data['vip']['lvl'];
             $um_data['default'] = $sec == $um['_ld']['sec'] ? 1 : 0;
             $um_data['section_name'] = $section_config[$sec]['name'];
             $ret['info']['sections'][$sec] = $um_data;
         }
     }
     //获取支付信息
     $ret['payment_config'] = getApp()->getPaymentConifg();
     //NULL, $um['source']);
     $ret['payment_unit'] = '元宝';
     $list = $ret['payment_config'];
     //添加自定义支付项
     $max_product_config = array('cash' => -1);
     foreach ($ret['payment_config'] as $index => $p_config) {
         //修改一下提示信息
         $trans_config = PL_Config_Numeric::get('translate', $p_config['desc']);
         $ret['payment_config'][$index]['desc'] = $trans_config['zh_CN'];
         if ($p_config['cash'] > $max_product_config['cash']) {
             $max_product_config = $p_config;
             $product_config_list[] = $p_config;
         }
     }
     $ret['payment_config'] = array();
     $max_product = 1000;
     if ($max_product_config['cash'] > 0) {
         $custom_config = array('type' => 'define', 'gt' => $max_product, 'inputdesc' => '首次充值翻倍额度以游戏内最高可充值额度为准', 'gemcalc' => "Math.ceil(cash*10 + cash*1300/998)", 'product_id' => 'custom');
         $ret['payment_config'][] = $custom_config;
     }
     foreach ($list as $k => $v) {
         //if($v['gemaward'] > 0 && !isset($v['hide'])){
         if (isset($v['forweb'])) {
             $ret['payment_config'][] = $v;
         }
     }
     echo json_encode($ret);
 }
Exemplo n.º 2
0
 function actionSendSystemMsg()
 {
     //$uid = (int)self::getParam('uid');
     $userstr = self::getParam('uid');
     $sec = self::getParam('sec');
     $content = self::getParam('content');
     $desc = self::getParam('desc');
     $items = self::getParam('items');
     $ready_id = self::getParam('ready_id');
     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');
     if ($userstr != "all") {
         $uids = explode(',', $userstr);
         $itemmsg = "";
         foreach ($uids as $uid) {
             $uid = getApp()->getRealUid($uid, $sec);
             $sec = getApp()->getRealSec($sec);
             $player = new model_Player($uid, $sec);
             $level = $player->objectGet("base", "level");
             foreach ((array) $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 (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);
         }
     } else {
         $r = model_Chat::send($msg, 2, "", "toall", $sec);
     }
     if ($r) {
         $mon = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
         $mon->switchColl('msgready');
         $mon = $mon->getmc();
         $id = $mon->update(array('ready_id' => (int) $ready_id), array('$set' => array('applicant_status' => 0, 'check_man' => $_SERVER['PHP_AUTH_USER'])));
         echo json_encode(array('s' => 'OK'));
     }
 }
Exemplo n.º 3
0
<?php

$cond = array();
$mon = new PL_Db_Mongo(DbConfig::getMongodb($coll));
$limit = $this->getParam('rows', 20);
$page = $this->getParam('page', 0);
//prcoess sort as string "0 dec,1"
$sort = array();
$sidx = $this->getParam('sidx');
$sord = $this->getParam('sord');
if ($sidx) {
    $sidx .= $sord;
    preg_match_all('/[\\s]*([\\w]+)[\\s]+([\\w]+)[\\s]*/', $sidx, $mout);
    foreach ((array) $mout[1] as $k => $v) {
        if ($mout[2][$k] == 'asc') {
            $sort[$v] = 1;
        } else {
            $sort[$v] = -1;
        }
    }
} else {
    if ($sord == 'desc') {
        $sort[0] = -1;
    } else {
        if ($sord == 'asc') {
            $sort[0] = 1;
        }
    }
}
//process query
//todo procecess all ops
Exemplo n.º 4
0
 /**
  * @author 符璨
  * @desc
  *      从cdkey_task取出待处理的cdkey任务进行处理 
  *      批量生成cdkey
  */
 public static function action_gen_cdkey()
 {
     $redis = DbConfig::getRedis('realtime_stat');
     $process_id = getmypid();
     //从cdkey中取出一条状态为0(未处理cdkey生成记录),并更新为1(正在处理)
     $mc = new PL_Db_Mongo(DbConfig::getMongodb('userlogin'));
     $mc->switchColl('cdkey_task');
     $cdkey_task = $mc->findOne(array('status' => 0));
     //没有待处理的任务
     if ($cdkey_task == NULL) {
         return;
     }
     glog::info("[{$process_id}] gen cdkey worker started", 'cdkey');
     $task_id = $cdkey_task['_id'];
     $mc->update(array('_id' => $task_id), array('$set' => array('status' => 1)));
     $pa = $cdkey_task;
     unset($pa['status']);
     $num = $pa['num'];
     $task_id = $cdkey_task['_id'];
     //根据cdkey_task的内容生成cdkey
     $mc->switchColl('cdkey');
     while ($num--) {
         $pa['_id'] = model_Cdkey::genCdkey(13);
         $pa['task_id'] = $task_id->__toString();
         //try以防有重复的cdkey
         try {
             $cdkey = $mc->insert($pa);
             //redis中统计当前已生成的cdkey数目
             $redis->hIncrBy('cdkey_task', $task_id, 1);
             $redis->lpush("cdkey_{$task_id}", $pa['_id']);
         } catch (Exception $ex) {
             $exception_cnt--;
             $num++;
             glog::info("[{$process_id}] gen cdkey worker:Duplicated _id {$pa['_id']}", 'cdkey');
             if (!$exception_cnt) {
                 break;
             }
             continue;
         }
         $exception_cnt = 10;
     }
     $mc->switchColl('cdkey_task');
     $mc->update(array('_id' => $task_id), array('$set' => array('status' => 2)));
     $redis->hDel('cdkey_task', $task_id);
     glog::info("[{$process_id}] gen cdkey worker completed", 'cdkey');
 }