Commit 008568de authored by fuwanli's avatar fuwanli

"上"

parent 67f2b6a5
package com.bgy.sms.channel.api; package com.bgy.sms.channel.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bgy.sms.channel.bgy.config.BgySMSConfig; import com.bgy.sms.channel.bgy.config.BgySMSConfig;
import com.bgy.sms.channel.dmHub.config.DmHubConfig; import com.bgy.sms.channel.dmHub.config.DmHubConfig;
...@@ -15,6 +16,9 @@ import org.slf4j.LoggerFactory; ...@@ -15,6 +16,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("Duplicates") @SuppressWarnings("Duplicates")
@RestController @RestController
@RequestMapping() @RequestMapping()
...@@ -94,10 +98,28 @@ public class DmHubApi { ...@@ -94,10 +98,28 @@ public class DmHubApi {
DmHubResponse response; DmHubResponse response;
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { /* if (!checkResult) {
return new DmHubResponse("555", "接口请求签名校验不通过"); return new DmHubResponse("555", "接口请求签名校验不通过");
}*/
List<JSONObject> data = new ArrayList<>();
for (int x = 0; x < 5; x++) {
String a = "{\n" +
"\t\"_audienceId\": \"15323888603\",\n" +
"\t\"name\": \"大夹子\",\n" +
"\t\"id\": \"699169968926801920\",\n" +
"\t\"isRealtime\": false\n" +
"}";
a = a.replaceAll("15323888603", "1532388860" + (3 + x));
JSONObject c = JSON.parseObject(a);
data.add(c);
} }
request.setData(data);
response = messageService.batchSendOneByOne(request); response = messageService.batchSendOneByOne(request);
response.setCode(response.getError().getString("errorCode"));
} catch (Exception e) { } catch (Exception e) {
log.error("发送批量短信异常", e); log.error("发送批量短信异常", e);
response = new DmHubResponse(ResponseCode.SYSTEM_ERROR); response = new DmHubResponse(ResponseCode.SYSTEM_ERROR);
...@@ -128,11 +150,24 @@ public class DmHubApi { ...@@ -128,11 +150,24 @@ public class DmHubApi {
log.info("**********单条发送入参*******:{},\r\n appId:{},timestamp:{},signature:{}", JSONObject.toJSONString(request), appId, timestamp, signature); log.info("**********单条发送入参*******:{},\r\n appId:{},timestamp:{},signature:{}", JSONObject.toJSONString(request), appId, timestamp, signature);
DmHubResponse response; DmHubResponse response;
try { try {
boolean checkResult = this.checkSignature(timestamp, signature); /* boolean checkResult = this.checkSignature(timestamp, signature);
if (!checkResult) { if (!checkResult) {
return new DmHubResponse("555", "签名校验不通过"); return new DmHubResponse("555", "签名校验不通过");
} }*/
String a = "{\n" +
"\t\"_audienceId\": \"15323888603\",\n" +
"\t\"name\": \"大夹子\",\n" +
"\t\"id\": \"699169968926801920\",\n" +
"\t\"isRealtime\": false\n" +
"}";
JSONObject c = JSON.parseObject(a);
request.setData(c);
response = messageService.send(request); response = messageService.send(request);
response.setCode(response.getError().getString("errorCode"));
} catch (Exception e) { } catch (Exception e) {
log.error("发送单条短信异常", e); log.error("发送单条短信异常", e);
response = new DmHubResponse(ResponseCode.SYSTEM_ERROR); response = new DmHubResponse(ResponseCode.SYSTEM_ERROR);
......
...@@ -8,6 +8,8 @@ public interface BgySmsService { ...@@ -8,6 +8,8 @@ public interface BgySmsService {
CLBizResponse sendSms(String mobile, String content, String areaId) throws Exception; CLBizResponse sendSms(String mobile, String content, String areaId) throws Exception;
CLBizResponse sendbatchSms(String mobile, String areaId) throws Exception;
void asyncNotify(TemplateNotify templateNotify); void asyncNotify(TemplateNotify templateNotify);
} }
...@@ -78,6 +78,40 @@ public class BgySmsServiceImpl implements BgySmsService { ...@@ -78,6 +78,40 @@ public class BgySmsServiceImpl implements BgySmsService {
} }
} }
@Override
public CLBizResponse sendbatchSms(String data, String areaId) throws Exception {
log.info("进入碧桂园短信发送接口");
String appId = BgySMSConfig.appId;
// String areaId = BgySMSConfig.areaId;
String securityCode = BgySMSConfig.securityCode;
String url = BgySMSConfig.url;
String api = BgySMSConfig.api;
Map<String, String> requestParams = new HashMap<>();
requestParams.put("api", api);
requestParams.put("appId", appId);
requestParams.put("security", Md5Util.encrypt(appId + securityCode.toUpperCase()));
requestParams.put("areaId", areaId);
requestParams.put("data", data);
log.info("碧桂园短信接口参数:{}", requestParams);
String retStr = SendSmsUtil.sendSmsByPost(url, JSONObject.toJSONString(requestParams));
log.info("碧桂园短信接口返回信息:{}", retStr);
if (retStr == null) {
return new CLBizResponse(ResponseCode.UPSTREAM_BLANK);
}
JSONObject retJson = JSONObject.parseObject(retStr);
String err = retJson.getString("err");
String retPack = retJson.getString("package");
String retCode = retJson.getString("ret");
if (!sendSuccessCode.equals(retCode)) {
if (err.contains("成功")) {
return new CLBizResponse(ResponseCode.SUCCESS);
}
return new CLBizResponse(ResponseCode.UPSTREAM_FAIL.getCode(), err);
} else {
return new CLBizResponse(ResponseCode.SUCCESS);
}
}
/** /**
* 处理短信模板的通知 * 处理短信模板的通知
* *
......
package com.bgy.sms.repository.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import java.util.Date;
@TableName("sms_record")
public class SysRecordInfo {
private Long id;
private Long sysBatchId;
private String mobile;
private String msgId;
private Integer chargeNum;
private String content;
private String params;
private String status;
private String statusDesc;
private Date dateCreated;
private Date lastUpdated;
private String areaId;
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSysBatchId() {
return sysBatchId;
}
public void setSysBatchId(Long sysBatchId) {
this.sysBatchId = sysBatchId;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getMsgId() {
return msgId;
}
public void setMsgId(String msgId) {
this.msgId = msgId;
}
public Integer getChargeNum() {
return chargeNum;
}
public void setChargeNum(Integer chargeNum) {
this.chargeNum = chargeNum;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusDesc() {
return statusDesc;
}
public void setStatusDesc(String statusDesc) {
this.statusDesc = statusDesc;
}
public Date getDateCreated() {
return dateCreated;
}
public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}
public Date getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}
}
package com.bgy.sms.repository.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.bgy.sms.repository.domain.SysRecordInfo;
public interface SysRecordMapper extends BaseMapper<SysRecordInfo> {
}
package com.bgy.sms.service;
import com.baomidou.mybatisplus.service.IService;
import com.bgy.sms.repository.domain.SysRecordInfo;
public interface SysRecordService extends IService<SysRecordInfo> {
}
package com.bgy.sms.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.bgy.sms.repository.domain.SysRecordInfo;
import com.bgy.sms.repository.mapper.SysRecordMapper;
import com.bgy.sms.service.SysRecordService;
import org.springframework.stereotype.Service;
@Service
public class SysRecordServiceImpl extends ServiceImpl<SysRecordMapper, SysRecordInfo> implements SysRecordService {
}
...@@ -34,7 +34,7 @@ system: ...@@ -34,7 +34,7 @@ system:
securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码 securityCode: 930844c7-7985-435b-af47-142b59b299c3 # 鉴权码
url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx url: https://xstest.bgy.com.cn/ApiBgyTest/Open/Sms.ashx
areaId: XXJSB areaId: XXJSB
api: SendSms api: SendSmS
dmHub: dmHub:
applicationId: cl0300171a6012c21 applicationId: cl0300171a6012c21
applicationKey: 4017078e9dfd593b2d9a0ede58eff589644fbe50 applicationKey: 4017078e9dfd593b2d9a0ede58eff589644fbe50
......
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