- 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: 新闻自动采集脚本
238 lines
10 KiB
PHP
Executable File
238 lines
10 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\admin\controller\app;
|
|
|
|
use app\common\controller\Backend;
|
|
use think\Db;
|
|
|
|
/**
|
|
* C2C申述记录
|
|
*
|
|
* @icon fa fa-circle-o
|
|
*/
|
|
class AppMarketAppeal extends Backend
|
|
{
|
|
|
|
/**
|
|
* AppMarketAppeal模型对象
|
|
* @var \app\admin\model\app\AppMarketAppeal
|
|
*/
|
|
protected $model = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new \app\admin\model\app\AppMarketAppeal;
|
|
$this->view->assign("typeList", $this->model->getTypeList());
|
|
$this->view->assign("statusList", $this->model->getStatusList());
|
|
$this->view->assign("victoryList", $this->model->getVictoryList());
|
|
}
|
|
|
|
public function import()
|
|
{
|
|
parent::import();
|
|
}
|
|
|
|
/**
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
|
*/
|
|
|
|
/**
|
|
* index重写
|
|
*/
|
|
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);
|
|
// print_r($params);exit;
|
|
if(count($params) > 0){
|
|
$new_params = $new_op = [];
|
|
foreach ($params as $key => $value) {
|
|
if ($key == 'mobile') {
|
|
$new_params['u.mobile'] = $value;
|
|
$new_op['u.mobile'] = $op[$key];
|
|
}elseif ($key == 'nickname') {
|
|
$new_params['u.nickname'] = $value;
|
|
$new_op['u.nickname'] = $op[$key];
|
|
}else {
|
|
$new_params['aa.' . $key] = $value;
|
|
$new_op['aa.' . $key] = $op[$key];
|
|
}
|
|
}
|
|
$w = $this->rewriteQuery($new_params, $new_op);
|
|
}else{
|
|
$w['aa.id'] = array('>', 0);
|
|
}
|
|
$total = Db::name('app_market_appeal aa')
|
|
->field('aa.*,u.nickname,u.mobile')
|
|
->join('user u', 'aa.user_id = u.id','left')
|
|
->where($w)
|
|
->count();
|
|
$list = Db::name('app_market_appeal aa')
|
|
->field('aa.*,u.nickname,u.mobile')
|
|
->join('user u', 'aa.user_id = u.id','left')
|
|
->where($w)
|
|
->order('aa.id', 'desc')
|
|
->limit($offset, $limit)
|
|
->select();
|
|
// var_dump( Db::name('jpp_widthdraw aa')->getlastsql() );die;
|
|
$result = array("total" => $total, "rows" => $list);
|
|
|
|
return json($result);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 重写编辑
|
|
* @param type $ids
|
|
* @return type
|
|
*/
|
|
public function edit($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
// echo "<pre>";var_dump($row);die;
|
|
if (!$row) {
|
|
$this->error(__('No Results were found'));
|
|
}
|
|
if ($this->request->isPost()) {
|
|
$params = $this->request->post("row/a");
|
|
// echo "<pre>";var_dump($params);die;
|
|
//start
|
|
$w1 = [];
|
|
$w1['id'] = array("eq",$ids);
|
|
$r1 = Db::name( "app_market_appeal" )->where( $w1 )->find();
|
|
if( !$r1 ){
|
|
$this->error( "未查询到信息" );
|
|
}
|
|
Db::startTrans();
|
|
try {
|
|
if($r1['status'] == 2 && $params['status'] == 1){
|
|
if($params['victory'] == 1){
|
|
//卖家胜 回滚
|
|
$market_user = Db::name("app_market_user")->where("id",$r1['order_id'])->find();
|
|
if(empty($market_user)){
|
|
$this->error("订单错误");
|
|
}
|
|
$market = Db::name("app_market")->where("id",$market_user['order_id'])->find();
|
|
if($market_user['type'] == 1){
|
|
//买单
|
|
$buy_user_id = $market_user['user_id'];
|
|
$sell_user_id = $market_user['relid'];
|
|
}else{
|
|
//卖单
|
|
$sell_user_id = $market_user['user_id'];
|
|
$buy_user_id = $market_user['relid'];
|
|
|
|
// 退币
|
|
$user_curr = Db::name("app_currency_user")->where("user_id",$sell_user_id)->where("curr_id",$market['curr_id'])->find();
|
|
$count_num = $market_user['num']+$market_user['free_num'];
|
|
$derail_date = array(
|
|
"user_id" => $sell_user_id,
|
|
"curr_id" => $user_curr['curr_id'],
|
|
"price" => $count_num,
|
|
"cart" => 1,
|
|
"type" => 2,
|
|
"description" => "交易失败,货币退还",
|
|
"createtime" => time(),
|
|
"before_num" => $user_curr['num_fb'],
|
|
"after_num" => $user_curr['num_fb']+$count_num,
|
|
);
|
|
Db::name("app_detailed_fb")->insert($derail_date);
|
|
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num_fb",$count_num);
|
|
}
|
|
//修改订单
|
|
$market_user_update = array(
|
|
"status" => 5,
|
|
"cancel_time" => time(),
|
|
);
|
|
Db::name("app_market_user")->where("id",$market_user['id'])->update($market_user_update);
|
|
$market_update = array(
|
|
"status" => 1,
|
|
"updatetime" => time(),
|
|
);
|
|
Db::name("app_market")->where("id",$market['id'])->update($market_update);
|
|
}else{
|
|
//买家胜 放币
|
|
$market_user = Db::name("app_market_user")->where("id",$r1['order_id'])->find();
|
|
if(empty($market_user)){
|
|
$this->error("订单错误");
|
|
}
|
|
$market = Db::name("app_market")->where("id",$market_user['order_id'])->find();
|
|
if($market_user['type'] == 1){
|
|
//买单
|
|
$buy_user_id = $market_user['user_id'];
|
|
$sell_user_id = $market_user['relid'];
|
|
}else{
|
|
$sell_user_id = $market_user['user_id'];
|
|
$buy_user_id = $market_user['relid'];
|
|
}
|
|
//修改订单
|
|
$market_user_update = array(
|
|
"status" => 4,
|
|
"succ_time" => time(),
|
|
);
|
|
Db::name("app_market_user")->where("id",$market_user['id'])->update($market_user_update);
|
|
//修改挂单
|
|
if($market['residue_num']>$market_user['num']){
|
|
$market_update = array(
|
|
"residue_num" => $market['residue_num'] - $market_user['num'],
|
|
"status" => 1,
|
|
"updatetime" => time(),
|
|
);
|
|
}else{
|
|
$market_update = array(
|
|
"residue_num" => 0,
|
|
"status" => 3,
|
|
"endtime" => time(),
|
|
);
|
|
}
|
|
Db::name("app_market")->where("id",$market['id'])->update($market_update);
|
|
//放币
|
|
$user_curr = Db::name("app_currency_user")->where("user_id",$buy_user_id)->where("curr_id",$market['curr_id'])->find();
|
|
$derail_date[] = array(
|
|
"user_id" => $buy_user_id,
|
|
"curr_id" => $user_curr['curr_id'],
|
|
"price" => $market_user['num'],
|
|
"cart" => 1,
|
|
"type" => 2,
|
|
"description" => "货币购买",
|
|
"createtime" => time(),
|
|
"before_num" => $user_curr['num_fb'],
|
|
"after_num" => $user_curr['num_fb']+$market_user['num'],
|
|
);
|
|
Db::name("app_currency_user")->where("id",$user_curr['id'])->setInc("num_fb",$market_user['num']);
|
|
|
|
Db::name("app_detailed_fb")->insertAll($derail_date);
|
|
}
|
|
}
|
|
$params['updatetime'] = time();
|
|
Db::name("app_market_appeal")->where("id",$ids)->update($params);
|
|
Db::commit();
|
|
$this->success("success");
|
|
} catch (Exception $e) {
|
|
Db::rollback();
|
|
$this->error("修改失败");
|
|
}
|
|
|
|
}
|
|
$this->view->assign("row", $row);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
}
|