yangdamao 2 lat temu
rodzic
commit
5ad79b672a

+ 7 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonController.java

@@ -411,4 +411,11 @@ public class CommonController extends BaseController {
         iSmsService.sendLiveSms(bo.getTel());
         return AjaxResult.success();
     }
+
+    @ApiOperation("获取7个工作日后的时间")
+    @GetMapping("/live/time")
+    public AjaxResult getLiveTime() {
+        Long time = iCourseService.getLiveTime();
+        return AjaxResult.success(time);
+    }
 }

+ 17 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java

@@ -559,4 +559,21 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         return c.getTime().getTime()/1000;
     }
 
+    /**
+     * 指定时间往前或往后推n天
+     *
+     * @param dateTime 指定时间
+     * @param x 指定天数
+     * @return
+     */
+    public static Long getDayAfter(Long dateTime, int x) {
+        Calendar c = Calendar.getInstance();
+        Date date = new Date(dateTime*1000);
+        c.setTime(date);
+        int day = c.get(Calendar.DATE);
+//        c.set(Calendar.DATE, day - x);    //往前推几天
+        c.set(Calendar.DATE, day + x);  //往后推几天
+        return c.getTime().getTime()/1000;
+    }
+
 }

+ 2 - 2
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java

@@ -1290,7 +1290,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         }
 
         if(Validator.isEmpty(user)){
-            throw new CustomException("账号未注册,请联系管理员!");
+            throw new CustomException("请联系管理员!");
         }
         else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
         {
@@ -1398,7 +1398,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
 
         List<User> userList = baseMapper.getUserByTel(bo.getTel());
         if (CollectionUtils.isEmpty(userList)){
-            throw new CustomException("账号不存在!请检查");
+            throw new CustomException("请联系管理员!");
         }
         //参数解析
         String param = new String(Base64.decode(bo.getParam()));

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuExamMapper.java

@@ -22,4 +22,8 @@ public interface CourseMenuExamMapper extends BaseMapper<CourseMenuExam> {
 
     @InterceptorIgnore(tenantLine = "true")
     void deleteByIdTenant(@Param("newCourseId") Long newCourseId,@Param("newTenantId") Long newTenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    void deleteModuleByIdTenant(@Param("newCourseId")Long newCourseId,@Param("newModuleId") Long newModuleId,@Param("newTenantId") Long newTenantId);
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseMenuExamService.java

@@ -53,4 +53,6 @@ public interface ICourseMenuExamService extends IService<CourseMenuExam> {
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
     void deleteByIdTenant(Long newCourseId, Long newTenantId);
+
+    void deleteModuleByIdTenant(Long newCourseId, Long newModuleId, Long newTenantId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseService.java

@@ -94,4 +94,6 @@ public interface ICourseService extends IService<Course> {
 
 	Long getCourseByTenantTwo(String courseName, String code, Long tenantId);
 
+	Long getLiveTime();
+
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuExamServiceImpl.java

@@ -114,4 +114,9 @@ public class CourseMenuExamServiceImpl extends ServiceImpl<CourseMenuExamMapper,
     public void deleteByIdTenant(Long newCourseId, Long newTenantId) {
         baseMapper.deleteByIdTenant(newCourseId, newTenantId);
     }
+
+    @Override
+    public void deleteModuleByIdTenant(Long newCourseId, Long newModuleId, Long newTenantId) {
+        baseMapper.deleteModuleByIdTenant(newCourseId,newModuleId, newTenantId);
+    }
 }

+ 46 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -3,9 +3,11 @@ package com.zhongzheng.modules.course.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.Page;
@@ -22,10 +24,8 @@ import com.zhongzheng.modules.course.service.ICoursePhotoLogService;
 import com.zhongzheng.modules.course.service.ICourseService;
 import com.zhongzheng.modules.course.vo.CourseUserVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
-import com.zhongzheng.modules.exam.domain.ExamApply;
-import com.zhongzheng.modules.exam.domain.ExamApplyUser;
-import com.zhongzheng.modules.exam.domain.ExamBefore;
-import com.zhongzheng.modules.exam.domain.ExamBeforeApply;
+import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeTwoAddBo;
+import com.zhongzheng.modules.exam.domain.*;
 import com.zhongzheng.modules.exam.service.*;
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
 import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
@@ -63,6 +63,7 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -112,6 +113,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     @Autowired
     private IExamApplyUserService iExamApplyUserService;
 
+    @Autowired
+    private IExamApplySiteTimeService iExamApplySiteTimeService;
+
     @Autowired
     private IExamBeforeApplyService iExamBeforeApplyService;
 
@@ -496,6 +500,19 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
                 List<ExamApplyGoodsVo> examApplyGoodsVos2 = new ArrayList<>();
                 examApplyGoodsVoList.forEach(examApplyGoodsVo -> {
                     ExamApply examApply = iExamApplyService.getById(examApplyGoodsVo.getApplyId());
+                    List<ExamApplySiteTime> siteTimes = iExamApplySiteTimeService.list(new LambdaQueryWrapper<ExamApplySiteTime>()
+                            .eq(ExamApplySiteTime::getApplyId, examApplyGoodsVo.getApplyId()));
+                    if (CollectionUtils.isNotEmpty(siteTimes)){
+                        ExamApplySiteTime timeTime = siteTimes.get(0);
+                        List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(timeTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
+                        ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
+                        if (ObjectUtils.isNotNull(twoAddBo)){
+                           Long time = timeTime.getExamTime()+28800L;
+                           String format = String.format("%s-%s", twoAddBo.getStartTime(), twoAddBo.getEndTime());
+                            examApplyGoodsVo.setApplyTime(time);
+                            examApplyGoodsVo.setApplyMoment(format);
+                        }
+                    }
                     switch (examApply.getApplyNature()){
                         case 1: //普通场
                             LambdaQueryWrapper<ExamApplyUser> lqw = Wrappers.lambdaQuery();
@@ -632,6 +649,31 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         return baseMapper.getCourseByTenantTwo(courseName, code, tenantId);
     }
 
+    @Override
+    public Long getLiveTime() {
+        Long nowTime = DateUtils.getNowTime();
+        Long aLong = liveTime(nowTime, 7);
+        return aLong;
+    }
+
+    private Long liveTime(Long nowTime, Integer day) {
+        Long dayAfter = DateUtils.getDayAfter(nowTime, day);
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(DateUtils.timeToDate(dayAfter));
+        int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        String[] weeks = new String[]{"星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
+        if (weeks[index].equals("星期六") || weeks[index].equals("星期天")) {
+            //周末
+            liveTime(nowTime,day + 1);
+        }
+
+        //判断当前是否为工作日
+        if (!DateUtils.isWorkingDay(dayAfter)) {
+            liveTime(nowTime,day + 1);
+        }
+        return dayAfter;
+    }
+
     private List<UserStudyRecordPhotoVo> entity2PhotoVo(Collection<UserStudyRecordPhoto> collection) {
         List<UserStudyRecordPhotoVo> voList = collection.stream()
                 .map(any -> BeanUtil.toBean(any, UserStudyRecordPhotoVo.class))

+ 4 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamApplyGoodsVo.java

@@ -1,11 +1,9 @@
 package com.zhongzheng.modules.exam.vo;
 
 import cn.afterturn.easypoi.excel.annotation.Excel;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
-import java.util.Date;
 
 
 
@@ -41,4 +39,8 @@ public class ExamApplyGoodsVo {
 	/** 考试开始时间段 */
 	@Excel(name = "商品标题",width = 30)
 	private String goodsName;
+	@ApiModelProperty("考试时间段")
+	private String applyMoment;
+	@ApiModelProperty("考试时间")
+	private Long applyTime;
 }

+ 44 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -2526,6 +2526,37 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                     iCourseMenuService.saveBatch(list);
                 }
             }
+
+            //课程模块试卷
+            iCourseMenuExamService.deleteModuleByIdTenant(newCourseId,newModuleId,newTenantId);
+            List<CourseMenuExam> examList = iCourseMenuExamService
+                    .list(new LambdaQueryWrapper<CourseMenuExam>()
+                    .eq(CourseMenuExam::getCourseId, oldCourseId)
+                    .eq(CourseMenuExam::getModuleId, oldModuleId));
+            if (CollectionUtils.isNotEmpty(examList)){
+                for (CourseMenuExam menuExam : examList) {
+                    if (ObjectUtils.isNotNull(menuExam.getChapterId()) || menuExam.getChapterId() != 0){
+                        Long newChapterId = getNewIdByTenant(menuExam.getChapterId(),GoodsCopyEnum.COURSE_CHAPTER.getType(),newTenantId);
+                        if (ObjectUtils.isNull(newChapterId)){
+                            continue;
+                        }
+                        menuExam.setChapterId(newChapterId);
+                    }
+                    if (ObjectUtils.isNotNull(menuExam.getSectionId()) || menuExam.getSectionId() != 0){
+                        Long newSectionId = getNewIdByTenant(menuExam.getSectionId(),GoodsCopyEnum.COURSE_SECTION.getType(),newTenantId);
+                        if (ObjectUtils.isNull(newSectionId)){
+                            continue;
+                        }
+                        menuExam.setSectionId(newSectionId);
+                    }
+                    menuExam.setId(null);
+                    menuExam.setCourseId(newCourseId);
+                    menuExam.setModuleId(newModuleId);
+                    menuExam.setExamId(getNewExamId(menuExam.getExamId(),newTenantId,array));
+                    menuExam.setTenantId(newTenantId);
+                }
+                iCourseMenuExamService.saveBatch(examList);
+            }
         }
 
     }
@@ -4500,15 +4531,24 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
                 Course course = iCourseService.getById(bo.getCourseId());
                 bo.getTenantId().forEach(newTenantId -> {
                     List<SysGoodsCopyRecord> recordList = new ArrayList<>();
-                    Long newCourseId = iCourseService.getCourseByTenantTwo(course.getCourseName(), course.getCode(), newTenantId);
+                    Long  newCourseId = iCourseService.getCourseByTenantTwo(course.getCourseName(), course.getCode(), newTenantId);
                     if (ObjectUtils.isNull(newCourseId)){
                         throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
                     }
-                    getNewModuleId(bo.getModelId(),newTenantId,recordList);
+                    disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
+                });
+                break;
+            case 3://章复制
+                Course courseTwo = iCourseService.getById(bo.getCourseId());
+                bo.getTenantId().forEach(newTenantId -> {
+                    List<SysGoodsCopyRecord> recordList = new ArrayList<>();
+                    Long newCourseId = iCourseService.getCourseByTenantTwo(courseTwo.getCourseName(), courseTwo.getCode(), newTenantId);
+                    if (ObjectUtils.isNull(newCourseId)){
+                        throw new CustomException("该机构不存在此商品课程,请先复制商品课程!");
+                    }
+//                    disposeModule(bo.getModelId(),newTenantId,bo.getCourseId(),newCourseId,recordList);
                 });
                 break;
-
-
 
 
         }

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/impl/TopOldOrderServiceImpl.java

@@ -2018,7 +2018,13 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
             //新云学堂C端
             User user = userService.getById(orderVo.getUserId());
             vo.setApplyName(String.format("%s(%s)", tenant.getTenantName(), user.getRealname()));
-        } else {
+        }else if (orderVo.getOrderFrom() == 2){
+            vo.setPayType(orderVo.getPayType());
+            List<TopOldOrderGoods> list = topOrderGoodsService
+                    .list(new LambdaQueryWrapper<TopOldOrderGoods>()
+                    .eq(TopOldOrderGoods::getOrderSn, orderVo.getOrderSn()));
+            vo.setApplyName(String.format("%s(%s)", tenant.getTenantName(),list.get(0).getUserName()));
+        }else {
             vo.setApplyName(String.format("%s(%s)", tenant.getTenantName(), orderVo.getCreateUsername()));
         }
         vo.setCheckType(1);

+ 4 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuExamMapper.xml

@@ -49,4 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from course_menu_exam where course_id = #{newCourseId} and tenant_id = #{newTenantId}
     </delete>
 
+    <delete id="deleteModuleByIdTenant" parameterType="map">
+        delete from course_menu_exam where course_id = #{newCourseId} and module_id = #{newModuleId} and tenant_id = #{newTenantId}
+    </delete>
+
 </mapper>