查询账号连接数
This commit is contained in:
67
app/manager/controller/Account.php
Normal file
67
app/manager/controller/Account.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-13 19:52:37
|
||||
* @LastEditors: “wanyongkang” “937888580@qq.com”
|
||||
* @LastEditTime: 2023-09-17 18:06:12
|
||||
*/
|
||||
|
||||
namespace app\manager\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use app\manager\model\ProductAccount;
|
||||
|
||||
class Account extends Controller
|
||||
{
|
||||
public function getAccountCount() {
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
$account_model = new ProductAccount;
|
||||
$where1 = [];
|
||||
$where2 = ' PackageName <> "测试卡" AND DeleteTag=0 ';
|
||||
//根据用户id
|
||||
if (!empty($data['UserId'])) {
|
||||
$where1['UserId'] = $data['UserId'];
|
||||
}
|
||||
//根据用户会员号
|
||||
if (!empty($data['keyWord'])) {
|
||||
$where1['UserCode'] = $data['keyWord'];
|
||||
}
|
||||
//根据产品
|
||||
if (!empty($data['ProductIds'])) {
|
||||
$where1['ProductId'] = ['in', $data['ProductIds']];
|
||||
}
|
||||
//根据套餐
|
||||
if (!empty($data['PackageNames'])) {
|
||||
$where1['PackageName'] = ['in', $data['PackageNames']];
|
||||
}
|
||||
//根据账号类型
|
||||
if (!empty($data['accountTypes'])) {
|
||||
$where1['AccountType'] = ['in', $data['accountTypes']];
|
||||
}
|
||||
//根据账号过期时间
|
||||
if ($data['ExpirdDay'] > -100)
|
||||
{
|
||||
if ($data['ExpirdDay'] == 0)
|
||||
{
|
||||
$where2 .= ' AND EndTime<now() ';
|
||||
}elseif($data['ExpirdDay'] == -2){
|
||||
$where2 .= ' AND EndTime>now() ';
|
||||
} elseif ($data['ExpirdDay'] < 0 && $data['ExpirdDay']>-4) {
|
||||
$where2 .= ' AND TO_DAYS(EndTime) - (TO_DAYS(now()))>='.$data['ExpirdDay'].' AND EndTime < now() ';
|
||||
} elseif ($data['ExpirdDay']==-4) {
|
||||
$where2 .= ' AND TO_DAYS(EndTime) - (TO_DAYS(now()))<='.$data['ExpirdDay'].' ';
|
||||
} elseif ($data['ExpirdDay'] > 0){
|
||||
$where2 .= ' AND TO_DAYS(EndTime) - (TO_DAYS(now()))<='.$data['ExpirdDay'].' AND EndTime>now() ';
|
||||
// $where2 .= ' AND EndTime<now() ';
|
||||
}
|
||||
}
|
||||
$count = $account_model->getCountConnect($where1,$where2);
|
||||
|
||||
$count = !empty($count)?$count:0;
|
||||
|
||||
\result($count,'',30000);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-16 14:44:02
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2020-11-25 14:56:10
|
||||
* @LastEditors: “wanyongkang” “937888580@qq.com”
|
||||
* @LastEditTime: 2023-09-17 17:39:17
|
||||
*/
|
||||
|
||||
namespace app\manager\model;
|
||||
@@ -88,4 +88,12 @@ class ProductAccount extends Model
|
||||
->limit($limit)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
//获取账号总连接数
|
||||
public function getCountConnect($where1 = [], $where2 = '') {
|
||||
return $this->field('sum(ConnectCount) as sum')
|
||||
->where($where1)
|
||||
->where($where2)
|
||||
->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user