|
@@ -4,13 +4,11 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
|
-import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.http.Method;
|
|
import cn.hutool.http.Method;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.constant.TemplateEnum;
|
|
import com.cyksj.common.constant.TemplateEnum;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
import com.cyksj.common.util.Jsons;
|
|
@@ -20,7 +18,11 @@ import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
import com.cyksj.model.dto.WxMpTemplateData;
|
|
import com.cyksj.model.dto.WxMpTemplateData;
|
|
|
import com.cyksj.model.dto.WxMpTemplateMessage;
|
|
import com.cyksj.model.dto.WxMpTemplateMessage;
|
|
|
-import com.cyksj.model.entity.*;
|
|
|
|
|
|
|
+import com.cyksj.model.entity.Coupon;
|
|
|
|
|
+import com.cyksj.model.entity.CouponUser;
|
|
|
|
|
+import com.cyksj.model.entity.RegisterOrderDon;
|
|
|
|
|
+import com.cyksj.model.entity.SysConfig;
|
|
|
|
|
+import com.cyksj.model.request.SpotifyRegisterReq;
|
|
|
import com.cyksj.model.response.ProxyInfo;
|
|
import com.cyksj.model.response.ProxyInfo;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
@@ -34,8 +36,11 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
|
import java.net.Proxy;
|
|
import java.net.Proxy;
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -98,166 +103,180 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11",
|
|
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11",
|
|
|
"Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10");
|
|
"Mozilla/5.0 (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10");
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void register(Long registerOrderId){
|
|
public void register(Long registerOrderId){
|
|
|
log.info("spotify 注册 orderId:{}",registerOrderId);
|
|
log.info("spotify 注册 orderId:{}",registerOrderId);
|
|
|
RegisterOrderDon registerOrderDon = registerOrderDonMapper.selectById(registerOrderId);
|
|
RegisterOrderDon registerOrderDon = registerOrderDonMapper.selectById(registerOrderId);
|
|
|
- HttpRequest request = new HttpRequest("https://spclient.wg.spotify.com/signup/public/v1/account");
|
|
|
|
|
-
|
|
|
|
|
- request.header("User-Agent", User_Agent_LIST.get(RandomUtil.randomInt(User_Agent_LIST.size())));
|
|
|
|
|
- request.header("Connection","close");
|
|
|
|
|
- //request.header( "Accept","*/*");
|
|
|
|
|
- request.header( "Content-Type","application/x-www-form-urlencoded");
|
|
|
|
|
- request.header( "Referer","https://www.spotify.com/");
|
|
|
|
|
- request.header( "Host","spclient.wg.spotify.com");
|
|
|
|
|
- request.header( "sec-fetch-site", "same-site");
|
|
|
|
|
- request.header( "sec-fetch-mode", "cors");
|
|
|
|
|
- request.header( "sec-fetch-dest", "empty");
|
|
|
|
|
- request.header( "authority", "spclient.wg.spotify.com");
|
|
|
|
|
- request.header( "origin", "https://www.spotify.com");
|
|
|
|
|
-
|
|
|
|
|
- Map<String,Object> jsonObject = new HashMap<>();
|
|
|
|
|
- jsonObject.put("key","a1e486e2729f46d6bb368d6b2bcda326");
|
|
|
|
|
- //creation_point=https://www.spotify.com/uk/
|
|
|
|
|
- jsonObject.put("creation_point","https%3A%2F%2Fwww.spotify.com%2Fus%2F");
|
|
|
|
|
- jsonObject.put("displayname",Optional.ofNullable(registerOrderDon.getNickname()).orElse(registerOrderDon.getEmail()));
|
|
|
|
|
- jsonObject.put("password_repeat",registerOrderDon.getPassword());
|
|
|
|
|
- jsonObject.put("password",registerOrderDon.getPassword());
|
|
|
|
|
- jsonObject.put("username",Optional.ofNullable(registerOrderDon.getUsername()).orElse(registerOrderDon.getEmail()));
|
|
|
|
|
- jsonObject.put("birth_year", Optional.ofNullable(registerOrderDon.getBirthYear()).orElse("1995"));
|
|
|
|
|
- jsonObject.put("birth_month",Optional.ofNullable(registerOrderDon.getBirthMonth()).orElse("01"));
|
|
|
|
|
- jsonObject.put("birth_day",Optional.ofNullable(registerOrderDon.getBirthDay()).orElse("01"));
|
|
|
|
|
- jsonObject.put("gender",registerOrderDon.getGender());
|
|
|
|
|
- jsonObject.put("email",registerOrderDon.getEmail());
|
|
|
|
|
- jsonObject.put("platform","www");
|
|
|
|
|
- jsonObject.put("iagree","1");
|
|
|
|
|
- request.setMethod(Method.POST);
|
|
|
|
|
- request.setConnectionTimeout(15 * 1000);
|
|
|
|
|
- request.setReadTimeout(15 * 1000);
|
|
|
|
|
-
|
|
|
|
|
- request.form(jsonObject);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- int start = 1;
|
|
|
|
|
- int limit = 20;
|
|
|
|
|
- boolean regFlag = false;
|
|
|
|
|
- while (true) {
|
|
|
|
|
|
|
|
|
|
- List<ProxyInfo> proxyInfos = new ArrayList<>();
|
|
|
|
|
- List<Proxys> records = proxysMapper.selectPage(new Page<>(start, limit), Wrappers.lambdaQuery(Proxys.class).orderByDesc(Proxys::getId)).getRecords();
|
|
|
|
|
- if (records.isEmpty()) {
|
|
|
|
|
- log.info("----------代理池内无可用ip 获取付费IP地址----------");
|
|
|
|
|
- ProxyInfo proxyInfo = (ProxyInfo)redisService.get(RedisKey.DOVEIP);
|
|
|
|
|
- if (proxyInfo == null) {
|
|
|
|
|
|
|
+ SpotifyRegisterReq registerReq = new SpotifyRegisterReq();
|
|
|
|
|
+ SpotifyRegisterReq.AccountDetails accountDetails = new SpotifyRegisterReq.AccountDetails();
|
|
|
|
|
+ SpotifyRegisterReq.AccountDetails.EmailAndPasswordIdentifier emailAndPasswordIdentifier = new SpotifyRegisterReq.AccountDetails.EmailAndPasswordIdentifier();
|
|
|
|
|
+ emailAndPasswordIdentifier.setEmail(registerOrderDon.getEmail());
|
|
|
|
|
+ emailAndPasswordIdentifier.setPassword(registerOrderDon.getPassword());
|
|
|
|
|
+ accountDetails.setEmail_and_password_identifier(emailAndPasswordIdentifier);
|
|
|
|
|
+ accountDetails.setBirthdate(Optional.ofNullable(registerOrderDon.getBirthYear()).orElse("1989") + "-" + Optional.ofNullable(registerOrderDon.getBirthMonth()).orElse("10") + "-" + Optional.ofNullable(registerOrderDon.getBirthDay()).orElse("06"));
|
|
|
|
|
+ accountDetails.setDisplay_name(emailAndPasswordIdentifier.getEmail());
|
|
|
|
|
+ accountDetails.setGender(1);
|
|
|
|
|
+ registerReq.setAccount_details(accountDetails);
|
|
|
|
|
|
|
|
- String result = HttpUtil.get("https://dvapi.doveip.com/cmapi.php?rq=distribute&user=1031494735&token=ckc1MUFURnk3bi80MXVxeUFTZUh0Zz09&auth=0&geo=ir&agreement=0&timeout=10&num=1&type_ip=1&repeat=0");
|
|
|
|
|
- log.info("付费ip 请求返回 res:{}",result);
|
|
|
|
|
- /*
|
|
|
|
|
- * {
|
|
|
|
|
- * "errno": 200,
|
|
|
|
|
- * "msg": "Success",
|
|
|
|
|
- * "data": {
|
|
|
|
|
- * "geo": "mx", //国家
|
|
|
|
|
- * "ip": "47.253.12.97", //代理ip
|
|
|
|
|
- * "port": 40076, //代理端口
|
|
|
|
|
- * "d_ip": "201.162.169.86" //目标ip
|
|
|
|
|
- * "timeout": 600 //有效时间(秒)
|
|
|
|
|
- * }
|
|
|
|
|
- * }
|
|
|
|
|
- */
|
|
|
|
|
- JSONObject resObj = JSONUtil.parseObj(result);
|
|
|
|
|
- if (200 == resObj.getInt("errno")) {
|
|
|
|
|
- JSONObject data = resObj.getJSONObject("data");
|
|
|
|
|
- proxyInfo = new ProxyInfo();
|
|
|
|
|
- proxyInfo.setPort(data.getInt("port"));
|
|
|
|
|
- proxyInfo.setIp(data.getStr("ip"));
|
|
|
|
|
- log.info("----------付费IP地址----------\n ip:{}",proxyInfo);
|
|
|
|
|
- proxyInfos.add(proxyInfo);
|
|
|
|
|
- redisService.set(RedisKey.DOVEIP,proxyInfo,data.getLong("timeout"));
|
|
|
|
|
- }else {
|
|
|
|
|
- log.error("----------获取 付费IP 错误 停止循环----------");
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
- proxyInfos.add(proxyInfo);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
|
+ map.put("User-Agent", User_Agent_LIST.get(RandomUtil.randomInt(User_Agent_LIST.size())));
|
|
|
|
|
+ map.put( "authority","spclient.wg.spotify.com");
|
|
|
|
|
+ map.put( "method","POST");
|
|
|
|
|
+ map.put("Host","spclient.wg.spotify.com");
|
|
|
|
|
+ map.put("Accept", "*/*");
|
|
|
|
|
+ map.put( "path","/signup/public/v2/account/create");
|
|
|
|
|
+ map.put( "Referer", "https://www.spotify.com/");
|
|
|
|
|
+ map.put("Content-Type", "application/json; charset=utf-8");
|
|
|
|
|
+ map.put("Origin", "https://www.spotify.com");
|
|
|
|
|
+ map.put("Connection", "keep-alive");
|
|
|
|
|
+ map.put("sec-ch-ua", "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"");
|
|
|
|
|
+ map.put("sec-ch-ua-mobile", "?0");
|
|
|
|
|
+ map.put("sec-ch-ua-platform", "Windows");
|
|
|
|
|
+ map.put("Sec-Fetch-Dest", "empty");
|
|
|
|
|
+ map.put("Sec-Fetch-Mode", "cors");
|
|
|
|
|
+ map.put("Sec-Fetch-Site", "same-site");
|
|
|
|
|
+ map.put("referrer-policy", "strict-origin-when-cross-origin");
|
|
|
|
|
+ CopyOnWriteArrayList<ProxyInfo> proxyInfos = (CopyOnWriteArrayList<ProxyInfo>) redisService.get(RedisKey.IP_LIST);
|
|
|
|
|
+ if (proxyInfos == null || proxyInfos.size() == 0) {
|
|
|
|
|
+ //String res = HttpUtil.get("http://api.proxy.ipidea.io/getProxyIp?num=30&return_type=json&lb=1&sb=0&flow=1®ions=&protocol=http");
|
|
|
|
|
+ //JSONObject jsonObject = JSONUtil.parseObj(res);
|
|
|
|
|
+ //JSONArray data = jsonObject.getJSONArray("data");
|
|
|
|
|
+ //proxyInfos = new CopyOnWriteArrayList<>(data.toList(ProxyInfo.class));
|
|
|
|
|
|
|
|
- proxyInfos.addAll(records.stream().map((proxy) -> {
|
|
|
|
|
|
|
+ String result = HttpUtil.get("https://dvapi.doveip.com/cmapi.php?rq=distribute&user=1031494735&token=ckc1MUFURnk3bi80MXVxeUFTZUh0Zz09&auth=0&geo=tr&agreement=0&timeout=10&num=1&type_ip=1&repeat=0");
|
|
|
|
|
+ log.info("付费ip 请求返回 res:{}",result);
|
|
|
|
|
+ /*
|
|
|
|
|
+ * {
|
|
|
|
|
+ * "errno": 200,
|
|
|
|
|
+ * "msg": "Success",
|
|
|
|
|
+ * "data": {
|
|
|
|
|
+ * "geo": "mx", //国家
|
|
|
|
|
+ * "ip": "47.253.12.97", //代理ip
|
|
|
|
|
+ * "port": 40076, //代理端口
|
|
|
|
|
+ * "d_ip": "201.162.169.86" //目标ip
|
|
|
|
|
+ * "timeout": 600 //有效时间(秒)
|
|
|
|
|
+ * }
|
|
|
|
|
+ * }
|
|
|
|
|
+ */
|
|
|
|
|
+ JSONObject resObj = JSONUtil.parseObj(result);
|
|
|
|
|
+ if (200 == resObj.getInt("errno")) {
|
|
|
|
|
+ JSONObject data = resObj.getJSONObject("data");
|
|
|
ProxyInfo proxyInfo = new ProxyInfo();
|
|
ProxyInfo proxyInfo = new ProxyInfo();
|
|
|
- proxyInfo.setIp(proxy.getIp());
|
|
|
|
|
- proxyInfo.setPort(proxy.getPort());
|
|
|
|
|
- return proxyInfo;
|
|
|
|
|
- }).collect(Collectors.toList()));
|
|
|
|
|
-
|
|
|
|
|
|
|
+ proxyInfo.setPort(data.getInt("port"));
|
|
|
|
|
+ proxyInfo.setIp(data.getStr("ip"));
|
|
|
|
|
+ log.info("----------付费IP地址----------\n ip:{}",proxyInfo);
|
|
|
|
|
+ proxyInfos = new CopyOnWriteArrayList<>();
|
|
|
|
|
+ proxyInfos.add(proxyInfo);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ log.error("----------获取 付费IP 错误 停止循环----------");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ int count = 1;
|
|
|
|
|
+ while (count <= 10) {
|
|
|
|
|
+ boolean flag = false;
|
|
|
for (ProxyInfo proxyInfo : proxyInfos) {
|
|
for (ProxyInfo proxyInfo : proxyInfos) {
|
|
|
try {
|
|
try {
|
|
|
log.info("执行:info:{}", proxyInfo);
|
|
log.info("执行:info:{}", proxyInfo);
|
|
|
|
|
+
|
|
|
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
|
|
Proxy proxy = new Proxy(Proxy.Type.SOCKS,
|
|
|
new InetSocketAddress(proxyInfo.getIp(), proxyInfo.getPort()));
|
|
new InetSocketAddress(proxyInfo.getIp(), proxyInfo.getPort()));
|
|
|
|
|
+ //OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).build();
|
|
|
|
|
+ //log.info("spotify request body :{}",JSONUtil.toJsonStr(registerReq));
|
|
|
|
|
+ //RequestBody requestBody = FormBody.create(JSONUtil.toJsonStr(registerReq),MediaType.parse("application/json; charset=utf-8"));
|
|
|
|
|
+ //
|
|
|
|
|
+ //Request request = new Request.Builder()
|
|
|
|
|
+ // .url("https://spclient.wg.spotify.com/signup/public/v2/account/create")
|
|
|
|
|
+ // .post(requestBody)
|
|
|
|
|
+ // .headers(Headers.of(map))
|
|
|
|
|
+ // .build();
|
|
|
|
|
+ //
|
|
|
|
|
+ //okhttp3.Response response = client.newCall(request).execute();
|
|
|
|
|
+ //ResponseBody body = response.body();
|
|
|
|
|
+ HttpRequest request = new HttpRequest("https://spclient.wg.spotify.com/signup/public/v2/account/create");
|
|
|
request.setProxy(proxy);
|
|
request.setProxy(proxy);
|
|
|
- HttpResponse response = request.execute();
|
|
|
|
|
- String body = response.body();
|
|
|
|
|
- log.info("spotify 返回body:{}", body);
|
|
|
|
|
- JSONObject resObj = JSONUtil.parseObj(body);
|
|
|
|
|
- JSONObject errors = resObj.getJSONObject("errors");
|
|
|
|
|
|
|
+ request.body(JSONUtil.toJsonStr(registerReq));
|
|
|
|
|
+ request.addHeaders(map);
|
|
|
|
|
+ request.setMethod(Method.POST);
|
|
|
|
|
+ request.setConnectionTimeout(15 * 1000);
|
|
|
|
|
+ request.setReadTimeout(15 * 1000);
|
|
|
|
|
+ String spotifyBody = request.execute().body();
|
|
|
|
|
|
|
|
- Integer status = resObj.getInt("status");
|
|
|
|
|
- if (status == 320) {
|
|
|
|
|
- String errorMsg = errors.getStr("generic_error");
|
|
|
|
|
- if (StringUtils.isNotBlank(errorMsg) || "你似乎正在使用代理服务。请关闭此类服务,然后再试一次。如需更多帮助,请联系客户服务。".equals(errorMsg) || errorMsg.contains("代理")) {
|
|
|
|
|
- log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}", proxyInfo.getIp());
|
|
|
|
|
- if (proxyInfo.getId() != null) {
|
|
|
|
|
- int count = proxysMapper.deleteById(proxyInfo.getId());
|
|
|
|
|
- }else {
|
|
|
|
|
- redisService.del(RedisKey.DOVEIP);
|
|
|
|
|
|
|
+ log.info("spotify 返回body:{}", spotifyBody);
|
|
|
|
|
+ /*
|
|
|
|
|
+ {
|
|
|
|
|
+ "error":{
|
|
|
|
|
+ "error_details":{
|
|
|
|
|
+ "code":2,
|
|
|
|
|
+ "title":"请检查你的详细信息,然后再试一次。",
|
|
|
|
|
+ "body":"此电子邮件已关联至某个帐号。请登录你的帐号,或使用其他电子邮件注册。",
|
|
|
|
|
+ "already_exists":{
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- continue;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(resObj.getStr("login_token"))) {
|
|
|
|
|
- log.info("注册成功!");
|
|
|
|
|
- registerOrderDon.setStatus(RegisterOrderDon.Status.complete);
|
|
|
|
|
- registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
|
|
- regFlag = true;
|
|
|
|
|
- //注册成功发放模板消息
|
|
|
|
|
- spotifyTemplateMsg(registerOrderDon, String.format("%s%s", envCommonService.getDomain(), "yinhe/web/sign/list"), true);
|
|
|
|
|
- //注册成功发放声破天优惠券
|
|
|
|
|
- sendSpotifyCoupon(registerOrderDon);
|
|
|
|
|
- break;
|
|
|
|
|
- } else {
|
|
|
|
|
- if (errors != null && !errors.isEmpty()) {
|
|
|
|
|
- StringBuilder error = new StringBuilder();
|
|
|
|
|
- for (String str : errors.keySet()) {
|
|
|
|
|
- error.append(errors.getStr(str));
|
|
|
|
|
- }
|
|
|
|
|
- registerOrderDon.setErrorMsg(error.toString());
|
|
|
|
|
- registerOrderDon.setStatus(RegisterOrderDon.Status.error);
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+ /*
|
|
|
|
|
+ {
|
|
|
|
|
+ "success": {
|
|
|
|
|
+ "username": "31naixo6v3uydhvcp63sya57ozae",
|
|
|
|
|
+ "login_token": "N7N9gHZ3QeG74yHWAx8hAw"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+ JSONObject resObj = JSONUtil.parseObj(spotifyBody);
|
|
|
|
|
+ log.info("spotify 返回:{}",resObj);
|
|
|
|
|
+ JSONObject error = resObj.getJSONObject("error");
|
|
|
|
|
+ if (error.isEmpty()) {
|
|
|
|
|
+ JSONObject success = resObj.getJSONObject("success");
|
|
|
|
|
+ if (StringUtils.isNotBlank(success.getStr("login_token")) || StringUtils.isNotBlank("username")) {
|
|
|
|
|
+ log.info("注册成功!");
|
|
|
|
|
+ registerOrderDon.setStatus(RegisterOrderDon.Status.complete);
|
|
|
registerOrderDonMapper.updateById(registerOrderDon);
|
|
registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
- regFlag = true;
|
|
|
|
|
- //注册失败发放模板消息
|
|
|
|
|
- spotifyTemplateMsg(registerOrderDon, String.format("%s%s", envCommonService.getDomain(), "yinhe/web/sign/list"), false);
|
|
|
|
|
|
|
+ //注册成功发放模板消息
|
|
|
|
|
+ spotifyTemplateMsg(registerOrderDon, String.format("%s%s", envCommonService.getDomain(), "yinhe/web/sign/list"), true);
|
|
|
|
|
+ //注册成功发放声破天优惠券
|
|
|
|
|
+ sendSpotifyCoupon(registerOrderDon);
|
|
|
|
|
+ flag = true;
|
|
|
break;
|
|
break;
|
|
|
|
|
+ }else if(!resObj.getJSONObject("challenge").isEmpty()) {
|
|
|
|
|
+ log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}", proxyInfo.getIp());
|
|
|
|
|
+ proxyInfos.remove(proxyInfo);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- if (proxyInfo.getId() != null) {
|
|
|
|
|
- proxysMapper.deleteById(proxyInfo.getId());
|
|
|
|
|
}else {
|
|
}else {
|
|
|
- redisService.del(RedisKey.DOVEIP);
|
|
|
|
|
|
|
+ JSONObject error_details = error.getJSONObject("error_details");
|
|
|
|
|
+ String errorMsg = error_details.getStr("body");
|
|
|
|
|
+ Integer code = error_details.getInt("code");
|
|
|
|
|
+ if (code.equals(4) || "你的设备似乎已连接至代理或 VPN 服务。请关闭此类服务,然后再试一次。".equals(errorMsg) || errorMsg.contains("代理")) {
|
|
|
|
|
+ log.info("spotify 注册 被监测出代理服务 。 删除该代理 ip:{}", proxyInfo.getIp());
|
|
|
|
|
+ proxyInfos.remove(proxyInfo);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //{"error":{"error_details":{"code":2,"title":"请检查你的详细信息,然后再试一次。","body":"此电子邮件已关联至某个帐号。请登录你的帐号,或使用其他电子邮件注册。","already_exists":{}}}}
|
|
|
|
|
+ registerOrderDon.setErrorMsg(error_details.getStr("body"));
|
|
|
|
|
+ registerOrderDon.setStatus(RegisterOrderDon.Status.error);
|
|
|
|
|
+ registerOrderDonMapper.updateById(registerOrderDon);
|
|
|
|
|
+
|
|
|
|
|
+ //注册失败发放模板消息
|
|
|
|
|
+ spotifyTemplateMsg(registerOrderDon, String.format("%s%s", envCommonService.getDomain(), "yinhe/web/sign/list"), false);
|
|
|
|
|
+ flag = true;
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ proxyInfos.remove(proxyInfo);
|
|
|
log.error("错误 ip:{}", proxyInfo.getIp());
|
|
log.error("错误 ip:{}", proxyInfo.getIp());
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ count++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (regFlag) {
|
|
|
|
|
|
|
+ if(flag){
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ redisService.set(RedisKey.IP_LIST,proxyInfos,360L);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void sendSpotifyCoupon(RegisterOrderDon registerOrderDon) {
|
|
private void sendSpotifyCoupon(RegisterOrderDon registerOrderDon) {
|
|
@@ -293,5 +312,4 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
weChatService.sendTemplateMessage(weChatService.getAccessToken(), Jsons.toJson(templateMessage));
|
|
weChatService.sendTemplateMessage(weChatService.getAccessToken(), Jsons.toJson(templateMessage));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|