Pārlūkot izejas kodu

Merge branch 'children_day'

周箭河 4 gadi atpakaļ
vecāks
revīzija
523d25ec55

+ 16 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ChildrenDayReserveServiceImpl.java

@@ -14,6 +14,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -41,6 +42,8 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
     private ChildrenDayDegreeDetailService childrenDayDegreeDetailService;
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @Override
     public BaseDAO<Integer, ChildrenDayReserve> getDAO() {
@@ -49,9 +52,21 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
 
     @Override
     public ChildrenDayReserve addReserve(SysUser user) {
+        Date nowTime = new Date();
+        String startTimeStr = sysConfigDao.findConfigValue("children_day_start_time");
+        Date startTime = DateUtil.stringToDate(startTimeStr);
+        if (startTime.compareTo(nowTime) > 0) {
+            throw new BizException("活动还未开始,谢谢关注");
+        }
+        String endTimeStr = sysConfigDao.findConfigValue("children_day_end_time");
+        Date endTime = DateUtil.stringToDate(endTimeStr);
+        if (endTime.compareTo(nowTime) <= 0) {
+            throw new BizException("活动已结束,谢谢关注");
+        }
+
         ChildrenDayReserve hasOne = childrenDayReserveDao.getByUserId(user.getId());
         if (hasOne != null) {
-            throw new BizException("您已成功占位");
+            throw new BizException("您已预报名");
         }
         MusicGroup studentLastMusicGroup = musicGroupDao.getStudentLastMusicGroup(user.getId());
         ChildrenDayReserve childrenDayReserve = new ChildrenDayReserve();

+ 3 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/HttpResponseResult.java

@@ -2,6 +2,8 @@ package com.ym.mec.common.entity;
 
 import org.springframework.http.HttpStatus;
 
+import java.util.Date;
+
 /**
  * HttpResponse 返回结果
  */
@@ -11,6 +13,7 @@ public class HttpResponseResult<T> {
 	private String msg;
 	private T data;
 	private int code;
+	private Date nowTime = new Date();
 
 	public HttpResponseResult(boolean status, int code, T data, String message) {
 		this.status = status;

+ 0 - 1
mec-student/src/main/java/com/ym/mec/student/controller/ChildrenDayController.java

@@ -42,7 +42,6 @@ public class ChildrenDayController extends BaseController {
     @Autowired
     private ChildrenDayDegreeDetailService childrenDayDegreeDetailService;
 
-
     @ApiOperation(value = "占位")
     @PostMapping("/reserve")
     public HttpResponseResult<ChildrenDayReserve> reserve() {