Пример #1
0
 /**
  * 商品流量统计
  */
 public function goodsflowOp()
 {
     $store_id = intval($_SESSION['store_id']);
     //确定统计分表名称
     $last_num = $store_id % 10;
     //获取店铺ID的末位数字
     $tablenum = ($t = intval(C('flowstat_tablenum'))) > 1 ? $t : 1;
     //处理流量统计记录表数量
     $flow_tablename = ($t = $last_num % $tablenum) > 0 ? "flowstat_{$t}" : 'flowstat';
     if (!$this->search_arr['search_type']) {
         $this->search_arr['search_type'] = 'week';
     }
     $model = Model('stat');
     //获得搜索的开始时间和结束时间
     $searchtime_arr = $model->getStarttimeAndEndtime($this->search_arr);
     $where = array();
     $where['store_id'] = $store_id;
     $where['stattime'] = array('between', $searchtime_arr);
     $where['type'] = 'goods';
     $field = ' goods_id,SUM(clicknum) as amount';
     $stat_arr = array();
     //构造横轴数据
     for ($i = 1; $i <= 30; $i++) {
         //横轴
         $stat_arr['xAxis']['categories'][] = $i;
         $stat_arr['series'][0]['data'][] = array('name' => '', 'y' => 0);
     }
     $statlist_tmp = $model->statByFlowstat($flow_tablename, $where, $field, 0, 30, 'amount desc,goods_id asc', 'goods_id');
     if ($statlist_tmp) {
         $goodsid_arr = array();
         foreach ((array) $statlist_tmp as $k => $v) {
             $goodsid_arr[] = $v['goods_id'];
         }
         //查询相应商品
         $goods_list_tmp = $model->statByGoods(array('goods_id' => array('in', $goodsid_arr)), $field = 'goods_name,goods_id');
         foreach ((array) $goods_list_tmp as $k => $v) {
             $goods_list[$v['goods_id']] = $v;
         }
         foreach ((array) $statlist_tmp as $k => $v) {
             $v['goods_name'] = $goods_list[$v['goods_id']];
             $v['amount'] = floatval($v['amount']);
             $statlist[] = $v;
             $stat_arr['series'][0]['data'][$k] = array('name' => strval($goods_list[$v['goods_id']]['goods_name']), 'y' => floatval($v['amount']));
         }
     }
     //得到统计图数据
     $stat_arr['legend']['enabled'] = false;
     $stat_arr['series'][0]['name'] = '访问量';
     $stat_arr['title'] = '商品访问量TOP30';
     $stat_arr['yAxis'] = '访问次数';
     $stat_json = uk86_getStatData_Column2D($stat_arr);
     Tpl::output('stat_json', $stat_json);
     self::profile_menu('goodsflow');
     Tpl::showpage('stat.flow.goods');
 }
Пример #2
0
 /**
  * 热卖商品列表
  */
 public function hotgoods_listOp()
 {
     $model = Model('stat');
     switch ($_GET['type']) {
         case 'goodsnum':
             $sort_text = '下单量';
             break;
         default:
             $_GET['type'] = 'orderamount';
             $sort_text = '下单金额';
             break;
     }
     //构造横轴数据
     for ($i = 1; $i <= 50; $i++) {
         //数据
         $stat_arr['series'][0]['data'][] = array('name' => '', 'y' => 0);
         //横轴
         $stat_arr['xAxis']['categories'][] = "{$i}";
     }
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $searchtime_arr_tmp = explode('|', $this->search_arr['t']);
     foreach ((array) $searchtime_arr_tmp as $k => $v) {
         $searchtime_arr[] = intval($v);
     }
     $where['order_add_time'] = array('between', $searchtime_arr);
     //商品分类
     if ($this->choose_gcid > 0) {
         //获得分类深度
         $depth = $this->gc_arr[$this->choose_gcid]['depth'];
         $where['gc_parentid_' . $depth] = $this->choose_gcid;
     }
     //查询统计数据
     $field = ' goods_id,goods_name ';
     switch ($_GET['type']) {
         case 'goodsnum':
             $field .= ' ,SUM(goods_num) as goodsnum ';
             $orderby = 'goodsnum desc';
             break;
         default:
             $_GET['type'] = 'orderamount';
             $field .= ' ,SUM(goods_pay_price) as orderamount ';
             $orderby = 'orderamount desc';
             break;
     }
     $orderby .= ',goods_id';
     $statlist = $model->statByStatordergoods($where, $field, 0, 50, $orderby, 'goods_id');
     foreach ((array) $statlist as $k => $v) {
         switch ($_GET['type']) {
             case 'goodsnum':
                 $stat_arr['series'][0]['data'][$k] = array('name' => strval($v['goods_name']), 'y' => intval($v[$_GET['type']]));
                 break;
             case 'orderamount':
                 $stat_arr['series'][0]['data'][$k] = array('name' => strval($v['goods_name']), 'y' => floatval($v[$_GET['type']]));
                 break;
         }
         $statlist[$k]['sort'] = $k + 1;
     }
     $stat_arr['series'][0]['name'] = $sort_text;
     $stat_arr['legend']['enabled'] = false;
     //得到统计图数据
     $stat_arr['title'] = '热卖商品TOP50';
     $stat_arr['yAxis'] = $sort_text;
     $stat_json = uk86_getStatData_Column2D($stat_arr);
     Tpl::output('stat_json', $stat_json);
     Tpl::output('statlist', $statlist);
     Tpl::output('sort_text', $sort_text);
     Tpl::output('stat_field', $_GET['type']);
     Tpl::showpage('stat.goods.hotgoods.list', 'null_layout');
 }
