Commit 946741dbae64ac9b50d3da23b283d80527689eae

Authored by teemitop
1 parent 80685b16

数据增加两项、增加数据缓存

... ... @@ -60,27 +60,55 @@ class Index extends Common
public function main(){
if(Request::isAjax()) {
$arr = array();
$time = $this->GetDate();
foreach ($time as $key => $value) {
$time[$key]['list'] = array_column( Db::query("SELECT
type
FROM
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
WHERE
r.cdate BETWEEN ".$value['sta']."
AND ".$value['end']."
AND t.type_id = 1 AND r.status not in (4,6)"), 'type');
}
foreach ($time as $key => $value) {
$arr['time'][] = $key; //日期
$arr['online'][] = array_sum($value['list']); //在线订单
$arr['unline'][] = count($value['list']) - array_sum($value['list']); //内部订单
}
$arr['online_sum'] = array_sum($arr['online']);
$arr['unline_sum'] = array_sum($arr['unline']);
$arr = cache('time_total');
if(!$arr){
$arr = array();
$time = $this->GetDate();
foreach ($time as $key => $value) {
$time[$key]['list'] = array_column( Db::query("SELECT
type
FROM
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
WHERE
r.cdate BETWEEN ".$value['sta']."
AND ".$value['end']."
AND t.type_id = 1 AND r.status not in (4,6)"), 'type');
$time[$key]['cancel'] = Db::query("SELECT
count(r.id) as cancel
FROM
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
WHERE
r.cdate BETWEEN ".$value['sta']."
AND ".$value['end']."
AND t.type_id = 1 AND r.status = 4");
$time[$key]['refuse'] = Db::query("SELECT
count(r.id) as refuse
FROM
`xt-member-two-LINE`.xt_dc_reserve AS r
LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
WHERE
r.cdate BETWEEN ".$value['sta']."
AND ".$value['end']."
AND t.type_id = 1 AND r.status = 6");
}
foreach ($time as $key => $value) {
$arr['time'][] = $key; //日期
$arr['online'][] = array_sum($value['list']); //最近7天每天在线订单
$arr['unline'][] = count($value['list']) - array_sum($value['list']); //最近7天每天内部订单
$arr['cancel'][] = intval(join(",",$value['cancel'][0])); //最近7天每天取消的
$arr['refuse'][] = intval(join(",",$value['refuse'][0])); //最近7天每天拒单的
unset($time[$key]['list']);
}
$arr['online_sum'] = array_sum($arr['online']); //最近7天在线订单
$arr['unline_sum'] = array_sum($arr['unline']); //最近7天内部订单
$arr['cancel_sum'] = array_sum($arr['cancel']); //最近7天取消的
$arr['refuse_sum'] = array_sum($arr['refuse']); //最近7天拒单的
cache('time_total', $arr, 3600); //将数据集加入缓存
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$arr,'rel'=>1];
}
... ...
... ... @@ -98,8 +98,8 @@ layui.use(['table', 'layer'], function(){
layer.close(loading);
var dom = document.getElementById("container");
var dom1 = document.getElementById("container1");
var myChart = echarts.init(dom);
var myChart1 = echarts.init(dom1);
var myChart = echarts.init(dom,'light');
var myChart1 = echarts.init(dom1,'light');
var app = {};
option = null;
option = {
... ... @@ -118,7 +118,7 @@ layui.use(['table', 'layer'], function(){
}
},
legend: {
data: ['在线订单', '内部订单'],
data: ['在线订单', '内部订单','取消订单','拒绝订单'],
left: 'left',
},
toolbox: {
... ... @@ -139,38 +139,47 @@ layui.use(['table', 'layer'], function(){
data: data.data.time
}
],
yAxis: [
{
type: 'value',
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} 单'
},
axisPointer: {
snap: true
}
],
},
series: [
{
name: '在线订单',
type: 'line',
stack: '总量',
smooth: true,
areaStyle: {color: '#37a2da'},
lineStyle: {
color: '#2195ae',
width: 3
},
itemStyle: {color: '#2195ae',},
areaStyle: {},
data: data.data.online
},
{
name: '内部订单',
type: 'line',
smooth: true,
stack: '总量',
areaStyle: {color: '#46b1c3'},
lineStyle: {
color: '#66e0e3',
width: 3
},
itemStyle: {color: '#66e0e3',},
areaStyle: {},
data: data.data.unline
},
{
name: '取消订单',
type: 'line',
smooth: true,
areaStyle: {},
data: data.data.cancel
},
{
name: '拒绝订单',
type: 'line',
smooth: true,
areaStyle: {},
data: data.data.refuse
}
]
};
... ... @@ -193,7 +202,7 @@ layui.use(['table', 'layer'], function(){
legend: {
orient: 'vertical',
left: 'left',
data: ['在线预订', '内部预订']
data: ['在线订单', '内部订单','取消订单','拒绝订单']
},
series: [
{
... ... @@ -204,17 +213,19 @@ layui.use(['table', 'layer'], function(){
data: [
{
value:data.data.online_sum,
name:'在线预订',
itemStyle: {
color: '#37a2da'
}
name:'在线订单'
},
{
value:data.data.unline_sum,
name:'内部预订',
itemStyle: {
color: '#46b1c3'
}
name:'内部订单'
},
{
value:data.data.cancel_sum,
name:'取消订单'
},
{
value:data.data.refuse_sum,
name:'拒绝订单'
}
],
clockwise: true,
... ... @@ -225,11 +236,6 @@ layui.use(['table', 'layer'], function(){
color: '#333333'
}
}
},
itemStyle: {
// 设置扇形的颜色
shadowBlur: 150,
shadowColor: 'rgba(5, 10, 243)'
}
}
]
... ...