|
@@ -1204,20 +1204,51 @@ class StatisticsController extends Controller
|
1204
|
1204
|
* 成单率梯形图
|
1205
|
1205
|
*/
|
1206
|
1206
|
public function orderRateList(Request $request){
|
|
1207
|
+ $stime = $request->input('stime');
|
|
1208
|
+ $etime = $request->input('etime');
|
|
1209
|
+ $_day = 30;
|
|
1210
|
+ if($stime == '' && $etime == ''){
|
|
1211
|
+ $stime = date("Y-m-d", strtotime('-32 day'));
|
|
1212
|
+ $etime = date("Y-m-d", strtotime('-2 day'));
|
|
1213
|
+ }else{
|
|
1214
|
+ if($stime){
|
|
1215
|
+ $_day = floor( (time() - strtotime($stime)) / 86400) - 1; //距昨天天数
|
|
1216
|
+ }
|
|
1217
|
+ }
|
1207
|
1218
|
#统计天数
|
1208
|
1219
|
$month = date('d')<=2 ? date('Y-m', strtotime('-1 month')) : date('Y-m'); //当前月
|
1209
|
|
- $day_count = DB::table('cust_day_remain')->where('month_time', $month)->count();
|
1210
|
|
- #计算分区级别 固定分20区
|
1211
|
|
- $_day = round($day_count / 30);
|
1212
|
|
- if($_day == 0) $_day = 1;
|
1213
|
|
- $result = DB::table('cust_day_remain')->orderBy('idate', 'asc')->orderBy('month_time', 'asc')->get();
|
|
1220
|
+ $day_count = DB::table('cust_day_remain')->where('month_time', $month)->where(function($query) use($stime, $etime){
|
|
1221
|
+ if($stime) $query->where('idate','>=', $stime);
|
|
1222
|
+ if($etime) $query->where('idate','<=', $etime);
|
|
1223
|
+ })->count();
|
|
1224
|
+
|
|
1225
|
+ $result = DB::table('cust_day_remain')->where(function($query) use($stime, $etime){
|
|
1226
|
+ if($stime) $query->where('idate','>=', $stime);
|
|
1227
|
+ if($etime) $query->where('idate','<=', $etime);
|
|
1228
|
+ })->orderBy('idate', 'asc')->orderBy('month_time', 'asc')->get();
|
|
1229
|
+
|
|
1230
|
+ if($stime)
|
1214
|
1231
|
#获取列
|
1215
|
1232
|
$columns = array();
|
1216
|
|
- $i_max = floor($day_count/$_day) > 30 ? 30 : floor($day_count/$_day);
|
|
1233
|
+ $i_max = 31;
|
1217
|
1234
|
for($i=0; $i<$i_max; $i++){
|
1218
|
|
- $columns[] = $i*$_day;
|
|
1235
|
+ $columns[] = $i;
|
1219
|
1236
|
}
|
1220
|
1237
|
|
|
1238
|
+ if($_day >= 45){
|
|
1239
|
+ $columns[] = 45;
|
|
1240
|
+ }
|
|
1241
|
+ if($_day >= 60){
|
|
1242
|
+ $columns[] = 60;
|
|
1243
|
+ }
|
|
1244
|
+ if($_day >= 75){
|
|
1245
|
+ $columns[] = 75;
|
|
1246
|
+ }
|
|
1247
|
+ if($_day >= 90){
|
|
1248
|
+ $columns[] = 90;
|
|
1249
|
+ }
|
|
1250
|
+
|
|
1251
|
+
|
1221
|
1252
|
#数据整合
|
1222
|
1253
|
$data = array();
|
1223
|
1254
|
foreach($result as $k=>$v){
|
|
@@ -1239,7 +1270,7 @@ class StatisticsController extends Controller
|
1239
|
1270
|
}
|
1240
|
1271
|
//echo '<pre>';
|
1241
|
1272
|
//print_r($new_data);print_r($columns);exit;
|
1242
|
|
- return view('statistics/orderRateList', ['result' =>$new_data, 'columns'=>$columns]);
|
|
1273
|
+ return view('statistics/orderRateList', ['result' =>$new_data, 'columns'=>$columns, 'stime'=>$stime, 'etime'=>$etime]);
|
1243
|
1274
|
|
1244
|
1275
|
}
|
1245
|
1276
|
}
|