Commit 4de2b17d authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/MVP1.7.18' into MVP1.7.18

parents 95c75b54 034e0ff1
...@@ -45,5 +45,9 @@ ...@@ -45,5 +45,9 @@
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -48,4 +48,6 @@ public interface ChecksConstants { ...@@ -48,4 +48,6 @@ public interface ChecksConstants {
String ID_NUM="idNum"; String ID_NUM="idNum";
String CARD_NO="cardNo"; String CARD_NO="cardNo";
String ORDER_NO="orderNo";
} }
...@@ -79,6 +79,12 @@ public class TCheckMobile extends BaseEntity { ...@@ -79,6 +79,12 @@ public class TCheckMobile extends BaseEntity {
@Schema(description ="检测结果,枚举值:0:空号 1:实号 2:停机 3:库无 4:沉默号 5:风险号 10:配置或接口异常") @Schema(description ="检测结果,枚举值:0:空号 1:实号 2:停机 3:库无 4:沉默号 5:风险号 10:配置或接口异常")
private String status; private String status;
/**
* 检测结果,枚举值:1 正常 2 空号 3 通话中(此状态失效,不返回) 4 不在网(即空号,可以和状态2合并) 5 关机 7 在网但不可用 13 停机 10 未知 9 服务器异常 12 不存在的号码
*/
@Schema(description ="检测结果,枚举值:0:空号 1:实号 2:停机 3:库无 4:沉默号 5:风险号 10:配置或接口异常")
private String statusNew;
/** /**
* 响应code码解释 * 响应code码解释
*/ */
......
...@@ -10,11 +10,11 @@ import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard; ...@@ -10,11 +10,11 @@ import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile; import com.yifu.cloud.plus.v1.check.entity.TCheckMobile;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RandomUtil;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* @author hgw2 * @author hgw2
...@@ -30,6 +30,9 @@ public class ChecksUtil { ...@@ -30,6 +30,9 @@ public class ChecksUtil {
private static final String APP_KEY_IDCARD = "s4lW5JRA"; private static final String APP_KEY_IDCARD = "s4lW5JRA";
private static final String API_URL = "https://api.253.com/open/idcard/id-card-auth"; private static final String API_URL = "https://api.253.com/open/idcard/id-card-auth";
private static final String API_URL_MOBILE = "https://api.253.com/open/unn/batch-ucheck"; private static final String API_URL_MOBILE = "https://api.253.com/open/unn/batch-ucheck";
private static final String API_URL_MOBILE_NEW = "https://api.253.com/open/mobstatus/mobstatus-query-basic";
private static final String API_URL_BANK_NO ="https://api.253.com/open/bankcard/card-auth"; private static final String API_URL_BANK_NO ="https://api.253.com/open/bankcard/card-auth";
private static final String API_URL_BANK_NO_TWO ="https://api.253.com/open/bankcard/card-two-auth"; private static final String API_URL_BANK_NO_TWO ="https://api.253.com/open/bankcard/card-two-auth";
private static final String API_URL_BANK_NO_THREE ="https://api.253.com/open/bankcard/card-three-auth"; private static final String API_URL_BANK_NO_THREE ="https://api.253.com/open/bankcard/card-three-auth";
...@@ -75,6 +78,35 @@ public class ChecksUtil { ...@@ -75,6 +78,35 @@ public class ChecksUtil {
return R.ok(resMap); return R.ok(resMap);
} }
} }
/**
* @Author fxj
* @Description 手机号码状态检测--号码实时基础版
* @Date 17:50 2022/6/20
* @param mobiles 检测手机号,多个手机号码用英文半角逗号隔开,仅支持国内号码 一次请求最多五十个号码
**/
public static R<Map<String,TCheckMobile>> checkMobileBasic(String mobiles, boolean canCheck) {
Map<String,TCheckMobile> checkMobiles = new HashMap<>();
if (canCheck) {
// 1.调用手机信息校验api
return checkMobileBasicMethod(mobiles,checkMobiles);
} else {
TCheckMobile checkMobile;
List<String> mobileList = Common.initStrToList(mobiles,CommonConstants.COMMA_STRING);
Map<String,TCheckMobile> resMap = new HashMap<>();
if (Common.isNotNull(mobileList)){
for (String m:mobileList){
checkMobile = new TCheckMobile();
checkMobile.setMobile(m);
checkMobile.setStatus(CommonConstants.ONE_STRING);
checkMobile.setType(CommonConstants.ONE_STRING);
checkMobile.setMessage(ChecksConstants.CHECK_CONFIG_ACCESS);
resMap.put(m,checkMobile);
}
}
return R.ok(resMap);
}
}
/** /**
* @Author fxj * @Author fxj
* @Description 银行卡四要素标准版 校验 * @Description 银行卡四要素标准版 校验
...@@ -247,7 +279,78 @@ public class ChecksUtil { ...@@ -247,7 +279,78 @@ public class ChecksUtil {
} }
return R.ok(checkMobileMap); return R.ok(checkMobileMap);
} }
/**
* @Author fxj
* @Description 手机号码状态检测--号码实时基础版
* 倩倩确定:非2、4、12的都可以进
* 开发api :https://rkzav3pcv4.feishu.cn/wiki/SCt3wBxhEig772kzQxecMGtjnig
* @Date 11:50 2026/1/12
* @Param
* @return
**/
private static R<Map<String,TCheckMobile>> checkMobileBasicMethod(String mobiles, Map<String,TCheckMobile> checkMobileMap) {
if (Common.isEmpty(mobiles)){
return R.failed("手机号码不能为空");
}
List<String> mobileList = new ArrayList<>();
mobileList.addAll(Arrays.asList(mobiles.split(",")));
JsonObject jsonObject;
if (mobileList.size() > CommonConstants.ZERO_INT){
TCheckMobile mobile = null;
for (String mb : mobileList){
jsonObject = ChecksUtil.invokeMobileBasic(mb);
// 2.处理返回结果
if (jsonObject != null) {
//响应code码。200000:成功,其他失败
String code = jsonObject.get(ChecksConstants.CODE).getAsString();
if (ChecksConstants.CODE_200000.equals(code) && jsonObject.get(ChecksConstants.DATA) != null) {
// 调用身份信息校验成功
// 解析结果数据,进行业务处理
// 校验状态码 200000:成功,其他失败
JsonObject mobileJson = jsonObject.get(ChecksConstants.DATA).getAsJsonObject();
String message = jsonObject.get(ChecksConstants.MESSAGE).getAsString();
if (Common.isNotNull(mobileJson)){
mobile = new TCheckMobile();
mobile.setMobile(getJsonElementValue(mobileJson.get(ChecksConstants.MOBILE)));
mobile.setArea(getJsonElementValue(mobileJson.get(ChecksConstants.AREA)));
mobile.setNumbertype(getJsonElementValue(mobileJson.get(ChecksConstants.NUMBER_TYPE)));
mobile.setChargesstatus(getJsonElementValue(mobileJson.get(ChecksConstants.CHARGES_STATUS)));
mobile.setStatus(getJsonElementValue(mobileJson.get(ChecksConstants.STATUS)));
//老检测结果,枚举值:0:空号 1:实号 2:停机 3:库无 4:沉默号 5:风险号 10:配置异常 (1、4、5为号码正常放行)
//新号码状态,1 正常 2 空号 3 通话中(此状态失效,不返回) 4 不在网(即空号,可以和状态2合并) 5 关机 7 在网但不可用 13 停机 10 未知 9 服务器异常 12 不存在的号码
//倩倩确定:新号码状态非2、4、12的都可以进
//转换好旧状态
if ( !CommonConstants.TWO_STRING.equals(mobile.getStatus())
&& !CommonConstants.FOUR_STRING.equals(mobile.getStatus())
&& !CommonConstants.TWELVE_STRING.equals(mobile.getStatus())){
mobile.setStatus(CommonConstants.ONE_STRING);
}else {
if (CommonConstants.TWO_STRING.equals(mobile.getStatus())
|| CommonConstants.FOUR_STRING.equals(mobile.getStatus())){
mobile.setStatus(CommonConstants.ZERO_STRING);
}
if (CommonConstants.TWELVE_STRING.equals(mobile.getStatus())){
mobile.setStatus(CommonConstants.THREE_STRING);
}
}
//保存新状态
mobile.setStatusNew(getJsonElementValue(mobileJson.get(ChecksConstants.STATUS)));
//转换成老的状态
mobile.setMessage(message);
mobile.setType(CommonConstants.ONE_STRING);
checkMobileMap.put(mb,mobile);
}
} else {
// 记录错误日志,正式项目中请换成log打印
return R.failed("手机号校验失败:" + jsonObject.get(ChecksConstants.MESSAGE).getAsString());
}
} else {
return R.failed(ChecksConstants.NO_DATA_RESULT);
}
}
}
return R.ok(checkMobileMap);
}
// 核心调用 // 核心调用
private static void checkIdCardMethod(TCheckIdCard checkIdCard) { private static void checkIdCardMethod(TCheckIdCard checkIdCard) {
final JsonObject jsonObject = ChecksUtil.invokeIdCard(checkIdCard.getName(), checkIdCard.getIdCard()); final JsonObject jsonObject = ChecksUtil.invokeIdCard(checkIdCard.getName(), checkIdCard.getIdCard());
...@@ -312,6 +415,39 @@ public class ChecksUtil { ...@@ -312,6 +415,39 @@ public class ChecksUtil {
} }
return null; return null;
} }
/**
* @Author fxj
* @Description 手机号码状态检测--实时基础版
* 号码实时基础版status解释
* 1-正常 ----(通话中、正常号码、响应慢 (静音)、忙音) 可以正常打通的号码
* 13-停机--- 停机号码
* 7-在网但不可用 ---、号码小号呼转、手机号码繁忙,无法接听,不在服务区等。
* 4-不在网(空号)--- 空号销号的号码
* 3-通话中 ---号码在通话中、可以放在正常状态里面
* 5-关机-- 当时该手机处于关机或者没电来电提醒的状态
* 2-空号 ---空号、未激活使用的号码
* 9-服务器异常 --运营商异常或系统内部异常,也包含特殊号码无法查询
* 10-未知 ---号码失败次数超频,请隔天再试/运营商返回其他的错误信息、号码管控、号段不支持
* 12-号码不存在--- 号码不支持/运营商返回其他的错误信息
* 倩倩确定:非2、4、12的都可以进
* @Date 11:32 2026/1/12
* @Param
* @return
**/
private static JsonObject invokeMobileBasic(String mobiles) {
Map<String, String> params = new HashMap<>();
params.put(ChecksConstants.APP_ID, APP_ID);
params.put(ChecksConstants.APP_KEY, APP_KEY_IDCARD);
params.put(ChecksConstants.MOBILE, mobiles);
params.put(ChecksConstants.ORDER_NO, new Date().getTime()+ RandomUtil.getSix());
//请求参数 Body 以 multipart/form-data 方式提交
String result = HttpUtils.postMultipart(API_URL_MOBILE_NEW, params);
// 解析json,并返回结果
if (Common.isNotNull(result)){
return jsonParser.parse(result).getAsJsonObject();
}
return null;
}
private static JsonObject invokeBankNo(String name, String idNum, String cardNo, String mobile) { private static JsonObject invokeBankNo(String name, String idNum, String cardNo, String mobile) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
......
...@@ -5,10 +5,13 @@ import org.apache.http.HttpStatus; ...@@ -5,10 +5,13 @@ import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder; import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Map; import java.util.Map;
...@@ -47,6 +50,15 @@ public class HttpUtils { ...@@ -47,6 +50,15 @@ public class HttpUtils {
return send(RequestBuilder.post(url), paramsMap); return send(RequestBuilder.post(url), paramsMap);
} }
/**
* 以 multipart/form-data 方式提交POST请求
* @param url 请求地址
* @param paramsMap 参数map
* @return 响应结果
*/
public static String postMultipart(String url, Map<String, String> paramsMap) {
return sendMultipart(RequestBuilder.post(url), paramsMap);
}
public static String send(RequestBuilder requestBuilder, Map<String, String> paramsMap) { public static String send(RequestBuilder requestBuilder, Map<String, String> paramsMap) {
requestBuilder.setCharset(Charset.forName(ENCODING)); requestBuilder.setCharset(Charset.forName(ENCODING));
...@@ -80,4 +92,51 @@ public class HttpUtils { ...@@ -80,4 +92,51 @@ public class HttpUtils {
return responseText; return responseText;
} }
/**
* 以 multipart/form-data 方式发送请求
* @param requestBuilder 请求构建器
* @param paramsMap 参数map
* @return 响应结果
*/
public static String sendMultipart(RequestBuilder requestBuilder, Map<String, String> paramsMap) {
String responseText = "";
if (paramsMap != null) {
// 创建 multipart/form-data 实体
MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
entityBuilder.setCharset(Charset.forName(ENCODING));
// 添加参数到 multipart 实体
for (Map.Entry<String, String> param : paramsMap.entrySet()) {
try {
entityBuilder.addPart(param.getKey(), new StringBody(param.getValue(), Charset.forName(ENCODING)));
} catch (UnsupportedEncodingException e) {
return null;
}
}
HttpEntity entity = entityBuilder.build();
requestBuilder.setEntity(entity);
CloseableHttpResponse response = null;
try {
response = client.execute(requestBuilder.build());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity responseEntity = response.getEntity();
if (responseEntity != null) {
responseText = EntityUtils.toString(responseEntity, ENCODING);
}
}
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
} finally {
try {
response.close();
} catch (Exception e) {
e.printStackTrace();//正式项目中请改为log打印
}
}
}
return responseText;
}
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.check.mapper.TCheckMobileMapper; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.check.mapper.TCheckMobileMapper;
import com.yifu.cloud.plus.v1.check.service.TCanCheckService; import com.yifu.cloud.plus.v1.check.service.TCanCheckService;
import com.yifu.cloud.plus.v1.check.service.TCheckMobileService; import com.yifu.cloud.plus.v1.check.service.TCheckMobileService;
import com.yifu.cloud.plus.v1.check.service.TPreEmpCheckNumService; import com.yifu.cloud.plus.v1.check.service.TPreEmpCheckNumService;
import com.yifu.cloud.plus.v1.check.utils.ChecksUtil;
import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo; import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
...@@ -88,7 +89,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -88,7 +89,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
mobileList.removeAll(existMap.keySet()); mobileList.removeAll(existMap.keySet());
//2.从远处端获取数据 //2.从远处端获取数据
if (Common.isNotNull(mobileList)) { if (Common.isNotNull(mobileList)) {
mobileMapR = checkMobileTemp(Common.ListToStr(mobileList, CommonConstants.COMMA_STRING), canCheckService.getCanCheck()); mobileMapR = ChecksUtil.checkMobileBasic(Common.ListToStr(mobileList, CommonConstants.COMMA_STRING), canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) { if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) {
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR) return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR)
+ (Common.isNotNull(mobileMapR) ? mobileMapR.getMsg() : CommonConstants.EMPTY_STRING)); + (Common.isNotNull(mobileMapR) ? mobileMapR.getMsg() : CommonConstants.EMPTY_STRING));
...@@ -150,7 +151,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -150,7 +151,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
return returnMobile; return returnMobile;
} else { } else {
//2.从远处端获取数据 //2.从远处端获取数据
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(mobile, canCheckService.getCanCheck()); R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobileBasic(mobile, canCheckService.getCanCheck());
if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) { if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())) {
if (mobileMapR != null) { if (mobileMapR != null) {
returnMobile.setMessage(mobileMapR.getMsg()); returnMobile.setMessage(mobileMapR.getMsg());
...@@ -237,7 +238,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -237,7 +238,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
} }
} }
synchronized (this) { synchronized (this) {
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(phone, canCheck); R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobileBasic(phone, canCheck);
if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) { if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) {
Map<String, TCheckMobile> result = mobileMapR.getData(); Map<String, TCheckMobile> result = mobileMapR.getData();
TCheckMobile mo = result.get(phone); TCheckMobile mo = result.get(phone);
...@@ -285,7 +286,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -285,7 +286,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
List<TCheckMobile> saveList = new ArrayList<>(); List<TCheckMobile> saveList = new ArrayList<>();
if (!noCurlist.isEmpty() && Common.isNotNull(phones)) { if (!noCurlist.isEmpty() && Common.isNotNull(phones)) {
synchronized (this) { synchronized (this) {
R<Map<String, TCheckMobile>> mobileMapR = checkMobileTemp(phones.toString(), canCheckService.getCanCheck()); R<Map<String, TCheckMobile>> mobileMapR = ChecksUtil.checkMobileBasic(phones.toString(), canCheckService.getCanCheck());
if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) { if (Common.isNotNull(mobileMapR) && Common.isNotNull(mobileMapR.getData())) {
Map<String, TCheckMobile> result = mobileMapR.getData(); Map<String, TCheckMobile> result = mobileMapR.getData();
TCheckMobile mo; TCheckMobile mo;
...@@ -308,6 +309,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -308,6 +309,7 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
vo.setCheckMap(backMap); vo.setCheckMap(backMap);
} }
/* * 临时查询本地库的代码,先留存吧
private R<Map<String,TCheckMobile>> checkMobileTemp(String mobiles, boolean canCheck) { private R<Map<String,TCheckMobile>> checkMobileTemp(String mobiles, boolean canCheck) {
Map<String,TCheckMobile> resMap = new HashMap<>(); Map<String,TCheckMobile> resMap = new HashMap<>();
TCheckMobile checkMobile; TCheckMobile checkMobile;
...@@ -362,5 +364,5 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -362,5 +364,5 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
} }
} }
return R.ok(resMap); return R.ok(resMap);
} }*/
} }
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
<result property="numbertype" column="numberType"/> <result property="numbertype" column="numberType"/>
<result property="chargesstatus" column="chargesStatus"/> <result property="chargesstatus" column="chargesStatus"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="statusNew" column="status_new"/>
<result property="message" column="message"/> <result property="message" column="message"/>
</resultMap> </resultMap>
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
SELECT SELECT
a.id, a.id,
a.mobile, a.mobile,
a.status a.status,status_new
FROM t_check_mobile a FROM t_check_mobile a
where a.mobile in where a.mobile in
<foreach item="item" index="index" collection="noList" open="(" separator="," close=")"> <foreach item="item" index="index" collection="noList" open="(" separator="," close=")">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment