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
+238
View File
@@ -0,0 +1,238 @@
<?php
namespace app\admin\controller\app;
use app\common\controller\Backend;
use think\Db;
use think\Config;
/**
* 一键发币
*
* @icon fa fa-circle-o
*/
class AppCurrRelease extends Backend
{
/**
* AppCurrRelease模型对象
* @var \app\admin\model\app\AppCurrRelease
*/
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\app\AppCurrRelease;
$this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("isBbList", $this->model->getIsBbList());
$this->view->assign("isHytradeList", $this->model->getIsHytradeList());
$this->view->assign("isTkList", $this->model->getIsTkList());
}
public function import()
{
parent::import();
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 添加
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post("row/a");
if ($params) {
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$params['symbol'] = strtolower($params['symbol']);
$rates = Db::name("app_rate")->where("symbol",$params['symbol'])->find();
if(!empty($rates)){
$this->error($params['symbol']."标识已存在,请选择其他币种");
}
Db::startTrans();
try {
// $this->error("暂未开放");
$rate_data = array(
"name" => $params['name'],
"nickname" => $params['name'],
"coinname" => $params['name']."/USDT",
"symbol" => $params['symbol'],
"is_hytrade" => $params['is_hytrade'],
"high" => $params['usdt'],
"low" => $params['usdt'],
"open" => $params['usdt'],
"close" => $params['usdt'],
"usdt" => $params['usdt'],
"rmb" => $params['usdt']*6.4,
"jd" => 4,
"logo_image" => $params['logo_image'],
"liutong_num" => $params['count_num'],
"gongji_num" => $params['count_num'],
"count_num" => $params['count_num'],
"faxin_price" => $params['usdt'],
"is_bb" => $params['is_bb'],
"bb_type" => 2,
"market_jd" => 4,
"price_jd" => 4,
);
$curr_data = array(
"name" => $params['name'],
"full_name" => $params['name'],
"exchange" => $params['usdt'],
"suffix" => $params['symbol'],
"thumb_image" => $params['logo_image'],
"is_reg" => 0,
"is_wid" => 0,
"is_tran" => 0,
"is_otc" => 0,
"createtime" => time(),
);
if($params['status'] != 3){
$curr_data['status'] = "1";
$rate_data['status'] = "0";
}else{
$curr_data['status'] = "0";
$rate_data['status'] = "1";
}
$rate_id = Db::name("app_rate")->insertGetId($rate_data);
$curr_id = Db::name("app_currency")->insertGetId($curr_data);
$params['rate_id'] = $rate_id;
$id = Db::name("app_curr_release")->insertGetId($params);
$user = Db::name("user")->field("id")->select();
$user_curr = [];
foreach ($user as $key => $value) {
$user_curr[] = array(
"user_id" => $value['id'],
"curr_id" => $curr_id,
"num" => 0,
);
}
Db::name("app_currency_user")->insertAll($user_curr);
create_bt_kline($id);
Db::commit();
$this->success();
} catch (Exception $e) {
Db::rollback();
$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);
Db::startTrans();
try {
$rate_update = array(
"is_bb" => $params['is_bb'],
"is_hytrade" => $params['is_hytrade'],
"logo_image" => $params['logo_image'],
);
$curr_update = array(
"thumb_image" => $params['logo_image'],
);
if($params['status'] != 3){
$rate_update['status'] = 0;
$curr_update['status'] = "1";
}else{
$rate_update['status'] = 1;
$curr_update['status'] = "0";
}
if($params['is_tk'] == 1){
$rate_update['tradectrl_json'] = $params['tradectrl_json'];
$rate_update['trademulte_json'] = $params['trademulte_json'];
}else{
$rate_update['tradectrl_json'] = "";
$rate_update['trademulte_json'] = $params['trademulte_json'];
}
Db::name("app_curr_release")->where("id",$row['id'])->update($params);
Db::name("app_rate")->where("name",$row['name'])->update($rate_update);
Db::name("app_currency")->where("name",$row['name'])->update($curr_update);
Db::commit();
$this->success();
} catch (Exception $e) {
Db::rollback();
$this->error(__('No rows were updated'));
}
}
$this->error(__('Parameter %s can not be empty', ''));
}
$this->view->assign("row", $row);
return $this->view->fetch();
}
/**
* 删除
*/
public function del($ids = "")
{
if (!$this->request->isPost()) {
$this->error(__("Invalid parameters"));
}
$ids = $ids ? $ids : $this->request->post("ids");
if ($ids) {
$list = Db::name('app_curr_release')->where("id","in",$ids)->select();
// var_dump($list);exit;
Db::startTrans();
try {
foreach ($list as $k => $v) {
Db::name("bb_k_15min")->where("symbol",$v['symbol'])->delete();
Db::name("bb_k_1h")->where("symbol",$v['symbol'])->delete();
Db::name("bb_k_1min")->where("symbol",$v['symbol'])->delete();
Db::name("bb_k_5min")->where("symbol",$v['symbol'])->delete();
Db::name("bb_k_24h")->where("symbol",$v['symbol'])->delete();
Db::name("bb_k_30min")->where("symbol",$v['symbol'])->delete();
Db::name("app_rate")->where("id",$v['rate_id'])->delete();
$curr = Db::name("app_currency")->where("suffix",$v['symbol'])->order("id desc")->find();
Db::name("app_currency")->where("id",$curr['id'])->delete();
Db::name("app_currency_user")->where("curr_id",$curr['id'])->delete();
$ico = Db::name("app_ico_set")->where("curr_id",$curr['id'])->find();
Db::name("app_ico_set")->where("id",$ico['id'])->delete();
Db::name("app_ico_user")->where("ico_id",$ico['id'])->delete();
Db::name("app_detailed")->where("curr_id",$curr['id'])->delete();
Db::name("app_curr_release")->where("id",$v['id'])->delete();
}
Db::commit();
$this->success();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
}
$this->error(__('Parameter %s can not be empty', 'ids'));
}
}