472 lines
14 KiB
PHP
472 lines
14 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | 缓存更新 数据统计 [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\admin\controller;
|
|
use app\common\controller\Admin;
|
|
use think\Cache;
|
|
use think\Controller;
|
|
|
|
class Newcache extends Controller{
|
|
|
|
//更新数据统计缓存
|
|
public function index(){
|
|
$data = $this->orderCoutData();
|
|
$b = Cache::store('redis')->set('Statistics-data',$data,300);
|
|
echo '更新缓存成功';
|
|
echo $b;
|
|
}
|
|
|
|
//订单大数据统计 今日昨日本月总数据
|
|
public function orderCoutData(){
|
|
$showDataDay = array(); //今日
|
|
$showDataYesterday = array(); //昨日
|
|
$showDataMonth = array(); //本月
|
|
$showDataCount = array(); //总统计
|
|
$showDataDayOffset = array(); //今日低充
|
|
$showDataYesterdayOffset = array(); //昨日低充
|
|
$showDataOffset = array(); //累计低充
|
|
$showDataDayback = array(); //今日返回键充值
|
|
$showDataYesterdayback = array(); //昨日返回键充值
|
|
$showDataback = array(); //累计返回键充值
|
|
|
|
// 今日
|
|
$showDataDay['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->sum('money');
|
|
|
|
$showDataDay['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDay['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDay['npay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDay['nnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDay['hpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDay['hnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
// 昨日
|
|
$showDataYesterday['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->sum('money');
|
|
|
|
$showDataYesterday['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterday['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterday['npay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterday['nnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterday['hpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterday['hnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
// 本月
|
|
$showDataMonth['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->sum('money');
|
|
|
|
$showDataMonth['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
$showDataMonth['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
$showDataMonth['npay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
$showDataMonth['nnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
$showDataMonth['hpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
$showDataMonth['hnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'month')->count();
|
|
|
|
// 上月
|
|
$showDataMonthlast['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->sum('money');
|
|
|
|
$showDataMonthlast['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
$showDataMonthlast['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
$showDataMonthlast['npay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
$showDataMonthlast['nnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
$showDataMonthlast['hpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
$showDataMonthlast['hnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->whereTime('create_time', 'last month')->count();
|
|
|
|
// 总统计
|
|
$showDataCount['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->sum('money');
|
|
|
|
$showDataCount['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataCount['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataCount['npay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataCount['nnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>2,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataCount['hpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataCount['hnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>3,
|
|
'hidden'=>0,
|
|
'isback'=>0
|
|
))->where('iscontrol',0)->count();
|
|
|
|
|
|
// 潜在用户今日低充
|
|
$showDataDayOffset['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->sum('money');
|
|
|
|
$showDataDayOffset['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDayOffset['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
|
|
$showDataDayOffset['firstpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDayOffset['complexpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>array('>',1)
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$hiddenNum['userType'] = array('in','4,5,6,11,12,13,14');
|
|
$invalid['userType'] = array('in','7,8');
|
|
|
|
$showDataDayOffset['hiddenNum'] = db('member')->where($hiddenNum)->whereTime('reg_time', 'today')->count();
|
|
$showDataDayOffset['invalid'] = db('member')->where($invalid)->whereTime('reg_time', 'today')->count();
|
|
|
|
// 潜在用户昨日低充
|
|
$showDataYesterdayOffset['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->sum('money');
|
|
|
|
$showDataYesterdayOffset['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterdayOffset['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterdayOffset['firstpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterdayOffset['complexpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>array('>',1)
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterdayOffset['hiddenNum'] = db('member')->where($hiddenNum)->whereTime('matchTypeTime', 'yesterday')->count();
|
|
$showDataYesterdayOffset['invalid'] = db('member')->where($invalid)->whereTime('matchTypeTime', 'yesterday')->count();
|
|
|
|
|
|
// 潜在用户累计低充
|
|
$showDataOffset['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->sum('money');
|
|
|
|
$showDataOffset['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataOffset['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'type'=>1,
|
|
'hidden'=>1
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataOffset['firstpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>1
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataOffset['complexpay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'type'=>1,
|
|
'hidden'=>1,
|
|
'is_complex'=>array('>',1)
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataOffset['hiddenNum'] = db('member')->where($hiddenNum)->count();
|
|
$showDataOffset['invalid'] = db('member')->where($invalid)->count();
|
|
|
|
// 今日返回键充值
|
|
$showDataDayback['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->sum('money');
|
|
|
|
$showDataDayback['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
$showDataDayback['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'today')->count();
|
|
|
|
// 昨日返回键充值
|
|
$showDataYesterdayback['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->sum('money');
|
|
|
|
$showDataYesterdayback['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
$showDataYesterdayback['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->whereTime('create_time', 'yesterday')->count();
|
|
|
|
// 累计返回键充值
|
|
$showDataback['daymoney'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->sum('money');
|
|
|
|
$showDataback['ppay'] = db('order')->where(array(
|
|
'status'=>1,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->count();
|
|
|
|
$showDataback['pnopay'] = db('order')->where(array(
|
|
'status'=>0,
|
|
'isback'=>1
|
|
))->where('iscontrol',0)->count();
|
|
|
|
|
|
|
|
return $data = array(
|
|
'showDataDay'=>$showDataDay,
|
|
'showDataYesterday'=>$showDataYesterday,
|
|
'showDataMonth'=>$showDataMonth,
|
|
'showDataCount'=>$showDataCount,
|
|
'showDataMonthlast'=>$showDataMonthlast,
|
|
'showDataDayOffset'=>$showDataDayOffset,
|
|
'showDataOffset'=>$showDataOffset,
|
|
'showDataYesterdayOffset'=>$showDataYesterdayOffset,
|
|
'showDataDayback'=>$showDataDayback,
|
|
'showDataYesterdayback'=>$showDataYesterdayback,
|
|
'showDataback'=>$showDataback
|
|
);
|
|
}
|
|
|
|
|
|
public function getaccess_token(){ //获取access_token 用redis来做中间token存储
|
|
$redis = new \Redis();
|
|
$redis->connect('127.0.0.1',6379);
|
|
$list = db('wxopen_account')->select();
|
|
foreach ($list as $k => $v) {
|
|
$token_access_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $v['appid'] . "&secret=" . $v['appsecret'];
|
|
$res = file_get_contents($token_access_url); //获取文件内容或获取网络请求的内容
|
|
$result = json_decode($res, true); //接受一个 JSON 格式的字符串并且把它转换为 PHP 变量
|
|
if(isset($result['access_token'])){
|
|
//把access_token存入redis用 access_token expires_in 过期时间 来做过期时间
|
|
$redis->setex($v['appid'],$result['expires_in'],$result['access_token']);
|
|
$this->access_token = $result['access_token'];
|
|
db('wxopen_account')->where('appid',$v['appid'])->update(['access_token'=>$result['access_token']]);
|
|
}
|
|
}
|
|
}
|
|
} |