Compare commits

...

2 Commits

Author SHA1 Message Date
aea1718fd0 新增短效无限量白名单接口功能 2025-10-18 20:22:24 +08:00
79641f01ee 新增本地开发环境配置 2025-10-18 11:32:27 +08:00
7 changed files with 383 additions and 99 deletions

4
.gitignore vendored
View File

@@ -1 +1,5 @@
*.csv *.csv
.idea/
.vscode/
.volumes/

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM php:7.3-fpm-alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN docker-php-ext-install pdo_mysql mysqli

View File

@@ -308,7 +308,48 @@ class Order extends Controller
switch ($data['order_type']) { switch ($data['order_type']) {
case 2: case 2:
$data['money'] = round($data['data']['periodAmount'] * $price['price'],2); $peroid = $data['data']['periodAmount'];
$whitelist = 0;
if (isset($data['renew'])) {
$url = $this->url_root . '/user/short/unlimited/whitelist/maxAmount';
$req = formatHttpRequert([
'sgUserId' => $this->http_user_info['sgUserId'],
]);
$resp = json_decode(linkcurl($url, 'POST', $req, [], 0));
if ($resp->s < 0) {
return [
'code'=>-1,
'data' => $resp,
'msg' => '请求后台失败,请联系客服!'
];
}
$whitelist = $resp->d->maxAmount;
}
else {
if (!isset($data['data']['maxWhitelist'])) {
return [
'code'=>-2,
'data' => '',
'msg' => '请求后台失败,请联系客服!'
];
}
$whitelist = $data['data']['maxWhitelist'];
}
if ($whitelist == 0) {
return [
'code'=>-3,
'data' => '',
'msg' => '请求后台失败,请联系客服!'
];
}
$discount = max(.6, 1 - .1 * ($whitelist -1)); // 每多一个白名单配额就减 1 折,最低 6 折
$data['money'] = round($price['price'] * $peroid * $whitelist * $discount, 2);
break; break;
case 3: case 3:
$data['money'] = round(($data['data']['periodAmount'] * $price['price'] * $data['data']['ipAmount']),2); $data['money'] = round(($data['data']['periodAmount'] * $price['price'] * $data['data']['ipAmount']),2);
@@ -342,13 +383,21 @@ class Order extends Controller
if ($order_model->add($order_data)) { if ($order_model->add($order_data)) {
$url = $http_url; $url = $http_url;
$request_data = formatHttpRequert($request_data); if ($url == $this->url_root . '/user/pack/renew') {
$request_data = formatHttpRequert([
'sgUserId' => $request_data['sgUserId'],
'packId' => $request_data['packId'],
'packType' => $request_data['packType'],
'periodType' => $request_data['periodType'],
'periodAmount' => $request_data['periodAmount'],
]);
}
$http_data = json_decode(linkcurl($url,'POST',$request_data,[],0)); $http_data = json_decode(linkcurl($url,'POST',$request_data,[],0));
if ($http_data->s < 0) { if ($http_data->s < 0) {
$info = [ $info = [
'code'=>-1, 'code'=>-7,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '请求后台失败,请联系客服!' 'msg' => '请求后台失败,请联系客服!'
]; ];
@@ -369,7 +418,7 @@ class Order extends Controller
if ($http_order_data->s < 0) { if ($http_order_data->s < 0) {
$info = [ $info = [
'code'=>-1, 'code'=>-8,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '请求后台失败,请联系客服!' 'msg' => '请求后台失败,请联系客服!'
]; ];
@@ -393,7 +442,7 @@ class Order extends Controller
} }
} else { } else {
$info = [ $info = [
'code'=>-1, 'code'=>-6,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '请求后台失败,请联系客服!' 'msg' => '请求后台失败,请联系客服!'
]; ];
@@ -402,7 +451,7 @@ class Order extends Controller
} }
} else { } else {
$info = [ $info = [
'code'=>-1, 'code'=>-5,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '聚币不足!' 'msg' => '聚币不足!'
]; ];
@@ -411,7 +460,7 @@ class Order extends Controller
} else { } else {
$info = [ $info = [
'code'=>-1, 'code'=>-4,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '聚币不足!' 'msg' => '聚币不足!'
]; ];

View File

@@ -8,15 +8,13 @@ use app\http\model\Order as OrderModel;
use enum\http\Order as HttpOrderEnum; use enum\http\Order as HttpOrderEnum;
use app\http\model\Recharge as RechargeModel; use app\http\model\Recharge as RechargeModel;
class User extends Controller class User extends Controller {
{
// private $url_root = 'https://sandbox.sgxz.cn'; // private $url_root = 'https://sandbox.sgxz.cn';
private $url_root = 'https://merchant.sgxz.cn'; private $url_root = 'https://merchant.sgxz.cn';
private $http_user_info = []; private $http_user_info = [];
public function __construct() public function __construct() {
{
parent::__construct('', ''); parent::__construct('', '');
if (empty($this->userinfo['UserId'])) { if (empty($this->userinfo['UserId'])) {
die; die;
@@ -107,7 +105,6 @@ class User extends Controller
]; ];
echo json_encode($return_data); echo json_encode($return_data);
} }
//短效全部套餐 //短效全部套餐
@@ -152,7 +149,6 @@ class User extends Controller
]; ];
echo json_encode($return_data); echo json_encode($return_data);
} }
//用户短效每日使用情况查询 //用户短效每日使用情况查询
public function dx_used_log() { public function dx_used_log() {
@@ -182,7 +178,6 @@ class User extends Controller
]; ];
echo json_encode($return_data); echo json_encode($return_data);
} }
//长效ip列表 //长效ip列表
@@ -253,7 +248,6 @@ class User extends Controller
]; ];
echo json_encode($return_data); echo json_encode($return_data);
} }
//长效全部订单 //长效全部订单
@@ -417,5 +411,156 @@ class User extends Controller
echo (linkcurl($url, 'GET', $request_data, [], 0)); echo (linkcurl($url, 'GET', $request_data, [], 0));
} }
// 短效无限量白名单列表
public function white_list_su() {
$list = [];
$request_data = [
'sgUserId' => $this->http_user_info['sgUserId'],
];
$url = $this->url_root . '/user/short/unlimited/whitelist';
$request_data = formatHttpRequert($request_data);
$data = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
if ($data->s < 0) {
echo json_encode([
'code' => 0,
'msg' => $data->m,
]);
return;
}
$list = $data->d->items;
foreach ($list as &$info) {
$info->isLocked = $info->isLocked ? '已锁定' : '未锁定';
}
$return_data = [
'code' => 1,
'data' => $list,
'msg' => '',
];
echo json_encode($return_data);
}
// 短效无限量白名单创建
public function create_white_ip_su() {
$request_data = json_decode(file_get_contents("php://input"), true)['data'];
$request_data['sgUserId'] = $this->http_user_info['sgUserId'];
$url = $this->url_root . '/user/short/unlimited/whitelist/create';
$request_data = formatHttpRequert($request_data);
$data = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
$return_data = [
'code' => 1,
'msg' => '',
];
echo json_encode($return_data);
}
// 短效无限量白名单删除
public function delete_ip_su() {
$request_data = json_decode(file_get_contents("php://input"), true)['data'];
$request_data['sgUserId'] = $this->http_user_info['sgUserId'];
$url = $this->url_root . '/user/short/unlimited/whitelist/delete';
$request_data = formatHttpRequert($request_data);
$data = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
$return_data = [
'code' => 1,
'msg' => '',
];
echo json_encode($return_data);
}
// 短效无限量白名单切换锁定
public function lock_ip_su() {
$request_data = json_decode(file_get_contents("php://input"), true)['data'];
$request_data['sgUserId'] = $this->http_user_info['sgUserId'];
$url = $this->url_root . '/user/short/unlimited/whitelist/lock';
$request_data = formatHttpRequert($request_data);
$data = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
$return_data = [
'code' => 1,
'msg' => '',
];
echo json_encode($return_data);
}
// 短效无限量白名单查询上限
public function white_limit_get_su() {
$request_data = [
'sgUserId' => $this->http_user_info['sgUserId'],
];
$url = $this->url_root . '/user/short/unlimited/whitelist/maxAmount';
$request_data = formatHttpRequert($request_data);
$data = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
echo json_encode([
'code' => 1,
'data' => $data->d->maxAmount,
'msg' => '',
]);
}
// 短效无限量白名单修改上限
public function white_limit_set_su() {
$request_data = json_decode(file_get_contents("php://input"), true)['data'];
$request_data['sgUserId'] = $this->http_user_info['sgUserId'];
$url = $this->url_root . '/user/short/unlimited/whitelist/edit/maxAmount';
$request_data = formatHttpRequert($request_data);
$resp = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
if ($resp->s < 0) {
echo json_encode([
'code' => -1,
'msg' => $resp->m,
]);
return;
}
echo json_encode([
'code' => 1,
'data' => $resp,
'msg' => '',
]);
}
// 用户短效当前可用的无限量套餐详情
public function get_unlimited_available() {
$url = $this->url_root . '/user/short/pack/unlimited/available';
$request_data = formatHttpRequert([
'sgUserId' => $this->http_user_info['sgUserId'],
]);
$resp = json_decode(linkcurl($url, 'POST', $request_data, [], 0));
if ($resp->s < 0) {
echo json_encode([
'code' => -1,
'msg' => $resp->m,
]);
return;
}
echo json_encode([
'code' => 1,
'data' => $resp->d,
]);
}
} }

