Merge branch 'dev/dev_xp' into dev/dev
This commit is contained in:
@@ -18,9 +18,11 @@ public class AccountTask {
|
||||
|
||||
/**
|
||||
* 每周日晚上刷新 年付用户、月付用户的积分
|
||||
* 替换为
|
||||
* 每个月月初只刷新年付用户的积分
|
||||
*/
|
||||
// @Scheduled(cron = "59 59 23 ? * SUN")
|
||||
// @Scheduled(cron = "59 59 23 * * ?")
|
||||
@Scheduled(cron = "0 0 0 1 * ?")
|
||||
public void refreshCreditsMonthly() {
|
||||
log.info("每周日晚11:59:59刷新付费用户积分为 6000");
|
||||
accountService.refreshCreditsWeekly();
|
||||
|
||||
@@ -235,7 +235,7 @@ public class AccountController {
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "verifyUserEmail")
|
||||
/*@ApiOperation(value = "verifyUserEmail")
|
||||
@GetMapping("/verifyUserEmail")
|
||||
public Response<String> verifyUserEmail(@RequestParam("verifyCode") String verifyCode){
|
||||
accountService.verifyUserEmail(verifyCode);
|
||||
@@ -254,7 +254,7 @@ public class AccountController {
|
||||
public Response<String> activateNewEmail(@RequestParam("token") String token){
|
||||
accountService.activateNewEmail(token);
|
||||
return Response.success("success");
|
||||
}
|
||||
}*/
|
||||
|
||||
@PostMapping("halfPricePromotion")
|
||||
@ApiOperation(value = "十月半价活动")
|
||||
|
||||
@@ -112,4 +112,10 @@ public class StripeController {
|
||||
return Response.success(stripeService.detachCustomerAllPaymentMethod(name, email));
|
||||
}
|
||||
|
||||
@ApiOperation("临时 获取ip")
|
||||
@GetMapping("/getIp2")
|
||||
public Response<String> getIp2(HttpServletRequest request) {
|
||||
return Response.success(stripeService.getIp2(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TagsController {
|
||||
|
||||
@ApiOperation("获取标签")
|
||||
@GetMapping("/getTags")
|
||||
public Response<List<Tags>> getTags(@RequestParam("userInput") String userInput) {
|
||||
public Response<List<Tags>> getTags(@RequestParam(value = "userInput", required = false) String userInput) {
|
||||
return Response.success(tagsService.getTags(userInput));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,11 @@ public class Account implements Serializable {
|
||||
*/
|
||||
private String country;
|
||||
|
||||
/**
|
||||
* 职业
|
||||
*/
|
||||
private String occupation;
|
||||
|
||||
/**
|
||||
* 账户有效期开始时间
|
||||
*/
|
||||
|
||||
@@ -10,4 +10,7 @@ import lombok.EqualsAndHashCode;
|
||||
public class Tags extends BaseEntity{
|
||||
|
||||
private String tagName;
|
||||
|
||||
// 表示标签是否正在活动中 0->不在活动中 1->在活动中
|
||||
private byte active = (byte)0;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package com.ai.da.model.vo;
|
||||
import com.ai.da.mapper.primary.entity.AccountExtend;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -68,4 +67,10 @@ public class AccountLoginVO {
|
||||
// 是否是affiliate
|
||||
private boolean isAffiliate = false;
|
||||
|
||||
private String country;
|
||||
|
||||
private String occupation;
|
||||
|
||||
private Map<String, Long> usernameModify;
|
||||
|
||||
}
|
||||
|
||||
@@ -177,11 +177,11 @@ public interface AccountService extends IService<Account> {
|
||||
|
||||
void editUserName(String newUserName);
|
||||
|
||||
void verifyUserEmail(String verifyCode);
|
||||
/*void verifyUserEmail(String verifyCode);
|
||||
|
||||
void changeUserEmail(String newMailbox);
|
||||
|
||||
void activateNewEmail(String token);
|
||||
void activateNewEmail(String token);*/
|
||||
|
||||
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||
|
||||
|
||||
@@ -47,4 +47,6 @@ public interface StripeService {
|
||||
List<Map<String,String>> getCustomerPaymentMethod(String name, String email);
|
||||
|
||||
String detachCustomerAllPaymentMethod(String name, String email);
|
||||
|
||||
String getIp2(HttpServletRequest request);
|
||||
}
|
||||
|
||||
@@ -1622,7 +1622,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// 刷新账号有效期截止之前的年付用户的积分
|
||||
long epochMilli = Instant.now().toEpochMilli();
|
||||
accountUpdateWrapper.lambda().set(Account::getCredits, CreditsEventsEnum.INIT_WEEKLY.getValue())
|
||||
.eq(Account::getSystemUser,1).or().eq(Account::getSystemUser,2)
|
||||
.eq(Account::getSystemUser,1)
|
||||
// .or().eq(Account::getSystemUser,2)
|
||||
.gt(Account::getValidEndTime, epochMilli);
|
||||
baseMapper.update(null,accountUpdateWrapper);
|
||||
}
|
||||
@@ -1863,7 +1864,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
}
|
||||
|
||||
// 验证是否是本人进行邮箱绑定更改
|
||||
/*// 验证是否是本人进行邮箱绑定更改
|
||||
public void verifyUserEmail(String verifyCode){
|
||||
// 向旧邮箱发送验证码,以保证是当前邮箱拥有者在进行更改
|
||||
String userEmail = baseMapper.selectById(UserContext.getUserHolder().getId()).getUserEmail();
|
||||
@@ -1896,7 +1897,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
// 验证激活链接
|
||||
public void activateNewEmail(String token){
|
||||
// 获取链接地址信息,更新指定用户邮箱
|
||||
|
||||
String emailAndId = jwtTokenHelper.parseToEmailAndId(token);
|
||||
String newMailbox = emailAndId.substring(0, emailAndId.lastIndexOf("_"));
|
||||
String accountId = emailAndId.substring(emailAndId.lastIndexOf("_") + 1);
|
||||
@@ -1918,7 +1918,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
account.setId(Long.parseLong(accountId));
|
||||
baseMapper.updateById(account);
|
||||
log.info("邮箱绑定更改完成,用户id:{},新邮箱:{}", accountId, newMailbox);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String googleCallback(String code, HttpSession session) {
|
||||
@@ -2463,6 +2463,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
if (!Objects.isNull(affiliate) && affiliate.getStatus().equals("Active")) {
|
||||
response.setAffiliate(true);
|
||||
}
|
||||
|
||||
response.setUsernameModify(getNicknameModifyTimes());
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -2504,7 +2506,6 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
accountExtendInsert.setHeadImgUrl(pictureUrl);
|
||||
accountExtendInsert.setName(name);
|
||||
|
||||
|
||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||
accountExtendInsert.setAccountId(authPrincipalVo.getId());
|
||||
accountExtendMapper.insert(accountExtendInsert);
|
||||
|
||||
@@ -592,7 +592,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// 2、判断用户当前积分是否够本次生成消耗
|
||||
Boolean preDeduction = creditsService.creditsPreDeduction(creditsEventsEnum, 1);
|
||||
if (!preDeduction) {
|
||||
throw new BusinessException("remaining.credits.insufficient");
|
||||
throw new BusinessException("remaining.credits.insufficient", ResultEnum.WARNING.getCode());
|
||||
}
|
||||
|
||||
// 3、生成唯一id 使用uuid,由于uuid重复的几率很小,故取消对uuid重复性的校验
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.*;
|
||||
import com.ai.da.common.utils.DateUtil;
|
||||
import com.ai.da.common.utils.RequestInfoUtil;
|
||||
import com.ai.da.common.utils.SendEmailUtil;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.PaymentInfoMapper;
|
||||
@@ -17,6 +18,7 @@ import com.ai.da.model.dto.ProductPurchaseDTO;
|
||||
import com.ai.da.model.dto.SubscriptionEmailParamsDTO;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.gson.Gson;
|
||||
@@ -36,8 +38,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -1145,5 +1151,96 @@ public class StripeServiceImpl implements StripeService {
|
||||
}
|
||||
}
|
||||
|
||||
public String getIp2(HttpServletRequest request) {
|
||||
/*String ip = request.getHeader("X-Forwarded-For");
|
||||
String ipAddress = "";
|
||||
if(StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)){
|
||||
//多次反向代理后会有多个ip值,第一个ip才是真实ip
|
||||
int index = ip.indexOf(",");
|
||||
if(index != -1){
|
||||
ipAddress = ip.substring(0,index);
|
||||
}else{
|
||||
ipAddress = ip;
|
||||
}
|
||||
}
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
if(StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)){
|
||||
ipAddress = ip;
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(ipAddress)) {
|
||||
getIPLocation(ipAddress);
|
||||
}*/
|
||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||
if (!StringUtil.isNullOrEmpty(ipAddress)) {
|
||||
return getIPLocation(ipAddress);
|
||||
}
|
||||
|
||||
return request.getRemoteAddr();
|
||||
}
|
||||
|
||||
/* 免费 API 服务可能有请求频率限制,如果你需要处理大量 IP 地址,可能需要考虑使用付费服务或购买 IP 地理位置数据库。此外,始终要遵守 API 提供商的使用条款和隐私政策。*/
|
||||
|
||||
public String getIPLocation(String ip) {
|
||||
// String ip = "117.143.125.1"; // 替换为你想查询的 IP 地址
|
||||
// String ip = "194.5.48.180"; // 替换为你想查询的 IP 地址
|
||||
String apiURL = "http://ip-api.com/json/" + ip;
|
||||
|
||||
try {
|
||||
URL url = new URL(apiURL);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
|
||||
if (conn.getResponseCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
|
||||
}
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String output;
|
||||
StringBuilder outputBuilder = new StringBuilder();
|
||||
System.out.println("Output from Server .... \n");
|
||||
while ((output = br.readLine()) != null) {
|
||||
outputBuilder.append(output);
|
||||
System.out.println(output);
|
||||
}
|
||||
conn.disconnect();
|
||||
Map map = JSONObject.parseObject(outputBuilder.toString(), Map.class);
|
||||
log.info("map: {}", map);
|
||||
return JSON.toJSONString(map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String ip = "117.143.125.1"; // 替换为你想查询的 IP 地址
|
||||
// String ip = "194.5.48.180"; // 替换为你想查询的 IP 地址
|
||||
String apiURL = "http://ip-api.com/json/" + ip;
|
||||
|
||||
try {
|
||||
URL url = new URL(apiURL);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept", "application/json");
|
||||
|
||||
if (conn.getResponseCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
|
||||
}
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String output;
|
||||
System.out.println("Output from Server .... \n");
|
||||
StringBuilder outputBuilder = new StringBuilder();
|
||||
while ((output = br.readLine()) != null) {
|
||||
outputBuilder.append(output);
|
||||
System.out.println(output);
|
||||
}
|
||||
conn.disconnect();
|
||||
Map map = JSONObject.parseObject(outputBuilder.toString(), Map.class);
|
||||
log.info("map: {}", map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.ai.da.mapper.primary.entity.Tags;
|
||||
import com.ai.da.service.TagsService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -19,7 +20,10 @@ public class TagsServiceImpl extends ServiceImpl<TagsMapper, Tags> implements Ta
|
||||
public List<Tags> getTags(String tagPrefix){
|
||||
// 1、根据tag前缀,查询
|
||||
QueryWrapper<Tags> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.likeRight("tag_name", tagPrefix);
|
||||
if (!StringUtil.isNullOrEmpty(tagPrefix)) {
|
||||
queryWrapper.like("tag_name", tagPrefix);
|
||||
}
|
||||
queryWrapper.orderByDesc("id").last("limit 10");
|
||||
|
||||
// 需返回标签内容和id
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
|
||||
Reference in New Issue
Block a user