Ejemplo n.º 1
0
 /**
  * save Method
  *
  * @brief データを集計してmongodbに登録する
  * @params $from timestamp
  * @params $to timestamp
  */
 public static function save($from, $to)
 {
     $mongodb = \Mongo_Db::instance();
     $payment_data = $mongodb->select(array('timestamp', 'user_id', 'status', 'client_type', 'note'))->order_by(array('timestamp' => 'asc'))->where_in('status', array('gacha', 'coin'))->where_lte('timestamp', (string) $to)->where_gte('timestamp', (string) $from)->get('system');
     foreach ($payment_data as $value) {
         $data = array();
         $data['timestamp'] = $value['timestamp'];
         $data['status'] = $value['status'];
         $data['user_id'] = $value['user_id'];
         $data['client_type'] = $value['client_type'];
         $tmp = explode(',', $value['note']);
         foreach ($tmp as $v) {
             $tmp2 = explode('=', $v);
             switch ($tmp2[0]) {
                 case 'item_id':
                     $data['item_id'] = $tmp2[1];
                     break;
                 case 'buy_num':
                     $data['num'] = $tmp2[1];
                     break;
                 case 'ii_id':
                     $data['ii_id'] = $tmp2[1];
                     break;
                 case 'price':
                     $data['price'] = $tmp2[1];
                     break;
                 default:
                     break;
             }
         }
         $insert_id = $mongodb->insert('payment', $data);
     }
 }
Ejemplo n.º 2
0
 public function action_index()
 {
     $mongodb = \Mongo_Db::instance();
     $results = $mongodb->insert('posts', array('name' => '名前', 'contents' => 'コンテンツ'));
     $results = $mongodb->get('posts');
     var_dump($results);
     return $results;
 }
Ejemplo n.º 3
0
 /**
  * getSalesData
  *
  * @brief get search for sales data by ajax
  */
 public function get_getSalesData()
 {
     /* initialize */
     $mongodb = \Mongo_Db::instance();
     $data = array();
     $where = array();
     $from_time = strtotime("yesterday");
     $to_time = strtotime("today - 1sec");
     /* get値がない場合、つまり初期アクセス時にはデータの表示はしないで表示 */
     if (\Input::get() == array()) {
         $this->response(array());
         return;
     }
     /* データ作成 */
     foreach (\Input::get() as $key => $value) {
         /* 空の場合は飛ばす */
         if (empty($value)) {
             continue;
         }
         /* 各パラメータ作成 */
         switch ($key) {
             case 'user_id':
             case 'client_type':
             case 'status':
             case 'item_id':
             case 'num':
             case 'price':
             case 'user_id':
                 $where[$key] = $value;
                 break;
             case 'from_time':
                 $from_time = strtotime($value);
                 break;
             case 'to_time':
                 $to_time = strtotime($value);
                 break;
             default:
                 break;
         }
     }
     $count = $mongodb->where($where)->where_lte('timestamp', (string) $to_time)->where_gte('timestamp', (string) $from_time)->count('payment');
     /* 件数が多すぎるので却下 */
     if ($count >= 1000000 || $count == 0) {
         $this->response(array());
         return;
     }
     $data = $mongodb->where($where)->where_lte('timestamp', (string) $to_time)->where_gte('timestamp', (string) $from_time)->get('payment');
     /* 時間フォーマットの変更 */
     foreach ($data as $key => $value) {
         /* csv 出力*/
         unset($data[$key]['_id']);
         unset($data[$key]['ii_id']);
         $data[$key]['time'] = date("Y-m-d H:i:s", $value['timestamp']);
     }
     $this->response($data);
     return;
 }
Ejemplo n.º 4
0
 /**
  * drop Method
  *
  * データを空にする
  * :all前に実行
  */
 public static function drop()
 {
     $mongodb = \Mongo_Db::instance();
     $bool = $mongodb->delete_all('gacha_comp_user');
 }
