Przeglądaj źródła

奈飞外部车票登录

zoujiajian 2 lat temu
rodzic
commit
ad3186c66d

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

@@ -334,4 +334,7 @@ public interface Constant {
 	 * 电影域名
 	 */
 	String ZHAOJU_MOVIES = "https://zhaoju666.com";
+
+	//英文
+	String EN_US = "en_US";
 }

+ 2 - 0
netflix-dao/src/main/java/com/cyksj/mapper/GroupsRelationMapper.java

@@ -74,4 +74,6 @@ public interface GroupsRelationMapper extends BaseMapper<GroupsRelation> {
 	Long getExperienceTicket(@Param("userId") Long userId, @Param("skuId") Long skuId);
 
 	Long selectGoodsDonQaByGoodsId(Long goodsId);
+
+	GroupsRelation selectRelationByAccountAndNum(@Param("account") String account, @Param("password") String password, @Param("goodsId") Long goodsId, @Param("num") Integer num);
 }

+ 45 - 0
netflix-dao/src/main/java/com/cyksj/model/request/TicketLoginReq.java

@@ -0,0 +1,45 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: TicketLoginReq
+ * 创建者: JavaZou
+ * 创建时间:2024/7/9 12:13
+ */
+@Getter
+@Setter
+public class TicketLoginReq {
+	@NotEmpty
+	private String account;
+
+	@NotEmpty
+	private String password;
+
+	@NotNull
+	private Integer num;
+
+	private Long goodsId;
+
+	private String lang = "zh_CN";
+
+	private Long relationId;
+
+	/**
+	 * 获取奈飞验证类型
+	 * 1.验证码 2.验证链接
+	 */
+	private Integer type;
+
+	/**
+	 * 是否是奈飞同步操作
+	 */
+	private Boolean sync;
+
+	private Long userId;
+}

+ 13 - 0
netflix-dao/src/main/resources/mapper/GroupRelationMapper.xml

@@ -363,4 +363,17 @@
           and qa.status is true
           and qa.deleted is true
     </select>
