Files
tuiguangzhushou/application/system/controller/Account.php
2020-08-06 15:26:41 +08:00

101 lines
3.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\system\controller;
use app\common\model\Account as AccountModel;
use app\common\model\AccountLogs as AccountLogsModel;
use app\common\model\Member as MemberModel;
use app\common\service\Excel;
class Account extends _Init
{
public function index($nickname = '', $start_date = '', $end_date = '')
{
$model = new AccountModel();
$info_map = [];
if (!empty($nickname)) {
$info_map['nickname|mobile'] = ['like', "%{$nickname}%"];
}
if ($start_date && $end_date) {
$map['create_time'] = ['between time', [$start_date, date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_date)) - 1)]];
} elseif ($start_date) {
$map['create_time'] = ['> time', $start_date];
} elseif ($end_date) {
$map['create_time'] = ['< time', date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_date)) - 1)];
}
// 搜索昵称
if (!empty($info_map)) {
$model = $model->hasWhere('userinfo', $info_map);
}
$this->list = $model->order('price desc')->paginate();
return $this->fetch();
}
public function logs($id = '', $start_time = '', $end_time = '')
{
$map = array();
if ($id) {
if (is_numeric($id)) {
$map['uid'] = $id;
} else {
$uid = MemberModel::where('username', $id)->value('id');
$map['uid'] = $uid;
}
}
if ($start_time && $end_time) {
$map['create_time'] = ['between time', [$start_time, date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_time)) - 1)]];
} elseif ($start_time) {
$map['create_time'] = ['> time', $start_time];
} elseif ($end_time) {
$map['create_time'] = ['< time', date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_time)) - 1)];
}
$this->list = AccountLogsModel::where($map)->order('create_time desc')->paginate();
$this->assign('info', MemberModel::find($id));
return $this->fetch();
}
public function toexcel($id = '', $start_time = '', $end_time = '')
{
$map = array();
if ($id) {
$map['uid'] = $id;
}
if ($start_time) {
$map['create_time'] = ['egt', strtotime($start_time)];
}
if ($end_time) {
$map['create_time'] = ['elt', strtotime($end_time)];
}
$list = AccountLogsModel::field('password', true)->where($map)->order('create_time desc')->select();
$n = array();
foreach ($list as $key => $v) {
$n[] = [
$v->uid,
$v->user->info->nickname ?? '',
$v->type_text,
$v->rules->title,
$v->increase,
$v->remark,
$v->create_time,
$v->fromuser,
$v->fuser->info->nickname ?? '',
];
}
$header = ['会员编号', '真实名称', '账户类型', '获取规则', '获取数值', '描述', '产生时间', '产生会员', '会员名称'];
$ress = Excel::writer($header, $n, '会员账户明细 - ' . date('Y年m月d日H时i分s秒', time()), true);
}
}