Ejemplo n.º 5
0
 /**
  * The basic welcome message
  * 
  * @access  public
  * @return  Response
  */
 public function action_index()
 {
     /* get notify item data */
     $data = array();
     $mongodb = \Mongo_Db::instance();
     $results = $mongodb->select(array('user_id', 'client_type', 'timestamp', 'note'))->order_by(array('timestamp' => 'desc'))->limit(10)->where_in('status', array('gacha', 'coin'))->get('system');
     foreach ($results as $value) {
         $datum = array();
         $datum['id'] = $value['_id'];
         $datum['user_id'] = $value['user_id'];
         $datum['client_type'] = $value['client_type'];
         $datum['time'] = date("H:i:s", $value['timestamp']);
         /* note, item_id, buy_num */
         $tmp1 = explode(',', $value['note']);
         foreach ($tmp1 as $v) {
             $tmp2 = explode('=', $v);
             $datum[$tmp2[0]] = $tmp2[1];
         }
         array_push($data, $datum);
     }
     /* get payment data */
     /* today */
     $view = Request::forge('sales/todays_data')->execute();
     $today = $view->controller_instance->results;
     /* yesterday */
     $view = Request::forge('sales/yesterdays_data')->execute();
     $yesterday = $view->controller_instance->results;
     /* this month */
     $view = Request::forge('sales/thismonths_data')->execute();
     $thismonth = $view->controller_instance->results;
     /* add app user count */
     $from = strtotime('today');
     $to = strtotime('now');
     $adduser = $mongodb->where_in('status', array('event.addapp'))->where_lte('timestamp', (string) $to)->where_gte('timestamp', (string) $from)->count('system');
     /* remove app user cuont */
     $removeuser = $mongodb->where_in('status', array('event.removeapp'))->where_lte('timestamp', (string) $to)->where_gte('timestamp', (string) $from)->count('system');
     /* get message data */
     $comments = $mongodb->select()->order_by(array('_id' => 'desc'))->limit(8)->get('comments');
     foreach ($comments as $k => $v) {
         $comments[$k]['timestamp'] = date("M/d H:i:s", $comments[$k]['timestamp']);
     }
     #asort($comments);
     /* online user count */
     $minago_offset = strtotime('-90 sec');
     $minago_limit = strtotime('-89 sec');
     $online = $mongodb->select(array('_id', 'user_id', 'status', 'timestamp'))->order_by(array('_id' => 'desc'))->where_in('status', array('transaction start'))->where_lte('timestamp', (string) $minago_limit)->where_gte('timestamp', (string) $minago_offset)->get('system');
     $tmp = array();
     foreach ($online as $value) {
         if (!isset($tmp[$value['user_id']])) {
             $tmp[$value['user_id']] = 0;
         }
         $tmp[$value['user_id']]++;
     }
     $online_user_count = count($tmp);
     /* to view */
     $params = array('data' => $data, 'today' => $today, 'yesterday' => $yesterday, 'thismonth' => $thismonth, 'comments' => $comments, 'adduser' => $adduser, 'removeuser' => $removeuser, 'online' => $online_user_count);
     $this->template->content = View::forge('welcome/index', $params);
     #        	$view = View::forge('layout');
     #        	$view->content = View::forge('welcome/index', $params);
     #        	return $view;
 }
Ejemplo n.º 6
0
 /**
  * drop Method
  *
  * データを空にする
  * :all前に実行
  */
 public static function drop()
 {
     $mongodb = \Mongo_Db::instance();
     $bool = $mongodb->delete_all('invites');
 }
Ejemplo n.º 7
0
 public function __construct($instance = 'default')
 {
     $this->mongo = \Mongo_Db::instance($instance);
 }
Ejemplo n.º 8
0
 /**
  * not having today's data
  */
 public function action_thismonths_data()
 {
     $mongodb = \Mongo_Db::instance();
     $from = strtotime('first day of this month 00:00');
     $results = $mongodb->select()->where_gte('timestamp', (string) $from)->get('payment');
     $view = View::forge('sales/detail');
     $this->results = $this->_payment_parse($results);
     return $view;
 }
Ejemplo n.º 9
0
 public function action_error($page = 1)
 {
     /* initialize */
     $mongodb = \Mongo_Db::instance();
     $count = $mongodb->count('error');
     $limit = \Input::get('limit') ? \Input::get('limit') : 20;
     $offset = ($page - 1) * $limit;
     $data = $mongodb->offset($offset)->limit($limit)->order_by(array('timestamp' => 'desc'))->get('error');
     /* 件数が多すぎるので件数だけ渡して却下 */
     if ($count == 0) {
         $error = 'データが見つかりませんでした。';
         /* Viewに渡すデータ */
         $params = array('data' => array(), 'error' => $error, 'config' => array(), 'offset' => 0);
         $this->template->content = View::forge('users/error', $params);
         return;
     }
     /* 時間フォーマットの変更 */
     foreach ($data as $key => $value) {
         $data[$key]['time'] = date("Y-m-d H:i:s", $value['time']->sec);
     }
     /* pagination 作成 */
     $config = array('pagination_url' => 'users/error', 'total_items' => $count, 'per_page' => $limit);
     Pagination::set_config($config);
     /* Viewに渡すデータ */
     $params = array('data' => $data, 'config' => $config, 'offset' => $offset);
     $this->template->content = View::forge('users/error', $params);
     return;
 }