增加了对公充值的短信通知

This commit is contained in:
1215525055@qq.com 2025-03-03 11:47:43 +08:00
parent 3307f3c335
commit 8f496ce8c5
3 changed files with 245 additions and 1 deletions

View File

@ -17,14 +17,16 @@ import cn.com.tenlion.operator.service.accountbank.IAccountBankService;
import cn.com.tenlion.operator.service.accountitem.IAccountItemService;
import cn.com.tenlion.operator.service.remote.IRemoteWangGengInvoiceService;
import cn.com.tenlion.operator.service.sys.callback.SysCallbackService;
import cn.com.tenlion.operator.util.TenlionSMS;
import cn.com.tenlion.operator.util.UserUtil;
import cn.com.tenlion.operator.util.pay.ALiPay;
import cn.com.tenlion.operator.util.pay.PayResultDTO;
import cn.com.tenlion.operator.util.pay.PayUtil;
import cn.com.tenlion.operator.util.pay.WXPay;
import cn.com.tenlion.projectconfig.util.ProjectConfigUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.exceptions.SaveException;
@ -433,6 +435,22 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
SuccessResult result = operatorPluginRemoteService.saveOrder(systemApiPathProperties.getOperatorPlugin(), appVO, accessToken);
System.out.println("调用套餐包创建结果 : " + result);
}
if (ThirdPartyEnum.DGZZ.getValue().equals(thirdParty)) {
/**
* 向系统人员发送信息
*/
JSONArray phoneArray = new JSONArray();
String[] phones = ProjectConfigUtil.getText("HandleRechargePhones").split(",");
for(String phone : phones) {
com.alibaba.fastjson.JSONObject obj1 = new JSONObject();
obj1.put("phone", phone);
phoneArray.add(obj1);
}
Map<String, String> templateParams = new HashMap<>();
templateParams.put("count", 1 + "");
templateParams.put("money", PayUtil.buiderMoney(totalMoney) + "");
TenlionSMS.sendMessage(UUIDUtil.getUUID(), "M00005", templateParams, phoneArray);
}
}
return payDTO;
}

View File

@ -0,0 +1,44 @@
package cn.com.tenlion.operator.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class OperatorSpringUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if(OperatorSpringUtil.applicationContext == null) {
OperatorSpringUtil.applicationContext = applicationContext;
}
System.out.println("---------------------------------------------------------------------");
System.out.println("--------------------------OperatorSpringUtil------------------------");
System.out.println("========ApplicationContext配置成功,在普通类可以通过调用SpringUtils.getAppContext()获取applicationContext对象,applicationContext="+OperatorSpringUtil.applicationContext+"========");
System.out.println("---------------------------------------------------------------------");
}
//获取applicationContext
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
//通过name获取 Bean.
public static Object getBean(String name){
return getApplicationContext().getBean(name);
}
//通过class获取Bean.
public static <T> T getBean(Class<T> clazz){
return getApplicationContext().getBean(clazz);
}
//通过name,以及Clazz返回指定的Bean
public static <T> T getBean(String name,Class<T> clazz){
return getApplicationContext().getBean(name, clazz);
}
}

View File

