Procházet zdrojové kódy

gpt账号登录验证码;踢出奈飞设备

zoujiajian před 1 rokem
rodič
revize
5d589c478b

+ 19 - 1
netflix-common/src/main/java/com/cyksj/common/util/TicketCodeCommonUtil.java

@@ -1,6 +1,10 @@
 package com.cyksj.common.util;
 
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.cyksj.common.exception.BusinessRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -13,6 +17,7 @@ import java.util.regex.Pattern;
  */
 
 public class TicketCodeCommonUtil {
+	private static final Logger LOGGER = LoggerFactory.getLogger(TicketCodeCommonUtil.class);
 	/**
 	 * 车票邮箱验证码
 	 */
@@ -32,7 +37,16 @@ public class TicketCodeCommonUtil {
 		if (StrUtil.isNotBlank(code)) {
 			code = code.replace(str, "");
 		}
-		return code;
+		int length = 4;
+		if (goodsId == 33l || goodsId == 45l || goodsId == 18l) {
+			length = 6;
+		}
+		code = StringUtil.getVerifyCodePattern(code, length);
+		if (!Validator.isNumber(code)) {
+			LOGGER.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
+			throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取..");
+		}
+		return code.trim();
 	}
 
 	public static String extractUrl(String body, String prefixUrl) {
@@ -69,6 +83,10 @@ public class TicketCodeCommonUtil {
 				}
 			}
 		}
+		//GPT PLUS
+		if (goodsId == 18l) {
+			str = "X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-80345.templateTenant";
+		}
 		return str;
 	}
 }

+ 10 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/Account.java

@@ -107,4 +107,14 @@ public class Account extends BaseEntity {
      * 账号是否禁用
      */
     private Boolean isDisable;
+
+    /**
+     * cookie nf
+     */
+    private String cookie;
+
+    /**
+     * 关联邮箱 收取邮件
+     */
+    private String relateEmail;
 }

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

@@ -108,6 +108,11 @@ public class GroupsRelation extends BaseEntity {
      */
     private Integer aqType;
 
+    /**
+     * 奈飞pinCode
+     */
+    private String pinCode;
+
 
     @AllArgsConstructor
     @Getter

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/AccountView.java

@@ -164,4 +164,10 @@ public class AccountView {
 
     @DbField("a.is_disable")
     private Boolean isDisable;
+
+    @DbField("a.cookie")
+    private Boolean cookie;
+
+    @DbField("a.relate_email")
+    private Boolean relateEmail;
 }

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -846,6 +846,7 @@ public class RedisService {
         LUMA_USER("luma_user:", "luma_user", 60 * 60 * 2L),
         LUMA_NUM_LIMIT("luma_num_limit:", "luma次数", 60 * 60 * 48L),
         NF_SET_TIME_LIMIT("nf_set_time_limit:", "设置pin码", 60l),
+        NF_KICKOUT_TIME_LIMIT("nf_kickout_time_limit:", "踢出奈飞设备", 60l),
         GOODS_WHOLESALE_KEY("yh_home_paghe_cache:wholesale_key", "平台批发", 60 * 60 * 4L),
         ;
 

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

@@ -9,7 +9,6 @@ import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
-import com.cyksj.common.util.StringUtil;
 import com.cyksj.common.util.TicketCodeCommonUtil;
 import com.cyksj.mapper.CuiQiuEmailConfigMapper;
 import com.cyksj.model.dto.CuiQiuEmailDetailDto;
@@ -191,11 +190,7 @@ public class CuiQiuMailServiceImpl implements CuiQiuMailService {
 		if (StrUtil.isEmpty(code)) {
 			code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
 		}
-		int length = 4;
-		if (goodsId == 33l || goodsId == 45l) {
-			length = 6;
-		}
-		return StringUtil.getVerifyCodePattern(code, length);
+		return code;
 	}
 
 	/**

+ 1 - 11
netflix-service/src/main/java/com/cyksj/service/mail/impl/YhEmailServiceImpl.java

@@ -1,6 +1,5 @@
 package com.cyksj.service.mail.impl;
 
-import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpStatus;
@@ -111,16 +110,7 @@ public class YhEmailServiceImpl implements YhMailService {
 		if (StrUtil.isEmpty(code)) {
 			code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
 		}
-		int length = 4;
-		if (goodsId == 33l || goodsId == 45l) {
-			length = 6;
-		}
-		code = StringUtil.getVerifyCodePattern(code, length);
-		if (!Validator.isNumber(code)) {
-			log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
-			throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取..");
-		}
-		return code.trim();
+		return code;
 	}
 
 }

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/mange/CmsAccountService.java

@@ -55,4 +55,6 @@ public interface CmsAccountService extends IService<Account> {
 	void batchImportBlockedAccount(Long goodsId, List<Object> accountBlockedList);
 
 	String nfUpgradeDevice(Long accountId) throws Exception;
+
+	String getAccountEmailCode(Long accountId) throws Exception;
 }

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

@@ -475,4 +475,25 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 		}
 		return code;
 	}
+
+	@Override
+	public String getAccountEmailCode(Long accountId) throws Exception {
+		Account at = accountMapper.selectById(accountId);
+		if (at == null || at.getGoodsId() != 1l) {
+			throw BusinessRuntimeException.getInstance("只支持奈飞账号");
+		}
+		String account = at.getAccount();
+		String password = at.getPassword();
+		if (StrUtil.isNotEmpty(at.getRelateEmail())) {
+			account = at.getRelateEmail();
+		}
+		if (StrUtil.hasEmpty(account, password)) {
+			throw BusinessRuntimeException.getInstance("账户异常");
+		}
+		if (cuiQiuMailService.isCuiQiuEmail(account)) {
+			return cuiQiuMailService.getVerifyCode(account, at.getGoodsId(), null, null);
+		}
+		String code = yhMailService.getVerifyCode(account, at.getGoodsId(), null, null);
+		return code;
+	}
 }

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

@@ -24,4 +24,6 @@ public interface GroupsRelationNetflixService {
 	 * 定时设置奈飞座位号
 	 */
 	void timingSetNetflix(Integer num, String nickname, String account, String password, Date expiryTime);
+
+	JSONObject nfKickOut(long userId, Long relationId);
 }

+ 66 - 1
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupsRelationNetflixServiceImpl.java

@@ -109,7 +109,10 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
 		if (!redisService.setNx(RedisService.key.NF_SET_TIME_LIMIT.getName() + relationId, relationId, RedisService.key.NF_SET_TIME_LIMIT.getTimeout())) {
 			throw BusinessRuntimeException.getInstance("一分钟内可执行一次");
 		}
-		return setNetflixSeatNum(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), relation.getExpiryTime(), code);
+		JSONObject jsonObject = setNetflixSeatNum(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), relation.getExpiryTime(), code);
+		relation.setPinCode(code);
+		relationMapper.updateById(relation);
+		return jsonObject;
 	}
 
 	@Override
