|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.service.relation.impl;
|
|
package com.cyksj.service.relation.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.BetweenFormater;
|
|
import cn.hutool.core.date.BetweenFormater;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
@@ -17,6 +18,7 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
|
|
+import com.cyksj.common.util.TicketCodeCommonUtil;
|
|
|
import com.cyksj.enums.GatewayApiCode;
|
|
import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.mapper.*;
|
|
import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.sys.SysEmailMapper;
|
|
import com.cyksj.mapper.sys.SysEmailMapper;
|
|
@@ -29,8 +31,8 @@ import com.cyksj.service.groups.GroupsFuncService;
|
|
|
import com.cyksj.service.mail.CuiQiuMailService;
|
|
import com.cyksj.service.mail.CuiQiuMailService;
|
|
|
import com.cyksj.service.mail.MailService;
|
|
import com.cyksj.service.mail.MailService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
|
|
+import com.cyksj.service.midjourney.MidjourneyAccountService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
-import com.cyksj.service.shop.YhShopFrontService;
|
|
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.service.user.UserLoginRecordService;
|
|
import com.cyksj.service.user.UserLoginRecordService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
@@ -38,6 +40,7 @@ import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
import com.ejlchina.searcher.util.MapBuilder;
|
|
import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
|
|
+import com.github.rholder.retry.*;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -47,6 +50,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -83,7 +88,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
|
|
private final OrderDonMapper orderDonMapper;
|
|
private final OrderDonMapper orderDonMapper;
|
|
|
|
|
|
|
|
- private final YhShopFrontService yhShopFrontService;
|
|
|
|
|
|
|
+ private final GroupsRelationExpiryNotifyRecordMapper groupsRelationExpiryNotifyRecordMapper;
|
|
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
|
@@ -107,6 +112,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
|
|
private final UserCertRecordMapper userCertRecordMapper;
|
|
private final UserCertRecordMapper userCertRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final MidjourneyAccountService midjourneyAccountService;
|
|
|
|
|
+
|
|
|
//脆球邮箱后缀
|
|
//脆球邮箱后缀
|
|
|
private final static String CUI_QIU_EMAIL_SUFFIX = "@kindvd.com";
|
|
private final static String CUI_QIU_EMAIL_SUFFIX = "@kindvd.com";
|
|
|
private final UpgradePackageMapper upgradePackageMapper;
|
|
private final UpgradePackageMapper upgradePackageMapper;
|
|
@@ -231,10 +238,25 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
ticket.setPayTime(payTime);
|
|
ticket.setPayTime(payTime);
|
|
|
}
|
|
}
|
|
|
if (ticket.getGoodsId() == 26 && ticket.getIsMirror()){
|
|
if (ticket.getGoodsId() == 26 && ticket.getIsMirror()){
|
|
|
- List<UpgradePackage> upgradePackages = upgradePackageMapper.selectList(Wrappers.lambdaQuery(UpgradePackage.class).eq(UpgradePackage::getSkuId, ticket.getSkuId()).eq(UpgradePackage::getStatus, Boolean.TRUE));
|
|
|
|
|
|
|
+ List<UpgradePackage> upgradePackages = upgradePackageMapper.selectList(Wrappers.lambdaQuery(UpgradePackage.class).apply("JSON_CONTAINS(sku_ids,'\""+ticket.getSkuId()+"\"')").eq(UpgradePackage::getStatus, Boolean.TRUE));
|
|
|
if (CollectionUtil.isNotEmpty(upgradePackages)){
|
|
if (CollectionUtil.isNotEmpty(upgradePackages)){
|
|
|
upgradePackages.stream().map(e -> e.getPrice().divide(BigDecimal.valueOf(e.getNum()), 2, RoundingMode.HALF_UP)).min(BigDecimal::compareTo).ifPresent(ticket::setMjPackagePrice);
|
|
upgradePackages.stream().map(e -> e.getPrice().divide(BigDecimal.valueOf(e.getNum()), 2, RoundingMode.HALF_UP)).min(BigDecimal::compareTo).ifPresent(ticket::setMjPackagePrice);
|
|
|
}
|
|
}
|
|
|
|
|
+ try {
|
|
|
|
|
+ MidjourneyUserView search = beanSearcher.searchFirst(MidjourneyUserView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
|
|
+ .field(MidjourneyUserView::getUserId, ticket.getUserId()).field(MidjourneyUserView::getRelationId, ticket.getRelationId())
|
|
|
|
|
+ .onlySelect(MidjourneyUserView::getMjFastNum, MidjourneyUserView::getMjRelaxNum)
|
|
|
|
|
+ .build());
|
|
|
|
|
+ if (search == null) {
|
|
|
|
|
+ MidjourneyUser midjourneyUser = midjourneyAccountService.getMidjourneyUserToken(ticket.getUserId(), ticket.getRelationId());
|
|
|
|
|
+ ticket.setMjUserFastNum(midjourneyUser.getMjFastNum());
|
|
|
|
|
+ ticket.setMjUserRelaxNum(midjourneyUser.getMjRelaxNum());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ticket.setMjUserFastNum(search.getMjFastNum());
|
|
|
|
|
+ ticket.setMjUserRelaxNum(search.getMjRelaxNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
List<GroupsRelationUserView> relationUserViews = groupsRelationMapper.getUserRelationUserViews(ticket.getGroupId(), ticket.getRelationId(), ticket.getUserId(), List.of(GroupsRelation.Status.validity, GroupsRelation.Status.outside));
|
|
List<GroupsRelationUserView> relationUserViews = groupsRelationMapper.getUserRelationUserViews(ticket.getGroupId(), ticket.getRelationId(), ticket.getUserId(), List.of(GroupsRelation.Status.validity, GroupsRelation.Status.outside));
|
|
|
ticket.setRelationViews(relationUserViews);
|
|
ticket.setRelationViews(relationUserViews);
|
|
@@ -465,8 +487,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (StrUtil.hasEmpty(account, password)) {
|
|
if (StrUtil.hasEmpty(account, password)) {
|
|
|
throw BusinessRuntimeException.getInstance("您的车票账号密码异常,请联系客服...");
|
|
throw BusinessRuntimeException.getInstance("您的车票账号密码异常,请联系客服...");
|
|
|
}
|
|
}
|
|
|
- if (renewalView.getGoodsId() == 33l && renewalView.getAccount().contains(CUI_QIU_EMAIL_SUFFIX)) {
|
|
|
|
|
- return cuiQiuMailService.getVerifyCode(renewalView.getAccount());
|
|
|
|
|
|
|
+ if (renewalView.getAccount().contains(CUI_QIU_EMAIL_SUFFIX)) {
|
|
|
|
|
+ return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId());
|
|
|
}
|
|
}
|
|
|
//获取邮箱密码
|
|
//获取邮箱密码
|
|
|
SysEmail sysEmail = sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
|
|
SysEmail sysEmail = sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
|
|
@@ -653,8 +675,9 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
List<RenewalView> list = beanSearcher.searchAll(RenewalView.class, builder
|
|
List<RenewalView> list = beanSearcher.searchAll(RenewalView.class, builder
|
|
|
.field(RenewalView::getUserId, 0).op(Operator.GreaterThan)
|
|
.field(RenewalView::getUserId, 0).op(Operator.GreaterThan)
|
|
|
.field(RenewalView::getUserId, userIds).op(Operator.InList)
|
|
.field(RenewalView::getUserId, userIds).op(Operator.InList)
|
|
|
- .field("condition", String.format("(gr.expiry_time is null or gr.expiry_time > '%s')", now))
|
|
|
|
|
|
|
+ .field(RenewalView::getExpiryTime, now).op(Operator.GreaterThan)
|
|
|
.field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
|
|
.field(RenewalView::getStatus, List.of("validity", "overdue", "outside")).op(Operator.InList)
|
|
|
|
|
+ .field(RenewalView::getAqType, 1)
|
|
|
.orderBy(RenewalView::getExpiryTime).asc()
|
|
.orderBy(RenewalView::getExpiryTime).asc()
|
|
|
.onlySelect(RenewalView::getMonths, RenewalView::getExpiryTime, RenewalView::getRelationId, RenewalView::getAccount, RenewalView::getGoodsId, RenewalView::getTitle, RenewalView::getLogo, RenewalView::getImg, RenewalView::getGroupId, RenewalView::getSkuId, RenewalView::getSpecVal, RenewalView::getGoodsStatus, RenewalView::getSkuStatus)
|
|
.onlySelect(RenewalView::getMonths, RenewalView::getExpiryTime, RenewalView::getRelationId, RenewalView::getAccount, RenewalView::getGoodsId, RenewalView::getTitle, RenewalView::getLogo, RenewalView::getImg, RenewalView::getGroupId, RenewalView::getSkuId, RenewalView::getSpecVal, RenewalView::getGoodsStatus, RenewalView::getSkuStatus)
|
|
|
.build());
|
|
.build());
|
|
@@ -685,6 +708,9 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return false;
|
|
return false;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
|
|
redisService.setNx(RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getNameFormat(thisDate, userId), userId, RedisService.key.TICKET_EXPIRY_NOTIFY_DAY.getTimeout());
|
|
|
|
|
+ if (CollUtil.isNotEmpty(expiryTickets)) {
|
|
|
|
|
+ groupsRelationExpiryNotifyRecordMapper.batchInsert(userId, expiryTickets);
|
|
|
|
|
+ }
|
|
|
return expiryTickets;
|
|
return expiryTickets;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -712,23 +738,67 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
throw BusinessRuntimeException.getInstance("查询失败,请检查是否发送了登陆码..");
|
|
throw BusinessRuntimeException.getInstance("查询失败,请检查是否发送了登陆码..");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //迪士尼
|
|
|
|
|
- if (goodsId == 3) {
|
|
|
|
|
- int index = body.indexOf("otp_code");
|
|
|
|
|
- if (index == -1) {
|
|
|
|
|
- index = body.indexOf(" 15 ");
|
|
|
|
|
- }
|
|
|
|
|
- code = StrUtil.subWithLength(body, index, 215);
|
|
|
|
|
|
|
+ if (StrUtil.isEmpty(code)) {
|
|
|
|
|
+ code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
|
|
|
}
|
|
}
|
|
|
- //PS
|
|
|
|
|
|
|
+ int length = 4;
|
|
|
if (goodsId == 33l) {
|
|
if (goodsId == 33l) {
|
|
|
- code = StrUtil.subWithLength(body, body.indexOf("ADOBE"), 215);
|
|
|
|
|
|
|
+ length = 6;
|
|
|
}
|
|
}
|
|
|
- code = StringUtil.getVerifyCodePattern(code);
|
|
|
|
|
|
|
+ code = StringUtil.getVerifyCodePattern(code, length);
|
|
|
if (!Validator.isNumber(code)) {
|
|
if (!Validator.isNumber(code)) {
|
|
|
log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
|
|
log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
|
|
|
throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取..");
|
|
throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取..");
|
|
|
}
|
|
}
|
|
|
return code.trim();
|
|
return code.trim();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void getCollegeStudentUserGptTicket(Long userId) {
|
|
|
|
|
+ Retryer<Boolean> build = RetryerBuilder.<Boolean>newBuilder()
|
|
|
|
|
+ .retryIfException()
|
|
|
|
|
+ //运行时异常重试
|
|
|
|
|
+ .retryIfRuntimeException()
|
|
|
|
|
+ //false重试
|
|
|
|
|
+ .retryIfResult(res -> Objects.equals(res, false))
|
|
|
|
|
+ //1s 间隔
|
|
|
|
|
+ .withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS))
|
|
|
|
|
+ //停止策略 : 尝试请求3次
|
|
|
|
|
+ .withStopStrategy(StopStrategies.stopAfterAttempt(3)).build();
|
|
|
|
|
+ try {
|
|
|
|
|
+ build.call(() -> {
|
|
|
|
|
+ //体验规格
|
|
|
|
|
+ Long gptMirrorSkuId = Constant.GPT_MIRROR_SKU_ID;
|
|
|
|
|
+ GroupsTrips groups = groupsMapper.selectCollegeStudentUserGptTicket(gptMirrorSkuId);
|
|
|
|
|
+ GroupsRelation relation = null;
|
|
|
|
|
+ if (groups != null) {
|
|
|
|
|
+ relation = groupsRelationMapper.selectRandomOneRelationByGroupsId(groups.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (relation == null) {
|
|
|
|
|
+ //生成空车队
|
|
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(gptMirrorSkuId);
|
|
|
|
|
+ relation = groupsFuncService.createNewGroupsTrips(sku);
|
|
|
|
|
+ }
|
|
|
|
|
+ DateTime startTime = DateTime.now();
|
|
|
|
|
+ DateTime expiryTime = DateUtil.offsetDay(startTime, 1);
|
|
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
|
|
+ .set(GroupsRelation::getUserId, userId)
|
|
|
|
|
+ .set(GroupsRelation::getStartTime, startTime)
|
|
|
|
|
+ .set(GroupsRelation::getExpiryTime, expiryTime)
|
|
|
|
|
+ .set(GroupsRelation::getStatus, GroupsRelation.Status.validity)
|
|
|
|
|
+ .set(GroupsRelation::getAqType, 2)
|
|
|
|
|
+ .eq(GroupsRelation::getId, relation.getId())
|
|
|
|
|
+ .eq(GroupsRelation::getUserId, 0));
|
|
|
|
|
+ if (update > 0) {
|
|
|
|
|
+ groupsMapper.decrAvailableNum(groups.getId());
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (ExecutionException | RetryException e) {
|
|
|
|
|
+ log.error("发送用户GPT镜像体验失败:{}", StringUtil.getErrorText(e));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|