Browse Source

feat(server): 机经报名

Go 4 years ago
parent
commit
1b90067571
19 changed files with 436 additions and 42 deletions
  1. 12 12
      front/project/Constant.js
  2. 2 2
      front/project/admin/routes/show/faq/page.js
  3. 8 0
      front/project/www/stores/textbook.js
  4. 6 2
      server/data/src/main/java/com/qxgmat/data/constants/enums/status/AskStatus.java
  5. 20 0
      server/data/src/main/java/com/qxgmat/data/relation/UserTextbookEnrollRelationMapper.java
  6. 39 0
      server/data/src/main/java/com/qxgmat/data/relation/entity/TextbookEnrollNumberRelation.java
  7. 40 0
      server/data/src/main/java/com/qxgmat/data/relation/mapping/UserTextbookEnrollRelationMapper.xml
  8. 2 0
      server/gateway-api/src/main/java/com/qxgmat/controller/admin/QuestionController.java
  9. 2 10
      server/gateway-api/src/main/java/com/qxgmat/controller/admin/SettingController.java
  10. 72 2
      server/gateway-api/src/main/java/com/qxgmat/controller/api/TextbookController.java
  11. 15 0
      server/gateway-api/src/main/java/com/qxgmat/dto/request/TextbookEnrollDto.java
  12. 36 0
      server/gateway-api/src/main/java/com/qxgmat/dto/response/TextbookEnrollTimeDto.java
  13. 114 6
      server/gateway-api/src/main/java/com/qxgmat/service/extend/MessageExtendService.java
  14. 7 0
      server/gateway-api/src/main/java/com/qxgmat/service/extend/OrderFlowService.java
  15. 17 6
      server/gateway-api/src/main/java/com/qxgmat/service/extend/TextbookService.java
  16. 20 0
      server/gateway-api/src/main/java/com/qxgmat/service/inline/UserTextbookEnrollService.java
  17. 2 0
      server/gateway-api/src/main/java/com/qxgmat/task/ScheduledTask.java
  18. 5 1
      server/gateway-api/src/main/profile/dev/application-runtime.yml
  19. 17 1
      server/tools/src/main/java/com/nuliji/tools/Tools.java

+ 12 - 12
front/project/Constant.js

