瀏覽代碼

Merge branch 'dev'

yangdamao 2 年之前
父節點
當前提交
86a74aecc1
共有 100 個文件被更改,包括 2770 次插入411 次删除
  1. 4 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/activity/ActivityRecommendController.java
  2. 26 4
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java
  3. 2 1
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassGradeController.java
  4. 7 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java
  5. 41 0
      zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserSubscribeController.java
  6. 4 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/ActivityRecommendController.java
  7. 10 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/order/OrderController.java
  8. 210 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java
  9. 5 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java
  10. 10 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserServiceImpl.java
  11. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ActivityRecommendQueryBo.java
  12. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityRecommendServiceImpl.java
  13. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/vo/ActivityRecommendVo.java
  14. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/base/mapper/UserProfileMapper.java
  15. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/IUserProfileService.java
  16. 16 15
      zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/CertificateTpServiceImpl.java
  17. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/UserProfileServiceImpl.java
  18. 3 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseAddBo.java
  19. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseEditBo.java
  20. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuAddBo.java
  21. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuEditBo.java
  22. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuQueryBo.java
  23. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/Course.java
  24. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseMenu.java
  25. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuMapper.java
  26. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/MajorMapper.java
  27. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/IMajorService.java
  28. 7 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java
  29. 4 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java
  30. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/MajorServiceImpl.java
  31. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseMenuVo.java
  32. 8 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseUserMenuVo.java
  33. 4 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseVo.java
  34. 51 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamApplyResultExportBo.java
  35. 24 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/SubscribeInfoBo.java
  36. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/domain/ExamApply.java
  37. 16 4
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyMapper.java
  38. 9 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java
  39. 174 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java
  40. 9 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAddBo.java
  41. 9 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsEditBo.java
  42. 38 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsFirstChoiceAddBo.java
  43. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/Goods.java
  44. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsCourse.java
  45. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java
  46. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java
  47. 14 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java
  48. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/ClassGradeUserQueryBo.java
  49. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/domain/ClassGrade.java
  50. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeGoodsMapper.java
  51. 1 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeMapper.java
  52. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeUserMapper.java
  53. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IClassGradeGoodsService.java
  54. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeGoodsServiceImpl.java
  55. 204 199
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java
  56. 7 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java
  57. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassGradeStudentVo.java
  58. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java
  59. 5 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java
  60. 135 8
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java
  61. 46 41
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java
  62. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/IScheduleService.java
  63. 226 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java
  64. 44 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysTask.java
  65. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysTenant.java
  66. 13 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysTaskMapper.java
  67. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysTenantMapper.java
  68. 16 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTaskService.java
  69. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTenantService.java
  70. 16 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysTaskServiceImpl.java
  71. 49 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/system/vo/SysTaskVo.java
  72. 20 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/SubUserExportBo.java
  73. 83 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubQueryBo.java
  74. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserSubscribe.java
  75. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserMapper.java
  76. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java
  77. 20 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserSubscribeMapper.java
  78. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserService.java
  79. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java
  80. 13 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserSubscribeService.java
  81. 15 8
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java
  82. 376 22
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java
  83. 38 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserExamApplyExport.java
  84. 52 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubApplyExport.java
  85. 74 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubVo.java
  86. 10 1
      zhongzheng-system/src/main/resources/mapper/modules/activity/ActivityRecommendMapper.xml
  87. 7 3
      zhongzheng-system/src/main/resources/mapper/modules/base/UserProfileMapper.xml
  88. 17 19
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml
  89. 14 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml
  90. 3 0
      zhongzheng-system/src/main/resources/mapper/modules/course/MajorMapper.xml
  91. 95 0
      zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyMapper.xml
  92. 11 0
      zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml
  93. 5 0
      zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeGoodsMapper.xml
  94. 20 19
      zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeMapper.xml
  95. 69 60
      zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml
  96. 9 0
      zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml
  97. 3 1
      zhongzheng-system/src/main/resources/mapper/modules/system/SysTenantMapper.xml
  98. 19 0
      zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml
  99. 5 1
      zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml
  100. 194 0
      zhongzheng-system/src/main/resources/mapper/modules/user/UserSubscribeMapper.xml

+ 4 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/activity/ActivityRecommendController.java

@@ -46,6 +46,10 @@ public class ActivityRecommendController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<ActivityRecommendVo> list(ActivityRecommendQueryBo bo) {
         startPage();
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(1);
+        statusList.add(0);
+        bo.setStatusList(statusList);
         List<ActivityRecommendVo> list = iActivityRecommendService.selectList(bo);
         return getDataTable(list);
     }

+ 26 - 4
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -42,10 +42,7 @@ import com.zhongzheng.modules.distribution.service.IDistributionActivityGoodsSer
 import com.zhongzheng.modules.distribution.service.IDistributionCashWithdrawalService;
 import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
-import com.zhongzheng.modules.exam.bo.ExamApplyDetailBo;
-import com.zhongzheng.modules.exam.bo.ExamApplyResultBo;
-import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
-import com.zhongzheng.modules.exam.bo.UpdateStudentImageBo;
+import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.service.IExamApplyService;
 import com.zhongzheng.modules.exam.vo.ExamApplyDetailVo;
 import com.zhongzheng.modules.goods.bo.AlikeGoodsBo;
@@ -315,6 +312,31 @@ public class CommonController extends BaseController {
     }
 
     @ApiOperation("七大员新考结果")
+    @PostMapping("common/apply/result/receipt")
+    public AjaxResult examApplyResultReceipt(List<MultipartFile> files) {
+        files.forEach(item -> {
+            try {
+                ExcelUtil<ExamApplyResultExportBo> util = new ExcelUtil<ExamApplyResultExportBo>(ExamApplyResultExportBo.class);
+                //测试时间
+                String time = util.examApplyTimeAnalysis(item.getInputStream(), 1);
+                //成绩数据
+                List<ExamApplyResultExportBo> exportBo = util.examApplyImportExcel("", item.getInputStream());
+                iExamApplyService.examApplyResultReceipt(exportBo,time);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        });
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("七大员新考证书")
+    @PostMapping("common/apply/result/certificate")
+    public AjaxResult examApplyResultCertificate(List<MultipartFile> files) {
+        String msg = iExamApplyService.examApplyResultCertificate(files);
+        return AjaxResult.success(msg);
+    }
+
+    @ApiOperation("七大员考试结果回执")
     @PostMapping("common/apply/result")
     public AjaxResult examApplyResult(@RequestBody ExamApplyResultBo bo) {
         if (!ToolsUtils.checkSignFromOldSys(bo.getStamp().toString(), bo.getSign())) {

+ 2 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/grade/ClassGradeController.java

@@ -196,7 +196,8 @@ public class ClassGradeController extends BaseController {
     @PreAuthorize("@ss.hasPermi('grade:grade:list')")
     @GetMapping("/listGrade")
     public TableDataInfo<ClassGradeStudentVo> listGrade(ClassGradeUserQueryBo bo) {
-        if (ObjectUtils.isNotNull(bo.getGradeId())){
+        if (ObjectUtils.isNotNull(bo.getSevenCodeSign()) && bo.getSevenCodeSign() == 1
+                && ObjectUtils.isNotNull(bo.getGradeId())){
             ClassGrade gradeGrade = iClassGradeService.getById(bo.getGradeId());
             if (StringUtils.isNotBlank(gradeGrade.getSevenCode())){
                 bo.setSevenCode(gradeGrade.getSevenCode());

+ 7 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java

@@ -444,4 +444,11 @@ public class ScheduleController extends BaseController {
         iScheduleService.syncUserDateStudyLog();
         return AjaxResult.success();
     }
+
+    @ApiOperation("七大员学员预约下载任务执行")
+    @GetMapping("/user/download")
+    public AjaxResult usbUserDownload(){
+        iScheduleService.usbUserDownload();
+        return AjaxResult.success();
+    }
 }

+ 41 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserSubscribeController.java

@@ -18,6 +18,7 @@ import com.zhongzheng.modules.exam.domain.ExamApplySiteTime;
 import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
 import com.zhongzheng.modules.exam.service.IExamApplySiteTimeService;
 import com.zhongzheng.modules.exam.vo.ExamSessionVo;
+import com.zhongzheng.modules.system.vo.SysTaskVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.service.IUserExamGoodsService;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
@@ -69,6 +70,46 @@ public class UserSubscribeController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 预约列表(包含其他使用祥粤考场的机构)
+     */
+    @ApiOperation("预约列表(包含其他使用祥粤考场的机构)")
+    @GetMapping("/sub/list")
+    public TableDataInfo<UserSubVo> getListSubscribe(UserSubQueryBo bo) {
+        startPage();
+        List<UserSubVo> list = iUserSubscribeService.getListSubscribe(bo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 预约学员档案资料下载
+     */
+    @ApiOperation("预约学员档案资料下载")
+    @GetMapping("/sub/user/export")
+    public AjaxResult<Void> subUserExport(SubUserExportBo bo) {
+        return toAjax(iUserSubscribeService.subUserExport(bo) ? 1 : 0);
+    }
+
+    /**
+     * 预约学员信息下载
+     */
+    @ApiOperation("预约学员信息下载")
+    @PostMapping("/sub/record/user/export")
+    public AjaxResult<String> subRecordUserExport(@RequestBody SubUserExportBo bo) {
+        String path = iUserSubscribeService.subRecordUserExport(bo);
+        return AjaxResult.success("操作成功",path);
+    }
+
+    /**
+     * 学员档案下载任务列表
+     */
+    @ApiOperation("学员档案下载任务列表")
+    @GetMapping("/sub/user/export/list")
+    public AjaxResult<List<SysTaskVo>> subUserExportList() {
+        return AjaxResult.success(iUserSubscribeService.subUserExportList());
+    }
+
+
     /**
      * 根据月份获取当月考试场次
      */

+ 4 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/ActivityRecommendController.java

@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -40,6 +41,9 @@ public class ActivityRecommendController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo<ActivityRecommendVo> list(ActivityRecommendQueryBo bo) {
         startPage();
+        List<Integer> statusList = new ArrayList<>();
+        statusList.add(1);
+        bo.setStatusList(statusList);
         List<ActivityRecommendVo> list = iActivityRecommendService.selectList(bo);
         return getDataTable(list);
     }

+ 10 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/order/OrderController.java

@@ -10,6 +10,7 @@ import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.base.vo.BaseFilterVo;
 import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
 import com.zhongzheng.modules.course.vo.CourseEducationTypeVo;
+import com.zhongzheng.modules.goods.bo.GoodsFirstChoiceAddBo;
 import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.order.service.IOrderService;
@@ -227,4 +228,13 @@ public class OrderController extends BaseController {
     public AjaxResult<String> getOrderSevenYear(@PathVariable("orderGoodsId")Long orderGoodsId) {
         return AjaxResult.success("成功",iOrderGoodsService.getOrderSevenYear(orderGoodsId));
     }
+
+
+    @ApiOperation("优选商品重构")
+    @PostMapping("/firstChoiceGoods")
+    public AjaxResult<GoodsFirstChoiceAddBo> firstChoiceGoods(@RequestBody GoodsFirstChoiceAddBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iOrderGoodsService.firstChoiceGoods(bo));
+    }
 }

+ 210 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java

@@ -315,6 +315,216 @@ public class ExcelUtil<T>
         return list;
     }
 
+    /**
+     * 获取七大员指定表格考试时间
+     *
+     * @param is 输入流
+     * @return 转换后集合
+     */
+    public String examApplyTimeAnalysis(InputStream is,Integer index) throws Exception
+    {
+        this.type = Type.IMPORT;
+        this.wb = WorkbookFactory.create(is);
+        Sheet sheet = wb.getSheetAt(0);
+        if (sheet == null)
+        {
+            throw new IOException("文件sheet不存在");
+        }
+        // 获取表头
+        Row heard = sheet.getRow(index);
+        Iterator<Cell> cellIterator = heard.cellIterator();
+        List<String> dataList = new ArrayList<>();
+        while(cellIterator.hasNext()) {
+            Cell next = cellIterator.next();
+            String stringCellValue = next.getStringCellValue();
+            dataList.add(stringCellValue);
+        }
+        return dataList.get(dataList.size() -1);
+    }
+    /**
+     * 七大员考试回执方法
+     *
+     * @param sheetName 表格索引名
+     * @param is 输入流
+     * @return 转换后集合
+     */
+    public List<T> examApplyImportExcel(String sheetName, InputStream is) throws Exception
+    {
+        this.type = Type.IMPORT;
+        this.wb = WorkbookFactory.create(is);
+        List<T> list = new ArrayList<T>();
+        Sheet sheet = null;
+        if (Validator.isNotEmpty(sheetName))
+        {
+            // 如果指定sheet名,则取指定sheet中的内容.
+            sheet = wb.getSheet(sheetName);
+        }
+        else
+        {
+            // 如果传入的sheet名不存在则默认指向第1个sheet.
+            sheet = wb.getSheetAt(0);
+        }
+
+        if (sheet == null)
+        {
+            throw new IOException("文件sheet不存在");
+        }
+
+        int rows = sheet.getPhysicalNumberOfRows();
+
+        if (rows > 0)
+        {
+            // 定义一个map用于存放excel列的序号和field.
+            Map<String, Integer> cellMap = new HashMap<String, Integer>();
+            // 第2行是表头
+            Row heard = sheet.getRow(2);
+            for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
+            {
+                Cell cell = heard.getCell(i);
+                if (Validator.isNotNull(cell))
+                {
+                    String value = this.getCellValue(heard, i).toString();
+                    cellMap.put(value, i);
+                }
+                else
+                {
+                    cellMap.put(null, i);
+                }
+            }
+            // 有数据时才处理 得到类的所有field.
+            Field[] allFields = clazz.getDeclaredFields();
+            // 定义一个map用于存放列的序号和field.
+            Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
+            for (int col = 0; col < allFields.length; col++)
+            {
+                Field field = allFields[col];
+                Excel attr = field.getAnnotation(Excel.class);
+                if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
+                {
+                    // 设置类的私有字段属性可访问.
+                    field.setAccessible(true);
+                    Integer column = cellMap.get(attr.name());
+                    if (column != null)
+                    {
+                        fieldsMap.put(column, field);
+                    }
+                }
+            }
+            for (int i = 3; i < rows; i++)
+            {
+                // 从第3行开始取数据,第2行是表头.
+                Row row = sheet.getRow(i);
+                if(row == null)
+                {
+                    continue;
+                }
+                T entity = null;
+                for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
+                {
+                    Object val = this.getCellValue(row, entry.getKey());
+
+                    // 如果不存在实例则新建.
+                    entity = (entity == null ? clazz.newInstance() : entity);
+                    // 从map中得到对应列的field.
+                    Field field = fieldsMap.get(entry.getKey());
+                    // 取得类型,并根据对象类型设置值.
+                    Class<?> fieldType = field.getType();
+                    if (String.class == fieldType)
+                    {
+                        String s = Convert.toStr(val);
+                        if (StrUtil.endWith(s, ".0"))
+                        {
+                            //    val = StrUtil.subBefore(s, ".0",false);
+                        }
+                        else
+                        {
+                            if (val instanceof Double)
+                            {
+                                String dateFormat = field.getAnnotation(Excel.class).dateFormat();
+                                if (Validator.isNotEmpty(dateFormat))
+                                {
+                                    val = DateUtils.parseDateToStr(dateFormat, (Date) val);
+                                }
+                                else
+                                {
+                                    val = Convert.toStr(val);
+                                }
+                            }
+                            if (val instanceof Date)
+                            {
+                                String dateFormat = field.getAnnotation(Excel.class).dateFormat();
+                                if (Validator.isNotEmpty(dateFormat))
+                                {
+                                    val = DateUtils.parseDateToStr(dateFormat, (Date) val);
+                                }
+                                else
+                                {
+                                    val = Convert.toStr(val);
+                                }
+                            }
+
+                        }
+                    }
+                    else if ((Integer.TYPE == fieldType || Integer.class == fieldType) && Validator.isNumber(Convert.toStr(val)))
+                    {
+                        val = Convert.toInt(val);
+                    }
+                    else if (Long.TYPE == fieldType || Long.class == fieldType)
+                    {
+                        val = Convert.toLong(val);
+                    }
+                    else if (Double.TYPE == fieldType || Double.class == fieldType)
+                    {
+                        val = Convert.toDouble(val);
+                    }
+                    else if (Float.TYPE == fieldType || Float.class == fieldType)
+                    {
+                        val = Convert.toFloat(val);
+                    }
+                    else if (BigDecimal.class == fieldType)
+                    {
+                        val = Convert.toBigDecimal(val);
+                    }
+                    else if (Date.class == fieldType)
+                    {
+                        if (val instanceof String)
+                        {
+                            val = DateUtils.parseDate(val);
+                        }
+                        else if (val instanceof Double)
+                        {
+                            val = DateUtil.getJavaDate((Double) val);
+                        }
+                    }
+                    else if (Boolean.TYPE == fieldType || Boolean.class == fieldType)
+                    {
+                        val = Convert.toBool(val, false);
+                    }
+                    if (Validator.isNotNull(fieldType))
+                    {
+                        Excel attr = field.getAnnotation(Excel.class);
+                        String propertyName = field.getName();
+                        if (Validator.isNotEmpty(attr.targetAttr()))
+                        {
+                            propertyName = field.getName() + "." + attr.targetAttr();
+                        }
+                        else if (Validator.isNotEmpty(attr.readConverterExp()))
+                        {
+                            val = reverseByExp(Convert.toStr(val), attr.readConverterExp(), attr.separator());
+                        }
+                        else if (Validator.isNotEmpty(attr.dictType()))
+                        {
+                            val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
+                        }
+                        ReflectUtils.invokeSetter(entity, propertyName, val);
+                    }
+                }
+                list.add(entity);
+            }
+        }
+        return list;
+    }
+
     /**
      * 对list数据源将其里面的数据导入到excel表单
      *

+ 5 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/SysTenantServiceImpl.java

@@ -496,6 +496,11 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
         return baseMapper.getListNoTenant(tenantId);
     }
 
+    @Override
+    public List<SysTenant> getExamRoomTenant() {
+        return baseMapper.getExamRoomTenant();
+    }
+
     private void initRoles(Long newTenantId,Long tenantId) {
         List<String> roleKey = new ArrayList<>();
         roleKey.add("seller");

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

@@ -1584,6 +1584,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         return tokenService.createToken(loginUser);
     }
 
+    @Override
+    public User getByIdNoTenant(Long userId) {
+        return baseMapper.getByIdNoTenant(userId);
+    }
+
+    @Override
+    public User getByCardNoTenant(String idCard) {
+        return baseMapper.getByCardNoTenant(idCard);
+    }
+
 
     @Override
     public Map<String, Object> accountLogin(UserAppAccountLoginBo bo) {

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/bo/ActivityRecommendQueryBo.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -57,4 +58,6 @@ public class ActivityRecommendQueryBo extends BaseEntity {
 	/** 1小程序 2PC网站 */
 	@ApiModelProperty("1小程序 2PC网站")
 	private Integer platform;
+	@ApiModelProperty("1有效 0无效")
+	private List<Integer> statusList;
 }

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityRecommendServiceImpl.java

@@ -140,6 +140,18 @@ public class ActivityRecommendServiceImpl extends ServiceImpl<ActivityRecommendM
                             GoodsSpecAttributeRelation relation = list.stream().findFirst().get();
                             item.setSpecTemplateId(relation.getSpecTemplateId());
                         }
+                        //多规格下的价格区间
+                        List<GoodsSpecAttributeRelation> specAttributeRelations = goodsSpecAttributeRelationService
+                                .list(new LambdaQueryWrapper<GoodsSpecAttributeRelation>()
+                                        .eq(GoodsSpecAttributeRelation::getSpecTemplateId, item.getSpecTemplateId()));
+                        if (CollectionUtils.isNotEmpty(specAttributeRelations)) {
+                            List<Long> goodsIds = specAttributeRelations.stream().filter(x -> ObjectUtils.isNotNull(x.getGoodsId())).map(GoodsSpecAttributeRelation::getGoodsId).collect(Collectors.toList());
+                            List<Goods> goodsList = iGoodsService.listByIds(goodsIds);
+                            //从小到大排序
+                            List<Goods> collect = goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getStandPrice())).sorted(Comparator.comparing(Goods::getStandPrice)).collect(Collectors.toList());
+                            item.setMinPrice(collect.get(0).getStandPrice());
+                            item.setMaxPrice(collect.get(collect.size() - 1).getStandPrice());
+                        }
                     }
                 });
             }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/vo/ActivityRecommendVo.java

