Commit 946741dbae64ac9b50d3da23b283d80527689eae

Authored by teemitop
1 parent 80685b16

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

@@ -60,27 +60,55 @@ class Index extends Common @@ -60,27 +60,55 @@ class Index extends Common
60 public function main(){ 60 public function main(){
61 61
62 if(Request::isAjax()) { 62 if(Request::isAjax()) {
63 - $arr = array();  
64 - $time = $this->GetDate();  
65 - foreach ($time as $key => $value) {  
66 - $time[$key]['list'] = array_column( Db::query("SELECT  
67 - type  
68 - FROM  
69 - `xt-member-two-LINE`.xt_dc_reserve AS r  
70 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid  
71 - WHERE  
72 - r.cdate BETWEEN ".$value['sta']."  
73 - AND ".$value['end']."  
74 - AND t.type_id = 1 AND r.status not in (4,6)"), 'type');  
75 - }  
76 - foreach ($time as $key => $value) {  
77 - $arr['time'][] = $key; //日期  
78 - $arr['online'][] = array_sum($value['list']); //在线订单  
79 - $arr['unline'][] = count($value['list']) - array_sum($value['list']); //内部订单  
80 - }  
81 63
82 - $arr['online_sum'] = array_sum($arr['online']);  
83 - $arr['unline_sum'] = array_sum($arr['unline']); 64 + $arr = cache('time_total');
  65 +
  66 + if(!$arr){
  67 + $arr = array();
  68 + $time = $this->GetDate();
  69 + foreach ($time as $key => $value) {
  70 + $time[$key]['list'] = array_column( Db::query("SELECT
  71 + type
  72 + FROM
  73 + `xt-member-two-LINE`.xt_dc_reserve AS r
  74 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
  75 + WHERE
  76 + r.cdate BETWEEN ".$value['sta']."
  77 + AND ".$value['end']."
  78 + AND t.type_id = 1 AND r.status not in (4,6)"), 'type');
  79 + $time[$key]['cancel'] = Db::query("SELECT
  80 + count(r.id) as cancel
  81 + FROM
  82 + `xt-member-two-LINE`.xt_dc_reserve AS r
  83 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
  84 + WHERE
  85 + r.cdate BETWEEN ".$value['sta']."
  86 + AND ".$value['end']."
  87 + AND t.type_id = 1 AND r.status = 4");
  88 + $time[$key]['refuse'] = Db::query("SELECT
  89 + count(r.id) as refuse
  90 + FROM
  91 + `xt-member-two-LINE`.xt_dc_reserve AS r
  92 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS t ON r.sid = t.sid
  93 + WHERE
  94 + r.cdate BETWEEN ".$value['sta']."
  95 + AND ".$value['end']."
  96 + AND t.type_id = 1 AND r.status = 6");
  97 + }
  98 + foreach ($time as $key => $value) {
  99 + $arr['time'][] = $key; //日期
  100 + $arr['online'][] = array_sum($value['list']); //最近7天每天在线订单
  101 + $arr['unline'][] = count($value['list']) - array_sum($value['list']); //最近7天每天内部订单
  102 + $arr['cancel'][] = intval(join(",",$value['cancel'][0])); //最近7天每天取消的
  103 + $arr['refuse'][] = intval(join(",",$value['refuse'][0])); //最近7天每天拒单的
  104 + unset($time[$key]['list']);
  105 + }
  106 + $arr['online_sum'] = array_sum($arr['online']); //最近7天在线订单
  107 + $arr['unline_sum'] = array_sum($arr['unline']); //最近7天内部订单
  108 + $arr['cancel_sum'] = array_sum($arr['cancel']); //最近7天取消的
  109 + $arr['refuse_sum'] = array_sum($arr['refuse']); //最近7天拒单的
  110 + cache('time_total', $arr, 3600); //将数据集加入缓存
  111 + }
84 112
85 return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$arr,'rel'=>1]; 113 return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$arr,'rel'=>1];
86 } 114 }
@@ -98,8 +98,8 @@ layui.use(['table', 'layer'], function(){ @@ -98,8 +98,8 @@ layui.use(['table', 'layer'], function(){
98 layer.close(loading); 98 layer.close(loading);
99 var dom = document.getElementById("container"); 99 var dom = document.getElementById("container");
100 var dom1 = document.getElementById("container1"); 100 var dom1 = document.getElementById("container1");
101 - var myChart = echarts.init(dom);  
102 - var myChart1 = echarts.init(dom1); 101 + var myChart = echarts.init(dom,'light');
  102 + var myChart1 = echarts.init(dom1,'light');
103 var app = {}; 103 var app = {};
104 option = null; 104 option = null;
105 option = { 105 option = {
@@ -118,7 +118,7 @@ layui.use(['table', 'layer'], function(){ @@ -118,7 +118,7 @@ layui.use(['table', 'layer'], function(){
118 } 118 }
119 }, 119 },
120 legend: { 120 legend: {
121 - data: ['在线订单', '内部订单'], 121 + data: ['在线订单', '内部订单','取消订单','拒绝订单'],
122 left: 'left', 122 left: 'left',
123 }, 123 },
124 toolbox: { 124 toolbox: {
@@ -139,38 +139,47 @@ layui.use(['table', 'layer'], function(){ @@ -139,38 +139,47 @@ layui.use(['table', 'layer'], function(){
139 data: data.data.time 139 data: data.data.time
140 } 140 }
141 ], 141 ],
142 - yAxis: [  
143 - {  
144 - type: 'value', 142 + yAxis: {
  143 + type: 'value',
  144 + axisLabel: {
  145 + formatter: '{value} 单'
  146 + },
  147 + axisPointer: {
  148 + snap: true
145 } 149 }
146 - ], 150 + },
147 series: [ 151 series: [
148 { 152 {
149 name: '在线订单', 153 name: '在线订单',
150 type: 'line', 154 type: 'line',
151 - stack: '总量',  
152 smooth: true, 155 smooth: true,
153 - areaStyle: {color: '#37a2da'},  
154 - lineStyle: {  
155 - color: '#2195ae',  
156 - width: 3  
157 - },  
158 - itemStyle: {color: '#2195ae',}, 156 + areaStyle: {},
  157 +
159 data: data.data.online 158 data: data.data.online
160 }, 159 },
161 -  
162 { 160 {
163 name: '内部订单', 161 name: '内部订单',
164 type: 'line', 162 type: 'line',
165 smooth: true, 163 smooth: true,
166 - stack: '总量',  
167 - areaStyle: {color: '#46b1c3'},  
168 - lineStyle: {  
169 - color: '#66e0e3',  
170 - width: 3  
171 - },  
172 - itemStyle: {color: '#66e0e3',}, 164 + areaStyle: {},
  165 +
173 data: data.data.unline 166 data: data.data.unline
  167 + },
  168 + {
  169 + name: '取消订单',
  170 + type: 'line',
  171 + smooth: true,
  172 + areaStyle: {},
  173 +
  174 + data: data.data.cancel
  175 + },
  176 + {
  177 + name: '拒绝订单',
  178 + type: 'line',
  179 + smooth: true,
  180 + areaStyle: {},
  181 +
  182 + data: data.data.refuse
174 } 183 }
175 ] 184 ]
176 }; 185 };
@@ -193,7 +202,7 @@ layui.use(['table', 'layer'], function(){ @@ -193,7 +202,7 @@ layui.use(['table', 'layer'], function(){
193 legend: { 202 legend: {
194 orient: 'vertical', 203 orient: 'vertical',
195 left: 'left', 204 left: 'left',
196 - data: ['在线预订', '内部预订'] 205 + data: ['在线订单', '内部订单','取消订单','拒绝订单']
197 }, 206 },
198 series: [ 207 series: [
199 { 208 {
@@ -204,17 +213,19 @@ layui.use(['table', 'layer'], function(){ @@ -204,17 +213,19 @@ layui.use(['table', 'layer'], function(){
204 data: [ 213 data: [
205 { 214 {
206 value:data.data.online_sum, 215 value:data.data.online_sum,
207 - name:'在线预订',  
208 - itemStyle: {  
209 - color: '#37a2da'  
210 - } 216 + name:'在线订单'
211 }, 217 },
212 { 218 {
213 value:data.data.unline_sum, 219 value:data.data.unline_sum,
214 - name:'内部预订',  
215 - itemStyle: {  
216 - color: '#46b1c3'  
217 - } 220 + name:'内部订单'
  221 + },
  222 + {
  223 + value:data.data.cancel_sum,
  224 + name:'取消订单'
  225 + },
  226 + {
  227 + value:data.data.refuse_sum,
  228 + name:'拒绝订单'
218 } 229 }
219 ], 230 ],
220 clockwise: true, 231 clockwise: true,
@@ -225,11 +236,6 @@ layui.use(['table', 'layer'], function(){ @@ -225,11 +236,6 @@ layui.use(['table', 'layer'], function(){
225 color: '#333333' 236 color: '#333333'
226 } 237 }
227 } 238 }
228 - },  
229 - itemStyle: {  
230 - // 设置扇形的颜色  
231 - shadowBlur: 150,  
232 - shadowColor: 'rgba(5, 10, 243)'  
233 } 239 }
234 } 240 }
235 ] 241 ]