@@ -109,19 +109,19 @@ export const ContractKey = [{ label: '注册', value: 'register' }, { label: '
 export const RoomPosition = [{ label: '北部', value: 'north' }, { label: '东部', value: 'east' }, { label: '中南', value: 'south_central' }, { label: '西部', value: 'west' }, { label: '海外', value: 'overseas' }];
 
 export const MessageCategory = [
-  { label: '注册消息', value: 'register', params: [''] },
-  { label: '登录异常', value: 'login_abnormal', params: [''] },
+  { label: '注册消息', value: 'register', params: ['mobile'] },
+  { label: '登录异常', value: 'login_abnormal', params: ['nickname', 'ip', 'city'] },
   { label: '机经更新', value: 'textbook_update', params: [''] },
-  { label: '预习作业提醒', value: 'preview_notice', params: [''] },
-  { label: '支付成功提醒', value: 'payed', params: [''] },
-  { label: '资料更新', value: 'data_update', params: [''] },
-  { label: '题目提问回复', value: 'ask_question', params: [''] },
-  { label: '课程提问回复', value: 'ask_course', params: [''] },
-  { label: '咨询回复', value: 'faq_callback', params: [''] },
-  { label: '纠错回复', value: 'feedback_callback', params: [''] },
-  { label: '邀请好友注册', value: 'invited', params: [''] },
-  { label: '邮箱变更', value: 'email_change', params: [''] },
-  { label: '自定义消息', value: 'custom', params: [''] },
+  { label: '预习作业提醒', value: 'preview_notice', params: ['courseTitle', 'title'] },
+  { label: '支付成功提醒', value: 'payed', params: ['money'] },
+  { label: '资料更新', value: 'data_update', params: ['title', 'time'] },
+  { label: '题目提问回复', value: 'ask_question', params: ['content', 'time', 'status'] },
+  { label: '课程提问回复', value: 'ask_course', params: ['content', 'time', 'status'] },
+  { label: '咨询回复', value: 'faq_callback', params: ['content', 'answer', 'channel'] },
+  { label: '纠错回复', value: 'feedback_callback', params: ['content', 'object', 'correct', 'status'] },
+  { label: '邀请好友注册', value: 'invited', params: ['code', 'nickname', 'url'] },
+  { label: '邮箱变更', value: 'email_change', params: ['nickname', 'email'] },
+  { label: '自定义消息', value: 'custom', params: ['nickname'] },
 ];
 
 export const MessageEmailStatus = [

+ 2 - 2
front/project/admin/routes/show/faq/page.js

@@ -284,8 +284,8 @@ export default class extends Page {
         renderItem={(item) => (
           <List.Item actions={[<Icon type='bars' className='icon' />]}>
             <Row style={{ width: '100%' }}>
-              <Col span={8}>{item.user ? item.user.nickname : item.nickname}</Col>
-              <Col span={15} offset={1}>{item.content}</Col>
+              <Col span={8}>Q: {item.content}</Col>
+              <Col span={15} offset={1}>A: {item.answer}</Col>
             </Row>
           </List.Item>
         )}

+ 8 - 0
front/project/www/stores/textbook.js

@@ -37,6 +37,14 @@ export default class TextbookStore extends BaseStore {
   subscribe(subscribe) {
     return this.apiPost('/textbook/subscribe', { subscribe });
   }
+
+  enroll(month) {
+    return this.apiPost('/textbook/enroll', { month });
+  }
+
+  listEnroll(year) {
+    return this.apiGet('/textbook/enroll/list', { year });
+  }
 }
 
 export const Textbook = new TextbookStore({ key: 'textbook' });

+ 6 - 2
server/data/src/main/java/com/qxgmat/data/constants/enums/status/AskStatus.java

@@ -2,8 +2,12 @@ package com.qxgmat.data.constants.enums.status;
 
 
 public enum AskStatus {
-    NEW(0), ANSWER(1), IGNORE(2);
-    final static public String message = "状态:0新增,1回答,2忽略";
+    NEW(0),
+    ANSWER(1),
+    IGNORE(2),
+    NOHANDLE(3), // 在feedback支持
+    ;
+    final static public String message = "状态:0新增,1回答,2忽略, 3不处理";
 
     public int index;
     private AskStatus(int index){

+ 20 - 0
server/data/src/main/java/com/qxgmat/data/relation/UserTextbookEnrollRelationMapper.java

@@ -0,0 +1,20 @@
+package com.qxgmat.data.relation;
+
+import com.qxgmat.data.dao.entity.UserOrderRecord;
+import com.qxgmat.data.relation.entity.CourseStudentNumberRelation;
+import com.qxgmat.data.relation.entity.TextbookEnrollNumberRelation;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Created by gaojie on 2017/11/9.
+ */
+public interface UserTextbookEnrollRelationMapper {
+
+    List<TextbookEnrollNumberRelation> groupByMonth(
+            @Param("startTime") String startTime,
+            @Param("endTime") String endTime
+    );
+}

+ 39 - 0
server/data/src/main/java/com/qxgmat/data/relation/entity/TextbookEnrollNumberRelation.java

@@ -0,0 +1,39 @@
+package com.qxgmat.data.relation.entity;
+
+import javax.persistence.Column;
+import java.util.Date;
+
+/**
+ * Created by gaojie on 2017/11/9.
+ */
+// 备考统计
+public class TextbookEnrollNumberRelation {
+
+    /**
+     * 数字字段
+     */
+    @Column(name = "`id`")
+    private Date month;
+
+    /**
+     * 统计值
+     */
+    @Column(name = "`user_id`")
+    private Integer number;
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+}

+ 40 - 0
server/data/src/main/java/com/qxgmat/data/relation/mapping/UserTextbookEnrollRelationMapper.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.qxgmat.data.relation.UserTextbookEnrollRelationMapper">
+  <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserTextbookEnroll">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <id column="id" jdbcType="INTEGER" property="id" />
+  </resultMap>
+  <resultMap id="NumberMap" type="com.qxgmat.data.relation.entity.TextbookEnrollNumberRelation">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    <id column="month" jdbcType="TIMESTAMP" property="month" />
+    <id column="number" jdbcType="INTEGER" property="number" />
+  </resultMap>
+  <sql id="Id_Column_List">
+    <!--
+      WARNING - @mbg.generated
+    -->
+    ute.`id`
+  </sql>
+
+  <!--
+    统计报名人数
+  -->
+  <select id="groupByMonth" resultMap="NumberMap">
+    select
+    count(ute.`id`) as `number`, ute.`month` as `month`
+    from `user_textbook_enrool` ute
+    where 1
+    <if test="startTime != null">
+      and ute.`month` &gt; #{startTime,jdbcType=VARCHAR}
+    </if>
+    <if test="endTime != null">
+      and ute.`month` &lt; #{endTime,jdbcType=VARCHAR}
+    </if>
+  </select>
+
+</mapper>

+ 2 - 0
server/gateway-api/src/main/java/com/qxgmat/controller/admin/QuestionController.java

@@ -193,6 +193,8 @@ public class QuestionController {
 
         if (dto.getIgnoreStatus() != null && dto.getIgnoreStatus() > 0){
             entity.setAnswerStatus(AskStatus.IGNORE.index);
+            User user = usersService.get(in.getUserId());
+            messageExtendService.sendAskQuestion(user, entity);
         }
 
         entity = userAskQuestionService.edit(entity);

+ 2 - 10
server/gateway-api/src/main/java/com/qxgmat/controller/admin/SettingController.java

@@ -528,16 +528,8 @@ public class SettingController {
             Manager manager = shiroHelp.getLoginManager();
             entity.setManagerId(manager.getId());
             User user = usersService.get(in.getUserId());
-            messageExtendService.sendFaqCallback(user, in);
-        }
-        if(in.getIsSystem() == 0 && dto.getSendUser() != null && dto.getSendUser()){
-            // 回复邮箱
-            if (in.getEmail() != null && !in.getEmail().isEmpty()){
-                // 发送邮件,取消
-            }
-            // 回复站内信
-            if(in.getMessage() != null && in.getMessage() > 0){
-
+            if(in.getIsSystem() == 0){
+                messageExtendService.sendFaqCallback(user, in);
             }
         }
         faqService.edit(entity);

+ 72 - 2
server/gateway-api/src/main/java/com/qxgmat/controller/api/TextbookController.java

@@ -13,12 +13,15 @@ import com.qxgmat.data.constants.enums.module.QuestionModule;
 import com.qxgmat.data.constants.enums.status.DirectionStatus;
 import com.qxgmat.data.dao.entity.*;
 import com.qxgmat.data.inline.UserQuestionStat;
+import com.qxgmat.data.relation.entity.TextbookEnrollNumberRelation;
 import com.qxgmat.data.relation.entity.TextbookQuestionRelation;
 import com.qxgmat.dto.extend.UserPaperBaseExtendDto;
 import com.qxgmat.dto.extend.UserReportExtendDto;
 import com.qxgmat.dto.extend.UserServiceRecordExtendDto;
 import com.qxgmat.dto.extend.UserTextbookGroupExtendDto;
+import com.qxgmat.dto.request.TextbookEnrollDto;
 import com.qxgmat.dto.request.TextbookSubscribeDto;
+import com.qxgmat.dto.response.TextbookEnrollTimeDto;
 import com.qxgmat.dto.response.UserTextbookGroupDto;
 import com.qxgmat.dto.response.UserTextbookInfoDto;
 import com.qxgmat.dto.response.UserTextbookPaperDto;
@@ -28,6 +31,7 @@ import com.qxgmat.service.UserQuestionService;
 import com.qxgmat.service.UserServiceService;
 import com.qxgmat.service.UsersService;
 import com.qxgmat.service.extend.QuestionFlowService;
+import com.qxgmat.service.extend.TextbookService;
 import com.qxgmat.service.inline.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -91,6 +95,12 @@ public class TextbookController
     @Autowired
     private TextbookTopicService textbookTopicService;
 
+    @Autowired
+    private TextbookService textbookService;
+
+    @Autowired
+    private UserTextbookEnrollService userTextbookEnrollService;
+
     @RequestMapping(value = "/progress", method = RequestMethod.GET)
     @ApiOperation(value = "机经进度", httpMethod = "GET")
     public Response<List<UserTextbookGroupDto>> progress(HttpSession session) {
@@ -289,7 +299,6 @@ public class TextbookController
         return ResponseHelp.success(p, page, size, p.getTotal());
     }
 
-
     @RequestMapping(value = "/paper/list", method = RequestMethod.GET)
     @ApiOperation(value = "机经组卷列表", httpMethod = "GET")
     public Response<List<UserTextbookPaperDto>> listPaper(
@@ -345,7 +354,9 @@ public class TextbookController
     @ApiOperation(value = "订阅机经", notes = "订阅机经开关", httpMethod = "POST")
     public Response<Boolean> subscribe(@RequestBody @Validated TextbookSubscribeDto dto)  {
         User user = (User) shiroHelp.getLoginUser();
-
+        if (user == null){
+            throw new AuthException("请先登录");
+        }
         UserService userService = userServiceService.getServiceBase(user.getId(), ServiceKey.TEXTBOOK);
         if (userService == null){
             throw new ParameterException("无订阅权限");
@@ -353,4 +364,63 @@ public class TextbookController
         userServiceService.edit(UserService.builder().id(userService.getId()).isSubscribe(dto.getSubscribe() ? 1 : 0).build());
         return ResponseHelp.success(true);
     }
+
+    @RequestMapping(value = "/enroll", method = RequestMethod.POST)
+    @ApiOperation(value = "报名", notes = "报名", httpMethod = "POST")
+    public Response<Boolean> enroll(@RequestBody @Validated TextbookEnrollDto dto)  {
+        User user = (User) shiroHelp.getLoginUser();
+        if (user == null){
+            throw new AuthException("请先登录");
+        }
+        textbookService.enroll(user.getId(), dto.getMonth());
+
+        return ResponseHelp.success(true);
+    }
+
+    @RequestMapping(value = "/enroll/list", method = RequestMethod.GET)
+    @ApiOperation(value = "报名记录", notes = "报名记录", httpMethod = "GET")
+    public Response<List<TextbookEnrollTimeDto>> enroll(
+            @RequestParam(required = false) String year,
+            HttpSession session) {
+        User user = (User) shiroHelp.getLoginUser();
+        Date start;
+        try {
+            start = DateFormat.getDateInstance().parse(String.format("%s-01-01", year));
+        } catch (ParseException e) {
+            throw new ParameterException("日期格式错误");
+        }
+        Date end = Tools.addYear(start, 1);
+
+        List<TextbookEnrollNumberRelation> relations = userTextbookEnrollService.groupByMonth(start.toString(), end.toString());
+        Map<Integer, Integer> monthMap = new HashMap<>();
+        for(TextbookEnrollNumberRelation relation : relations){
+            int month = Tools.monthNumber(relation.getMonth());
+            monthMap.put(month, relation.getNumber());
+        }
+
+        Map<Integer, Boolean> enrollMap = new HashMap<>();
+        if(user != null){
+            List<UserTextbookEnroll> enrolls = userTextbookEnrollService.allByUser(user.getId(), start.toString(), end.toString());
+            for(UserTextbookEnroll enroll : enrolls){
+                int month = Tools.monthNumber(enroll.getMonth());
+                enrollMap.put(month, true);
+            }
+        }
+
+        List<TextbookEnrollTimeDto> dtos = new ArrayList<>();
+        Date now = Tools.addMonth(new Date(), 1);
+        Date monthTime = start;
+        while(monthTime.before(now)){
+            int month = Tools.monthNumber(monthTime);
+            int number = monthMap.getOrDefault(month, 0);
+            boolean status = enrollMap.getOrDefault(month, false);
+            TextbookEnrollTimeDto dto = new TextbookEnrollTimeDto();
+            dto.setMonth(monthTime);
+            dto.setNumber(number);
+            dto.setStatus(status);
+
+            monthTime = Tools.addMonth(monthTime, 1);
+        }
+        return ResponseHelp.success(dtos);
+    }
 }

+ 15 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/request/TextbookEnrollDto.java

@@ -0,0 +1,15 @@
+package com.qxgmat.dto.request;
+
+import java.util.Date;
+
+public class TextbookEnrollDto {
+    private Date month;
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+}

+ 36 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/response/TextbookEnrollTimeDto.java

@@ -0,0 +1,36 @@
+package com.qxgmat.dto.response;
+
+
+import java.util.Date;
+
+public class TextbookEnrollTimeDto {
+    private Date month;
+
+    private Integer number;
+
+    private Boolean status;
+
+    public Date getMonth() {
+        return month;
+    }
+
+    public void setMonth(Date month) {
+        this.month = month;
+    }
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public Boolean getStatus() {
+        return status;
+    }
+
+    public void setStatus(Boolean status) {
+        this.status = status;
+    }
+}

+ 114 - 6
server/gateway-api/src/main/java/com/qxgmat/service/extend/MessageExtendService.java

@@ -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);
     }
 

+ 7 - 0
server/gateway-api/src/main/java/com/qxgmat/service/extend/OrderFlowService.java

@@ -67,6 +67,9 @@ public class OrderFlowService {
     @Resource
     private MessageExtendService messageExtendService;
 
+    @Resource
+    private TextbookService textbookService;
+
     private TradeService tradeService;
 
     @Resource
@@ -609,6 +612,10 @@ public class OrderFlowService {
                 userService.setIsSubscribe(record.getIsSubscribe());
                 userService = userServiceService.edit(userService);
             }
+            if (serviceKey == ServiceKey.TEXTBOOK){
+                // 自动报名: 使用机经的后10天所在月份
+                textbookService.enroll(record.getUserId(), Tools.addDate(new Date(), 10));
+            }
 
             record.setUseStartTime(startTime);
             record.setUseEndTime(endTime);

+ 17 - 6
server/gateway-api/src/main/java/com/qxgmat/service/extend/TextbookService.java

@@ -9,16 +9,12 @@ import com.qxgmat.data.dao.entity.TextbookLibrary;
 import com.qxgmat.data.dao.entity.TextbookPaper;
 import com.qxgmat.data.dao.entity.TextbookQuestion;
 import com.qxgmat.data.relation.entity.TextbookQuestionRelation;
-import com.qxgmat.service.inline.TextbookPaperService;
-import com.qxgmat.service.inline.QuestionService;
-import com.qxgmat.service.inline.TextbookLibraryService;
-import com.qxgmat.service.inline.TextbookQuestionService;
+import com.qxgmat.service.inline.*;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
@@ -46,6 +42,20 @@ public class TextbookService {
     @Resource
     private TextbookLibraryService textbookLibraryService;
 
+    @Resource
+    private UserTextbookEnrollService userTextbookEnrollService;
+
+    /**
+     * 报名
+     * @param userId
+     * @param date
+     */
+    @Transactional
+    public void enroll(Integer userId, Date date){
+        date = Tools.month(date);
+
+    }
+
     /**
      * 添加新一期的换库
      * @param entity
@@ -86,7 +96,7 @@ public class TextbookService {
 
         relation.setTitle(textbookQuestionService.generateTitle(prefixTitle, relation.getNo()));
         // 保存年份
-        relation.setYear(String.valueOf(Tools.year(library.getStartDate())));
+        relation.setYear(String.valueOf(Tools.yearNumber(library.getStartDate())));
 
         TextbookQuestion textbookQuestion =  textbookQuestionService.add(relation);
 
@@ -175,4 +185,5 @@ public class TextbookService {
         }
         return String.format("%s-%s", startDate, endDate);
     }
+
 }

+ 20 - 0
server/gateway-api/src/main/java/com/qxgmat/service/inline/UserTextbookEnrollService.java

@@ -9,11 +9,14 @@ import com.qxgmat.data.dao.TextbookLibraryHistoryMapper;
 import com.qxgmat.data.dao.UserTextbookEnrollMapper;
 import com.qxgmat.data.dao.entity.TextbookLibraryHistory;
 import com.qxgmat.data.dao.entity.UserTextbookEnroll;
+import com.qxgmat.data.relation.UserTextbookEnrollRelationMapper;
+import com.qxgmat.data.relation.entity.TextbookEnrollNumberRelation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -24,7 +27,24 @@ public class UserTextbookEnrollService extends AbstractService {
     @Resource
     private UserTextbookEnrollMapper userTextbookEnrollMapper;
 
+    @Resource
+    private UserTextbookEnrollRelationMapper userTextbookEnrollRelationMapper;
+
+    public List<UserTextbookEnroll> allByUser(Integer userId, String startTime, String endTime){
+        Example example = new Example(UserTextbookEnroll.class);
+        example.and(
+                example.createCriteria()
+                        .andEqualTo("userId", userId)
+                        .andGreaterThanOrEqualTo("month", startTime)
+                        .andLessThan("month", endTime)
+        );
+        example.orderBy("month").asc();
+        return select(userTextbookEnrollMapper, example);
+    }
 
+    public List<TextbookEnrollNumberRelation> groupByMonth(String startTime, String endTime){
+        return userTextbookEnrollRelationMapper.groupByMonth(startTime, endTime);
+    }
 
     public UserTextbookEnroll add(UserTextbookEnroll ad){
         int result = insert(userTextbookEnrollMapper, ad);

+ 2 - 0
server/gateway-api/src/main/java/com/qxgmat/task/ScheduledTask.java

@@ -247,6 +247,8 @@ public class ScheduledTask {
                 // 1v1,查找对应预约用户
                 UserCourseAppointment appointment = userCourseAppointmentService.get(previewAssign.getCourseAppointment());
                 User user = usersService.get(appointment.getUserId());
+                // 替换课程题目
+                course.setTitle(appointment.getTitle());
                 messageExtendService.sendPreviewNotice(user, course, previewAssign);
             }
 //            if (previewAssign.getCourseTime() > 0){

+ 5 - 1
server/gateway-api/src/main/profile/dev/application-runtime.yml

@@ -106,4 +106,8 @@ pay:
   notifyUrl: http://www.qianxing.com/gateway/pay
 
 video:
-  ffmpeg: ffmpeg
+  ffmpeg: ffmpeg
+
+url:
+  pc: http://www.qianxing.com
+  h5: http://m.qianxing.com

+ 17 - 1
server/tools/src/main/java/com/nuliji/tools/Tools.java

@@ -265,12 +265,28 @@ public class Tools {
         return calendar.getTime();
     }
 
-    public static int year(Date date){
+    public static int yearNumber(Date date){
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);
         return calendar.get(Calendar.YEAR);
     }
 
+    public static int monthNumber(Date date){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        return calendar.get(Calendar.MONTH);
+    }
+
+    public static Date month(Date date){
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTime();
+    }
+
     public static int hour(Date date){
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);