Home php教程 PHP源码 php开发ebay店铺管理系统-订单综合统计

php开发ebay店铺管理系统-订单综合统计

Jun 08, 2016 pm 05:22 PM
date gt lt nbsp quot

给各位同学整理了一个ebay订单综合统计的php源码程序,并且可以生成图形表这样可以让我们一眼就看出每天的相关数据了,下面来看例子

<script>ec(2);</script>

订单综合统计 

 一、主程序/admin/erp_ebay_order_stats.php

 代码如下 复制代码

 
define('IN_ECS', true);
 
require(dirname(__FILE__) . '/includes/init.php');
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/admin/erp_ebay_statistic.php');
$smarty->assign('lang', $_LANG);
 
/* act操作项的初始化 */
if (empty($_REQUEST['act']))
{
    $_REQUEST['act'] = 'view';
}
else
{
    $_REQUEST['act'] = trim($_REQUEST['act']);
}
 
if ($_REQUEST['act'] == 'view')
{
 
    admin_priv('order_stats'); //检查权限
 
    $is_multi = empty($_POST['is_multi']) ? false : true;
 
    /* 时间参数 */
    if (isset($_POST['start_date']) && !empty($_POST['end_date']))
    {
        $start_date = local_strtotime($_POST['start_date']);
        $end_date = local_strtotime($_POST['end_date']);
    }
    else
    {
        $today  = local_strtotime(local_date('Y-m-d'));
        $start_date = $today - 86400 * 14;
        $end_date   = $today;
    }
 
    $start_date_arr = array();
    $end_date_arr = array();
    if(!empty($_POST['year_month']))
    {
        $tmp = $_POST['year_month'];
 
        for ($i = 0; $i         {
            if (!empty($tmp[$i]))
            {
                $tmp_time = local_strtotime($tmp[$i] . '-1');
                //echo $tmp_time;
                $start_date_arr[] = $tmp_time;
                $end_date_arr[]   = local_strtotime($tmp[$i] . '-' . date('t', $tmp_time));
 
                //echo local_strtotime($tmp[$i] . '-' . date('t', $tmp_time));
            }
        }
    }
    else
    {
        $tmp_time = local_strtotime(local_date('Y-m-d'));
        $start_date_arr[] = local_strtotime(local_date('Y-m') . '-1');
        $end_date_arr[]   = local_strtotime(local_date('Y-m') . '-31');;
    }
 
    /* ------------------------------------- */
    /* -- 综合订单量
    /* ------------------------------------- */
    $max = 0;
 
    if(!$is_multi)
    {
        $general_xml = "";
 
        $sql = "SELECT FLOOR((created_time - $start_date) / (24 * 3600)) AS sn, created_time, COUNT(*) AS order_count".
                " FROM " .$ecs->table('erp_ebay_order').
                " WHERE ebay_status = 'Complete' AND created_time >= '$start_date' AND created_time                 " GROUP BY sn";
        $res = $db->query($sql);
 
        $key = 0;
 
        while ($val = $db->fetchRow($res))
        {
            $val['order_date'] = gmdate('m-d',$val['created_time'] +  $timezone * 3600 + 86400);
            $general_xml .= "";
            if ($val['order_count'] > $max)
            {
                $max = $val['order_count'];
            }
            $key++;
        }
 
        $general_xml .= '
';
        $general_xml  = sprintf($general_xml, $max);
    }
    else
    {
        $general_xml = "";
        foreach($start_date_arr AS $k => $val)
        {
 
            $seriesName = local_date('Y-m', $start_date_arr[$k]);
            $general_xml .= "";
            $sql = "SELECT FLOOR((created_time - $start_date_arr[$k]) / (24 * 3600)) AS sn, created_time, COUNT(*) AS order_count".
                " FROM " .$ecs->table('erp_ebay_order').
                " WHERE ebay_status = 'Complete' AND created_time >= '$start_date_arr[$k]' AND created_time                 " GROUP BY sn";
            $res = $db->query($sql);
 
            $lastDay = 0;
 
            while ($val = $db->fetchRow($res))
            {
                $day = gmdate('d', $val['created_time'] +  $timezone * 3600);
 
                if ($lastDay == 0)
                {
                    $time_span = (($day-1) - $lastDay);
                    $lastDay++;
                    for (; $lastDay                     {
                        $general_xml .= "";
                    }
                }
                $general_xml .= "";
 
                $lastDay = $day;
            }
 
            $general_xml .= "
";
        }
 
        $general_xml .= "";
 
        for ($i = 1; $i         {
            $general_xml .= "";
        }
        $general_xml .= "
";
        $general_xml .= "
";
 
        echo $general_xml;
    }
 
    /* ------------------------------------- */
    /* -- 销售额
    /* ------------------------------------- */
    $max = 0;
 
    if(!$is_multi)
    {
        $amount_xml = "";
 
        $sql = "SELECT FLOOR((created_time - $start_date) / (24 * 3600)) AS sn, created_time, SUM(subtotal) AS order_amount".
                " FROM " .$ecs->table('erp_ebay_order').
                " WHERE ebay_status = 'Complete' AND created_time >= '$start_date' AND created_time                 " GROUP BY sn";
        $res = $db->query($sql);
 
        $key = 0;
 
        while ($val = $db->fetchRow($res))
        {
            $val['order_date'] = gmdate('m-d',$val['created_time'] +  $timezone * 3600 + 86400);
            $amount_xml .= "";
            if ($val['order_amount'] > $max)
            {
                $max = $val['order_amount'];
            }
            $key++;
        }
 
        $amount_xml .= '
';
        $amount_xml  = sprintf($amount_xml, $max);
    }
    else
    {
        $amount_xml = "";
        foreach($start_date_arr AS $k => $val)
        {
 
            $seriesName = local_date('Y-m', $start_date_arr[$k]);
            $amount_xml .= "";
            $sql = "SELECT FLOOR((created_time - $start_date_arr[$k]) / (24 * 3600)) AS sn, created_time, SUM(subtotal) AS order_amount".
                " FROM " .$ecs->table('erp_ebay_order').
                " WHERE ebay_status = 'Complete' AND created_time >= '$start_date_arr[$k]' AND created_time                 " GROUP BY sn";
            $res = $db->query($sql);
 
            $lastDay = 0;
 
            while ($val = $db->fetchRow($res))
            {
                $day = gmdate('d',$val['created_time'] +  $timezone * 3600);
 
                if ($lastDay == 0)
                {
                    $time_span = (($day-1) - $lastDay);
                    $lastDay++;
                    for (; $lastDay                     {
                        $amount_xml .= "";
                    }
                }
                $amount_xml .= "";
                $lastDay = $day;
            }
 
            $amount_xml .= "
";
        }
 
        $amount_xml .= "";
 
        for ($i = 1;$i         {
            $amount_xml .= "";
        }
        $amount_xml .= "
";
        $amount_xml .= "
";
    }
 
    /* ------------------------------------- */
    /* -- 状态
    /* ------------------------------------- */
    $status_xml  = '';
 
    if(!$is_multi)
    {
        $status_xml .= "";
 
        $sql = "SELECT COUNT(*) AS order_count, ebay_status FROM " . $ecs->table('erp_ebay_order') .
                " WHERE created_time >= '$start_date' AND created_time                 " GROUP BY ebay_status ORDER BY order_count DESC LIMIT 20";
        $res = $db->query($sql);
 
        $key = 0;
        while ($val = $db->fetchRow($res))
        {
            $ebay_status = empty($val['ebay_status']) ? 'no data' : $val['ebay_status'];
 
            $status_xml .= "";
            $key++;
        }
        $status_xml .= '
';
    }
    else
    {
        $where = '';
        foreach($start_date_arr AS $k => $val)
        {
            if ($where != '')
            {
                $where .= ' or ';
            }
            $where .= "(created_time >= '$start_date_arr[$k]' AND created_time         }
        $sql = "SELECT created_time, ebay_status FROM " . $ecs->table('erp_ebay_order') .
                " WHERE $where";
        $res = $db->query($sql);
        $area_arr = array();
        while ($val = $db->fetchRow($res))
        {
           $date = local_date('Y-m', $val['created_time']);
           $area_arr[$val['ebay_status']] = null;
 
           if (isset($category[$date][$val['ebay_status']]))
           {
               $category[$date][$val['ebay_status']]++;
           }
           else
           {
               $category[$date][$val['ebay_status']] = 1;
           }
        }
        $status_xml = "";
        $status_xml .= "";
        foreach ($area_arr AS $k => $v)
        {
            $status_xml .= "";
        }
        $status_xml .= "
";
        $key = 0;
        foreach($start_date_arr AS $val)
        {
            $key++;
            $date = local_date('Y-m', $val);
            $status_xml .= "";
 
            foreach ($area_arr AS $k => $v)
            {
                if (isset($category[$date][$k]))
                {
                    $status_xml .= "";
                }
                else
                {
                    $status_xml .= "";
                }
            }
            $status_xml .= "
";
        }
        $status_xml .= "
";
    }
 
    /* 模板赋值 */
    $smarty->assign('ur_here',      $_LANG['01_erp_order_stats']);
    $smarty->assign('general_data', $general_xml);
    $smarty->assign('amount_data',  $amount_xml);
    $smarty->assign('status_data',  $status_xml);
    $smarty->assign('is_multi',     $is_multi);
 
    /* 显示日期 */
    $smarty->assign('start_date',   local_date('Y-m-d', $start_date));
    $smarty->assign('end_date',     local_date('Y-m-d', $end_date));
 
    for ($i = 0; $i     {
        if (isset($start_date_arr[$i]))
        {
            $start_date_arr[$i] = local_date('Y-m', $start_date_arr[$i]);
        }
        else
        {
            $start_date_arr[$i] = null;
        }
    }
    $smarty->assign('start_date_arr', $start_date_arr);
 
    if (!$is_multi)
    {
        $filename = gmdate($_CFG['date_format'], $start_date + $timezone * 3600 + 86400) . '_' .
                    gmdate($_CFG['date_format'], $end_date + $timezone * 3600 + 86400);
 
        $smarty->assign('action_link',  array('text' => $_LANG['down_order_stats'],
          'href'=>'erp_ebay_order_stats.php?act=download&filename=' . $filename .
            '&start_date=' . $start_date . '&end_date=' . $end_date));
    }
 
    /* 显示页面 */
    assign_query_info();
    $smarty->display('erp_ebay_order_stats.htm');
}
 
/* 报表下载 */
elseif ($act = 'download')
{
    admin_priv('download_order_stats'); //检查权限
 
    $filename = !empty($_REQUEST['filename']) ? trim($_REQUEST['filename']) : '';
 
    header("Content-type: application/vnd.ms-excel; charset=utf-8");
    header("Content-Disposition: attachment; filename=$filename.xls");
    $start_date = empty($_GET['start_date']) ? strtotime('-20 day') : intval($_GET['start_date']);
    $end_date   = empty($_GET['end_date']) ? time() : intval($_GET['end_date']);
 
    //综合订单量统计
    $sql = "SELECT FLOOR((created_time - $start_date) / (24 * 3600)) AS sn, created_time, COUNT(*) AS order_count, SUM(subtotal) AS order_amount".
                " FROM " . $GLOBALS['ecs']->table('erp_ebay_order') .
                " WHERE created_time >= '$start_date' AND created_time                 " GROUP BY sn";
    $res = $GLOBALS['db']->query($sql);
 
    $data .= $_LANG['date'] . "t";
    $data .= $_LANG['order_count'] . "t";
    $data .= $_LANG['order_amount'] . "tn";
 
    while ($val = $GLOBALS['db']->fetchRow($res))
    {
        $val['created_date'] = gmdate($_CFG['date_format'], $val['created_time'] +  $timezone * 3600 + 86400);
        $data .= $val['created_date'] . "t";
        $data .= $val['order_count'] . "t";
        $data .= price_format($val['order_amount']) . "tn";
 
        $total_count += $val['order_count'];
        $total_amount += $val['order_amount'];
    }
 
    $data .= $_LANG['total'] . "t";
    $data .= $total_count . "t";
    $data .= price_format($total_amount) . "tn";
 
    //状态统计
    $sql = "SELECT COUNT(*) AS order_count, SUM(subtotal) AS order_amount, ebay_status FROM " . $GLOBALS['ecs']->table('erp_ebay_order') .
            " WHERE created_time >= '$start_date' AND created_time             " GROUP BY ebay_status ORDER BY order_count DESC LIMIT 20";
 
    $res = $GLOBALS['db']->query($sql);
 
    $data .= "tn";
    $data .= $_LANG['order_status'] . "t";
    $data .= $_LANG['order_count'] . "t";
    $data .= $_LANG['order_amount'] . "tn";
 
    while ($val = $GLOBALS['db']->fetchRow($res))
    {
        $data .= $val['ebay_status'] . "t";
        $data .= $val['order_count'] . "t";
        $data .= price_format($val['order_amount']) . "tn";
    }
 
    if (EC_CHARSET != 'UTF-8')
    {
        echo ecs_iconv(EC_CHARSET, 'UTF-8', $data) . "t";
    }
    else
    {
        echo $data. "t";
    }
}
 
?>

二、语言文件/languages/zh_cn/admin/erp_ebay_statistic.php

 

 代码如下 复制代码
 
 
/* 订单综合统计 */
$_LANG['tab_general'] = '综合订单量';
$_LANG['tab_amount'] = '销售额';
$_LANG['tab_status'] = '状态';
 
$_LANG['general_stats'] = '综合订单量统计';
$_LANG['amount_stats'] = '销售额统计';
$_LANG['status_stats'] = '状态统计';
 
$_LANG['date'] = '日期';
$_LANG['order_status'] = '状态';
$_LANG['order_count'] = '订单量(个)';
$_LANG['order_amount'] = '销售额';
$_LANG['total'] = '合计';
$_LANG['down_order_stats'] = '订单报表下载';
 
/* 买家排行 */
$_LANG['order_by'] = '排行';
$_LANG['buyer_id'] = '买家';
$_LANG['buyer_email'] = '邮箱';
$_LANG['buyer_phone'] = '电话';
$_LANG['country'] = '国家';
$_LANG['order_count'] = '订单数';
$_LANG['amount_sum'] = '购物金额';
$_LANG['created_time'] = '下单时间';
 
$_LANG['show_num'] = '显示数量';
$_LANG['order_amount_sort'] = '按订单数量排序';
$_LANG['download_amount_sort'] = '排行报表下载';
 
/* 公用 */
$_LANG['query'] = '查询';
$_LANG['start_date'] = '开始日期';
$_LANG['end_date'] = '结束日期';
$_LANG['date_interval'] = '日期';
$_LANG['year_month'] = '年月';
?>

三、模板文件/admin/templates/erp_ebay_order_stats.htm

 代码如下 复制代码

{include file="pageheader.htm"}



 

    {$lang.date_interval}  
   
    --
   
   
 

   

    {$lang.year_month}  
   
    {if $k > 0}
     + 
    {/if}
   
   
   
 



   
   

     


        {$lang.tab_general}
  {$lang.tab_amount}
  {$lang.tab_status}
     


   

   
   


       
       
         
       

           
                          codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
              width="565" height="420" id="FCColumn2" align="middle">
             
             
             
             
             
             
           
           
                          codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
              width="565" height="420" id="FCColumn2" align="middle">
             
             
             
             
             
             
           
           
         

       
       


         
       

       
       


         
       
   

{insert_scripts files="tab.js"}


{include file="pagefooter.htm"}

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

See all articles