|
|
@@ -6,13 +6,14 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
-import com.cyksj.common.util.J11HttpC;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.mapper.*;
|
|
|
@@ -37,11 +38,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.net.http.HttpResponse;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_ALREADY_BE_USER;
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_NOT_FIND;
|
|
|
@@ -84,6 +83,10 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private final OrderDiscountPlusPurchaseSkuRelationMapper orderDiscountPlusPurchaseSkuRelationMapper;
|
|
|
|
|
|
+ private final GroupsRelationLoginCodeRecordMapper groupsRelationLoginCodeRecordMapper;
|
|
|
+
|
|
|
+ private final SysEmailMapper sysEmailMapper;
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
private final static String VERIFY_CODE_SECRET = "q1w2e3";
|
|
|
@@ -411,24 +414,49 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (renewalView == null) {
|
|
|
throw BusinessRuntimeException.getInstance("您的车票不存在...");
|
|
|
}
|
|
|
+ if (StrUtil.isEmpty(renewalView.getAccount())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("车票未配置账号");
|
|
|
+ }
|
|
|
String account = renewalView.getAccount();
|
|
|
String password = renewalView.getPassword();
|
|
|
if (StrUtil.hasEmpty(account, password)) {
|
|
|
throw BusinessRuntimeException.getInstance("您的车票账号密码异常,请联系客服...");
|
|
|
}
|
|
|
- String url = String.format("http://yinhelx.com/api/imap_yhcz.php?sc=&id=&yhm=%s&mm=%s&duan_kou=143&ip=127.0.0.1&mi_yao=%s", account, password, VERIFY_CODE_SECRET);
|
|
|
- HttpResponse<String> send = J11HttpC.custom()
|
|
|
- .ofGet()
|
|
|
- .url(url)
|
|
|
- .send(HttpResponse.BodyHandlers.ofString());
|
|
|
- if (send.statusCode() != HttpStatus.HTTP_OK) {
|
|
|
- throw BusinessRuntimeException.getInstance("获取验证码失败...");
|
|
|
+ //获取邮箱密码
|
|
|
+ SysEmail sysEmail = sysEmailMapper.selectOne(Wrappers.lambdaQuery(SysEmail.class)
|
|
|
+ .eq(SysEmail::getEmail, account)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (sysEmail == null) {
|
|
|
+ log.info("获取账号:{}验证码异常,未配置对应系统邮箱", account);
|
|
|
+ throw BusinessRuntimeException.getInstance("获取账号验证码异常,请联系客服...");
|
|
|
}
|
|
|
- String code = StrUtil.subBetween(send.body(), "Doğrulama kodunuz:", "Bu istek sizin");
|
|
|
- if (StrUtil.isEmpty(code)) {
|
|
|
- throw BusinessRuntimeException.getInstance("获取验证码失败...");
|
|
|
+ String url = "http://yinhelx.com/api/controller.php";
|
|
|
+ Map<String,Object> params = new HashMap<>();
|
|
|
+
|
|
|
+ params.put("imap_key", "imap_56568niua@@");
|
|
|
+ params.put("fun", "imap_read");
|
|
|
+ params.put("imap_ip", "yinhelx.com");
|
|
|
+ params.put("port", "143");
|
|
|
+ params.put("username", account);
|
|
|
+ params.put("password", sysEmail.getPassword());
|
|
|
+ params.put("mbox_id", "0");
|
|
|
+ params.put("delete", "0");
|
|
|
+
|
|
|
+ HttpRequest post = HttpUtil.createPost(url);
|
|
|
+ post.form(params);
|
|
|
+ cn.hutool.http.HttpResponse execute = post.execute();
|
|
|
+ if (execute.getStatus() != HttpStatus.HTTP_OK) {
|
|
|
+ throw BusinessRuntimeException.getInstance("获取验证码异常,请联系客服...");
|
|
|
}
|
|
|
- return code.trim();
|
|
|
+ String code = getDifferentGoodsCode(renewalView.getGoodsId(), execute.body());
|
|
|
+ GroupsRelationLoginCodeRecord record = new GroupsRelationLoginCodeRecord();
|
|
|
+ record.setUserId(userId);
|
|
|
+ record.setRelationId(relationId);
|
|
|
+ record.setAccount(renewalView.getAccount());
|
|
|
+ record.setGoodsId(renewalView.getGoodsId());
|
|
|
+ record.setSkuId(renewalView.getSkuId());
|
|
|
+ groupsRelationLoginCodeRecordMapper.insert(record);
|
|
|
+ return code;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -522,4 +550,32 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public String getDifferentGoodsCode(Long goodsId, String body) {
|
|
|
+ String code = null;
|
|
|
+ //奈飞
|
|
|
+ if (goodsId == 1) {
|
|
|
+ code = StrUtil.subBetween(body, "Doğrulama kodunuz:", "Bu istek sizin");
|
|
|
+ }
|
|
|
+ //迪士尼
|
|
|
+ if (goodsId == 3) {
|
|
|
+ code = StrUtil.subWithLength(body, body.indexOf(" 15 "), 215);
|
|
|
+ if (StrUtil.isNotEmpty(code)) {
|
|
|
+ Pattern pattern = Pattern.compile("\\d{6}");
|
|
|
+ Matcher matcher = pattern.matcher(code);
|
|
|
+ while (matcher.find()) {
|
|
|
+ code = matcher.group();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Validator.isNumber(code)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取");
|
|
|
+ }
|
|
|
+ if (StrUtil.isEmpty(code)) {
|
|
|
+ log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
|
|
|
+ throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取...");
|
|
|
+ }
|
|
|
+ return code.trim();
|
|
|
+ }
|
|
|
}
|