后台首页统计新增权限和时间筛选

This commit is contained in:
Devil 2021-08-31 16:06:01 +08:00
parent 920fcb5807
commit a7b45d4f47
11 changed files with 1207 additions and 639 deletions

View File

@ -230,6 +230,10 @@ class Common extends BaseController
// 系统基础信息
$is_system_show_base = (empty($site_store_info) || empty($site_store_info['vip']) || !isset($site_store_info['vip']['status']) || $site_store_info['vip']['status'] == 0 || ($site_store_info['vip']['status'] == 1 && (AdminIsPower('index', 'storeaccountsbind') || AdminIsPower('index', 'inspectupgrade')))) ? 1 : 0;
MyViewAssign('is_system_show_base', $is_system_show_base);
// 后台公告
$admin_notice = MyC('admin_notice');
MyViewAssign('admin_notice', empty($admin_notice) ? '' : str_replace("\n", '<br />', $admin_notice));
}
/**

View File

@ -72,47 +72,55 @@ class Index extends Common
{
// 系统信息
$mysql_ver = \think\facade\Db::query('SELECT VERSION() AS `ver`');
$data = array(
'server_ver' => php_sapi_name(),
'php_ver' => PHP_VERSION,
'mysql_ver' => isset($mysql_ver[0]['ver']) ? $mysql_ver[0]['ver'] : '',
'os_ver' => PHP_OS,
'host' => isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '',
'ver' => 'ShopXO'.' '.APPLICATION_VERSION,
);
$data = [
'server_ver' => php_sapi_name(),
'php_ver' => PHP_VERSION,
'mysql_ver' => isset($mysql_ver[0]['ver']) ? $mysql_ver[0]['ver'] : '',
'os_ver' => PHP_OS,
'host' => isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '',
'ver' => 'ShopXO'.' '.APPLICATION_VERSION,
];
MyViewAssign('data', $data);
// 用户
$user = StatisticalService::UserYesterdayTodayTotal();
MyViewAssign('user', $user['data']);
// 用户是否有数据统计权限
$is_stats = AdminIsPower('index', 'stats');
MyViewAssign('is_stats', $is_stats);
if($is_stats == 1)
{
// 默认时间
$default_day = '30-day';
MyViewAssign('default_day', $default_day);
// 订单总数
$order_number = StatisticalService::OrderNumberYesterdayTodayTotal();
MyViewAssign('order_number', $order_number['data']);
// 时间
$time_data = StatisticalService::DateTimeList();
MyViewAssign('time_data', $time_data);
// 订单成交总量
$order_complete_number = StatisticalService::OrderCompleteYesterdayTodayTotal();
MyViewAssign('order_complete_number', $order_complete_number['data']);
// 基础数据总计
$time = [];
if(!empty($time_data) && !empty($default_day) && isset($time_data[$default_day]))
{
$time['start'] = strtotime($time_data[$default_day]['start']);
$time['end'] = strtotime($time_data[$default_day]['end']);
}
$base_count = StatisticalService::BaseTotalCount($time);
MyViewAssign('base_count', $base_count['data']);
// 订单收入总计
$order_complete_money = StatisticalService::OrderCompleteMoneyYesterdayTodayTotal();
MyViewAssign('order_complete_money', $order_complete_money['data']);
// 用户
$user = StatisticalService::UserYesterdayTodayTotal();
MyViewAssign('user', $user['data']);
// 近30日订单成交金额走势
$order_profit_chart = StatisticalService::OrderProfitSevenTodayTotal();
MyViewAssign('order_profit_chart', $order_profit_chart['data']);
// 订单总数
$order_number = StatisticalService::OrderNumberYesterdayTodayTotal();
MyViewAssign('order_number', $order_number['data']);
// 近30日订单交易走势
$order_trading_trend = StatisticalService::OrderTradingTrendSevenTodayTotal();
MyViewAssign('order_trading_trend', $order_trading_trend['data']);
// 近30日支付方式
$pay_type_number = StatisticalService::PayTypeSevenTodayTotal();
MyViewAssign('pay_type_number', $pay_type_number['data']);
// 订单成交总量
$order_complete_number = StatisticalService::OrderCompleteYesterdayTodayTotal();
MyViewAssign('order_complete_number', $order_complete_number['data']);
// 近30日热销商品
$goods_hot_sale = StatisticalService::GoodsHotSaleSevenTodayTotal();
MyViewAssign('goods_hot_sale', $goods_hot_sale['data']);
// 订单收入总计
$order_complete_money = StatisticalService::OrderCompleteMoneyYesterdayTodayTotal();
MyViewAssign('order_complete_money', $order_complete_money['data']);
}
return MyView();
}
@ -188,5 +196,28 @@ class Index extends Common
$params = $this->data_request;
return SystemUpgradeService::Run($params);
}
/**
* 统计数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
*/
public function Stats()
{
// 是否ajax请求
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 权限校验
$this->IsPower();
$params = $this->data_request;
return StatisticalService::StatsData($params);
}
}
?>

View File

@ -29,7 +29,7 @@
</div>
<div class="am-form-group">
<label>{{$data.common_user_center_notice.name}}<span class="am-form-group-label-tips">{{$data.common_user_center_notice.describe}}</span></label>
<textarea rows="3" name="{{$data.common_user_center_notice.only_tag}}" class="am-radius" placeholder="{{$data.common_user_center_notice.name}}" data-validation-message="{{$data.common_user_center_notice.error_tips}}">{{if !empty($data)}}{{$data.common_user_center_notice.value}}{{/if}}</textarea>
<textarea rows="4" name="{{$data.common_user_center_notice.only_tag}}" class="am-radius" placeholder="{{$data.common_user_center_notice.name}}" data-validation-message="{{$data.common_user_center_notice.error_tips}}">{{if !empty($data)}}{{$data.common_user_center_notice.value}}{{/if}}</textarea>
</div>
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">

View File

@ -23,6 +23,10 @@
<label>{{$data.common_page_size.name}}<span class="am-form-group-label-tips">{{$data.common_page_size.describe}}</span></label>
<input type="number" name="{{$data.common_page_size.only_tag}}" placeholder="{{$data.common_page_size.name}}" pattern="{{:MyConst('common_regex_page_number')}}" data-validation-message="{{$data.common_page_size.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_page_size.value}}"{{/if}} required />
</div>
<div class="am-form-group">
<label>{{$data.admin_notice.name}}<span class="am-form-group-label-tips">{{$data.admin_notice.describe}}</span></label>
<textarea rows="4" name="{{$data.admin_notice.only_tag}}" class="am-radius" placeholder="{{$data.admin_notice.name}}" data-validation-message="{{$data.admin_notice.error_tips}}">{{if !empty($data)}}{{$data.admin_notice.value}}{{/if}}</textarea>
</div>
</div>
</div>

View File

