|
|
@@ -1309,6 +1309,54 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Long getTicket(Long userId, Long skuId, Boolean isVip) {
|
|
|
+ Retryer<Long> build = RetryerBuilder.<Long>newBuilder()
|
|
|
+ .retryIfException()
|
|
|
+ //运行时异常重试
|
|
|
+ .retryIfRuntimeException()
|
|
|
+ //false重试
|
|
|
+ .retryIfResult(res -> res == null)
|
|
|
+ //1s 间隔
|
|
|
+ .withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS))
|
|
|
+ //停止策略 : 尝试请求1次
|
|
|
+ .withStopStrategy(StopStrategies.stopAfterAttempt(1)).build();
|
|
|
+ try {
|
|
|
+ return build.call(() -> {
|
|
|
+ //体验规格
|
|
|
+ GroupsTrips groups = groupsMapper.selectCollegeStudentUserGptTicket(skuId);
|
|
|
+ GroupsRelation relation = null;
|
|
|
+ if (groups != null) {
|
|
|
+ relation = groupsRelationMapper.selectRandomOneRelationByGroupsId(groups.getId());
|
|
|
+ }
|
|
|
+ if (relation == null) {
|
|
|
+ //生成空车队
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
+ 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::getIsVip, isVip)
|
|
|
+ .eq(GroupsRelation::getId, relation.getId())
|
|
|
+ .eq(GroupsRelation::getUserId, 0));
|
|
|
+ if (update > 0) {
|
|
|
+ groupsMapper.decrAvailableNum(groups.getId());
|
|
|
+ return relation.getId();
|
|
|
+ }
|
|
|
+ log.error("发送用户:{} GPT镜像车票失败,进行重试", userId);
|
|
|
+ return null;
|
|
|
+ });
|
|
|
+ } catch (ExecutionException | RetryException e) {
|
|
|
+ log.error("发送用户GPT镜像失败:{}", StringUtil.getErrorText(e));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private DistributePosterGoodsDetailView setGoodsPoster(RenewalView ticket, User user, List<Long> userIds) {
|
|
|
DistributePosterGoodsDetailView distributePosterGoodsDetailView = beanSearcher.searchFirst(DistributePosterGoodsDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
.field(DistributePosterGoodsFrontView::getGoodsId, ticket.getGoodsId()).build());
|