Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
225618ba14
|
|
@ -8,7 +8,8 @@ import lombok.Getter;
|
|||
public enum ApiFrom {
|
||||
LianTong(1L,"联通Api"),
|
||||
GuangZhouDX(2L,"广州电信Api"),
|
||||
HaiNanDX(3L,"海南电信Api");
|
||||
HaiNanDX(3L,"海南电信Api"),
|
||||
HuNanDX(4L,"湖南电信Api");
|
||||
private final Long id;
|
||||
private final String name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,130 @@
|
|||
package cn.iocoder.yudao.module.haoka.api;
|
||||
|
||||
import cn.iocoder.yudao.module.haoka.api.hunandianxin.HuNanDXApi;
|
||||
import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 湖南电信API服务类,用于调用湖南电信的各个接口。
|
||||
*/
|
||||
@Service
|
||||
public class ApiHuNanDXService extends ApiConfigService {
|
||||
|
||||
public static final String Key_baseUrl = "baseUrl";
|
||||
public static final String Key_accessToken = "accessToken";
|
||||
public static final String Key_secret = "secret";
|
||||
public static final String Key_channel = "channel";
|
||||
|
||||
/**
|
||||
* 获取湖南电信API的配置信息。
|
||||
*
|
||||
* @return 配置信息对象 {@link HaiNanDxInfo.ConfigInfo}
|
||||
*/
|
||||
private HaiNanDxInfo.ConfigInfo getConfig() {
|
||||
Map<String, String> devConfig = getDevConfig(ApiFrom.HuNanDX);
|
||||
return new HaiNanDxInfo.ConfigInfo(
|
||||
devConfig.get(Key_accessToken),
|
||||
devConfig.get(Key_secret),
|
||||
devConfig.get(Key_channel),
|
||||
devConfig.get(Key_baseUrl)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验互联网卡下单资格。
|
||||
*
|
||||
* @param param 校验参数 {@link HaiNanDxInfo.InternetCardQualificationParam}
|
||||
* @return 校验结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp>
|
||||
checkInternetCardQualification(HaiNanDxInfo.InternetCardQualificationParam param) throws Exception {
|
||||
return HuNanDXApi.checkInternetCardQualification(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步订单信息给BPS。
|
||||
*
|
||||
* @param param 同步订单参数 {@link HaiNanDxInfo.SyncOrderParam}
|
||||
* @return 同步结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>
|
||||
syncOrder(HaiNanDxInfo.SyncOrderParam param) throws Exception {
|
||||
return HuNanDXApi.syncOrder(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询BPS业务订单详情。
|
||||
*
|
||||
* @param param 查询订单参数 {@link HaiNanDxInfo.QueryOrderParam}
|
||||
* @return 订单详情 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp>
|
||||
queryOrder(HaiNanDxInfo.QueryOrderParam param) throws Exception {
|
||||
return HuNanDXApi.queryOrder(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信验证码。
|
||||
*
|
||||
* @param param 发送短信验证码参数 {@link HaiNanDxInfo.SendSmsCodeParam}
|
||||
* @return 发送结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SendSmsCodeResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SendSmsCodeResp>
|
||||
sendSmsCode(HaiNanDxInfo.SendSmsCodeParam param) throws Exception {
|
||||
return HuNanDXApi.sendSmsCode(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证短信验证码。
|
||||
*
|
||||
* @param param 验证短信验证码参数 {@link HaiNanDxInfo.VerifySmsCodeParam}
|
||||
* @return 验证结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.VerifySmsCodeResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.VerifySmsCodeResp>
|
||||
verifySmsCode(HaiNanDxInfo.VerifySmsCodeParam param) throws Exception {
|
||||
return HuNanDXApi.verifySmsCode(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询号码。
|
||||
*
|
||||
* @param param 查询号码参数 {@link HaiNanDxInfo.QueryPhoneNumberParam}
|
||||
* @return 查询结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryPhoneNumberResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryPhoneNumberResp>
|
||||
queryPhoneNumber( HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
|
||||
return HuNanDXApi.queryPhoneNumber(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 占用号码。
|
||||
*
|
||||
* @param param 占用号码参数 {@link HaiNanDxInfo.PossessPhoneNumberParam}
|
||||
* @return 占用结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>
|
||||
possessPhoneNumber(HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
|
||||
return HuNanDXApi.possessPhoneNumber(getConfig(), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查黑名单。
|
||||
*
|
||||
* @param param 检查黑名单参数 {@link HaiNanDxInfo.BlackListCheckParam}
|
||||
* @return 检查结果 {@link HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>}
|
||||
* @throws Exception 如果调用接口时发生异常
|
||||
*/
|
||||
public HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>
|
||||
checkBlackList(HaiNanDxInfo.BlackListCheckParam param) throws Exception {
|
||||
return HuNanDXApi.checkBlackList(getConfig(), param);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package cn.iocoder.yudao.module.haoka.api.hunan;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class HunanDXApi {
|
||||
public static String genSignFromMap(JSONObject data, String seckey) throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, Object> mapBody = mapper.readValue(data.toString(), Map.class);
|
||||
Map<String, String> params = (Map<String,String>) mapBody.get("data");
|
||||
|
||||
Map<String, String> map = new TreeMap<String, String>();
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
if(entry.getValue()==null||entry.getValue().equals("")){
|
||||
continue;
|
||||
}
|
||||
if (!entry.getKey().equals("sign")) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int index = 0;
|
||||
for(String _key:map.keySet()){
|
||||
if(index!=0){
|
||||
sb.append("&");
|
||||
}
|
||||
sb.append(_key);
|
||||
sb.append("=");
|
||||
sb.append(map.get(_key));
|
||||
index++;
|
||||
}
|
||||
|
||||
sb.append("&key=" + seckey);
|
||||
String md5 = MD5Utils.md5Digest(sb.toString()).toLowerCase();
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,295 @@
|
|||
package cn.iocoder.yudao.module.haoka.api.hunandianxin;
|
||||
|
||||
/**
|
||||
* 湖南省区域信息---配置
|
||||
*
|
||||
* @author lixiangjiang
|
||||
* @Description:
|
||||
* @date 2018年7月31日
|
||||
*/
|
||||
public enum HNLanCode {
|
||||
yueyang("730", "岳阳", "4306", "2", "730", "10", "1660", "8430600", "4306022027637", "HNWT00730"),
|
||||
changsha("731", "长沙", "4301", "1350", "731", "11", "1650", "8430100", "4301022027773", "HNWT00731"),
|
||||
zhuzhou("732", "湘潭", "4303", "21", "731", "12", "1657", "8430300", "4303022035377", "HNWT00732"),
|
||||
xiangtan("733", "株洲", "4302", "27", "731", "13", "1648", "8430200", "4302032027789", "HNWT00733"),
|
||||
hengyang("734", "衡阳", "4304", "34", "734", "14", "1652", "8430400", "4304072027807", "HNWT00734"),
|
||||
chenzhou("735", "郴州", "4310", "44", "735", "15", "1651", "8431000", "4310032027827", "HNWT00735"),
|
||||
changde("736", "常德", "4307", "56", "736", "16", "1649", "8430700", "4307022027839", "HNWT00736"),
|
||||
yiyang("737", "益阳", "4309", "66", "737", "17", "1658", "8430900", "4309032027883", "HNWT00737"),
|
||||
loudi("738", "娄底", "4313", "73", "738", "18", "1655", "8431300", "4313022027891", "HNWT00738"),
|
||||
shaoyang("739", "邵阳", "4305", "80", "739", "19", "1656", "8430500", "4305032028025", "HNWT00739"),
|
||||
xiangxi("743", "湘西", "4331", "92", "743", "20", "1654", "8433100", "4331012028044", "HNWT00743"),
|
||||
zhangjiajie("744", "张家界", "4308", "102", "744", "21", "1661", "8430800", "4308022028055", "HNWT00744"),
|
||||
huaihua("745", "怀化", "4312", "108", "745", "22", "1653", "8431200", "4312022028175", "HNWT00745"),
|
||||
yongzhou("746", "永州", "4311", "122", "746", "23", "1659", "8431100", "4311032028119", "HNWT00746");
|
||||
|
||||
|
||||
private final String code; //编码
|
||||
private final String name; //名称
|
||||
private final String idCard4; //身份正前4位
|
||||
private final String crmId; //crm对区域的描述
|
||||
private final String queryLanCode;//查询区域
|
||||
private final String yxId;//营协系统ID
|
||||
private final String staffNo;//staffNo 订购时的参数
|
||||
private final String consistencyLanId;//渠道一致性二期,接口入参对应地市ID
|
||||
private final String channel_nbr; //渠道帐号
|
||||
private final String staffCode; //工号
|
||||
|
||||
private HNLanCode(String code, String name,
|
||||
String idCard4,
|
||||
String crmId,
|
||||
String queryLanCode,
|
||||
String yxId,
|
||||
String staffNo,
|
||||
String consistencyLanId,
|
||||
String channel_nbr,
|
||||
String staffCode) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.idCard4 = idCard4;
|
||||
this.crmId = crmId;
|
||||
this.queryLanCode = queryLanCode;
|
||||
this.yxId = yxId;
|
||||
this.staffNo = staffNo;
|
||||
this.consistencyLanId = consistencyLanId;
|
||||
this.channel_nbr = channel_nbr;
|
||||
this.staffCode = staffCode;
|
||||
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getIdCard4() {
|
||||
return idCard4;
|
||||
}
|
||||
|
||||
public String getCrmId() {
|
||||
return crmId;
|
||||
}
|
||||
|
||||
public String getQueryLanCode() {
|
||||
return queryLanCode;
|
||||
}
|
||||
|
||||
public String getYxId() {
|
||||
return yxId;
|
||||
}
|
||||
|
||||
public String getConsistencyLanId() {
|
||||
return consistencyLanId;
|
||||
}
|
||||
|
||||
public String getStaffNo() {
|
||||
return staffNo;
|
||||
}
|
||||
|
||||
public String getChannel_nbr() {
|
||||
return channel_nbr;
|
||||
}
|
||||
|
||||
public String getStaffCode() {
|
||||
return staffCode;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名称获取区域id
|
||||
*
|
||||
* @param lanName
|
||||
* @return
|
||||
*/
|
||||
public static String getLanCodeByName(String lanName) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getName().equals(lanName)) {
|
||||
return lancode.getCode();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据身份正前4位获取区域id
|
||||
*
|
||||
* @param idCard4
|
||||
* @return
|
||||
*/
|
||||
public static String getLanCodeByIdCard4(String idCard4) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getIdCard4().equals(idCard4)) {
|
||||
return lancode.getCode();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 consistencyLanId;渠道一致性二期,接口入参对应地市ID 获取区域id
|
||||
*
|
||||
* @param crmId
|
||||
* @return
|
||||
*/
|
||||
public static String getLanCodeByCrmId(String crmId) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCrmId().equals(crmId)) {
|
||||
return lancode.getCode();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据crm区域编码获取区域名称
|
||||
*
|
||||
* @param crmId
|
||||
* @return
|
||||
*/
|
||||
public static String getLanNameByCrmId(String crmId) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getConsistencyLanId().equals(crmId)) {
|
||||
return lancode.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static HNLanCode getHNLanCodeByLanCode(String lanCode) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(lanCode)) {
|
||||
return lancode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否包含区号
|
||||
*
|
||||
* @param lanCode
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasLanCode(String lanCode) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(lanCode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询的区域,获取需要查询的区域列表
|
||||
*
|
||||
* @param queryLanCode
|
||||
* @return
|
||||
*/
|
||||
public static String[] getLanCodesByQueryType(String queryLanCode) {
|
||||
String[] lans = new String[14];
|
||||
int i = 0;
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getQueryLanCode().equals(queryLanCode)) {
|
||||
lans[i] = lancode.getCode();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
return new String[]{queryLanCode};
|
||||
}
|
||||
|
||||
String[] returnLans = new String[i + 1];
|
||||
for (int j = 0; i < returnLans.length; j++) {
|
||||
returnLans[j] = lans[j];
|
||||
}
|
||||
return returnLans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取湖南省所有的地市区域ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String[] getCodes() {
|
||||
HNLanCode[] codes = HNLanCode.values();
|
||||
String[] lans = new String[codes.length];
|
||||
int i = 0;
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
lans[i] = lancode.getCode();
|
||||
i++;
|
||||
}
|
||||
return lans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道一致性二期
|
||||
*
|
||||
* @throws
|
||||
* @Title: getConsistencyLanIdByCode 能力平台
|
||||
* @Description: 根据地市ID获取接口对应的入参地市编码
|
||||
* @author hjs
|
||||
* @date 2019年1月22日
|
||||
* @param: @param code
|
||||
* @param: @return
|
||||
* @return: String
|
||||
*/
|
||||
public static String getConsistencyLanIdByCode(String code) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(code)) {
|
||||
return lancode.getConsistencyLanId();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道一致性二期
|
||||
*
|
||||
* @throws
|
||||
* @Title: getStaffNoByCode 能力平台
|
||||
* @Description: 根据地市ID获取接口对应的入参工号ID
|
||||
* @author hjs
|
||||
* @date 2019年2月18日
|
||||
* @param: @param code
|
||||
* @param: @return
|
||||
* @return: String
|
||||
*/
|
||||
public static String getStaffNoByCode(String code) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(code)) {
|
||||
return lancode.getStaffNo();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getChannelNbrByCode(String code) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(code)) {
|
||||
return lancode.getChannel_nbr();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getStaffCodeByCode(String code) {
|
||||
for (HNLanCode lancode : HNLanCode.values()) {
|
||||
if (lancode.getCode().equals(code)) {
|
||||
return lancode.getStaffCode();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
package cn.iocoder.yudao.module.haoka.api.hunandianxin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HaiNanDxInfo {
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class ConfigInfo {
|
||||
private String accessToken; // access_token
|
||||
private String secret; // 密钥
|
||||
private String channel; // 渠道ID
|
||||
private String baseUrl; // 接口基础URL
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ResponseInfo<T> {
|
||||
private String code;
|
||||
private String res_code; // 返回状态码
|
||||
private String res_message; // 返回消息
|
||||
private JSONObject result; // 返回结果数据
|
||||
private T data; // 返回的业务数据
|
||||
}
|
||||
|
||||
// 接口1、校验互联网卡下单资格_新(BPS):chk.ordercheck.InternetCardQualifica
|
||||
@Data
|
||||
public static class InternetCardQualificationParam {
|
||||
private String cartNo; // 入网身份证
|
||||
private String serviceOrderSource; // 渠道ID
|
||||
private String serviceOrderSalesNumber; // 产品ID
|
||||
private String buyerName; // 入网姓名
|
||||
private String mobilePhone; // 联系电话
|
||||
private String receiverName; // 收货人姓名
|
||||
private String receiverProv; // 收货人所在省
|
||||
private String receiverCity; // 收货人所在市
|
||||
private String receiverDistrict; // 收货人所在区
|
||||
private String receiverAdress; // 收货人详细地址 Adress
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class InternetCardQualificationResp {
|
||||
private String code; // 状态码
|
||||
private String message; // 消息
|
||||
}
|
||||
|
||||
// 接口4、BPS互联网卡订单状态同步接口 被调接口
|
||||
@Data
|
||||
public static class BpsOrderStatusSyncParam {
|
||||
private String webOrder; // 订单号
|
||||
private String orderStatus; // 订单状态
|
||||
private String otherStatus; // 激活状态
|
||||
private String sendNo; // 物流单号
|
||||
private String logisticsName; // 物流公司
|
||||
private String logisticsStatus; // 物流状态
|
||||
private String cp1; // CPS1
|
||||
private String isAccNumber; // 是否换号(针对靓号宽带)
|
||||
private String orderStatusDesc; // 订单状态/作废原因
|
||||
private String isInvest; // 激活前充值,1是充值
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BpsOrderStatusSyncResp {
|
||||
private String rspCode; // 接口返回状态码(0 成功,其他失败)
|
||||
private String rspDesc; // 接口返回信息
|
||||
}
|
||||
|
||||
// 接口2、同步订单信息给BPS:syn.orderinfo.SynJdServiceOrder
|
||||
@Data
|
||||
public static class SyncOrderParam {
|
||||
private String serviceOrderOutOrderId; // 提交订单ID
|
||||
private String serviceOrderSubmitTime; // 提交时间
|
||||
private String serviceOrderCusName; // 客户入网姓名
|
||||
private String serviceOrderCusCardNo; // 客户入网身份证
|
||||
private String serviceOrderCusAccPhone;// 客户预占号码
|
||||
private String serviceOrderSalesNumber;// 入网所选套餐ID
|
||||
private String serviceOrderCpsRefereePeople; // CPS1
|
||||
private String serviceOrderRefereePeople; // CPS2
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SyncOrderResp {
|
||||
private String code; // 状态码
|
||||
private String message; // 消息
|
||||
}
|
||||
|
||||
// 接口3、查询BPS业务订单详情:qry.order.QryBpsOrderInfo
|
||||
@Data
|
||||
public static class QueryOrderParam {
|
||||
private String outId; // 订单号
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class QueryOrderResp {
|
||||
private String code; // 状态码
|
||||
private String message; // 消息
|
||||
private JSONObject data; // 订单详情
|
||||
}
|
||||
|
||||
// 接口5、短信渠道短信验证码发送:push.sms.sendsmsCode
|
||||
@Data
|
||||
public static class SendSmsCodeParam {
|
||||
private String phoneNumber; // 手机号码
|
||||
private String source; // 渠道来源
|
||||
private String flag; // 验证标示
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SendSmsCodeResp {
|
||||
private String retErrorInfo; // 返回信息
|
||||
private String retFlag; // 结果是否成功(0 成功,1 失败)
|
||||
}
|
||||
|
||||
// 接口6、短信渠道下发短信验证码是否验证通过:push.sms.sendsmsCodeYz
|
||||
@Data
|
||||
public static class VerifySmsCodeParam {
|
||||
private String phoneNumber; // 手机号码
|
||||
private String flag; // 验证标示
|
||||
private String source; // 渠道来源
|
||||
private String pwd; // 短信验证码
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class VerifySmsCodeResp {
|
||||
private String retErrorInfo; // 返回信息
|
||||
private String retFlag; // 结果是否成功(0 成功,1 失败)
|
||||
}
|
||||
// 接口7、号码查询:qry.nmall.phoneNumberlList
|
||||
@Data
|
||||
public static class QueryPhoneNumberParam {
|
||||
private String poolId; // 号池ID
|
||||
private String pageSize; // 每页记录数
|
||||
private String isMain; // 主副卡标识
|
||||
private String currentPage; // 当前页数
|
||||
private String lastNumbers; // 尾号4位
|
||||
private String beginNum; // 号段
|
||||
private String numMonthFee; // 月租
|
||||
private String numPreDeposit; // 预存款
|
||||
private String regionRange; // 全省设置
|
||||
private String areaCode; // 地市编码
|
||||
}
|
||||
|
||||
// 接口7、号码查询:qry.nmall.phoneNumberlList
|
||||
@Data
|
||||
public static class NeedSignQueryParam<T> {
|
||||
private String apiName;
|
||||
private String channel;
|
||||
private String sign;
|
||||
private String timestamp;
|
||||
private T data;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class QueryPhoneNumberResp {
|
||||
private String respCode; // 返回状态码
|
||||
private String respDesc; // 返回描述
|
||||
private JSONObject data; // 号码数据
|
||||
}
|
||||
|
||||
// 接口8、占用号码:qry.nmall.possessPhoneNumber
|
||||
@Data
|
||||
public static class PossessPhoneNumberParam {
|
||||
private String poolId; // 号池ID
|
||||
private String numberId; // 号码编号
|
||||
private String apiName; // 请求服务名
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PossessPhoneNumberResp {
|
||||
private String respCode; // 返回状态码
|
||||
private String respDesc; // 返回描述
|
||||
}
|
||||
|
||||
// 接口9、联系电话黑名单接口:getBlackDataByPhone
|
||||
@Data
|
||||
public static class BlackListCheckParam {
|
||||
private String phone; // 手机号码
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BlackListCheckResp {
|
||||
private String code; // 返回状态码
|
||||
private String message; // 返回消息
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
package cn.iocoder.yudao.module.haoka.api.hunandianxin;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.TrustStrategy;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Slf4j
|
||||
public class HuNanDXApi {
|
||||
|
||||
// 接口1、校验互联网卡下单资格_新(BPS):chk.ordercheck.InternetCardQualifica
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp>
|
||||
checkInternetCardQualification(HaiNanDxInfo.ConfigInfo config,
|
||||
HaiNanDxInfo.InternetCardQualificationParam param) throws Exception {
|
||||
return doExecute(config, "chk.ordercheck.InternetCardQualifica", param, HaiNanDxInfo.InternetCardQualificationResp.class);
|
||||
}
|
||||
|
||||
// 接口2、同步订单信息给BPS:syn.orderinfo.SynJdServiceOrder
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>
|
||||
syncOrder(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SyncOrderParam param) throws Exception {
|
||||
return doExecute(config, "syn.orderinfo.SynJdServiceOrder", param, HaiNanDxInfo.SyncOrderResp.class);
|
||||
}
|
||||
|
||||
// 接口3、查询BPS业务订单详情:qry.order.QryBpsOrderInfo
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp>
|
||||
queryOrder(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.QueryOrderParam param) throws Exception {
|
||||
return doExecute(config, "qry.order.QryBpsOrderInfo", param, HaiNanDxInfo.QueryOrderResp.class);
|
||||
}
|
||||
|
||||
// 接口5、短信渠道短信验证码发送:push.sms.sendsmsCode
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SendSmsCodeResp>
|
||||
sendSmsCode(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.SendSmsCodeParam param) throws Exception {
|
||||
return doExecute(config, "push.sms.sendsmsCode", param, HaiNanDxInfo.SendSmsCodeResp.class);
|
||||
}
|
||||
|
||||
// 接口6、短信渠道下发短信验证码是否验证通过:push.sms.sendsmsCodeYz
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.VerifySmsCodeResp>
|
||||
verifySmsCode(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.VerifySmsCodeParam param) throws Exception {
|
||||
return doExecute(config, "push.sms.sendsmsCodeYz", param, HaiNanDxInfo.VerifySmsCodeResp.class);
|
||||
}
|
||||
|
||||
// 接口7、号码查询:qry.nmall.phoneNumberlList
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryPhoneNumberResp>
|
||||
queryPhoneNumber(HaiNanDxInfo.ConfigInfo config,
|
||||
HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
|
||||
// 生成签名
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(param);
|
||||
String sign = genSignFromMap(jsonObject, config.getSecret());
|
||||
param.setSign(sign);
|
||||
return doExecute(config, "qry.nmall.phoneNumberlList", param, HaiNanDxInfo.QueryPhoneNumberResp.class);
|
||||
}
|
||||
|
||||
// 接口8、占用号码:qry.nmall.possessPhoneNumber
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>
|
||||
possessPhoneNumber(HaiNanDxInfo.ConfigInfo config,
|
||||
HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
|
||||
// 生成签名
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(param);
|
||||
String sign = genSignFromMap(jsonObject, config.getSecret());
|
||||
param.setSign(sign);
|
||||
return doExecute(config, "qry.nmall.possessPhoneNumber", param, HaiNanDxInfo.PossessPhoneNumberResp.class);
|
||||
}
|
||||
|
||||
// 接口9、联系电话黑名单接口:getBlackDataByPhone
|
||||
public static HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>
|
||||
checkBlackList(HaiNanDxInfo.ConfigInfo config, HaiNanDxInfo.BlackListCheckParam param) throws Exception {
|
||||
return doExecute(config, "getBlackDataByPhone", param, HaiNanDxInfo.BlackListCheckResp.class);
|
||||
}
|
||||
|
||||
// 通用 API 调用方法
|
||||
private static <T, R> HaiNanDxInfo.ResponseInfo<R>
|
||||
doExecute(HaiNanDxInfo.ConfigInfo config, String method, T data, Class<R> rClass) throws Exception {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(data);
|
||||
String calledApi = callApi(config, method, jsonObject);
|
||||
System.out.println("-------{}--" + calledApi);
|
||||
HaiNanDxInfo.ResponseInfo responseInfo = JSON.parseObject(calledApi, HaiNanDxInfo.ResponseInfo.class);
|
||||
|
||||
JSONObject result = responseInfo.getResult();
|
||||
HaiNanDxInfo.ResponseInfo<R> objectResponseInfo = new HaiNanDxInfo.ResponseInfo<>();
|
||||
|
||||
if (result != null) {
|
||||
R dataInfo = result.toJavaObject(rClass);
|
||||
objectResponseInfo.setData(dataInfo);
|
||||
}
|
||||
return objectResponseInfo;
|
||||
}
|
||||
private static CloseableHttpClient createHttpClientIgnoreSSL() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
|
||||
// 创建信任所有证书的TrustStrategy
|
||||
TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true;
|
||||
|
||||
// 创建SSLContext,并使用信任所有证书的TrustManager
|
||||
SSLContext sslContext = SSLContextBuilder.create()
|
||||
.loadTrustMaterial(null, acceptingTrustStrategy)
|
||||
.build();
|
||||
|
||||
// 创建SSLConnectionSocketFactory,忽略主机名验证
|
||||
SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
|
||||
|
||||
// 创建HttpClient
|
||||
return HttpClients.custom()
|
||||
.setSSLSocketFactory(sslSocketFactory)
|
||||
.build();
|
||||
}
|
||||
|
||||
// 通用 API 调用方法
|
||||
private static String callApi(HaiNanDxInfo.ConfigInfo config, String method, JSONObject data) throws Exception {
|
||||
// 构建请求体
|
||||
Map<String, Object> requestBody = new TreeMap<>();
|
||||
requestBody.put("access_token", config.getAccessToken());
|
||||
requestBody.put("method", method);
|
||||
requestBody.put("version", "1.0");
|
||||
requestBody.put("content", data);
|
||||
|
||||
// 发送 HTTP 请求
|
||||
try (CloseableHttpClient httpClient = createHttpClientIgnoreSSL()) {
|
||||
HttpPost httpPost = new HttpPost(config.getBaseUrl());
|
||||
httpPost.setHeader("Content-Type", "application/json; charset=UTF-8");
|
||||
httpPost.setEntity(new StringEntity(new ObjectMapper().writeValueAsString(requestBody)));
|
||||
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String string = EntityUtils.toString(response.getEntity());
|
||||
log.info("Response Code: " + response.getStatusLine().getStatusCode());
|
||||
httpClient.close();
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
// 生成签名
|
||||
private static String genSignFromMap(JSONObject data, String seckey) throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Map<String, Object> mapBody = mapper.readValue(data.toString(), Map.class);
|
||||
Map<String, String> params = (Map<String, String>) mapBody.get("data");
|
||||
|
||||
Map<String, String> map = new TreeMap<String, String>();
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
if (entry.getValue() == null || entry.getValue().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (!entry.getKey().equals("sign")) {
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int index = 0;
|
||||
for (String _key : map.keySet()) {
|
||||
if (index != 0) {
|
||||
sb.append("&");
|
||||
}
|
||||
sb.append(_key);
|
||||
sb.append("=");
|
||||
sb.append(map.get(_key));
|
||||
index++;
|
||||
}
|
||||
|
||||
sb.append("&key=").append(seckey);
|
||||
return MD5Utils.md5Digest(sb.toString()).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package cn.iocoder.yudao.module.haoka.api.hunan;
|
||||
package cn.iocoder.yudao.module.haoka.api.hunandianxin;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package cn.iocoder.yudao.module.haoka.controller.admin.api;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.haoka.api.ApiHuNanDXService;
|
||||
import cn.iocoder.yudao.module.haoka.api.hunandianxin.HaiNanDxInfo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "API----------上游接口-------湖南电信")
|
||||
@RestController
|
||||
@RequestMapping("/haoka/api/hunan-dx")
|
||||
@Validated
|
||||
public class HaokaHuNanDXController {
|
||||
|
||||
@Resource
|
||||
private ApiHuNanDXService apiHuNanDXService;
|
||||
|
||||
@PostMapping("/checkInternetCardQualification")
|
||||
@Operation(summary = "湖南电信-校验互联网卡下单资格")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.InternetCardQualificationResp>>
|
||||
checkInternetCardQualification(@RequestBody HaiNanDxInfo.InternetCardQualificationParam param) throws Exception {
|
||||
return success(apiHuNanDXService.checkInternetCardQualification(param));
|
||||
}
|
||||
|
||||
@PostMapping("/syncOrder")
|
||||
@Operation(summary = "湖南电信-同步订单信息")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SyncOrderResp>>
|
||||
syncOrder(@RequestBody HaiNanDxInfo.SyncOrderParam param) throws Exception {
|
||||
return success(apiHuNanDXService.syncOrder(param));
|
||||
}
|
||||
|
||||
@PostMapping("/queryOrder")
|
||||
@Operation(summary = "湖南电信-查询订单详情")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryOrderResp>>
|
||||
queryOrder(@RequestBody HaiNanDxInfo.QueryOrderParam param) throws Exception {
|
||||
return success(apiHuNanDXService.queryOrder(param));
|
||||
}
|
||||
|
||||
@PostMapping("/sendSmsCode")
|
||||
@Operation(summary = "湖南电信-发送短信验证码")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.SendSmsCodeResp>>
|
||||
sendSmsCode(@RequestBody HaiNanDxInfo.SendSmsCodeParam param) throws Exception {
|
||||
return success(apiHuNanDXService.sendSmsCode(param));
|
||||
}
|
||||
|
||||
@PostMapping("/verifySmsCode")
|
||||
@Operation(summary = "湖南电信-验证短信验证码")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.VerifySmsCodeResp>>
|
||||
verifySmsCode(@RequestBody HaiNanDxInfo.VerifySmsCodeParam param) throws Exception {
|
||||
return success(apiHuNanDXService.verifySmsCode(param));
|
||||
}
|
||||
|
||||
@PostMapping("/queryPhoneNumber")
|
||||
@Operation(summary = "湖南电信-查询号码")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.QueryPhoneNumberResp>>
|
||||
queryPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.QueryPhoneNumberParam> param) throws Exception {
|
||||
return success(apiHuNanDXService.queryPhoneNumber(param));
|
||||
}
|
||||
|
||||
@PostMapping("/possessPhoneNumber")
|
||||
@Operation(summary = "湖南电信-占用号码")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.PossessPhoneNumberResp>>
|
||||
possessPhoneNumber(@RequestBody HaiNanDxInfo.NeedSignQueryParam<HaiNanDxInfo.PossessPhoneNumberParam> param) throws Exception {
|
||||
return success(apiHuNanDXService.possessPhoneNumber(param));
|
||||
}
|
||||
|
||||
@PostMapping("/checkBlackList")
|
||||
@Operation(summary = "湖南电信-检查黑名单")
|
||||
public CommonResult<HaiNanDxInfo.ResponseInfo<HaiNanDxInfo.BlackListCheckResp>>
|
||||
checkBlackList(@RequestBody HaiNanDxInfo.BlackListCheckParam param) throws Exception {
|
||||
return success(apiHuNanDXService.checkBlackList(param));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue