Преглед изворни кода

gpt独立会员批量导入

zoujiajian пре 3 месеци
родитељ
комит
c3c7fd33c9

+ 49 - 0
netflix-dao/src/main/java/com/cyksj/model/dto/MailCodeResponseDTO.java

@@ -0,0 +1,49 @@
+package com.cyksj.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class MailCodeResponseDTO {
+
+    private Integer code;
+
+    private String message;
+
+    private Long timestamp;
+
+    private Data data;
+
+    @Getter
+    @Setter
+    public static class Data {
+
+        private Boolean alive;
+
+        private String email_address;
+
+        private Boolean has_new_mail;
+
+        private String project;
+
+        private String verification_code;
+
+        private LatestMail latest_mail;
+    }
+
+    @Getter
+    @Setter
+    public static class LatestMail {
+
+        private String from;
+
+        private String subject;
+
+        private String received_at;
+
+        private String message_id;
+
+        private String excerpt;
+    }
+}

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

@@ -147,4 +147,9 @@ public class Account extends BaseEntity {
      * 谷歌身份认证器
      */
     private String googleAuth;
+
+    /**
+     * 邮箱授权码
+     */
+    private String emailAuthCode;
 }

+ 7 - 0
netflix-dao/src/main/java/com/cyksj/model/excel/ExcelManageAccountData.java

@@ -165,4 +165,11 @@ public class ExcelManageAccountData {
 	@DbField("a.remark")
 	@ExcelProperty("备注")
 	private String remark;
+
+    /**
+     * 邮箱授权码
+     */
+    @DbField("a.email_auth_code")
+    @ExcelProperty("邮箱授权码")
+    private String emailAuthCode;
 }

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

@@ -224,4 +224,10 @@ public class AccountView {
      */
     @DbField("a.google_auth")
     private String googleAuth;
+
+    /**
+     * 邮箱授权码
+     */
+    @DbField("a.email_auth_code")
+    private String emailAuthCode;
 }

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

@@ -57,6 +57,12 @@ public class GroupsRelationView {
     @DbField("if(a.api_secret='',false,true)")
     private Boolean isVerify;
 
+    /**
+     * 邮箱授权码
+     */
+    @DbField("a.email_auth_code")
+    private String emailAuthCode;
+
     @DbField("gr.verify_code")
     private String verifyCode;
 

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

@@ -414,6 +414,12 @@ public class RenewalView {
     @DbField("a.user_side_remark")
     private String userSideRemark;
 
+    /**
+     * 邮箱授权码
+     */
+    @DbField("a.email_auth_code")
+    private String emailAuthCode;
+
     /**
      * 分类id
      */

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

@@ -411,6 +411,13 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 									}
 								}
 							}
+                            //GPT 独立会员
+                            if (goodsId == Constant.GPT_PLUS_GID) {
+                                //邮箱授权码
+                                String emailAutoCode = part[2];
+                                insert.setEmailAuthCode(emailAutoCode);
+                                insert.setGptEmailPwd(null);
+                            }
 						}
 					}
 				}

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

@@ -135,4 +135,6 @@ public interface GroupRelationFrontService {
 	List<GoodsCategorySkuView> getYoutubeReplaceOtherSkus() throws Exception;
 
 	OrderRefundDto getYoutubeRefundInfo(long userId, Long relationId);
+
+    String getEmailCode(long userId, Long relationId) throws Exception;
 }

+ 43 - 5
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -9,6 +9,9 @@ import cn.hutool.core.lang.Assert;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.cyksj.common.constant.Constant;
@@ -30,10 +33,7 @@ import com.cyksj.mapper.sys.SysConfigMapper;
 import com.cyksj.mapper.sys.SysEmailMapper;
 import com.cyksj.mapper.vip.VipGoodsSkuMapper;
 import com.cyksj.mapper.vip.VipUserMapper;
-import com.cyksj.model.dto.ErrorNetflixChangeOtherSkuTicketDto;
-import com.cyksj.model.dto.NetflixRecoverReceivedGptConditionDto;
-import com.cyksj.model.dto.OrderRefundDto;
-import com.cyksj.model.dto.TicketChangeDto;
+import com.cyksj.model.dto.*;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.AccountView;
 import com.cyksj.model.manage.views.GroupsRelationView;
@@ -353,6 +353,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 						ticket.setGptEmailPwd(null);
 					}
 				}
+                //邮箱授权码非必填,填的话就不显示邮箱密码
+                if (StrUtil.isNotEmpty(ticket.getEmailAuthCode())) {
+                    ticket.setGptEmailPwd(null);
+                }
 				if (isLoginPopularize != null && isLoginPopularize) {
 					GoodsDonViews views = beanSearcher.searchFirst(GoodsDonViews.class, MapUtils.builder().field(GoodsDonViews::getId, ticket.getGoodsId()).build());
 					views.setSpecs(beanSearcher.searchFirst(GoodsDonSpecFrontView.class, MapUtils.builder().field(GoodsDonSpecFrontView::getGoodsId, views.getId()).build()));
@@ -2692,7 +2696,41 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		return null;
 	}
 
-	private GroupsRelationView checkYoutubeTime(Long relationId, Long userId) {
+    @Override
+    public String getEmailCode(long userId, Long relationId) throws Exception {
+        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.GPT_PLUS_GID)
+                .build());
+        if (relationView != null && StrUtil.isNotEmpty(relationView.getEmailAuthCode())) {
+            String session_url = "https://mail.cpacc.us.ci/api/open";
+
+            JSONObject params = new JSONObject();
+            params.putOpt("mailbox_token", relationView.getEmailAuthCode());
+
+            HttpResponse result = HttpUtil.createPost(session_url)
+                    .header("sec-fetch-site", "same-origin")
+                    .setConnectionTimeout(Constant.CONNECT_MILLISECONDS)
+                    .body(params.toString())
+                    .execute();
+            JSONObject jsonObject = Jsons.parseObject(result.body(), JSONObject.class);
+            String session = jsonObject.getStr("box_session");
+
+            String getCodeUrl = "https://mail.cpacc.us.ci/api/code";
+            HttpResponse execute = HttpUtil.createGet(getCodeUrl)
+                    .header("authorization", "Bearer " + session)
+                    .setConnectionTimeout(Constant.CONNECT_MILLISECONDS)
+                    .execute();
+            MailCodeResponseDTO mailCodeResponseDTO = Jsons.parseObject(execute.body(), MailCodeResponseDTO.class);
+            return mailCodeResponseDTO.getData().getVerification_code();
+        }
+        return null;
+
+    }
+
+    private GroupsRelationView checkYoutubeTime(Long relationId, Long userId) {
 		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		GroupsRelationView relationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
 				.field(GroupsRelationView::getId, relationId)

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

@@ -1202,6 +1202,15 @@ public class GroupRelationController {
         return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
     }
 
+    /**
+     * 获取邮箱验证码
+     */
+    @GetMapping("/get/email/code")
+    public Result<String> getEmailCode(Long relationId) throws Exception {
+        long userId = StpUserUtil.getLoginIdAsLong();
+        return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getEmailCode(userId, relationId));
+    }
+
     /**
      * 获取GPT PLUS登录验证码
      */