Ejemplo n.º 1
0
 /**
  * 促销分析
  */
 public function promotionOp()
 {
     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['goods_type'] = array('in', array(2, 3, 4));
     //下单量
     $field = ' goods_type,count(DISTINCT order_id) as ordernum,SUM(goods_num) as goodsnum,SUM(goods_pay_price) as orderamount';
     $statlist_tmp = $model->statByStatordergoods($where, $field, 0, 0, 'goods_type', 'goods_type');
     //优惠类型数组
     $goodstype_arr = array(2 => '抢购', 3 => '限时折扣', 4 => '优惠套装');
     $statlist = array();
     $statcount = array('ordernum' => 0, 'goodsnum' => 0, 'orderamount' => 0.0);
     $stat_arr = array();
     $stat_json = array('ordernum' => '', 'goodsnum' => '', 'orderamount' => '');
     if ($statlist_tmp) {
         foreach ((array) $statlist_tmp as $k => $v) {
             $statcount['ordernum'] += intval($v['ordernum']);
             $statcount['goodsnum'] += intval($v['goodsnum']);
             $statcount['orderamount'] += floatval($v['orderamount']);
         }
         foreach ((array) $statlist_tmp as $k => $v) {
             $v['ordernumratio'] = round($v['ordernum'] / $statcount['ordernum'], 4) * 100;
             $v['goodsnumratio'] = round($v['goodsnum'] / $statcount['goodsnum'], 4) * 100;
             $v['orderamountratio'] = round($v['orderamount'] / $statcount['orderamount'], 4) * 100;
             $statlist_tmp2[$v['goods_type']] = $v;
             $stat_arr['ordernum'][] = array('p_name' => $goodstype_arr[$v['goods_type']], 'allnum' => $v['ordernumratio']);
             $stat_arr['goodsnum'][] = array('p_name' => $goodstype_arr[$v['goods_type']], 'allnum' => $v['goodsnumratio']);
             $stat_arr['orderamount'][] = array('p_name' => $goodstype_arr[$v['goods_type']], 'allnum' => $v['orderamountratio']);
         }
         foreach ($goodstype_arr as $k => $v) {
             if ($statlist_tmp2[$k]) {
                 $statlist_tmp2[$k]['goodstype_text'] = $v;
                 $statlist[] = $statlist_tmp2[$k];
             } else {
                 $statlist[] = array('goodstype_text' => $k, 'goodstype_text' => $v, 'ordernum' => 0, 'goodsnum' => 0, 'orderamount' => 0.0);
             }
         }
         $stat_json['ordernum'] = uk86_getStatData_Pie(array('title' => '下单量', 'name' => '下单量(%)', 'label_show' => false, 'series' => $stat_arr['ordernum']));
         $stat_json['goodsnum'] = uk86_getStatData_Pie(array('title' => '下单商品数', 'name' => '下商品数(%)', 'label_show' => false, 'series' => $stat_arr['goodsnum']));
         $stat_json['orderamount'] = uk86_getStatData_Pie(array('title' => '下单金额', 'name' => '下单金额(%)', 'label_show' => false, 'series' => $stat_arr['orderamount']));
     }
     Tpl::output('statcount', $statcount);
     Tpl::output('statlist', $statlist);
     Tpl::output('stat_json', $stat_json);
     Tpl::output('searchtime', implode('|', $searchtime_arr));
     Tpl::output('top_link', $this->sublink($this->links, 'promotion'));
     Tpl::showpage('stat.marketing.promotion');
 }
Ejemplo n.º 2
0
 /**
  * 店铺等级
  */
 public function degreeOp()
 {
     $where = array();
     $field = ' count(*) as allnum,grade_id ';
     $model = Model('stat');
     //查询店铺分类下的店铺
     $search_sclass = intval($_REQUEST['search_sclass']);
     if ($search_sclass > 0) {
         $where['sc_id'] = $search_sclass;
     }
     $storelist = $model->getNewStoreStatList($where, $field, 0, '', 0, 'grade_id');
     $sd_list = $model->getStoreDegree();
     $statlist['headertitle'] = array();
     $statlist['data'] = array();
     //处理数组数据
     if (!empty($storelist)) {
         foreach ($storelist as $k => $v) {
             $storelist[$k]['p_name'] = $v['grade_id'] > 0 ? $sd_list[$v['grade_id']] : '平台店铺';
             $storelist[$k]['allnum'] = intval($v['allnum']);
             $statlist['headertitle'][] = $v['grade_id'] > 0 ? $sd_list[$v['grade_id']] : '平台店铺';
             $statlist['data'][] = $v['allnum'];
         }
         $data = array('title' => '店铺等级统计', 'name' => '店铺个数', 'label_show' => true, 'series' => $storelist);
         Tpl::output('stat_json', uk86_getStatData_Pie($data));
     }
     Tpl::output('top_link', $this->sublink($this->links, 'degree'));
     Tpl::showpage('stat.storedegree');
 }