feat: 后端全量更新 - 含所有本次需求
- Contract.php: 返回合约账户余额(balance_contract) - My.php: 地址管理增加BTC/ETH - AppContract.php: 一键平仓(closeall) - AppProxy.php: 代理专属注册链接 + 分级权限(L1/L2) - site.php: 手续费减半(0.018→0.009) - agent_permission_setup.sql: 代理权限SQL - crypto_news_crawler.py: 新闻自动采集脚本
This commit is contained in:
+195
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\app;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 代理管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class AppProxyTj extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* AppProxyTj模型对象
|
||||
* @var \app\admin\model\app\AppProxyTj
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\app\AppProxyTj;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function import()
|
||||
{
|
||||
parent::import();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags']);
|
||||
if ($this->request->isAjax())
|
||||
{
|
||||
//如果发送的来源是Selectpage,则转发到Selectpage
|
||||
if ($this->request->request('keyField'))
|
||||
{
|
||||
return $this->selectpage();
|
||||
}
|
||||
// list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
$offset = $this->request->get("offset", 0);
|
||||
$limit = $this->request->get("limit", 0);
|
||||
$params = json_decode(input('filter'),true);
|
||||
$op = json_decode(input('op'),true);
|
||||
if(count($params) > 0){
|
||||
$new_params = $new_op = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if($key == 'user_name')
|
||||
{
|
||||
$new_params['u.nickname'] = $value;
|
||||
$new_op['u.nickname'] = $op[$key];
|
||||
}else if($key == 'admin_name'){
|
||||
$new_params['b.nickname'] = $value;
|
||||
$new_op['b.nickname'] = $op[$key];
|
||||
}else {
|
||||
$new_params['a.' . $key] = $value;
|
||||
$new_op['a.' . $key] = $op[$key];
|
||||
}
|
||||
}
|
||||
$w = $this->rewriteQuery($new_params, $new_op);
|
||||
}else{
|
||||
$w['a.id'] = array('>', 0);
|
||||
}
|
||||
$admin_id = $this->auth->id;
|
||||
if($admin_id > 1){
|
||||
$user = Db::name("user")->where("admin_id",$admin_id)->find();
|
||||
if($user){
|
||||
$w['u.path'] = array("like",$user['path']."%");
|
||||
$w['a.admin_id'] = array("neq",$admin_id);
|
||||
}
|
||||
}
|
||||
$total = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.path')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->count();
|
||||
$list = Db::name('app_proxy')
|
||||
->alias('a')
|
||||
->field('a.*,b.nickname as admin_name,u.path')
|
||||
->join('fa_user u', 'a.user_id = u.id')
|
||||
->join('fa_admin b','b.id = a.admin_id')
|
||||
->where($w)
|
||||
->order('a.id', 'desc')
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
$today = strtotime(date("Y-m-d"));
|
||||
foreach ($list as $key => $value) {
|
||||
|
||||
$son_arr = [];
|
||||
//团队人数
|
||||
$team_arr = Db::name("user")->field("id,jointime")->where("path","like",$value['path']."%")->where("id","neq",$value['user_id'])->select();
|
||||
$team_num = count($team_arr);$today_user = 0;
|
||||
foreach ($team_arr as $ke => $val) {
|
||||
$son_arr[] = $val['id'];
|
||||
}
|
||||
foreach ($team_arr as $ke => $val) {
|
||||
if(in_array($val['id'], $son_arr) && $val['jointime']>$today){
|
||||
$today_user = $today_user+1;
|
||||
}
|
||||
}
|
||||
//累计充值
|
||||
$rechrge = Db::name("app_recharge")->field("user_id,num,addtime")->where("status",1)->select();
|
||||
$count_reg = 0;$today_reg = 0;
|
||||
foreach ($rechrge as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_reg = $count_reg+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['addtime']>$today){
|
||||
$today_reg = $today_user+$val['num'];
|
||||
}
|
||||
}
|
||||
//累计提现
|
||||
$widthdraw = Db::name("app_widthdraw")->field("user_id,num,add_time")->where("status",1)->select();
|
||||
$count_wid = 0;$today_wid = 0;
|
||||
foreach ($widthdraw as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_wid = $count_wid+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['add_time']>$today){
|
||||
$today_wid = $today_wid+$val['num'];
|
||||
}
|
||||
}
|
||||
//币币交易
|
||||
$trade = Db::name("app_coin_trade")->field("user_id,have_usdt,createtime")->select();
|
||||
$count_trade = 0;$today_trade = 0;
|
||||
foreach ($trade as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_trade = $count_trade+$val['have_usdt'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_trade = $today_trade+$val['have_usdt'];
|
||||
}
|
||||
}
|
||||
//合约交易
|
||||
$contract = Db::name("app_contract")->field("user_id,num,createtime")->where("status","2")->select();
|
||||
$count_cont = 0;$today_cont = 0;
|
||||
foreach ($contract as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_cont = $count_cont+$val['num'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_cont = $today_cont+$val['num'];
|
||||
}
|
||||
}
|
||||
|
||||
//ICO
|
||||
$detail = Db::name("app_detailed")->field("user_id,price,createtime")->where("cart",2)->where("type",5)->where("description","ICO")->select();
|
||||
$count_ico = 0;$today_ico = 0;
|
||||
foreach ($detail as $ke => $val) {
|
||||
if(in_array($val['user_id'], $son_arr)){
|
||||
$count_ico = $count_ico+$val['price'];
|
||||
}
|
||||
if(in_array($val['user_id'], $son_arr) && $val['createtime']>$today){
|
||||
$today_ico = $today_ico+$val['price'];
|
||||
}
|
||||
}
|
||||
$value['team_num'] = $team_num;
|
||||
$value['today_user'] = $today_user;
|
||||
$value['count_reg'] = sprintf("%.2f",$count_reg);
|
||||
$value['today_reg'] = sprintf("%.2f",$today_reg);
|
||||
$value['count_wid'] = sprintf("%.2f",$count_wid);
|
||||
$value['today_wid'] = sprintf("%.2f",$today_wid);
|
||||
$value['count_trade'] = sprintf("%.2f",$count_trade);
|
||||
$value['today_trade'] = sprintf("%.2f",$today_trade);
|
||||
$value['count_cont'] = sprintf("%.2f",$count_cont);
|
||||
$value['today_cont'] = sprintf("%.2f",$today_cont);
|
||||
$value['count_ico'] = sprintf("%.2f",$count_ico);
|
||||
$value['today_ico'] = sprintf("%.2f",$today_ico);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
//可结算金额
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user