|
|
@@ -238,8 +238,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (StrUtil.isNotBlank(account)) {
|
|
|
builder.field(RenewalView::getAccount, account).op(Operator.Contain);
|
|
|
}
|
|
|
- //代充剩余次数大于0/未发车/过期时间
|
|
|
- String conditionSql = String.format("(gr.recharge_remain_num > 0 or gr.expiry_time is null or gr.expiry_time > '%s'", now);
|
|
|
+ //代充剩余次数大于0/未发车/过期时间/冻结时
|
|
|
+ String conditionSql = String.format("(gr.recharge_remain_num > 0 or gr.expiry_time is null or gr.expiry_time > '%s' or gr.is_frozen = true", now);
|
|
|
//镜像车票 过期7天后清除
|
|
|
//个人店铺和AI店铺 暂不支持过期续费
|
|
|
if (cmt == null && StrUtil.isEmpty(customId)) {
|
|
|
@@ -1514,11 +1514,40 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
public NetflixRecoverResp netflixSubmitRecover(ErrorNetflixChangeReq req) {
|
|
|
+ NetflixRecoverResp recoverResp = new NetflixRecoverResp();
|
|
|
Long relationId = req.getRelationId();
|
|
|
Long userId = req.getUserId();
|
|
|
//校验奈飞账号状态
|
|
|
GroupsRelationView netflixRelationView = checkNetflixErrorStatus(relationId, userId);
|
|
|
+ if (netflixRelationView.getIsFrozen()) {
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getIsFrozen, Boolean.FALSE)
|
|
|
+ .eq(GroupsRelation::getId, netflixRelationView.getId())
|
|
|
+ .eq(GroupsRelation::getIsFrozen, Boolean.TRUE));
|
|
|
+ if (update == 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("申请恢复账号失败,请重试");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //获取同规格的车票
|
|
|
+ Long skuId = netflixRelationView.getSkuId();
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
+ GroupsRelation relation = getRelation(null, userId, sku, null);
|
|
|
+ if (relation != null) {
|
|
|
+ Long groupsId = relation.getGroupsId();
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
|
|
|
+ //已发车
|
|
|
+ if (groupsTrips.getStatus() == GroupsTrips.Status.validity) {
|
|
|
+ resetUserTicket(netflixRelationView, relation);
|
|
|
+ recoverResp.setIsReset(Boolean.TRUE);
|
|
|
+ return recoverResp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw BusinessRuntimeException.getInstance("申请恢复账号失败,请重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
Date expiryTime = netflixRelationView.getExpiryTime();
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
NetflixUserAccountSubmitRecoverRecord recoverRecord = netflixUserAccountSubmitRecoverRecordMapper.selectOne(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
@@ -1545,13 +1574,58 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
Integer selectCount = netflixUserAccountSubmitRecoverRecordMapper.selectCount(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
.lt(NetflixUserAccountSubmitRecoverRecord::getCreatedTime, recoverRecord.getCreatedTime())
|
|
|
.eq(NetflixUserAccountSubmitRecoverRecord::getStatus, 0));
|
|
|
- NetflixRecoverResp recoverResp = new NetflixRecoverResp();
|
|
|
//往前加100位
|
|
|
recoverResp.setIndex(100 + selectCount + 1);
|
|
|
recoverResp.setRemainDays(recoverRecord.getRemainDays());
|
|
|
return recoverResp;
|
|
|
}
|
|
|
|
|
|
+ private void resetUserTicket(GroupsRelationView oldRelation, GroupsRelation newRelation) {
|
|
|
+ Long userId = oldRelation.getUserId();
|
|
|
+ Long oldRelationId = oldRelation.getId();
|
|
|
+ //清除车票
|
|
|
+ List<Long> userIdList;
|
|
|
+ try {
|
|
|
+ userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ userIdList = List.of(userId);
|
|
|
+ }
|
|
|
+ GroupsRelation clearRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getId, oldRelationId)
|
|
|
+ .in(GroupsRelation::getUserId, userIdList)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (clearRelation != null) {
|
|
|
+ clearRelation.setNewRelationId(newRelation.getId());
|
|
|
+ clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.ticket_replace);
|
|
|
+ }
|
|
|
+ newRelation.setUserId(userId);
|
|
|
+ //校验座位
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getUserId, userId)
|
|
|
+ .eq(GroupsRelation::getUserId, 0)
|
|
|
+ .eq(GroupsRelation::getId, newRelation.getId()));
|
|
|
+ if (update == 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("申请恢复账号失败,请重试");
|
|
|
+ }
|
|
|
+ //恢复状态
|
|
|
+ newRelation.setStartTime(oldRelation.getStartTime());
|
|
|
+ newRelation.setExpiryTime(DateUtil.offsetDay(DateTime.now(), oldRelation.getReservedDays()));
|
|
|
+ newRelation.setStatus(GroupsRelation.Status.validity);
|
|
|
+ groupsRelationMapper.updateById(newRelation);
|
|
|
+
|
|
|
+ //原订单座位id更新
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .in(OrderDon::getUserId, userIdList)
|
|
|
+ .eq(OrderDon::getRelationId, oldRelationId)
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderStatus)
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (orderDon != null) {
|
|
|
+ orderDon.setRelationId(newRelation.getId());
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
public void errorNetflixSubmitChangeOtherTicket(ErrorNetflixChangeReq req) throws Exception {
|
|
|
@@ -1957,6 +2031,35 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return ticketRenewUpgradeView;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void netflixSubmitFrozen(ErrorNetflixChangeReq req) {
|
|
|
+ Long relationId = req.getRelationId();
|
|
|
+ Long userId = req.getUserId();
|
|
|
+ //校验奈飞账号状态
|
|
|
+ GroupsRelationView netflixRelationView = checkNetflixErrorStatus(relationId, userId);
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ Integer recoverCount = netflixUserAccountSubmitRecoverRecordMapper.selectCount(Wrappers.lambdaQuery(NetflixUserAccountSubmitRecoverRecord.class)
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getRelationId, relationId)
|
|
|
+ .in(NetflixUserAccountSubmitRecoverRecord::getUserId, userIdList)
|
|
|
+ .eq(NetflixUserAccountSubmitRecoverRecord::getStatus, 0));
|
|
|
+ if (recoverCount > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("你已申请恢复账号,无法再申请冻结");
|
|
|
+ }
|
|
|
+ if (netflixRelationView.getIsFrozen()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("你已申请冻结,无法再申请冻结");
|
|
|
+ }
|
|
|
+ Date expiryTime = netflixRelationView.getExpiryTime();
|
|
|
+ //保留天数
|
|
|
+ Long betweenDay = DateUtil.betweenDay(DateTime.now(), expiryTime, false) + 1;
|
|
|
+ groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getIsFrozen, Boolean.TRUE)
|
|
|
+ //冻结2个月
|
|
|
+ .set(GroupsRelation::getUnfrozenTime, DateUtil.offsetMonth(DateTime.now(), 2))
|
|
|
+ .set(GroupsRelation::getReservedDays, betweenDay)
|
|
|
+ .eq(GroupsRelation::getId, netflixRelationView.getId())
|
|
|
+ .eq(GroupsRelation::getUserId, netflixRelationView.getUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
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());
|
|
|
@@ -2228,11 +2331,22 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.field(GroupsRelationView::getId, relationId)
|
|
|
.field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
|
|
|
.field(GroupsRelationView::getGoodsId, Constant.NETFLIX_GID)
|
|
|
- .field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
|
|
|
.build());
|
|
|
if (netflixRelationView == null) {
|
|
|
throw BusinessRuntimeException.getInstance("奈飞车票已过期");
|
|
|
}
|
|
|
+ if (netflixRelationView != null) {
|
|
|
+ if (netflixRelationView.getIsFrozen() && netflixRelationView.getUnfrozenTime().after(DateTime.now())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("冻结未结束");
|
|
|
+ }
|
|
|
+ if (netflixRelationView.getIsFrozen()) {
|
|
|
+ //重新设置车票时长
|
|
|
+ netflixRelationView.setExpiryTime(DateUtil.offsetDay(DateTime.now(), netflixRelationView.getReservedDays()));
|
|
|
+ }
|
|
|
+ if (netflixRelationView.getExpiryTime().before(DateTime.now())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("奈飞车票已过期");
|
|
|
+ }
|
|
|
+ }
|
|
|
netflixRelationView.setNfCheckId(netflixUseAccountStatusRecord.getId());
|
|
|
netflixRelationView.setNfOriOrderId(netflixUseAccountStatusRecord.getOrderId());
|
|
|
return netflixRelationView;
|