修正查看特权
This commit is contained in:
@@ -102,7 +102,7 @@ public class HxrAdminUserService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取用户列表,{@code data} 解析为 {@link LbUser}(与 lb_user 字段对应)。
|
||||
* 分页拉取用户列表,{@code data} 解析为 {@link }(与 lb_user 字段对应)。
|
||||
*
|
||||
* @param page 页码,从 1 开始
|
||||
*/
|
||||
@@ -225,13 +225,25 @@ public class HxrAdminUserService {
|
||||
* @return 接口 {@code code==0} 时为 true
|
||||
*/
|
||||
public boolean updateUserVipFields(long userId, int maxOrder, String viptimeFormatted) throws Exception {
|
||||
return updateUserVipFields(userId, maxOrder, viptimeFormatted, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户 VIP 相关字段({@code application/x-www-form-urlencoded})。
|
||||
*
|
||||
* @param maxOrder 为 null 时不传 max_order,第三方保持原值
|
||||
* @param isVip 1 开通特权,0 关闭特权
|
||||
* @return 接口 {@code code==0} 时为 true
|
||||
*/
|
||||
public boolean updateUserVipFields(long userId, Integer maxOrder, String viptimeFormatted, int isVip)
|
||||
throws Exception {
|
||||
String cookieHeader = properties.resolveCookieHeader();
|
||||
if (cookieHeader == null || cookieHeader.isBlank()) {
|
||||
log.warn("hxr.admin 未配置 cookie 或 phpsid,跳过 user/update");
|
||||
return false;
|
||||
}
|
||||
|
||||
String form = buildUpdateFormBody(userId, maxOrder, viptimeFormatted);
|
||||
String form = buildUpdateFormBody(userId, maxOrder, viptimeFormatted, isVip);
|
||||
|
||||
HttpClient client = HttpClient.newBuilder()
|
||||
.connectTimeout(java.time.Duration.ofSeconds(35))
|
||||
@@ -275,13 +287,19 @@ public class HxrAdminUserService {
|
||||
return t.format(VIP_TIME_FORMAT);
|
||||
}
|
||||
|
||||
private static String buildUpdateFormBody(long userId, int maxOrder, String viptimeFormatted) {
|
||||
return "id=" + userId
|
||||
+ "&max_order=" + maxOrder
|
||||
+ "&is_vip=1"
|
||||
+ "&is_resell=1"
|
||||
+ "&status=1"
|
||||
+ "&viptime=" + URLEncoder.encode(viptimeFormatted, StandardCharsets.UTF_8);
|
||||
private static String buildUpdateFormBody(long userId, Integer maxOrder, String viptimeFormatted, int isVip) {
|
||||
int vipFlag = isVip == 1 ? 1 : 0;
|
||||
String viptime = viptimeFormatted != null ? viptimeFormatted : "";
|
||||
StringBuilder form = new StringBuilder();
|
||||
form.append("id=").append(userId);
|
||||
if (maxOrder != null) {
|
||||
form.append("&max_order=").append(maxOrder);
|
||||
}
|
||||
form.append("&is_vip=").append(vipFlag)
|
||||
.append("&is_resell=1")
|
||||
.append("&status=1")
|
||||
.append("&viptime=").append(URLEncoder.encode(viptime, StandardCharsets.UTF_8));
|
||||
return form.toString();
|
||||
}
|
||||
|
||||
private static String abbreviate(String s, int maxLen) {
|
||||
|
||||
Reference in New Issue
Block a user