@ -1,7 +1,7 @@
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<div class="content-right" data-url="{{:MyUrl('admin/index/stats')}}">
<div class="content">
{{if $is_system_show_base eq 1}}
<!-- 顶部提示信息 -->
@ -44,152 +44,169 @@
</div>
{{/if}}
<!-- 基础统计 -->
<div class="block-container shopxo-base">
<div class="echarts-title">
<span class="icon"></span>
<span class="title">商城统计</span>
<!-- 后台公告 -->
{{if !empty($admin_notice)}}
<div class="am-alert am-alert-danger" data-am-alert>
<button type="button" class="am-close">&times;</button>
<p>{{$admin_notice|raw}}</p>
</div>
<ul class="am-avg-sm-2 am-avg-lg-4">
{{/if}}
<!-- 是否展示统计数据 -->
{{if isset($is_stats) and $is_stats eq 1}}
<!-- 基础统计 -->
<div class="block-container shopxo-base">
<div class="block-title echarts-title">
<span class="icon"></span>
<span class="title">商城统计</span>
<a href="javascript:;" class="am-icon-question-circle am-text-warning" data-am-popover="{content: '时间筛选仅对总数有效', trigger: 'hover focus', theme: 'sm'}"></a>
{{include file="/index/stats_where" type="base-count" init="0" /}}
</div>
<ul class="am-avg-sm-2 am-avg-lg-4">
<li>
<div class="li-content">
<p class="name">用户总量</p>
<p class="total animation-count-to base-user-count" data-to="{{$base_count.user_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$user.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$user.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$user.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$user.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-user am-icon-lg bg-icon"></i>
</div>
</li>
<li>
<div class="li-content">
<p class="name">订单总量</p>
<p class="total animation-count-to base-order-count" data-to="{{$base_count.order_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_number.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_number.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_number.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_number.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-pie-chart am-icon-lg bg-icon"></i>
</div>
</li>
<li>
<div class="li-content">
<p class="name">成交总量</p>
<p class="total animation-count-to base-order-sale-count" data-to="{{$base_count.order_sale_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_complete_number.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_complete_number.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_complete_number.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_complete_number.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-gg am-icon-lg bg-icon"></i>
</div>
</li>
<li>
<div class="li-content">
<p class="name">收入总计</p>
<p class="total animation-count-to base-order-complete-total" data-to="{{$base_count.order_complete_total}}" data-speed="1500" data-decimals="2">0.00</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_complete_money.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_complete_money.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_complete_money.yesterday_count}}" data-speed="1500" data-decimals="2">0.00</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_complete_money.today_count}}" data-speed="1500" data-decimals="2">0.00</span>
</div>
<i class="am-icon-line-chart am-icon-lg bg-icon"></i>
</div>
</li>
</ul>
</div>
<!-- 订单成交金额走势 -->
<div class="block-container">
<div class="block-title echarts-title">
<span class="icon"></span>
<span class="title">订单成交金额走势</span>
{{include file="/index/stats_where" type="order-profit" init="1" /}}
</div>
<div id="echarts-order-profit"></div>
</div>
<!-- 近30日订单交易走势 -->
<div class="block-container">
<div class="block-title echarts-title">
<span class="icon"></span>
<span class="title">订单交易走势</span>
{{include file="/index/stats_where" type="order-trading" init="1" /}}
</div>
<div id="echarts-order-trading"></div>
</div>
<!-- 组合 -->
<ul class="am-avg-sm-1 am-avg-sm-2 am-avg-lg-2 block-combination-container-2 {{if $is_system_show_base eq 0}}am-padding-bottom-sm{{/if}}">
<li>
<div class="li-content">
<p class="name">用户总量</p>
<p class="total animation-count-to" data-to="{{$user.total_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$user.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$user.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$user.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$user.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-user am-icon-lg bg-icon"></i>
<!-- 近30日热销商品 -->
<div class="block-title echarts-title">
<span class="icon"></span>
<span class="title">热销商品</span>
{{include file="/index/stats_where" type="goods-hot" init="1" /}}
</div>
<div id="echarts-goods-hot"></div>
</li>
<li>
<div class="li-content">
<p class="name">订单总量</p>
<p class="total animation-count-to" data-to="{{$order_number.total_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_number.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_number.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_number.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_number.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-pie-chart am-icon-lg bg-icon"></i>
</div>
</li>
<li>
<div class="li-content">
<p class="name">成交总量</p>
<p class="total animation-count-to" data-to="{{$order_complete_number.total_count}}" data-speed="1500">0</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_complete_number.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_complete_number.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_complete_number.yesterday_count}}" data-speed="1500">0</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_complete_number.today_count}}" data-speed="1500">0</span>
</div>
<i class="am-icon-gg am-icon-lg bg-icon"></i>
</div>
</li>
<li>
<div class="li-content">
<p class="name">收入总计</p>
<p class="total animation-count-to" data-to="{{$order_complete_money.total_count}}" data-speed="1500" data-decimals="2">0.00</p>
<div class="item am-margin-bottom-xs">
<span>上月</span>
<span class="animation-count-to" data-to="{{$order_complete_money.last_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>当月</span>
<span class="animation-count-to" data-to="{{$order_complete_money.same_month_count}}" data-speed="1500">0</span>
</div>
<div class="item am-margin-bottom-xs">
<span>昨日</span>
<span class="animation-count-to" data-to="{{$order_complete_money.yesterday_count}}" data-speed="1500" data-decimals="2">0.00</span>
</div>
<div class="item">
<span>今日</span>
<span class="animation-count-to" data-to="{{$order_complete_money.today_count}}" data-speed="1500" data-decimals="2">0.00</span>
</div>
<i class="am-icon-line-chart am-icon-lg bg-icon"></i>
<!-- 近30日支付方式 -->
<div class="block-title echarts-title">
<span class="icon"></span>
<span class="title">支付方式</span>
{{include file="/index/stats_where" type="pay-type" init="1" /}}
</div>
<div id="echarts-pay-type"></div>
</li>
</ul>
</div>
<!-- 近30日订单成交金额走势 -->
<div class="block-container">
<div class="echarts-title">
<span class="icon"></span>
<span class="title">近30日订单成交金额走势</span>
</div>
<div id="echarts-order-profit"></div>
</div>
<!-- 近30日订单交易走势 -->
<div class="block-container">
<div class="echarts-title">
<span class="icon"></span>
<span class="title">近30日订单交易走势</span>
</div>
<div id="echarts-order-trading"></div>
</div>
<!-- 组合 -->
<ul class="am-avg-sm-1 am-avg-sm-2 am-avg-lg-2 block-combination-container-2 {{if $is_system_show_base eq 0}}am-padding-bottom-sm{{/if}}">
<li>
<!-- 近30日热销商品 -->
<div class="echarts-title">
<span class="icon"></span>
<span class="title">近30日热销商品</span>
</div>
<div id="echarts-goods-hot"></div>
</li>
<li>
<!-- 近30日支付方式 -->
<div class="echarts-title">
<span class="icon"></span>
<span class="title">近30日支付方式</span>
</div>
<div id="echarts-pay-type"></div>
</li>
</ul>
{{/if}}
<!-- 系统信息 -->
{{if $is_system_show_base eq 1}}
<ul class="am-avg-sm-1 am-avg-sm-2 am-avg-lg-2 block-combination-container-2 am-padding-bottom-sm">
<li>
<div class="echarts-title">
<div class="block-title">
<span class="icon"></span>
<span class="title">系统信息</span>
</div>
@ -215,7 +232,7 @@
</li>
<li>
<div class="echarts-title">
<div class="block-title">
<span class="icon"></span>
<span class="title">开发团队</span>
</div>
@ -284,188 +301,22 @@
<script type="text/javascript">
$(function()
{
// 近30日订单成交金额走势
var order_profit_chart = echarts.init(document.getElementById('echarts-order-profit'), 'macarons');
var option = {
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: {{:json_encode($order_profit_chart.title_arr)}}
},
toolbox: {
show : {{if IsMobile()}}false{{else}}true{{/if}},
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {name:'近30日订单交易走势', show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : {{:json_encode($order_profit_chart.name_arr)}}
}
],
yAxis : [
{
type : 'value'
}
],
series : {{:json_encode($order_profit_chart.data)}}
};
order_profit_chart.setOption(option);
// 近30日订单交易走势
var order_trading_chart = echarts.init(document.getElementById('echarts-order-trading'), 'macarons');
var option = {
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: {{:json_encode($order_trading_trend.title_arr)}}
},
toolbox: {
show : {{if IsMobile()}}false{{else}}true{{/if}},
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {name:'近30日订单交易走势', show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : {{:json_encode($order_trading_trend.name_arr)}}
}
],
yAxis : [
{
type : 'value'
}
],
series : {{:json_encode($order_trading_trend.data)}}
};
order_trading_chart.setOption(option);
// 近30日热销商品
var goods_hot_chart = echarts.init(document.getElementById('echarts-goods-hot'), 'macarons');
var option = {
title : {
subtext: '仅显示前10条商品',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{b} : {c} ({d}%)"
},
toolbox: {
show : {{if IsMobile()}}false{{else}}true{{/if}},
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {
show: true,
type: ['pie', 'funnel'],
option: {
funnel: {
x: '25%',
width: '50%',
funnelAlign: 'left',
max: 1548
}
}
},
restore : {show: false},
saveAsImage : {name:'近30日热销商品', show: true}
}
},
calculable : true,
series : [
{
type:'pie',
radius : '55%',
center: ['50%', '60%'],
data: {{:json_encode($goods_hot_sale.data)}}
}
]
};
goods_hot_chart.setOption(option);
// 近30日支付方式
var order_pay_type_chart = echarts.init(document.getElementById('echarts-pay-type'), 'macarons');
var option = {
tooltip : {
trigger: 'axis'
},
legend: {
data: {{:json_encode($pay_type_number.title_arr)}}
},
toolbox: {
show : {{if IsMobile()}}false{{else}}true{{/if}},
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: false},
saveAsImage : {name:'近30日支付方式', show: true}
}
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data : {{:json_encode($pay_type_number.name_arr)}}
}
],
yAxis : [
{
type : 'value'
}
],
series : {{:json_encode($pay_type_number.data)}}
};
order_pay_type_chart.setOption(option);
// 浏览器大小改变则实时更新图表大小
window.onresize = function ()
{
order_pay_type_chart.resize();
goods_hot_chart.resize();
order_profit_chart.resize();
order_trading_chart.resize();
};
// // 浏览器大小改变则实时更新图表大小
// window.onresize = function ()
// {
// order_pay_type_chart.resize();
// goods_hot_chart.resize();
// order_profit_chart.resize();
// order_trading_chart.resize();
// };
});
</script>

