|
@@ -191,4 +191,183 @@ class Dashboard extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 销售金额数据统计
|
|
|
+ */
|
|
|
+ public function datacenter_three(){
|
|
|
+ $type = input('type',1);
|
|
|
+
|
|
|
+ $servicetype = Db::name('servicetype')->field('id,title as name')->select();
|
|
|
+ //七日
|
|
|
+ if($type == 1){
|
|
|
+ $starttime = strtotime(date('Y-m-d')) - 518400;
|
|
|
+ $endtime = strtotime(date('Y-m-d')) + 86399;
|
|
|
+
|
|
|
+ $ec_date = [];
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'status' => 3,
|
|
|
+ ];
|
|
|
+ if($this->auth->type == 2){
|
|
|
+ $map['staff_id'] = $this->auth->id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for($i=$starttime;$i<$endtime;$i+=86400){
|
|
|
+ $starttime_i = $i;
|
|
|
+ $endtime_i = $i + 86399;
|
|
|
+ //日历
|
|
|
+ $ec_date[] = date('d',$starttime_i).'日';
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($servicetype as $key => &$val){
|
|
|
+ $map['servicetype_id'] = $val['id'];
|
|
|
+ $val['data'] = [];
|
|
|
+ $val['textColor'] = '#FFFFFF';
|
|
|
+ for($i=$starttime;$i<$endtime;$i+=86400){
|
|
|
+ $starttime_i = $i;
|
|
|
+ $endtime_i = $i + 86399;
|
|
|
+ //销售金额
|
|
|
+ $map['finish_time'] = ['between',[$starttime_i,$endtime_i]];
|
|
|
+ $val['data'][] = Db::name('order')->where($map)->sum('total_fee');
|
|
|
+ }
|
|
|
+ unset($val['id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ 'ec_data' => $ec_date,
|
|
|
+ 'ec_totalfee' => $servicetype,
|
|
|
+ ];
|
|
|
+ $this->success(1,$result);
|
|
|
+ }else{
|
|
|
+ $thismonth = strtotime(date('Y-m-01'));
|
|
|
+
|
|
|
+ $ec_date = [];
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'status' => 3,
|
|
|
+ ];
|
|
|
+ if($this->auth->type == 2){
|
|
|
+ $map['staff_id'] = $this->auth->id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for($i=5;$i>=0;$i--){
|
|
|
+ $starttime_i = strtotime("-".$i." month",$thismonth);
|
|
|
+ $endtime_i = strtotime("-".($i+1) ." month",$thismonth) - 1;
|
|
|
+ //日历
|
|
|
+ $ec_date[] = date('m',$starttime_i).'月';
|
|
|
+ //dump(date('Y-m-d H:i:s',$starttime_i));
|
|
|
+ //dump(date('Y-m-d H:i:s',$endtime_i));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ foreach($servicetype as $key => &$val){
|
|
|
+ $map['servicetype_id'] = $val['id'];
|
|
|
+ $val['data'] = [];
|
|
|
+ $val['textColor'] = '#FFFFFF';
|
|
|
+ for($i=5;$i>=0;$i-=1){
|
|
|
+ $starttime_i = strtotime("-".$i." month",$thismonth);
|
|
|
+ $endtime_i = strtotime("-".($i+1) ." month",$thismonth) - 1;
|
|
|
+ //销售金额
|
|
|
+ $map['finish_time'] = ['between',[$starttime_i,$endtime_i]];
|
|
|
+ $val['data'][] = Db::name('order')->where($map)->sum('total_fee');
|
|
|
+ }
|
|
|
+ unset($val['id']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ 'ec_data' => $ec_date,
|
|
|
+ 'ec_totalfee' => $servicetype,
|
|
|
+ ];
|
|
|
+ $this->success(1,$result);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 业绩统计笔数
|
|
|
+ */
|
|
|
+ public function datacenterfour(){
|
|
|
+ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前
|
|
|
+ $endtime = strtotime(date('Y-m-d')) - 1;
|
|
|
+
|
|
|
+ //接收
|
|
|
+ $choicedatetime = input('choicedatetime','');
|
|
|
+ if(!empty($choicedatetime)){
|
|
|
+ $choicedatetime = explode(' - ',$choicedatetime);
|
|
|
+ $starttime = strtotime($choicedatetime[0]);
|
|
|
+ $endtime = strtotime($choicedatetime[1]) + 86399;
|
|
|
+ }
|
|
|
+ $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime));
|
|
|
+
|
|
|
+ $staff = Db::name('company_staff')->field('id,truename')->where('type',2)->where('company_id',$this->auth->company_id)->select();
|
|
|
+ //柱状图
|
|
|
+ $ec_date = [];
|
|
|
+ $ec_ordernum = [];
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'status' => 3,
|
|
|
+ 'finish_time' => ['between',[$starttime,$endtime]],
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach($staff as $key => $val){
|
|
|
+ //日历
|
|
|
+ $ec_date[] = $val['truename'];
|
|
|
+ //下单人数
|
|
|
+ $map['staff_id'] = $val['id'];
|
|
|
+ $ec_ordernum[] = Db::name('order')->where($map)->count('id');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assignconfig('ec_date', $ec_date);
|
|
|
+ $this->assignconfig('ec_ordernum', $ec_ordernum);
|
|
|
+
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 业绩统计金额
|
|
|
+ */
|
|
|
+ public function datacenterfive(){
|
|
|
+ $starttime = strtotime(date('Y-m-d',strtotime("-30 day"))); //默认30天前
|
|
|
+ $endtime = strtotime(date('Y-m-d')) - 1;
|
|
|
+
|
|
|
+ //接收
|
|
|
+ $choicedatetime = input('choicedatetime','');
|
|
|
+ if(!empty($choicedatetime)){
|
|
|
+ $choicedatetime = explode(' - ',$choicedatetime);
|
|
|
+ $starttime = strtotime($choicedatetime[0]);
|
|
|
+ $endtime = strtotime($choicedatetime[1]) + 86399;
|
|
|
+ }
|
|
|
+ $this->view->assign('defaultdatetime',date('Y-m-d',$starttime).' - '.date('Y-m-d',$endtime));
|
|
|
+
|
|
|
+ $staff = Db::name('company_staff')->field('id,truename')->where('type',2)->where('company_id',$this->auth->company_id)->select();
|
|
|
+ //柱状图
|
|
|
+ $ec_date = [];
|
|
|
+ $ec_ordernum = [];
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'company_id' => $this->auth->company_id,
|
|
|
+ 'status' => 3,
|
|
|
+ 'finish_time' => ['between',[$starttime,$endtime]],
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach($staff as $key => $val){
|
|
|
+ //日历
|
|
|
+ $ec_date[] = $val['truename'];
|
|
|
+ //下单人数
|
|
|
+ $map['staff_id'] = $val['id'];
|
|
|
+ $ec_ordernum[] = Db::name('order')->where($map)->sum('total_fee');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->assignconfig('ec_date', $ec_date);
|
|
|
+ $this->assignconfig('ec_ordernum', $ec_ordernum);
|
|
|
+
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|