| @@ -90,5 +90,12 @@ public class WxMsgModelController extends BaseController { | |||||
| return wxMsgModelService.getModelList(getTenantInfo()); | return wxMsgModelService.getModelList(getTenantInfo()); | ||||
| } | } | ||||
| @ApiOperation("获取当前租户的短信渠道信息") | |||||
| @GetMapping("getMessageChannel") | |||||
| @SystemControllerLog(description = "获取当前租户的短信渠道信息") | |||||
| public ResultData getMessageChannel() { | |||||
| logger.debug("[" + getIpAddr() + "] WxMsgModelController::getMessageChannel"); | |||||
| return wxMsgModelService.getMessageChannel(getTenantInfo()); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,10 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class GetMessageChannelVO { | |||||
| private Integer smsChannel; | |||||
| private Integer maxSize; | |||||
| private String suffix; | |||||
| } | |||||
| @@ -45,6 +45,10 @@ public interface WxMsgModelService { | |||||
| ResultData getModelList(TenantEntity tenantEntity); | ResultData getModelList(TenantEntity tenantEntity); | ||||
| /** | |||||
| * 获取短信渠道信息 | |||||
| * @param tenantInfo | |||||
| * @return {@link ResultData} | |||||
| */ | |||||
| ResultData getMessageChannel(TenantEntity tenantInfo); | |||||
| } | } | ||||
| @@ -10,6 +10,7 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxMsgConfig; | import com.iformall.domain.po.WxMsgConfig; | ||||
| import com.iformall.domain.po.WxMsgModel; | import com.iformall.domain.po.WxMsgModel; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.GetMessageChannelVO; | |||||
| import com.iformall.enums.EnumMsgModelStatus; | import com.iformall.enums.EnumMsgModelStatus; | ||||
| import com.iformall.enums.EnumVerifyCode; | import com.iformall.enums.EnumVerifyCode; | ||||
| import com.iformall.exception.BizMessageException; | import com.iformall.exception.BizMessageException; | ||||
| @@ -17,6 +18,7 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxMsgConfigMapper; | import com.iformall.mapper.WxMsgConfigMapper; | ||||
| import com.iformall.mapper.WxMsgModelMapper; | import com.iformall.mapper.WxMsgModelMapper; | ||||
| import com.iformall.service.WxMsgModelService; | import com.iformall.service.WxMsgModelService; | ||||
| import com.iformall.sms.EnumSMSChannel; | |||||
| import com.iformall.sms.SMSFactory; | import com.iformall.sms.SMSFactory; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -144,5 +146,20 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||||
| return new ResultData(list); | return new ResultData(list); | ||||
| } | } | ||||
| @Override | |||||
| public ResultData getMessageChannel(TenantEntity tenantInfo) { | |||||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||||
| wxMsgConfig.updateTenantInfo(tenantInfo); | |||||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||||
| if (wxMsgConfigs.size() == 0) { | |||||
| return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); | |||||
| } | |||||
| wxMsgConfig = wxMsgConfigs.get(0); | |||||
| EnumSMSChannel channelEnum = EnumSMSChannel.getEnum(wxMsgConfig.getSmsChannel()); | |||||
| GetMessageChannelVO vo = new GetMessageChannelVO(); | |||||
| vo.setSmsChannel(wxMsgConfig.getSmsChannel()); | |||||
| vo.setSuffix(channelEnum != null ? channelEnum.getSuffix() : ""); | |||||
| vo.setMaxSize(channelEnum != null ? channelEnum.getPerSize() : 0); | |||||
| return new ResultData(vo); | |||||
| } | |||||
| } | } | ||||
| @@ -6,9 +6,9 @@ package com.iformall.sms; | |||||
| */ | */ | ||||
| public enum EnumSMSChannel { | public enum EnumSMSChannel { | ||||
| ALIYUN(11, "ALIYUN",70), | |||||
| ALIYUN_ZDY(12, "ALIYUN_ZDY(客户的阿里云短信)",0), | |||||
| WIWIDE(0,"WIWIDE",0); | |||||
| ALIYUN(11, "ALIYUN",70, "回T退订"), | |||||
| ALIYUN_ZDY(12, "ALIYUN_ZDY(客户的阿里云短信)",0, ""), | |||||
| WIWIDE(0,"WIWIDE",0, ""); | |||||
| public static EnumSMSChannel getEnum(Integer code) { | public static EnumSMSChannel getEnum(Integer code) { | ||||
| for (EnumSMSChannel value : values()) { | for (EnumSMSChannel value : values()) { | ||||
| @@ -22,6 +22,7 @@ public enum EnumSMSChannel { | |||||
| private Integer code; | private Integer code; | ||||
| private String message; | private String message; | ||||
| private Integer perSize;//每条短信最大字数,0:无限制,都按1条算 | private Integer perSize;//每条短信最大字数,0:无限制,都按1条算 | ||||
| private String suffix; | |||||
| EnumSMSChannel(Integer code, String message,Integer perSize) { | EnumSMSChannel(Integer code, String message,Integer perSize) { | ||||
| this.code = code; | this.code = code; | ||||
| @@ -29,6 +30,13 @@ public enum EnumSMSChannel { | |||||
| this.perSize = perSize; | this.perSize = perSize; | ||||
| } | } | ||||
| EnumSMSChannel(Integer code, String message,Integer perSize, String suffix) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| this.perSize = perSize; | |||||
| this.suffix = suffix; | |||||
| } | |||||
| public Integer getCode() { | public Integer getCode() { | ||||
| return code; | return code; | ||||
| } | } | ||||
| @@ -40,4 +48,8 @@ public enum EnumSMSChannel { | |||||
| public Integer getPerSize() { | public Integer getPerSize() { | ||||
| return perSize; | return perSize; | ||||
| } | } | ||||
| public String getSuffix() { | |||||
| return suffix; | |||||
| } | |||||
| } | } | ||||
| @@ -127,9 +127,12 @@ public class AliyunSMS implements SMSExcutor { | |||||
| @Override | @Override | ||||
| public void checkMsgWordCount(String signature, String content) { | public void checkMsgWordCount(String signature, String content) { | ||||
| int limitWord = 70; | |||||
| String msg = "【" + signature + "】" + content + "回T退订"; | |||||
| if (msg.length() > limitWord) { | |||||
| StringBuilder sendContent = new StringBuilder("【") | |||||
| .append(signature) | |||||
| .append("】") | |||||
| .append(content) | |||||
| .append(EnumSMSChannel.ALIYUN.getSuffix()); | |||||
| if (sendContent.length() > EnumSMSChannel.ALIYUN.getPerSize()) { | |||||
| throw new MallinkException(ErrorCode.MSG_WORD_COUNT_OVERLONG_ERROR.getCode(), ErrorCode.MSG_WORD_COUNT_OVERLONG_ERROR.getMessage()); | throw new MallinkException(ErrorCode.MSG_WORD_COUNT_OVERLONG_ERROR.getCode(), ErrorCode.MSG_WORD_COUNT_OVERLONG_ERROR.getMessage()); | ||||
| } | } | ||||
| } | } | ||||