Compare commits

...

7 Commits

Author SHA1 Message Date
“wanyongkang”
c80725bb4a 代理商下用户注册检验是否存在 2026-04-13 12:45:13 +08:00
“wanyongkang”
2efa163483 客户通过代理商api注册 2026-04-11 13:28:24 +08:00
“wanyongkang”
abb3584262 添加代理商注册用户接口 2026-04-08 15:35:17 +08:00
5a1d44095c 金柚所有未过期账号都不允许重复 2026-02-12 16:49:58 +08:00
2649b20dae 修复订单接口请求格式问题 2025-10-21 14:12:28 +08:00
aea1718fd0 新增短效无限量白名单接口功能 2025-10-18 20:22:24 +08:00
79641f01ee 新增本地开发环境配置 2025-10-18 11:32:27 +08:00
10 changed files with 540 additions and 123 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

@@ -71,11 +71,19 @@ class Index
$user_model = new UserModel(); $user_model = new UserModel();
$is_exit = $user_model->getOne(['Phone' => $phone]); $is_exit = $user_model->getOne(['Phone' => $phone]);
if($is_exit) { if($is_exit) {
$return_data = [ if ($is_exit['is_verify'] == 0) {
'code' => 0, $data_user_old = [
'msg' => '用户已经存在' 'LoginCode' => $is_exit['LoginCode'].'-del',
'Phone' => $is_exit['Phone'].'-del',
]; ];
echo json_encode($return_data);die;
$user_model->updateOne(['Id'=>$is_exit['Id']],$data_user_old);
}
// $return_data = [
// 'code' => 0,
// 'msg' => '用户已经存在'
// ];
// echo json_encode($return_data);die;
} }
@@ -206,6 +214,105 @@ class Index
die; die;
} }
//推广用户注册
public function apiregister()
{
$data = $_GET;
// dump($data);die;
unset($data['s']);
$data['LoginCode'] = trim($data['LoginCode']);
if(empty($data['LoginCode'])){
$info = [
'Code' => 10003,
'Data' => '',
'Message' => '账号为空',
];
echo json_encode($info);
die;
}
//----
if(empty($data['agent_id'])){
$info = [
'Code' => 10003,
'Data' => '',
'Message' => '代理id错误',
];
echo json_encode($info);
die;
}
$data['agent_id'] = base64_decode($data['agent_id']);
if ($data['agent_id']<10000) {
$info = [
'Code' => 10003,
'Data' => '',
'Message' => '代理id错误',
];
echo json_encode($info);
die;
}
// dump($data);die;
$data['Phone'] = $data['LoginCode'];
$data['TenantId'] = 0;
$data['Enabled'] = 1;
$data['UpdateTime'] = date('Y-m-d H:i:s',time());
$data['CreateTime'] = date('Y-m-d H:i:s',time());
$data['CreateType'] = 4;
$data['ProductAccountCount'] = 0;
$data['ExpiredProductAccountCount'] = 0;
$data['RestAmount'] = 0;
$data['ConsumeAmount'] = 0;
$data['DeleteTag'] = 0;
$data['UseTestCount'] = 0;
$data['Sex'] = 0;
$data['Wx'] = '';
$data['QQ'] = '';
$data['LastLoginDate'] = date('Y-m-d H:i:s',time());
$data['Password'] = empty($data['Password'])?cToMd5('123568'):cToMd5(trim($data['Password']));
$user_model = new UserModel;
$data['ManagerId'] = 0;
$has_user = $user_model->isExit("LoginCode='".$data['LoginCode']."' or Phone='".$data['Phone']."' or TaoBao='".$data['Phone']."'");
if ($has_user){
if ($has_user['is_verify'] == 0) {
$data_user_old = [
'LoginCode' => $has_user['LoginCode'].'-del',
'Phone' => $has_user['Phone'].'-del',
];
$user_model->updateOne(['Id'=>$has_user['Id']],$data_user_old);
} else {
$info = [
'Code' => 20000,
'Data' => '',
'Message' => '该账号或者手机号被注册了',
];
echo json_encode($info);
die;
}
}
if ($user_model->add($data)) {
$info = [
'Code' => 10000,
'Data' => '',
'Message' => '该账号注册成功!',
];
echo json_encode($info);
die;
}
die;
}
private function getCred(){ private function getCred(){
$ak = "JDC_A3B38E573D7404F976472FB42F52"; $ak = "JDC_A3B38E573D7404F976472FB42F52";
$sk = "C9BAE98F49B42DA2DC02868A75AA3AD8"; $sk = "C9BAE98F49B42DA2DC02868A75AA3AD8";

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,22 @@ 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 = [
'sgUserId' => $request_data['sgUserId'],
'packId' => $request_data['packId'],
'packType' => $request_data['packType'],
'periodType' => $request_data['periodType'],
'periodAmount' => $request_data['periodAmount'],
];
}
$request_data = formatHttpRequert($request_data);
$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 +419,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 +443,7 @@ class Order extends Controller
} }
} else { } else {
$info = [ $info = [
'code'=>-1, 'code'=>-6,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '请求后台失败,请联系客服!' 'msg' => '请求后台失败,请联系客服!'
]; ];
@@ -402,7 +452,7 @@ class Order extends Controller
} }
} else { } else {
$info = [ $info = [
'code'=>-1, 'code'=>-5,
'data' => '非法参数', 'data' => '非法参数',
'msg' => '聚币不足!' 'msg' => '聚币不足!'
]; ];
@@ -411,7 +461,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'];

View File

@@ -10,6 +10,7 @@ use app\jinyou\model\Package as PackageModel;
use app\jinyou\model\PriceScheme as SchemeModel; use app\jinyou\model\PriceScheme as SchemeModel;
use app\jinyou\model\UserPrice as UserPriceModel; use app\jinyou\model\UserPrice as UserPriceModel;
use app\jinyou\model\ProductOrder as ProductOrderModel; use app\jinyou\model\ProductOrder as ProductOrderModel;
use app\jinyou\model\ProductAccount as ProductAccountModel;
use enum\order\ProductOrder as OrderEnum; use enum\order\ProductOrder as OrderEnum;
use app\user\model\UserScore as UserScore; use app\user\model\UserScore as UserScore;
use app\jinyou\model\Account as AccountModel; use app\jinyou\model\Account as AccountModel;
@@ -74,11 +75,11 @@ class Jinyoujt extends Controller
$user_model = new UserModel; $user_model = new UserModel;
$jinyoujingtai = new Jinyoujingtai; $jinyoujingtai = new Jinyoujingtai;
$package_model = new PackageModel; $package_model = new PackageModel;
$product_account = new ProductAccountModel;
$user_update_info = []; $user_update_info = [];
$user_info = $user_model->getOne(['Id' => $this->userinfo['UserId']]); $user_info = $user_model->getOne(['Id' => $this->userinfo['UserId']]);
//套餐详情 //套餐详情
$package_info = $package_model->getOne(['Id' => $request_data['package_id']]); $package_info = $package_model->getOne(['Id' => $request_data['package_id']]);
@@ -117,6 +118,20 @@ class Jinyoujt extends Controller
} }
//判断账号是否存在 //判断账号是否存在
$timezone = new \DateTimeZone('Asia/Shanghai');
$datetime = new \DateTime('now', $timezone); // 确保是东八区时间
$account_result = $product_account->getCount([
'ProductId' => $package_info['ProductId'],
'Account' => $request_data['account'],
'EndTime' => ['>',$datetime->format('Y-m-d H:i:s')]
]);
if($account_result['count'] > 0){
$return_data['code'] = -1;
$return_data['msg'] = "账号已经存在!";
echo json_encode($return_data);
die;
}
$exist = $jinyoujingtai::checkVpnAccountExists($request_data['account'],$request_data['type']); $exist = $jinyoujingtai::checkVpnAccountExists($request_data['account'],$request_data['type']);
if($exist->code != 200){ if($exist->code != 200){
$return_data['code'] = -1; $return_data['code'] = -1;

View File

@@ -0,0 +1,10 @@
<?php
namespace app\jinyou\model;
use fastphp\base\Model;
class ProductAccount extends Model
{
protected $table = "product_account";
}

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;
}
}
}