|
@@ -17,6 +17,7 @@ import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpEntity;
|
|
@@ -28,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
+import reactor.util.function.Tuples;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
@@ -85,14 +88,14 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
return ResultVO.fail(HttpStatusEnum.CARD_ID_ERROR.getMsg());
|
|
|
}
|
|
|
//阿里实名认证
|
|
|
- boolean authenticationCheck;
|
|
|
+ Tuple2<Boolean, String> tuple2;
|
|
|
if (this.serverUrl.contains("test")) {
|
|
|
- authenticationCheck = this.authenticationCheck(cardName, cardId);
|
|
|
+ tuple2 = this.authenticationCheck(cardName, cardId);
|
|
|
} else {
|
|
|
- authenticationCheck = this.userCardCheck(cardName, cardId);
|
|
|
+ tuple2 = this.userCardCheck(cardName, cardId);
|
|
|
}
|
|
|
//实名认证失败
|
|
|
- if (!authenticationCheck) {
|
|
|
+ if (!tuple2.getT1()) {
|
|
|
return ResultVO.fail(HttpStatusEnum.AUTHENTICATION_FAIL.getMsg());
|
|
|
}
|
|
|
//新建记录
|
|
@@ -108,6 +111,7 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
.cardType(1)
|
|
|
.createTime(LocalDateTime.now())
|
|
|
.updateTime(LocalDateTime.now())
|
|
|
+ .address(Strings.isBlank(tuple2.getT2()) ? null : tuple2.getT2())
|
|
|
.build());
|
|
|
//更新用户信息
|
|
|
userService.update(new LambdaUpdateWrapper<User>()
|
|
@@ -172,7 +176,7 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
return sex;
|
|
|
}
|
|
|
|
|
|
- private boolean authenticationCheck(String cardName, String cardId) {
|
|
|
+ private Tuple2<Boolean, String> authenticationCheck(String cardName, String cardId) {
|
|
|
String host = "https://dskj.market.alicloudapi.com/platform/check/verified";
|
|
|
String appCode = "f395b1587fc04a49a975f908660fb1e9";
|
|
|
String url = host + "?certCode=" + cardId + "&realName=" + cardName;
|
|
@@ -192,10 +196,10 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
log.error("请求阿里实名认证接口返回值为空(OLD), cardName : {}, cardId : {}, result : {}", cardName, cardId, JsonUtil.toString(result));
|
|
|
throw new BaseException("实名认证失败");
|
|
|
}
|
|
|
- return result.isPast();
|
|
|
+ return Tuples.of(result.isPast(), Strings.EMPTY);
|
|
|
}
|
|
|
|
|
|
- private boolean userCardCheck(String cardName, String cardId) {
|
|
|
+ private Tuple2<Boolean, String> userCardCheck(String cardName, String cardId) {
|
|
|
String url = "https://eid.shumaidata.com/eid/check";
|
|
|
String appCode = "f395b1587fc04a49a975f908660fb1e9";
|
|
|
//请求头
|
|
@@ -219,6 +223,6 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
throw new BaseException("实名认证失败");
|
|
|
}
|
|
|
log.error("实名认证结果, result : {}", JsonUtil.toString(result));
|
|
|
- return result.past();
|
|
|
+ return Tuples.of(result.past(), result.getAddress());
|
|
|
}
|
|
|
}
|