Explorar o código

奈飞同步更新装置代点

zoujiajian hai 1 ano
pai
achega
3b2432762d

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

@@ -352,7 +352,7 @@ public interface Constant {
 	/**
 	 * 电影域名
 	 */
-	String ZHAOJU_MOVIES = "http://43.154.169.245:8090";
+	String ZHAOJU_MOVIES = "http://43.154.169.245:8089";
 
 	//英文
 	String EN_US = "en_US";

+ 16 - 0
netflix-dao/src/main/java/com/cyksj/model/request/NfDeviceReq.java

@@ -0,0 +1,16 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: NfDeviceReq
+ * 创建者: JavaZou
+ * 创建时间:2024/10/14 16:23
+ */
+@Getter
+@Setter
+public class NfDeviceReq {
+	private String url;
+}

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/mail/CuiQiuMailService.java

@@ -11,7 +11,7 @@ public interface CuiQiuMailService {
 	/**
 	 * 获取最新邮箱 返回验证码
 	 */
-	String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType) throws Exception;
+	String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType, Boolean isReturnDeviceUrl) throws Exception;
 
 	boolean isCuiQiuEmail(String account);
 }

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/mail/YhMailService.java

@@ -11,5 +11,5 @@ public interface YhMailService {
 	/**
 	 * 获取最新邮箱 返回验证码
 	 */
-	String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType) throws Exception;
+	String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType, Boolean isReturnDeviceUrl) throws Exception;
 }

+ 10 - 6
netflix-service/src/main/java/com/cyksj/service/mail/impl/CuiQiuMailServiceImpl.java

@@ -61,12 +61,12 @@ public class CuiQiuMailServiceImpl implements CuiQiuMailService {
 	}
 
 	/**
-	 *
-	 * @param type 1:奈飞安全码
+	 * @param type     1:奈飞安全码
 	 * @param linkType 链接 1:同步验证链接
+	 * @param isReturnDeviceUrl true 直接返回同步装置url
 	 */
 	@Override
