Files
juipphp/app/agent/controller/Account.php

107 lines
3.7 KiB
PHP
Raw Normal View History

2021-02-21 18:18:26 +08:00
<?php
namespace app\agent\controller;
use fastphp\base\Controller;
use app\agent\model\AgentUser;
use app\agent\model\User as UserModel;
use app\agent\model\ProductAccount as ProductAccountModel;
class Account extends Controller
{
//账号列表
public function getList ()
{
$get_data = $_GET;
$agent_id = $this->userinfo['OperaterID'];
2022-04-30 17:30:22 +08:00
$agent_phone = $this->userinfo['phone'];
2021-02-21 18:18:26 +08:00
$page = 0;
if (isset($_GET['PageIndex'])) {
$page = ($_GET['PageIndex'] - 1) * 50;
}
2023-11-01 18:04:25 +08:00
$where['DeleteTag'] = 0;
$where['agent_id']=$agent_id;
$where_str = '';
2021-02-21 18:18:26 +08:00
//处理筛选
if($get_data['UserId'] != 0){
$where['UserId'] = $get_data['UserId'];
}
if(!empty($get_data['ProductIds'])){
$where['ProductId'] = $get_data['ProductIds'];
}
if(!empty($get_data['PackageNames'])){
$where['PackageName'] = $get_data['PackageNames'];
}
if(!empty($get_data['accountTypes'])){
$where['AccountType'] = $get_data['accountTypes'];
}
if (!empty($_GET['Btime'])){
$date1 = date('Y-m-d', strtotime($_GET['Btime']));
$date2 = date('Y-m-d', strtotime($_GET['Etime']));
2023-11-01 18:04:25 +08:00
if (mb_strlen($where_str)>0){
$where_str .= ' AND ';
}
$where_str .= " EndTime>='" . $date1 . "' and EndTime<='" . $date2 . "' ";
2021-02-21 18:18:26 +08:00
}
if (!empty($_GET['Bktime'])){
if (mb_strlen($where_str)>0){
$where_str .= ' AND ';
}
$date1 = date('Y-m-d', strtotime($_GET['Bktime']));
$date2 = date('Y-m-d', strtotime($_GET['Ektime']));
$where_str .= " StartTime>='" . $date1 . "' and StartTime<='" . $date2 . "' ";
}
if (!empty($get_data['keyWord'])){
$where['Account'] = ['like','%'.$get_data['keyWord'].'%'];
}
//根据账号过期时间
if ($get_data['ExpirdDay'] > -100)
{
if (mb_strlen($where_str)>0){
$where_str .= ' AND ';
}
if ($get_data['ExpirdDay'] == 0)
{
$where_str .= ' EndTime<now() ';
}elseif($get_data['ExpirdDay'] == -2){
$where_str .= ' EndTime>now() ';
} elseif ($get_data['ExpirdDay'] < 0 && $get_data['ExpirdDay']>-4) {
$where_str .= ' TO_DAYS(EndTime) - (TO_DAYS(now()))>='.$get_data['ExpirdDay'].' AND EndTime < now() ';
} elseif ($get_data['ExpirdDay']==-4) {
$where_str .= 'TO_DAYS(EndTime) - (TO_DAYS(now()))<='.$get_data['ExpirdDay'].' ';
} elseif ($get_data['ExpirdDay'] > 0){
$where_str .= ' TO_DAYS(EndTime) - (TO_DAYS(now()))<='.$get_data['ExpirdDay'].' AND EndTime>now() ';
// $where2 .= ' AND EndTime<now() ';
}
}
2021-02-21 18:18:26 +08:00
$account_model = new ProductAccountModel;
$list = $account_model->getAgentListPage($where,$where_str, '*', 'id desc', "$page,50");
2023-11-01 18:04:25 +08:00
2021-02-21 18:18:26 +08:00
foreach ($list as &$info){
$endtime = strtotime($info['EndTime']);
if($endtime <= time()){
$info['RestTime'] = '已过期';
} else {
$day = ceil(($endtime - time())/86400);
$info['RestTime'] = $day.'天';
}
2022-04-30 17:30:22 +08:00
$info['UserCode'] = $info['UserPhone']?$info['UserPhone']:$info['UserCode'];
2021-02-21 18:18:26 +08:00
}
$data = [
'Code' => 10000,
'Data' => $list,
'Message' => '',
'TotalCount' => (int)$account_model->getCount($where)['count'],
];
echo json_encode($data);
}
}