Commit 185598ad by huluobin

企业微信消息

parent b6943319
......@@ -42,6 +42,7 @@ import com.gogirl.infrastructure.mapper.product.serve.TechnicianServeMapper;
import com.gogirl.infrastructure.mapper.store.oa.TakeLeaveEventMapper;
import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper;
import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.service.push.TechnicianPushService;
import com.gogirl.infrastructure.util.MapDistanceUtils;
import com.gogirl.infrastructure.util.SessionUtils;
import com.gogirl.shared.order.serve.command.schedule.*;
......@@ -101,6 +102,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
private final PurchaseSkuMapper purchaseSkuMapper;
private final BaseProduceMapper baseProduceMapper;
private final TechnicianPushService technicianPushService;
@Override
public List<StoreTechnicianPeriod> queryStoreTechnicianPeriod(Integer scheduledId,
Integer departmentId,
......@@ -585,6 +588,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
});
scheduleManageMapper.updateById(scheduleManage);
technicianPushService.cancelScheduledMsg(scheduleManage.getId());
}
@Override
......@@ -903,6 +908,8 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
});
//保存预约详情
scheduleManage.getScheduleServeList().forEach(scheduleServeMapper::insert);
technicianPushService.scheduledMsg(scheduleManage.getId());
}
@Override
......
......@@ -7,7 +7,7 @@ import java.util.List;
@Data
public class EnterpriseWxMsg {
private String msgType;
private String msgtype;
private EnterpriseTextWxMsg text;
@Data
......
......@@ -44,6 +44,7 @@ import com.gogirl.infrastructure.mapper.store.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper;
import com.gogirl.infrastructure.service.push.PushMsgService;
import com.gogirl.infrastructure.service.push.TechnicianPushService;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -113,6 +114,7 @@ public class Schedule {
* config
*/
private final GogirlProperties gogirlProperties;
private final TechnicianPushService technicianPushService;
/**
* 每天3点判断优惠券是否过期。
......@@ -201,11 +203,16 @@ public class Schedule {
Customer customer = customerService.getById(scheduleManage.getScheduledUser());
StoreManage storeManage = storeManageService.getById(scheduleManage.getDepartmentId());
/*用户超时提醒*/
List<ScheduleServe> scheduleServeList = scheduleManageMapper.selectByScheduleId(scheduleManage.getId());
pushMsgService.sendScheduleMsg(customer.getOpenid1(), scheduleServeList.get(0).getServeName(), scheduleManage.getArriveTime(), storeManage.getName(), storeManage.getAddress());
/*美甲师超时预约提醒*/
technicianPushService.ScheduledOverTimeMsg(scheduleManage.getId());
scheduleManage.setIsSend(1);
scheduleManageMapper.updateById(scheduleManage);
}
});
......
......@@ -5,6 +5,7 @@ import com.gogirl.domain.order.serve.ScheduleManage;
import com.gogirl.domain.order.serve.ScheduleServe;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.dto.EnterpriseWxMsg;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.config.property.GogirlProperties;
import com.gogirl.infrastructure.mapper.order.serve.ScheduleManageMapper;
import com.gogirl.infrastructure.mapper.order.serve.ScheduleServeMapper;
......@@ -13,11 +14,13 @@ import com.gogirl.infrastructure.service.push.TechnicianPushService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.stream.Collectors;
......@@ -40,7 +43,7 @@ public class TechnicianPushServiceImpl implements TechnicianPushService {
ScheduleManage scheduleManage = scheduleManageMapper.selectById(scheduledId);
String name = scheduleManage.getStoreScheduleUsername();
String phone = scheduleManage.getTelephone();
String date = scheduleManage.getArriveTime().toString();
String date = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").format(scheduleManage.getArriveTime());
List<ScheduleServe> scheduleServeList = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, scheduledId));
String serves = scheduleServeList.stream().map(ScheduleServe::getServeName).collect(Collectors.joining(","));
......@@ -50,15 +53,15 @@ public class TechnicianPushServiceImpl implements TechnicianPushService {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
EnterpriseWxMsg enterpriseWxMsg = new EnterpriseWxMsg();
enterpriseWxMsg.setMsgType("text");
enterpriseWxMsg.setMsgtype("text");
EnterpriseWxMsg.EnterpriseTextWxMsg textWxMsg = new EnterpriseWxMsg.EnterpriseTextWxMsg();
StringBuilder builder = new StringBuilder();
String content = builder.append("预约提醒\n")
.append("预约客户").append(name).append("\n")
.append("预约客户手机").append(phone).append("\n")
.append("预约时间").append(date).append("\n")
.append("预约技师").append(technicianNames).append("\n")
String content = builder.append("预约提醒\n\n")
.append("预约客户: ").append(name).append("\n")
.append("预约客户手机: ").append(phone).append("\n")
.append("预约时间: ").append(date).append("\n")
.append("预约技师: ").append(technicianNames).append("\n")
.append("预约项目: ").append(serves).append("\n")
.toString();
textWxMsg.setMentioned_mobile_list(storeTechnicianList.stream().map(StoreTechnician::getMobile).collect(Collectors.toList()));
......@@ -66,16 +69,83 @@ public class TechnicianPushServiceImpl implements TechnicianPushService {
enterpriseWxMsg.setText(textWxMsg);
HttpEntity<EnterpriseWxMsg> httpEntity = new HttpEntity<>(enterpriseWxMsg, httpHeaders);
restTemplate.postForEntity(gogirlProperties.getEnterpriseWechatWebhook(), httpEntity, String.class);
log.info("发送企业微信消息参数:{}", JsonUtilByFsJson.beanToJson(enterpriseWxMsg));
String response = restTemplate.exchange(gogirlProperties.getEnterpriseWechatWebhook(), HttpMethod.POST, httpEntity, String.class).getBody();
log.info("发送企业微信消息响应:{}", response);
}
@Override
public void cancelScheduledMsg(Integer scheduledId) {
ScheduleManage scheduleManage = scheduleManageMapper.selectById(scheduledId);
String name = scheduleManage.getStoreScheduleUsername();
String phone = scheduleManage.getTelephone();
String date = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").format(scheduleManage.getArriveTime());
List<ScheduleServe> scheduleServeList = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, scheduledId));
String serves = scheduleServeList.stream().map(ScheduleServe::getServeName).collect(Collectors.joining(","));
List<StoreTechnician> storeTechnicianList = storeTechnicianMapper.selectBatchIds(scheduleServeList.stream().map(ScheduleServe::getTechnicianId).collect(Collectors.toList()));
String technicianNames = storeTechnicianList.stream().map(StoreTechnician::getName).collect(Collectors.joining(","));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
EnterpriseWxMsg enterpriseWxMsg = new EnterpriseWxMsg();
enterpriseWxMsg.setMsgtype("text");
EnterpriseWxMsg.EnterpriseTextWxMsg textWxMsg = new EnterpriseWxMsg.EnterpriseTextWxMsg();
StringBuilder builder = new StringBuilder();
String content = builder.append("用户取消预约提醒\n\n")
.append("预约客户: ").append(name).append("\n")
.append("预约客户手机: ").append(phone).append("\n")
.append("预约时间: ").append(date).append("\n")
.append("预约技师: ").append(technicianNames).append("\n")
.append("预约项目: ").append(serves).append("\n")
.append("取消原因: 用户取消")
.toString();
textWxMsg.setMentioned_mobile_list(storeTechnicianList.stream().map(StoreTechnician::getMobile).collect(Collectors.toList()));
textWxMsg.setContent(content);
enterpriseWxMsg.setText(textWxMsg);
HttpEntity<EnterpriseWxMsg> httpEntity = new HttpEntity<>(enterpriseWxMsg, httpHeaders);
log.info("发送企业微信消息参数:{}", JsonUtilByFsJson.beanToJson(enterpriseWxMsg));
String response = restTemplate.exchange(gogirlProperties.getEnterpriseWechatWebhook(), HttpMethod.POST, httpEntity, String.class).getBody();
log.info("发送企业微信消息响应:{}", response);
}
@Override
public void ScheduledOverTimeMsg(Integer scheduledId) {
ScheduleManage scheduleManage = scheduleManageMapper.selectById(scheduledId);
String name = scheduleManage.getStoreScheduleUsername();
String phone = scheduleManage.getTelephone();
String date = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss").format(scheduleManage.getArriveTime());
List<ScheduleServe> scheduleServeList = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, scheduledId));
String serves = scheduleServeList.stream().map(ScheduleServe::getServeName).collect(Collectors.joining(","));
List<StoreTechnician> storeTechnicianList = storeTechnicianMapper.selectBatchIds(scheduleServeList.stream().map(ScheduleServe::getTechnicianId).collect(Collectors.toList()));
String technicianNames = storeTechnicianList.stream().map(StoreTechnician::getName).collect(Collectors.joining(","));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
EnterpriseWxMsg enterpriseWxMsg = new EnterpriseWxMsg();
enterpriseWxMsg.setMsgtype("text");
EnterpriseWxMsg.EnterpriseTextWxMsg textWxMsg = new EnterpriseWxMsg.EnterpriseTextWxMsg();
StringBuilder builder = new StringBuilder();
String content = (builder.append("超时取消提醒\n\n")
.append("预约客户: ").append(name).append("\n")
.append("预约客户手机: ").append(phone).append("\n")
.append("预约时间: ").append(date).append("\n")
.append("预约技师: ").append(technicianNames).append("\n")
.append("预约项目: ").append(serves).append("\n")
.append("取消原因: 超时取消"))
.toString();
textWxMsg.setMentioned_mobile_list(storeTechnicianList.stream().map(StoreTechnician::getMobile).collect(Collectors.toList()));
textWxMsg.setContent(content);
enterpriseWxMsg.setText(textWxMsg);
HttpEntity<EnterpriseWxMsg> httpEntity = new HttpEntity<>(enterpriseWxMsg, httpHeaders);
log.info("发送企业微信消息参数:{}", JsonUtilByFsJson.beanToJson(enterpriseWxMsg));
String response = restTemplate.exchange(gogirlProperties.getEnterpriseWechatWebhook(), HttpMethod.POST, httpEntity, String.class).getBody();
log.info("发送企业微信消息响应:{}", response);
}
}
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