新增短效无限量白名单接口功能

This commit is contained in:
2025-10-18 20:18:42 +08:00
parent 79641f01ee
commit aea1718fd0
3 changed files with 293 additions and 98 deletions

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'];