Пример #3
0
 /**
  * 热卖商品
  */
 public function hotgoodsOp()
 {
     $topnum = 30;
     if (!$this->search_arr['search_type']) {
         $this->search_arr['search_type'] = 'day';
     }
     $model = Model('stat');
     //获得搜索的开始时间和结束时间
     $searchtime_arr = $model->getStarttimeAndEndtime($this->search_arr);
     $model = Model('stat');
     $where = array();
     $where['store_id'] = $_SESSION['store_id'];
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['order_add_time'] = array('between', $searchtime_arr);
     //查询销量top
     //构造横轴数据
     for ($i = 1; $i <= $topnum; $i++) {
         //数据
         $stat_arr['series'][0]['data'][] = array('name' => '', 'y' => 0);
         //横轴
         $stat_arr['xAxis']['categories'][] = "{$i}";
     }
     $field = ' goods_id,goods_name,SUM(goods_num) as goodsnum ';
     $orderby = 'goodsnum desc,goods_id';
     $statlist = array();
     $statlist['goodsnum'] = $model->statByStatordergoods($where, $field, 0, $topnum, $orderby, 'goods_id');
     foreach ((array) $statlist['goodsnum'] as $k => $v) {
         $stat_arr['series'][0]['data'][$k] = array('name' => strval($v['goods_name']), 'y' => intval($v['goodsnum']));
     }
     $stat_arr['series'][0]['name'] = '下单商品数';
     $stat_arr['legend']['enabled'] = false;
     //得到统计图数据
     $stat_arr['title'] = '热卖商品TOP' . $topnum;
     $stat_arr['yAxis'] = '下单商品数';
     $stat_json['goodsnum'] = uk86_getStatData_Column2D($stat_arr);
     unset($stat_arr);
     //查询下单金额top
     //构造横轴数据
     for ($i = 1; $i <= $topnum; $i++) {
         //数据
         $stat_arr['series'][0]['data'][] = array('name' => '', 'y' => 0);
         //横轴
         $stat_arr['xAxis']['categories'][] = "{$i}";
     }
     $field = ' goods_id,goods_name,SUM(goods_pay_price) as orderamount ';
     $orderby = 'orderamount desc,goods_id';
     $statlist['orderamount'] = $model->statByStatordergoods($where, $field, 0, $topnum, $orderby, 'goods_id');
     foreach ((array) $statlist['orderamount'] as $k => $v) {
         $stat_arr['series'][0]['data'][$k] = array('name' => strval($v['goods_name']), 'y' => floatval($v['orderamount']));
     }
     $stat_arr['series'][0]['name'] = '下单金额';
     $stat_arr['legend']['enabled'] = false;
     //得到统计图数据
     $stat_arr['title'] = '热卖商品TOP' . $topnum;
     $stat_arr['yAxis'] = '下单金额';
     $stat_json['orderamount'] = uk86_getStatData_Column2D($stat_arr);
     Tpl::output('stat_json', $stat_json);
     Tpl::output('statlist', $statlist);
     self::profile_menu('hotgoods');
     Tpl::showpage('stat.goods.hotgoods');
 }
Пример #4
0
 /**
  * 行业排行
  */
 public function hotOp()
 {
     $datanum = 30;
     if (!$this->search_arr['search_type']) {
         $this->search_arr['search_type'] = 'day';
     }
     $model = Model('stat');
     //获得搜索的开始时间和结束时间
     $searchtime_arr = $model->getStarttimeAndEndtime($this->search_arr);
     $where = array();
     $where['order_isvalid'] = 1;
     //计入统计的有效订单
     $where['order_add_time'] = array('between', $searchtime_arr);
     $where['store_id'] = array('neq', $_SESSION['store_id']);
     $gc_id_depth = $this->gc_arr[$this->choose_gcid]['depth'];
     if ($this->choose_gcid > 0) {
         $where['gc_parentid_' . $gc_id_depth] = $this->choose_gcid;
     }
     /**
      * 商品排行
      */
     $goods_stat_arr = array();
     //构造横轴数据
     for ($i = 1; $i <= $datanum; $i++) {
         //数据
         $goods_stat_arr['series'][0]['data'][] = array('name' => '', 'y' => 0);
         //横轴
         $goods_stat_arr['xAxis']['categories'][] = "{$i}";
     }
     $field = 'goods_id,goods_name,SUM(goods_num) as goodsnum';
     $goods_list = $model->statByStatordergoods($where, $field, 0, $datanum, 'goodsnum desc,goods_id asc', 'goods_id');
     foreach ((array) $goods_list as $k => $v) {
         $goods_stat_arr['series'][0]['data'][$k] = array('name' => strval($v['goods_name']), 'y' => floatval($v['goodsnum']));
     }
     //得到统计图数据
     $goods_stat_arr['series'][0]['name'] = '下单商品数';
     $goods_stat_arr['title'] = "行业商品{$datanum}强";
     $goods_stat_arr['legend']['enabled'] = false;
     $goods_stat_arr['yAxis'] = '下单商品数';
     $goods_statjson = uk86_getStatData_Column2D($goods_stat_arr);
     Tpl::output('goods_statjson', $goods_statjson);
     Tpl::output('goods_list', $goods_list);
     self::profile_menu('hot');
     Tpl::showpage('stat.industry.hot');
 }
