|
|
@@ -2392,12 +2392,19 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
Long userId = req.getUserId();
|
|
|
//校验账号
|
|
|
GroupsRelationView netflixRelationView = checkYoutubeTime(relationId, userId);
|
|
|
+ if (netflixRelationView.getIsFrozen()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("您的车票已冻结");
|
|
|
+ }
|
|
|
Date expiryTime = netflixRelationView.getExpiryTime();
|
|
|
- Long betweenDay = null;
|
|
|
- if (expiryTime != null) {
|
|
|
- //保留天数
|
|
|
- betweenDay = DateUtil.betweenDay(DateTime.now(), expiryTime, false) + 1;
|
|
|
+ OrderDon orderDon = orderDonMapper.selectById(netflixRelationView.getNfOriOrderId());
|
|
|
+ Long betweenDay;
|
|
|
+ if (expiryTime == null) {
|
|
|
+ //用订单时间
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
+ expiryTime = DateUtil.offsetMonth(orderDon.getCreatedTime(), sku.getMonths());
|
|
|
}
|
|
|
+ betweenDay= DateUtil.betweenDay(DateTime.now(), expiryTime, false) + 1;
|
|
|
+
|
|
|
groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
.set(GroupsRelation::getIsFrozen, Boolean.TRUE)
|
|
|
//冻结12个月
|
|
|
@@ -2443,6 +2450,14 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
changeOtherTicketRecord.setExpiryTime(expiryTime);
|
|
|
netflixUserChangeOtherTicketRecordMapper.insert(changeOtherTicketRecord);
|
|
|
}
|
|
|
+ //清除车票
|
|
|
+ GroupsRelation clearRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getId, relationId)
|
|
|
+ .eq(GroupsRelation::getUserId, relationView.getUserId())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (clearRelation != null) {
|
|
|
+ clearService.clearTicket(clearRelation, UserTicketClearedRecord.Source.yt_refund);
|
|
|
+ }
|
|
|
} finally {
|
|
|
redisService.del(key);
|
|
|
}
|
|
|
@@ -2452,7 +2467,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
public void errorYoutubeRefund(ErrorNetflixChangeReq req) throws Exception {
|
|
|
Long relationId = req.getRelationId();
|
|
|
Long userId = req.getUserId();
|
|
|
- //校验奈飞账号状态
|
|
|
+ //校验状态
|
|
|
GroupsRelationView relationView = checkYoutubeTime(relationId, userId);
|
|
|
Long ticketUserId = relationView.getUserId();
|
|
|
OrderDon orderDon = orderDonMapper.selectById(relationView.getNfOriOrderId());
|
|
|
@@ -2461,10 +2476,9 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (orderDon.getType() == OrderDon.Type.PAYPAL || (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0 && orderDon.getCreatedTime().after(DateUtil.offsetMonth(orderDon.getCreatedTime(), -12)))) {
|
|
|
throw BusinessRuntimeException.getInstance("请联系客服退款");
|
|
|
}
|
|
|
- SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
- .eq(SysConfig::getSysKey, Constant.YOUTUBE_REFUND_INFO_KEY)
|
|
|
- .last("limit 1"));
|
|
|
- OrderRefundDto orderRefundDto = Jsons.parseObject(sysConfig.getSysValue(), OrderRefundDto.class);
|
|
|
+ GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
+ OrderRefundDto orderRefundDto = getYoutubeRefundInfo(orderDon, sku);
|
|
|
BigDecimal refundBalance = orderRefundDto.getRefundBalance();
|
|
|
BigDecimal refundMoney = orderRefundDto.getRefundMoney();
|
|
|
//超过订单金额 让联系客服退款
|
|
|
@@ -2495,9 +2509,6 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
orderDon.setRefundDesc("油管掉会员退款");
|
|
|
orderDonMapper.updateById(orderDon);
|
|
|
-
|
|
|
- GoodsDon goodsDon = goodsDonMapper.selectById(orderDon.getGoodsId());
|
|
|
- GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
//记录退款类型
|
|
|
String refundType = getRefundType(refundMoney, refundBalance, orderDon);
|
|
|
orderRefundService.refundRecord(orderDon, refundMoney, refundBalance, "系统", goodsDon, sku, outNo, refundType, null);
|
|
|
@@ -2512,6 +2523,49 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private OrderRefundDto getYoutubeRefundInfo(OrderDon orderDon, GoodsDonSku sku) {
|
|
|
+ OrderRefundDto orderRefundDto = new OrderRefundDto();
|
|
|
+ //该订单月份
|
|
|
+ int month = DateUtil.month(orderDon.getCreatedTime()) + 1;
|
|
|
+ BigDecimal refundBalance = BigDecimal.ZERO;
|
|
|
+ //2年
|
|
|
+ if ((sku.getDays() != null && sku.getDays() == 730) || (sku.getMonths() != null && sku.getMonths() == 24)) {
|
|
|
+ //第二年未生效
|
|
|
+ if (orderDon.getCreatedTime().after(DateUtil.offsetMonth(DateTime.now(), -12))) {
|
|
|
+ //将第二年的金额 按订单金额折算一半
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
+ BigDecimal balance = Optional.ofNullable(orderDon.getBalance()).orElse(BigDecimal.ZERO);
|
|
|
+ BigDecimal orderTotalMoney = money.add(balance);
|
|
|
+ //兑换码订单
|
|
|
+ if (orderTotalMoney.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ orderTotalMoney = sku.getPrice();
|
|
|
+ }
|
|
|
+ BigDecimal thisRefundMoney = orderTotalMoney.divide(BigDecimal.valueOf(2), RoundingMode.DOWN);
|
|
|
+ if (money.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ refundBalance = refundBalance.add(thisRefundMoney);
|
|
|
+ } else {
|
|
|
+ if (thisRefundMoney.compareTo(money) > 0) {
|
|
|
+ BigDecimal refundMoney = money;
|
|
|
+ orderRefundDto.setRefundMoney(refundMoney);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (month >= 1 && month <= 6) {
|
|
|
+ //1-6月买的 退100余额
|
|
|
+ refundBalance = refundBalance.add(BigDecimal.valueOf(10000));
|
|
|
+ } else if (month >= 7 && month <= 11) {
|
|
|
+ //7-11月买的 退150余额
|
|
|
+ refundBalance = refundBalance.add(BigDecimal.valueOf(15000));
|
|
|
+ } else {
|
|
|
+ //12月买的 退200余额
|
|
|
+ refundBalance = refundBalance.add(BigDecimal.valueOf(20000));
|
|
|
+ }
|
|
|
+ orderRefundDto.setRefundBalance(refundBalance);
|
|
|
+ return orderRefundDto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<GoodsCategorySkuView> getYoutubeReplaceOtherSkus() throws Exception {
|
|
|
SysConfig sysConfig = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
@@ -2526,29 +2580,46 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
return goodsCategorySkuViews;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public OrderRefundDto getYoutubeRefundInfo(long userId, Long relationId) {
|
|
|
+ //校验状态
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ GroupsRelationView relationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ .field(GroupsRelationView::getId, relationId)
|
|
|
+ .field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
|
|
|
+ .field(GroupsRelationView::getGoodsId, Constant.YOUTUBE_GOODS_ID)
|
|
|
+ .build());
|
|
|
+ if (relationView != null) {
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getUserId, userIdList).eq(OrderDon::getRelationId, relationId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).orderByDesc(OrderDon::getId).last("limit 1"));
|
|
|
+ if (orderDon != null) {
|
|
|
+ GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
|
|
|
+ OrderRefundDto orderRefundDto = getYoutubeRefundInfo(orderDon, sku);
|
|
|
+ return orderRefundDto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
private GroupsRelationView checkYoutubeTime(Long relationId, Long userId) {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
- GroupsRelationView netflixRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
|
|
|
+ GroupsRelationView relationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
|
|
|
.field(GroupsRelationView::getId, relationId)
|
|
|
.field(GroupsRelationView::getUserId, userIdList).op(Operator.InList)
|
|
|
- .field(GroupsRelationView::getGoodsId, Constant.NETFLIX_GID)
|
|
|
+ .field(GroupsRelationView::getGoodsId, Constant.YOUTUBE_GOODS_ID)
|
|
|
.build());
|
|
|
- if (netflixRelationView == null) {
|
|
|
+ if (relationView == null) {
|
|
|
throw BusinessRuntimeException.getInstance("车票不存在");
|
|
|
}
|
|
|
- if (netflixRelationView.getIsFrozen()) {
|
|
|
- throw BusinessRuntimeException.getInstance("您的车票已冻结");
|
|
|
- }
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getUserId, userIdList).eq(OrderDon::getRelationId, relationId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).last("limit 1"));
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getUserId, userIdList).eq(OrderDon::getRelationId, relationId).notIn(OrderDon::getStatus, Constant.noOrderAllStatus).orderByDesc(OrderDon::getId).last("limit 1"));
|
|
|
if (orderDon == null) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
}
|
|
|
- DateTime availableHandleTime = DateUtil.parse("2025-12-19 17:00:00");
|
|
|
+ DateTime availableHandleTime = DateUtil.parse("2025-12-20 00:00:00");
|
|
|
if (orderDon.getCreatedTime().after(availableHandleTime)) {
|
|
|
throw BusinessRuntimeException.getInstance("不可进行售后,请联系客服");
|
|
|
}
|
|
|
- netflixRelationView.setNfOriOrderId(orderDon.getId());
|
|
|
- return netflixRelationView;
|
|
|
+ relationView.setNfOriOrderId(orderDon.getId());
|
|
|
+ return relationView;
|
|
|
}
|
|
|
|
|
|
private DistributePosterGoodsDetailView setGoodsPoster(RenewalView ticket, User user, List<Long> userIds) {
|
|
|
@@ -2963,7 +3034,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
|
|
|
- public OrderRefundDto getYoutubeRefundInfo(GroupsRelationView netflixRelationView) {
|
|
|
+ public OrderRefundDto getRefundInfo(GroupsRelationView netflixRelationView) {
|
|
|
OrderDon orderDon = orderDonMapper.selectById(netflixRelationView.getNfOriOrderId());
|
|
|
Long betweenDay = Long.valueOf(netflixRelationView.getReservedDays());
|
|
|
//未冻结时,使用车票时长
|