View File

@ -0,0 +1,15 @@
<div class="am-fr right-operate" data-type="[type]" data-init="[init]">
{{if !empty($time_data)}}
<span class="quick-time">
{{foreach $time_data as $k=>$v}}
<a href="javascript:;" data-start="{{$v.start}}" data-end="{{$v.end}}">{{$v.name}}</a>
{{/foreach}}
</span>
{{/if}}
<span class="am-form echarts-where-time">
<input type="text" autocomplete="off" name="time_start" class="Wdate am-radius" placeholder="开始时间" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{if !empty($time_data) and !empty($default_day) and isset($time_data[$default_day])}}{{$time_data[$default_day]['start']}}{{/if}}" />
<span class="join">-</span>
<input type="text" autocomplete="off" class="Wdate am-radius" placeholder="结束时间" name="time_end" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{{if !empty($time_data) and !empty($default_day) and isset($time_data[$default_day])}}{{$time_data[$default_day]['end']}}{{/if}}" />
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-line-chart btn-loading-example echarts-where-submit" data-am-loading="{loadingText:' 加载'}"> 确认</button>
</span>
</div>

View File

@ -64,6 +64,7 @@
var __public__ = '{{$public_host}}';
var __attachment_host__ = '{{$attachment_host}}';
var __currency_symbol__ = '{{$currency_symbol}}';
var __is_mobile__ = '{{if IsMobile()}}1{{else}}0{{/if}}';
</script>
<body>
{{if $module_name.$controller_name.$action_name neq 'adminindexindex'}}

View File