Пример #5
0
 /**
  * 会员分析
  */
 public function analyzeOp()
 {
     if (!$this->search_arr['search_type']) {
         $this->search_arr['search_type'] = 'day';
     }
     $model = Model('stat');
     //构造横轴数据
     for ($i = 1; $i <= 15; $i++) {
         //横轴
         $stat_arr['xAxis']['categories'][] = $i;
     }
     $stat_arr['title'] = '买家排行Top15';
     $stat_arr['legend']['enabled'] = false;
     //获得搜索的开始时间和结束时间
     $searchtime_arr = $model->getStarttimeAndEndtime($this->search_arr);
     $where = array();
     $where['statm_time'] = array('between', $searchtime_arr);
     //下单量
     $where['statm_ordernum'] = array('gt', 0);
     $field = ' statm_memberid, statm_membername, SUM(statm_ordernum) as ordernum ';
     $ordernum_listtop15 = $model->statByStatmember($where, $field, 0, 15, 'ordernum desc,statm_memberid desc', 'statm_memberid');
     $stat_ordernum_arr = $stat_arr;
     $stat_ordernum_arr['series'][0]['name'] = '下单量';
     $stat_ordernum_arr['series'][0]['data'] = array();
     for ($i = 0; $i < 15; $i++) {
         $stat_ordernum_arr['series'][0]['data'][] = array('name' => strval($ordernum_listtop15[$i]['statm_membername']), 'y' => intval($ordernum_listtop15[$i]['ordernum']));
     }
     $stat_ordernum_arr['yAxis'] = '下单量';
     $statordernum_json = uk86_getStatData_Column2D($stat_ordernum_arr);
     unset($stat_ordernum_arr);
     Tpl::output('statordernum_json', $statordernum_json);
     Tpl::output('ordernum_listtop15', $ordernum_listtop15);
     //下单商品件数
     $where['statm_goodsnum'] = array('gt', 0);
     $field = ' statm_memberid, statm_membername, SUM(statm_goodsnum) as goodsnum ';
     $goodsnum_listtop15 = $model->statByStatmember($where, $field, 0, 15, 'goodsnum desc,statm_memberid desc', 'statm_memberid');
     $stat_goodsnum_arr = $stat_arr;
     $stat_goodsnum_arr['series'][0]['name'] = '下单商品件数';
     $stat_goodsnum_arr['series'][0]['data'] = array();
     for ($i = 0; $i < 15; $i++) {
         $stat_goodsnum_arr['series'][0]['data'][] = array('name' => strval($goodsnum_listtop15[$i]['statm_membername']), 'y' => intval($goodsnum_listtop15[$i]['goodsnum']));
     }
     $stat_goodsnum_arr['yAxis'] = '下单商品件数';
     $statgoodsnum_json = uk86_getStatData_Column2D($stat_goodsnum_arr);
     unset($stat_goodsnum_arr);
     Tpl::output('statgoodsnum_json', $statgoodsnum_json);
     Tpl::output('goodsnum_listtop15', $goodsnum_listtop15);
     //下单金额
     $where['statm_orderamount'] = array('gt', 0);
     $field = ' statm_memberid, statm_membername, SUM(statm_orderamount) as orderamount ';
     $orderamount_listtop15 = $model->statByStatmember($where, $field, 0, 15, 'orderamount desc,statm_memberid desc', 'statm_memberid');
     $stat_orderamount_arr = $stat_arr;
     $stat_orderamount_arr['series'][0]['name'] = '下单金额';
     $stat_orderamount_arr['series'][0]['data'] = array();
     for ($i = 0; $i < 15; $i++) {
         $stat_orderamount_arr['series'][0]['data'][] = array('name' => strval($orderamount_listtop15[$i]['statm_membername']), 'y' => floatval($orderamount_listtop15[$i]['orderamount']));
     }
     $stat_orderamount_arr['yAxis'] = '下单金额';
     $statorderamount_json = uk86_getStatData_Column2D($stat_orderamount_arr);
     unset($stat_orderamount_arr);
     Tpl::output('statorderamount_json', $statorderamount_json);
     Tpl::output('orderamount_listtop15', $orderamount_listtop15);
     Tpl::output('searchtime', implode('|', $searchtime_arr));
     Tpl::output('top_link', $this->sublink($this->links, 'analyze'));
     Tpl::showpage('stat.memberanalyze');
 }