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:
li
2026-03-30 20:16:32 +08:00
commit 1b24994e74
6721 changed files with 1308571 additions and 0 deletions
+305
View File
@@ -0,0 +1,305 @@
<?php
namespace app\admin\controller\app;
use app\common\controller\Backend;
use think\Db;
/**
* 用户货币管理
*
* @icon fa fa-circle-o
*/
class AppCurrencyUser extends Backend
{
/**
* AppCurrencyUser模型对象
* @var \app\admin\model\app\AppCurrencyUser
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\app\AppCurrencyUser;
}
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 == 'mobile')
{
$new_params['u.' . $key] = $value;
$new_op['u.' . $key] = $op[$key];
}else if($key == 'user_name'){
$new_params['u.nickname'] = $value;
$new_op['u.nickname'] = $op[$key];
}else if($key == 'coinname'){
$new_params['b.name'] = $value;
$new_op['b.name'] = $op[$key];
}elseif ($key == 'daili_name') {
$new_params['e.nickname'] = $value;
$new_op['e.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']."%");
}
}
$total = Db::name('app_currency_user')
->alias('a')
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
->join('fa_user u', 'a.user_id = u.id')
->join('fa_app_currency b', 'b.id = a.curr_id')
->join('admin e', 'u.p_admin_id = e.id' , 'left')
->where($w)
->count();
$list = Db::name('app_currency_user')
->alias('a')
->field('a.*,u.nickname as user_name,b.name as coinname,e.nickname as daili_name')
->join('fa_user u', 'a.user_id = u.id')
->join('fa_app_currency b', 'b.id = a.curr_id')
->join('admin e', 'u.p_admin_id = e.id' , 'left')
->where($w)
->order('a.id', 'desc')
->limit($offset, $limit)
->select();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
public function recharge()
{
if ($this->request->isPost()) {
// exit;
$params = $this->request->post();
if ($params) {
if(!isset($params['num']) || !is_numeric($params['num']))
{
$this->error('请输入正常的数量');
}
if(!isset($params['user_id']) || !is_numeric($params['user_id']))
{
$this->error('请选择正确的用户');
}
$user = Db::name('app_currency_user')->where('user_id',$params['user_id'])
->where('curr_id',$params['curr_id'])->find();
if(!$user)
{
$this->error('该用户账号不存在');
}
$admin_id = $this->auth->id;
if($admin_id > 1){
$my_user = Db::name("user")->where("admin_id",$admin_id)->find();
$reg_user = Db::name("user")->where("id",$user['user_id'])->find();
$path_arr = explode("|", $reg_user['path']);
if(!in_array($my_user['id'], $path_arr)){
$this->error("权限不足");
}
}
if($params['num'] < 0){
$num = abs($params['num']);
$recharge = [
'user_id' => $user['user_id'],
'curr_id' => $user['curr_id'],
'price' => $num,
'cart' => '2',
'type' => '1',
'description' => '后台扣除',
'hash' => time(),
'before_num' => $user['num'],
'after_num' => $user['num'] - $num,
'is_outer' => '0',
'order_result' => 'result',
'createtime' => time(),
];
$amount = $user['num'] - $num;
}else{
$num = $params['num'];
$recharge = [
'user_id' => $user['user_id'],
'curr_id' => $user['curr_id'],
'price' => $params['num'],
'cart' => '1',
'type' => '1',
'description' => '后台充值',
'hash' => time(),
'before_num' => $user['num'],
'after_num' => $user['num'] + $num,
'is_outer' => '0',
'order_result' => 'result',
'createtime' => time(),
];
$amount = $user['num'] + $num;
}
if ($amount > 0) {
Db::name('app_detailed')->insert($recharge);
$changeamount = $amount;
Db::name('app_currency_user')->where('id', $user['id'])
->update(['num' => $changeamount, 'updatetime' => time()]);
}
$this->success('充值成功');
}
}
return $this->view->fetch();
}
/**
* 冻结操作
*/
public function freeze()
{
if ($this->request->isPost()) {
// exit;
$params = $this->request->post();
if ($params) {
if(!isset($params['user_id']) || !is_numeric($params['user_id']))
{
$this->error('请选择正确的用户');
}
$user = Db::name('app_currency_user')->where('user_id',$params['user_id'])
->where('curr_id',$params['curr_id'])->find();
if(!$user)
{
$this->error('该用户账号不存在');
}
if($params['type'] == 1){
//冻结
switch ($params['zh_type']) {
case 1:
$table = "app_detailed";
$key = "num";
$key_dj = "num_dj";
break;
case 2:
$table = "app_detailed_fb";
$key = "num_fb";
$key_dj = "num_fb_dj";
break;
case 3:
$table = "app_detailed_lh";
$key = "num_lh";
$key_dj = "num_lh_dj";
break;
default:
break;
}
if($params['num'] <= 0){
$num = $user[$key];
}else{
if($params['num'] > $user[$key]){
$this->error("账户余额不足");
}
$num = $params['num'];
}
$recharge = [
'user_id' => $user['user_id'],
'curr_id' => $user['curr_id'],
'price' => $num,
'cart' => '2',
'type' => '5',
'description' => '账户冻结',
'before_num' => $user[$key],
'after_num' => $user[$key] - $num,
'createtime' => time(),
];
$after_num = $user[$key] - $num;
$after_num_dj = $user[$key_dj] + $num;
}else{
//解除冻结
switch ($params['zh_type']) {
case 1:
$table = "app_detailed";
$key = "num";
$key_dj = "num_dj";
break;
case 2:
$table = "app_detailed_fb";
$key = "num_fb";
$key_dj = "num_fb_dj";
break;
case 3:
$table = "app_detailed_lh";
$key = "num_lh";
$key_dj = "num_lh_dj";
break;
default:
break;
}
if($params['num'] <= 0){
$num = $user[$key_dj];
}else{
if($params['num'] > $user[$key_dj]){
$this->error("冻结余额不足");
}
$num = $params['num'];
}
$recharge = [
'user_id' => $user['user_id'],
'curr_id' => $user['curr_id'],
'price' => $num,
'cart' => '1',
'type' => '5',
'description' => '解除冻结',
'before_num' => $user[$key],
'after_num' => $user[$key] + $num,
'createtime' => time(),
];
$after_num = $user[$key] + $num;
$after_num_dj = $user[$key_dj] - $num;
}
Db::name($table)->insert($recharge);
Db::name('app_currency_user')->where('id', $user['id'])->update([$key => $after_num,$key_dj=>$after_num_dj]);
$this->success('操作成功');
}
}
return $this->view->fetch();
}
}