View File

@@ -39,6 +39,7 @@ class Package extends Model
$where = $data['data']; $where = $data['data'];
$where['package_type'] = HttpOrderEnum::$dxwxl; $where['package_type'] = HttpOrderEnum::$dxwxl;
$where['periodAmount'] = 1; $where['periodAmount'] = 1;
unset($where['maxWhitelist']);
break; break;
case 3: case 3:
$where = $data['data']; $where = $data['data'];

49
docker-compose.yaml Normal file
View File

@@ -0,0 +1,49 @@
name: juipphp
services:
mysql:
image: mysql:8.0.21
environment:
MYSQL_ROOT_PASSWORD: 123456789
MYSQL_DATABASE: hualianyun
ports:
- "3306:3306"
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./.volumes/mysql:/var/lib/mysql
php:
build:
context: .
dockerfile: Dockerfile
volumes:
- ./alipay:/var/www/html/alipay
- ./app:/var/www/html/app
- ./config:/var/www/html/config
- ./enum:/var/www/html/enum
- ./extends:/var/www/html/extends
- ./fastphp:/var/www/html/fastphp
- ./script:/var/www/html/script
- ./vendor:/var/www/html/vendor
- ./.htaccess:/var/www/html/.htaccess
- ./index.php:/var/www/html/index.php
depends_on:
- mysql
nginx:
image: nginx:alpine
volumes:
- ./nginx.conf:/etc/nginx/conf.d/app.conf
- ./alipay:/var/www/html/alipay
- ./app:/var/www/html/app
- ./config:/var/www/html/config
- ./enum:/var/www/html/enum
- ./extends:/var/www/html/extends
- ./fastphp:/var/www/html/fastphp
- ./script:/var/www/html/script
- ./vendor:/var/www/html/vendor
- ./.htaccess:/var/www/html/.htaccess
- ./index.php:/var/www/html/index.php
ports:
- 9000:9000

33
nginx.conf Normal file
View File

@@ -0,0 +1,33 @@
server {
listen 9000;
server_name _;
# CORS
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# pre-flight requests
if ($request_method = 'OPTIONS') {
return 204;
}
index index.php;
root /var/www/html;
location ~ \.php(.*)$ {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param PATH_INFO $1;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
}