@@ -71,4 +71,6 @@ public class ActivityRecommendVo {
 	private String businessName;
 	@ApiModelProperty("商品列表")
 	private List<ActivityRecommendGoodsVo> goodsList;
+	@ApiModelProperty("业务别名称")
+	private String aliasName;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/mapper/UserProfileMapper.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.base.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.zhongzheng.common.annotation.DataScope;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.bo.UserProfileQueryBo;
@@ -29,4 +30,7 @@ public interface UserProfileMapper extends BaseMapper<UserProfile> {
     Long selectGrade(@Param("userId") Long userId,@Param("goodsId") Long goodsId);
 
     Integer getProfileStatusNum(ConsoleQueryBo bo);
+
+    @InterceptorIgnore(tenantLine = "true")
+    UserProfile getByOrderGoodsIdNoTenant(Long orderGoodsId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/IUserProfileService.java

@@ -77,4 +77,6 @@ public interface IUserProfileService extends IService<UserProfile> {
 	Map<String,Object> exportPo(UserProfileQueryBo bo);
 
 	Integer getProfileStatusNum(ConsoleQueryBo bo);
+
+    UserProfile getByOrderGoodsIdNoTenant(Long orderGoodsId);
 }

+ 16 - 15
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/CertificateTpServiceImpl.java

@@ -48,6 +48,7 @@ import javax.imageio.ImageIO;
 import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -193,7 +194,7 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                     vo.setYear(date.substring(0, 4));
                     vo.setType("专业");
                     vo.setMajor("网络班");
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
@@ -216,7 +217,7 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                     vo.setYear(date.substring(0, 4));
                     vo.setType("选修");
                     vo.setMajor("网络班");
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
@@ -244,13 +245,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中必修");
-                    vo.setRemark2("课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -274,13 +275,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中建");
-                    vo.setRemark2("筑工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("筑工程课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -304,13 +305,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中机");
-                    vo.setRemark2("电工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("电工程课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -334,13 +335,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中市");
-                    vo.setRemark2("政公用工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("政公用工程课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -364,13 +365,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中公");
-                    vo.setRemark2("路工程课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("路工程课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -394,13 +395,13 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
                         sex = "女";
                     }
                     vo.setSex(sex);
-                    vo.setClassHours(goodsVo.getClassHours()+"");
+                    vo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+"");
                     vo.setDateY(nowDate.substring(0, 4));
                     vo.setDateM(nowDate.substring(5, 7));
                     vo.setDateD(nowDate.substring(8, 10));
                     vo.setMajor("一级建造师继续教育培训");
                     vo.setRemark1("其中水");
-                    vo.setRemark2("利水电课 "+goodsVo.getClassHours()+" 学时,测试成绩合格。");
+                    vo.setRemark2("利水电课 "+goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP )+" 学时,测试成绩合格。");
                     vo.setTrainStartTime(studyRecordVo.getFirstStartTime()); //培训开始时间
                     vo.setTrainEndTime(classGradeUser.getPeriodWaitTime());//学时变为待审核时间,也是学习完成时间
                     List<String> chapterListTxt = changeChapterList(chapterList);
@@ -422,7 +423,7 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         addBo.setCertificateTpId(certificateTpId);
         addBo.setCertificateCode(vo.getCode());
         addBo.setCertificatePath(certificatePath);
-        addBo.setClassHours(goodsVo.getClassHours());
+        addBo.setClassHours(goodsVo.getClassHours().setScale( 0, BigDecimal.ROUND_HALF_UP ));
         addBo.setEducationTypeId(goodsVo.getEducationTypeId());
         addBo.setProjectId(goodsVo.getProjectId());
         addBo.setBusinessId(goodsVo.getBusinessId());

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/UserProfileServiceImpl.java

@@ -997,6 +997,11 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
         return baseMapper.getProfileStatusNum(bo);
     }
 
+    @Override
+    public UserProfile getByOrderGoodsIdNoTenant(Long orderGoodsId) {
+        return baseMapper.getByOrderGoodsIdNoTenant(orderGoodsId);
+    }
+
     /**
      * url读取image转换为Base64字符串
      *

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseAddBo.java

@@ -78,5 +78,7 @@ public class CourseAddBo {
     /** 1显示 0隐藏 */
     @ApiModelProperty("1显示 0隐藏")
     private Integer courseShow;
-
+    /** 优选生成 0否 1是 */
+    @ApiModelProperty("优选生成 0否 1是")
+    private Integer firstChoice;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseEditBo.java

@@ -96,4 +96,7 @@ public class CourseEditBo {
     /** 1显示 0隐藏 */
     @ApiModelProperty("1显示 0隐藏")
     private Integer courseShow;
+    /** 优选生成 0否 1是 */
+    @ApiModelProperty("优选生成 0否 1是")
+    private Integer firstChoice;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuAddBo.java

@@ -42,4 +42,7 @@ public class CourseMenuAddBo {
     /** 排序 */
     @ApiModelProperty("排序")
     private Integer sort;
+    /** 是否优选  0没有 1选中 */
+    @ApiModelProperty("是否优选  0没有 1选中")
+    private Integer firstChoiceStatus;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuEditBo.java

@@ -48,4 +48,8 @@ public class CourseMenuEditBo {
     /** 排序 */
     @ApiModelProperty("排序")
     private Integer sort;
+
+    /** 是否优选  0没有 1选中 */
+    @ApiModelProperty("是否优选  0没有 1选中")
+    private Integer firstChoiceStatus;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseMenuQueryBo.java

@@ -79,4 +79,7 @@ public class CourseMenuQueryBo extends BaseEntity {
 
 	@ApiModelProperty("商品ID")
 	private Long goodsId;
+
+	@ApiModelProperty("是否获取学时 1获取")
+	private Integer getHours;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/Course.java

@@ -72,5 +72,7 @@ private static final long serialVersionUID=1L;
     private Long tenantId;
     @TableField(exist = false)
     private Long oId;
+    /** 优选生成 0否 1是 */
+    private Integer firstChoice;
 
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/domain/CourseMenu.java

@@ -45,4 +45,6 @@ private static final long serialVersionUID=1L;
     /** 排序 */
     private Integer sort;
     private Long tenantId;
+    /** 是否优选  0没有 1选中 */
+    private Integer firstChoiceStatus;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMenuMapper.java

@@ -43,4 +43,6 @@ public interface CourseMenuMapper extends BaseMapper<CourseMenu> {
     @InterceptorIgnore(tenantLine = "true")
     List<CourseMenu> selectByNotTenant(@Param("newCourseId") Long newCourseId,@Param("type") Integer type,@Param("newModuleId") Long newModuleId,@Param("newTenantId") Long newTenantId);
 
+    Long countChapterTotalTime(@Param("chapterId") Long chapterId);
+
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/MajorMapper.java

@@ -28,4 +28,7 @@ public interface MajorMapper extends BaseMapper<Major> {
 
     @InterceptorIgnore(tenantLine = "true")
     Major getMajorByTenant(@Param("encoder") String encoder,@Param("newTenantId") Long newTenantId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    Major getMajorByIdNoTenant(Long majorId);
 }

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

@@ -51,4 +51,6 @@ public interface IMajorService extends IService<Major> {
 	Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
 
     Major getMajorByTenant(String encoder, Long newTenantId);
+
+    Major getMajorByIdNoTenant(Long majorId);
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseMenuServiceImpl.java

@@ -269,6 +269,13 @@ public class CourseMenuServiceImpl extends ServiceImpl<CourseMenuMapper, CourseM
                 }
             }
         }
+        if ( Validator.isNotEmpty(bo.getGetHours()) && bo.getGetHours() == 1) {
+            for (CourseUserMenuVo courseMenuVo : courseMenuVos) {
+                if(courseMenuVo.getType()==2){
+                    courseMenuVo.setTotalTime(baseMapper.countChapterTotalTime(courseMenuVo.getMenuId()));
+                }
+            }
+        }
         if (bo.getRebuild() != null && bo.getRebuild() == 1) {
             List<CourseUserMenuVo> courseMenuVoss = courseMenuVos.stream().filter(s ->
                     s.getRebuild() != null && s.getRebuild().equals(1)

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

@@ -781,8 +781,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
             }
             goodsUserVo.setSecAllNum(secLong);
             goodsUserVo.setStuAllNum(studyLong);
-            goodsUserVo.setSubscribeSign(2);
-
+            goodsUserVo.setSubscribeSign(0);
 
             //查询对应考试安排
             List<ExamApplyGoodsVo> examApplyGoodsVoList = iExamApplyGoodsService.listByGoodsId(goodsUserVo.getGoodsId());
@@ -799,6 +798,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
                             .last("limit 1"));
                     if (ObjectUtils.isNull(userSubscribe)){
                         goodsUserVo.setSubscribeSign(1);
+                    }else if (userSubscribe.getSubscribeStatus() == 1 && userSubscribe.getExamStatus() == 1
+                            && ObjectUtils.isNull(userSubscribe.getResult())){
+                        goodsUserVo.setSubscribeSign(2);
                     }else if (userSubscribe.getSubscribeStatus() == 1 && userSubscribe.getExamStatus() == 0){
                         goodsUserVo.setSubscribeSign(4);
                     }else if (ObjectUtils.isNotNull(userSubscribe.getResult()) && userSubscribe.getResult() == 0){

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

@@ -175,4 +175,9 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
     public Major getMajorByTenant(String encoder, Long newTenantId) {
         return baseMapper.getMajorByTenant(encoder,newTenantId);
     }
+
+    @Override
+    public Major getMajorByIdNoTenant(Long majorId) {
+        return baseMapper.getMajorByIdNoTenant(majorId);
+    }
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseMenuVo.java

@@ -95,4 +95,9 @@ public class CourseMenuVo {
 	@ApiModelProperty("章下面的节")
 	private List<CourseChapterSectionVo> courseChapterSectionList;
 
+	/** 是否优选  0没有 1选中 */
+	@Excel(name = "是否优选  0没有 1选中")
+	@ApiModelProperty("是否优选  0没有 1选中")
+	private Integer firstChoiceStatus;
+
 }

+ 8 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseUserMenuVo.java

@@ -101,4 +101,12 @@ public class CourseUserMenuVo {
 	@ApiModelProperty("公共标识:1公共章 0非公共章")
 	private Integer commonSign;
 
+	/** 是否优选  0没有 1选中 */
+	@Excel(name = "是否优选  0没有 1选中")
+	@ApiModelProperty("是否优选  0没有 1选中")
+	private Integer firstChoiceStatus;
+
+	@ApiModelProperty("章下节总秒数")
+	private Long totalTime;
 }
+

+ 4 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/vo/CourseVo.java

@@ -117,5 +117,8 @@ public class CourseVo {
 	private Integer courseShow;
 	@ApiModelProperty("课程双师资绑定状态")
 	private Integer bindStatus;
-
+	/** 优选生成 0否 1是 */
+	@Excel(name = "优选生成 0否 1是")
+	@ApiModelProperty("优选生成 0否 1是")
+	private Integer firstChoice;
 }

+ 51 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamApplyResultExportBo.java

@@ -0,0 +1,51 @@
+package com.zhongzheng.modules.exam.bo;
+
+import com.zhongzheng.common.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年06月20日 11:22
+ */
+@Data
+public class ExamApplyResultExportBo implements Serializable {
+
+    @Excel(name = "序号")
+    private String index;
+
+    @Excel(name = "考生姓名")
+    private String userName;
+
+    @Excel(name = "考生身份证号")
+    private String idCard;
+
+    @Excel(name = "联系方式")
+    private String telphone;
+
+    @Excel(name = "岗位名称")
+    private String majorName;
+
+    @Excel(name = "考试状态")
+    private String applyStatus;
+
+    @Excel(name = "考试成绩")
+    private String score;
+
+    @Excel(name = "成绩审核状态")
+    private String scoreCheck;
+
+    @Excel(name = "成绩审核时间")
+    private String scoreCheckTime;
+
+    @Excel(name = "工作单位")
+    private String companyName;
+
+    @Excel(name = "证书编码")
+    private String certificateCode;
+
+
+}

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/SubscribeInfoBo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.exam.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年10月11日 11:40
+ */
+@Data
+public class SubscribeInfoBo implements Serializable {
+
+    private Long userId;
+
+    private Long applyTime;
+
+    private String applyStartTime;
+
+    private String applyEndTime;
+
+    private String major;
+
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/domain/ExamApply.java

@@ -63,6 +63,8 @@ private static final long serialVersionUID=1L;
     private Integer applyNature;
     /** 专场学员资料地址 */
     private String natureUrl;
+    /** 关联code(公用祥粤考场) */
+    private String relCode;
 
     private Long tenantId;
 }

+ 16 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyMapper.java

@@ -3,10 +3,7 @@ package com.zhongzheng.modules.exam.mapper;
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.base.domain.UserProfile;
-import com.zhongzheng.modules.exam.bo.ExamApplyDetailBo;
-import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
-import com.zhongzheng.modules.exam.bo.ExamApplyRoomQueryBo;
-import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
+import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.vo.*;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
@@ -97,4 +94,19 @@ public interface ExamApplyMapper extends BaseMapper<ExamApply> {
 
     @InterceptorIgnore(tenantLine = "true")
     ExamApply getEntityById(Long applyId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    String getExamRelCodeNotTenant(@Param("applyName") String applyName);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserStudyRecordExport> getUserStudyRecordNoTenant(Long orderGoodsId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<String> getSevenMajorNames();
+
+    @InterceptorIgnore(tenantLine = "true")
+    UserSubscribe getSubscribeInfo(SubscribeInfoBo infoBo);
+
+    @InterceptorIgnore(tenantLine = "true")
+    UserSubscribe getExamPassSub(SubscribeInfoBo infoBo);
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java

@@ -8,6 +8,7 @@ import com.zhongzheng.modules.exam.vo.*;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.user.vo.UserStudyRecordExport;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.Collection;
@@ -101,4 +102,12 @@ public interface IExamApplyService extends IService<ExamApply> {
     void updateExamUserProfile(MultipartFile file);
 
 	String examUserProfileExport(UserProfileQueryBo bo);
+
+    String getExamRelCodeNotTenant(String applyName);
+
+    List<UserStudyRecordExport> getUserStudyRecordNoTenant(Long orderGoodsId);
+
+    void examApplyResultReceipt(List<ExamApplyResultExportBo> exportBo, String time);
+
+    String examApplyResultCertificate(List<MultipartFile> files);
 }

+ 174 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -78,9 +78,12 @@ import javax.mail.internet.*;
 import javax.mail.util.ByteArrayDataSource;
 import java.awt.image.BufferedImage;
 import java.io.*;
+import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -631,6 +634,16 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         add.setCode(ServletUtils.getEncoded("KSAP"));
         add.setCreateTime(DateUtils.getNowTime());
         add.setUpdateTime(DateUtils.getNowTime());
+        add.setRelCode(ServletUtils.getEncoded("SHEX"));
+        //是否公用祥粤考场
+        String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+        SysTenant sysTenant = sysTenantService.getById(Long.valueOf(tenantId));
+        if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+            String code = baseMapper.getExamRelCodeNotTenant(add.getApplyName());
+            if (net.polyv.common.v1.util.StringUtils.isNotEmpty(code)){
+                add.setRelCode(code);
+            }
+        }
         this.save(add);
         if (CollectionUtils.isNotEmpty(bo.getApplyUsers())) {
             //专场预约学员
@@ -1219,6 +1232,167 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         return content;
     }
 
+    @Override
+    public String getExamRelCodeNotTenant(String applyName) {
+        return baseMapper.getExamRelCodeNotTenant(applyName);
+    }
+
+    @Override
+    public List<UserStudyRecordExport> getUserStudyRecordNoTenant(Long orderGoodsId) {
+        return baseMapper.getUserStudyRecordNoTenant(orderGoodsId);
+    }
+
+    @Override
+    public void examApplyResultReceipt(List<ExamApplyResultExportBo> exportBo, String time) {
+        if (CollectionUtils.isEmpty(exportBo)){
+            return;
+        }
+        //考试时间
+        List<String> collect = Arrays.stream(time.split(" ")).collect(Collectors.toList());
+        SubscribeInfoBo infoBo = new SubscribeInfoBo();
+        infoBo.setApplyTime(DateUtils.dateTimeSec("yyyy-MM-dd",collect.get(0)));
+        infoBo.setApplyStartTime(getTimeStr(collect.get(1)));
+        infoBo.setApplyEndTime(getTimeStr(collect.get(3)));
+        //补充学员成绩
+        exportBo.forEach(bo -> {
+            //查询学员信息
+            User user = iUserService.getByCardNoTenant(bo.getIdCard());
+            if (ObjectUtils.isNull(user)){
+                log.error("学员信息查询不到:"+bo.getUserName());
+                return;
+            }
+            //预约考试信息
+            //匹配系统七大员报考岗位
+            String majorName = getMajorName(bo.getMajorName());
+            infoBo.setMajor(majorName);
+            infoBo.setUserId(user.getUserId());
+            UserSubscribe subscribe = baseMapper.getSubscribeInfo(infoBo);
+            if (ObjectUtils.isNull(subscribe)){
+                return;
+            }
+            switch (bo.getApplyStatus()){
+                case "正常":
+                    //补充考试成绩
+                    BigDecimal bigDecimal = new BigDecimal(bo.getScore());
+                    subscribe.setExamStatus(1);
+                    subscribe.setPerformance(bigDecimal.longValue());
+                    if (bigDecimal.compareTo(new BigDecimal("60.00")) >= 0){
+                        subscribe.setResult(1);
+                    }else {
+                        subscribe.setResult(0);
+                    }
+                    break;
+                case "缺考":
+                    //补充考试成绩
+                    BigDecimal bigDecimal2 = new BigDecimal(bo.getScore());
+                    subscribe.setExamStatus(2);
+                    subscribe.setPerformance(bigDecimal2.longValue());
+                    subscribe.setResult(0);
+                    break;
+                case "作弊":
+                    //补充考试成绩
+                    BigDecimal bigDecimal3 = new BigDecimal(bo.getScore());
+                    subscribe.setExamStatus(3);
+                    subscribe.setPerformance(bigDecimal3.longValue());
+                    subscribe.setResult(0);
+                    break;
+                    default :
+                        break;
+            }
+
+            iUserSubscribeService.updateByIdNoTenant(subscribe);
+        });
+    }
+
+    @Override
+    public String examApplyResultCertificate(List<MultipartFile> files) {
+        if (CollectionUtils.isEmpty(files)){
+            return "请勿上传空文件!";
+        }
+        List<String> msgList = new ArrayList<>();
+        files.forEach(multipartFile -> {
+            //文件名= 身份证号码_岗位名称_证书编号_发证日期
+            String fileName = multipartFile.getOriginalFilename();
+            List<String> collect = Arrays.stream(fileName.split("_")).collect(Collectors.toList());
+            //查询学员信息
+            User user = iUserService.getByCardNoTenant(collect.get(0));
+            if (ObjectUtils.isNull(user)){
+                log.error("学员信息查询不到:"+collect.get(0));
+                msgList.add(multipartFile.getOriginalFilename());
+                return;
+            }
+            SubscribeInfoBo infoBo = new SubscribeInfoBo();
+            infoBo.setMajor(collect.get(1));
+            infoBo.setUserId(user.getUserId());
+            UserSubscribe subscribe = baseMapper.getExamPassSub(infoBo);
+            if (ObjectUtils.isNull(subscribe)){
+                msgList.add(multipartFile.getOriginalFilename());
+                return;
+            }
+            subscribe.setCertificateCode(collect.get(2));
+            Long time = DateUtils.dateTimeSec("yyyy-MM-dd",collect.get(3));
+            subscribe.setCertificateStartTime(time);
+            //有效期为一年
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(DateUtils.timeToDate(time));
+            // 将年份加一
+            calendar.add(Calendar.YEAR, 1);
+            Long timeTwo = calendar.getTime().getTime()/1000;
+            subscribe.setCertificateEndTime(timeTwo);
+
+            //上传证书
+            OssRequest ossRequest = new OssRequest();
+            ossRequest.setGradeId(0L);
+            ossRequest.setUserId(0L);
+            ossRequest.setImageStatus(7);
+            ossRequest.setFile(multipartFile);
+            try {
+                String upload = ossService.upload(ossRequest);
+                subscribe.setCertificateUrl(upload);
+            } catch (Exception e) {
+//                log.error("证书上传有误:"+collect.get(0));
+                msgList.add(multipartFile.getOriginalFilename());
+                e.printStackTrace();
+            }
+            iUserSubscribeService.updateByIdNoTenant(subscribe);
+        });
+        return msgList.stream().collect(Collectors.joining(","));
+    }
+
+    private String getMajorName(String majorName) {
+        //祥粤学习 七大员报考岗位名称
+        List<String> names = baseMapper.getSevenMajorNames();
+        if (CollectionUtils.isEmpty(names)){
+            return "";
+        }
+        List<String> collect = names.stream().sorted(Comparator.comparing(x -> {
+            Integer count = 0;
+            for (int i = 0; i < majorName.length(); i++) {
+                char c = majorName.charAt(i);
+                if (x.contains(Character.toString(c))) {
+                    count++;
+                }
+            }
+            return count;
+        })).collect(Collectors.toList());
+
+        return collect.get(collect.size() - 1);
+    }
+
+    private String getTimeStr(String str){
+        String format = "";
+        SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss");
+        SimpleDateFormat sf2 = new SimpleDateFormat("HH:mm");
+        try {
+            Date parse = sf.parse(str);
+            format = sf2.format(parse);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return format;
+    }
+
+
     //生成承诺书
     private void generateCommitment(String keyValue,String toPath,String idCard,String major)throws IOException {
         int imgIndex=(int)(Math.random() * 10 );

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsAddBo.java

@@ -202,4 +202,13 @@ public class GoodsAddBo {
     private String sevenYear;
     @ApiModelProperty("商品试卷限制终端学习,多个,拼接  1公众号 2小程序")
     private String examLimitClient;
+    /** 是否优选  0没有 1选中 */
+    @ApiModelProperty("是否优选  0没有 1选中")
+    private Integer firstChoiceStatus;
+    /** 优选至少学习学时 */
+    @ApiModelProperty("优选至少学习学时")
+    private Long minClassHour;
+    /** 优选生成商品 0否 1是 */
+    @ApiModelProperty("优选生成商品 0否 1是")
+    private Long firstChoiceGoods;
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsEditBo.java

@@ -236,4 +236,13 @@ public class GoodsEditBo {
     private String sevenYear;
     @ApiModelProperty("商品试卷限制终端学习,多个,拼接  1公众号 2小程序")
     private String examLimitClient;
+    /** 是否优选  0没有 1选中 */
+    @ApiModelProperty("是否优选  0没有 1选中")
+    private Integer firstChoiceStatus;
+    /** 优选至少学习学时 */
+    @ApiModelProperty("优选至少学习学时")
+    private Long minClassHour;
+    /** 优选生成商品 0否 1是 */
+    @ApiModelProperty("优选生成商品 0否 1是")
+    private Long firstChoiceGoods;
 }

+ 38 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/GoodsFirstChoiceAddBo.java

@@ -0,0 +1,38 @@
+package com.zhongzheng.modules.goods.bo;
+
+import com.zhongzheng.modules.course.bo.CourseMenuAddBo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 商品添加对象 goods
+ *
+ * @author hjl
+ * @date 2021-10-12
+ */
+@Data
+@ApiModel("商品添加对象")
+public class GoodsFirstChoiceAddBo {
+
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
+    @ApiModelProperty("订单商品ID")
+    private Long orderGoodsId;
+
+    @ApiModelProperty("商品ID")
+    private Long goodsId;
+
+    @ApiModelProperty("课程ID")
+    private Long courseId;
+
+    @ApiModelProperty("班级ID")
+    private Long gradeId;
+
+    @ApiModelProperty("章列表ID")
+    private List<Long> chapterIdList;
+}

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/Goods.java

@@ -170,4 +170,10 @@ private static final long serialVersionUID=1L;
     private String sevenYear;
     /** 补考商品统一标识 */
     private Integer unifySign;
+    /** 是否优选  0没有 1选中 */
+    private Integer firstChoiceStatus;
+    /** 优选至少学习学时 */
+    private Long minClassHour;
+    /** 优选生成商品 0否 1是 */
+    private Long firstChoiceGoods;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsCourse.java

@@ -38,4 +38,5 @@ private static final long serialVersionUID=1L;
     /** 别名 */
     private String aliasName;
     private Long tenantId;
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -164,4 +164,6 @@ public interface IGoodsService extends IService<Goods> {
 	List<Goods> getRelevanceGoodsNoTenant(String businessName,String majName,Long goodsId);
 
 	List<Goods> getRelGoodsNoTenant(String businessName, String categoryName, Long tenantId);
+
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -5489,6 +5489,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         return baseMapper.getRelGoodsNoTenant(businessName, categoryName, tenantId);
     }
 
+
+
     private void updateHandoutsId(Long goodsId, Long tenantId, Long handoutsId) {
         baseMapper.updateHandoutsId(goodsId, tenantId, handoutsId);
     }

+ 14 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsVo.java

@@ -376,4 +376,18 @@ public class GoodsVo {
 	private Boolean jjShiGongYuan;
 	@ApiModelProperty("补考商品统一标识:1统一")
 	private Integer unifySign;
+	/** 是否优选  0没有 1选中 */
+	@Excel(name = "是否优选  0没有 1选中")
+	@ApiModelProperty("是否优选  0没有 1选中")
+	private Integer firstChoiceStatus;
+	/** 优选至少学习学时 */
+	@Excel(name = "优选至少学习学时")
+	@ApiModelProperty("优选至少学习学时")
+	private Long minClassHour;
+	/** 优选生成商品 0否 1是 */
+	@Excel(name = "优选生成商品 0否 1是")
+	@ApiModelProperty("优选生成商品 0否 1是")
+	private Long firstChoiceGoods;
+	@ApiModelProperty("业务别名")
+	private String aliasName;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/ClassGradeUserQueryBo.java

@@ -299,6 +299,9 @@ public class ClassGradeUserQueryBo extends BaseEntity {
 	@ApiModelProperty("七大员继教班级关联code")
 	private String sevenCode;
 
+	@ApiModelProperty("七大员继教班级关联code标签:1 是 0否")
+	private Integer sevenCodeSign;
+
 	private List<WeekDataVo> weekList;
 
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/domain/ClassGrade.java

@@ -93,4 +93,6 @@ private static final long serialVersionUID=1L;
 
     /** 企业ID */
     private Long tenantId;
+
+    private Long firstChoiceGrade;
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeGoodsMapper.java

@@ -24,4 +24,7 @@ public interface ClassGradeGoodsMapper extends BaseMapper<ClassGradeGoods> {
 
     @InterceptorIgnore(tenantLine = "true")
     ClassGradeGoods getOneNoTenant(@Param("gradeId") Long gradeId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<ClassGradeGoods> listByIdNoTenant(Long gradeId);
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeMapper.java

@@ -98,7 +98,7 @@ public interface ClassGradeMapper extends BaseMapper<ClassGrade> {
     List<String> getSevenYearByCode(String sevenCode);
 
     @InterceptorIgnore(tenantLine = "true")
-    List<ClassGrade> listByIdsNoTenant(List<Long> ids);
+    List<ClassGrade> listByIdsNoTenant(@Param("ids") List<Long> ids);
 
     @InterceptorIgnore(tenantLine = "true")
     List<ClassGrade> getListNoTenant(@Param("sevenCode") String sevenCode,@Param("gradeId") Long gradeId);

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/ClassGradeUserMapper.java

@@ -62,6 +62,8 @@ public interface ClassGradeUserMapper extends BaseMapper<ClassGradeUser> {
 
     List<Long> selectStart(@Param("userId") Long userId,@Param("goodsId") Long goodsId,@Param("gradeId") Long gradeId,@Param("orderGoodsId") Long orderGoodsId);
 
+    Long selectStartNoPhoto(@Param("userId") Long userId,@Param("goodsId") Long goodsId,@Param("gradeId") Long gradeId,@Param("orderGoodsId") Long orderGoodsId);
+
     List<Long> selectEnd(@Param("userId") Long userId,@Param("goodsId") Long goodsId,@Param("gradeId") Long gradeId);
 
     List<ClassGradeUserGoodsVo> sendClassGradeUser();

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IClassGradeGoodsService.java

@@ -57,4 +57,6 @@ public interface IClassGradeGoodsService extends IService<ClassGradeGoods> {
     List<ClassGradeGoods> getClassNoTenant(List<Long> collect);
 
     ClassGradeGoods getOneNoTenant(Long gradeId);
+
+    List<ClassGradeGoods> listByIdNoTenant(Long gradeId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeGoodsServiceImpl.java

@@ -117,4 +117,9 @@ public class ClassGradeGoodsServiceImpl extends ServiceImpl<ClassGradeGoodsMappe
     public ClassGradeGoods getOneNoTenant(Long gradeId) {
         return baseMapper.getOneNoTenant(gradeId);
     }
+
+    @Override
+    public List<ClassGradeGoods> listByIdNoTenant(Long gradeId) {
+        return baseMapper.listByIdNoTenant(gradeId);
+    }
 }

+ 204 - 199
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java

@@ -121,6 +121,8 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
     @Autowired
     private IUserUpdateService iUserUpdateService;
+    @Autowired
+    private ISysTenantService iSysTenantService;
 
     @Autowired
     private IInformRemindService informRemindService;
@@ -266,7 +268,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
         //企业ID
         String tenant = ServletUtils.getRequest().getHeader("TenantId");
-//        SysTenant sysTenant = sysTenantService.getById(Long.valueOf(tenant));
+        SysTenant sysTenant = sysTenantService.getById(Long.valueOf(tenant));
         SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
                 .eq(SysOldOrg::getTenantId, tenant)
                 .last("limit 1")).stream().findFirst().orElse(null);
@@ -313,111 +315,111 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 String sevenCode = getSevenCode(goodsId);
                 add.setSevenCode(sevenCode);
             }
-//            else if (("继续教育二级建造师".equals(businessName)) || ("继续教育二级造价师".equals(businessName))){
-//                erJfalg = true;
-//                ezJfalg = "继续教育二级造价师".equals(businessName);
-//                add.setOfficialName(ServletUtils.getEncoded("PIY"));
-//            }
-        }
-        //是否创建官方班级编号
-        if (bo.getClassGradeGoodsAddBos() != null &&
-                (ObjectUtils.isNull(bo.getClassStatus()) || 0 == bo.getClassStatus()) && org.getShareClass() == 1) {
-            Long goodsId = bo.getClassGradeGoodsAddBos()[0];
-            Goods goods = iGoodsService.getById(goodsId);
-            CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
-            CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
-            businessQueryBo.setId(goods.getBusinessId());
-            String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
-            if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
-                List<Goods> goodsList = iGoodsService.list(new LambdaQueryWrapper<Goods>()
-                        .eq(Goods::getEducationTypeId, goods.getEducationTypeId())
-                        .eq(Goods::getBusinessId, goods.getBusinessId())
-                        .eq(Goods::getStatus, 1)
-                        .eq(Goods::getGoodsStatus, 1)
-                        .eq(Goods::getProjectId, goods.getProjectId())
-                        .eq(Goods::getSubjectIds, goods.getSubjectIds()));
-                if (goodsList.size() > 1) {
-                    //该业务层次下有多个商品
-                    List<Long> goodsIds = goodsList.stream().filter(item -> !item.getGoodsId().equals(goodsId)).map(Goods::getGoodsId).collect(Collectors.toList());
-                    List<ClassGradeGoods> goodsGradeList = iClassGradeGoodsService
-                            .list(new LambdaQueryWrapper<ClassGradeGoods>()
-                                    .in(ClassGradeGoods::getGoodsId, goodsIds));
-                    if (CollectionUtils.isNotEmpty(goodsGradeList)) {
-                        Map<Long, List<ClassGradeGoods>> map = goodsGradeList.stream().collect(Collectors.groupingBy(ClassGradeGoods::getGoodsId));
-                        List<ClassGradeSortBo> sortList = new ArrayList<>();
-                        map.forEach((k, v) -> {
-                            ClassGradeSortBo sortBo = new ClassGradeSortBo();
-                            sortBo.setKey(k);
-                            sortBo.setSize(v.size());
-                            sortList.add(sortBo);
-                        });
-                        ClassGradeSortBo sortBo = sortList.stream().sorted(Comparator.comparing(ClassGradeSortBo::getSize).reversed()).findFirst().orElse(null);
-                        List<ClassGradeGoods> classGradesMax = map.get(sortBo.getKey()).stream().sorted(Comparator.comparing(ClassGradeGoods::getCreateTime)).collect(Collectors.toList());
-                        //班级信息
-                        List<ClassGrade> listGrade = listByIds(classGradesMax.stream().map(ClassGradeGoods::getGradeId).collect(Collectors.toList()));
-                        //获取当前机构商品下的班级
-                        List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goods.getGoodsId());
-                        if (gradeGoods.size() < listGrade.size()) {
-                            ClassGrade grade = listGrade.get(gradeGoods.size());
-                            if (checkEjjjPeopleNumLimit(business.getId(), grade.getGradeId())) {
-                                add.setOfficialName(listGrade.get(gradeGoods.size()).getOfficialName());
-                                add.setClassStatus(0);
-                            } else {
-                                add.setOfficialName(ServletUtils.getEncoded("PIY"));
-                                add.setClassStatus(0);
-                            }
-                        }
-                    }
-                }
-
-                if (StringUtils.isBlank(add.getOfficialName())) {
-                    List<CourseSubject> courseSubjectList = iCourseSubjectService.listByIds(Arrays.asList(goods.getSubjectIds().split(",")));
-                    List<String> subNames = courseSubjectList.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
-                    List<Long> subIds = iCourseSubjectService.getIdsByTenant(subNames);
-                    //获取业务层次下所有班级
-                    ClassGradeListBo bgListBo = new ClassGradeListBo();
-                    bgListBo.setAliasName(business.getAliasName());
-                    bgListBo.setSubIds(subIds);
-                    List<ClassGrade> classGrades = baseMapper.getGradeListByTenant(bgListBo);
-                    if (CollectionUtils.isEmpty(classGrades)) {
-                        //生成预报名官方编号
-                        add.setOfficialName(ServletUtils.getEncoded("PIY"));
-                        add.setClassStatus(0);
-                    } else {
-                        //获取班级创建最多的机构
-                        Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
-                        List<ClassGradeSortBo> sortList = new ArrayList<>();
-                        map.forEach((k, v) -> {
-                            ClassGradeSortBo sortBo = new ClassGradeSortBo();
-                            sortBo.setKey(k);
-                            Map<String, List<ClassGrade>> collect = v.stream().collect(Collectors.groupingBy(ClassGrade::getOfficialName));
-                            sortBo.setSize(collect.keySet().size());
-                            sortList.add(sortBo);
-                        });
-                        ClassGradeSortBo sortBo = sortList.stream().sorted(Comparator.comparing(ClassGradeSortBo::getSize).reversed()).findFirst().orElse(null);
-                        List<ClassGrade> classGradesMax = map.get(sortBo.getKey()).stream().sorted(Comparator.comparing(ClassGrade::getCreateTime)).collect(Collectors.toList());
-                        //去重
-                        List<String> codeStrs = new ArrayList<>();
-                        for (ClassGrade gradesMax : classGradesMax) {
-                            if (codeStrs.contains(gradesMax.getOfficialName())) {
-                                continue;
-                            }
-                            codeStrs.add(gradesMax.getOfficialName());
-                        }
-                        //获取当前机构商品下的班级
-                        List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goodsId);
-                        if (gradeGoods.size() < codeStrs.size()) {
-                            add.setOfficialName(codeStrs.get(gradeGoods.size()));
-                            add.setClassStatus(0);
-                        } else {
-                            //生成预报名官方编号
-                            add.setOfficialName(ServletUtils.getEncoded("PIY"));
-                            add.setClassStatus(0);
-                        }
-                    }
-                }
+            else if (("继续教育二级建造师".equals(businessName)) || ("继续教育二级造价师".equals(businessName))){
+                erJfalg = true;
+                ezJfalg = "继续教育二级造价师".equals(businessName);
+                add.setOfficialName(ServletUtils.getEncoded("PIY"));
             }
         }
+        //是否创建官方班级编号
+//        if (bo.getClassGradeGoodsAddBos() != null &&
+//                (ObjectUtils.isNull(bo.getClassStatus()) || 0 == bo.getClassStatus()) && org.getShareClass() == 1) {
+//            Long goodsId = bo.getClassGradeGoodsAddBos()[0];
+//            Goods goods = iGoodsService.getById(goodsId);
+//            CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
+//            CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
+//            businessQueryBo.setId(goods.getBusinessId());
+//            String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
+//            if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+//                List<Goods> goodsList = iGoodsService.list(new LambdaQueryWrapper<Goods>()
+//                        .eq(Goods::getEducationTypeId, goods.getEducationTypeId())
+//                        .eq(Goods::getBusinessId, goods.getBusinessId())
+//                        .eq(Goods::getStatus, 1)
+//                        .eq(Goods::getGoodsStatus, 1)
+//                        .eq(Goods::getProjectId, goods.getProjectId())
+//                        .eq(Goods::getSubjectIds, goods.getSubjectIds()));
+//                if (goodsList.size() > 1) {
+//                    //该业务层次下有多个商品
+//                    List<Long> goodsIds = goodsList.stream().filter(item -> !item.getGoodsId().equals(goodsId)).map(Goods::getGoodsId).collect(Collectors.toList());
+//                    List<ClassGradeGoods> goodsGradeList = iClassGradeGoodsService
+//                            .list(new LambdaQueryWrapper<ClassGradeGoods>()
+//                                    .in(ClassGradeGoods::getGoodsId, goodsIds));
+//                    if (CollectionUtils.isNotEmpty(goodsGradeList)) {
+//                        Map<Long, List<ClassGradeGoods>> map = goodsGradeList.stream().collect(Collectors.groupingBy(ClassGradeGoods::getGoodsId));
+//                        List<ClassGradeSortBo> sortList = new ArrayList<>();
+//                        map.forEach((k, v) -> {
+//                            ClassGradeSortBo sortBo = new ClassGradeSortBo();
+//                            sortBo.setKey(k);
+//                            sortBo.setSize(v.size());
+//                            sortList.add(sortBo);
+//                        });
+//                        ClassGradeSortBo sortBo = sortList.stream().sorted(Comparator.comparing(ClassGradeSortBo::getSize).reversed()).findFirst().orElse(null);
+//                        List<ClassGradeGoods> classGradesMax = map.get(sortBo.getKey()).stream().sorted(Comparator.comparing(ClassGradeGoods::getCreateTime)).collect(Collectors.toList());
+//                        //班级信息
+//                        List<ClassGrade> listGrade = listByIds(classGradesMax.stream().map(ClassGradeGoods::getGradeId).collect(Collectors.toList()));
+//                        //获取当前机构商品下的班级
+//                        List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goods.getGoodsId());
+//                        if (gradeGoods.size() < listGrade.size()) {
+//                            ClassGrade grade = listGrade.get(gradeGoods.size());
+//                            if (checkEjjjPeopleNumLimit(business.getId(), grade.getGradeId())) {
+//                                add.setOfficialName(listGrade.get(gradeGoods.size()).getOfficialName());
+//                                add.setClassStatus(0);
+//                            } else {
+//                                add.setOfficialName(ServletUtils.getEncoded("PIY"));
+//                                add.setClassStatus(0);
+//                            }
+//                        }
+//                    }
+//                }
+//
+//                if (StringUtils.isBlank(add.getOfficialName())) {
+//                    List<CourseSubject> courseSubjectList = iCourseSubjectService.listByIds(Arrays.asList(goods.getSubjectIds().split(",")));
+//                    List<String> subNames = courseSubjectList.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
+//                    List<Long> subIds = iCourseSubjectService.getIdsByTenant(subNames);
+//                    //获取业务层次下所有班级
+//                    ClassGradeListBo bgListBo = new ClassGradeListBo();
+//                    bgListBo.setAliasName(business.getAliasName());
+//                    bgListBo.setSubIds(subIds);
+//                    List<ClassGrade> classGrades = baseMapper.getGradeListByTenant(bgListBo);
+//                    if (CollectionUtils.isEmpty(classGrades)) {
+//                        //生成预报名官方编号
+//                        add.setOfficialName(ServletUtils.getEncoded("PIY"));
+//                        add.setClassStatus(0);
+//                    } else {
+//                        //获取班级创建最多的机构
+//                        Map<Long, List<ClassGrade>> map = classGrades.stream().collect(Collectors.groupingBy(ClassGrade::getTenantId));
+//                        List<ClassGradeSortBo> sortList = new ArrayList<>();
+//                        map.forEach((k, v) -> {
+//                            ClassGradeSortBo sortBo = new ClassGradeSortBo();
+//                            sortBo.setKey(k);
+//                            Map<String, List<ClassGrade>> collect = v.stream().collect(Collectors.groupingBy(ClassGrade::getOfficialName));
+//                            sortBo.setSize(collect.keySet().size());
+//                            sortList.add(sortBo);
+//                        });
+//                        ClassGradeSortBo sortBo = sortList.stream().sorted(Comparator.comparing(ClassGradeSortBo::getSize).reversed()).findFirst().orElse(null);
+//                        List<ClassGrade> classGradesMax = map.get(sortBo.getKey()).stream().sorted(Comparator.comparing(ClassGrade::getCreateTime)).collect(Collectors.toList());
+//                        //去重
+//                        List<String> codeStrs = new ArrayList<>();
+//                        for (ClassGrade gradesMax : classGradesMax) {
+//                            if (codeStrs.contains(gradesMax.getOfficialName())) {
+//                                continue;
+//                            }
+//                            codeStrs.add(gradesMax.getOfficialName());
+//                        }
+//                        //获取当前机构商品下的班级
+//                        List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goodsId);
+//                        if (gradeGoods.size() < codeStrs.size()) {
+//                            add.setOfficialName(codeStrs.get(gradeGoods.size()));
+//                            add.setClassStatus(0);
+//                        } else {
+//                            //生成预报名官方编号
+//                            add.setOfficialName(ServletUtils.getEncoded("PIY"));
+//                            add.setClassStatus(0);
+//                        }
+//                    }
+//                }
+//            }
+//        }
         boolean save = this.save(add);
 
         //添加班级商品
@@ -445,42 +447,42 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             classGradeSysService.save(classGradeSys);
         }
 
-//        if (erJfalg && bo.getClassGradeGoodsAddBos() != null){
-//            //二建继教班级创建,所有共享班级机构同步创建
-//            synchronousCreation(add,sysTenant,bo.getClassGradeGoodsAddBos()[0]);
-//            //通知旧系统
-//            CreateSameClassBo classBo = new CreateSameClassBo();
-//            if (ObjectUtils.isNotNull(bo.getClassStatus()) && bo.getClassStatus() == 1){
-//                classBo.setClassNo(add.getOfficialName());
-//                classBo.setOpenclassState(1);
-//                classBo.setBeginTime(DateUtils.timestampToDateFormat(add.getClassStartTime(),"yyyy-MM-dd HH:mm:ss"));
-//                classBo.setEndTime(DateUtils.timestampToDateFormat(add.getClassEndTime(),"yyyy-MM-dd HH:mm:ss"));
-//            }else {
-//                classBo.setClassNo(add.getOfficialName());
-//                classBo.setOpenclassState(0);
-//            }
-//            classBo.setCategoryName(add.getClassName());
-//            classBo.setPlatformId(ezJfalg?8:5);
-//            Goods goods = iGoodsService.getById(bo.getClassGradeGoodsAddBos()[0]);
-//            Major major = iMajorService.getById(goods.getMajorId());
-//            if (ObjectUtils.isNotNull(major)){
-//                classBo.setMajorName(major.getCategoryName());
-//            }
-//            Long nowTime = DateUtils.getNowTime();
-//            String sign = ToolsUtils.EncoderByMd5(classBo.getClassNo()+nowTime.toString() + "pubilc2022");
-//            classBo.setSign(sign);
-//            classBo.setStamp(nowTime);
-//            JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(classBo));
-//            String respone = "";
-//            try {
-//                respone = HttpUtils.sendPost(CREATE_EXAM_PATH, param);
-//                if (!respone.contains("\"Status\":true")) {
-//                    throw new CustomException("旧系统创建班级错误" + respone);
-//                }
-//            } catch (Exception e) {
-//                throw new CustomException("旧系统创建班级错误" + e.getMessage());
-//            }
-//        }
+        if (erJfalg && bo.getClassGradeGoodsAddBos() != null){
+            //二建继教班级创建,所有共享班级机构同步创建
+            synchronousCreation(add,sysTenant,bo.getClassGradeGoodsAddBos()[0]);
+            //通知旧系统
+            CreateSameClassBo classBo = new CreateSameClassBo();
+            if (ObjectUtils.isNotNull(bo.getClassStatus()) && bo.getClassStatus() == 1){
+                classBo.setClassNo(add.getOfficialName());
+                classBo.setOpenclassState(1);
+                classBo.setBeginTime(DateUtils.timestampToDateFormat(add.getClassStartTime(),"yyyy-MM-dd HH:mm:ss"));
+                classBo.setEndTime(DateUtils.timestampToDateFormat(add.getClassEndTime(),"yyyy-MM-dd HH:mm:ss"));
+            }else {
+                classBo.setClassNo(add.getOfficialName());
+                classBo.setOpenclassState(0);
+            }
+            classBo.setCategoryName(add.getClassName());
+            classBo.setPlatformId(ezJfalg?8:5);
+            Goods goods = iGoodsService.getById(bo.getClassGradeGoodsAddBos()[0]);
+            Major major = iMajorService.getById(goods.getMajorId());
+            if (ObjectUtils.isNotNull(major)){
+                classBo.setMajorName(major.getCategoryName());
+            }
+            Long nowTime = DateUtils.getNowTime();
+            String sign = ToolsUtils.EncoderByMd5(classBo.getClassNo()+nowTime.toString() + "pubilc2022");
+            classBo.setSign(sign);
+            classBo.setStamp(nowTime);
+            JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(classBo));
+            String respone = "";
+            try {
+                respone = HttpUtils.sendPost(CREATE_EXAM_PATH, param);
+                if (!respone.contains("\"Status\":true")) {
+                    throw new CustomException("旧系统创建班级错误" + respone);
+                }
+            } catch (Exception e) {
+                throw new CustomException("旧系统创建班级错误" + e.getMessage());
+            }
+        }
 
         return save;
     }
@@ -491,7 +493,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
 
 
     private void synchronousCreation(ClassGrade classGrade, SysTenant sysTenant,Long goodsId) {
-        List<SysTenant> tenantList = sysTenantService.getListNoTenant(sysTenant.getTenantId());
+        List<SysTenant> tenantList = sysTenantService.getListNoTenant(0L);
         if (CollectionUtils.isEmpty(tenantList)){
             return;
         }
@@ -507,7 +509,12 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             //班级是否存在
             ClassGrade grade = baseMapper.getCodeNoTenant(classGrade.getOfficialName(),tenant.getTenantId());
             if (ObjectUtils.isNotNull(grade)){
-                //已经存在 不创建
+                //已经存在 过滤已经创建过班级的商品
+                List<ClassGradeGoods> classGradeGoods = iClassGradeGoodsService.listByIdNoTenant(grade.getGradeId());
+                List<Long> goodsIds = classGradeGoods.stream().map(ClassGradeGoods::getGoodsId).collect(Collectors.toList());
+                relGoods = relGoods.stream().filter(x -> !goodsIds.contains(x.getGoodsId())).collect(Collectors.toList());
+            }
+            if (CollectionUtils.isEmpty(relGoods)){
                 return;
             }
 
@@ -570,16 +577,14 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         String officialName = classGrade.getOfficialName();//预开班班级编号
         //企业ID
         String tenant = ServletUtils.getRequest().getHeader("TenantId");
-        SysOldOrg org = sysOldOrgService.list(new LambdaQueryWrapper<SysOldOrg>()
-                .eq(SysOldOrg::getTenantId, tenant)
-                .last("limit 1")).stream().findFirst().orElse(null);
+        SysTenant sysTenant = sysTenantService.getById(Long.valueOf(tenant));
 
         Goods goods = iGoodsService.getById(gradeGoods.getGoodsId());
         CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
         businessQueryBo.setId(goods.getBusinessId());
         String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
 
-        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName)))&& org.getShareClass() == 1) {
+        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName)))&& sysTenant.getShareClass() == 1) {
             if (update.getClassStatus() != null && update.getClassStatus().equals(1)) {
                 //二造和二建班级开班校验班级人数(300人)
                 if (!checkClassUserNum(goods.getBusinessId(), update.getGradeId())) {
@@ -637,7 +642,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                     throw new RuntimeException("班级还有学员,无法设置为无效");
                 }
             }
-            if (StringUtils.isNotBlank(oldGrade.getOfficialName()) && org.getShareClass() == 1) {
+            if (StringUtils.isNotBlank(oldGrade.getOfficialName()) && sysTenant.getShareClass() == 1) {
                 throw new RuntimeException("二建/二造班级无法设置为无效,请联系技术人员!");
             }
         }
@@ -702,25 +707,13 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         }
 
         ClassGrade grade = getById(update.getGradeId());
-        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && org.getShareClass() == 1) {
-            if (ObjectUtils.isNotNull(grade) && ObjectUtils.isNotNull(grade.getClassStatus())
-                    && StringUtils.isNotBlank(grade.getOfficialName()) && grade.getClassStatus() == 1) {
-//                List<ClassGrade> list = list(new LambdaQueryWrapper<ClassGrade>().eq(ClassGrade::getOfficialName, update.getRegisterCode()));
-//                if (CollectionUtils.isNotEmpty(list)){
-//                    update(new LambdaUpdateWrapper<ClassGrade>()
-//                            .set(ClassGrade::getOfficialName,update.getOfficialName())
-//                            .set(ClassGrade::getRegisterCode,update.getRegisterCode())
-//                            .set(ClassGrade::getClassStartTime,update.getClassStartTime())
-//                            .set(ClassGrade::getClassEndTime,update.getClassEndTime())
-//                            .set(ClassGrade::getClassStatus,update.getClassStatus())
-//                            .set(ClassGrade::getLearningStatus,update.getLearningStatus())
-//                            .set(ClassGrade::getInterfacePushId,update.getInterfacePushId())
-//                            .in(ClassGrade::getGradeId,list.stream().map(ClassGrade::getGradeId).collect(Collectors.toList())));
-//                }
+        if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && sysTenant.getShareClass() == 1) {
+            if (StringUtils.isNotBlank(grade.getOfficialName()) && grade.getClassStatus() == 1) {
 
                 ClassGradeOpenBo openBo = new ClassGradeOpenBo();
                 openBo.setOfficialName(grade.getOfficialName());
-                openBo.setRegisterCode(grade.getRegisterCode());
+//                openBo.setRegisterCode(grade.getRegisterCode());
+                openBo.setRegisterCode(officialName);
                 openBo.setClassName(grade.getClassName());
                 openBo.setClassStartTime(grade.getClassStartTime());
                 openBo.setClassEndTime(grade.getClassEndTime());
@@ -892,6 +885,12 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             if (Validator.isNotEmpty(classGradeStudentVo.getRebuyOrderGoodsId()) && classGradeStudentVo.getRebuyOrderGoodsId().longValue() > 0) {
                 classGradeStudentVo.setRebuy(orderMapper.getGradePeriod(classGradeStudentVo.getRebuyOrderGoodsId(), classGradeStudentVo.getUserId()));
             }
+            if (ObjectUtils.isNotNull(classGradeStudentVo.getOrgId())){
+                SysTenant tenant = iSysTenantService.getById(classGradeStudentVo.getOrgId());
+                if (ObjectUtils.isNotNull(tenant)){
+                    classGradeStudentVo.setTenantName(tenant.getTenantName());
+                }
+            }
         }
         return classGradeStudentVos;
     }
@@ -1658,50 +1657,56 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
                 return;
             }
             //班级是否存在
-            ClassGrade grade = baseMapper.getCodeNoTenant(bo.getRegisterCode(),tenant.getTenantId());
-            if (ObjectUtils.isNotNull(grade)){
-                //已经存在 不创建
-                return;
-            }
-            ClassGrade classGrade = new ClassGrade();
-            classGrade.setCreateTime(DateUtils.getNowTime());
-            if (bo.getClassStatus() == 1){
-                //开班
-                classGrade.setClassStatus(1);
-                classGrade.setOfficialName(bo.getOfficialName());
-                classGrade.setLearningStatus(1);
-                classGrade.setClassStartTime(bo.getClassStartTime());
-                classGrade.setClassEndTime(bo.getClassEndTime());
-                //二建/二造官方信息推送开关打开
-                List<ClassGradeInterface> interfaceList = iClassGradeInterfaceService
-                        .list(new LambdaQueryWrapper<ClassGradeInterface>()
-                                .eq(ClassGradeInterface::getType, 1).last("limit 1"));
-                if (CollectionUtils.isNotEmpty(interfaceList)) {
-                    classGrade.setInterfacePushId(interfaceList.get(0).getId());
+            if (StringUtils.isNotBlank(bo.getRegisterCode())){
+                ClassGrade grade = baseMapper.getCodeNoTenant(bo.getRegisterCode(),tenant.getTenantId());
+                if (ObjectUtils.isNotNull(grade)){
+                    //已经存在 过滤已经创建过班级的商品
+                    List<ClassGradeGoods> classGradeGoods = iClassGradeGoodsService.listByIdNoTenant(grade.getGradeId());
+                    List<Long> goodsIds = classGradeGoods.stream().map(ClassGradeGoods::getGoodsId).collect(Collectors.toList());
+                    relGoods = relGoods.stream().filter(x -> !goodsIds.contains(x.getGoodsId())).collect(Collectors.toList());
+                }
+                if (CollectionUtils.isEmpty(relGoods)){
+                    return;
                 }
-            }else {
-                classGrade.setClassStatus(0);
-                classGrade.setLearningStatus(2);//待定
             }
-            classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
-            classGrade.setUpdateTime(DateUtils.getNowTime());
-            classGrade.setStatus(1);
-            String gradeCode = ServletUtils.getEncoded("BJ");
-            classGrade.setGradeCode(gradeCode);
-            classGrade.setClassName(bo.getClassName());
-            classGrade.setTenantId(tenant.getTenantId());
-            classGrade.setRegisterCode(bo.getRegisterCode());
-            save(classGrade);
-            List<ClassGradeGoods> gradeGoods = relGoods.stream().map(item -> {
+            relGoods.forEach(item -> {
+                ClassGrade classGrade = new ClassGrade();
+                classGrade.setCreateTime(DateUtils.getNowTime());
+                if (bo.getClassStatus() == 1){
+                    //开班
+                    classGrade.setClassStatus(1);
+                    classGrade.setOfficialName(bo.getOfficialName());
+                    classGrade.setLearningStatus(1);
+                    classGrade.setClassStartTime(bo.getClassStartTime());
+                    classGrade.setClassEndTime(bo.getClassEndTime());
+                    //二建/二造官方信息推送开关打开
+                    List<ClassGradeInterface> interfaceList = iClassGradeInterfaceService
+                            .list(new LambdaQueryWrapper<ClassGradeInterface>()
+                                    .eq(ClassGradeInterface::getType, 1).last("limit 1"));
+                    if (CollectionUtils.isNotEmpty(interfaceList)) {
+                        classGrade.setInterfacePushId(interfaceList.get(0).getId());
+                    }
+                }else {
+                    classGrade.setClassStatus(0);
+                    classGrade.setLearningStatus(2);//待定
+                    classGrade.setOfficialName(bo.getRegisterCode());
+                }
+                classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
+                classGrade.setUpdateTime(DateUtils.getNowTime());
+                classGrade.setStatus(1);
+                String gradeCode = ServletUtils.getEncoded("BJ");
+                classGrade.setGradeCode(gradeCode);
+                classGrade.setClassName(bo.getClassName());
+                classGrade.setTenantId(tenant.getTenantId());
+                save(classGrade);
                 ClassGradeGoods classGradeGoods = new ClassGradeGoods();
                 classGradeGoods.setGradeId(classGrade.getGradeId());
                 classGradeGoods.setGoodsId(item.getGoodsId());
                 classGradeGoods.setCreateTime(DateUtils.getNowTime());
                 classGradeGoods.setUpdateTime(DateUtils.getNowTime());
                 classGradeGoods.setTenantId(tenant.getTenantId());
-                return classGradeGoods;
-            }).collect(Collectors.toList());
-            iClassGradeGoodsService.saveBatch(gradeGoods);
+                iClassGradeGoodsService.save(classGradeGoods);
+            });
         });
     }
 

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -436,6 +436,9 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         queryBo.setUserId(bo.getUserId());
         queryBo.setOrderGoodsId(bo.getOrderGoodsId());
         ClassPeriodStudentVo classPeriodStudentVo = baseMapper.userPeriodStatus(queryBo);
+        if(Validator.isEmpty(classPeriodStudentVo)){
+            throw new CustomException("数据非法");
+        }
         Long secLong = 0L;
         Long studyLong = 0L;
 
@@ -1780,6 +1783,9 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
             if (!CollectionUtils.isEmpty(baseMapper.selectStart(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId()))) {
                 //查找开始学习时间
                 classPeriodStudentVo.setStartTime(baseMapper.selectStart(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId()).get(0));
+            }else{
+                classPeriodStudentVo.setStartTime(baseMapper.selectStartNoPhoto(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId())
+                );
             }
             //当审核状态状态为通过是采取解析身份证和一寸照
             if ("1".equals(classPeriodStudentVo.getProfileStatus()) && Validator.isNotEmpty(bo.getUserPhoto()) && bo.getUserPhoto() == 1) {
@@ -1911,6 +1917,7 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
             classGradeUserQueryBo.setGradeId(classPeriodStudentVo.getGradeId());
             classGradeUserQueryBo.setUserId(classPeriodStudentVo.getUserId());
             classGradeUserQueryBo.setGoodsId(classPeriodStudentVo.getGoodsId());
+            classGradeUserQueryBo.setOrderGoodsId(classPeriodStudentVo.getOrderGoodsId());
             Long studyTime = baseMapper.listUserWeekStudyTime(classGradeUserQueryBo);
             classPeriodStudentVo.setStudyTime(studyTime);
             //    List<ClassPeriodUserVo> classPeriodUserVos1 = baseMapper.listPeriod(classGradeUserQueryBo);

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassGradeStudentVo.java

@@ -236,6 +236,12 @@ public class ClassGradeStudentVo {
 	@ApiModelProperty("官方信息推送结果")
 	private String officialStatusMsg;
 
+	@ApiModelProperty("机构ID")
+	private Long orgId;
+
+	@ApiModelProperty("所属机构")
+	private String tenantName;
+
 
 
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.order.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.course.vo.CourseLiveVo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
@@ -72,4 +73,7 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
     OrderGoods getSevenLastOne(@Param("projectId")Integer projectId,@Param("sevenYear")String sevenYear,@Param("userId")Long userId);
 
     Long countOrderGoodsByYear(@Param("sevenYear") String sevenYear,@Param("goodsId") Long goodsId,@Param("userId") Long userId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    OrderGoods getByIdNoTenant(Long orderGoodsId);
 }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.order.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.course.vo.CourseLiveVo;
 import com.zhongzheng.modules.goods.bo.CheckGoodsStatusBo;
+import com.zhongzheng.modules.goods.bo.GoodsFirstChoiceAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsSectionListBo;
 import com.zhongzheng.modules.goods.vo.GoodsSectionListVo;
@@ -124,4 +125,8 @@ public interface IOrderGoodsService extends IService<OrderGoods> {
     Long countOrderGoodsByYear(String sevenYear, Long goodsId, Long userId);
 
     String getOrderSevenYear(Long orderGoodsId);
+
+    GoodsFirstChoiceAddBo firstChoiceGoods(GoodsFirstChoiceAddBo bo);
+
+    OrderGoods getByIdNoTenant(Long orderGoodsId);
 }

+ 135 - 8
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -16,11 +16,15 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
+import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.domain.ShoppingCart;
 import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IShoppingCartService;
 import com.zhongzheng.modules.base.service.IUserProfileService;
+import com.zhongzheng.modules.course.domain.Course;
+import com.zhongzheng.modules.course.domain.CourseBusiness;
+import com.zhongzheng.modules.course.domain.CourseMenu;
 import com.zhongzheng.modules.course.mapper.CourseMapper;
 import com.zhongzheng.modules.course.mapper.CourseMenuMapper;
 import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
@@ -37,11 +41,9 @@ import com.zhongzheng.modules.exam.service.IExamApplySiteTimeService;
 import com.zhongzheng.modules.exam.service.IExamApplyUserService;
 import com.zhongzheng.modules.exam.service.IExamBeforeService;
 import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
-import com.zhongzheng.modules.goods.bo.CheckGoodsStatusBo;
-import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
-import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
-import com.zhongzheng.modules.goods.bo.GoodsSectionListBo;
+import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.domain.GoodsCourse;
 import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
 import com.zhongzheng.modules.goods.domain.QuestionMerchant;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
@@ -51,6 +53,8 @@ import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
 import com.zhongzheng.modules.goods.vo.GoodsSectionListVo;
 import com.zhongzheng.modules.goods.vo.GoodsSectionNumVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.grade.bo.ClassGradeGoodsAddBo;
+import com.zhongzheng.modules.grade.domain.ClassGrade;
 import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
@@ -77,11 +81,10 @@ import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.domain.UserExamGoods;
+import com.zhongzheng.modules.user.domain.UserExamGoodsSupplement;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
-import com.zhongzheng.modules.user.service.IUserExamGoodsService;
-import com.zhongzheng.modules.user.service.IUserService;
-import com.zhongzheng.modules.user.service.IUserStudyRecordService;
-import com.zhongzheng.modules.user.service.IUserSubscribeService;
+import com.zhongzheng.modules.user.service.*;
 import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
 import net.polyv.common.v1.util.StringUtils;
 import net.polyv.live.v1.entity.channel.operate.LiveChannelBasicInfoResponse;
@@ -114,6 +117,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     @Autowired
     private IClassGradeService iClassGradeService;
 
+
     @Autowired
     private IOrderService iOrderService;
 
@@ -179,6 +183,10 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     @Autowired
     private IQuestionMerchantService iQuestionMerchantService;
 
+    @Autowired
+    private IUserExamGoodsSupplementService iUserExamGoodsSupplementService;
+
+
     @Override
     public OrderGoodsVo queryById(Long orderGoodsId) {
         OrderGoods db = this.baseMapper.selectById(orderGoodsId);
@@ -848,6 +856,11 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         return orderGoods.getSevenYear();
     }
 
+    @Override
+    public OrderGoods getByIdNoTenant(Long orderGoodsId) {
+        return baseMapper.getByIdNoTenant(orderGoodsId);
+    }
+
     private boolean checkUnique(Long GoodsId,Long UserId) {
         ShoppingCart info = iShoppingCartService.getOne(new LambdaQueryWrapper<ShoppingCart>()
                 .eq(ShoppingCart::getUserId,UserId).eq(ShoppingCart::getGoodsId,GoodsId).last("limit 1"));
@@ -921,4 +934,118 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
 
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public GoodsFirstChoiceAddBo firstChoiceGoods(GoodsFirstChoiceAddBo bo) {
+        if(Validator.isEmpty(bo.getGradeId())||Validator.isEmpty(bo.getGoodsId())||Validator.isEmpty(bo.getOrderGoodsId())||Validator.isEmpty(bo.getCourseId())){
+            throw new CustomException("参数错误");
+        }
+        Goods goodsOld = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
+                .eq(Goods::getGoodsId, bo.getGoodsId()));
+        if(Validator.isEmpty(goodsOld)){
+            throw new CustomException("数据错误");
+        }
+        if(Validator.isEmpty(goodsOld.getFirstChoiceStatus())||goodsOld.getFirstChoiceStatus()!=1){
+            throw new CustomException("非法商品操作");
+        }
+        OrderGoods orderGoods = getOne(new LambdaQueryWrapper<OrderGoods>()
+                .eq(OrderGoods::getOrderGoodsId, bo.getOrderGoodsId()));
+        if(Validator.isEmpty(orderGoods)||orderGoods.getGoodsId().longValue()!=bo.getGoodsId().longValue()||orderGoods.getGradeId().longValue()!=bo.getGradeId().longValue()){
+            throw new CustomException("订单商品数据错误");
+        }
+        ClassGrade gradeOld = iClassGradeService.getOne(new LambdaQueryWrapper<ClassGrade>()
+                .eq(ClassGrade::getGradeId, bo.getGradeId()));
+      /*  ClassGrade gradeNew = BeanUtil.toBean(gradeOld, ClassGrade.class);
+        gradeNew.setGradeId(null);
+        gradeNew.setFirstChoiceGrade(gradeOld.getGradeId());
+        gradeNew.setCreateTime(DateUtils.getNowTime());
+        gradeNew.setUpdateTime(DateUtils.getNowTime());
+        gradeNew.setGradeCode(ServletUtils.getEncoded("BJ"));
+        gradeNew.setClassName(gradeNew.getClassName()+"(优选)");
+        iClassGradeService.save(gradeNew);*/
+
+
+
+        Course courseOld =courseMapper.selectOne(new LambdaQueryWrapper<Course>()
+                .eq(Course::getCourseId, bo.getCourseId()));
+        Course courseNew = BeanUtil.toBean(courseOld, Course.class);
+        courseNew.setCourseId(null);
+        courseNew.setFirstChoice(1);
+        courseNew.setCreateTime(DateUtils.getNowTime());
+        courseNew.setUpdateTime(DateUtils.getNowTime());
+        courseNew.setCode(ServletUtils.getEncoded("KC"));
+        courseNew.setCourseName(courseNew.getCourseName()+"(优选)");
+        courseMapper.insert(courseNew);
+
+        LambdaQueryWrapper<CourseMenu> lqw = Wrappers.lambdaQuery();
+        lqw.eq(bo.getCourseId() != null, CourseMenu::getCourseId, bo.getCourseId());
+        lqw.in( CourseMenu::getMenuId, bo.getChapterIdList());
+        lqw.eq(CourseMenu::getType, 2);
+        List<CourseMenu> menuList = courseMenuMapper.selectList(lqw);
+        if(Validator.isEmpty(menuList)||menuList.size()==0){
+            throw new CustomException("章数据错误");
+        }
+        for(CourseMenu menu : menuList){
+            menu.setCourseId(courseNew.getCourseId());
+            menu.setFirstChoiceStatus(0);
+            menu.setCreateTime(DateUtils.getNowTime());
+            menu.setUpdateTime(DateUtils.getNowTime());
+            courseMenuMapper.insert(menu);
+        }
+
+        Goods goodsNew = BeanUtil.toBean(goodsOld, Goods.class);
+        goodsNew.setGoodsId(null);
+        goodsNew.setCreateTime(DateUtils.getNowTime());
+        goodsNew.setUpdateTime(DateUtils.getNowTime());
+        goodsNew.setCode(ServletUtils.getEncoded("KC"));
+        goodsNew.setFirstChoiceGoods(bo.getGoodsId());
+        goodsNew.setFirstChoiceStatus(0);
+        goodsNew.setCode(ServletUtils.getEncoded("SP"));
+        goodsNew.setGoodsName(goodsNew.getGoodsName()+"(优选)");
+        iGoodsService.save(goodsNew);
+
+        GoodsCourse goodsCourseOld = iGoodsCourseService.getOne(new LambdaQueryWrapper<GoodsCourse>()
+                .eq(GoodsCourse::getGoodsId, bo.getGoodsId()).eq(GoodsCourse::getCourseId, bo.getCourseId()));
+        if(Validator.isEmpty(goodsCourseOld)){
+            throw new CustomException("商品课程错误");
+        }
+        GoodsCourse goodsCourseNew = BeanUtil.toBean(goodsCourseOld, GoodsCourse.class);
+        goodsCourseNew.setCourseId(courseNew.getCourseId());
+        goodsCourseNew.setGoodsId(goodsNew.getGoodsId());
+        iGoodsCourseService.save(goodsCourseNew);
+
+        orderGoods.setGoodsId(goodsNew.getGoodsId());
+   //     orderGoods.setGradeId(gradeNew.getGradeId());
+        updateById(orderGoods);
+
+        ClassGradeGoodsAddBo gradeGoodsAddBo = new ClassGradeGoodsAddBo();
+        gradeGoodsAddBo.setGoodsId(goodsNew.getGoodsId());
+        gradeGoodsAddBo.setGradeId(gradeOld.getGradeId());//
+        iClassGradeGoodsService.insertByAddBo(gradeGoodsAddBo);
+
+        LambdaUpdateWrapper<UserExamGoods> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+        objectLambdaUpdateWrapper.eq(UserExamGoods::getOrderGoodsId, bo.getOrderGoodsId());
+        objectLambdaUpdateWrapper.set(UserExamGoods::getGoodsId, goodsNew.getGoodsId());
+        objectLambdaUpdateWrapper.set(UserExamGoods::getUpdateTime,DateUtils.getNowTime());
+        iUserExamGoodsService.update(null, objectLambdaUpdateWrapper);
+
+        LambdaUpdateWrapper<UserExamGoodsSupplement> objectLambdaUpdateWrapper2 = Wrappers.lambdaUpdate();
+        objectLambdaUpdateWrapper2.eq(UserExamGoodsSupplement::getOrderGoodsId, bo.getOrderGoodsId());
+        objectLambdaUpdateWrapper2.set(UserExamGoodsSupplement::getGoodsId, goodsNew.getGoodsId());
+        objectLambdaUpdateWrapper2.set(UserExamGoodsSupplement::getUpdateTime,DateUtils.getNowTime());
+        iUserExamGoodsSupplementService.update(null, objectLambdaUpdateWrapper2);
+
+      /*  LambdaUpdateWrapper<ClassGradeUser> objectLambdaUpdateWrapper3 = Wrappers.lambdaUpdate();
+        objectLambdaUpdateWrapper3.eq(ClassGradeUser::getOrderGoodsId, bo.getOrderGoodsId());
+        objectLambdaUpdateWrapper3.eq(ClassGradeUser::getUserId, bo.getUserId());
+        objectLambdaUpdateWrapper3.set(ClassGradeUser::getGradeId, gradeNew.getGradeId());
+        objectLambdaUpdateWrapper3.set(ClassGradeUser::getUpdateTime,DateUtils.getNowTime());
+        iClassGradeUserService.update(null, objectLambdaUpdateWrapper3);*/
+
+        bo.setGoodsId(goodsNew.getGoodsId());
+        bo.setCourseId(goodsCourseNew.getCourseId());
+    //    bo.setGradeId(gradeNew.getGradeId());
+        return bo;
+    }
 }

+ 46 - 41
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -2486,8 +2486,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
             if ((("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) && org.getShareClass() == 1) {
                 //生成预开班编号
-                classGrade.setOfficialName(createGradeCode(goodsId, businessVo));
-//                classGrade.setOfficialName(ServletUtils.getEncoded("PIY"));
+//                classGrade.setOfficialName(createGradeCode(goodsId, businessVo));
+                classGrade.setOfficialName(ServletUtils.getEncoded("PIY"));
             }
 
         } else {
@@ -2572,48 +2572,48 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         iClassGradeGoodsService.save(classGradeGoods);
         //锁定班级
         lockGrade(orderGoodsId, classGrade.getGradeId(), userId, goodsId, orderSn,orderGoods.getSevenYear());
-//        if ((("继续教育二级建造师".equals(businessFull)) || ("继续教育二级造价师".equals(businessFull))) && sysTenant.getShareClass() == 1) {
-//            //二建继教班级创建,所有共享班级机构同步创建
-//            synchronousCreation(classGrade,sysTenant,goodsId);
-//            //通知旧系统
-//            CreateSameClassBo classBo = new CreateSameClassBo();
-//            if (ObjectUtils.isNotNull(bo.getClassStatus()) && bo.getClassStatus() == 1){
-//                classBo.setClassNo(classGrade.getOfficialName());
-//                classBo.setOpenclassState(1);
-//                classBo.setBeginTime(DateUtils.timestampToDateFormat(classGrade.getClassStartTime(),"yyyy-MM-dd HH:mm:ss"));
-//                classBo.setEndTime(DateUtils.timestampToDateFormat(classGrade.getClassEndTime(),"yyyy-MM-dd HH:mm:ss"));
-//            }else {
-//                classBo.setClassNo(classGrade.getOfficialName());
-//                classBo.setOpenclassState(0);
-//            }
-//            classBo.setCategoryName(classGrade.getClassName());
-//            classBo.setPlatformId("继续教育二级造价师".equals(businessFull)?8:5);
-//            Major major = iMajorService.getById(goods.getMajorId());
-//            if (ObjectUtils.isNotNull(major)){
-//                classBo.setMajorName(major.getCategoryName());
-//            }
-//
-//            Long nowTime = DateUtils.getNowTime();
-//            String sign = ToolsUtils.EncoderByMd5(classBo.getClassNo()+nowTime.toString() + "pubilc2022");
-//            classBo.setSign(sign);
-//            classBo.setStamp(nowTime);
-//            JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(classBo));
-//            String respone = "";
-//            try {
-//                respone = HttpUtils.sendPost(CREATE_EXAM_PATH, param);
-//                if (!respone.contains("\"Status\":true")) {
-//                    log.error("旧系统创建班级错误" + respone);
-//                }
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//                log.error("旧系统创建班级错误" + respone);
-//            }
-//        }
+        if ((("继续教育二级建造师".equals(businessFull)) || ("继续教育二级造价师".equals(businessFull))) && sysTenant.getShareClass() == 1) {
+            //二建继教班级创建,所有共享班级机构同步创建
+            synchronousCreation(classGrade,sysTenant,goodsId);
+            //通知旧系统
+            CreateSameClassBo classBo = new CreateSameClassBo();
+            if (ObjectUtils.isNotNull(bo.getClassStatus()) && bo.getClassStatus() == 1){
+                classBo.setClassNo(classGrade.getOfficialName());
+                classBo.setOpenclassState(1);
+                classBo.setBeginTime(DateUtils.timestampToDateFormat(classGrade.getClassStartTime(),"yyyy-MM-dd HH:mm:ss"));
+                classBo.setEndTime(DateUtils.timestampToDateFormat(classGrade.getClassEndTime(),"yyyy-MM-dd HH:mm:ss"));
+            }else {
+                classBo.setClassNo(classGrade.getOfficialName());
+                classBo.setOpenclassState(0);
+            }
+            classBo.setCategoryName(classGrade.getClassName());
+            classBo.setPlatformId("继续教育二级造价师".equals(businessFull)?8:5);
+            Major major = iMajorService.getById(goods.getMajorId());
+            if (ObjectUtils.isNotNull(major)){
+                classBo.setMajorName(major.getCategoryName());
+            }
+
+            Long nowTime = DateUtils.getNowTime();
+            String sign = ToolsUtils.EncoderByMd5(classBo.getClassNo()+nowTime.toString() + "pubilc2022");
+            classBo.setSign(sign);
+            classBo.setStamp(nowTime);
+            JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(classBo));
+            String respone = "";
+            try {
+                respone = HttpUtils.sendPost(CREATE_EXAM_PATH, param);
+                if (!respone.contains("\"Status\":true")) {
+                    log.error("旧系统创建班级错误" + respone);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("旧系统创建班级错误" + respone);
+            }
+        }
        return true;
     }
 
     private void synchronousCreation(ClassGrade classGrade, SysTenant sysTenant,Long goodsId) {
-        List<SysTenant> tenantList = iSysTenantService.getListNoTenant(sysTenant.getTenantId());
+        List<SysTenant> tenantList = iSysTenantService.getListNoTenant(0L);
         if (CollectionUtils.isEmpty(tenantList)){
             return;
         }
@@ -2629,7 +2629,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //班级是否存在
             ClassGrade grade = iClassGradeService.getCodeNoTenant(classGrade.getOfficialName(),tenant.getTenantId());
             if (ObjectUtils.isNotNull(grade)){
-                //已经存在 不创建
+                //已经存在 过滤已经创建过班级的商品
+                List<ClassGradeGoods> classGradeGoods = iClassGradeGoodsService.listByIdNoTenant(grade.getGradeId());
+                List<Long> goodsIds = classGradeGoods.stream().map(ClassGradeGoods::getGoodsId).collect(Collectors.toList());
+                relGoods = relGoods.stream().filter(x -> !goodsIds.contains(x.getGoodsId())).collect(Collectors.toList());
+            }
+            if (CollectionUtils.isEmpty(relGoods)){
                 return;
             }
 

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/IScheduleService.java

@@ -116,4 +116,5 @@ public interface IScheduleService extends IService<PolyvVideo> {
 
     void syncUserDateStudyLog();
 
+    void usbUserDownload();
 }

+ 226 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -14,9 +14,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zhongzheng.common.core.domain.entity.SysUser;
 import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
+import com.zhongzheng.common.type.EncryptHandler;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.common.utils.file.FileUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
+import com.zhongzheng.modules.alioss.bo.OssRequest;
+import com.zhongzheng.modules.alioss.service.OssService;
 import com.zhongzheng.modules.alisms.vo.ResultBean;
 import com.zhongzheng.modules.base.service.IProfileTpService;
 import com.zhongzheng.modules.base.vo.ProfileTpVo;
@@ -99,6 +104,9 @@ import com.zhongzheng.modules.polyv.service.IPolyvLiveService;
 import com.zhongzheng.modules.schedule.service.IScheduleService;
 import com.zhongzheng.modules.system.bo.SysTenantBadBillConfigBo;
 import com.zhongzheng.modules.system.bo.SysTenantQueryBo;
+import com.zhongzheng.modules.system.domain.SysTask;
+import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.service.ISysTaskService;
 import com.zhongzheng.modules.system.service.ISysTenantService;
 import com.zhongzheng.modules.system.service.ISysUserService;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
@@ -130,7 +138,14 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.math.BigDecimal;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -138,6 +153,7 @@ import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * 定时任务
@@ -332,6 +348,10 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     private ICourseProjectTypeService iCourseProjectTypeService;
     @Autowired
     private ICourseBusinessService iCourseBusinessService;
+    @Autowired
+    private ISysTaskService iSysTaskService;
+    @Autowired
+    private OssService ossService;
 
 
     @Value("${aliyun.sms.OpenTheGoodsCode}")
@@ -1737,8 +1757,18 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
                 examApply.setProjectId(projectId);
                 examApply.setBusinessId(businessId);
                 examApply.setCode(ServletUtils.getEncoded("KSAP"));
+                examApply.setRelCode(ServletUtils.getEncoded("SHEX"));
                 examApply.setReportStatus(0);
                 examApply.setApplyNature(1);//普通场次
+                //是否公用祥粤考场
+                String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+                SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+                if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+                   String code = iExamApplyService.getExamRelCodeNotTenant(examApply.getApplyName());
+                   if (StringUtils.isNotEmpty(code)){
+                       examApply.setRelCode(code);
+                   }
+                }
                 iExamApplyService.save(examApply);
 
                 //考试商品
@@ -1813,6 +1843,202 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
         iUserStudyRecordService.syncUserDateStudyLog();
     }
 
+    @Override
+    public void usbUserDownload() {
+        int count = iSysTaskService
+                .count(new LambdaQueryWrapper<SysTask>()
+                .eq(SysTask::getStatus, 1)
+                .eq(SysTask::getTaskStatus, 2));
+        if (count > 0){
+            //已有任务在执行中 不同步执行
+            return;
+        }
+        SysTask task = iSysTaskService.getOne(new LambdaQueryWrapper<SysTask>()
+                .eq(SysTask::getTaskStatus, 1)
+                .eq(SysTask::getStatus, 1)
+                .orderByAsc(SysTask::getCreateTime)
+                .last("limit 1"));
+        if (ObjectUtils.isNull(task)){
+            return;
+        }
+
+        //执行下载任务
+        SubUserExportBo subUserExportBo = JSONObject.parseObject(task.getTaskParam(), SubUserExportBo.class);
+        List<UserSubscribe> subscribeList = iUserSubscribeService.listByTimeNoTenant(subUserExportBo);
+        if (CollectionUtils.isEmpty(subscribeList)){
+            task.setTaskStatus(3);//完成
+            iSysTaskService.updateById(task);
+            return;
+        }
+        task.setTaskStatus(2);//执行中
+        iSysTaskService.updateById(task);
+        String zhiyuan = System.getProperty("user.dir");
+        String destDirPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
+                +String.format("%s预约考试",DateUtils.timestampToDateFormat(subUserExportBo.getApplyTime(),"yyyy-MM-dd"));
+        List<UserStudyRecordExport> recordExports = new ArrayList<>();
+        for (int i = 0; i < subscribeList.size(); i++) {
+            UserSubscribe item = subscribeList.get(i);
+            User user = iUserService.getByIdNoTenant(item.getUserId());
+            String userPhotoPath = destDirPath+"/"+user.getRealname()+"/"+"个人相片";
+            File dirw = new File(userPhotoPath);
+            if (!dirw.exists()){
+                dirw.mkdirs();
+            }
+            //获取个人近照和身份证照片
+            try {
+                InputStream inputStream = ossService.getStreamByObject(user.getOneInchPhotos());
+                //写入本地文件
+                String inchPath = userPhotoPath + "/"+String.format("%s$头像.jpg", EncryptHandler.decrypt(user.getIdCard()));
+                FileOutputStream fileOutputStream = new FileOutputStream(inchPath);
+                byte[] buffer = new byte[1024];
+                int len = 0;
+                while ((len = inputStream.read(buffer)) != -1) {
+                    fileOutputStream.write(buffer, 0, len);
+                }
+                inputStream.close();
+                fileOutputStream.close();
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
+                InputStream inputStream = ossService.getStreamByObject(user.getIdCardImg2());
+                //写入本地文件
+                String cardPath1 = userPhotoPath + "/"+String.format("%s身份证反面.jpg", user.getRealname());
+                FileOutputStream fileOutputStream = new FileOutputStream(cardPath1);
+                byte[] buffer = new byte[1024];
+                int len = 0;
+                while ((len = inputStream.read(buffer)) != -1) {
+                    fileOutputStream.write(buffer, 0, len);
+                }
+                inputStream.close();
+                fileOutputStream.close();
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            try {
+                InputStream inputStream = ossService.getStreamByObject(user.getIdCardImg1());
+                //写入本地文件
+                String cardPath2 = userPhotoPath + "/"+String.format("%s身份证正面.jpg", user.getRealname());
+                FileOutputStream fileOutputStream = new FileOutputStream(cardPath2);
+                byte[] buffer = new byte[1024];
+                int len = 0;
+                while ((len = inputStream.read(buffer)) != -1) {
+                    fileOutputStream.write(buffer, 0, len);
+                }
+                inputStream.close();
+                fileOutputStream.close();
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            //学习照片
+            OrderGoods orderGoods = iOrderGoodsService.getByIdNoTenant(item.getOrderGoodsId());
+            Goods goods = iGoodsService.getGoodsByIdNotTenant(orderGoods.getGoodsId());
+            String goodsPath = destDirPath+"/"+user.getRealname()+"/"+goods.getGoodsName();
+            File dirw2 = new File(goodsPath);
+            if (!dirw2.exists()){
+                dirw2.mkdirs();
+            }
+            List<UserStudyRecord> recordList = iUserStudyRecordService.getStudyRecordNoTenant(orderGoods.getOrderGoodsId());
+            if (CollectionUtils.isEmpty(recordList)){
+                continue;
+            }
+            Map<Long, List<UserStudyRecord>> map = recordList.stream().collect(Collectors.groupingBy(UserStudyRecord::getSectionId));
+            map.forEach((k,v) -> {
+                CourseSection section = iCourseSectionService.getSectionByNotTenant(k);
+                String sectionPath = goodsPath+"/"+section.getName();
+                File dirw3 = new File(sectionPath);
+                if (!dirw3.exists()){
+                    dirw3.mkdirs();
+                }
+                //视频拍照信息
+                v.stream().filter(x -> ObjectUtils.isNotNull(x.getPhoto())).forEach(photo -> {
+                    try {
+                        InputStream inputStream = ossService.getStreamByObject(photo.getPhoto());
+                        //写入本地文件
+                        String photoPath1 = sectionPath + "/"+String.format("%s.jpg",DateUtils.getNowTime());
+                        FileOutputStream fileOutputStream = new FileOutputStream(photoPath1);
+                        byte[] buffer = new byte[1024];
+                        int len = 0;
+                        while ((len = inputStream.read(buffer)) != -1) {
+                            fileOutputStream.write(buffer, 0, len);
+                        }
+                        inputStream.close();
+                        fileOutputStream.close();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                });
+            });
+
+            //学习记录
+           List<UserStudyRecordExport> exports = iExamApplyService.getUserStudyRecordNoTenant(item.getOrderGoodsId());
+            if (CollectionUtils.isEmpty(exports)) {
+                continue;
+            }
+            exports.forEach(recordItem -> {
+                recordItem.setUserName(user.getRealname());
+                recordItem.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
+                recordItem.setCompanyName(user.getCompanyName());
+                recordItem.setSectionTime(DateUtils.secondConvertHourMinSecond(recordItem.getDurationTime()));
+                if (ObjectUtils.isNotNull(recordItem.getStatus()) && recordItem.getStatus() == 1) {
+                    //已学完
+                    recordItem.setStudyTime(DateUtils.secondConvertHourMinSecond(recordItem.getDurationTime()));
+                    recordItem.setFinish("已完成");
+                } else {
+                    recordItem.setFinish("未完成");
+                }
+                recordItem.setStudyStartTime(DateUtils.timestampToDateFormat(recordItem.getStartTime(), "yyyy/MM/dd HH:mm:ss"));
+                recordItem.setStudyEndTime(DateUtils.timestampToDateFormat(recordItem.getEndTime(), "yyyy/MM/dd HH:mm:ss"));
+            });
+            recordExports.addAll(exports);
+            task.setFinishNum(i+1);
+            iSysTaskService.updateById(task);
+        }
+        ExcelUtil<UserStudyRecordExport> util = new ExcelUtil<UserStudyRecordExport>(UserStudyRecordExport.class);
+        String path = destDirPath + "/" +"学习记录表" + ".xlsx";
+        util.exportEasyExcelStudy(util.exportEasyData(recordExports), path);
+        //打包zip 上传oss
+        String zipPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
+                +String.format("%s预约考试.zip",DateUtils.timestampToDateFormat(subUserExportBo.getApplyTime(),"yyyy-MM-dd"));
+        FileUtils.toZip(zipPath,destDirPath,true);
+        //上传oss
+        OssRequest ossRequest = new OssRequest();
+        ossRequest.setGradeId(0L);
+        ossRequest.setUserId(0L);
+        ossRequest.setImageStatus(7);
+        File file1 = new File(zipPath);
+        ossRequest.setFile(FileUtils.getMultipartFile(file1));
+        try {
+            String upload = ossService.upload(ossRequest);
+            task.setTaskPath(upload);
+            task.setTaskStatus(3);//完成
+            iSysTaskService.updateById(task);
+            //删除本地资源
+            Path pathStr = Paths.get(destDirPath);
+            try (Stream<Path> walk = Files.walk(pathStr)) {
+                walk.sorted(Comparator.reverseOrder())
+                        .forEach(FileUtils::deleteDirectoryStream);
+            }catch (IOException e) {
+                log.error("删除本地资源失败:"+ DateUtils.getNowTime());
+            }
+
+            Path zipStr = Paths.get(zipPath);
+            try (Stream<Path> walk = Files.walk(zipStr)) {
+                walk.sorted(Comparator.reverseOrder())
+                        .forEach(FileUtils::deleteDirectoryStream);
+            }catch (IOException e) {
+                log.error("删除本地资源失败:"+ DateUtils.getNowTime());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
     private String getWeeks(Long time){
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(DateUtils.timeToDate(time));

+ 44 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysTask.java

@@ -0,0 +1,44 @@
+package com.zhongzheng.modules.system.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 系统商户对象 sys_tenant
+ *
+ * @author hjl
+ * @date 2021-08-03
+ */
+@Data
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("sys_task")
+public class SysTask implements Serializable {
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Long createTime;
+    private Long updateTime;
+    /** 0 失效 1启用 */
+    private Integer status;
+    /** 任务名称 */
+    private String taskName;
+    /** 任务数量 */
+    private Integer taskNum;
+    /** 完成数量 */
+    private Integer finishNum;
+    /** 执行参数 */
+    private String taskParam;
+    /** 下载路径 */
+    private String taskPath;
+    /** 1未开始 2执行中 3已完成 */
+    private Integer taskStatus;
+
+    private Long tenantId;
+
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/domain/SysTenant.java

@@ -111,5 +111,7 @@ private static final long serialVersionUID=1L;
     private Integer sort;
     /** 七大员班级标识:1使用祥粤班级 0正常 */
     private Integer sevenClass;
+    /** 考场共享标识: 1使用祥粤 0正常 */
+    private Integer examRoom;
 
 }

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysTaskMapper.java

@@ -0,0 +1,13 @@
+package com.zhongzheng.modules.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.system.domain.SysTask;
+
+/**
+ * 参数配置 数据层
+ *
+ * @author zhongzheng
+ */
+public interface SysTaskMapper extends BaseMapper<SysTask> {
+
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/mapper/SysTenantMapper.java

@@ -20,4 +20,7 @@ public interface SysTenantMapper extends BaseMapper<SysTenant> {
 
     @InterceptorIgnore(tenantLine = "true")
     List<SysTenant> getListNoTenant(Long tenantId);
+    @InterceptorIgnore(tenantLine = "true")
+    List<SysTenant> getExamRoomTenant();
+
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/ISysTaskService.java

@@ -0,0 +1,16 @@
+package com.zhongzheng.modules.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.system.domain.SysConfig;
+import com.zhongzheng.modules.system.domain.SysTask;
+import com.zhongzheng.modules.system.vo.SysConfigVo;
+
+import java.util.List;
+
+/**
+ * 参数配置 服务层
+ *
+ * @author zhongzheng
+ */
+public interface ISysTaskService extends IService<SysTask> {
+}

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

@@ -71,4 +71,6 @@ public interface ISysTenantService extends IService<SysTenant> {
 	boolean deleteTopTenant(SysTopTenantEditBo bo);
 
     List<SysTenant> getListNoTenant(Long tenantId);
+
+	List<SysTenant> getExamRoomTenant();
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/service/impl/SysTaskServiceImpl.java

@@ -0,0 +1,16 @@
+package com.zhongzheng.modules.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhongzheng.modules.system.domain.SysTask;
+import com.zhongzheng.modules.system.mapper.SysTaskMapper;
+import com.zhongzheng.modules.system.service.ISysTaskService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 参数配置 服务层实现
+ *
+ * @author zhongzheng
+ */
+@Service
+public class SysTaskServiceImpl extends ServiceImpl<SysTaskMapper, SysTask> implements ISysTaskService {
+}

+ 49 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/system/vo/SysTaskVo.java

@@ -0,0 +1,49 @@
+package com.zhongzheng.modules.system.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 系统商户对象 sys_tenant
+ *
+ * @author hjl
+ * @date 2021-08-03
+ */
+@Data
+public class SysTaskVo implements Serializable {
+
+    private Long id;
+
+    private Long createTime;
+    private Long updateTime;
+    /** 0 失效 1启用 */
+    private Integer status;
+    /** 任务名称 */
+    @ApiModelProperty("任务名称")
+    private String taskName;
+    /** 任务数量 */
+    @ApiModelProperty("任务数量")
+    private Integer taskNum;
+    /** 完成数量 */
+    @ApiModelProperty("完成数量")
+    private Integer finishNum;
+    /** 执行参数 */
+    @ApiModelProperty("执行参数")
+    private String taskParam;
+    /** 下载路径 */
+    @ApiModelProperty("下载路径")
+    private String taskPath;
+    /** 1未开始 2执行中 3已完成 */
+    @ApiModelProperty("1未开始 2执行中 3已完成")
+    private Integer taskStatus;
+
+    private Long tenantId;
+
+}

+ 20 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/SubUserExportBo.java

@@ -0,0 +1,20 @@
+package com.zhongzheng.modules.user.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author yangdamao
+ * @date 2023年10月09日 15:29
+ */
+@Data
+public class SubUserExportBo implements Serializable {
+
+    @ApiModelProperty("考试日期时间")
+    private Long applyTime;
+
+    private List<Long> tenantIds;
+}

+ 83 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubQueryBo.java

@@ -0,0 +1,83 @@
+package com.zhongzheng.modules.user.bo;
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 用户预约考试分页查询对象 user_subscribe
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel("预约列表(包含其他使用祥粤考场的机构)")
+public class UserSubQueryBo extends BaseEntity {
+
+	/** 分页大小 */
+	@ApiModelProperty("分页大小")
+	private Integer pageSize;
+	/** 当前页数 */
+	@ApiModelProperty("当前页数")
+	private Integer pageNum;
+	/** 排序列 */
+	@ApiModelProperty("排序列")
+	private String orderByColumn;
+	/** 排序的方向desc或者asc */
+	@ApiModelProperty(value = "排序的方向", example = "asc,desc")
+	private String isAsc;
+
+	@ApiModelProperty("预约状态:1成功 2取消 3已过期")
+	private Integer subscribeStatus;
+
+	@ApiModelProperty("考试状态:1待考试 2通过 3未通过")
+	private Integer applyStatus;
+
+	@ApiModelProperty("剩余考试次数")
+	private Integer applyNum;
+
+	@ApiModelProperty("是否新考:1是 2否")
+	private Integer newApply;
+
+	@ApiModelProperty("关键字")
+	private String keyWord;
+
+	@ApiModelProperty("月份")
+	private String ApplyDateTime;
+
+	@ApiModelProperty("月份开始时间")
+	private Long monthStartTime;
+
+	@ApiModelProperty("月份结束时间")
+	private Long monthEndTime;
+
+	/** 考试开始时间段 */
+	@ApiModelProperty("考试开始时间段")
+	private String applySiteStartTime;
+
+	/** 考试结束时间段 */
+	@ApiModelProperty("考试结束时间段")
+	private String applySiteEndTime;
+
+	/** 考试日期 */
+	@ApiModelProperty("考试日期")
+	private Long applySiteExamTime;
+
+	@ApiModelProperty("当前时间")
+	private Long dataTime;
+
+	@ApiModelProperty("教育类型ID")
+	private Long educationId;
+
+	@ApiModelProperty("业务层次ID")
+	private Long businessId;
+
+
+	private List<Long> tenantIds;
+
+}

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserSubscribe.java

@@ -117,5 +117,11 @@ private static final long serialVersionUID=1L;
     private Long reportFileTime;
     /** 智慧考场抓拍照 */
     private String snapPictures;
+    /** 证书下载地址 */
+    private String certificateUrl;
+    /** 发证时间 */
+    private Long certificateStartTime;
+    /** 到期时间 */
+    private Long certificateEndTime;
 
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserMapper.java

@@ -78,4 +78,10 @@ public interface UserMapper extends BaseMapper<User> {
 
     @InterceptorIgnore(tenantLine = "true")
     List<User> listByIdsNotTenant(@Param("userIds")List<Long> userIds);
+
+    @InterceptorIgnore(tenantLine = "true")
+    User getByIdNoTenant(Long userId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    User getByCardNoTenant(String idCard);
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserStudyRecordMapper.java

@@ -126,4 +126,8 @@ public interface UserStudyRecordMapper extends BaseMapper<UserStudyRecord> {
 
     @InterceptorIgnore(tenantLine = "true")
     List<CdUserStudyLogVo> syncUserList(UserStudyRecordQueryBo bo);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserStudyRecord> getStudyRecordNoTenant(Long orderGoodsId);
+
 }

+ 20 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserSubscribeMapper.java

@@ -1,9 +1,14 @@
 package com.zhongzheng.modules.user.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
+import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
+import com.zhongzheng.modules.user.bo.SubUserExportBo;
+import com.zhongzheng.modules.user.bo.UserSubQueryBo;
 import com.zhongzheng.modules.user.bo.UserSubscribeQueryBo;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.user.vo.UserSubVo;
 import com.zhongzheng.modules.user.vo.UserSubscribeVo;
 import com.zhongzheng.modules.user.vo.UserVo;
 import org.apache.ibatis.annotations.Param;
@@ -63,4 +68,19 @@ public interface UserSubscribeMapper extends BaseMapper<UserSubscribe> {
     Long selectMajorId(@Param("majorName")String majorName);
 
     List<Long> getGoodsIds(@Param("userId")Long userId, @Param("applyId")Long applyId,@Param("majorId") Long majorId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    Integer getExamApplyNum(String relCode);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserSubVo> getListSubscribe(UserSubQueryBo bo);
+
+    @InterceptorIgnore(tenantLine = "true")
+    GoodsQuestionRel getQuestionRel(Long orderGoodsId);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserSubscribe> listByTimeNoTenant(SubUserExportBo bo);
+
+    @InterceptorIgnore(tenantLine = "true")
+    void updateByIdNoTenant(UserSubscribe subscribe);
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserService.java

@@ -138,4 +138,8 @@ public interface IUserService extends IService<User> {
     List<User> listByIdsNotTenant(List<Long> userIds);
 
 	String createToken(LoginUser loginUser);
+
+    User getByIdNoTenant(Long userId);
+
+    User getByCardNoTenant(String idCard);
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserStudyRecordService.java

@@ -150,4 +150,5 @@ public interface IUserStudyRecordService extends IService<UserStudyRecord> {
 
 	Boolean syncUserDateStudyLog();
 
+    List<UserStudyRecord> getStudyRecordNoTenant(Long orderGoodsId);
 }

+ 13 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserSubscribeService.java

@@ -4,6 +4,7 @@ import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
 import com.zhongzheng.modules.exam.bo.UpdateStudentImageBo;
 import com.zhongzheng.modules.exam.vo.ExamSessionVo;
+import com.zhongzheng.modules.system.vo.SysTaskVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
 import com.zhongzheng.modules.user.vo.*;
@@ -112,4 +113,16 @@ public interface IUserSubscribeService extends IService<UserSubscribe> {
     String updateStudentImage(UpdateStudentImageBo bo);
 
 	void examApplySubscribeCancel(ExamApplySubscribeBo bo);
+
+	List<UserSubVo> getListSubscribe(UserSubQueryBo bo);
+
+    Boolean subUserExport(SubUserExportBo bo);
+
+	List<UserSubscribe> listByTimeNoTenant(SubUserExportBo subUserExportBo);
+
+	void updateByIdNoTenant(UserSubscribe subscribe);
+
+	String subRecordUserExport(SubUserExportBo bo);
+
+	List<SysTaskVo> subUserExportList();
 }

+ 15 - 8
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserStudyRecordServiceImpl.java

@@ -341,27 +341,29 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
     @Transactional(rollbackFor = Exception.class)
     public Integer insertByAddBo(UserStudyRecordAddBo bo) {
         //temp start
-        GoodsVo goodsVoTemp = iGoodsService.queryById(bo.getGoodsId());
+        GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
         CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
-        businessQueryBo.setId(goodsVoTemp.getBusinessId());
-        String fullNameTemp = iCourseBusinessService.queryFullName(businessQueryBo);
-        if(Validator.isNotEmpty(fullNameTemp)){
-            if(fullNameTemp.equals("继续教育二级建造师")||fullNameTemp.equals("继续教育二级造价师")){
+        businessQueryBo.setId(goodsVo.getBusinessId());
+        String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
+        if(Validator.isNotEmpty(fullName)){
+            if(fullName.equals("继续教育二级建造师")||fullName.equals("继续教育二级造价师")){
                 bo.setErJianErZao(true);
             }
         }
         //temp end
-
+        if(Validator.isNotEmpty(goodsVo.getFirstChoiceStatus())&&goodsVo.getFirstChoiceStatus()==1){
+            throw new CustomException("优选根商品无法学习");
+        }
 
         CourseSectionVo courseSectionVo =iCourseSectionService.queryById(bo.getSectionId());
         if(Validator.isEmpty(courseSectionVo)||Validator.isEmpty(bo.getSectionId())){
             throw new CustomException("节数据错误");
         }
-        GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
+        /*GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
         String fullName;
         CourseBusinessQueryBo queryBusinessBo = new CourseBusinessQueryBo();
         queryBusinessBo.setId(goodsVo.getBusinessId());
-        fullName = iCourseBusinessService.queryFullName(queryBusinessBo);
+        fullName = iCourseBusinessService.queryFullName(queryBusinessBo);*/
         //判断录播拍照是否达标
         if(courseSectionVo.getSectionType()==1&&Validator.isNotEmpty(bo.getStatus())&&bo.getStatus()==1){
             if(Validator.isNotEmpty(goodsVo)){
@@ -1443,6 +1445,11 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
         return null;
     }
 
+    @Override
+    public List<UserStudyRecord> getStudyRecordNoTenant(Long orderGoodsId) {
+        return baseMapper.getStudyRecordNoTenant(orderGoodsId);
+    }
+
 
     /**
      * 获取最后一次看完的节

+ 376 - 22
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -26,11 +26,14 @@ import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.file.FileUtils;
 import com.zhongzheng.common.utils.file.ImageUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.alioss.bo.OssRequest;
 import com.zhongzheng.modules.alioss.service.OssService;
 import com.zhongzheng.modules.alioss.vo.FileBean;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.bo.UserProfileFit;
+import com.zhongzheng.modules.base.domain.UserProfile;
+import com.zhongzheng.modules.base.service.IUserProfileService;
 import com.zhongzheng.modules.course.domain.CourseBusiness;
 import com.zhongzheng.modules.course.domain.CourseEducationType;
 import com.zhongzheng.modules.course.domain.CourseProjectType;
@@ -61,6 +64,7 @@ import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.domain.ClassGradeUser;
 import com.zhongzheng.modules.grade.service.IClassGradeUserService;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
 import com.zhongzheng.modules.inform.service.IInformRemindService;
@@ -69,8 +73,11 @@ import com.zhongzheng.modules.inform.vo.InformRemindBusinessVo;
 import com.zhongzheng.modules.inform.vo.InformRemindVo;
 import com.zhongzheng.modules.order.domain.OrderGoods;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
+import com.zhongzheng.modules.system.domain.SysTask;
 import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.service.ISysTaskService;
 import com.zhongzheng.modules.system.service.ISysTenantService;
+import com.zhongzheng.modules.system.vo.SysTaskVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
@@ -97,6 +104,9 @@ import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -108,6 +118,7 @@ import java.util.List;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import java.util.zip.ZipOutputStream;
 
 import static java.util.stream.Collectors.toCollection;
@@ -130,6 +141,8 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
 
     @Autowired
     private IGoodsService iGoodsService;
+    @Autowired
+    private IMajorService iMajorService;
 
     @Autowired
     private IInformUserService iInformUserService;
@@ -146,6 +159,9 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
     @Autowired
     private IUserService iUserService;
 
+    @Autowired
+    private IUserProfileService iUserProfileService;
+
     @Autowired
     private IExamApplySiteService iExamApplySiteService;
 
@@ -177,6 +193,8 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
     private ICourseBusinessService iCourseBusinessService;
     @Autowired
     private ISysTenantService iSysTenantService;
+    @Autowired
+    private ISysTaskService iSysTaskService;
 
     @Value("${aliyun.sms.cancellationReminder}")
     private String cancellationReminder;
@@ -371,6 +389,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         if (System.currentTimeMillis()/1000 > time){
             throw new CustomException("当前选择的考试时间已过期,请重新预约,选择未过期考试时间");
         }
+        subscribeNumCheck(60L,bo.getApplyId());
         //要求非必填考点
         if(Validator.isNotEmpty(bo.getApplySiteAddress())){
             ExamApplyQueryBo queryTimeBo = new ExamApplyQueryBo();
@@ -1211,28 +1230,51 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
                 continue;
             }
             //考点已申报人数
-            Long sitePeopleNum = examApplyMapper.sitePeopleNum(queryTimeBo);
-            System.out.println(queryTimeBo);
-            List<String> siteTimeJsonList = examApplyMapper.siteTimeJson(queryTimeBo);
-            String siteTimeJson = siteTimeJsonList.stream().filter(x -> {
-                List<ExamApplySiteTimeTwoVo> timeTwoVos = JSONArray.parseArray(x, ExamApplySiteTimeTwoVo.class);
-                ExamApplySiteTimeTwoVo timeTwoVo = timeTwoVos.get(0);
-                if (timeTwoVo.getStartTime().equals(queryTimeBo.getStartTime())
-                        && timeTwoVo.getEndTime().equals(queryTimeBo.getEndTime())) {
-                    return true;
+//            Long sitePeopleNum = examApplyMapper.sitePeopleNum(queryTimeBo);
+//            System.out.println(queryTimeBo);
+//            List<String> siteTimeJsonList = examApplyMapper.siteTimeJson(queryTimeBo);
+//            String siteTimeJson = siteTimeJsonList.stream().filter(x -> {
+//                List<ExamApplySiteTimeTwoVo> timeTwoVos = JSONArray.parseArray(x, ExamApplySiteTimeTwoVo.class);
+//                ExamApplySiteTimeTwoVo timeTwoVo = timeTwoVos.get(0);
+//                if (timeTwoVo.getStartTime().equals(queryTimeBo.getStartTime())
+//                        && timeTwoVo.getEndTime().equals(queryTimeBo.getEndTime())) {
+//                    return true;
+//                }
+//                return false;
+//            }).findFirst().orElse(null);
+//            if (Validator.isEmpty(siteTimeJson)) {
+//                userSubscribeImport.setCause("考点数据错误");
+//                userSubscribeImports.add(userSubscribeImport);
+//                continue;
+//            }
+//            int num = findPeopleNum(queryTimeBo,siteTimeJson);
+//            if(num==-1||num<=sitePeopleNum){
+//                userSubscribeImport.setCause("考点人数已满");
+//                userSubscribeImports.add(userSubscribeImport);
+//                continue;
+//            }
+
+            String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+            SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+            if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+                //公用祥粤考场
+                ExamApply examApply = iExamApplyService.getById(applyId);
+                if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(examApply.getRelCode())){
+                    //约考人数
+                    Integer number = baseMapper.getExamApplyNum(examApply.getRelCode());
+                    if (number >= 60){
+                        userSubscribeImport.setCause("考点人数已满");
+                        userSubscribeImports.add(userSubscribeImport);
+                    }
+                }
+            }else {
+                int countNum = count(new LambdaQueryWrapper<UserSubscribe>()
+                        .eq(UserSubscribe::getApplyId, applyId)
+                        .eq(UserSubscribe::getSubscribeStatus, 1));
+                if (countNum >= 60){
+                    userSubscribeImport.setCause("考点人数已满");
+                    userSubscribeImports.add(userSubscribeImport);
                 }
-                return false;
-            }).findFirst().orElse(null);
-            if (Validator.isEmpty(siteTimeJson)) {
-                userSubscribeImport.setCause("考点数据错误");
-                userSubscribeImports.add(userSubscribeImport);
-                continue;
-            }
-            int num = findPeopleNum(queryTimeBo,siteTimeJson);
-            if(num==-1||num<=sitePeopleNum){
-                userSubscribeImport.setCause("考点人数已满");
-                userSubscribeImports.add(userSubscribeImport);
-                continue;
             }
 
             //查看是否有无考试记录
@@ -2302,7 +2344,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         //考场人数
         List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(examApplySiteTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
         Long userNum = siteTimeTwoAddBos.get(0).getNum();
-
+        subscribeNumCheck(userNum,bo.getApplyId());
         //生成座位号
         Integer tNum = getSeatNumber(bo,userNum);
         add.setSeatNumber(tNum.toString());
@@ -2382,6 +2424,29 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         return add.getSubscribeId();
     }
 
+    private void subscribeNumCheck(Long userNum,Long applyId) {
+        String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+        SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+        if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+            //公用祥粤考场
+            ExamApply examApply = iExamApplyService.getById(applyId);
+            if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(examApply.getRelCode())){
+                //约考人数
+                Integer number = baseMapper.getExamApplyNum(examApply.getRelCode());
+                if (number >= userNum){
+                    throw new CustomException("预约考点人数已满,请选择其他场次");
+                }
+            }
+        }else {
+            int count = count(new LambdaQueryWrapper<UserSubscribe>()
+                    .eq(UserSubscribe::getApplyId, applyId)
+                    .eq(UserSubscribe::getSubscribeStatus, 1));
+            if (count >= userNum){
+                throw new CustomException("预约考点人数已满,请选择其他场次");
+            }
+        }
+    }
+
     @Override
     public List<ExamSessionVo> getExamSession(String applyDate) {
         //根据月份筛选
@@ -2592,6 +2657,295 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         sendExamcancel(userSubscribeEditBo);
     }
 
+    @Override
+    public List<UserSubVo> getListSubscribe(UserSubQueryBo bo) {
+        String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+        SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+        if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+           List<SysTenant> tenants = iSysTenantService.getExamRoomTenant();
+           bo.setTenantIds(tenants.stream().map(SysTenant::getTenantId).collect(Collectors.toList()));
+        }else {
+            bo.setTenantIds(Arrays.asList(Long.valueOf(tenantId)));
+        }
+        Long zeroTime = DateUtils.getTodayZeroTime();
+        bo.setDataTime(zeroTime);
+        if (ObjectUtils.isNotNull(bo.getApplyDateTime()) && bo.getApplyDateTime().length() == 6){
+            //根据月份筛选
+            String dateStr = String.format(bo.getApplyDateTime()); // 指定年月
+            LocalDate date = LocalDate.parse(dateStr + "01", DateTimeFormatter.BASIC_ISO_DATE);
+            LocalDate dateFirst = date.with(TemporalAdjusters.firstDayOfMonth()); // 指定年月的第一天
+            LocalDate dateEnd = date.with(TemporalAdjusters.lastDayOfMonth()); // 指定年月的最后一天
+            ZonedDateTime zonedDateTime1 = dateFirst.atStartOfDay(ZoneId.systemDefault());
+            Date date1 = Date.from(zonedDateTime1.toInstant());
+            ZonedDateTime zonedDateTime = dateEnd.atStartOfDay(ZoneId.systemDefault());
+            Date date2 = Date.from(zonedDateTime.toInstant());
+            Long startTime = date1.getTime()/1000;
+            Long endTime = (date2.getTime()/1000) + 86400;
+            bo.setMonthStartTime(startTime);
+            bo.setMonthEndTime(endTime);
+        }else if (ObjectUtils.isNotNull(bo.getApplyDateTime()) && bo.getApplyDateTime().length() > 6){
+            //根据某天筛选
+            String dateStr = String.format(bo.getApplyDateTime());
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+            try {
+                Date parse = sdf.parse(dateStr);
+                bo.setMonthStartTime(parse.getTime()/1000);
+                bo.setMonthEndTime(parse.getTime()/1000);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+        List<UserSubVo> userSubVos = baseMapper.getListSubscribe(bo);
+        if (CollectionUtils.isEmpty(userSubVos)){
+            return new ArrayList<>();
+        }
+        userSubVos.forEach(item -> {
+            item.setUserCard(EncryptHandler.decrypt(item.getUserCard()));
+            item.setUserPhone(EncryptHandler.decrypt(item.getUserPhone()));
+            if (item.getSubscribeStatus() == 1 && zeroTime > item.getApplyTime()){
+                item.setSubscribeStatus(3);
+            }
+            GoodsQuestionRel questionRel = baseMapper.getQuestionRel(item.getOrderGoodsId());
+            if (ObjectUtils.isNotNull(questionRel)){
+                item.setQuestionStatus(1);
+            }else {
+                item.setQuestionStatus(2);
+            }
+            //考试状态
+            if (item.getSubscribeStatus() == 1 && item.getExamStatus() == 0){
+                item.setApplyStatus(1);
+            }else if (item.getSubscribeStatus() == 1 && item.getExamStatus() == 1 && item.getResult() == 1){
+                item.setApplyStatus(2);
+            }else if (item.getSubscribeStatus() == 1 && item.getExamStatus() == 1 && item.getResult() == 0){
+                item.setApplyStatus(3);
+            }else {
+                item.setApplyStatus(item.getExamStatus());
+            }
+        });
+
+        return userSubVos;
+    }
+
+    @Override
+    public Boolean subUserExport(SubUserExportBo bo) {
+        //加入任务列表
+        SysTask sysTask = new SysTask();
+        sysTask.setTaskName(String.format("(%s)学员档案下载任务",DateUtils.getTime()));
+        //下载数量
+        String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+        SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+        if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+            //公用祥粤考场
+            List<SysTenant> list = iSysTenantService
+                    .list(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getStatus, 1)
+                    .eq(SysTenant::getExamRoom, 1));
+            bo.setTenantIds(list.stream().map(SysTenant::getTenantId).collect(Collectors.toList()));
+        }else {
+            bo.setTenantIds(Arrays.asList(Long.valueOf(tenantId)));
+        }
+        List<UserSubscribe> subscribeList = baseMapper.listByTimeNoTenant(bo);
+        sysTask.setTaskNum(subscribeList.size());
+        sysTask.setFinishNum(0);
+        sysTask.setTaskParam(JSONObject.toJSONString(bo));
+        sysTask.setTaskStatus(1);
+        sysTask.setCreateTime(DateUtils.getNowTime());
+        sysTask.setUpdateTime(DateUtils.getNowTime());
+        return iSysTaskService.save(sysTask);
+    }
+
+    @Override
+    public List<UserSubscribe> listByTimeNoTenant(SubUserExportBo subUserExportBo) {
+        return baseMapper.listByTimeNoTenant(subUserExportBo);
+    }
+
+    @Override
+    public void updateByIdNoTenant(UserSubscribe subscribe) {
+        baseMapper.updateByIdNoTenant(subscribe);
+    }
+
+    @Override
+    public String subRecordUserExport(SubUserExportBo bo) {
+        String tenantId = ServletUtils.getRequest().getHeader("TenantId");
+        SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
+        if (ObjectUtils.isNotNull(sysTenant.getExamRoom()) && sysTenant.getExamRoom() == 1){
+            //公用祥粤考场
+            List<SysTenant> list = iSysTenantService
+                    .list(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getStatus, 1)
+                            .eq(SysTenant::getExamRoom, 1));
+            bo.setTenantIds(list.stream().map(SysTenant::getTenantId).collect(Collectors.toList()));
+        }else {
+            bo.setTenantIds(Arrays.asList(Long.valueOf(tenantId)));
+        }
+        List<UserSubscribe> subscribeList = baseMapper.listByTimeNoTenant(bo);
+        if (CollectionUtils.isEmpty(subscribeList)){
+            throw new CustomException("该场次没有预约的学员!");
+        }
+        //商品分组
+        Map<Long, List<UserSubscribe>> map = subscribeList.stream().collect(Collectors.groupingBy(UserSubscribe::getGoodsId));
+        String zhiyuan = System.getProperty("user.dir");
+        String destDirPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
+                +String.format("%s预约考试%s",DateUtils.timestampToDateFormat(bo.getApplyTime(),"yyyy-MM-dd"),DateUtils.getNowTime());
+        List<UserExamApplyExport> examApplyExports = new ArrayList<>();
+        map.forEach((k,v) -> {
+            Goods goods = iGoodsService.getGoodsByIdNotTenant(k);
+            if (ObjectUtils.isNull(goods) || ObjectUtils.isNull(goods.getMajorId())){
+                return;
+            }
+            Major major = iMajorService.getMajorByIdNoTenant(goods.getMajorId());
+            String majorPath = destDirPath+"/"+major.getCategoryName();
+            File dirw = new File(majorPath);
+            if (!dirw.exists()){
+                dirw.mkdirs();
+            }
+            String photoPath = majorPath+"/"+"广东省祥粤建设职业培训学校";
+            File dirw2 = new File(photoPath);
+            if (!dirw2.exists()){
+                dirw2.mkdirs();
+            }
+            List<UserSubApplyExport> applyExports = new ArrayList<>();
+            //学员头像
+            v.forEach(item -> {
+                User user = iUserService.getByIdNoTenant(item.getUserId());
+                //获取个人近照
+                try {
+                    InputStream inputStream = ossService.getStreamByObject(user.getOneInchPhotos());
+                    //写入本地文件
+                    String inchPath = photoPath + "/"+String.format("%s$头像.jpg", EncryptHandler.decrypt(user.getIdCard()));
+                    FileOutputStream fileOutputStream = new FileOutputStream(inchPath);
+                    byte[] buffer = new byte[1024];
+                    int len = 0;
+                    while ((len = inputStream.read(buffer)) != -1) {
+                        fileOutputStream.write(buffer, 0, len);
+                    }
+                    inputStream.close();
+                    fileOutputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                //报考资料
+                UserProfile profile = iUserProfileService.getByOrderGoodsIdNoTenant(item.getOrderGoodsId());
+                if (ObjectUtils.isNull(profile)){
+                    return;
+                }
+                UserSubApplyExport applyExport = new UserSubApplyExport();
+                applyExport.setUserName(user.getRealname());
+                applyExport.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
+                applyExport.setPhone(EncryptHandler.decrypt(user.getTelphone()));
+
+                String keyValue = profile.getKeyValue();
+                applyExport.setSex(getUserProfileValue(keyValue,"sex"));
+                applyExport.setEducation(getUserProfileValue(keyValue,"education"));
+                applyExport.setCompanyName(getUserProfileValue(keyValue,"work_unit"));
+                applyExport.setPostName(getUserProfileValue(keyValue,"apply_post"));
+                applyExport.setMajorName(getUserProfileValue(keyValue,"major"));
+                applyExport.setAge(getUserProfileValue(keyValue,"working_years"));
+                applyExport.setGraduateTime(getUserProfileValue(keyValue,"graduation_time"));
+                applyExports.add(applyExport);
+
+                //测试计划
+                UserExamApplyExport export = new UserExamApplyExport();
+                export.setUserName(user.getRealname());
+                export.setIdCard(EncryptHandler.decrypt(user.getIdCard()));
+                export.setPhone(EncryptHandler.decrypt(user.getTelphone()));
+                export.setPostName(getUserProfileValue(keyValue,"apply_post"));
+                export.setApplyName(
+                        String.format("%s测试%s-%s",DateUtils.timestampToDateFormat(item.getApplySiteExamTime(),"yyyy.MM.dd")
+                                ,applyTimeTransition(item.getApplySiteStartTime()),applyTimeTransition(item.getApplySiteEndTime())));
+                examApplyExports.add(export);
+            });
+            //打包zip
+            String zipPath = majorPath+"/"+"广东省祥粤建设职业培训学校.zip";
+            FileUtils.toZip(zipPath,photoPath,true);
+            //删除本地资源
+            Path pathStr = Paths.get(photoPath);
+            try (Stream<Path> walk = Files.walk(pathStr)) {
+                walk.sorted(Comparator.reverseOrder())
+                        .forEach(FileUtils::deleteDirectoryStream);
+            }catch (IOException e) {
+                log.error("删除本地资源失败:"+ DateUtils.getNowTime());
+            }
+            //报考资料
+            if (CollectionUtils.isNotEmpty(applyExports)){
+                ExcelUtil<UserSubApplyExport> util = new ExcelUtil<UserSubApplyExport>(UserSubApplyExport.class);
+                String path = majorPath + "/" +String.format("%s报名信息表",major.getCategoryName()) + ".xlsx";
+                util.exportEasyExcelStudy(util.exportEasyData(applyExports), path);
+            }
+        });
+
+        //测试计划
+        if (CollectionUtils.isNotEmpty(examApplyExports)){
+            ExcelUtil<UserExamApplyExport> util = new ExcelUtil<UserExamApplyExport>(UserExamApplyExport.class);
+            String path = destDirPath + "/测试计划.xlsx";
+            util.exportEasyExcelStudy(util.exportEasyData(examApplyExports), path);
+        }
+
+        //打包zip 上传oss
+        String zipPath = zhiyuan+"/zhongzheng-admin/src/main/resources/"
+                +String.format("%s预约考试%s.zip",DateUtils.timestampToDateFormat(bo.getApplyTime(),"yyyy-MM-dd"),DateUtils.getNowTime());
+        FileUtils.toZip(zipPath,destDirPath,true);
+        //上传oss
+        OssRequest ossRequest = new OssRequest();
+        ossRequest.setGradeId(0L);
+        ossRequest.setUserId(0L);
+        ossRequest.setImageStatus(7);
+        File file1 = new File(zipPath);
+        ossRequest.setFile(FileUtils.getMultipartFile(file1));
+        try {
+            String upload = ossService.upload(ossRequest);
+            //删除本地资源
+            Path pathStr = Paths.get(destDirPath);
+            try (Stream<Path> walk = Files.walk(pathStr)) {
+                walk.sorted(Comparator.reverseOrder())
+                        .forEach(FileUtils::deleteDirectoryStream);
+            }catch (IOException e) {
+                log.error("删除本地资源失败:"+ DateUtils.getNowTime());
+            }
+
+            Path zipStr = Paths.get(zipPath);
+            try (Stream<Path> walk = Files.walk(zipStr)) {
+                walk.sorted(Comparator.reverseOrder())
+                        .forEach(FileUtils::deleteDirectoryStream);
+            }catch (IOException e) {
+                log.error("删除本地资源失败:"+ DateUtils.getNowTime());
+            }
+            return upload;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    @Override
+    public List<SysTaskVo> subUserExportList() {
+        List<SysTask> list = iSysTaskService.list(new LambdaQueryWrapper<SysTask>().eq(SysTask::getStatus, 1));
+        if (CollectionUtils.isEmpty(list)){
+            return new ArrayList<>();
+        }
+        return list.stream().map(item -> BeanUtil.toBean(item,SysTaskVo.class)).collect(Collectors.toList());
+    }
+
+    private String applyTimeTransition(String time){
+        List<String> collect = Arrays.stream(time.split(":")).collect(Collectors.toList());
+        StringBuffer result = new StringBuffer();
+        for (String s : collect) {
+            result.append(s);
+        }
+        return result.toString();
+    }
+
+    private String getUserProfileValue(String keyValue,String key){
+        JSONObject jsonObject = JSONObject.parseObject(keyValue);
+        if (ObjectUtils.isNotNull(jsonObject.get(key))){
+            Object o = jsonObject.get(key);
+            JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(o));
+            if (ObjectUtils.isNotNull(jsonObject1.get("value"))){
+                return jsonObject1.get("value").toString();
+            }
+        }
+        return "";
+    }
+
+
     /**
      * 学员学时图片修改
      * @author change

+ 38 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserExamApplyExport.java

@@ -0,0 +1,38 @@
+package com.zhongzheng.modules.user.vo;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 用户预约考试视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("测试计划")
+public class UserExamApplyExport implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Excel(name = "姓名",width = 30)
+	private String userName;
+
+	@Excel(name = "身份证号" ,width = 30)
+	private String idCard;
+
+	@Excel(name = "手机号" ,width = 30)
+	private String phone;
+
+	@Excel(name = "岗位",width = 30)
+	private String postName;
+
+	@Excel(name = "场次名称",width = 30)
+	private String applyName;
+
+
+}

+ 52 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubApplyExport.java

@@ -0,0 +1,52 @@
+package com.zhongzheng.modules.user.vo;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 用户预约考试视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("学员预约报名资料")
+public class UserSubApplyExport implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@Excel(name = "姓名",width = 30)
+	private String userName;
+
+	@Excel(name = "性别",width = 30)
+	private String sex;
+
+	@Excel(name = "身份证号" ,width = 30)
+	private String idCard;
+
+	@Excel(name = "手机号" ,width = 30)
+	private String phone;
+
+	@Excel(name = "学历" ,width = 30)
+	private String education;
+
+	@Excel(name = "工作单位",width = 30)
+	private String companyName;
+
+	@Excel(name = "岗位",width = 30)
+	private String postName;
+
+	@Excel(name = "所学专业",width = 30)
+	private String majorName;
+
+	@Excel(name = "工作年限",width = 30)
+	private String age;
+
+	@Excel(name = "毕业时间",width = 30)
+	private String graduateTime;
+
+}

+ 74 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubVo.java

@@ -0,0 +1,74 @@
+package com.zhongzheng.modules.user.vo;
+
+import com.zhongzheng.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 用户预约考试分页查询对象 user_subscribe
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("预约列表(包含其他使用祥粤考场的机构)")
+public class UserSubVo implements Serializable {
+
+	@ApiModelProperty("预约ID")
+	private Long subscribeId;
+	private Long orderGoodsId;
+	@ApiModelProperty("学员姓名")
+	private String userName;
+	@ApiModelProperty("学员身份证")
+	private String userCard;
+	@ApiModelProperty("学员手机号码")
+	private String userPhone;
+	@ApiModelProperty("课程名称")
+	private String goodsName;
+	@ApiModelProperty("岗位")
+	private String majorName;
+	@ApiModelProperty("公司名称")
+	private String companyName;
+	@ApiModelProperty("所属机构")
+	private String tenantName;
+	@ApiModelProperty("创建时间")
+	private Long createTime;
+	@ApiModelProperty("预约状态:1成功 2取消 3已过期")
+	private Integer subscribeStatus;
+	@ApiModelProperty("预约结果")
+	private String applyResult;
+	@ApiModelProperty("是否开通题库:1是 2否")
+	private Integer questionStatus;
+	@ApiModelProperty("考试状态:1待考试 2通过 3未通过")
+	private Integer applyStatus;
+	@ApiModelProperty("剩余考试次数")
+	private Integer applyNum;
+	@ApiModelProperty("是否新考:1是 2否")
+	private Integer newApply;
+	@ApiModelProperty("出考情况:0 待登记 1正常 2缺考 3作弊 4替考")
+	private Integer examStatus;
+	@ApiModelProperty("1通过 0不通过")
+	private Integer result;
+	@ApiModelProperty("考试日期")
+	private Long applyTime;
+	@ApiModelProperty("考试开始时间")
+	private String applyStartTime;
+	@ApiModelProperty("考试结束时间")
+	private String applyEndTime;
+	@ApiModelProperty("考试地点")
+	private String applyAddress;
+	@ApiModelProperty("成绩")
+	private BigDecimal performance;
+	@ApiModelProperty("证书编号")
+	private String certificateCode;
+	@ApiModelProperty("发证时间")
+	private String certificateStartTime;
+	@ApiModelProperty("到期时间")
+	private String certificateEndTime;
+
+}

+ 10 - 1
zhongzheng-system/src/main/resources/mapper/modules/activity/ActivityRecommendMapper.xml

@@ -31,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="educationName" column="education_name"/>
         <result property="projectName" column="project_name"/>
         <result property="businessName" column="business_name"/>
+        <result property="aliasName" column="alias_name"/>
         <result property="majorId" column="major_id"/>
         <result property="subjectIdList" column="subject_ids"/>
         <collection property="goodsList" column="recommend_id" select="findGoodsList"/>
@@ -52,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             g.goods_id,
             g.goods_name,
             g.stand_price,
+            g.line_price,
             rg.sort,
             g.code,
             g.year,
@@ -70,14 +72,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectListByBo" parameterType="com.zhongzheng.modules.activity.bo.ActivityRecommendQueryBo" resultMap="ActivityRecommendVoResult">
         SELECT ar.*, cet.education_name,
                cpt.project_name,
+               cb.alias_name,
                cb.business_name from activity_recommend ar
             LEFT JOIN course_education_type cet ON ar.education_type_id = cet.id
             LEFT JOIN course_project_type cpt ON ar.project_id = cpt.id
             LEFT JOIN course_business cb ON ar.business_id = cb.id
-        WHERE 1 = 1 and ar.`status` = 1
+        WHERE 1 = 1
         <if test="type != null and type != ''">
             AND ar.type = #{type}
         </if>
+        <if test="statusList != null and statusList.size()!=0 ">
+            AND ar.`status` in
+            <foreach collection="statusList" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
         <if test="platform != null and platform != ''">
             AND ar.platform = #{platform}
         </if>

+ 7 - 3
zhongzheng-system/src/main/resources/mapper/modules/base/UserProfileMapper.xml

@@ -241,11 +241,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             cgu.grade_id
         FROM
             class_grade_user cgu
-                LEFT JOIN class_grade_goods cgg on cgu.grade_id = cgg.grade_id
-                LEFT JOIN class_grade cg on cg.grade_id = cgg.grade_id
+                LEFT JOIN order_goods og on og.order_goods_id  = cgu.order_goods_id
+                LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
         WHERE
             cgu.user_id = #{userId}
-          and cgg.goods_id = #{goodsId}
+          and og.goods_id = #{goodsId}
           and cg.`status` = 1
           and cgu.`status` = 1
         ORDER BY cgu.create_time desc
@@ -266,4 +266,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and g.business_id = #{businessId}
         </if>
     </select>
+
+    <select id="getByOrderGoodsIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.base.domain.UserProfile">
+        SELECT * FROM user_profile WHERE order_goods_id = #{orderGoodsId} AND current_status = 1 AND `status` NOT IN (3,-1)
+    </select>
 </mapper>

+ 17 - 19
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -26,6 +26,7 @@
         <result property="subjectId" column="subject_id"/>
         <result property="projectId" column="project_id"/>
         <result property="courseShow" column="course_show"/>
+        <result property="firstChoice" column="first_choice"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
@@ -56,6 +57,7 @@
         <result property="categoryName" column="category_name"/>
         <result property="subjectName" column="subject_name"/>
         <result property="courseShow" column="course_show"/>
+        <result property="firstChoice" column="first_choice"/>
         <collection property="goodsList" column="course_id" select="findGoodsList"/>
     </resultMap>
 
@@ -295,7 +297,7 @@
         LEFT JOIN major m ON c.major_id = m.id AND m.status =1
         LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
         WHERE
-        1 = 1 AND c.status !=-1 AND c.course_show =1
+        1 = 1 AND c.status !=-1 AND c.course_show =1 AND c.first_choice =0
         <if test="subjectIds != null and subjectIds.size()!=0 ">
             AND c.subject_id in
             <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
@@ -346,7 +348,7 @@
         FROM
             course c
         WHERE
-        1 = 1   AND c.status !=-1 AND c.course_show =1
+        1 = 1   AND c.status !=-1 AND c.course_show =1 AND c.first_choice =0
         <if test="subjectIds != null and subjectIds.size()!=0 ">
             AND c.subject_id in
             <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
@@ -440,9 +442,9 @@
             (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where  ups.period_status =1  and (ups.`status` =3 or ups.`status` =0) and up.grade_id = cgu.grade_id and up.user_id = cgu.user_id) as rebuild,
             (case WHEN (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.grade_id = cgu.grade_id AND ups.period_status =1 and ups.`status` =3 and up.user_id = cgu.user_id ) >0 then 1 ELSE 0 end) as rebuild_status,
             cgu.grade_id,
-            (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = cgg.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
-            (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
-            (SELECT eb.before_name FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name,
+            (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = og.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
+            (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = og.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
+            (SELECT eb.before_name FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = og.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name,
             cgu.order_goods_id,
             og.service_start_time,
             og.service_end_time,
@@ -463,9 +465,9 @@
             g.external_link_status
         FROM
             class_grade_user cgu
-                LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
+                LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
                 LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
-                LEFT JOIN goods g on g.goods_id=cgg.goods_id
+                LEFT JOIN goods g on g.goods_id=og.goods_id
                 LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
                 LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
                 LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
@@ -778,8 +780,7 @@
         where
         m.type in (1,3)
         and c.goods_id = #{goodsId}) as exam_num,
-        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
-        = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
+        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
             cgu.grade_id,
             cg.class_start_time,
             cg.class_end_time,
@@ -800,7 +801,7 @@
         FROM
             class_grade_user cgu
                 LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
-                LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
+                LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
         WHERE
             1=1
         <if test="gradeId != null and gradeId != ''">
@@ -809,7 +810,7 @@
         <if test="orderGoodsId != null and orderGoodsId != ''">
             and cgu.order_goods_id = #{orderGoodsId}
         </if>
-          and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
+          and cg.`status` =1 and og.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
         order by cg.create_time desc LIMIT 1
     </select>
 
@@ -822,8 +823,7 @@
         where
         m.type in (1,3)
         and c.goods_id = #{goodsId}) as exam_num,
-        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
-        = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
+        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
         cgu.grade_id,
         cg.class_start_time,
         cg.class_end_time,
@@ -843,15 +843,15 @@
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
+        LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
         WHERE
         1=1 and cgu.tenant_id = #{tenantId}
           and cg.tenant_id = #{tenantId}
-          and cgg.tenant_id = #{tenantId}
+          and og.tenant_id = #{tenantId}
         <if test="gradeId != null and gradeId != ''">
             and cg.grade_id = #{gradeId}
         </if>
-        and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
+        and cg.`status` =1 and og.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
         order by cg.create_time desc LIMIT 1
     </select>
 
@@ -876,15 +876,13 @@
         where
         m.type in (1,3)
         and c.goods_id = #{goodsId}) as exam_num,
-        (SELECT ifnull(COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id),0) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
-        = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
+        (SELECT ifnull(COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id),0) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.report_status=1 and ubr.order_goods_id = cgu.order_goods_id and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
         cgu.grade_id,
         cgu.user_id,
         cgu.order_goods_id
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
         WHERE
         1=1
         <if test="gradeId != null and gradeId != ''">

+ 14 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime" column="update_time"/>
         <result property="status" column="status"/>
         <result property="sort" column="sort"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseMenuVo" id="CourseMenuResultVo">
@@ -36,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="freeExamName" column="free_exam_name"/>
         <result property="code" column="code"/>
         <result property="publishStatus" column="publish_status"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.course.vo.CourseUserMenuVo" id="CourseUserMenuVo">
@@ -57,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="teacherName" column="teacher_name"/>
         <result property="goodsId" column="goods_id"/>
         <result property="commonSign" column="common_sign"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
     </resultMap>
 
     <select id="getList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo"  resultMap="CourseMenuResultVo">
@@ -386,4 +389,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectByNotTenant" parameterType="map"  resultType="com.zhongzheng.modules.course.domain.CourseMenu">
         SELECT * FROM `course_menu` WHERE course_id = #{newCourseId} AND menu_id = #{newModuleId} AND type = #{type} AND tenant_id = #{newTenantId}
     </select>
+
+    <select id="countChapterTotalTime" parameterType="map"  resultType="Long">
+        SELECT
+            IFNULL( SUM( s.duration_time ), 0 )
+        FROM
+            course_chapter_section cs
+                LEFT JOIN course_section s ON cs.section_id = s.section_id
+        WHERE
+            cs.chapter_id = #{chapterId}
+          AND s.`status` = 1
+    </select>
 </mapper>

+ 3 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/MajorMapper.xml

@@ -107,4 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getMajorByTenant" parameterType="map"  resultType="com.zhongzheng.modules.course.domain.Major">
         SELECT * FROM major where encoder = #{encoder} and tenant_id = #{newTenantId}
     </select>
+    <select id="getMajorByIdNoTenant" parameterType="java.lang.Long"  resultType="com.zhongzheng.modules.course.domain.Major">
+        SELECT * FROM major where id = #{majorId}
+    </select>
 </mapper>

+ 95 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyMapper.xml

@@ -308,6 +308,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             apply_id = #{applyId}
     </select>
 
+    <select id="getExamRelCodeNotTenant" parameterType="java.lang.String" resultType="java.lang.String">
+        SELECT rel_code FROM `exam_apply` WHERE apply_name = #{applyName} AND rel_code != '' AND rel_code IS NOT NULL LIMIT 1
+    </select>
+
     <select id="getUserProfileList" parameterType="java.lang.String" resultType="com.zhongzheng.modules.base.domain.UserProfile">
         SELECT
             up.*
@@ -651,4 +655,95 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND m.`status` = 1
           AND m.category_name = #{majorName}
     </select>
+
+
+    <select id="getUserStudyRecordNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.vo.UserStudyRecordExport">
+        SELECT
+            order_goods_id,
+            goods_id,
+            module_id,
+            chapter_id,
+            section_id,
+            (SELECT goods_name FROM goods WHERE goods_id = usr.goods_id) as goods_name,
+            (SELECT `name` FROM course_chapter WHERE chapter_id = usr.chapter_id) as chapter_name,
+            (SELECT `name` FROM course_section WHERE section_id = usr.section_id) as section_name,
+            (SELECT duration_time FROM course_section WHERE section_id = usr.section_id) as duration_time,
+            MIN(start_time) AS start_time,
+            MAX(end_time) AS end_time,
+            MAX(`status`) AS `status`,
+            any_value(ip) AS ip
+        FROM
+            user_study_record usr
+        WHERE
+            order_goods_id = #{orderGoodsId}
+        GROUP BY
+            order_goods_id,
+            goods_id,
+            course_id,
+            module_id,
+            chapter_id,
+            section_id
+    </select>
+
+    <select id="getSevenMajorNames" resultType="java.lang.String">
+        SELECT DISTINCT
+            m.category_name
+        FROM
+            course_education_type cet
+                LEFT JOIN course_project_type cpt ON cpt.education_id = cet.id
+                AND cet.tenant_id = 867735392558919680
+                LEFT JOIN major_project mp ON mp.project_id = cpt.id
+                AND mp.tenant_id = 867735392558919680
+                LEFT JOIN major m ON mp.major_id = m.id
+                AND m.tenant_id = 867735392558919680
+        WHERE
+            cet.education_name = '考前培训'
+          AND cpt.project_name = '施工现场专业人员'
+          AND cet.`status` = 1
+          AND cpt.`status` = 1
+          AND m.`status` = 1
+          AND m.tenant_id = 867735392558919680
+    </select>
+
+    <select id="getSubscribeInfo" parameterType="com.zhongzheng.modules.exam.bo.SubscribeInfoBo"
+            resultType="com.zhongzheng.modules.user.domain.UserSubscribe">
+        SELECT
+            *
+        FROM
+            user_subscribe us
+                LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
+                LEFT JOIN goods g ON og.goods_id = g.goods_id
+                LEFT JOIN major m ON g.major_id = m.id
+        WHERE
+            us.user_id = #{userId}
+            AND us.subscribe_status = 1
+            AND m.category_name = #{major}
+            AND us.apply_site_exam_time = #{applyTime}
+            <if test="applyStartTime != null and applyStartTime != ''">
+                AND us.apply_site_start_time = #{applyStartTime}
+            </if>
+            <if test="applyEndTime != null and applyEndTime != ''">
+                AND us.apply_site_end_time = #{applyEndTime}
+            </if>
+            LIMIT 1
+    </select>
+
+    <select id="getExamPassSub" parameterType="com.zhongzheng.modules.exam.bo.SubscribeInfoBo"
+            resultType="com.zhongzheng.modules.user.domain.UserSubscribe">
+        SELECT
+            *
+        FROM
+            user_subscribe us
+            LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
+            LEFT JOIN goods g ON og.goods_id = g.goods_id
+            LEFT JOIN major m ON g.major_id = m.id
+        WHERE
+            us.user_id = #{userId}
+            AND us.subscribe_status = 1
+            AND us.exam_status = 1
+            AND us.result = 1
+            AND m.category_name = #{major}
+            LIMIT 1
+    </select>
+
 </mapper>

+ 11 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/GoodsMapper.xml

@@ -55,6 +55,9 @@
         <result property="commitPeriodRemark" column="commit_period_remark"/>
         <result property="gradeType" column="grade_type"/>
         <result property="examLimitClient" column="exam_limit_client"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
+        <result property="minClassHour" column="min_class_hour"/>
+        <result property="firstChoiceGoods" column="first_choice_goods"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
@@ -145,6 +148,10 @@
         <result property="gradeType" column="grade_type"/>
         <result property="examLimitClient" column="exam_limit_client"/>
         <result property="optionalYear" column="optional_year"/>
+        <result property="firstChoiceStatus" column="first_choice_status"/>
+        <result property="minClassHour" column="min_class_hour"/>
+        <result property="firstChoiceGoods" column="first_choice_goods"/>
+        <result property="aliasName" column="alias_name"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
@@ -190,6 +197,7 @@
         cet.education_name,
         cpt.project_name,
         cb.business_name,
+        cb.alias_name,
         cb.goods_learning_order,
         s.school_name,
         m.category_name,
@@ -253,6 +261,7 @@
         WHERE
         1 = 1
         AND g.goods_type != 5
+        AND g.first_choice_goods = 0
         <if test="status != null and status.size()!=0 ">
             AND g.status in
             <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
@@ -416,6 +425,7 @@
         WHERE
         1 = 1
         AND g.goods_type != 5
+        AND g.first_choice_goods = 0
         <if test="status != null and status.size()!=0 ">
             AND g.status in
             <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
@@ -867,6 +877,7 @@
                 LEFT JOIN major m ON g.major_id = m.id
         WHERE
             g.`status` = 1
+            AND g.goods_status = 1
             AND INSTR(#{businessName}, cet.education_name)
             AND INSTR(#{businessName}, cpt.project_name)
             AND INSTR(#{categoryName}, m.category_name)

+ 5 - 0
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeGoodsMapper.xml

@@ -41,4 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         cgg.grade_id = #{gradeId}
     </select>
 
+    <select id="listByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.grade.domain.ClassGradeGoods">
+        SELECT cgg.* FROM class_grade_goods cgg
+        WHERE
+            cgg.grade_id = #{gradeId}
+    </select>
 </mapper>

+ 20 - 19
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeMapper.xml

@@ -171,6 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="projectName" column="project_name"/>
         <result property="businessName" column="business_name"/>
         <result property="sevenYear" column="seven_year"/>
+        <result property="orgId" column="org_id"/>
 
         <result property="userBindWx" column="user_bind_wx"/>
         <result property="userFollowWx" column="user_follow_wx"/>
@@ -402,19 +403,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         u.user_id,
         cgu.`status`,
         u.realname,
-        (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
+        og.goods_id,
         u.id_card,
         cgu.grade_id,
         u.telphone,
         (case WHEN (select COUNT(uu.id) FROM user_update uu where cgu.user_id = uu.user_id and uu.status = 2) >0 then 1 ELSE 0 end) as user_status,
         (case WHEN cgu.official_status_time >  (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id) then 0 ELSE 1 end) as user_info_status,
         (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
-        (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as class_hours,
+        g.class_hours,
         cgu.period_status,
         cgu.finish_status,
         cgu.period_plush,
-        (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_start_time,
-        (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_end_time,
+        g.study_start_time,
+        g.study_end_time,
         cg.class_start_time,
         cg.class_end_time,
         cg.interface_push_id,
@@ -422,8 +423,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         cgu.official_status_msg,
         cgu.period_plush_msg,
         cgu.learn_status,
-        (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type  in (1,3) ) as exam_num,
-        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id = ubr.goods_id where ubr.`status`=1 and ubr.type  in (1,3) and  ubr.user_id = u.user_id and ubr.grade_id = cgu.grade_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,
+        (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id   where c.goods_id=og.goods_id and m.type  in (1,3) ) as exam_num,
+        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.type  in (1,3) and  ubr.user_id = u.user_id and ubr.order_goods_id = cgu.order_goods_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,
         (og.study_count) as study_count,
         og.order_goods_id,
         og.rebuy_order_goods_id,
@@ -436,6 +437,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         g.major_id,
         u.province,
         cgu.reason,
+        cgu.tenant_id as org_id,
         cb.business_name,
         cpt.project_name,
         (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
@@ -465,12 +467,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           and cgu.grade_id = #{gradeId}
         </if>
         <if test="choice != null and choice == 1 ">
-            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id)  AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0
+            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and  cgur.order_goods_id = cgu.order_goods_id AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0
             AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
         </if>
         <if test="choice != null and choice == 2 ">
-            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg
-            where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id)  AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
+            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and  cgur.order_goods_id = cgu.order_goods_id  AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
             and cge.`status`=1 and cgur.`status` =1)> 0
             AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
         </if>
@@ -732,8 +733,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         count(cgu.id)
         FROM
-        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
-        LEFT JOIN goods g ON cgg.goods_id = g.goods_id
+        class_grade_user cgu  LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g ON og.goods_id = g.goods_id
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
         WHERE
         cgu.`status` = 1
@@ -802,8 +803,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         count(cgu.id)
         FROM
-        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
-        LEFT JOIN goods g ON cgg.goods_id = g.goods_id
+        class_grade_user cgu  LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g ON og.goods_id = g.goods_id
         WHERE
         1 = 1
         <if test="periodStatus != null">
@@ -830,8 +831,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT
         count(cgu.id)
         FROM
-        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
-        LEFT JOIN goods g ON cgg.goods_id = g.goods_id
+        class_grade_user cgu  LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g ON og.goods_id = g.goods_id
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
         WHERE
         1 = 1
@@ -968,15 +969,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 <if test="tenantId != null">
                     AND cgu.tenant_id = #{tenantId}
                 </if>
-                 INNER JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
+                 INNER JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
                 <if test="tenantId != null">
-                    AND cgg.tenant_id = #{tenantId}
+                    AND og.tenant_id = #{tenantId}
                 </if>
                  LEFT JOIN `user` u ON cgu.user_id = u.user_id
                 <if test="tenantId != null">
                     AND u.tenant_id = #{tenantId}
                 </if>
-                 LEFT JOIN goods g ON cgg.goods_id = g.goods_id
+                 LEFT JOIN goods g ON og.goods_id = g.goods_id
                 <if test="tenantId != null">
                     AND g.tenant_id = #{tenantId}
                 </if>
@@ -1144,7 +1145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FIND_IN_SET( id, d.subject_ids )) subject_names
         FROM
         class_grade g
-        LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
+        LEFT JOIN (SELECT grade_id,any_value(goods_id) goods_id from  class_grade_goods   GROUP BY grade_id)cgg ON cgg.grade_id = g.grade_id
         LEFT JOIN goods d ON cgg.goods_id = d.goods_id
         LEFT JOIN course_business cb ON d.business_id = cb.id
         WHERE

+ 69 - 60
zhongzheng-system/src/main/resources/mapper/modules/grade/ClassGradeUserMapper.xml

@@ -310,25 +310,20 @@
             resultMap="ClassGradeUserGoodsVoResult">
         SELECT
         * ,
-        (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as goods_code,
-        (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as year,
-        (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as goods_name,
-        (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
-        (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
-        (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
-        g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
-        (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
+        g.code as goods_code,
+        g.`year`,
+        g.goods_name,
+        (select b.business_name FROM course_business b  where b.id = g.business_id) as business_name,
+        (select b.project_name FROM course_project_type b  where b.id = g.project_id) as project_name,
+        (select b.school_name FROM school b  where b.id = g.school_id) as school_name,
+        (select b.education_name FROM course_education_type b  where b.id = g.education_type_id) as education_name,
         (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
         (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
         (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
         FROM
         class_grade_user u
+        LEFT JOIN order_goods og on og.order_goods_id = u.order_goods_id
+        LEFT JOIN  goods g on g.goods_id = og.goods_id
         where 1=1
         <if test="status != null and status.size()!=0 ">
             AND u.status in
@@ -346,25 +341,20 @@
             resultMap="ClassGradeUserGoodsVoResult">
         SELECT
         * ,
-        (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as goods_code,
-        (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as year,
-        (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
-        u.grade_id) as goods_name,
-        (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
-        (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
-        (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
-        g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
-        (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
-        class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
+        g.code as goods_code,
+        g.`year`,
+        g.goods_name,
+        (select b.business_name FROM course_business b  where b.id = g.business_id) as business_name,
+        (select b.project_name FROM course_project_type b  where b.id = g.project_id) as project_name,
+        (select b.school_name FROM school b  where b.id = g.school_id) as school_name,
+        (select b.education_name FROM course_education_type b  where b.id = g.education_type_id) as education_name,
         (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
         (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
         (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
         FROM
         class_grade_user u
+        LEFT JOIN order_goods og on og.order_goods_id = u.order_goods_id
+        LEFT JOIN  goods g on g.goods_id = og.goods_id
         where 1=1
         <if test="status != null and status.size()!=0 ">
             AND u.status in
@@ -423,7 +413,7 @@
         u.user_id,
         cgu.`status`,
         u.realname,
-        cgg.goods_id,
+        og.goods_id,
         u.id_card,
         cgu.grade_id,
         u.telphone,
@@ -453,16 +443,16 @@
         (SELECT og.service_end_time FROM order_goods og  where og.order_goods_id = cgu.order_goods_id ) as service_end_time,
         (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.`type` in (1,3) and ubr.report_status=1 and ubr.order_goods_id = cgu.order_goods_id and ubr.grade_id = cgu.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num
         <if test="userPhoto == null">
-            ,(select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) and up.grade_id = cgu.grade_id and up.order_goods_id = cgu.order_goods_id and up.user_id = u.user_id
+            ,(select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = og.goods_id and up.grade_id = cgu.grade_id and up.order_goods_id = cgu.order_goods_id and up.user_id = u.user_id
             and ups.period_status=0 and ups.`status`=0 and (SELECT COUNT(upss.id) from user_period_status upss where upss.id = ups.id and upss.period_status = 1 and upss.`status` = 2) > 0 ) as rebuild_num
         </if>
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
         LEFT JOIN `user` u ON u.user_id = cgu.user_id
-        LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = cgg.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = og.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN course_business cb ON g.business_id = cb.id
         LEFT JOIN (SELECT
         COUNT( m.id ) AS exam_num,
@@ -472,7 +462,7 @@
         LEFT JOIN goods_course c ON m.course_id = c.course_id
         where
         m.type in (1,3)
-        GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
+        GROUP BY c.goods_id ) ge on og.goods_id = ge.goods_id
         where 1=1
         and cgu.`status` =1
         <if test="periodPlush != null and periodPlush != ''">
@@ -573,6 +563,7 @@
                 WHERE
                     user_id = #{userId}
                   AND grade_id = #{gradeId}
+                  AND order_goods_id = #{orderGoodsId}
                   AND current_status = 1
                   AND `status` = 1
                 <if test="searchWeekStartTime != null and searchWeekStartTime != '' ">
@@ -597,7 +588,7 @@
         u.user_id,
         cgu.`status`,
         u.realname,
-        cgg.goods_id,
+        og.goods_id,
         u.id_card,
         cgu.grade_id,
         u.telphone,
@@ -622,16 +613,16 @@
         </if>
         cgu.period_wait_time as end_time
         <if test="userPhoto == null">
-            ,(select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) and up.grade_id = cgu.grade_id and up.user_id = u.user_id
+            ,(select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = og.goods_id and up.grade_id = cgu.grade_id and up.user_id = u.user_id
             and ups.period_status=0 and ups.`status`=0 and (SELECT COUNT(upss.id) from user_period_status upss where upss.id = ups.id and upss.period_status = 1 and upss.`status` = 2) > 0 ) as rebuild_num
         </if>
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
         LEFT JOIN `user` u ON u.user_id = cgu.user_id
-        LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = cgg.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = og.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN course_business cb ON g.business_id = cb.id
         where 1=1
         and cgu.`status` =1
@@ -724,7 +715,7 @@
         u.user_id,
         cgu.`status`,
         u.realname,
-        cgg.goods_id,
+        og.goods_id,
         u.id_card,
         cgu.grade_id,
         u.telphone,
@@ -750,9 +741,9 @@
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
         LEFT JOIN `user` u ON u.user_id = cgu.user_id
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN course_business cb ON g.business_id = cb.id
         LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = g.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
         where 1=1
@@ -832,15 +823,14 @@
         cg.class_end_time,
         g.study_start_time,
         g.study_end_time,
-        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
-        = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.`type` in (1,3) and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
+        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr  where ubr.`status`=1 and ubr.report_status=1 and ubr.`type` in (1,3) and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
         cgu.user_id,
-        cgg.goods_id
+        og.goods_id
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
-        LEFT JOIN goods g on g.goods_id=cgg.goods_id
+        LEFT JOIN order_goods og on og.order_goods_id=cgu.order_goods_id
+        LEFT JOIN goods g on g.goods_id=og.goods_id
         LEFT JOIN (SELECT
         COUNT( m.id ) AS exam_num,
         c.goods_id
@@ -849,7 +839,7 @@
         LEFT JOIN goods_course c ON m.course_id = c.course_id
         where
         m.type in (1,3)
-        GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
+        GROUP BY c.goods_id ) ge on og.goods_id = ge.goods_id
         where 1=1
         and cgu.`status` =1
 
@@ -888,7 +878,7 @@
         cgu.period_status,
         cgu.order_goods_id,
         (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
-        class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type in (1,3) ) as exam_num,
+        order_goods og on og.goods_id = c.goods_id where og.order_goods_id=cgu.order_goods_id and m.type in (1,3) ) as exam_num,
         (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id, ubr.exam_id) FROM user_bank_record ubr  where ubr.`status` = 1 and ubr.`type` in (1,3) and ubr.report_status =1 and ubr.user_id=#{userId} and ubr.grade_id=cgu.grade_id and ubr.order_goods_id=cgu.order_goods_id and ubr.current_status=1) as record_num,
         (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
         ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.grade_id = cgu.grade_id and (up.order_goods_id=cgu.order_goods_id or up.order_goods_id is null) and up.`type` = 1) as pass,
@@ -915,8 +905,8 @@
         class_grade_user cgu
         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
         LEFT JOIN `user` u ON u.user_id = cgu.user_id
-        LEFT JOIN class_grade_goods cgg ON cg.grade_id=cgg.grade_id
-        LEFT JOIN goods g ON g.goods_id = cgg.goods_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g ON g.goods_id = og.goods_id
         where 1=1
         <if test="userId != null and userId !='' ">
             and u.user_id = #{userId}
@@ -1417,6 +1407,25 @@
             rp.create_time ASC
     </select>
 
+    <select id="selectStartNoPhoto" parameterType="map" resultType="long">
+        SELECT
+        ups.record_start_time
+        FROM
+             user_period_status ups
+        LEFT JOIN user_period up ON up.id = ups.period_id
+        WHERE
+        1=1
+        <if test="orderGoodsId != null ">
+            AND (up.order_goods_id = #{orderGoodsId} or up.order_goods_id is null)
+        </if>
+        AND ups.period_status = 1
+        AND up.grade_id = #{gradeId}
+        AND up.user_id = #{userId}
+        ORDER BY
+        ups.record_start_time ASC
+        limit 1
+    </select>
+
     <select id="selectEnd" parameterType="map" resultType="long">
         SELECT
             usr.end_time
@@ -1443,13 +1452,13 @@
         cgu.order_goods_id,
         cg.class_start_time,
         cg.class_end_time,
-        cgg.goods_id,
+        og.goods_id,
         cg.grade_id
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg on  cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN inform_remind_business irb on  irb.business_id = g.business_id
         where 1=1
         and irb.remind_id =5
@@ -1469,13 +1478,13 @@
         cgu.order_goods_id,
         cg.class_start_time,
         cg.class_end_time,
-        cgg.goods_id,
+        og.goods_id,
         cg.grade_id
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg on  cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN inform_remind_business irb on  irb.business_id = g.business_id
         where 1=1
         and irb.remind_id =6
@@ -1491,13 +1500,13 @@
         cgu.order_goods_id,
         cg.class_start_time,
         cg.class_end_time,
-        cgg.goods_id,
+        og.goods_id,
         cg.grade_id
         FROM
         class_grade_user cgu
         LEFT JOIN class_grade cg on  cgu.grade_id = cg.grade_id
-        LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
-        LEFT JOIN goods g on cgg.goods_id = g.goods_id
+        LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
+        LEFT JOIN goods g on og.goods_id = g.goods_id
         LEFT JOIN inform_remind_business irb on  irb.business_id = g.business_id
         where 1=1
         and irb.remind_id =7

+ 9 - 0
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -920,4 +920,13 @@
             AND og.service_start_time <![CDATA[  <=  ]]> UNIX_TIMESTAMP()
             AND og.service_end_time <![CDATA[   >=  ]]> UNIX_TIMESTAMP()
     </select>
+
+    <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
+        SELECT
+            *
+        FROM
+            order_goods
+        WHERE
+            order_goods_id = #{orderGoodsId}
+    </select>
 </mapper>

+ 3 - 1
zhongzheng-system/src/main/resources/mapper/modules/system/SysTenantMapper.xml

@@ -39,6 +39,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getListNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.system.domain.SysTenant">
         SELECT * FROM sys_tenant WHERE share_class = 1 AND `status` = 1 AND tenant_id != #{tenantId}
     </select>
-
+    <select id="getExamRoomTenant" resultType="com.zhongzheng.modules.system.domain.SysTenant">
+        SELECT * FROM sys_tenant WHERE exam_room = 1 AND `status` = 1
+    </select>
 
 </mapper>

+ 19 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml

@@ -655,6 +655,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </foreach>
     </select>
 
+    <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
+        SELECT
+        *
+        FROM
+        `user`
+        WHERE
+        status = 1 AND user_id = #{userId}
+    </select>
+
+    <select id="getByCardNoTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
+        SELECT
+            *
+        FROM
+            `user`
+        WHERE
+            status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+            LIMIT 1
+    </select>
+
     <select id="getUserOrderCount" parameterType="map" resultType="java.lang.Long">
         SELECT
             COUNT(o.order_sn)

+ 5 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -417,7 +417,7 @@
     <select id="listExamRecord" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo"
             resultMap="SectionStudyRecordVoResult">
         SELECT (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
-        class_grade_goods cgg on cgg.goods_id = c.goods_id where cgu.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
+        order_goods og on og.goods_id = c.goods_id where cgu.order_goods_id=og.order_goods_id and m.type = 1 ) as exam_num,
         (SELECT COUNT(DISTINCT ubr.chapter_id, ubr.exam_id) FROM user_bank_record ubr
         where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id=#{userId} and cgu.grade_id=ubr.grade_id and
         ubr.current_status=1 ) as exam_record_num
@@ -1988,4 +1988,8 @@
         WHERE
             o.plan_id > 0
     </select>
+
+    <select id="getStudyRecordNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.UserStudyRecord">
+        SELECT * FROM user_study_record WHERE order_goods_id = #{orderGoodsId} AND current_status = 1
+    </select>
 </mapper>

+ 194 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserSubscribeMapper.xml

@@ -582,4 +582,198 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND og.refund_status != 2
 	        AND og.pay_status IN (2,3,4)
     </select>
+
+    <select id="getExamApplyNum" parameterType="java.lang.String" resultType="java.lang.Integer">
+        SELECT
+            COUNT( DISTINCT us.user_id )
+        FROM
+            exam_apply ea
+                LEFT JOIN user_subscribe us ON ea.apply_id = us.apply_id
+        WHERE
+            ea.rel_code = ''
+          AND ea.`status` = 1
+          AND us.subscribe_status = 1
+    </select>
+
+    <select id="getListSubscribe" parameterType="com.zhongzheng.modules.user.bo.UserSubQueryBo" resultType="com.zhongzheng.modules.user.vo.UserSubVo">
+        SELECT
+            us.subscribe_id,
+            us.order_goods_id,
+            u.realname AS userName,
+            u.id_card AS userCard,
+            u.telphone AS userPhone,
+            u.company_name AS companyName,
+            g.goods_name,
+            m.category_name AS majorName,
+            t.tenant_name,
+            us.create_time,
+            us.subscribe_status,
+            ( SELECT SUM( ueg.exam_number ) FROM user_exam_goods ueg WHERE us.order_goods_id = ueg.order_goods_id GROUP BY ueg.order_goods_id ) AS applyNum,
+            us.exam_status,
+            us.result,
+            us.performance,
+            us.apply_site_exam_time as applyTime,
+            us.apply_site_start_time as applyStartTime,
+            us.apply_site_end_time as applyEndTime,
+            us.apply_site_address as applyAddress,
+            us.certificate_start_time as certificateStartTime,
+            us.certificate_end_time as certificateEndTime,
+            us.certificate_code,
+        CASE
+        WHEN    (
+                SELECT
+                COUNT( usu.order_goods_id )
+                FROM
+                user_subscribe usu
+                WHERE
+                usu.user_id = us.user_id
+                AND usu.order_goods_id = us.order_goods_id
+                AND usu.subscribe_status = 1
+                ) = 1
+        THEN 1
+        WHEN    (
+                SELECT
+                COUNT( usu.order_goods_id )
+                FROM
+                user_subscribe usu
+                WHERE
+                usu.user_id = us.user_id
+                AND usu.order_goods_id = us.order_goods_id
+                AND usu.subscribe_status = 1
+                ) >1
+        THEN 2
+        ELSE 0 END
+                AS newApply
+        FROM
+            user_subscribe us
+                LEFT JOIN order_goods og ON us.order_goods_id = og.order_goods_id
+                LEFT JOIN goods g ON og.goods_id = g.goods_id
+                LEFT JOIN major m ON g.major_id = m.id
+                LEFT JOIN sys_tenant t ON us.tenant_id = t.tenant_id
+                LEFT JOIN `user` u ON us.user_id = u.user_id
+        WHERE
+            1 = 1
+        <if test="subscribeStatus != null and subscribeStatus != '' and (subscribeStatus == 1 or subscribeStatus == 2)">
+            AND us.subscribe_status = #{subscribeStatus}
+        </if>
+        <if test="subscribeStatus != null and subscribeStatus != '' and subscribeStatus == 3">
+            AND (us.subscribe_status = 1 AND #{dataTime} &gt; us.apply_site_exam_time)
+        </if>
+        <if test="applyStatus != null and applyStatus != '' and applyStatus == 1 ">
+            AND ( us.exam_status = 1 AND us.result IS NULL )
+        </if>
+        <if test="applyStatus != null and applyStatus != '' and applyStatus == 2 ">
+            AND ( us.exam_status = 1 AND us.result = 1 )
+        </if>
+        <if test="applyStatus != null and applyStatus != '' and applyStatus == 3 ">
+            AND ( us.exam_status = 1 AND us.result = 0)
+        </if>
+        <if test="applyNum != null and applyNum != '' ">
+            AND ( SELECT SUM( ueg.exam_number ) FROM user_exam_goods ueg WHERE us.order_goods_id = ueg.order_goods_id GROUP BY ueg.order_goods_id ) = #{applyNum}
+        </if>
+        <if test="newApply != null and newApply != '' and newApply == 1">
+            AND (
+            SELECT
+            COUNT( usu.order_goods_id )
+            FROM
+            user_subscribe usu
+            WHERE
+            usu.user_id = us.user_id
+            AND usu.order_goods_id = us.order_goods_id
+            AND usu.subscribe_status = 1
+            ) = 1
+        </if>
+        <if test="newApply != null and newApply != '' and newApply == 2">
+            AND (
+            SELECT
+            COUNT( usu.order_goods_id )
+            FROM
+            user_subscribe usu
+            WHERE
+            usu.user_id = us.user_id
+            AND usu.order_goods_id = us.order_goods_id
+            AND usu.subscribe_status = 1
+            ) &gt; 1
+        </if>
+        <if test="keyWord != null and keyWord != '' ">
+            AND (u.realname LIKE concat('%',#{keyWord},'%') OR u.id_card = #{keyWord,typeHandler=com.zhongzheng.common.type.EncryptHandler})
+        </if>
+        <if test="applySiteExamTime != null and applySiteExamTime != '' ">
+            and us.apply_site_exam_time = #{applySiteExamTime}
+        </if>
+        <if test="monthStartTime != null and monthStartTime != '' ">
+            and us.apply_site_exam_time &gt;= #{monthStartTime}
+        </if>
+        <if test="monthEndTime != null and monthEndTime != '' ">
+            and us.apply_site_exam_time &lt;= #{monthEndTime}
+        </if>
+        <if test="applySiteStartTime != null and applySiteStartTime != '' ">
+            and us.apply_site_start_time = #{applySiteStartTime}
+        </if>
+        <if test="applySiteEndTime != null and applySiteEndTime != '' ">
+            and us.apply_site_end_time = #{applySiteEndTime}
+        </if>
+        <if test="educationId != null and educationId != '' ">
+            AND g.education_type_id = #{educationId}
+        </if>
+        <if test="businessId != null and businessId != '' ">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="tenantIds != null and tenantIds.size()!=0 " >
+            AND us.tenant_id in
+            <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        ORDER BY us.create_time DESC
+    </select>
+
+    <select id="getQuestionRel" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.domain.GoodsQuestionRel">
+        SELECT * FROM goods_question_rel WHERE order_goods_id = #{orderGoodsId} AND `status` = 1 AND question_do_num &gt; 0 LIMIT 1
+    </select>
+
+    <select id="listByTimeNoTenant" parameterType="com.zhongzheng.modules.user.bo.SubUserExportBo" resultType="com.zhongzheng.modules.user.domain.UserSubscribe">
+        SELECT * FROM user_subscribe
+        WHERE subscribe_status = 1 AND exam_status = 0
+        <if test="applyTime != null and applyTime != '' ">
+            AND apply_site_exam_time = #{applyTime}
+        </if>
+        <if test="tenantIds != null and tenantIds.size()!=0 " >
+            AND tenant_id IN
+            <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
+    </select>
+    <update id="updateByIdNoTenant"  parameterType="com.zhongzheng.modules.user.domain.UserSubscribe">
+        UPDATE
+            user_subscribe
+        SET
+            <if test="examStatus != null and examStatus != '' ">
+                exam_status = #{examStatus},
+            </if>
+            <if test="performance != null and performance != '' ">
+                performance = #{performance},
+            </if>
+            <if test="result != null and result != '' ">
+                `result` = #{result},
+            </if>
+            <if test="certificateCode != null and certificateCode != '' ">
+                certificate_code = #{certificateCode},
+            </if>
+            <if test="certificateUrl != null and certificateUrl != '' ">
+                certificate_url = #{certificateUrl},
+            </if>
+            <if test="certificateStartTime != null and certificateStartTime != '' ">
+                certificate_start_time = #{certificateStartTime},
+            </if>
+            <if test="certificateEndTime != null and certificateEndTime != '' ">
+                certificate_end_time = #{certificateEndTime},
+            </if>
+                update_time = unix_timestamp()
+        WHERE
+            subscribe_id = #{subscribeId}
+    </update>
+
 </mapper>