예제 #1
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $shop_rank = Cache_GetShopGM::getInstance()->get_shopRank($userInfo_array);
     $data = array();
     $data['data']['fields'] = array('rank' => '排名', 'item_id' => '道具ID', 'item_name' => '道具名', 'player_num' => '人数', 'times' => '次数', 'num' => '数量', 'money' => '金额');
     $data['data']['list'] = $shop_rank;
     $data['status'] = 1;
     echo json_encode($data, JSON_UNESCAPED_UNICODE);
 }
예제 #2
0
 /**
  * 商城消费排行
  * @param array $objDataInfo
  * @return unknown
  */
 public function get_shopRank($objDataInfo)
 {
     $page = $objDataInfo['page'] ? $objDataInfo['page'] : '1';
     $page_size = $objDataInfo['size'] ? $objDataInfo['size'] : '20';
     $all_page = $objDataInfo['all_page'];
     $serverId = $objDataInfo['serverId'];
     $stime = $objDataInfo['start_time'];
     $etime = $objDataInfo['end_time'];
     if ($stime) {
         $start_time = date('Y-m-d 00:00:00', strtotime($stime));
         $condition .= " add_time >= " . strtotime($start_time) . " AND";
     } else {
         $start_time = date('Y-m-d 00:00:00', time());
         $condition .= " add_time >= " . strtotime($start_time) . " AND";
     }
     if ($etime) {
         $end_time = date('Y-m-d 23:59:59', strtotime($etime));
         $condition .= " add_time <= " . strtotime($end_time) . " AND";
     } else {
         $end_time = date('Y-m-d 23:59:59', time());
         $condition .= " add_time <= " . strtotime($end_time) . " AND";
     }
     if ($condition) {
         $condition = 'where ' . $condition;
         $condition = substr($condition, 0, -3);
     }
     $shoprank_info = array();
     $shop_rank = array();
     $table = Cache_GetShopGM::get_table_name("log_shop_", $start_time, $end_time, false);
     $page_num_sql = "SELECT a.item_id AS item_id,a.item_name AS item_name,COUNT(DISTINCT a.player_id) AS player_num,COUNT(*) AS times,SUM(a.item_num) AS num,SUM(a.resource_num) AS money FROM ({$table}) AS a " . $condition . " GROUP BY item_id ORDER BY SUM(resource_num) DESC";
     $rank_temp = $this->select_all($page_num_sql);
     // $sql = 'select a.item_id as item_id,a.item_name item_name,count(distinct a.player_id) as player_num,count(*) as times,sum(a.item_num) as num,sum(a.resource_num) as money from ($table) as a '.$condition.' group by item_id';
     // $rank_temp = $this->select_all($sql);
     foreach ($rank_temp as $k => $v) {
         $shoprank_info[$k]['rank'] = $k + 1;
         $shoprank_info[$k]['item_id'] = $v['item_id'];
         $shoprank_info[$k]['item_name'] = $v['item_name'];
         $shoprank_info[$k]['player_num'] = $v['player_num'];
         $shoprank_info[$k]['times'] = $v['times'];
         $shoprank_info[$k]['num'] = $v['num'];
         $shoprank_info[$k]['money'] = $v['money'];
         //充值账号数
     }
     return $shoprank_info;
 }