Update Index.php

This commit is contained in:
Anyon 2019-07-31 13:59:47 +08:00
parent 1ae537afa6
commit 917e6ec777

View File

@ -38,18 +38,18 @@ class Index extends Controller
*/ */
public function index() public function index()
{ {
$map = ['appid' => WechatService::getAppid()];
$this->totalJson = ['xs' => [], 'ys' => []]; $this->totalJson = ['xs' => [], 'ys' => []];
for ($i = 5; $i >= 0; $i--) { for ($i = 5; $i >= 0; $i--) {
$time = strtotime("-{$i} months"); $time = strtotime("-{$i} months");
$where = [['subscribe_at', '<', date('Y-m-32 00:00:00', $time)]]; $where = [['subscribe_at', '<', date('Y-m-32 00:00:00', $time)]];
$this->totalJson['xs'][] = date('Y年m月', $time); $this->totalJson['xs'][] = date('Y年m月', $time);
$item = ['_0' => 0, '_1' => 0]; $item = ['_0' => 0, '_1' => 0];
$list = Db::name('WechatFans')->field('count(1) count,is_black black')->where($where)->group('is_black')->select(); $list = Db::name('WechatFans')->field('count(1) count,is_black black')->where($map)->where($where)->group('is_black')->select();
foreach ($list as $vo) $item["_{$vo['black']}"] = $vo['count']; foreach ($list as $vo) $item["_{$vo['black']}"] = $vo['count'];
$this->totalJson['ys']['_0'][] = $item['_0']; $this->totalJson['ys']['_0'][] = $item['_0'];
$this->totalJson['ys']['_1'][] = $item['_1']; $this->totalJson['ys']['_1'][] = $item['_1'];
} }
$map = ['appid' => WechatService::getAppid()];
$this->totalFans = Db::name('WechatFans')->where(['is_black' => '0'])->where($map)->count(); $this->totalFans = Db::name('WechatFans')->where(['is_black' => '0'])->where($map)->count();
$this->totalBlack = Db::name('WechatFans')->where(['is_black' => '1'])->where($map)->count(); $this->totalBlack = Db::name('WechatFans')->where(['is_black' => '1'])->where($map)->count();
$this->totalNews = Db::name('WechatNews')->where(['is_deleted' => '0'])->count(); $this->totalNews = Db::name('WechatNews')->where(['is_deleted' => '0'])->count();