|
@@ -5,15 +5,18 @@ import com.nuliji.tools.exception.SystemException;
|
|
|
import com.qxgmat.data.constants.enums.MessageCategory;
|
|
|
import com.qxgmat.data.constants.enums.MessageMethod;
|
|
|
import com.qxgmat.data.constants.enums.MessageType;
|
|
|
+import com.qxgmat.data.constants.enums.status.AskStatus;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
import com.qxgmat.help.MailHelp;
|
|
|
import com.qxgmat.help.WechatHelp;
|
|
|
import com.qxgmat.service.inline.MessageTemplateService;
|
|
|
import com.qxgmat.service.inline.UserMessageService;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -35,6 +38,12 @@ public class MessageExtendService {
|
|
|
@Resource
|
|
|
private ToolsService toolsService;
|
|
|
|
|
|
+ @Value("${url.pc}")
|
|
|
+ private String pcUrl;
|
|
|
+
|
|
|
+ @Value("${url.h5}")
|
|
|
+ private String h5Url;
|
|
|
+
|
|
|
private void send(User user, MessageCategory category, Map<String, String>params){
|
|
|
List<MessageTemplate> templateList = messageTemplateService.listByCategory(category);
|
|
|
for(MessageTemplate template : templateList){
|
|
@@ -79,6 +88,7 @@ public class MessageExtendService {
|
|
|
}
|
|
|
|
|
|
public void sendCustom(User user, MessageTemplate template, Map<String, String>params){
|
|
|
+ params.put("nickname", user.getNickname());
|
|
|
MessageMethod messageMethod = MessageMethod.ValueOf(template.getMessageMethod());
|
|
|
String title = replaceBody(template.getTitle(), params);
|
|
|
String content = replaceBody(template.getContent(), params);
|
|
@@ -102,6 +112,8 @@ public class MessageExtendService {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("emails", Strings.join(Arrays.stream(emails).collect(Collectors.toList()), ';'));
|
|
|
map.put("code", code);
|
|
|
+ map.put("nickname", user.getNickname());
|
|
|
+ map.put("url", pcUrl+"/id/"+code);
|
|
|
send(user, MessageCategory.INVITED, map);
|
|
|
}
|
|
|
|
|
@@ -118,6 +130,9 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendLoginAbnormal(User user, UserAbnormal userAbnormal){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("nickname", user.getNickname());
|
|
|
+ map.put("ip", userAbnormal.getLoginIp());
|
|
|
+ map.put("city", userAbnormal.getLoginCity());
|
|
|
send(user, MessageCategory.LOGIN_ABNORMAL, map);
|
|
|
}
|
|
|
|
|
@@ -128,6 +143,8 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendPreviewNotice(User user, Course course, PreviewAssign previewAssign){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("courseTitle", course.getTitle());
|
|
|
+ map.put("title", previewAssign.getTitle());
|
|
|
send(user, MessageCategory.PREVIEW_NOTICE, map);
|
|
|
}
|
|
|
|
|
@@ -139,6 +156,7 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendPayed(User user, UserOrder userOrder){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("money", userOrder.getMoney().toString());
|
|
|
send(user, MessageCategory.PAYED, map);
|
|
|
}
|
|
|
|
|
@@ -149,6 +167,10 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendDataUpdate(User user, CourseData data, CourseDataHistory history){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("title", data.getTitle());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String time = sdf.format(history.getTime());
|
|
|
+ map.put("time", time);
|
|
|
send(user, MessageCategory.DATA_UPDATE, map);
|
|
|
}
|
|
|
|
|
@@ -160,6 +182,19 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendAskQuestion(User user,UserAskQuestion userAskQuestion){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("content", userAskQuestion.getContent());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String time = sdf.format(new Date());
|
|
|
+ map.put("time", time);
|
|
|
+ AskStatus status = AskStatus.ValueOf(userAskQuestion.getAnswerStatus());
|
|
|
+ if (status == AskStatus.ANSWER){
|
|
|
+ map.put("status", "已回答");
|
|
|
+ }else if (status == AskStatus.IGNORE){
|
|
|
+ map.put("status", "已隐藏");
|
|
|
+ }
|
|
|
+ if(userAskQuestion.getShowStatus() > 0){
|
|
|
+ map.put("status", "精选");
|
|
|
+ }
|
|
|
send(user, MessageCategory.ASK_QUESTION, map);
|
|
|
}
|
|
|
|
|
@@ -171,26 +206,96 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendAskCourse(User user, UserAskCourse userAskCourse){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("content", userAskCourse.getContent());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String time = sdf.format(new Date());
|
|
|
+ map.put("time", time);
|
|
|
+ AskStatus status = AskStatus.ValueOf(userAskCourse.getAnswerStatus());
|
|
|
+ if (status == AskStatus.ANSWER){
|
|
|
+ map.put("status", "已回答");
|
|
|
+ }else if (status == AskStatus.IGNORE){
|
|
|
+ map.put("status", "已隐藏");
|
|
|
+ }
|
|
|
+ if(userAskCourse.getShowStatus() > 0){
|
|
|
+ map.put("status", "精选");
|
|
|
+ }
|
|
|
send(user, MessageCategory.ASK_COURSE, map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 咨询回复
|
|
|
- * 咨询板块
|
|
|
- * 咨询简介
|
|
|
+ * 咨询回复:{answer}
|
|
|
+ * 咨询板块:{channel}
|
|
|
+ * 咨询简介:{content}
|
|
|
*/
|
|
|
public void sendFaqCallback(User user, Faq faq){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("answer", faq.getAnswer());
|
|
|
+ map.put("content", faq.getContent());
|
|
|
+ String channel = "";
|
|
|
+ switch(faq.getChannel()){
|
|
|
+ case "course-video":
|
|
|
+ channel="在线课程";
|
|
|
+ break;
|
|
|
+ case "course-vs":
|
|
|
+ channel = "1v1课程";
|
|
|
+ break;
|
|
|
+ case "course-package":
|
|
|
+ channel = "课程套餐";
|
|
|
+ break;
|
|
|
+ case "course_data":
|
|
|
+ channel = "资料";
|
|
|
+ break;
|
|
|
+ case "getready":
|
|
|
+ channel = "GetReady";
|
|
|
+ break;
|
|
|
+ case "examination-cat":
|
|
|
+ channel = "模考Cat";
|
|
|
+ break;
|
|
|
+ case "examination-base":
|
|
|
+ channel = "模考";
|
|
|
+ break;
|
|
|
+ case "textbook":
|
|
|
+ channel = "数学机经";
|
|
|
+ break;
|
|
|
+ case "library":
|
|
|
+ channel = "换库表";
|
|
|
+ break;
|
|
|
+ case "course-index":
|
|
|
+ channel = "课堂";
|
|
|
+ break;
|
|
|
+ case "course-video_index":
|
|
|
+ channel= "在线课程";
|
|
|
+ break;
|
|
|
+ case "course-vs_index":
|
|
|
+ channel = "1v1课程";
|
|
|
+ break;
|
|
|
+ case "course-package_index":
|
|
|
+ channel="课程套餐";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ map.put("channel", channel);
|
|
|
send(user, MessageCategory.FAQ_CALLBACK, map);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 纠错回复
|
|
|
- * 咨询板块
|
|
|
- * 咨询简介
|
|
|
+ * 纠错对象:{object}
|
|
|
+ * 错误内容:{content}
|
|
|
+ * 应更正:{correct}
|
|
|
+ * 处理结果:{status}
|
|
|
*/
|
|
|
public void sendFeedbackAnswer(User user, UserFeedbackError feedbackError){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("content", feedbackError.getOriginContent());
|
|
|
+ AskStatus status = AskStatus.ValueOf(feedbackError.getStatus());
|
|
|
+ if (status == AskStatus.ANSWER){
|
|
|
+ map.put("status", "已采纳");
|
|
|
+ }else if (status == AskStatus.IGNORE){
|
|
|
+ map.put("status", "已忽略");
|
|
|
+ }else if (status == AskStatus.NOHANDLE){
|
|
|
+ map.put("status", "无需处理");
|
|
|
+ }
|
|
|
+ map.put("correct", feedbackError.getContent());
|
|
|
+ map.put("object", feedbackError.getTitle());
|
|
|
send(user, MessageCategory.FEEDBACK_CALLBACK, map);
|
|
|
}
|
|
|
|
|
@@ -200,6 +305,7 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendRegister(User user){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("mobile", user.getMobile());
|
|
|
send(user, MessageCategory.REGISTER, map);
|
|
|
}
|
|
|
|
|
@@ -209,6 +315,8 @@ public class MessageExtendService {
|
|
|
*/
|
|
|
public void sendEmailChange(User user){
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("nickname", user.getNickname());
|
|
|
+ map.put("email", user.getEmail());
|
|
|
send(user, MessageCategory.EMAIL_CHANGE, map);
|
|
|
}
|
|
|
|