-	public String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType) throws Exception {
+	public String getVerifyCode(String email, Long goodsId, Integer type, Integer linkType, Boolean isReturnDeviceUrl) throws Exception {
 		//获取近二十封邮件
 		String url = "https://domain-open-api.cuiqiu.com/v1/message/list";
 
@@ -118,7 +118,7 @@ public class CuiQiuMailServiceImpl implements CuiQiuMailService {
 			for (CuiQiuEmailDto CuiQiuEmailDto : list) {
 				Long messageId = CuiQiuEmailDto.getId();
 				try {
-					String code = getVerifyCodeByEmail(messageId, goodsId, type, linkType, mailId);
+					String code = getVerifyCodeByEmail(messageId, goodsId, type, linkType, mailId, isReturnDeviceUrl);
 					if (StrUtil.isNotBlank(code)) {
 						return code;
 					}
@@ -139,7 +139,7 @@ public class CuiQiuMailServiceImpl implements CuiQiuMailService {
 		return false;
 	}
 
-	public String getVerifyCodeByEmail(Long messageId, Long goodsId, Integer type, Integer linkType, String mailId) throws Exception {
+	public String getVerifyCodeByEmail(Long messageId, Long goodsId, Integer type, Integer linkType, String mailId, Boolean isReturnDeviceUrl) throws Exception {
 		String url = "https://domain-open-api.cuiqiu.com/v1/message/detail";
 		Map<String, Object> params = new HashMap<>();
 		params.put("token", CUI_QIU_TOKEN);
@@ -176,10 +176,14 @@ public class CuiQiuMailServiceImpl implements CuiQiuMailService {
 					nfVerifyUrl = TicketCodeCommonUtil.extractUrl(body, urlPref);
 				}
 				if (StrUtil.isEmpty(nfVerifyUrl)) {
-					throw BusinessRuntimeException.getInstance("获取认证链接失败,请重新获取");
+					throw BusinessRuntimeException.getInstance("请在奈飞端点击“传送电子邮件”");
 				}
 				//非点击装置同步更新按钮 直接返回链接
 				if (linkType == 2) return nfVerifyUrl;
+				//直接返回同步装置url
+				if (isReturnDeviceUrl) {
+					return nfVerifyUrl;
+				}
 				//失败返回验证链接
 				if (!groupsRelationNetflix.confirmUpdate(nfVerifyUrl)) {
 					return nfVerifyUrl;

+ 7 - 4
netflix-service/src/main/java/com/cyksj/service/mail/impl/YhEmailServiceImpl.java

@@ -6,7 +6,6 @@ import cn.hutool.http.HttpStatus;
 import cn.hutool.http.HttpUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
-import com.cyksj.common.util.StringUtil;
 import com.cyksj.common.util.TicketCodeCommonUtil;
 import com.cyksj.mapper.sys.SysEmailMapper;
 import com.cyksj.model.entity.SysEmail;
@@ -34,7 +33,7 @@ public class YhEmailServiceImpl implements YhMailService {
 	private final SysEmailMapper sysEmailMapper;
 
 	@Override
-	public String getVerifyCode(String account, Long goodsId, Integer type, Integer linkType) throws Exception {
+	public String getVerifyCode(String account, Long goodsId, Integer type, Integer linkType, Boolean isReturnDeviceUrl) throws Exception {
 		//获取邮箱密码
 		SysEmail sysEmail = sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
 				.eq(SysEmail::getEmail, account)
@@ -61,11 +60,11 @@ public class YhEmailServiceImpl implements YhMailService {
 		if (execute.getStatus() != HttpStatus.HTTP_OK) {
 			throw BusinessRuntimeException.getInstance("获取验证码异常,请联系客服...");
 		}
-		String code = getDifferentGoodsCode(goodsId, execute.body(), type, linkType);
+		String code = getDifferentGoodsCode(goodsId, execute.body(), type, linkType, isReturnDeviceUrl);
 		return code;
 	}
 
-	public String getDifferentGoodsCode(Long goodsId, String body, Integer type, Integer linkType) {
+	public String getDifferentGoodsCode(Long goodsId, String body, Integer type, Integer linkType, Boolean isReturnDeviceUrl) {
 		String code = null;
 		//奈飞
 		if (goodsId == 1) {
@@ -99,6 +98,10 @@ public class YhEmailServiceImpl implements YhMailService {
 				String url = urlPref + code;
 				//非点击装置同步更新按钮 直接返回链接
 				if (linkType == 2) return url;
+				//直接返回同步更新装置url
+				if (isReturnDeviceUrl) {
+					return url;
+				}
 				//失败返回验证链接
 				if (!groupsRelationNetflixService.confirmUpdate(url)) {
 					return url;

+ 4 - 4
netflix-service/src/main/java/com/cyksj/service/mange/account/CmsAccountServiceImpl.java

@@ -462,11 +462,11 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 			throw BusinessRuntimeException.getInstance("账户异常");
 		}
 		if (cuiQiuMailService.isCuiQiuEmail(account)) {
-			return cuiQiuMailService.getVerifyCode(account, at.getGoodsId(), null, 1);
+			return cuiQiuMailService.getVerifyCode(account, at.getGoodsId(), null, 1, false);
 		}
 		String code = null;
 		try {
-			code = yhMailService.getVerifyCode(account, at.getGoodsId(), null, 1);
+			code = yhMailService.getVerifyCode(account, at.getGoodsId(), null, 1, false);
 		} catch (Exception e) {
 			if (e.getMessage() != null && e.getMessage().contains("认证链接")) {
 				throw BusinessRuntimeException.getInstance("请联系用户确认是否发送邮件");
@@ -491,9 +491,9 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 			throw BusinessRuntimeException.getInstance("账户异常");
 		}
 		if (cuiQiuMailService.isCuiQiuEmail(account)) {
-			return cuiQiuMailService.getVerifyCode(account, at.getGoodsId(), null, null);
+			return cuiQiuMailService.getVerifyCode(account, at.getGoodsId(), null, null, false);
 		}
-		String code = yhMailService.getVerifyCode(account, at.getGoodsId(), null, null);
+		String code = yhMailService.getVerifyCode(account, at.getGoodsId(), null, null, false);
 		return code;
 	}
 }

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

@@ -64,4 +64,6 @@ public interface GroupRelationFrontService {
 	GroupsRelation ticketLogin(TicketLoginReq loginReq);
 
 	String outsideTicketVerify(TicketLoginReq loginReq);
+
+	String getNfHouseholdDevice(long userId, Long relationId) throws Exception;
 }

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

@@ -1,6 +1,7 @@
 package com.cyksj.service.relation;
 
 import cn.hutool.json.JSONObject;
+import com.cyksj.model.request.NfDeviceReq;
 
 import java.util.Date;
 
@@ -26,4 +27,6 @@ public interface GroupsRelationNetflixService {
 	void timingSetNetflix(Integer num, String nickname, String account, String password, Date expiryTime);
 
 	JSONObject nfKickOut(long userId, Long relationId);
+
+	void clickNfHouseholdDevice(NfDeviceReq nfDeviceReq);
 }

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

@@ -561,10 +561,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 			}
 		}
 		if (cuiQiuMailService.isCuiQiuEmail(renewalView.getAccount())) {
-			return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId(), type, loginReq.getLinkType());
+			return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId(), type, loginReq.getLinkType(), false);
 		}
 		//银河域名邮件
-		String code = yhMailService.getVerifyCode(account, renewalView.getGoodsId(), type, loginReq.getLinkType());
+		String code = yhMailService.getVerifyCode(account, renewalView.getGoodsId(), type, loginReq.getLinkType(), false);
 		GroupsRelationLoginCodeRecord record = new GroupsRelationLoginCodeRecord();
 		record.setUserId(userId);
 		record.setRelationId(relationId);
@@ -923,6 +923,34 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 	}
 
+	@Override
+	public String getNfHouseholdDevice(long userId, Long relationId) throws Exception {
+		List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder().field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
+				.field(RenewalView::getRelationId, relationId).build());
+		if (renewalView == null) {
+			throw BusinessRuntimeException.getInstance("您的车票不存在...");
+		}
+		if (StrUtil.isEmpty(renewalView.getAccount())) {
+			throw BusinessRuntimeException.getInstance("车票未配置账号");
+		}
+		String account = renewalView.getAccount();
+		//收取邮件的关联邮箱
+		if (StrUtil.isNotEmpty(renewalView.getRelateEmail())) {
+			account = renewalView.getRelateEmail();
+		}
+		String password = renewalView.getPassword();
+		if (StrUtil.hasEmpty(account, password)) {
+			throw BusinessRuntimeException.getInstance("您的车票账号密码异常,请联系客服...");
+		}
+
+		if (cuiQiuMailService.isCuiQiuEmail(renewalView.getAccount())) {
+			return cuiQiuMailService.getVerifyCode(renewalView.getAccount(), renewalView.getGoodsId(), null, 1, true);
+		}
+		//银河域名邮件
+		return yhMailService.getVerifyCode(account, renewalView.getGoodsId(), null, 1, true);
+	}
+
 	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());

+ 9 - 0
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupsRelationNetflixServiceImpl.java

@@ -18,6 +18,7 @@ import com.cyksj.model.entity.Account;
 import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.entity.GroupsTrips;
 import com.cyksj.model.entity.User;
+import com.cyksj.model.request.NfDeviceReq;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.relation.GroupsRelationNetflixService;
 import com.cyksj.service.user.UserBindRelationService;
@@ -199,6 +200,14 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
 		return doNfKickOut(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(),account.getCookie(), relation.getExpiryTime(), relation.getPinCode());
 	}
 
+	@Override
+	public void clickNfHouseholdDevice(NfDeviceReq nfDeviceReq) {
+		String url = nfDeviceReq.getUrl();
+		if (!confirmUpdate(url)) {
+			throw BusinessRuntimeException.getInstance("程序代点失败");
+		}
+	}
+
 	/**
 	 * 踢出奈飞设备
 	 */

+ 20 - 4
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -28,10 +28,7 @@ import com.cyksj.model.dto.DoubleVerifyDto;
 import com.cyksj.model.dto.QuestionnaireView;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.GroupsRelationView;
-import com.cyksj.model.request.OrderPayRequest;
-import com.cyksj.model.request.OrderRefundReq;
-import com.cyksj.model.request.SpecialGoodsTicketReq;
-import com.cyksj.model.request.TicketLoginReq;
+import com.cyksj.model.request.*;
 import com.cyksj.model.response.GptStandbyResp;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
@@ -58,6 +55,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -916,6 +914,24 @@ public class GroupRelationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(data.toString());
     }
 
+    /**
+     * 奈飞同户装置链接
+     */
+    @GetMapping("/get/nf/household/device")
+    public Result<String> getNfHouseholdDevice(@NotNull Long relationId) throws Exception {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        String url = groupRelationFrontService.getNfHouseholdDevice(userId, relationId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(url);
+    }
+
+    /**
+     * 代点奈飞同户装置
+     */
+    @PostMapping("/click/nf/household/device")
+    public void clickNfHouseholdDevice(@RequestBody NfDeviceReq nfDeviceReq) {
+        groupsRelationNetflixService.clickNfHouseholdDevice(nfDeviceReq);
+    }
+
     /**
      * 可选 续费升级车票
      */