<?php
namespace app\system\admin;
use Env;
use hisi\Dir;
use think\Db;
class Index extends Admin
{
public function index()
{
$admin_type = session('admin_type');
$this->assign('admin_type',$admin_type);
$sub0 = Db::name('subscribe')->where('status',0)->where('shop_id',session('shop_id'))->count('id');
$sub1 = Db::name('subscribe')->where('status',1)->where('shop_id',session('shop_id'))->count('id');
$sub2 = Db::name('subscribe')->where('status',2)->where('shop_id',session('shop_id'))->count('id');
$sub3 = Db::name('subscribe')->where('status',3)->where('shop_id',session('shop_id'))->count('id');
$sub5 = Db::name('subscribe')->where('status',5)->where('shop_id',session('shop_id'))->count('id');
$sub6 = Db::name('subscribe')->where('status',6)->where('shop_id',session('shop_id'))->count('id');
$sub7 = Db::name('product_order')->where('status',3)->where('shop_id',session('shop_id'))->count('id');
$this->assign('sub0', $sub0);
$this->assign('sub1', $sub1);
$this->assign('sub2', $sub2);
$this->assign('sub3', $sub3);
$this->assign('sub5', $sub5);
$this->assign('sub6', $sub6);
$this->assign('sub7', $sub7);
$userlagin = Db::query("SELECT nick,last_login_time FROM hisi_user where DATE_SUB(CURDATE(), INTERVAL 90 DAY) > date(from_unixtime(last_login_time))");
$this->assign('userlagin',$userlagin);
$this->assign('userlagincount',count($userlagin));
$userbir = Db::query("SELECT nick, shop_id,from_unixtime(birthday)
FROM hisi_user
WHERE date_format( from_unixtime(birthday), '%m%d' )
BETWEEN date_format( now( ) , '%m%d' )
AND date_format( date_add( now( ) , INTERVAL 7
DAY ) , '%m%d' )");
foreach ($userbir as $key => $value) {
$userbir[$key]['shop_name'] = Db::name('shop')->where('id',$value['shop_id'])->value('name');
}
$this->assign('userbir',$userbir);
$this->assign('userbircount',count($userbir));
if (cookie('hisi_iframe')) {
$this->view->engine->layout(false);
return $this->fetch('iframe');
} else {
if($this->request->module() == 'system' && $this->request->controller() == 'Index' && $this->request->action() == 'index'){
$this->view->engine->layout(false);
}
return $this->fetch();
}
}
public function getliushi()
{
$userlagin = Db::query("SELECT nick,last_login_time FROM hisi_user where DATE_SUB(CURDATE(), INTERVAL 90 DAY) > date(from_unixtime(last_login_time))");
$this->assign('userlagin',$userlagin);
$this->assign('userlagincount',count($userlagin));
$this->view->engine->layout(false);
return $this->fetch();
}
public function getuserbircount()
{
$userbir = Db::query("SELECT nick, shop_id,from_unixtime(birthday,'%Y-%m-%d') as birthday1
FROM hisi_user
WHERE date_format( from_unixtime(birthday), '%m%d' )
BETWEEN date_format( now( ) , '%m%d' )
AND date_format( date_add( now( ) , INTERVAL 7
DAY ) , '%m%d' )");
foreach ($userbir as $key => $value) {
$userbir[$key]['shop_name'] = Db::name('shop')->where('id',$value['shop_id'])->value('name');
}
$this->assign('userbir',$userbir);
$this->assign('userbircount',count($userbir));
$this->view->engine->layout(false);
return $this->fetch();
}
public function welcome()
{
$admin_type = session('admin_type');
$this->assign('admin_type',$admin_type);
$sub0 = Db::name('subscribe')->where('status',0)->where('shop_id',session('shop_id'))->count('id');
$sub1 = Db::name('subscribe')->where('status',1)->where('shop_id',session('shop_id'))->count('id');
$sub2 = Db::name('subscribe')->where('status',2)->where('shop_id',session('shop_id'))->count('id');
$sub3 = Db::name('subscribe')->where('status',3)->where('shop_id',session('shop_id'))->count('id');
$sub5 = Db::name('subscribe')->where('status',5)->where('shop_id',session('shop_id'))->count('id');
$sub6 = Db::name('subscribe')->where('status',6)->where('shop_id',session('shop_id'))->count('id');
$this->assign('sub0', $sub0);
$this->assign('sub1', $sub1);
$this->assign('sub2', $sub2);
$this->assign('sub3', $sub3);
$this->assign('sub5', $sub5);
$this->assign('sub6', $sub6);
$userlagin = Db::query("SELECT nick,last_login_time FROM hisi_user where DATE_SUB(CURDATE(), INTERVAL 90 DAY) > date(from_unixtime(last_login_time))");
$this->assign('userlagin',$userlagin);
$this->assign('userlagincount',count($userlagin));
$userbir = Db::query("SELECT nick, shop_id,from_unixtime(birthday)
FROM hisi_user
WHERE date_format( from_unixtime(birthday), '%m%d' )
BETWEEN date_format( now( ) , '%m%d' )
AND date_format( date_add( now( ) , INTERVAL 7
DAY ) , '%m%d' )");
foreach ($userbir as $key => $value) {
$userbir[$key]['shop_name'] = Db::name('shop')->where('id',$value['shop_id'])->value('name');
}
$this->assign('userbir',$userbir);
$this->assign('userbircount',count($userbir));
return $this->fetch('index');
}
public function clear()
{
$path = Env::get('runtime_path');
$cache = $this->request->param('cache/d', 0);
$log = $this->request->param('log/d', 0);
$temp = $this->request->param('temp/d', 0);
if ($cache == 1) {
Dir::delDir($path.'cache');
}
if ($temp == 1) {
Dir::delDir($path.'temp');
}
if ($log == 1) {
Dir::delDir($path.'log');
}
return $this->success('任务执行成功');
}
}