Jelajahi Sumber

新增appid导入格式判断

zoujiajian 2 tahun lalu
induk
melakukan
9f23802b7c

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

@@ -116,6 +116,11 @@ public interface Constant {
 
 	String AMERICA_APPID_SECRET = "1990-01-01 朋友 aaa111 工作 aab112 父母 aac113";
 
+	/**
+	 * 最新appid文件导入格式
+	 */
+	String NEW_APPID_SECRET = "朋友 %s 工作 %s 父母 %s 国家 %s";
+
 	String ACCOUNT_DOUBLE_VERIFY_KEY = "account_double_verify_key";
 
 	/**

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

@@ -2,6 +2,7 @@ package com.cyksj.service.mange.account;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.RandomUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -216,81 +217,98 @@ public class CmsAccountServiceImpl extends ServiceImpl<AccountMapper, Account> i
 		try {
 			accountList.forEach(accountData -> {
 				Map<String, Object> map = Jsons.toMap(accountData);
-				String[] part = map.get("0").toString().split(regex);
-				if (part.length >= 2) {
-					String account = part[0];
-					String password = part[1];
-					//重复不再重新插入
-					if (accountCommonService.checkIsDupAccount(goodsId, account)) {
-						return;
-					}
-					Account insert = new Account();
+				Account insert = new Account();
+				insert.setGoodsId(goodsId);
+				if (map.keySet().size() >= 6) {
+					String account = map.get("0").toString();
+					String password = map.get("1").toString();
+					String friend = map.get("2").toString();
+					String work = map.get("3").toString();
+					String parents = map.get("4").toString();
+					String country = map.get("5").toString();
+					String secret = String.format(Constant.NEW_APPID_SECRET, friend, work, parents, country);
 					insert.setAccount(account);
 					insert.setPassword(password);
-					if (part.length > 2 && part.length < 9) {
-						//google36、辅助邮箱
-						//46 Google Bard
-						if (special_email_goods_ids.contains(goodsId)) {
-							String email = part[2];
-							insert.setEmail(email);
-						} else {
-							String apiKey = part[2];
-							insert.setApiKey(apiKey);
-						}
-					}
-					insert.setGoodsId(goodsId);
-					if (goodsId.equals(31l)) {
-						if (part.length >= 9) {
-							StringBuilder sb = new StringBuilder();
-							String country = part[part.length - 1];
-							if (country.contains("国")) {
-								sb.append(part[part.length - 1]);
-								sb.append(Constant.ONE_EMPTY);
-								sb.append(part[part.length - 2]);
-								sb.append(Constant.ONE_EMPTY);
+					insert.setSecret(secret);
+				} else {
+					String[] part = map.get("0").toString().split(regex);
+					if (part.length >= 2) {
+						String account = part[0];
+						String password = part[1];
+						insert.setAccount(account);
+						insert.setPassword(password);
+						if (part.length > 2 && part.length < 9) {
+							//google36、辅助邮箱
+							//46 Google Bard
+							if (special_email_goods_ids.contains(goodsId)) {
+								String email = part[2];
+								insert.setEmail(email);
+							} else {
+								String apiKey = part[2];
+								insert.setApiKey(apiKey);
 							}
-							for (int i = 2; i < part.length; i++) {
-								if (part[i].contains("朋友")) {
-									sb.append("朋友");
+						}
+						if (goodsId.equals(31l)) {
+							if (part.length >= 9) {
+								StringBuilder sb = new StringBuilder();
+								String country = part[part.length - 1];
+								if (country.contains("国")) {
+									sb.append(part[part.length - 1]);
 									sb.append(Constant.ONE_EMPTY);
-									sb.append(part[i + 1]);
-									i++;
-								}
-								if (part[i].contains("工作")) {
-									sb.append("工作");
+									sb.append(part[part.length - 2]);
 									sb.append(Constant.ONE_EMPTY);
-									sb.append(part[i + 1]);
-									i++;
 								}
-								if (part[i].contains("父母")) {
-									sb.append("父母");
-									sb.append(Constant.ONE_EMPTY);
-									sb.append(part[i + 1]);
-									i++;
+								for (int i = 2; i < part.length; i++) {
+									if (part[i].contains("朋友")) {
+										sb.append("朋友");
+										sb.append(Constant.ONE_EMPTY);
+										sb.append(part[i + 1]);
+										i++;
+									}
+									if (part[i].contains("工作")) {
+										sb.append("工作");
+										sb.append(Constant.ONE_EMPTY);
+										sb.append(part[i + 1]);
+										i++;
+									}
+									if (part[i].contains("父母")) {
+										sb.append("父母");
+										sb.append(Constant.ONE_EMPTY);
+										sb.append(part[i + 1]);
+										i++;
+									}
 								}
+								insert.setSecret(sb.toString());
+							} else {
+								insert.setSecret(Constant.AMERICA_APPID_SECRET);
 							}
-							insert.setSecret(sb.toString());
-						} else {
-							insert.setSecret(Constant.AMERICA_APPID_SECRET);
 						}
 					}
-					this.save(insert);
-					//是否存在未发车的车队
-					GroupsTrips waiting = cmsGroupService.getOne(Wrappers.lambdaQuery(GroupsTrips.class)
-							.eq(GroupsTrips::getSkuId, skuId)
-							.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting).last("limit 1"));
-					if (waiting != null) {
-						waiting.setAccountId(insert.getId());
-						try {
-							cmsGroupService.setAccount(waiting);
-						} catch (Exception e) {
-							//自动配置车队
-							setGroupsTrips(skuId, insert.getId());
-						}
-					} else {
+				}
+				String account = insert.getAccount();
+				if (StrUtil.isEmpty(account)) {
+					return;
+				}
+				//重复不再重新插入
+				if (accountCommonService.checkIsDupAccount(goodsId, account)) {
+					return;
+				}
+				this.save(insert);
+				//是否存在未发车的车队
+				GroupsTrips waiting = cmsGroupService.getOne(Wrappers.lambdaQuery(GroupsTrips.class)
+						.eq(GroupsTrips::getSkuId, skuId)
+						.eq(GroupsTrips::getStatus, GroupsTrips.Status.waiting).last("limit 1"));
+				if (waiting != null) {
+					waiting.setAccountId(insert.getId());
+					try {
+						cmsGroupService.setAccount(waiting);
+					} catch (Exception e) {
 						//自动配置车队
 						setGroupsTrips(skuId, insert.getId());
 					}
+				} else {
+					//自动配置车队
+					setGroupsTrips(skuId, insert.getId());
 				}
 			});
 		} catch (Exception e) {