orderCoutInfo(); $a = Cache::store('redis')->set('info-30',$info); } //订单大数据统计 30天数据展示 public function orderCoutInfo(){ $sourceid = 1; $agentid = ''; $wxmpid = ''; $map = array(); $nowday= date('Y-m-d'); $info=array(); // 30天历史统计列表 for($i=30;$i>=1;$i--){ $date=strtotime($nowday)-(30-$i)*24*3600; $map['create_time'] = array(array('gt',$date),array('lt',$date+86399)); $map['status'] = 1; $info[date('Y-m-d',$date)] = array( // 充值金额 "pay"=> db('order')->where('iscontrol',0)->where($map)->sum('money'), // 普通充值 "paynormal"=> db('order')->where('iscontrol',0)->where($map)->where(array( 'type'=>1 ))->sum('money'), "normalnum"=> db('order')->where('iscontrol',0)->where(array_merge($map,array('type'=>1)))->count('uid'),//普通充值人数 "payvip"=> db('order')->where('iscontrol',0)->where($map)->where(array( 'type'=>2 ))->sum('money'),//年费VIP会员充值金额 "vipnum"=> db('order')->where('iscontrol',0)->where(array_merge($map,array('type'=>2)))->count(),//充值人数 "payOffer"=> db('order')->where('iscontrol',0)->where($map)->where(array( 'type'=>3 ))->sum('money'),//活动充值充值金额 "Offernum"=> db('order')->where('iscontrol',0)->where(array_merge($map,array('type'=>3)))->count(),//活动充值充值人数 "payPaid"=>$this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,1,1,0,0,$agentid),//普通充值支付订单数 "payUnpaid"=> $this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,1,0,0,0,$agentid),//未付款 "payYaerPaid"=>$this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,2,1,0,0,$agentid),//年费VIP会员支付订单数 "payYaerUnpaid"=> $this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,2,0,0,0,$agentid),//未付款 "payOfferPaid"=>$this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,3,1,0,0,$agentid),//活动充值支付订单数 "payOfferUnpaid"=> $this->statistics($wxmpid,$sourceid,'1',0,$date,$date+86399,3,0,0,0,$agentid),//活动充值未付款 ); } return $info; } /** * statistics [充值笔数] * * @param type $sourceid [来源 1:cps 2:APP] * @param type $model [1:小说,2:漫画] * @param type $is_kouliang [是否扣量] * @param type $startData [开始时间] * @param type $endData [结束时间] * @param type $type [订单类型] * @param type $status [订单状态] * @param type $recharge_type [充值方式 1:直接充值 2:引导充值] * @return type **/ protected function statistics($wxmpid,$sourceid,$model='1',$is_kouliang=0,$startData,$endData,$type=0,$status=0,$articleid=0,$recharge_type=0,$agentid=0) { if($startData && $endData){ $map['create_time'] = array(array('gt',$startData),array('lt',$endData)) ; } if($sourceid){ $map['sourceid'] = $sourceid; } if($type){ $map['type'] = array('in',$type); } if($recharge_type){ $map['recharge_type'] = $recharge_type; } if($articleid){ $map['articleid'] = $articleid; } if(strpos($model,",")!==false){ $map['model'] = array('IN',$model); }else{ $map['model'] = $model; } if($is_kouliang){ $map['is_kouliang'] = 1; }else{ $map['is_kouliang'] = 0; } $map['status'] = $status; if($endDatawhere('iscontrol',0)->where($map)->count(); }else{ $total = db('order')->where('iscontrol',0)->where($map)->count(); } return $total; } }