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
+153
View File
@@ -0,0 +1,153 @@
<?php
namespace app\admin\controller\app;
use app\common\controller\Backend;
/**
* 资讯管理
*
* @icon fa fa-circle-o
*/
class AppZixun extends Backend
{
/**
* AppZixun模型对象
* @var \app\admin\model\app\AppZixun
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\app\AppZixun;
}
public function import()
{
parent::import();
}
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
// 设置默认值
if (!isset($params['user_id']) || empty($params['user_id'])) {
$params['user_id'] = $this->auth->id; // 使用当前登录管理员ID
}
if (!isset($params['look_num']) || $params['look_num'] === '') {
$params['look_num'] = 0;
}
if (!isset($params['addtime']) || empty($params['addtime'])) {
$params['addtime'] = time();
}
// 可选字段,如果为空则设置为空字符串
$optionalFields = ['title_en', 'cover_image', 'content_en'];
foreach ($optionalFields as $field) {
if (!isset($params[$field])) {
$params[$field] = '';
}
}
$result = false;
\think\Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException(true)->validate($validate);
}
$result = $this->model->allowField(true)->save($params);
\think\Db::commit();
} catch (\think\exception\PDOException $e) {
\think\Db::rollback();
$this->error($e->getMessage());
} catch (\think\Exception $e) {
\think\Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were inserted'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
return $this->view->fetch();
}
/**
* 编辑
*/
public function edit($ids = null)
{
$row = $this->model->get($ids);
if (!$row) {
$this->error(__('No Results were found'));
}
$adminIds = $this->getDataLimitAdminIds();
if (is_array($adminIds)) {
if (!in_array($row[$this->dataLimitField], $adminIds)) {
$this->error(__('You have no permission'));
}
}
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
// 可选字段,如果为空则设置为空字符串
$optionalFields = ['title_en', 'cover_image', 'content_en'];
foreach ($optionalFields as $field) {
if (!isset($params[$field])) {
$params[$field] = '';
}
}
$result = false;
\think\Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
$row->validateFailException(true)->validate($validate);
}
$result = $row->allowField(true)->save($params);
\think\Db::commit();
} catch (\think\exception\PDOException $e) {
\think\Db::rollback();
$this->error($e->getMessage());
} catch (\think\Exception $e) {
\think\Db::rollback();
$this->error($e->getMessage());
}
if ($result !== false) {
$this->success();
} else {
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
}