@ -0,0 +1,182 @@
package cn.com.tenlion.operator.util;
import cn.com.tenlion.operator.properties.SystemApiPathProperties;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* 腾狮短信工具类
* @author Administrator
* 崔宝铖 2023年5月12日11:28:11
*/
public class TenlionSMS {
private static String smsKey = "c7bbe767-dad7-413b-a9f7-3d49d556366c";
private static String smsSecret = "zinF7QrbMmg72CyahEReu6vZJ4L9j1HB";
private static String systemUrl = "http://192.168.0.115:8099/operator-plugin";
// 短信发送地址
private static String sendSMSUrl = systemUrl + "/app/send";
// 短信状态查询地址
private static String getStatusSMSUrl = systemUrl + "/app/send/status";
// 短信回复列表查询
private static String getReplySMSUrl = systemUrl + "/app/send/reply";
// 账号可用模板列表查询
private static String getTemplateSMSUrl = systemUrl + "/app/send/template";
static{
SystemApiPathProperties apiPathProperties = OperatorSpringUtil.getBean(SystemApiPathProperties.class);
systemUrl = apiPathProperties.getOperatorPlugin();
if (systemUrl.endsWith("/")) {
systemUrl = systemUrl.substring(0, systemUrl.length() -1);
}
}
public static void main(String[] args) {
// 可用模板列表
// System.out.println(getTemplate());
// 短信发送
String uuid = UUID.randomUUID().toString();
Map<String, String> templateParams = new HashMap<String, String>();
templateParams.put("content", "您的验证码是123356");
JSONArray phoneArray = new JSONArray();
JSONObject obj1 = new JSONObject();
obj1.put("phone", "17691030315");
phoneArray.add(obj1);
System.out.println(sendMessage(uuid, "M00002", templateParams, phoneArray));
// 短信回复查询
System.out.println(getMessageReply(uuid, "17691030315"));
// 短信状态查询
// System.out.println(getMessageStatus("26800e6c-004a-4d77-bac2-3f80c70a423d", "17691030315"));
}
/**
* 获取模板列表
* @return
*/
public static JSONArray getTemplate() {
// jsonPost请求
HttpGet httpGet = new HttpGet(getTemplateSMSUrl);
httpGet.addHeader("smsKey", smsKey);
httpGet.addHeader("smsSecret", smsSecret);
CloseableHttpClient client = HttpClients.createDefault();
//定义接收数据
JSONArray result = new JSONArray();
try {
HttpResponse response = client.execute(httpGet);
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
result = JSON.parseArray(body);
System.out.println("返回结果:" + result.toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 短信回复查询
* @param smsNO 36位UUID
* @param phone 手机号
* @return
*/
public static JSONObject getMessageReply(String smsNO, String phone) {
// jsonPost请求
HttpGet httpGet = new HttpGet(getReplySMSUrl + "?smsNO=" + smsNO + "&phone=" + phone);
httpGet.addHeader("smsKey", smsKey);
httpGet.addHeader("smsSecret", smsSecret);
CloseableHttpClient client = HttpClients.createDefault();
//定义接收数据
JSONObject result = new JSONObject();
try {
HttpResponse response = client.execute(httpGet);
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
result = JSON.parseObject(body);
System.out.println("返回结果:" + result.toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 短信状态查询
* @param smsNO 36位UUID
* @param phone 手机号
* @return
*/
public static JSONObject getMessageStatus(String smsNO, String phone) {
// jsonPost请求
HttpGet httpGet = new HttpGet(getStatusSMSUrl + "?smsNO=" + smsNO + "&phone=" + phone);
httpGet.addHeader("smsKey", smsKey);
httpGet.addHeader("smsSecret", smsSecret);
CloseableHttpClient client = HttpClients.createDefault();
//定义接收数据
JSONObject result = new JSONObject();
try {
HttpResponse response = client.execute(httpGet);
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
result = JSON.parseObject(body);
System.out.println("返回结果:" + result.toJSONString());
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 短信发送
* @param smsNO 36位UUID
* @param templateCode 模板编码
* @param templateParams 模板参数
* @param phoneArray 接收号码集
* @return
*/
public static Boolean sendMessage(String smsNO, String templateCode, Map<String, String> templateParams, JSONArray phoneArray) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("smsNo", smsNO);
jsonObject.put("phoneArray", phoneArray);
jsonObject.put("templateParams", templateParams);
// jsonPost请求
HttpPost httpPost = new HttpPost(sendSMSUrl + "/" + templateCode);
httpPost.addHeader("smsKey", smsKey);
httpPost.addHeader("smsSecret", smsSecret);
CloseableHttpClient client = HttpClients.createDefault();
// 请求参数转JOSN字符串
StringEntity entity = new StringEntity(jsonObject.toString(), "UTF-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
//定义接收数据
JSONObject result = new JSONObject();
try {
HttpResponse response = client.execute(httpPost);
String body = EntityUtils.toString(response.getEntity(), "UTF-8");
result = JSON.parseObject(body);
System.out.println("返回结果:" + result.toJSONString());
if("200".equals(result.getString("code"))){
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
}