Răsfoiți Sursa

奈飞冻结车票

zoujiajian 11 luni în urmă
părinte
comite
cd4e5c2837

+ 16 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GroupsRelation.java

@@ -184,6 +184,22 @@ public class GroupsRelation extends BaseEntity {
     @TableField(exist = false)
     private Boolean isClaudeCodeUpgrade;
 
+    /**
+     * 是否被冻结
+     * 默认false
+     */
+    private Boolean isFrozen;
+
+    /**
+     * 解冻时长
+     */
+    private Date unfrozenTime;
+
+    /**
+     * 冻结保留天数
+     */
+    private Integer reservedDays;
+
 	@AllArgsConstructor
     @Getter
     public enum Status{

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/GroupsRelationView.java

@@ -164,4 +164,22 @@ public class GroupsRelationView {
     @DbIgnore
     private Long nfOriOrderId;
 
+    /**
+     * 是否被冻结
+     * 默认false
+     */
+    @DbField("gr.is_frozen")
+    private Boolean isFrozen;
+
+    /**
+     * 解冻时长
+     */
+    @DbField("gr.unfrozen_time")
+    private Date unfrozenTime;
+
+    /**
+     * 冻结保留天数
+     */
+    @DbField("gr.reserved_days")
+    private Integer reservedDays;
 }

+ 19 - 0
netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java

@@ -247,6 +247,25 @@ public class RenewalView {
     @DbField("gr.is_vip")
     private Boolean isVip;
 
+    /**
+     * 是否被冻结
+     * 默认false
+     */
+    @DbField("gr.is_frozen")
+    private Boolean isFrozen;
+
+    /**
+     * 解冻时长
+     */
+    @DbField("gr.unfrozen_time")
+    private Date unfrozenTime;
+
+    /**
+     * 冻结保留天数
+     */
+    @DbField("gr.reserved_days")
+    private Integer reservedDays;
+
     @DbIgnore
     private Date payTime;
 

+ 4 - 1
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -29,7 +29,10 @@
         gpt_task_id = null,
         recharge_error_info = null,
         bp_verify_code = null,
-        gpt_token = null
+        gpt_token = null,
+        is_frozen = 0,
+        unfrozen_time = null,
+        reserved_days = null
         where id = #{entity.id}
         <if test="expireTime != null">
             and expiry_time = #{expireTime}

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

@@ -115,4 +115,6 @@ public interface GroupRelationFrontService {
 	List<UserMirrorTicketView> getMirrorTicket(long userId);
 
 	TicketRenewUpgradeView getRenewUpgradeInfo(long userId, Long relationId);
+
+	void netflixSubmitFrozen(ErrorNetflixChangeReq req);
 }

+ 39 - 2
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -1957,6 +1957,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,10 +2257,18 @@ 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.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());

+ 12 - 0
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -1288,6 +1288,18 @@ public class GroupRelationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(recoverResp);
     }
 
+    /**
+     * 奈飞申请冻结
+     */
+    @PostMapping("/netflix/submit/frozen")
+    public Result<String> netflixSubmitFrozen(@RequestBody ErrorNetflixChangeReq req) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        req.setUserId(userId);
+        groupRelationFrontService.netflixSubmitFrozen(req);
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
+
+
     /**
      * 奈飞更换其他车票
      */