zoukankan      html  css  js  c++  java
  • 关于接口的统计

     public function indexAction()
        {
         $session = $_SESSION;
         $userName = $session['userInfo']['username'];
         /*
          * 订单统计表
          * @author ftt
          * @time 2015年11月5日15:53:14
          */
          $md = new Comm_Curl(); //实例化 Curl类
          $day = intval($_GET['day']);  //接收日期id
          $where['day'] = isset($day) ? $day : NULL;
          if($where['day'] == 0){
              $where['day']=1;
              $day=1;
          }
          $data = $md->post('http://www.baidu.com/api/getAdminOrderTongji',$where);
          $data = json_decode($data,TRUE);
    
          $d1=$data['d1'];   //当前(数组)
          $d2=$data['d2'];   //对比(数组)
          $count =$d1['count'];   //当前值(订单数)   
          $order_money=$d1['yizhifu'];
          $yes_order_money=$order_money;
          $money = $d1['money'];
          /*获取订单百分比*/
          $new_order_per = round(($count/$d2['count'])*100);
          if($new_order_per =='0'){
              $new_order_per=100;   //如果对比值为0那么将其设置为百分之百
          }
          if($new_order_per > 1000){
              $new_order_per=1000;
          }
          /*付款订单百分比*/
          $order_money_per = round(($order_money/$d2['yizhifu'])*100);
          if($order_money_per =='0'){
              $order_money_per=100;   //如果对比值为0那么将其设置为百分之百
          }
          
          if($order_money_per > 1000){
              $new_order_per=1000;
          }
          /*确认订单百分比*/
          //目前与确认订单一致
          /*成交额百分比*/
          $money_per = round(($money/$d2['money'])*100);
          if($money_per =='0'){
              $money_per=100;   //如果对比值为0那么将其设置为百分之百
          }
          
          if($money_per > 1000){
              $money_per=1000;
          }
           /**
            * 设置确认订单百分比等于付款订单百分比
            */
          $yes_order_money_per = $order_money_per;
          
         /*比较两次的大小用于对页面显示的百分比箭头做判定*/
         if($count <= $d2['count']){
             $new_order_per_or=2;
         }else{
             $new_order_per_or=1;
         }
         
         if($order_money <= $d2['yizhifu']){
             $order_money_per_or = 2;
             $yes_order_money_per_or = 2;
         }else{
             $order_money_per_or = 1;
             $yes_order_money_per_or = 1;
         }
         if($money <= $d2['money']){
             $money_per_or = 2;
         }else{
             $money_per_or = 1;
         }
          
          
         /*
          * 判断day的值进行字符串拼接
          */
          $dayType = '';
          switch ($day) {
              case 1:
                  $dayType='今日';
                  break;
               case 2:
                  $dayType='昨天';
                  break;
               case 3:
                  $dayType='本周';
                  break;
               case 4:
                  $dayType='本月';
                  break;
               case 5:
                  $dayType='本季度';
                  break;
               case 6:
                  $dayType='本年';
                  break;
               case 7:
                  $dayType='全部';
                  break;
              default:
                  $dayType='今日';
                  break;
          }
         
         $lists = array(
             'new_order'=>$count,                       //新订单
             'new_order_per'=>$new_order_per,
             'new_order_per_or'=>$new_order_per_or,
             'order_money'=>$order_money,                //付款订单
             'order_money_per'=>$order_money_per,
             'order_money_per_or'=>$order_money_per_or,
             'yes_order_money'=>$order_money,            //确认订单
             'yes_order_money_per'=>$yes_order_money_per,
             'yes_order_money_per_or'=>$yes_order_money_per_or,
             'money'=>$money,                            //成交额
             'money_per'=>$money_per,
             'money_per_or'=>$money_per_or,
             'dayType'=>$dayType,
             'day1'=>$day,
         );
         
         
    //     print_r($lists);   
         $view = $this->getView();
         $view->assign("day",$day);
         $view->assign("val",$lists);  //订单统计数
         $view->assign("userName", $userName);
         $this->getView()->display("admin/index.html");
        }
    <{include file="admin/header.html"}>
    
            <{include file="admin/left.html"}>
    
            <div class="main-content">
                <div class="breadcrumbs" id="breadcrumbs">
                    <script type="text/javascript">
                        try {
                            ace.settings.check('breadcrumbs', 'fixed')
                        } catch (e) {
                        }
                    </script>
    
                    <ul class="breadcrumb">
                        <li>
                            <i class="icon-home home-icon"></i>
                            <a href="/">首页</a>
                        </li>
                        <li class="active">控制台</li>
                    </ul><!-- .breadcrumb -->
    
                   
                </div>
    
                <div class="page-content myorder">
                    <!-- /.page-header -->
     <p class="welcome">欢迎“<span class="username"><{$smarty.session.userInfo.username}></span>”进入中细软电商后台管理系统!</p>
        <div class="order_header"></div>
            <ul class="order_time">
                <li class="<{if $day==1 || $day==''}>now_time<{/if}> btii" id="1">今天</li>
                <li class="<{if $day==2}>now_time<{/if}> btii" id="2">昨天</li>
                <li class="<{if $day==3}>now_time<{/if}> btii" id="3">本周</li>
                <li class="<{if $day==4}>now_time<{/if}> btii" id="4">本月</li>
                <li class="<{if $day==5}>now_time<{/if}> btii" id="5">本季度</li>
                <li class="<{if $day==6}>now_time<{/if}> btii" id="6">本年</li>
                <li class="<{if $day==7}>now_time<{/if}> btii" id="7">全部</li>
            </ul>
            <div class="order_content">
                <ul>
                    <li>
                        <em class="icon new_order icon_type"></em>
                        <span class="num num_order"><{$val['new_order']}></span>
                        <span class="type"><{$val['dayType']}>生成新订单</span>
                        <div class="proportion proportion_order"><{$val['new_order_per']}>%<em class="<{if $val['new_order_per_or'] ==1}>icon order_up<{else}>icon order_down<{/if}>"></em></div>
                    </li>
                    <li>
                        <em class="icon pay_order icon_type"></em>
                        <span class="num num_pay"><{$val['order_money']}></span>
                        <span class="type"><{$val['dayType']}>付款订单</span>
                        <div class="proportion proportion_pay"><{$val['order_money_per']}>%<em class="<{if $val['order_money_per_or'] ==1}>icon order_up<{else}>icon order_down<{/if}>"></em></div>
                    </li>
                    <li>
                        <em class="icon pay_ok icon_type"></em>
                        <span class="num num_ok"><{$val['yes_order_money']}></span>
                        <span class="type">支付确认订单</span>
                        <div class="proportion proportion_ok"><{$val['yes_order_money_per']}>%<em class="<{if $val['yes_order_money_per_or'] ==1}>icon order_up<{else}>icon order_down<{/if}>"></em></div>
                    </li>
                    <li>
                        <em class="icon pay_num icon_type"></em>
                        <span class="num num_num"><{$val['money']}></span>
                        <span class="type"><{$val['dayType']}>成交额</span>
                        <div class="proportion proportion_num"><{$val['money_per']}>%<em class="<{if $val['money_per_or'] ==1}>icon order_up<{else}>icon order_down<{/if}>"></em></div>
                    </li>
                </ul>
            </div>
    
        </div>
    </div>
                </div><!-- /.page-content -->
            </div><!-- /.main-content -->
    
            <{include file="admin/footer.html"}>
    <script type="text/JavaScript">
        $(function(){
            //添加搜索@ftt:2015-11-5 16:56:27
            $('.btii').click(function () {
               var vid = this.id;   //获取id的值
               location.href = "/index.php/admin/index?day="+vid;
            });
        });  
    </script>
    public function getAdminOrderTongjiAction() {
            $day = isset ( $this->request ['day'] ) ? Comm_Tools::removeXSS ( trim ( $this->request ['day'] ) ) : 1;
            $sql = '';
            switch ($day) {
                case 1 : // 当天
    
                         
                    // 昨天开始和结束
                    $nowup = date ( "Y/m/d H:i:s", mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) ) ); // 昨天开始
                    $nowdown = date ( "Y/m/d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) ) ); // 昨天结束
                    
                    $d1 = $this->getAdminOrders ( date ( 'Y-m-d' ), date ( 'Y-m-d 23:59:59' ) );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
    
                    break;
                case 2 : // 昨天
    
                         
                    // 昨天开始和结束
                    $now = date ( "Y/m/d H:i:s", mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) ) ); // 昨天开始
                    $end = date ( "Y/m/d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "d" ) - 1, date ( "Y" ) ) ); // 昨天结束
                                                                                                 
                    // 前天开始和结束
                    $nowup = date ( "Y/m/d H:i:s", mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - 2, date ( "Y" ) ) );
                    $nowdown = date ( "Y/m/d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "d" ) - 2, date ( "Y" ) ) );
                    
                    $d1 = $this->getAdminOrders ( $now, $end );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
                    break;
                case 3 : // 本周
                         // 上周起始时间:
                    $nowup = date ( "Y-m-d H:i:s", mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - date ( "w" ) + 1 - 7, date ( "Y" ) ) );
                    $nowdown = date ( "Y-m-d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "d" ) - date ( "w" ) + 7 - 7, date ( "Y" ) ) );
                    // 本周起始时间:
                    $now = date ( "Y-m-d H:i:s", mktime ( 0, 0, 0, date ( "m" ), date ( "d" ) - date ( "w" ) + 1, date ( "Y" ) ) );
                    $end = date ( "Y-m-d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "d" ) - date ( "w" ) + 7, date ( "Y" ) ) );
                    
                    $d1 = $this->getAdminOrders ( $now, $end );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
                    break;
                case 4 : // 本月
                         // 上月起始时间:
                    $nowup = date ( "Y-m-d H:i:s", mktime ( 0, 0, 0, date ( "m" ) - 1, 1, date ( "Y" ) ) );
                    $nowdown = date ( "Y-m-d H:i:s", mktime ( 23, 59, 59, date ( "m" ), 0, date ( "Y" ) ) );
                    // 本月起始时间:
                    $now = date ( "Y-m-d H:i:s", mktime ( 0, 0, 0, date ( "m" ), 1, date ( "Y" ) ) );
                    $end = date ( "Y-m-d H:i:s", mktime ( 23, 59, 59, date ( "m" ), date ( "t" ), date ( "Y" ) ) );
                    
                    $d1 = $this->getAdminOrders ( $now, $end );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
                    break;
                case 5 : // 季度
                    $season = ceil ( (date ( 'n' )) / 3 ) - 1; // 上季度是第几季度
                                                     // 上季度起始时间:
                    $nowup = date ( 'Y-m-d H:i:s', mktime ( 0, 0, 0, $season * 3 - 3 + 1, 1, date ( 'Y' ) ) );
                    $nowdown = date ( 'Y-m-d H:i:s', mktime ( 23, 59, 59, $season * 3, date ( 't', mktime ( 0, 0, 0, $season * 3, 1, date ( "Y" ) ) ), date ( 'Y' ) ) );
                    $season = ceil ( (date ( 'n' )) / 3 );
                    
                    // 本季度起始时间:
                    $now = date ( 'Y-m-d H:i:s', mktime ( 0, 0, 0, $season * 3 - 3 + 1, 1, date ( 'Y' ) ) );
                    $end = date ( 'Y-m-d H:i:s', mktime ( 23, 59, 59, $season * 3, date ( 't', mktime ( 0, 0, 0, $season * 3, 1, date ( "Y" ) ) ), date ( 'Y' ) ) );
                    
                    $d1 = $this->getAdminOrders ( $now, $end );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
                    break;
                case 6 : // 本年
                         // 上年起始时间:
                    $nowup = date ( "Y-m-d", mktime ( 0, 0, 0, 01, 01, date ( "Y" ) - 1 ) );
                    $nowdown = date ( "Y-m-d ", mktime ( 23, 59, 59, 12, 31, date ( "Y" ) - 1 ) );
                    // 本年起始时间:
                    $now = date ( "Y-m-d", mktime ( 0, 0, 0, 01, 01, date ( "Y" ) ) );
                    $end = date ( "Y-m-d", mktime ( 23, 59, 59, 12, 31, date ( "Y" ) ) );
                    $d1 = $this->getAdminOrders ( $now, $end );
                    $d2 = $this->getAdminOrders ( $nowup, $nowdown );
                    echo json_encode ( array (
                            'd1' => $d1,
                            'd2' => $d2 
                    ) );
                    break;
                case 7 : // 全部
                         // 全部起始时间:
                    $d1 = $this->getAdminOrders ( '2015-01-01', '2020-12-31' );
                    echo json_encode ( array (
                            'd1' => $d1 
                    ) );
                    break;
                default :
                    echo json_encode ( array (
                            'd1' => array (),
                            'd2' => array () 
                    ) );
                    ;
                    break;
            }
            exit ();
        }
  • 相关阅读:
    smarty语法
    combobox里面显示checkbox
    requirejs打包项目
    datagrid中用tooltip
    combobox默认值为第一个数据,修改为空值
    easyui-textbox高为0
    C++并发编程 异步任务
    C++并发编程 互斥和同步
    C++并发编程 thread
    C++智能指针
  • 原文地址:https://www.cnblogs.com/patf/p/4952249.html
Copyright © 2011-2022 走看看