zoujiajian 8 kuukautta sitten
vanhempi
sitoutus
a83f679324

+ 5 - 0
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -564,6 +564,11 @@ public interface Constant {
 	 */
 	List<Long> RECHARGE_INVITE_GOODS_IDS = List.of(4l, 5l);
 
+	/**
+	 * 油管平台ID
+	 */
+	Long YOUTUBE_GOODS_ID = 5L;
+
 	/**
 	 * 第三方分类id
 	 */

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -2,6 +2,7 @@ package com.cyksj.service.relation;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.model.dto.NetflixRecoverReceivedGptConditionDto;
+import com.cyksj.model.dto.OrderRefundDto;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.entity.NetflixUserAccountStatusRecord;
@@ -132,4 +133,6 @@ public interface GroupRelationFrontService {
 	void errorYoutubeRefund(ErrorNetflixChangeReq req) throws Exception;
 
 	List<GoodsCategorySkuView> getYoutubeReplaceOtherSkus() throws Exception;
+
+	OrderRefundDto getYoutubeRefundInfo(long userId, Long relationId);
 }

+ 94 - 23
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -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());
 		//未冻结时,使用车票时长

+ 11 - 3
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -27,9 +27,7 @@ import com.cyksj.mapper.*;
 import com.cyksj.mapper.manage.form.FormFieldsDataMapper;
 import com.cyksj.mapper.manage.form.QuestionnairePromotionMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
-import com.cyksj.model.dto.DoubleVerifyDto;
-import com.cyksj.model.dto.GalaxyCoinPayConfigDto;
-import com.cyksj.model.dto.NetflixRecoverReceivedGptConditionDto;
+import com.cyksj.model.dto.*;
 import com.cyksj.model.dto.QuestionnaireView;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.AccountView;
@@ -1617,4 +1615,14 @@ public class GroupRelationController {
         groupRelationFrontService.errorYoutubeRefund(req);
         return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
+
+    /**
+     * youtube 退款详情
+     */
+    @GetMapping("/youtube/refund/info")
+    public Result<OrderRefundDto> getYoutubeRefundInfo(Long relationId) throws Exception {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        OrderRefundDto orderRefundDto = groupRelationFrontService.getYoutubeRefundInfo(userId, relationId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(orderRefundDto);
+    }
 }