@@ -176,4 +179,66 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
 		} catch (Exception e) {
 		}
 	}
+
+	@Override
+	public JSONObject nfKickOut(long userId, Long relationId) {
+		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
+		GroupsRelation relation = relationMapper.selectById(relationId);
+		if (!userIdList.contains(relation.getUserId())) {
+			throw BusinessRuntimeException.getInstance("您车票已失效");
+		}
+		GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
+		Account account = accountMapper.selectById(groupsTrips.getAccountId());
+		if (account.getGoodsId() != 1) {
+			throw BusinessRuntimeException.getInstance("系统错误");
+		}
+		User user = userMapper.selectById(relation.getUserId());
+		if (!redisService.setNx(RedisService.key.NF_KICKOUT_TIME_LIMIT.getName()  + relationId, relationId, RedisService.key.NF_KICKOUT_TIME_LIMIT.getTimeout())) {
+			throw BusinessRuntimeException.getInstance("一分钟内可执行一次");
+		}
+		return doNfKickOut(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(),account.getCookie(), relation.getExpiryTime(), relation.getPinCode());
+	}
+
+	/**
+	 * 踢出奈飞设备
+	 */
+	private JSONObject doNfKickOut(Integer seatNum, String seatName, String account, String password, String cookie, Date expiryTime, String code) {
+		JSONObject params = new JSONObject();
+		params.putOpt("username", account);
+		params.putOpt("password", password);
+		params.putOpt("seat_name", seatName);
+		params.putOpt("seat_num", seatNum);
+		params.putOpt("seat_time", expiryTime);
+		if (StrUtil.isNotBlank(code)) {
+			params.putOpt("pin_code", code);
+		}
+		if (StrUtil.isNotEmpty(cookie)) {
+			params.putOpt("cookie", cookie);
+		}
+		//设置座位
+		String url = Constant.ZHAOJU_MOVIES + "/netflix_seat";
+		log.info("设置账号:{} 奈飞用户:{}座位信息", account, seatName);
+		try {
+			HttpResponse<String> res =
+					J11HttpC.custom()
+							.ofPost()
+							.url(url)
+							.headers(J11HttpC.ReqType.raw_json)
+							.body(HttpRequest.BodyPublishers.ofString(Jsons.toJson(params), IoKit.Charsets.UTF_8.getCharset()))
+							.send(HttpResponse.BodyHandlers.ofString());
+			String body = res.body();
+			JSONObject jsonObject = Jsons.parseObject(body, JSONObject.class);
+			JSONObject data = Jsons.parseObject(jsonObject.get("data"), JSONObject.class);
+			Integer status = data.getInt("status");
+			if (status == 2) {
+				log.error("设置用户:{}奈飞座位号失败", seatName);
+			}
+			return data;
+		} catch (Exception e) {
+			log.error("设置用户:{}奈飞座位号错误,msg:{}", seatName, StringUtil.getErrorText(e));
+		}
+		JSONObject jsonObject = new JSONObject();
+		jsonObject.putOpt("status", 2);
+		return jsonObject;
+	}
 }

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

@@ -906,6 +906,16 @@ public class GroupRelationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationNetflixService.getPinStatus(taskId));
     }
 
+    /**
+     * 踢出奈飞设备
+     */
+    @PostMapping("/kickOut/nf/{relationId}")
+    public Result<String> nfKickOut(@PathVariable Long relationId) {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        JSONObject data = groupsRelationNetflixService.nfKickOut(userId, relationId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(data.toString());
+    }
+
     /**
      * 可选 续费升级车票
      */

+ 9 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsAccountController.java

@@ -1293,4 +1293,13 @@ public class CmsAccountController {
 		String url = accountService.nfUpgradeDevice(accountId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(url);
 	}
+
+	/**
+	 * 查看验证码
+	 */
+	@GetMapping("/get/account/email/code")
+	public Result<String> getAccountEmailCode(Long accountId) throws Exception {
+		String code = accountService.getAccountEmailCode(accountId);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(code);
+	}
 }