|
|
@@ -8,9 +8,6 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.http.HttpRequest;
|
|
|
-import cn.hutool.http.HttpStatus;
|
|
|
-import cn.hutool.http.HttpUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
@@ -18,7 +15,6 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
-import com.cyksj.common.util.TicketCodeCommonUtil;
|
|
|
import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.distribute.DistributeGeneralSkuRateMapper;
|
|
|
@@ -36,8 +32,10 @@ import com.cyksj.service.chatgpt.ChatGptAccountService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAuthService;
|
|
|
import com.cyksj.service.claude.ClaudeService;
|
|
|
import com.cyksj.service.groups.GroupsFuncService;
|
|
|
+import com.cyksj.service.luma.LumaService;
|
|
|
import com.cyksj.service.mail.CuiQiuMailService;
|
|
|
import com.cyksj.service.mail.MailService;
|
|
|
+import com.cyksj.service.mail.YhMailService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
import com.cyksj.service.midjourney.MidjourneyAccountService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
@@ -58,7 +56,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
@@ -127,7 +128,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private final UpgradePackageMapper upgradePackageMapper;
|
|
|
|
|
|
- private final GoodsDonQaRelateMapper goodsDonQaRelateMapper;
|
|
|
+ private final LumaService lumaService;
|
|
|
|
|
|
private final GroupsRelationNetflixService groupsRelationNetflixService;
|
|
|
|
|
|
@@ -145,6 +146,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private final ClaudeService claudeService;
|
|
|
|
|
|
+ private final YhMailService yhMailService;
|
|
|
+
|
|
|
@Override
|
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account) {
|
|
|
User u = userMapper.selectById(userId);
|
|
|
@@ -317,6 +320,17 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
+ if (ticket.getGoodsId() == Constant.LUMA_GOODS_ID && ticket.getExpiryTime() != null) {
|
|
|
+ try {
|
|
|
+ List<UpgradePackage> upgradePackages = upgradePackageMapper.selectList(Wrappers.lambdaQuery(UpgradePackage.class).apply("JSON_CONTAINS(sku_ids,'\"" + ticket.getSkuId() + "\"')").eq(UpgradePackage::getStatus, Boolean.TRUE).eq(UpgradePackage::getDeleted, Boolean.TRUE));
|
|
|
+ if (CollectionUtil.isNotEmpty(upgradePackages)){
|
|
|
+ upgradePackages.stream().map(e -> e.getPrice().divide(BigDecimal.valueOf(e.getNum()), 2, RoundingMode.HALF_UP)).min(BigDecimal::compareTo).ifPresent(ticket::setLumaPackagePrice);
|
|
|
+ }
|
|
|
+ LumaUser lumaUser = lumaService.getLumaUser(userId, ticket.getRelationId());
|
|
|
+ ticket.setLumaUserNum(lumaUser.getNum());
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
List<GroupsRelationUserView> relationUserViews = groupsRelationMapper.getUserRelationUserViews(ticket.getGroupId(), ticket.getRelationId(), ticket.getUserId(), List.of(GroupsRelation.Status.validity, GroupsRelation.Status.outside));
|
|
|
ticket.setRelationViews(relationUserViews);
|
|
|
if (ticket.getExpiryTime() != null) {
|
|
|
@@ -558,35 +572,26 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
throw BusinessRuntimeException.getInstance("您的车票账号密码异常,请联系客服...");
|
|
|
}
|
|
|
if (cuiQiuMailService.isCuiQiuEmail(renewalView.getAccount())) {
|
|
|
- return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId(), type, sync, loginReq.getLinkType());
|
|
|
+ return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId(), type, loginReq.getLinkType());
|
|
|
}
|
|
|
- //获取邮箱密码
|
|
|
- SysEmail sysEmail = sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
|
|
|
- .eq(SysEmail::getEmail, account)
|
|
|
- .last("limit 1"));
|
|
|
- if (sysEmail == null) {
|
|
|
- log.info("获取账号:{}验证码异常,未配置对应系统邮箱", account);
|
|
|
- throw BusinessRuntimeException.getInstance("获取账号验证码异常,请联系客服...");
|
|
|
- }
|
|
|
- String url = "http://yinhelx.com/api/controller.php";
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
-
|
|
|
- params.put("imap_key", "imap_56568niua@@");
|
|
|
- params.put("fun", "imap_read");
|
|
|
- params.put("imap_ip", "yinhelx.com");
|
|
|
- params.put("port", "143");
|
|
|
- params.put("username", account);
|
|
|
- params.put("password", sysEmail.getPassword());
|
|
|
- params.put("mbox_id", "0");
|
|
|
- params.put("delete", "0");
|
|
|
-
|
|
|
- HttpRequest post = HttpUtil.createPost(url);
|
|
|
- post.form(params);
|
|
|
- cn.hutool.http.HttpResponse execute = post.execute();
|
|
|
- if (execute.getStatus() != HttpStatus.HTTP_OK) {
|
|
|
- throw BusinessRuntimeException.getInstance("获取验证码异常,请联系客服...");
|
|
|
- }
|
|
|
- String code = getDifferentGoodsCode(renewalView.getGoodsId(), execute.body(), type, sync, loginReq.getLinkType());
|
|
|
+ if (renewalView.getGoodsId() == 1l) {
|
|
|
+ Integer linkType = loginReq.getLinkType();
|
|
|
+ if (type == null && linkType == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统异常");
|
|
|
+ }
|
|
|
+ String key = RedisService.key.NF_UPGRAD_USER_LIMIT_KEY.getNameFormat(DateUtil.hour(DateTime.now(), true), linkType, renewalView.getUserId());
|
|
|
+ if (!redisService.hasKey(key)) {
|
|
|
+ redisService.set(key, 1l, RedisService.key.NF_UPGRAD_USER_LIMIT_KEY.getTimeout());
|
|
|
+ } else {
|
|
|
+ Integer value = (Integer) redisService.get(key);
|
|
|
+ if (value >= 5) {
|
|
|
+ throw BusinessRuntimeException.getInstance("获取失败,请联系客服");
|
|
|
+ }
|
|
|
+ redisService.incr(key, 1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //银河域名邮件
|
|
|
+ String code = yhMailService.getVerifyCode(account, renewalView.getGoodsId(), type, loginReq.getLinkType());
|
|
|
GroupsRelationLoginCodeRecord record = new GroupsRelationLoginCodeRecord();
|
|
|
record.setUserId(userId);
|
|
|
record.setRelationId(relationId);
|
|
|
@@ -787,64 +792,6 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return expiryTickets;
|
|
|
}
|
|
|
|
|
|
- public String getDifferentGoodsCode(Long goodsId, String body, Integer type, Boolean sync, Integer linkType) {
|
|
|
- String code = null;
|
|
|
- //奈飞
|
|
|
- if (goodsId == 1) {
|
|
|
- if (type != null && type == 1) {
|
|
|
- if (body.contains("輸入此代碼登入") || body.contains("输入此代码登录") || body.contains("Enter this code to sign in")) {
|
|
|
- code = StrUtil.subBetween(body, "輸入此代碼登入", "請在裝置上輸入上");
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- code = StrUtil.subAfter(body, "输入此代码登录", true);
|
|
|
- }
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- code = StrUtil.subAfter(body, "Enter this code to sign in", true);
|
|
|
- }
|
|
|
- }
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- throw BusinessRuntimeException.getInstance("查询失败,请检查是否发送了登陆码..");
|
|
|
- }
|
|
|
- } else {
|
|
|
- String urlPref;
|
|
|
- //更新装置
|
|
|
- if (linkType == 1) {
|
|
|
- urlPref = "https://www.netflix.com/account/update-primary-location";
|
|
|
- code = StrUtil.subBetween(body, "[" + urlPref, "]");
|
|
|
- } else {
|
|
|
- //验证链接
|
|
|
- urlPref = "https://www.netflix.com/account/travel/verify";
|
|
|
- code = StrUtil.subBetween(body, "[" + urlPref, "]");
|
|
|
- }
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- throw BusinessRuntimeException.getInstance("获取认证链接失败,请重新获取");
|
|
|
- }
|
|
|
- String url = urlPref + code;
|
|
|
- //非点击装置同步更新按钮 直接返回链接
|
|
|
- if (linkType == 2) return url;
|
|
|
- //失败返回验证链接
|
|
|
- if (!groupsRelationNetflixService.confirmUpdate(url)) {
|
|
|
- return url;
|
|
|
- }
|
|
|
- return StrUtil.EMPTY;
|
|
|
- }
|
|
|
- }
|
|
|
- //除奈飞
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
|
|
|
- }
|
|
|
- int length = 4;
|
|
|
- if (goodsId == 33l) {
|
|
|
- length = 6;
|
|
|
- }
|
|
|
- code = StringUtil.getVerifyCodePattern(code, length);
|
|
|
- if (!Validator.isNumber(code)) {
|
|
|
- log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
|
|
|
- throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取..");
|
|
|
- }
|
|
|
- return code.trim();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public void getCollegeStudentUserGptTicket(Long userId) {
|
|
|
Retryer<Boolean> build = RetryerBuilder.<Boolean>newBuilder()
|