|
@@ -57,6 +57,7 @@ import com.cyksj.service.relation.GroupRelationClearService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.relation.GroupsRelationChangeService;
|
|
import com.cyksj.service.relation.GroupsRelationChangeService;
|
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
|
|
+import com.cyksj.service.user.UserBenefitsService;
|
|
|
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;
|
|
@@ -199,6 +200,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
|
|
private final GroupRelationClearService clearService;
|
|
private final GroupRelationClearService clearService;
|
|
|
|
|
|
|
|
|
|
+ private final UserBenefitsService userBenefitsService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
|
|
|
User u = userMapper.selectById(userId);
|
|
User u = userMapper.selectById(userId);
|
|
@@ -584,11 +587,16 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
relation = getSimilarExpiredGroupRelation(sku, null, ip);
|
|
relation = getSimilarExpiredGroupRelation(sku, null, ip);
|
|
|
if (relation == null) {
|
|
if (relation == null) {
|
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
//TODO 如果没指定座位,等待逻辑确认
|
|
|
- groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.validity, maxNum, ip);
|
|
|
|
|
|
|
+ DateTime filterAccountTime = null;
|
|
|
|
|
+ //奈飞过滤6月23号之前的车队
|
|
|
|
|
+ if (sku.getGoodsId() == Constant.NETFLIX_GID) {
|
|
|
|
|
+ filterAccountTime = DateUtil.parse("2025-06-23");
|
|
|
|
|
+ }
|
|
|
|
|
+ groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.validity, maxNum, ip, filterAccountTime);
|
|
|
|
|
|
|
|
if (groups == null) {
|
|
if (groups == null) {
|
|
|
//待发车
|
|
//待发车
|
|
|
- groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.waiting, maxNum, ip);
|
|
|
|
|
|
|
+ groups = groupsMapper.selectTicketGroups(sku.getId(), GroupsTrips.Status.waiting, maxNum, ip, null);
|
|
|
}
|
|
}
|
|
|
//新增空车队
|
|
//新增空车队
|
|
|
if (groups == null) {
|
|
if (groups == null) {
|
|
@@ -934,7 +942,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
|
if (update > 0) {
|
|
if (update > 0) {
|
|
|
- groupsMapper.decrAvailableNum(groups.getId());
|
|
|
|
|
|
|
+ groupsMapper.decrAvailableNum(relation.getGroupsId());
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);
|
|
log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);
|
|
@@ -1338,7 +1346,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
|
if (update > 0) {
|
|
if (update > 0) {
|
|
|
- groupsMapper.decrAvailableNum(groups.getId());
|
|
|
|
|
|
|
+ groupsMapper.decrAvailableNum(relation.getGroupsId());
|
|
|
return relation.getId();
|
|
return relation.getId();
|
|
|
}
|
|
}
|
|
|
log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);
|
|
log.error("发送用户:{} GPT镜像车票体验失败,进行重试", userId);
|
|
@@ -1426,7 +1434,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
|
if (update > 0) {
|
|
if (update > 0) {
|
|
|
- groupsMapper.decrAvailableNum(groups.getId());
|
|
|
|
|
|
|
+ groupsMapper.decrAvailableNum(relation.getGroupsId());
|
|
|
return relation.getId();
|
|
return relation.getId();
|
|
|
}
|
|
}
|
|
|
log.error("发送用户:{} GPT镜像车票失败,进行重试", userId);
|
|
log.error("发送用户:{} GPT镜像车票失败,进行重试", userId);
|
|
@@ -1574,14 +1582,46 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.set(NetflixUserAccountStatusRecord::getDeleted, false)
|
|
.set(NetflixUserAccountStatusRecord::getDeleted, false)
|
|
|
.eq(NetflixUserAccountStatusRecord::getId, netflixRelationView.getNfCheckId()));
|
|
.eq(NetflixUserAccountStatusRecord::getId, netflixRelationView.getNfCheckId()));
|
|
|
}
|
|
}
|
|
|
|
|
+ Long ticketUserId = null;
|
|
|
//清除车票
|
|
//清除车票
|
|
|
GroupsRelation clearRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
GroupsRelation clearRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
.eq(GroupsRelation::getId, relationId)
|
|
.eq(GroupsRelation::getId, relationId)
|
|
|
.in(GroupsRelation::getUserId, userIdList)
|
|
.in(GroupsRelation::getUserId, userIdList)
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
if (clearRelation != null) {
|
|
if (clearRelation != null) {
|
|
|
|
|
+ ticketUserId = clearRelation.getUserId();
|
|
|
clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
|
}
|
|
}
|
|
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
|
|
+ .in(OrderDon::getUserId, userIdList)
|
|
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (orderDon != null) {
|
|
|
|
|
+ if (ticketUserId == null) {
|
|
|
|
|
+ ticketUserId = orderDon.getUserId();
|
|
|
|
|
+ }
|
|
|
|
|
+ //替换sku
|
|
|
|
|
+ GoodsDonSku replaceSku = goodsDonSkuMapper.selectById(skuId);
|
|
|
|
|
+ GoodsDonSku oriTicketSku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
|
|
+ //每天单价
|
|
|
|
|
+ BigDecimal dayPrice = oriTicketSku.getPrice().divide(BigDecimal.valueOf(oriTicketSku.getMonths() * 30), RoundingMode.DOWN);
|
|
|
|
|
+ //需要退款金额
|
|
|
|
|
+ BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
|
|
+ BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
|
|
+ BigDecimal finalOrderMoney = orderDon.getMoney().add(balance);
|
|
|
|
|
+ if (refundMoney.compareTo(finalOrderMoney) > 0) {
|
|
|
|
|
+ refundMoney = finalOrderMoney;
|
|
|
|
|
+ }
|
|
|
|
|
+ //车票价格高于替换的规格价格 退余额
|
|
|
|
|
+ if (refundMoney.compareTo(replaceSku.getPrice()) > 0) {
|
|
|
|
|
+ BigDecimal refundBalance = refundMoney.subtract(replaceSku.getPrice());
|
|
|
|
|
+ if (refundBalance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ userBenefitsService.addUserBalance(ticketUserId, refundBalance, UserBalanceSourceRecord.Source.TICKET_REPLACE, 0L, orderDon.getId(), UserBalanceSourceRecord.Source.TICKET_REPLACE.getDesc(), true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} finally {
|
|
} finally {
|
|
|
redisService.del(key);
|
|
redisService.del(key);
|
|
|
}
|
|
}
|
|
@@ -1612,7 +1652,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
}
|
|
|
List<GoodsCategorySkuView> goodsCategorySkuViews = beanSearcher.searchAll(GoodsCategorySkuView.class, MapUtils.builder()
|
|
List<GoodsCategorySkuView> goodsCategorySkuViews = beanSearcher.searchAll(GoodsCategorySkuView.class, MapUtils.builder()
|
|
|
.field(GoodsCategorySkuView::getSkuId, errorNetflixChangeOtherSkuTicketDto.getSkuIds()).op(Operator.InList)
|
|
.field(GoodsCategorySkuView::getSkuId, errorNetflixChangeOtherSkuTicketDto.getSkuIds()).op(Operator.InList)
|
|
|
- .orderBy(GoodsCategorySkuView::getPrice)
|
|
|
|
|
|
|
+ .orderBy(GoodsCategorySkuView::getPrice).desc()
|
|
|
.build());
|
|
.build());
|
|
|
return goodsCategorySkuViews;
|
|
return goodsCategorySkuViews;
|
|
|
}
|
|
}
|
|
@@ -1650,7 +1690,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
//需要退款金额
|
|
//需要退款金额
|
|
|
BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
BigDecimal refundMoney = dayPrice.multiply(BigDecimal.valueOf(betweenDay));
|
|
|
refundInfoResp.setPrice(refundMoney);
|
|
refundInfoResp.setPrice(refundMoney);
|
|
|
- BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
|
|
|
|
+ BigDecimal balance = orderDon == null ? BigDecimal.ZERO : Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
//超过本身订单金额 不允许退款
|
|
//超过本身订单金额 不允许退款
|
|
|
if (refundMoney.compareTo(orderMoney) > 0) {
|
|
if (refundMoney.compareTo(orderMoney) > 0) {
|
|
|
refundInfoResp.setIsRefund(false);
|
|
refundInfoResp.setIsRefund(false);
|
|
@@ -2025,7 +2065,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
.eq(GroupsRelation::getId, relation.getId())
|
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
.eq(GroupsRelation::getUserId, 0));
|
|
|
if (update > 0) {
|
|
if (update > 0) {
|
|
|
- groupsMapper.decrAvailableNum(groups.getId());
|
|
|
|
|
|
|
+ groupsMapper.decrAvailableNum(relation.getGroupsId());
|
|
|
Long relationId = relation.getId();
|
|
Long relationId = relation.getId();
|
|
|
//生成新的订单
|
|
//生成新的订单
|
|
|
OrderDon otherOrderDon = generateNewTicketOrder(relationId, userId, sku);
|
|
OrderDon otherOrderDon = generateNewTicketOrder(relationId, userId, sku);
|