Commit 3832574d authored by hezhen's avatar hezhen

Merge branch 'hz_master' into dev

parents b1e122ee 56182a6e
......@@ -29,8 +29,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.HOUR_MINUTE_FORMATTE_HUTOOL;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.admin.constant.enumerate.MemberEnum.NONE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.*;
import static com.xxfc.platform.universal.constant.DictionaryKey.APP_ORDER;
/**
......@@ -472,7 +472,7 @@ public class OrderMsgBiz {
private void handelSmsParamApp(CompanyDetail startCompanyDetail, CompanyDetail endCompanyDetail, OrderRentVehicleDetail orvd, OrderTourDetail otd, OrderMemberDetail omd, BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int paramHandelType) {
switch (paramHandelType) {
case SmsTemplateDTO.PAY_A :
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......@@ -502,14 +502,14 @@ public class OrderMsgBiz {
smsParams.add(appUserDTO.getRentFreeDays().toString());
break;
case SmsTemplateDTO.CANCEL_A :
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
}
break;
case SmsTemplateDTO.PAY_I :
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......@@ -517,7 +517,7 @@ public class OrderMsgBiz {
smsParams.add(startCompanyDetail.getAddrDetail());
break;
case SmsTemplateDTO.PAY_J :
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......@@ -534,7 +534,7 @@ public class OrderMsgBiz {
private void handelDepositSmsParamApp(BigDecimal originalAmount, BigDecimal violateAmount, BigDecimal refundAmount, BigDecimal residueAmount,BaseOrder baseOrder, List<String> smsParams, AppUserDTO appUserDTO, int paramHandelType) {
switch (paramHandelType) {
case SmsTemplateDTO.CANCEL_C :
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......@@ -549,7 +549,7 @@ public class OrderMsgBiz {
case SmsTemplateDTO.REFUND_A:
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
Integer rentDepositAutoRefundTime = new Integer(dictionaryMap.get(APP_ORDER+ "_"+ DictionaryKey.RENT_DEPOSIT_AUTO_REFUND_TIME).getDetail());
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......@@ -562,7 +562,7 @@ public class OrderMsgBiz {
smsParams.add(DateUtil.formatDateTime(DateUtil.date(baseOrder.getRefundTime() + Long.valueOf(rentDepositAutoRefundTime * 60 * 60 * 1000))));
break;
case SmsTemplateDTO.REFUND_B:
if(0 < appUserDTO.getMemberLevel() ) {
if(SYS_TRUE.equals(appUserDTO.getIsMember()) && !NONE.getCode().equals(appUserDTO.getMemberLevel()) ) {
smsParams.add(USER_M+ appUserDTO.getRealname());
}else {
smsParams.add(USER_N+ appUserDTO.getRealname());
......
......@@ -16,6 +16,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
@Slf4j
......@@ -196,12 +199,23 @@ public class SmsService {
JSONObject jsonParams=new JSONObject();
for (int i=0;i<params.length;i++){
String para=params[i];
if (para.contains("【")){
para=para.replaceAll("【","");
}
if (para.contains("】")){
para=para.replaceAll("】","");
if (StringUtils.isNotBlank(para)){
if (para.contains("【")){
para=para.replaceAll("【","");
}
if (para.contains("】")){
para=para.replaceAll("】","");
}
if (para.length()>20){
if (isNumeric(para)){
para.substring(0,20);
}else {
para=para.substring(0,18);
para+="..";
}
}
}
jsonParams.put(param+(i+1),para);
}
sendTemplate(PhoneNumbers,jsonParams.toJSONString(),templateCode);
......@@ -216,12 +230,24 @@ public class SmsService {
JSONObject jsonParams=new JSONObject();
for (int i=0;i<params.length;i++){
String para=params[i];
if (para.contains("【")){
para=para.replaceAll("【","");
}
if (para.contains("】")){
para=para.replaceAll("】","");
if (StringUtils.isNotBlank(para)){
if (para.contains("【")){
para=para.replaceAll("【","");
}
if (para.contains("】")){
para=para.replaceAll("】","");
}
if (para.length()>20){
if (isNumeric(para)){
para.substring(0,20);
}else {
para=para.substring(0,18);
para+="..";
}
}
}
if (i>3){
jsonParams.put(param+(i+2),para);
}else {
......@@ -236,11 +262,26 @@ public class SmsService {
}
/**
* 是否是数字
* @param str
* @return
*/
public static boolean isNumeric(String str){
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() ){
return false;
}
return true;
}
public static void main(String[] args) throws ClientException, InterruptedException {
SmsService smsService=new SmsService();
//发短信
String[] params={"1","2","3","2019-08-29","【松山湖】"};
SmsService.sendTemplateToJson("13612688539,13265487972",params,"SMS_169904346");
SmsService.sendTemplateToJson("13612688539",params,"SMS_169904346");
/*System.out.println("短信接口返回的数据----------------");
System.out.println("Code=" + response.getCode());
System.out.println("Message=" + response.getMessage());
......
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