@ -22,38 +22,50 @@ use think\facade\Db;
class StatisticalService
{
// 近3天,近7天,近15天,近30天
private static $nearly_three_days;
private static $nearly_seven_days;
private static $nearly_fifteen_days;
private static $nearly_thirty_days;
// 近30天
private static $thirty_time_start;
private static $thirty_time_end;
// 近15天
private static $fifteen_time_start;
private static $fifteen_time_end;
// 近7天
private static $seven_time_start;
private static $seven_time_end;
// 上月
private static $last_month_time_start;
private static $last_month_time_end;
// 当月
private static $same_month_time_start;
private static $same_month_time_end;
public static $nearly_three_days;
public static $nearly_seven_days;
public static $nearly_fifteen_days;
public static $nearly_thirty_days;
// 昨天
private static $yesterday_time_start;
private static $yesterday_time_end;
public static $yesterday_time_start;
public static $yesterday_time_end;
// 今天
private static $today_time_start;
private static $today_time_end;
public static $today_time_start;
public static $today_time_end;
// 近30天
public static $thirty_time_start;
public static $thirty_time_end;
// 近15天
public static $fifteen_time_start;
public static $fifteen_time_end;
// 近7天
public static $seven_time_start;
public static $seven_time_end;
// 近3天
public static $three_time_start;
public static $three_time_end;
// 上月
public static $last_month_time_start;
public static $last_month_time_end;
// 当月
public static $this_month_time_start;
public static $this_month_time_end;
// 去年
public static $this_year_time_start;
public static $this_year_time_end;
// 今年
public static $last_year_time_start;
public static $last_year_time_end;
/**
* 初始化
@ -72,26 +84,6 @@ class StatisticalService
// 初始化标记对象,避免重复初始化
$object = (object) [];
// 近30天日期
self::$thirty_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-30 day')));
self::$thirty_time_end = time();
// 近15天日期
self::$fifteen_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-15 day')));
self::$fifteen_time_end = time();
// 近7天日期
self::$seven_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-7 day')));
self::$seven_time_end = time();
// 上月
self::$last_month_time_start = strtotime(date('Y-m-01 00:00:00', strtotime('-1 month', strtotime(date('Y-m', time())))));
self::$last_month_time_end = strtotime(date('Y-m-t 23:59:59', strtotime('-1 month', strtotime(date('Y-m', time())))));
// 当月
self::$same_month_time_start = strtotime(date('Y-m-01 00:00:00'));
self::$same_month_time_end = time();
// 昨天日期
self::$yesterday_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-1 day')));
self::$yesterday_time_end = strtotime(date('Y-m-d 23:59:59', strtotime('-1 day')));
@ -100,6 +92,39 @@ class StatisticalService
self::$today_time_start = strtotime(date('Y-m-d 00:00:00'));
self::$today_time_end = time();
// 近30天日期
self::$thirty_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-29 day')));
self::$thirty_time_end = time();
// 近15天日期
self::$fifteen_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-14 day')));
self::$fifteen_time_end = time();
// 近7天日期
self::$seven_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-6 day')));
self::$seven_time_end = time();
// 近3天日期
self::$three_time_start = strtotime(date('Y-m-d 00:00:00', strtotime('-2 day')));
self::$three_time_end = time();
// 上月
self::$last_month_time_start = strtotime(date('Y-m-01 00:00:00', strtotime('-1 month', strtotime(date('Y-m', time())))));
self::$last_month_time_end = strtotime(date('Y-m-t 23:59:59', strtotime('-1 month', strtotime(date('Y-m', time())))));
// 当月
self::$this_month_time_start = strtotime(date('Y-m-01 00:00:00'));
self::$this_month_time_end = time();
// 去年
self::$last_year_time_start = strtotime(date('Y-01-01 00:00:00', strtotime('-1 year', strtotime(date('Y-m', time())))));
self::$last_year_time_end = strtotime(date('Y-12-31 23:59:59', strtotime('-1 year', strtotime(date('Y-m', time())))));
// 今年
self::$this_year_time_start = strtotime(date('Y-01-01 00:00:00'));
self::$this_year_time_end = time();
// 近3天,近7天,近15天,近30天
$nearly_all = [
3 => 'nearly_three_days',
@ -124,6 +149,65 @@ class StatisticalService
}
}
/**
* 获取时间列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-31
* @desc description
* @param [array] $params [数据参数]
*/
public static function DateTimeList($params = [])
{
// 初始化
self::Init($params);
// 统计时间配置列表
return [
'3-day' => [
'name' => '近3天',
'start' => date('Y-m-d H:i:s', StatisticalService::$three_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$three_time_end),
],
'7-day' => [
'name' => '近7天',
'start' => date('Y-m-d H:i:s', StatisticalService::$seven_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$seven_time_end),
],
'15-day' => [
'name' => '近15天',
'start' => date('Y-m-d H:i:s', StatisticalService::$fifteen_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$fifteen_time_end),
],
'30-day' => [
'name' => '近30天',
'start' => date('Y-m-d H:i:s', StatisticalService::$thirty_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$thirty_time_end),
],
'this-month' => [
'name' => '当月',
'start' => date('Y-m-d H:i:s', StatisticalService::$this_month_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$this_month_time_end),
],
'last-month' => [
'name' => '上月',
'start' => date('Y-m-d H:i:s', StatisticalService::$last_month_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$last_month_time_end),
],
'this-year' => [
'name' => '今年',
'start' => date('Y-m-d H:i:s', StatisticalService::$this_year_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$this_year_time_end),
],
'last-year' => [
'name' => '去年',
'start' => date('Y-m-d H:i:s', StatisticalService::$last_year_time_start),
'end' => date('Y-m-d H:i:s', StatisticalService::$last_year_time_end),
],
];
}
/**
* 用户总数,今日,昨日,当月,上月总数
* @author Devil
@ -137,9 +221,6 @@ class StatisticalService
// 初始化
self::Init($params);
// 总数
$total_count = Db::name('User')->count();
// 上月
$where = [
['status', '<=', 4],
@ -151,8 +232,8 @@ class StatisticalService
// 当月
$where = [
['status', '<=', 4],
['add_time', '>=', self::$same_month_time_start],
['add_time', '<=', self::$same_month_time_end],
['add_time', '>=', self::$this_month_time_start],
['add_time', '<=', self::$this_month_time_end],
];
$same_month_count = Db::name('User')->where($where)->count();
@ -172,7 +253,6 @@ class StatisticalService
// 数据组装
$result = [
'total_count' => $total_count,
'last_month_count' => $last_month_count,
'same_month_count' => $same_month_count,
'yesterday_count' => $yesterday_count,
@ -197,12 +277,6 @@ class StatisticalService
// 订单状态
// 0待确认, 1已确认/待支付, 2已支付/待发货, 3已发货/待收货, 4已完成, 5已取消, 6已关闭
// 总数
$where = [
['status', '<=', 4],
];
$total_count = Db::name('Order')->where($where)->count();
// 上月
$where = [
['status', '<=', 4],
@ -214,8 +288,8 @@ class StatisticalService
// 当月
$where = [
['status', '<=', 4],
['add_time', '>=', self::$same_month_time_start],
['add_time', '<=', self::$same_month_time_end],
['add_time', '>=', self::$this_month_time_start],
['add_time', '<=', self::$this_month_time_end],
];
$same_month_count = Db::name('Order')->where($where)->count();
@ -237,7 +311,6 @@ class StatisticalService
// 数据组装
$result = [
'total_count' => $total_count,
'last_month_count' => $last_month_count,
'same_month_count' => $same_month_count,
'yesterday_count' => $yesterday_count,
@ -261,12 +334,6 @@ class StatisticalService
// 订单状态
// 0待确认, 1已确认/待支付, 2已支付/待发货, 3已发货/待收货, 4已完成, 5已取消, 6已关闭
// 总数
$where = [
['status', '=', 4],
];
$total_count = Db::name('Order')->where($where)->count();
// 上月
$where = [
@ -279,8 +346,8 @@ class StatisticalService
// 当月
$where = [
['status', '=', 4],
['add_time', '>=', self::$same_month_time_start],
['add_time', '<=', self::$same_month_time_end],
['add_time', '>=', self::$this_month_time_start],
['add_time', '<=', self::$this_month_time_end],
];
$same_month_count = Db::name('Order')->where($where)->count();
@ -302,7 +369,6 @@ class StatisticalService
// 数据组装
$result = [
'total_count' => $total_count,
'last_month_count' => $last_month_count,
'same_month_count' => $same_month_count,
'yesterday_count' => $yesterday_count,
@ -326,12 +392,6 @@ class StatisticalService
// 订单状态
// 0待确认, 1已确认/待支付, 2已支付/待发货, 3已发货/待收货, 4已完成, 5已取消, 6已关闭
// 总数
$where = [
['status', 'in', [2,3,4]],
];
$total_count = Db::name('Order')->where($where)->sum('total_price');
// 上月
$where = [
@ -344,8 +404,8 @@ class StatisticalService
// 当月
$where = [
['status', 'in', [2,3,4]],
['add_time', '>=', self::$same_month_time_start],
['add_time', '<=', self::$same_month_time_end],
['add_time', '>=', self::$this_month_time_start],
['add_time', '<=', self::$this_month_time_end],
];
$same_month_count = Db::name('Order')->where($where)->sum('total_price');
@ -367,7 +427,6 @@ class StatisticalService
// 数据组装
$result = [
'total_count' => PriceNumberFormat($total_count),
'last_month_count' => PriceNumberFormat($last_month_count),
'same_month_count' => PriceNumberFormat($same_month_count),
'yesterday_count' => PriceNumberFormat($yesterday_count),
@ -377,18 +436,98 @@ class StatisticalService
}
/**
* 订单收益趋势, 30天数据
* 基础数据总计
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-31
* @desc description
* @param [array] $params [输入参数]
*/
public static function BaseTotalCount($params = [])
{
// 日期条件处理
$where = [];
if(!empty($params['start']))
{
$where[] = ['add_time', '>=', $params['start']];
}
if(!empty($params['end']))
{
$where[] = ['add_time', '<=', $params['end']];
}
// 用户总数
$user_count = Db::name('User')->where($where)->count();
// 订单总数
$order_count = Db::name('Order')->where(array_merge($where, [['status', '<=', 4]]))->count();
// 订单成交总量
$order_sale_count = Db::name('Order')->where(array_merge($where, [['status', '=', 4]]))->count();
// 订单收入总计
$order_complete_total = PriceNumberFormat(Db::name('Order')->where(array_merge($where, [['status', 'in', [2,3,4]]]))->sum('total_price'));
$result = [
'user_count' => $user_count,
'order_count' => $order_count,
'order_sale_count' => $order_sale_count,
'order_complete_total' => $order_complete_total,
];
return DataReturn('处理成功', 0, $result);
}
/**
* 区间时间创建
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param [int] $start [起始时间]
* @param [int] $end [结束时间]
*/
public static function DayCreate($start, $end)
{
$data = [];
while(true)
{
// 计算时间条件
$temp_end = strtotime('+1 day', $start);
// 最大时间减1秒条件使用 start >= ? && end <= ?
// start 2021-01-01 00:00:00 , end 2021-01-01 23:59:58
$data[] = [
'start' => $start,
'end' => $temp_end-1,
'date' => date('Y-m-d H:i:s', $start).' - '.date('Y-m-d H:i:s', $temp_end-1),
];
// 结束跳出循环
if($temp_end >= $end)
{
// 结束使用最大时间替代计算的最后一个最大时间
$count = count($data)-1;
$data[$count]['end'] = $end;
$data[$count]['date'] = date('Y-m-d H:i:s', $data[$count]['start']).' - '.date('Y-m-d H:i:s', $end);
break;
}
$start = $temp_end;
}
return $data;
}
/**
* 订单收益趋势
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function OrderProfitSevenTodayTotal($params = [])
public static function OrderProfitTotal($params = [])
{
// 初始化
self::Init($params);
// 订单状态列表
$order_status_list = MyConst('common_order_status');
$status_arr = array_column($order_status_list, 'id');
@ -399,10 +538,11 @@ class StatisticalService
$name_arr = [];
if(!empty($status_arr))
{
foreach(self::$nearly_thirty_days as $day)
$date = self::DayCreate($params['start'], $params['end']);
foreach($date as $day)
{
// 当前日期名称
$name_arr[] = $day['name'];
$name_arr[] = date('Y-m-d', $day['start']);
// 根据状态获取数量
foreach($status_arr as $status)
@ -410,8 +550,8 @@ class StatisticalService
// 获取订单
$where = [
['status', '=', $status],
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
['add_time', '>=', $day['start']],
['add_time', '<=', $day['end']],
];
$value_arr[$status][] = Db::name('Order')->where($where)->sum('pay_price');
}
@ -439,18 +579,15 @@ class StatisticalService
}
/**
* 订单交易趋势, 30天数据
* 订单交易趋势
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function OrderTradingTrendSevenTodayTotal($params = [])
public static function OrderTradingTotal($params = [])
{
// 初始化
self::Init($params);
// 订单状态列表
$order_status_list = MyConst('common_order_status');
$status_arr = array_column($order_status_list, 'id');
@ -461,10 +598,11 @@ class StatisticalService
$name_arr = [];
if(!empty($status_arr))
{
foreach(self::$nearly_thirty_days as $day)
$date = self::DayCreate($params['start'], $params['end']);
foreach($date as $day)
{
// 当前日期名称
$name_arr[] = $day['name'];
$name_arr[] = date('Y-m-d', $day['start']);
// 根据状态获取数量
foreach($status_arr as $status)
@ -472,8 +610,8 @@ class StatisticalService
// 获取订单
$where = [
['status', '=', $status],
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
['add_time', '>=', $day['start']],
['add_time', '<=', $day['end']],
];
$value_arr[$status][] = Db::name('Order')->where($where)->count();
}
@ -501,14 +639,14 @@ class StatisticalService
}
/**
* 支付方式, 30天数据
* 支付方式
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function PayTypeSevenTodayTotal($params = [])
public static function PayTypeTotal($params = [])
{
// 初始化
self::Init($params);
@ -527,10 +665,11 @@ class StatisticalService
$name_arr = [];
if(!empty($pay_name_arr))
{
foreach(self::$nearly_thirty_days as $day)
$date = self::DayCreate($params['start'], $params['end']);
foreach($date as $day)
{
// 当前日期名称
$name_arr[] = date('m-d', strtotime($day['name']));
$name_arr[] = date('m-d', $day['start']);
// 根据支付名称获取数量
foreach($pay_name_arr as $payment)
@ -538,8 +677,8 @@ class StatisticalService
// 获取订单
$where = [
['payment_name', '=', $payment],
['add_time', '>=', $day['start_time']],
['add_time', '<=', $day['end_time']],
['add_time', '>=', $day['start']],
['add_time', '<=', $day['end']],
];
$value_arr[$payment][] = Db::name('PayLog')->where($where)->count();
}
@ -568,23 +707,20 @@ class StatisticalService
}
/**
* 热销商品, 30天数据
* 热销商品
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function GoodsHotSaleSevenTodayTotal($params = [])
{
// 初始化
self::Init($params);
public static function GoodsHotTotal($params = [])
{
// 获取订单id
$where = [
['status', '<=', 4],
['add_time', '>=', self::$thirty_time_start],
['add_time', '<=', self::$thirty_time_end],
['add_time', '>=', $params['start']],
['add_time', '<=', $params['end']],
];
$order_ids = Db::name('Order')->where($where)->column('id');
@ -593,7 +729,7 @@ class StatisticalService
{
$data = [];
} else {
$data = Db::name('OrderDetail')->field('goods_id, sum(buy_number) AS value')->where('order_id', 'IN', $order_ids)->group('goods_id')->order('value desc')->limit(10)->select()->toArray();
$data = Db::name('OrderDetail')->field('goods_id, sum(buy_number) AS value')->where('order_id', 'IN', $order_ids)->group('goods_id')->order('value desc')->limit(30)->select()->toArray();
}
if(!empty($data))
@ -617,5 +753,82 @@ class StatisticalService
];
return DataReturn('处理成功', 0, $result);
}
/**
* 统计数据
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param [array] $params [输入参数]
*/
public static function StatsData($params = [])
{
// 请求类型
$p = [
[
'checked_type' => 'empty',
'key_name' => 'type',
'error_msg' => '类型为空',
],
[
'checked_type' => 'empty',
'key_name' => 'start',
'error_msg' => '开始时间为空',
],
[
'checked_type' => 'empty',
'key_name' => 'end',
'error_msg' => '结束时间为空',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 时间处理
$params['start'] = strtotime($params['start']);
$params['end'] = strtotime($params['end']);
if($params['end'] < $params['start'])
{
return DataReturn('开始时间不能小于结束时间', -1);
}
// 根据类型处理数据
switch($params['type'])
{
// 基础配置
case 'base-count' :
$ret = self::BaseTotalCount($params);
break;
// 订单成交金额走势
case 'order-profit' :
$ret = self::OrderProfitTotal($params);
break;
// 订单交易走势
case 'order-trading' :
$ret = self::OrderTradingTotal($params);
break;
// 热销商品
case 'goods-hot' :
$ret = self::GoodsHotTotal($params);
break;
// 支付方式
case 'pay-type' :
$ret = self::PayTypeTotal($params);
break;
default :
$ret = DataReturn('类型有误', -1);
}
return $ret;
}
}
?>

View File

@ -20,10 +20,10 @@ html, body {
margin-bottom: 20px;
}
.block-container .echarts-title, .block-combination-container-2 li .echarts-title {
.block-container .block-title, .block-combination-container-2 li .block-title {
margin-left: 10px;
}
.block-container .echarts-title .icon, .block-combination-container-2 li .echarts-title .icon {
.block-container .block-title .icon, .block-combination-container-2 li .block-title .icon {
background: #3f82fe;
display: block;
width: 5px;
@ -32,11 +32,57 @@ html, body {
left: 10px;
top: 13px;
}
.block-container .echarts-title .title, .block-combination-container-2 li .echarts-title .title {
.block-container .block-title .title, .block-combination-container-2 li .block-title .title {
color: #666;
font-size: 14px;
margin-left: 5px;
}
.right-operate .quick-time a {
margin-right: 8px;
color: #bde2f4;
}
.right-operate .quick-time a:hover {
color: #095f8a;
}
.right-operate .echarts-where-time input {
display: -webkit-inline-box !important;
width: 155px !important;
border-color: #eee;
color: #888;
}
.right-operate .echarts-where-submit {
color: #8cd8ff;
background-color: transparent;
border-color: #d0efff;
}
.right-operate .echarts-where-submit:hover {
color: #fff;
background-color: #3bb4f2;
border-color: #3bb4f2;
}
.right-operate .echarts-where-time .join {
color: #ccc;
}
.block-container .echarts-title{
height: 46px;
}
.block-combination-container-2 li .echarts-title {
height: 100px;
}
.block-combination-container-2 .right-operate {
float: none;
}
.block-combination-container-2 .right-operate .quick-time,
.block-combination-container-2 .right-operate .echarts-where-time {
display: block;
margin-top: 5px;
}
.block-combination-container-2 .right-operate .quick-time {
margin-top: 10px;
}
.block-combination-container-2 .right-operate .echarts-where-time input {
width: calc(50% - 46px) !important;
}
@media only screen and (min-width: 641px) {
.block-combination-container-2 {
margin-bottom: 20px;
@ -60,6 +106,25 @@ html, body {
margin-bottom: 20px;
}
}
@media only screen and (max-width: 800px) {
.block-container .echarts-title {
height: 100px;
}
.right-operate {
float: none;
}
.right-operate .quick-time,
.right-operate .echarts-where-time {
display: block;
margin-top: 5px;
}
.right-operate .quick-time {
margin-top: 10px;
}
.right-operate .echarts-where-time input {
width: calc(50% - 46px) !important;
}
}
/**

View File

@ -0,0 +1,561 @@
/**
* 系统更新异步请求步骤
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-02-22
* @desc description
* @param {[string]} url [url地址]
* @param {[string]} opt [操作类型url 获取下载地址 download_system 下载系统包 download_upgrade 下载升级包 upgrade 更新操作]
* @param {[string]} msg [提示信息]
*/
function SystemUpgradeRequestHandle(params)
{
// 参数处理
if((params || null) == null)
{
Prompt('操作参数有误');
return false;
}
var url = params.url || null;
var opt = params.opt || 'url';
var msg = params.msg || '正在获取中...';
// 加载提示
AMUI.dialog.loading({title: msg});
// ajax
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
timeout: 305000,
data: {"opt":opt},
success: function(result)
{
if((result || null) != null && result.code == 0)
{
switch(opt)
{
// 获取下载地址
case 'url' :
params['opt'] = 'download_system';
params['msg'] = '系统包正在下载中...';
SystemUpgradeRequestHandle(params);
break;
// 下载系统包
case 'download_system' :
params['opt'] = 'download_upgrade';
params['msg'] = '升级包正在下载中...';
SystemUpgradeRequestHandle(params);
break;
// 下载升级包
case 'download_upgrade' :
params['opt'] = 'upgrade';
params['msg'] = '正在更新中...';
SystemUpgradeRequestHandle(params);
break;
// 更新完成
case 'upgrade' :
Prompt(result.msg, 'success');
setTimeout(function()
{
window.location.reload();
}, 1500);
break;
}
} else {
AMUI.dialog.loading('close');
Prompt(((result || null) == null) ? '返回数据格式错误' : (result.msg || '异常错误'));
}
},
error: function(xhr, type)
{
AMUI.dialog.loading('close');
Prompt(HtmlToString(xhr.responseText) || '异常错误');
}
});
}
/**
* 基础数据总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[array]} data [数据]
*/
function EchartsBaseCount(data)
{
$('.base-user-count').text(data.user_count);
$('.base-order-count').text(data.order_count);
$('.base-order-sale-count').text(data.order_asle_count);
$('.base-order-complete-total').text(data.order_complete_total);
}
/**
* 订单成交金额走势
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[array]} title_arr [标题]
* @param {[array]} name_arr [名称]
* @param {[array]} data [数据]
*/
function EchartsOrderProfit(title_arr, name_arr, data)
{
var chart = echarts.init(document.getElementById('echarts-order-profit'), 'macarons');
var option = {
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: title_arr
},
toolbox: {
show : (__is_mobile__ == 1) ? false : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {name:'订单交易走势', show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : name_arr
}
],
yAxis : [
{
type : 'value'
}
],
series : data
};
chart.setOption(option);
return chart;
}
/**
* 订单交易走势
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[array]} title_arr [标题]
* @param {[array]} name_arr [名称]
* @param {[array]} data [数据]
*/
function EchartsOrderTrading(title_arr, name_arr, data)
{
var chart = echarts.init(document.getElementById('echarts-order-trading'), 'macarons');
var option = {
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: title_arr
},
toolbox: {
show : (__is_mobile__ == 1) ? false : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true},
saveAsImage : {name:'订单交易走势', show: true}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
type : 'category',
boundaryGap : false,
data : name_arr
}
],
yAxis : [
{
type : 'value'
}
],
series : data
};
chart.setOption(option);
return chart;
}
/**
* 热销商品
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[array]} title_arr [标题]
* @param {[array]} name_arr [名称]
* @param {[array]} data [数据]
*/
function EchartsGoodsHot(data)
{
var chart = echarts.init(document.getElementById('echarts-goods-hot'), 'macarons');
var option = {
title : {
subtext: '仅显示前30条商品',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{b} : {c} ({d}%)"
},
toolbox: {
show : (__is_mobile__ == 1) ? false : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {
show: true,
type: ['pie', 'funnel'],
option: {
funnel: {
x: '25%',
width: '50%',
funnelAlign: 'left',
max: 1548
}
}
},
restore : {show: false},
saveAsImage : {name:'热销商品', show: true}
}
},
calculable : true,
series : [
{
type:'pie',
radius : '55%',
center: ['50%', '60%'],
data: data
}
]
};
chart.setOption(option);
return chart;
}
/**
* 支付方式
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[array]} title_arr [标题]
* @param {[array]} name_arr [名称]
* @param {[array]} data [数据]
*/
function EchartsPayType(title_arr, name_arr, data)
{
var chart = echarts.init(document.getElementById('echarts-pay-type'), 'macarons');
var option = {
tooltip : {
trigger: 'axis'
},
legend: {
data: title_arr
},
toolbox: {
show : (__is_mobile__ == 1) ? false : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: false},
saveAsImage : {name:'支付方式', show: true}
}
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data : name_arr
}
],
yAxis : [
{
type : 'value'
}
],
series : data
};
chart.setOption(option);
return chart;
}
/**
* 图表更新
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-08-30
* @desc description
* @param {[object]} e [操作对象]
*/
var chart_object = [];
function EchartsInit(e)
{
// 类型
var $parent = e.parents('.right-operate');
var type = $parent.data('type');
// 时间
var $time = e.parent();
var start = $time.find('input[name="time_start"]').val() || '';
var end = $time.find('input[name="time_end"]').val() || '';
// ajax
e.button('loading');
$.AMUI.progress.start();
$.ajax({
url: $('.content-right').data('url'),
type: 'POST',
dataType: 'json',
timeout: 30000,
data: {"type":type, "start":start, "end":end},
success: function(res)
{
e.button('reset');
$.AMUI.progress.done();
if(res.code == 0)
{
var chart = null;
switch(type)
{
// 支付方式
case 'base-count' :
EchartsBaseCount(res.data);
break;
// 订单成交金额走势
case 'order-profit' :
var chart = EchartsOrderProfit(res.data.title_arr, res.data.name_arr, res.data.data);
break;
// 订单交易走势
case 'order-trading' :
var chart = EchartsOrderTrading(res.data.title_arr, res.data.name_arr, res.data.data);
break;
// 热销商品
case 'goods-hot' :
var chart = EchartsGoodsHot(res.data.data);
break;
// 支付方式
case 'pay-type' :
var chart = EchartsPayType(res.data.title_arr, res.data.name_arr, res.data.data);
break;
default :
console.info('操作类型未定义['+type+']')
}
// 图表对象存储
if(chart !== null)
{
chart_object.push(chart);
}
} else {
Prompt(res.msg);
}
},
error: function(xhr, type)
{
e.button('reset');
$.AMUI.progress.done();
Prompt(HtmlToString(xhr.responseText) || '异常错误', null, 30);
}
});
}
$(function()
{
// 检查更新
var $inspect_upgrade_popup = $('#inspect-upgrade-popup');
$('.inspect-upgrade-submit').on('click', function()
{
// 基础信息
AMUI.dialog.loading({title: '正在获取最新内容、请稍候...'});
// ajax请求
$.ajax({
url: $(this).data('url'),
type: 'POST',
dataType: 'json',
timeout: 30000,
data: {},
success: function(result)
{
AMUI.dialog.loading('close');
if(result.code == 0)
{
// html内容处理
// 基础信息
// 是否存在数据、网络不通将返回空数据
if((result.data || null) != null)
{
var html = '<p class="upgrade-title">';
html += '<i class="am-icon-info-circle am-icon-md am-text-warning"></i>';
html += '<span class="am-margin-left-xs">'+result.data.title+'</span>';
html += '</p>';
html += '<div class="am-alert upgrade-base">';
html += '<span class="upgrade-ver">更新版本:'+result.data.version_new+'</span>';
html += '<span class="upgrade-date am-margin-left-sm">更新日期:'+result.data.add_time+'</span>';
// 是否带指定链接和链接名称
if((result.data.go_title || null) != null && (result.data.go_url || null) != null)
{
html += '<a href="'+result.data.go_url+'" class="upgrade-go-detail am-margin-left-lg" target="_blank">'+result.data.go_title+'</a>';
}
html += '</div>';
// 提示信息
if((result.data.tips || null) != null)
{
html += '<div class="am-alert am-alert-danger">';
html += '<p class="am-text-danger">'+result.data.tips+'</p>';
html += '</div>';
}
// 更新内容介绍
if((result.data.content || null) != null && result.data.content.length > 0)
{
html += '<div class="am-alert am-alert-secondary upgrade-content-item">';
html += '<ul>';
for(var i in result.data.content)
{
html += '<li>'+result.data.content[i]+'</li>';
}
html += '</ul>';
html += '</div>';
}
} else {
var html = '<p class="upgrade-title am-text-center am-margin-top-xl am-padding-top-xl">';
html += '<i class="am-icon-info-circle am-icon-md am-text-warning"></i>';
html += '<span class="am-margin-left-xs">'+result.msg+'</span>';
html += '</p>';
}
$inspect_upgrade_popup.find('.upgrade-content').html(html);
// 是否支持在线自动更新
if((result.data.is_auto || 0) == 1)
{
$inspect_upgrade_popup.find('.inspect-upgrade-confirm').removeClass('am-hide');
} else {
$inspect_upgrade_popup.find('.inspect-upgrade-confirm').addClass('am-hide');
}
// 打开弹窗
$inspect_upgrade_popup.modal('open');
} else {
Prompt(result.msg);
}
},
error: function(xhr, type)
{
AMUI.dialog.loading('close');
Prompt(HtmlToString(xhr.responseText) || '异常错误', null, 30);
}
});
});
// 系统更新确认
$('.inspect-upgrade-confirm').on('click', function()
{
$inspect_upgrade_popup.modal('close');
SystemUpgradeRequestHandle({"url": $(this).data('url')});
});
// 初始化
$('.content-right .echarts-where-submit').each(function(k ,v)
{
if(parseInt($(this).parents('.right-operate').data('init')) == 1)
{
EchartsInit($(this));
}
});
// 条件确认
$('.echarts-where-submit').on('click', function()
{
EchartsInit($(this));
});
// 快捷时间
$('.quick-time a').on('click', function()
{
// 参数判断
var start = $(this).data('start') || null;
var end = $(this).data('end') || null;
if(start == null || end == null)
{
Prompt('快捷时间配置有误');
return false;
}
// 时间
var $time = $(this).parent().next();
if(!$time.find('button').is(':disabled'))
{
$time.find('input[name="time_start"]').val(start);
$time.find('input[name="time_end"]').val(end);
$time.find('button').trigger('click');
}
});
// 浏览器大小改变则实时更新图表大小
window.onresize = function()
{
if(chart_object.length > 0)
{
for(var i in chart_object)
{
chart_object[i].resize();
}
}
};
});

