Commit 7fb092c5 authored by hezhen's avatar hezhen

添加短信机

parent 702ff965
......@@ -41,6 +41,14 @@
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- 短信机-->
<dependency>
<groupId>sms</groupId>
<artifactId>sms</artifactId>
<version>2.6.3</version>
<scope>system</scope>
<systemPath>D:/hezhen/Program Files/apache-maven-3.5.4/repo/sms/CCP_REST_SMS_SDK_JAVA_v2.6.3r.jar</systemPath>
</dependency>
</dependencies>
......
package com.xxfc.platform.universal.dto;
import lombok.Data;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/3 17:51
*/
@Data
public class SmsTemplateDTO {
//类型:1-租车订单通知(普通用户),2-租车订单短信(会员权益),3-旅游订单短信,4-加入会员通知
private Integer type;
//手机号码(多个短信逗号隔开)
private String phoneNumbers;
//参数
private String[] params;
}
......@@ -3,6 +3,7 @@ package com.xxfc.platform.universal.feign;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.universal.dto.RegionDTO;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.vo.*;
......@@ -29,6 +30,9 @@ public interface ThirdFeign {
@RequestMapping(value = "/sms/app/unauth/sendCode", method = RequestMethod.GET)
//发送短信模板消息
public JSONObject sendCode(@RequestParam("phone") String phone, @RequestParam("code")String code, @RequestParam("templateCode")String templateCode );
//云通讯短信机
@RequestMapping(value = "/app/unauth/sendTemplate", method = RequestMethod.GET)
public ObjectRestResponse sendTemplate(SmsTemplateDTO smsTemplateDTO);
@RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST)
public JSONObject uploadFiles(@RequestParam(value = "files") MultipartFile[] files);
@RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST)
......
package com.xxfc.platform.universal.utils;
import com.cloopen.rest.sdk.CCPRestSmsSDK;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class CCPRestSmsUtils {
public static CCPRestSmsSDK restAPI;
static {
restAPI = new CCPRestSmsSDK();
restAPI.init("app.cloopen.com", "8883");
restAPI.setAccount("8aaf070865e6b6eb0165ecd776700559",
"3fe5e2f053674f23b029a9a9fc9503f0");
restAPI.setAppId("8a216da86812593601684bec10581ab5");
}
public static Map<String, Object> sendTemplateSMS(String phoneNumbers, String[] params, String templateId) {
HashMap<String, Object> result = null;
result = restAPI.sendTemplateSMS(phoneNumbers, templateId, params);
System.out.println("SDKTestGetSubAccounts result=" + result);
if ("000000".equals(result.get("statusCode"))) {
// 正常返回输出data包体信息(map)
HashMap<String, Object> data = (HashMap<String, Object>) result.get("data");
Set<String> keySet = data.keySet();
for (String key : keySet) {
Object object = data.get(key);
System.out.println(key + " = " + object);
}
} else {
// 异常返回输出错误码和错误信息
System.out.println("错误码=" + result.get("statusCode") + " 错误信息= " + result.get("statusMsg"));
}
return result;
}
}
\ No newline at end of file
package com.xxfc.platform.universal.biz;
import com.xxfc.platform.universal.utils.CCPRestSmsUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class CCPRestSmsBiz{
//租车订单通知(普通用户)1
public static final String TEMPLATE_ID_ORDER = "457270";
//租车订单短信(会员权益)2
public static final String TEMPLATE_ID_ORDER_MEMBER = "457271";
//旅游订单短信3
public static final String TEMPLATE_ID_ORDER_TOUR = "457272";
//加入会员通知4
public static final String TEMPLATE_ID_MEMBER = "457273";
//发送模板消息
public void sendTemplateSMS(Integer type,String phoneNumbers,String[]params){
switch (type){
case 1 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER);
break;
case 2 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_MEMBER);
break;
case 3 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_ORDER_TOUR);
break;
case 4 :
CCPRestSmsUtils.sendTemplateSMS(phoneNumbers,params,TEMPLATE_ID_MEMBER);
break;
}
}
}
......@@ -3,7 +3,10 @@ package com.xxfc.platform.universal.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.biz.CCPRestSmsBiz;
import com.xxfc.platform.universal.dto.SmsTemplateDTO;
import com.xxfc.platform.universal.service.SmsService;
import com.xxfc.platform.universal.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,6 +32,9 @@ public class SmsController {
@Autowired
SmsService smsService;
@Autowired
CCPRestSmsBiz smsBiz;
@RequestMapping(value = "/app/unauth/send", method = RequestMethod.GET) //匹配的是href中的download请求
public JSONObject sendSms(@RequestParam("phone") String phone) throws Exception {
return smsService.smsCode(phone);
......@@ -40,5 +46,17 @@ public class SmsController {
@RequestParam("templateCode")String templateCode ) throws Exception {
return smsService.smsByCode(phone,code,templateCode);
}
@RequestMapping(value = "/app/unauth/sendTemplate", method = RequestMethod.GET)
public ObjectRestResponse sendTemplate(SmsTemplateDTO smsTemplateDTO) throws Exception {
if(smsTemplateDTO==null){
return ObjectRestResponse.createDefaultFail();
}
Integer type=smsTemplateDTO.getType();
String[] params=smsTemplateDTO.getParams();
String phoneNumbers=smsTemplateDTO.getPhoneNumbers();
smsBiz.sendTemplateSMS(type,phoneNumbers,params);
return ObjectRestResponse.succ();
}
}
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