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:
Executable
+177
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* 在线买币
|
||||
*/
|
||||
class Marketpay extends Api
|
||||
{
|
||||
// 无需登录的接口,*表示全部
|
||||
protected $noNeedLogin = [''];
|
||||
// 无需鉴权的接口,*表示全部
|
||||
protected $noNeedRight = ['*'];
|
||||
|
||||
|
||||
/**
|
||||
* 获取国家法币
|
||||
*/
|
||||
public function get_country()
|
||||
{
|
||||
$country = Db::name("app_market_country")->where("status",1)->select();
|
||||
foreach ($country as $key => $value) {
|
||||
$value['pay_image'] = Config::get("site.image_url").$value['pay_image'];
|
||||
$country[$key] = $value;
|
||||
}
|
||||
$this->success("ok",$country);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起购买
|
||||
*/
|
||||
public function add_order()
|
||||
{
|
||||
$id = $this->request->post("id");
|
||||
$num = $this->request->post("num");
|
||||
$type = $this->request->post("type",1);//1=金额 2=数量
|
||||
$this->error(__("即将开放,请耐心等待!"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单记录
|
||||
*/
|
||||
public function order_list()
|
||||
{
|
||||
$user_id = $this->auth->id;
|
||||
$list = Db::name("app_market_order a")->field("a.id,a.num,a.price,a.addtime,b.symbol")
|
||||
->join("app_market_country b","a.country_id=b.id","left")
|
||||
->where("a.user_id",$user_id)
|
||||
->order("a.id desc")
|
||||
->paginate(20,false,['query' => request()->param()]);
|
||||
foreach ($list as $key => $value) {
|
||||
$value['addtime'] = date("Y-m-d H:i:s",$value['addtime']);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
$this->success("ok",$list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
public function get_token()
|
||||
{
|
||||
$data = [
|
||||
"username" => "TEST_MERCHANT",
|
||||
"password" => "123456",
|
||||
];
|
||||
$basic = base64_encode("TEST_MERCHANT:123456");
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://merchant-sandbox.qpay.mn/v2/auth/token',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Authorization: Basic '.$basic
|
||||
),
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$res = json_decode($response,true);
|
||||
if($res && isset($res['access_token'])){
|
||||
return $res;
|
||||
}else{
|
||||
var_dump($res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function test_pay()
|
||||
{
|
||||
$token = $this->get_token();
|
||||
$curl = curl_init();
|
||||
$data = array(
|
||||
"invoice_code" => "TEST_INVOICE",
|
||||
"sender_invoice_no" => "123456",
|
||||
"invoice_receiver_code" => "88614450",
|
||||
"invoice_description" => "test",
|
||||
"amount" => "50",
|
||||
"callback_url" => "http://aptadmin.acr336.xyz/api/notify/index",
|
||||
);
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://merchant-sandbox.qpay.mn/v2/invoice',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => json_encode($data),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer '.$token['access_token']
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$res = json_decode($response,true);
|
||||
var_dump($res);
|
||||
// echo $response;
|
||||
}
|
||||
|
||||
public function add_orders()
|
||||
{
|
||||
$token = $this->get_token();
|
||||
$curl = curl_init();
|
||||
$data = array(
|
||||
"invoice_code"=> "TEST_INVOICE",//qpay提供的发票代码
|
||||
"sender_invoice_no"=> "123456",// 组织创建的唯一发票编号
|
||||
"invoice_receiver_code"=> "88614450",//收到组织发票的客户的唯一编号
|
||||
"invoice_description"=> "Invoice description",//发票说明[产品描述]
|
||||
"lines"=> [
|
||||
[
|
||||
"line_description"=> "Invoice description",//描述
|
||||
"line_quantity"=> "1",//数量
|
||||
"line_unit_price"=> "50",//单价
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://merchant-sandbox.qpay.mn/v2/invoice',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => json_encode($data),
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer '.$token['access_token']
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$res = json_decode($response,true);
|
||||
var_dump($res);
|
||||
// echo $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user