webman/app/controller/api/CommonController.php

98 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2025-02-16 00:28:13 +08:00
<?php
namespace app\controller\api;
use support\Request;
use App\Utils\ApiResponseApp;
use App\model\Dictionary;
2025-02-23 17:22:44 +08:00
use App\model\Message;
2025-02-17 09:39:17 +08:00
use App\model\ExchangeRate;
2025-02-16 00:28:13 +08:00
use hg\apidoc\annotation as Apidoc;
use support\Db;
/**
* @Apidoc\Title("公共控制器?")
*/
class CommonController
{
protected $noNeedLogin = ['config', 'get_project', 'get_projectdetailed', 'get_mechanism_list'];
/**
* @Apidoc\Title("1.0 获取全局配置")
* @Apidoc\Url("api/common/config")
* @Apidoc\Method("POST")
*/
public function config(Request $request)
{
$Dictionary=Dictionary::all();
$res=[];
2025-02-17 09:39:17 +08:00
$ExchangeRate = ExchangeRate::all();
2025-02-16 00:28:13 +08:00
$res = [
"account_notice" => "Log in to link account and get 300 to 3,000 random points a day",
2025-02-17 09:39:17 +08:00
// "vi_rate" => "2.49",
// "trx_rate" => "0.00",
// "nrly_rate" => "30",
// "trx_rate1" => "",
// "inr_rate" => "1.62",
// "php_rate" => null,
// "brl_rate" => "0.10",
2025-02-16 00:28:13 +08:00
"brl_fee" => "300",
"pkr_fee" => "300",
2025-02-17 09:39:17 +08:00
// "pkr_rate" => "5",
2025-02-16 00:28:13 +08:00
"pkr_min" => "2000",
"brl_min" => "5000"
];
2025-02-17 09:39:17 +08:00
foreach ($ExchangeRate as $item) {
$res[strtolower($item['type']) . '_rate'] = $item['points'];
}
2025-02-16 00:28:13 +08:00
$col=['service_1','service_2','service_3','service_url','service_user_url','points'];
foreach($Dictionary as $key=>$value){
$res[$value->key]=$value->value;
}
return ApiResponseApp::success($res);
}
/**
* @Apidoc\Title("1.0 消息根据type 判断类型")
* @Apidoc\Url("api/common/messageList")
* 3是首页弹窗 1是消息中心
2025-02-16 00:28:13 +08:00
* @Apidoc\Method("POST")
*/
public function messageList(Request $request){
2025-02-23 17:22:44 +08:00
$type = $request->get('type');
$query = Message::query();
2025-02-16 00:28:13 +08:00
2025-02-23 17:22:44 +08:00
if ($type == 5) {
// 大于 type注意这里假设你想比较的是 'id' 字段)
$query->where('id', '>', $type);
2025-02-16 00:28:13 +08:00
}
2025-02-23 17:22:44 +08:00
if ($type == 3) {
// 小于 type同样假设是 'id' 字段)
$query->where('id', '<', $type);
}
if ($type == 1) {
// 等于特定值这里是6
$query->where('id', '=', 6);
}
// 执行查询并获取结果
$list = $query->get();
var_dump(1111);
// 准备返回的数据
$map = [
'data' => $list->toArray(),
];
return ApiResponseApp::success($map);
2025-02-16 00:28:13 +08:00
}
}