Commit dce6e4f3 by YG8999

生成保洁记录发送短信提示

parent 1156ca14
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<!-- 日志存放路径 --> <!-- 日志存放路径 -->
<property name="log.path" value="/home/gxpt/logs" /> <property name="log.path" value=" /Users/liwenjun/logs/share" />
<!-- 日志输出格式 --> <!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" /> <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
......
...@@ -111,4 +111,8 @@ public class SmsConstants { ...@@ -111,4 +111,8 @@ public class SmsConstants {
public static final int SMS_CONFIG_TYPE_BIND_SUCCESS_DOWN = 13; public static final int SMS_CONFIG_TYPE_BIND_SUCCESS_DOWN = 13;
/** 发送短信参数模板 */ /** 发送短信参数模板 */
public static final String SMS_COMMON_PARAM_FORMAT = "param[{}]"; public static final String SMS_COMMON_PARAM_FORMAT = "param[{}]";
/** 保洁短信提醒 */
public static final int SMS_CONFIG_TYPE_CLEAN_RECORDS_SWITCH = 20;
} }
...@@ -33,5 +33,10 @@ public class SmsConts { ...@@ -33,5 +33,10 @@ public class SmsConts {
*/ */
public final static String smsCodeTemp = "您的验证码是:{0},有效期为{1}分钟。如非本人操作,可不予理会。"; public final static String smsCodeTemp = "您的验证码是:{0},有效期为{1}分钟。如非本人操作,可不予理会。";
/**
* 保洁打扫提示短信内容
*/
public final static String smsCleanRecordsTemp = "门店:{0},房间:{1},已经结束订单,请前往小程序领取保洁任务并进行保洁工作,门店地址:{2}。";
} }
...@@ -2,6 +2,8 @@ package share.system.service; ...@@ -2,6 +2,8 @@ package share.system.service;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import share.system.domain.SRoom;
import share.system.domain.SStore;
/** /**
* @author wuwenlong * @author wuwenlong
...@@ -21,4 +23,12 @@ public interface SmsService { ...@@ -21,4 +23,12 @@ public interface SmsService {
* @return * @return
*/ */
boolean sendSmsCode(String phone); boolean sendSmsCode(String phone);
/**
* 发送保洁打扫提示短信
* @param phone
* @return
*/
boolean sendSmsCleanRecords(String phone, SStore store, SRoom room);
} }
...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import share.system.domain.SConsumer; import share.system.domain.SConsumer;
import share.system.domain.SRoom; import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.mapper.SCleanRecordsMapper; import share.system.mapper.SCleanRecordsMapper;
import share.system.domain.SCleanRecords; import share.system.domain.SCleanRecords;
...@@ -18,6 +19,7 @@ import share.system.mapper.SConsumerMapper; ...@@ -18,6 +19,7 @@ import share.system.mapper.SConsumerMapper;
import share.system.mapper.SRoomMapper; import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreMapper; import share.system.mapper.SStoreMapper;
import share.system.service.ISCleanRecordsService; import share.system.service.ISCleanRecordsService;
import share.system.service.SmsService;
/** /**
* 保洁记录Service业务层处理 * 保洁记录Service业务层处理
...@@ -36,6 +38,8 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -36,6 +38,8 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
private SRoomMapper sRoomMapper; private SRoomMapper sRoomMapper;
@Autowired @Autowired
private SStoreMapper sStoreMapper; private SStoreMapper sStoreMapper;
@Autowired
private SmsService smsService;
/** /**
* 查询保洁记录 * 查询保洁记录
...@@ -126,7 +130,9 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -126,7 +130,9 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
sCleanRecords.setCreateTime(DateUtils.getNowDate()); sCleanRecords.setCreateTime(DateUtils.getNowDate());
boolean b = 0 < sCleanRecordsMapper.insertSCleanRecords(sCleanRecords); boolean b = 0 < sCleanRecordsMapper.insertSCleanRecords(sCleanRecords);
if (b) { if (b) {
sendSms(storeId); SStore store = sStoreMapper.selectSStoreById(storeId);
SRoom room = sRoomMapper.selectSRoomById(roomId);
sendSms(storeId,store,room);
} }
return b; return b;
} }
...@@ -181,11 +187,11 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService ...@@ -181,11 +187,11 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
return 0 < sCleanRecordsMapper.updateBatch(list); return 0 < sCleanRecordsMapper.updateBatch(list);
} }
private void sendSms(Long storeId) { private void sendSms(Long storeId,SStore store, SRoom room) {
List<SConsumer> list = sConsumerMapper.selectListByStoreId(storeId); List<SConsumer> list = sConsumerMapper.selectListByStoreId(storeId);
for (SConsumer consumer : list) { for (SConsumer consumer : list) {
// 循环发送短信提示门店保洁打扫卫生 // 循环发送短信提示门店保洁打扫卫生
// todo smsService.sendSmsCleanRecords(consumer.getPhone(), store, room);
} }
} }
......
...@@ -16,6 +16,8 @@ import share.common.constant.SmsConts; ...@@ -16,6 +16,8 @@ import share.common.constant.SmsConts;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.utils.BaseUtil; import share.common.utils.BaseUtil;
import share.common.utils.SmsUtil; import share.common.utils.SmsUtil;
import share.system.domain.SRoom;
import share.system.domain.SStore;
import share.system.service.SConsumerService; import share.system.service.SConsumerService;
import share.system.service.SmsService; import share.system.service.SmsService;
...@@ -76,17 +78,23 @@ public class SmsServiceImpl implements SmsService { ...@@ -76,17 +78,23 @@ public class SmsServiceImpl implements SmsService {
* @param phone * @param phone
* @return * @return
*/ */
private boolean sendSms(String phone, Integer tag) { private boolean sendSms(String phone, Integer tag, String content) {
try { try {
if (tag.equals(SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE)) { if (tag.equals(SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE)) {
//TODO 发送短信 //TODO 发送短信
JSONObject jsonObject = sendOneSms(phone, getSmsContent(phone, tag)); JSONObject jsonObject = sendOneSms(phone, content);
Boolean isSendCode = Objects.nonNull(jsonObject);//TODO 发送成功判断?? Boolean isSendCode = Objects.nonNull(jsonObject);//TODO 发送成功判断??
if (isSendCode) { if (isSendCode) {
return isSendCode; return isSendCode;
} }
// 发送失败删除缓存 // 发送失败删除缓存
redisUtil.delete(sConsumerService.getValidateCodeRedisKey(phone)); redisUtil.delete(sConsumerService.getValidateCodeRedisKey(phone));
} else if (tag.equals(SmsConstants.SMS_CONFIG_TYPE_CLEAN_RECORDS_SWITCH)){
JSONObject jsonObject = sendOneSms(phone, content);
Boolean isSendCode = Objects.nonNull(jsonObject);
if (isSendCode) {
return isSendCode;
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("短信登录验证发送失败:", e); logger.error("短信登录验证发送失败:", e);
...@@ -98,7 +106,14 @@ public class SmsServiceImpl implements SmsService { ...@@ -98,7 +106,14 @@ public class SmsServiceImpl implements SmsService {
@Override @Override
public boolean sendSmsCode(String phone) { public boolean sendSmsCode(String phone) {
// redisUtil.set(sConsumerService.getValidateCodeRedisKey(phone), "123456", Long.valueOf(Constants.CONFIG_KEY_SMS_CODE_EXPIRE), TimeUnit.MINUTES); // redisUtil.set(sConsumerService.getValidateCodeRedisKey(phone), "123456", Long.valueOf(Constants.CONFIG_KEY_SMS_CODE_EXPIRE), TimeUnit.MINUTES);
return sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);//TODO 手机验证吗待对接短信平台 sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE); String content = getSmsContent(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);
return sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE, content);//TODO 手机验证吗待对接短信平台 sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);
}
@Override
public boolean sendSmsCleanRecords(String phone, SStore store, SRoom room) {
String content = MessageFormat.format(SmsConts.smsCleanRecordsTemp, store.getName(), room.getName(), store.getAddress());
return sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_CLEAN_RECORDS_SWITCH, content);
} }
private String getSmsContent(String phone, Integer tag) { private String getSmsContent(String phone, Integer tag) {
......
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