View File

@ -1,85 +1,3 @@
/**
* 系统更新异步请求步骤
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-02-22
* @desc description
* @param {[string]} url [url地址]
* @param {[string]} opt [操作类型url 获取下载地址 download_system 下载系统包 download_upgrade 下载升级包 upgrade 更新操作]
* @param {[string]} msg [提示信息]
*/
function SystemUpgradeRequestHandle(params)
{
// 参数处理
if((params || null) == null)
{
Prompt('操作参数有误');
return false;
}
var url = params.url || null;
var opt = params.opt || 'url';
var msg = params.msg || '正在获取中...';
// 加载提示
AMUI.dialog.loading({title: msg});
// ajax
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
timeout: 305000,
data: {"opt":opt},
success: function(result)
{
if((result || null) != null && result.code == 0)
{
switch(opt)
{
// 获取下载地址
case 'url' :
params['opt'] = 'download_system';
params['msg'] = '系统包正在下载中...';
SystemUpgradeRequestHandle(params);
break;
// 下载系统包
case 'download_system' :
params['opt'] = 'download_upgrade';
params['msg'] = '升级包正在下载中...';
SystemUpgradeRequestHandle(params);
break;
// 下载升级包
case 'download_upgrade' :
params['opt'] = 'upgrade';
params['msg'] = '正在更新中...';
SystemUpgradeRequestHandle(params);
break;
// 更新完成
case 'upgrade' :
Prompt(result.msg, 'success');
setTimeout(function()
{
window.location.reload();
}, 1500);
break;
}
} else {
AMUI.dialog.loading('close');
Prompt(((result || null) == null) ? '返回数据格式错误' : (result.msg || '异常错误'));
}
},
error: function(xhr, type)
{
AMUI.dialog.loading('close');
Prompt(HtmlToString(xhr.responseText) || '异常错误');
}
});
}
$(function()
{
/**
@ -259,99 +177,4 @@ $(function()
}
}
});
// 检查更新
var $inspect_upgrade_popup = $('#inspect-upgrade-popup');
$('.inspect-upgrade-submit').on('click', function()
{
// 基础信息
AMUI.dialog.loading({title: '正在获取最新内容、请稍候...'});
// ajax请求
$.ajax({
url: $(this).data('url'),
type: 'POST',
dataType: 'json',
timeout: 30000,
data: {},
success: function(result)
{
AMUI.dialog.loading('close');
if(result.code == 0)
{
// html内容处理
// 基础信息
// 是否存在数据、网络不通将返回空数据
if((result.data || null) != null)
{
var html = '<p class="upgrade-title">';
html += '<i class="am-icon-info-circle am-icon-md am-text-warning"></i>';
html += '<span class="am-margin-left-xs">'+result.data.title+'</span>';
html += '</p>';
html += '<div class="am-alert upgrade-base">';
html += '<span class="upgrade-ver">更新版本:'+result.data.version_new+'</span>';
html += '<span class="upgrade-date am-margin-left-sm">更新日期:'+result.data.add_time+'</span>';
// 是否带指定链接和链接名称
if((result.data.go_title || null) != null && (result.data.go_url || null) != null)
{
html += '<a href="'+result.data.go_url+'" class="upgrade-go-detail am-margin-left-lg" target="_blank">'+result.data.go_title+'</a>';
}
html += '</div>';
// 提示信息
if((result.data.tips || null) != null)
{
html += '<div class="am-alert am-alert-danger">';
html += '<p class="am-text-danger">'+result.data.tips+'</p>';
html += '</div>';
}
// 更新内容介绍
if((result.data.content || null) != null && result.data.content.length > 0)
{
html += '<div class="am-alert am-alert-secondary upgrade-content-item">';
html += '<ul>';
for(var i in result.data.content)
{
html += '<li>'+result.data.content[i]+'</li>';
}
html += '</ul>';
html += '</div>';
}
} else {
var html = '<p class="upgrade-title am-text-center am-margin-top-xl am-padding-top-xl">';
html += '<i class="am-icon-info-circle am-icon-md am-text-warning"></i>';
html += '<span class="am-margin-left-xs">'+result.msg+'</span>';
html += '</p>';
}
$inspect_upgrade_popup.find('.upgrade-content').html(html);
// 是否支持在线自动更新
if((result.data.is_auto || 0) == 1)
{
$inspect_upgrade_popup.find('.inspect-upgrade-confirm').removeClass('am-hide');
} else {
$inspect_upgrade_popup.find('.inspect-upgrade-confirm').addClass('am-hide');
}
// 打开弹窗
$inspect_upgrade_popup.modal('open');
} else {
Prompt(result.msg);
}
},
error: function(xhr, type)
{
AMUI.dialog.loading('close');
Prompt(HtmlToString(xhr.responseText) || '异常错误', null, 30);
}
});
});
// 系统更新确认
$('.inspect-upgrade-confirm').on('click', function()
{
$inspect_upgrade_popup.modal('close');
SystemUpgradeRequestHandle({"url": $(this).data('url')});
});
});