|
|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.constant.TemplateEnum;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.RedisKey;
|
|
|
import com.cyksj.mapper.ProxysMapper;
|
|
|
import com.cyksj.mapper.RegisterOrderDonMapper;
|
|
|
@@ -41,6 +42,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -105,7 +107,7 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void register(Long registerOrderId){
|
|
|
+ public synchronized void register(Long registerOrderId){
|
|
|
log.info("spotify 注册 orderId:{}",registerOrderId);
|
|
|
RegisterOrderDon registerOrderDon = registerOrderDonMapper.selectById(registerOrderId);
|
|
|
|
|
|
@@ -174,9 +176,10 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- int count = 1;
|
|
|
- while (count <= 10) {
|
|
|
+ AtomicInteger count = new AtomicInteger(1);
|
|
|
+ while (count.get() <= 3) {
|
|
|
boolean flag = false;
|
|
|
+ count.addAndGet(1);
|
|
|
for (ProxyInfo proxyInfo : proxyInfos) {
|
|
|
try {
|
|
|
log.info("执行:info:{}", proxyInfo);
|
|
|
@@ -230,7 +233,7 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
JSONObject resObj = JSONUtil.parseObj(spotifyBody);
|
|
|
log.info("spotify 返回:{}",resObj);
|
|
|
JSONObject error = resObj.getJSONObject("error");
|
|
|
- if (error.isEmpty()) {
|
|
|
+ if (error == null || error.isEmpty()) {
|
|
|
JSONObject success = resObj.getJSONObject("success");
|
|
|
if (StringUtils.isNotBlank(success.getStr("login_token")) || StringUtils.isNotBlank("username")) {
|
|
|
log.info("注册成功!");
|
|
|
@@ -268,11 +271,13 @@ public class SpotifyServiceImpl implements SpotifyService {
|
|
|
} catch (Exception e) {
|
|
|
proxyInfos.remove(proxyInfo);
|
|
|
log.error("错误 ip:{}", proxyInfo.getIp());
|
|
|
- e.printStackTrace();
|
|
|
- count++;
|
|
|
+ log.error("spotify 注册 error:{}", StringUtil.getErrorText(e));
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(flag){
|
|
|
+ log.info("spotify 停止");
|
|
|
break;
|
|
|
}
|
|
|
}
|