From d1c929bdac6cab4d60bfcd56d41e8d5f2f9e8b5a Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 19 二月 2024 10:04:20 +0800
Subject: [PATCH] 提交新版本
---
UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ChinaMobileUtil.java | 428 ++++++++++++++++++++++++++--------------------------
1 files changed, 214 insertions(+), 214 deletions(-)
diff --git a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ChinaMobileUtil.java b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ChinaMobileUtil.java
index 62f43fa..e1030fa 100644
--- a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ChinaMobileUtil.java
+++ b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ChinaMobileUtil.java
@@ -1,214 +1,214 @@
-package com.stylefeng.guns.modular.system.util;
-
-import com.alibaba.fastjson.JSONObject;
-import com.aliyuncs.CommonRequest;
-import com.aliyuncs.CommonResponse;
-import com.aliyuncs.DefaultAcsClient;
-import com.aliyuncs.IAcsClient;
-import com.aliyuncs.ecs.model.v20140526.DescribeInstancesRequest;
-import com.aliyuncs.exceptions.ClientException;
-import com.aliyuncs.exceptions.ServerException;
-import com.aliyuncs.http.MethodType;
-import com.aliyuncs.profile.DefaultProfile;
-import com.google.gson.Gson;
-import com.stylefeng.guns.core.qr.ImgQrTool;
-import com.stylefeng.guns.core.qr.QrImage;
-import com.stylefeng.guns.core.util.DateUtil;
-import com.stylefeng.guns.core.util.MD5Util;
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * 中国移动工具类
- */
-@Component
-public class ChinaMobileUtil {
-
- private static String APIKey = "LTAI4G1BpRaihVRZp1RS8Stn";
-
- private static String SecretKey = "PDR7uUEGNf0wIPPVCPCVdySgTwCr90";
-
- @Autowired
- private HttpClientUtil httpClientUtil;
-
-
- /**
- * 绑定小号
- * @param phoneA
- * @param phoneB
- * @param areaCode
- * @return
- * @throws Exception
- */
- public static Map<String, String> midAxbBindSend(String phoneA, String phoneB, Integer areaCode) throws Exception{
- Map<String, String> map1 = new HashMap<>();
- map1.put("code", "-1");
- map1.put("msg", "");
- map1.put("telX", "");
- map1.put("bindId", "");
- return map1;
- //暂时屏蔽-后期放开
- /*DefaultProfile profile = DefaultProfile.getProfile(
- "cn-hangzhou", // 地域ID
- APIKey, // 您的AccessKey ID
- SecretKey ); // 您的AccessKey Secret
- IAcsClient client = new DefaultAcsClient(profile);
-
- CommonRequest request = new CommonRequest();
- request.setMethod(MethodType.POST);
- request.setDomain("dyplsapi.aliyuncs.com");
- request.setVersion("2017-05-25");
- request.setAction("BindAxb");
- // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
- request.putQueryParameter("Expiration", DateUtil.format(new Date(new Date().getTime()+7 * 24 * 60 * 60*1000L),"yyyy-MM-dd HH:mm:ss"));
- // 号码池Key
- request.putQueryParameter("PoolKey", "FC100000119206151");
- // AXB中的B号码
- request.putQueryParameter("PhoneNoB", phoneB);
- // AXB中的A号码
- request.putQueryParameter("PhoneNoA", phoneA);
- // 指定城市进行X号码的选号。
- request.putQueryParameter("ExpectCity", "北京");
- // 是否需要针对该绑定关系产生的所有通话录制通话录音。
- request.putQueryParameter("IsRecordingEnabled", "false");
- Map<String, String> map1 = new HashMap<>();
- try {
- CommonResponse response = client.getCommonResponse(request);
- // 处理请求结果
- System.out.println(response.getData());
- JSONObject jsonObject = JSONObject.parseObject(response.getData());
- if(jsonObject.getString("Code").equals("OK")){
- map1.put("code", "200");
- map1.put("msg", jsonObject.getString("Message"));
- map1.put("telX", jsonObject.getJSONObject("SecretBindDTO").getString("SecretNo"));
- map1.put("bindId", jsonObject.getJSONObject("SecretBindDTO").getString("SubsId"));
- }else{
- map1.put("code", jsonObject.getString("Code"));
- map1.put("msg", jsonObject.getString("Message"));
- }
- } catch (ServerException e) {
- e.printStackTrace();
- map1.put("code", "-1");
- map1.put("msg", e.getErrMsg());
- } catch (ClientException e) {
- System.out.println("ErrCode:" + e.getErrCode());
- System.out.println("ErrMsg:" + e.getErrMsg());
- System.out.println("RequestId:" + e.getRequestId());
- map1.put("code", "-1");
- map1.put("msg", e.getErrMsg());
- }
- return map1;*/
- }
-
-
- /**
- * 解绑小号关系
- * @param bindId 绑定关系id
- * @return
- * @throws Exception
- */
- public static Map<String, String> midAxbUnBindSend(String bindId,String secretNo) throws Exception{
- //组装请求对象-具体描述见开发文档-订单小号-AXB接口规范部分内容
- /*Map<String, Object> request = new HashMap<>();
- //绑定关系ID
- request.put("APPID", APIKey);
- request.put("bindId", bindId);
-
- Map<String, String> header = new HashMap<String, String>(3);
- header.put("Authorization", "Basic " + new String(Base64.encodeBase64((APIKey + ":" + SecretKey).getBytes())));
- header.put("Content-Type", "application/json;charset=utf-8");
- String post = httpClientUtil.pushHttpRequset("POST", "https://ct.open.10086.cn/ordernumber/v1/unbinding", request, header, "json");
- JSONObject jsonObject = JSONObject.parseObject(post);
- Map<String, String> map1 = new HashMap<>();
- if(jsonObject.getString("code").equals("0000")){
- map1.put("code", "200");
- map1.put("msg", jsonObject.getString("message"));
- }else{
- map1.put("code", jsonObject.getString("code"));
- map1.put("msg", jsonObject.getString("message"));
- }
- return map1;*/
- DefaultProfile profile = DefaultProfile.getProfile(
- "cn-hangzhou", // 地域ID
- APIKey, // 您的AccessKey ID
- SecretKey ); // 您的AccessKey Secret
- IAcsClient client = new DefaultAcsClient(profile);
-
- CommonRequest request = new CommonRequest();
- request.setMethod(MethodType.POST);
- request.setDomain("dyplsapi.aliyuncs.com");
- request.setVersion("2017-05-25");
- request.setAction("UnbindSubscription");
- // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
- // 号码池Key
- request.putQueryParameter("PoolKey", "FC100000119206151");
- // 隐私号码。调用BindAXG等号码绑定接口时指定或自动分配的X号码。
- request.putQueryParameter("SecretNo", secretNo);
- // 绑定关系ID。
- //
- //可以在控制台的号码管理 > 号码详情中查看绑定关系ID,或者在调用BindAxb等号码绑定API时查看返回参数中的SubsId。
- request.putQueryParameter("SubsId", bindId);
- Map<String, String> map1 = new HashMap<>();
- try {
- CommonResponse response = client.getCommonResponse(request);
- // 处理请求结果
- System.out.println(response.getData());
- JSONObject jsonObject = JSONObject.parseObject(response.getData());
- if(jsonObject.getString("Code").equals("OK")){
- map1.put("code", "200");
- map1.put("msg", jsonObject.getString("Message"));
- }else{
- map1.put("code", jsonObject.getString("Code"));
- map1.put("msg", jsonObject.getString("Message"));
- }
- } catch (ServerException e) {
- e.printStackTrace();
- map1.put("code", "-1");
- map1.put("msg", e.getErrMsg());
- } catch (ClientException e) {
- System.out.println("ErrCode:" + e.getErrCode());
- System.out.println("ErrMsg:" + e.getErrMsg());
- System.out.println("RequestId:" + e.getRequestId());
- map1.put("code", "-1");
- map1.put("msg", e.getErrMsg());
- }
- return map1;
- }
-
- public static void main(String[] args) throws IOException {
- try{
- //System.out.println(midAxbBindSend("18380476116","13688394165",null));
- System.out.println(midAxbUnBindSend("1000028383491415","17150195840"));
- }catch (Exception e){
-
- }
-
- }
-
-
- public Map<String, String> HeaderUtils(String APIKey, String SecretKey) throws Exception{
- Map<String, String> header = new HashMap<>();
- long time = System.currentTimeMillis();
- String signStr = MD5Util.encrypt(APIKey + SecretKey + time);
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("apiKey", APIKey);
- jsonObject.put("time", time);
- jsonObject.put("sign", signStr);
- Base64 base64 = new Base64();
- String s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
- header.put("header", s);
-
- jsonObject = new JSONObject();
- jsonObject.put("platformId", "");
- jsonObject.put("secret", "");
- s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
- header.put("accessCode", s);
- return header;
- }
-}
+//package com.stylefeng.guns.modular.system.util;
+//
+//import com.alibaba.fastjson.JSONObject;
+//import com.aliyuncs.CommonRequest;
+//import com.aliyuncs.CommonResponse;
+//import com.aliyuncs.DefaultAcsClient;
+//import com.aliyuncs.IAcsClient;
+//import com.aliyuncs.ecs.model.v20140526.DescribeInstancesRequest;
+//import com.aliyuncs.exceptions.ClientException;
+//import com.aliyuncs.exceptions.ServerException;
+//import com.aliyuncs.http.MethodType;
+//import com.aliyuncs.profile.DefaultProfile;
+//import com.google.gson.Gson;
+//import com.stylefeng.guns.core.qr.ImgQrTool;
+//import com.stylefeng.guns.core.qr.QrImage;
+//import com.stylefeng.guns.core.util.DateUtil;
+//import com.stylefeng.guns.core.util.MD5Util;
+//import org.apache.commons.codec.binary.Base64;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//
+//import java.io.IOException;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+///**
+// * 中国移动工具类
+// */
+//@Component
+//public class ChinaMobileUtil {
+//
+// private static String APIKey = "1111";
+//
+// private static String SecretKey = "111";
+//
+// @Autowired
+// private HttpClientUtil httpClientUtil;
+//
+//
+// /**
+// * 绑定小号
+// * @param phoneA
+// * @param phoneB
+// * @param areaCode
+// * @return
+// * @throws Exception
+// */
+// public static Map<String, String> midAxbBindSend(String phoneA, String phoneB, Integer areaCode) throws Exception{
+// Map<String, String> map1 = new HashMap<>();
+// map1.put("code", "-1");
+// map1.put("msg", "");
+// map1.put("telX", "");
+// map1.put("bindId", "");
+// return map1;
+// //暂时屏蔽-后期放开
+// /*DefaultProfile profile = DefaultProfile.getProfile(
+// "cn-hangzhou", // 地域ID
+// APIKey, // 您的AccessKey ID
+// SecretKey ); // 您的AccessKey Secret
+// IAcsClient client = new DefaultAcsClient(profile);
+//
+// CommonRequest request = new CommonRequest();
+// request.setMethod(MethodType.POST);
+// request.setDomain("dyplsapi.aliyuncs.com");
+// request.setVersion("2017-05-25");
+// request.setAction("BindAxb");
+// // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
+// request.putQueryParameter("Expiration", DateUtil.format(new Date(new Date().getTime()+7 * 24 * 60 * 60*1000L),"yyyy-MM-dd HH:mm:ss"));
+// // 号码池Key
+// request.putQueryParameter("PoolKey", "FC100000119206151");
+// // AXB中的B号码
+// request.putQueryParameter("PhoneNoB", phoneB);
+// // AXB中的A号码
+// request.putQueryParameter("PhoneNoA", phoneA);
+// // 指定城市进行X号码的选号。
+// request.putQueryParameter("ExpectCity", "北京");
+// // 是否需要针对该绑定关系产生的所有通话录制通话录音。
+// request.putQueryParameter("IsRecordingEnabled", "false");
+// Map<String, String> map1 = new HashMap<>();
+// try {
+// CommonResponse response = client.getCommonResponse(request);
+// // 处理请求结果
+// System.out.println(response.getData());
+// JSONObject jsonObject = JSONObject.parseObject(response.getData());
+// if(jsonObject.getString("Code").equals("OK")){
+// map1.put("code", "200");
+// map1.put("msg", jsonObject.getString("Message"));
+// map1.put("telX", jsonObject.getJSONObject("SecretBindDTO").getString("SecretNo"));
+// map1.put("bindId", jsonObject.getJSONObject("SecretBindDTO").getString("SubsId"));
+// }else{
+// map1.put("code", jsonObject.getString("Code"));
+// map1.put("msg", jsonObject.getString("Message"));
+// }
+// } catch (ServerException e) {
+// e.printStackTrace();
+// map1.put("code", "-1");
+// map1.put("msg", e.getErrMsg());
+// } catch (ClientException e) {
+// System.out.println("ErrCode:" + e.getErrCode());
+// System.out.println("ErrMsg:" + e.getErrMsg());
+// System.out.println("RequestId:" + e.getRequestId());
+// map1.put("code", "-1");
+// map1.put("msg", e.getErrMsg());
+// }
+// return map1;*/
+// }
+//
+//
+// /**
+// * 解绑小号关系
+// * @param bindId 绑定关系id
+// * @return
+// * @throws Exception
+// */
+// public static Map<String, String> midAxbUnBindSend(String bindId,String secretNo) throws Exception{
+// //组装请求对象-具体描述见开发文档-订单小号-AXB接口规范部分内容
+// /*Map<String, Object> request = new HashMap<>();
+// //绑定关系ID
+// request.put("APPID", APIKey);
+// request.put("bindId", bindId);
+//
+// Map<String, String> header = new HashMap<String, String>(3);
+// header.put("Authorization", "Basic " + new String(Base64.encodeBase64((APIKey + ":" + SecretKey).getBytes())));
+// header.put("Content-Type", "application/json;charset=utf-8");
+// String post = httpClientUtil.pushHttpRequset("POST", "https://ct.open.10086.cn/ordernumber/v1/unbinding", request, header, "json");
+// JSONObject jsonObject = JSONObject.parseObject(post);
+// Map<String, String> map1 = new HashMap<>();
+// if(jsonObject.getString("code").equals("0000")){
+// map1.put("code", "200");
+// map1.put("msg", jsonObject.getString("message"));
+// }else{
+// map1.put("code", jsonObject.getString("code"));
+// map1.put("msg", jsonObject.getString("message"));
+// }
+// return map1;*/
+// DefaultProfile profile = DefaultProfile.getProfile(
+// "cn-hangzhou", // 地域ID
+// APIKey, // 您的AccessKey ID
+// SecretKey ); // 您的AccessKey Secret
+// IAcsClient client = new DefaultAcsClient(profile);
+//
+// CommonRequest request = new CommonRequest();
+// request.setMethod(MethodType.POST);
+// request.setDomain("dyplsapi.aliyuncs.com");
+// request.setVersion("2017-05-25");
+// request.setAction("UnbindSubscription");
+// // 绑定关系的过期时间。必须晚于当前时间1分钟以上。
+// // 号码池Key
+// request.putQueryParameter("PoolKey", "FC100000119206151");
+// // 隐私号码。调用BindAXG等号码绑定接口时指定或自动分配的X号码。
+// request.putQueryParameter("SecretNo", secretNo);
+// // 绑定关系ID。
+// //
+// //可以在控制台的号码管理 > 号码详情中查看绑定关系ID,或者在调用BindAxb等号码绑定API时查看返回参数中的SubsId。
+// request.putQueryParameter("SubsId", bindId);
+// Map<String, String> map1 = new HashMap<>();
+// try {
+// CommonResponse response = client.getCommonResponse(request);
+// // 处理请求结果
+// System.out.println(response.getData());
+// JSONObject jsonObject = JSONObject.parseObject(response.getData());
+// if(jsonObject.getString("Code").equals("OK")){
+// map1.put("code", "200");
+// map1.put("msg", jsonObject.getString("Message"));
+// }else{
+// map1.put("code", jsonObject.getString("Code"));
+// map1.put("msg", jsonObject.getString("Message"));
+// }
+// } catch (ServerException e) {
+// e.printStackTrace();
+// map1.put("code", "-1");
+// map1.put("msg", e.getErrMsg());
+// } catch (ClientException e) {
+// System.out.println("ErrCode:" + e.getErrCode());
+// System.out.println("ErrMsg:" + e.getErrMsg());
+// System.out.println("RequestId:" + e.getRequestId());
+// map1.put("code", "-1");
+// map1.put("msg", e.getErrMsg());
+// }
+// return map1;
+// }
+//
+// public static void main(String[] args) throws IOException {
+// try{
+// //System.out.println(midAxbBindSend("18380476116","13688394165",null));
+// System.out.println(midAxbUnBindSend("1000028383491415","17150195840"));
+// }catch (Exception e){
+//
+// }
+//
+// }
+//
+//
+// public Map<String, String> HeaderUtils(String APIKey, String SecretKey) throws Exception{
+// Map<String, String> header = new HashMap<>();
+// long time = System.currentTimeMillis();
+// String signStr = MD5Util.encrypt(APIKey + SecretKey + time);
+// JSONObject jsonObject = new JSONObject();
+// jsonObject.put("apiKey", APIKey);
+// jsonObject.put("time", time);
+// jsonObject.put("sign", signStr);
+// Base64 base64 = new Base64();
+// String s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
+// header.put("header", s);
+//
+// jsonObject = new JSONObject();
+// jsonObject.put("platformId", "");
+// jsonObject.put("secret", "");
+// s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8"));
+// header.put("accessCode", s);
+// return header;
+// }
+//}
--
Gitblit v1.7.1