+
+    <select id="selectRelationByAccountAndNum" resultType="com.cyksj.model.entity.GroupsRelation">
+        select gr.id, gr.user_id, gr.num
+        from (select id
+              from account
+              where account = #{account}
+                and password = #{password}
+                and goods_id = #{goodsId} limit 1) a
+                 inner join grops_trips gt
+                            on gt.account_id = a.id
+                 inner join groups_relation gr on gr.num = #{num}
+        where gr.expiry_time > now() limit 1
+    </select>
 </mapper>

+ 6 - 1
netflix-service/src/main/java/com/cyksj/service/relation/GroupRelationFrontService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.model.entity.GoodsDonSku;
 import com.cyksj.model.entity.GroupsRelation;
 import com.cyksj.model.request.SpecialGoodsTicketReq;
+import com.cyksj.model.request.TicketLoginReq;
 import com.cyksj.model.views.RenewalView;
 import com.cyksj.model.views.UserRecommendGoodsFrontView;
 import com.ejlchina.searcher.SearchResult;
@@ -38,7 +39,7 @@ public interface GroupRelationFrontService {
 	/**
 	 * 获取车票账号登录 验证码
 	 */
-	String getAiVerifyCode(Long userId, Long relationId, Integer type, Boolean sync) throws Exception;
+	String getAiVerifyCode(TicketLoginReq loginReq) throws Exception;
 
 
 	void checkGroupsAvailParkingNum(Long skuId, Long groupsId, Integer availableParkingNum, Integer maxNum);
@@ -59,4 +60,8 @@ public interface GroupRelationFrontService {
 	void getCollegeStudentUserGptTicket(Long userId);
 
 	RenewalView getTicketDetail(long userId, Long relationId);
+
+	GroupsRelation ticketLogin(TicketLoginReq loginReq);
+
+	String outsideTicketVerify(TicketLoginReq loginReq);
 }

+ 48 - 1
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -28,6 +28,7 @@ import com.cyksj.mapper.manage.distribute.UserPlatSkuDistributeRateMapper;
 import com.cyksj.mapper.sys.SysEmailMapper;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.SpecialGoodsTicketReq;
+import com.cyksj.model.request.TicketLoginReq;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.chatgpt.ChatGptAccountService;
@@ -515,7 +516,11 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 	}
 
 	@Override
-	public String getAiVerifyCode(Long userId, Long relationId, Integer type, Boolean sync) throws Exception {
+	public String getAiVerifyCode(TicketLoginReq loginReq) throws Exception {
+		Long userId = loginReq.getUserId();
+		Long relationId = loginReq.getRelationId();
+		Integer type = loginReq.getType();
+		Boolean sync = loginReq.getSync();
 		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());
@@ -876,6 +881,48 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		return renewalView;
 	}
 
+	@Override
+	public GroupsRelation ticketLogin(TicketLoginReq loginReq) {
+		String account = loginReq.getAccount();
+		String password = loginReq.getPassword();
+		Integer num = loginReq.getNum();
+		Long goodsId = Optional.ofNullable(loginReq.getGoodsId()).orElse(1l);
+		GroupsRelation relation = groupsRelationMapper.selectRelationByAccountAndNum(account, password, goodsId, num);
+		if (relation == null) {
+			log.info("外部入口使用账号account:{},pwd:{},座位num:{}登录失败...", account, password, num);
+			if (StrUtil.equals(loginReq.getLang(), Constant.EN_US)) {
+				throw BusinessRuntimeException.getInstance("Please enter the correct account information");
+			}
+			throw BusinessRuntimeException.getInstance("请输入正确的账号信息");
+		}
+		return relation;
+	}
+
+	@Override
+	public String outsideTicketVerify(TicketLoginReq loginReq) {
+		String account = loginReq.getAccount();
+		String password = loginReq.getPassword();
+		Integer num = loginReq.getNum();
+		Long goodsId = Optional.ofNullable(loginReq.getGoodsId()).orElse(1l);
+		GroupsRelation relation = groupsRelationMapper.selectRelationByAccountAndNum(account, password, goodsId, num);
+		if (relation == null) {
+			log.info("外部入口使用账号account:{},pwd:{},座位num:{}同步验证链接失败...", account, password, num);
+			if (StrUtil.equals(loginReq.getLang(), Constant.EN_US)) {
+				throw BusinessRuntimeException.getInstance("This account is no longer valid");
+			}
+			throw BusinessRuntimeException.getInstance("该账号已失效");
+		}
+		loginReq.setUserId(relation.getUserId());
+		try {
+			return getAiVerifyCode(loginReq);
+		} catch (Exception e) {
+			if (StrUtil.equals(loginReq.getLang(), Constant.EN_US)) {
+				throw BusinessRuntimeException.getInstance("Please verify that the link was sent");
+			}
+			throw BusinessRuntimeException.getInstance("请校验链接是否已发送");
+		}
+	}
+
 	private DistributePosterGoodsDetailView setGoodsPoster(RenewalView ticket, User user) {
 		DistributePosterGoodsDetailView distributePosterGoodsDetailView = beanSearcher.searchFirst(DistributePosterGoodsDetailView.class, MapUtils.flatBuilder(request.getParameterMap())
 				.field(DistributePosterGoodsFrontView::getGoodsId, ticket.getGoodsId()).build());

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

@@ -31,6 +31,7 @@ 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.response.GptStandbyResp;
 import com.cyksj.model.views.*;
 import com.cyksj.redis.RedisService;
@@ -616,10 +617,28 @@ public class GroupRelationController {
     /**
      * 读取车票账号登录验证码
      */
-    @GetMapping("/get/verifyCode/{relationId}")
-    public Result<String> getAiVerifyCode(@PathVariable Long relationId, Integer type, @RequestParam(defaultValue = "0") Boolean sync) throws Exception {
+    @GetMapping("/get/verifyCode")
+    public Result<String> getAiVerifyCode(@RequestBody @Validated TicketLoginReq loginReq) throws Exception {
         long userId = StpUserUtil.getLoginIdAsLong();
-        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(userId, relationId, type, sync));
+        loginReq.setUserId(userId);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(loginReq));
+    }
+
+    /**
+     * 车票后台登录
+     */
+    @GetMapping("/ticket/login")
+    public Result<GroupsRelation> ticketLogin(@RequestBody @Validated TicketLoginReq loginReq) {
+        GroupsRelation relation = groupRelationFrontService.ticketLogin(loginReq);
+        return GatewayResponse.SUCCESS.newBuilder().toResult(relation);
+    }
+
+    /**
+     * 奈飞
+     */
+    @GetMapping("/ticket/verify")
+    public Result<String> outsideTicketVerify(@RequestBody @Validated TicketLoginReq loginReq) {
+        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.outsideTicketVerify(loginReq));
     }
 
     /**