yangdamao 2 lat temu
rodzic
commit
6b006bfcd2

+ 96 - 89
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java

@@ -242,46 +242,46 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
             Long goodsId = bo.getClassGradeGoodsAddBos()[0];
             Goods goods = iGoodsService.getById(goodsId);
             CourseBusiness business = iCourseBusinessService.getById(goods.getBusinessId());
-            if (ObjectUtils.isNotNull(business) && ObjectUtils.isNotNull(business.getTemplateStatus()) && business.getTemplateStatus() == 1){
-                if (net.polyv.common.v1.util.StringUtils.isNotBlank(business.getAliasName()) &&
-                        (business.getAliasName().equals("二级建造师") || business.getAliasName().equals("二级造价工程师"))){
-                    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 = list.get(gradeGoods.size());
-                                if (checkEjjjPeopleNumLimit(business.getId(),grade.getGradeId())){
-                                    add.setOfficialName(list.get(gradeGoods.size()).getOfficialName());
-                                    add.setClassStatus(0);
-                                }else {
-                                    add.setOfficialName(ServletUtils.getEncoded("PIY"));
-                                    add.setClassStatus(0);
-                                }
+            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 = list.get(gradeGoods.size());
+                            if (checkEjjjPeopleNumLimit(business.getId(),grade.getGradeId())){
+                                add.setOfficialName(list.get(gradeGoods.size()).getOfficialName());
+                                add.setClassStatus(0);
+                            }else {
+                                add.setOfficialName(ServletUtils.getEncoded("PIY"));
+                                add.setClassStatus(0);
                             }
                         }
                     }
@@ -367,28 +367,33 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean updateByEditBo(ClassGradeEditBo bo) {
-
         //判断班级是否重复
         ClassGrade update = BeanUtil.toBean(bo, ClassGrade.class);
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
-        //二建和二造班级开班预留预报名编号
-        if (update.getClassStatus() != null && update.getClassStatus().equals(1)) {
-            //二造和二建班级开班校验班级人数(300人)
-            ClassGradeGoods gradeGoods = iClassGradeGoodsService.getOne(new LambdaQueryWrapper<ClassGradeGoods>().eq(ClassGradeGoods::getGradeId,update.getGradeId()));
-            if (ObjectUtils.isNull(gradeGoods)){
-                throw new RuntimeException("班级商品信息查询失败");
-            }
-            Goods goods = iGoodsService.getById(gradeGoods.getGoodsId());
-            if (!checkClassUserNum(goods.getBusinessId(),update.getGradeId())){
-                throw new RuntimeException("班级人数超过上限,不能开班,请检查!");
-            }
 
-            ClassGrade gradeGrade = getById(update.getGradeId());
-            if (StringUtils.isNotBlank(gradeGrade.getOfficialName())){
-                update.setRegisterCode(gradeGrade.getOfficialName());
+        ClassGradeGoods gradeGoods = iClassGradeGoodsService.getOne(new LambdaQueryWrapper<ClassGradeGoods>().eq(ClassGradeGoods::getGradeId,update.getGradeId()));
+        if (ObjectUtils.isNull(gradeGoods)){
+            throw new RuntimeException("班级商品信息查询失败");
+        }
+        Goods goods = iGoodsService.getById(gradeGoods.getGoodsId());
+        CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
+        businessQueryBo.setId(goods.getBusinessId());
+        String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
+
+        if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+            if (update.getClassStatus() != null && update.getClassStatus().equals(1)) {
+                //二造和二建班级开班校验班级人数(300人)
+                if (!checkClassUserNum(goods.getBusinessId(),update.getGradeId())){
+                    throw new RuntimeException("班级人数超过上限,不能开班,请检查!");
+                }
+                ClassGrade gradeGrade = getById(update.getGradeId());
+                if (StringUtils.isNotBlank(gradeGrade.getOfficialName())){
+                    update.setRegisterCode(gradeGrade.getOfficialName());
+                }
             }
         }
+
         if (bo.getStatus() != -1) {
             LambdaQueryWrapper<ClassGrade> lqw = Wrappers.lambdaQuery();
             lqw.eq(ClassGrade::getClassName, update.getClassName());
@@ -469,41 +474,43 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         this.updateById(update);
 
         ClassGrade grade = getById(update.getGradeId());
-        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())
-                .in(ClassGrade::getGradeId,list.stream().map(ClassGrade::getGradeId).collect(Collectors.toList())));
-            }
-            //官方班级开班通知旧系统
-            ClassGradeOpenBo openBo = new ClassGradeOpenBo();
-            openBo.setOfficialName(grade.getOfficialName());
-            openBo.setRegisterCode(grade.getRegisterCode());
-            openBo.setClassName(grade.getClassName());
-            openBo.setClassStartTime(grade.getClassStartTime());
-            openBo.setClassEndTime(grade.getClassEndTime());
-            Long nowTime = DateUtils.getNowTime();
-            String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
-            openBo.setSign(sign);
-            openBo.setStamp(nowTime);
-            JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(openBo));
-            String respone = "";
-            try {
-                respone = HttpUtils.sendPost(CLASS_OPEN_PATH, param);
-                log.info("查询旧系统班级开班接口结果" + respone, "");
-                if (!respone.contains("\"Status\":true")) {
-                    throw new CustomException("同步请求错误" + respone);
+        if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+            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())
+                            .in(ClassGrade::getGradeId,list.stream().map(ClassGrade::getGradeId).collect(Collectors.toList())));
+                }
+                //官方班级开班通知旧系统
+                ClassGradeOpenBo openBo = new ClassGradeOpenBo();
+                openBo.setOfficialName(grade.getOfficialName());
+                openBo.setRegisterCode(grade.getRegisterCode());
+                openBo.setClassName(grade.getClassName());
+                openBo.setClassStartTime(grade.getClassStartTime());
+                openBo.setClassEndTime(grade.getClassEndTime());
+                Long nowTime = DateUtils.getNowTime();
+                String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
+                openBo.setSign(sign);
+                openBo.setStamp(nowTime);
+                JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(openBo));
+                String respone = "";
+                try {
+                    respone = HttpUtils.sendPost(CLASS_OPEN_PATH, param);
+                    log.info("查询旧系统班级开班接口结果" + respone, "");
+                    if (!respone.contains("\"Status\":true")) {
+                        throw new CustomException("同步请求错误" + respone);
+                    }
+                } catch (Exception e) {
+                    throw new CustomException("同步请求错误"+e.getMessage());
                 }
-            } catch (Exception e) {
-                throw new CustomException("同步请求错误"+e.getMessage());
             }
         }
         return true;

+ 33 - 23
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsRefundServiceImpl.java

@@ -206,29 +206,35 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
         if(goods.getGoodsType()==6){
             throw new CustomException("直播商品不能退款");
         }
-        OrderGoodsRefund add = getOne(new LambdaQueryWrapper<OrderGoodsRefund>().eq(OrderGoodsRefund::getGoodsId,bo.getGoodsId()).eq(OrderGoodsRefund::getOrderSn,bo.getOrderSn()));
-        String out_trade_no = null;
-        if(Validator.isNotEmpty(add)){
-            out_trade_no = add.getRefundSn();
-        }else{
-            add = BeanUtil.toBean(bo, OrderGoodsRefund.class);
-            validEntityBeforeSave(add);
-            add.setCreateTime(DateUtils.getNowTime());
-            add.setUpdateTime(DateUtils.getNowTime());
-            //退款单号
-             out_trade_no = DateUtils.getDateOrderSn();
-            add.setRefundSn(out_trade_no);
-            add.setRefundFee(orderGoods.getGoodsReceived());
-            add.setUserId(order.getUserId());
-            add.setType(OrderGoodsRefund.TYPE_SMALL);
-            add.setOrderGoodsId(orderGoods.getOrderGoodsId());
-            this.save(add);
-        }
+
+        OrderGoodsRefund add = BeanUtil.toBean(bo, OrderGoodsRefund.class);
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        //退款单号
+        add.setRefundSn(DateUtils.getDateOrderSn());
+        add.setRefundFee(orderGoods.getGoodsReceived());
+        add.setUserId(order.getUserId());
+        add.setType(OrderGoodsRefund.TYPE_SMALL);
+        add.setOrderGoodsId(orderGoods.getOrderGoodsId());
+        this.save(add);
+        //修改订单状态
+        iOrderGoodsService.update(new LambdaUpdateWrapper<OrderGoods>()
+        .set(OrderGoods::getRefundStatus,1)
+        .eq(OrderGoods::getOrderGoodsId,orderGoods.getOrderGoodsId()));
+
+//        OrderGoodsRefund add = getOne(new LambdaQueryWrapper<OrderGoodsRefund>().eq(OrderGoodsRefund::getGoodsId,bo.getGoodsId()).eq(OrderGoodsRefund::getOrderSn,bo.getOrderSn()));
+//        String out_trade_no = null;
+//        if(Validator.isNotEmpty(add)){
+//            out_trade_no = add.getRefundSn();
+//        }else{
+//
+//        }
 //        Map<String, String> payResult =  iWxPayService.refund(out_trade_no,order.getTransid(),add.getRefundFee(),order.getPayPrice());
 //        if("OK".equals(payResult.get("return_msg"))&&Validator.isNotEmpty(payResult.get("refund_id"))){
 //            refundCall(payResult.get("refund_id"),add.getRefundId(),orderGoods.getOrderGoodsId(),order,goods.getGoodsType(),orderGoods.getGradeId(),bo.getUserId(),goods.getGoodsId());
 //            //关闭C端用户的分销返利
-
+//
 //        shareClientCancelOldSys(order,orderGoods,add.getRefundFee());
 //            return true;
 //        }else{
@@ -547,9 +553,13 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
                 orderGoodsUpdate.setUpdateTime(DateUtils.getNowTime());
                 iOrderGoodsService.updateById(orderGoodsUpdate);
                 if (ObjectUtils.isNotNull(bo.getType()) && bo.getType() == 1){
-                    //小程序/H5/PC 同意退款处理
+                    //小程序/H5/PC 同意退款处理(要大于半个小时)
+                    OrderGoodsRefund refund = getOne(new LambdaQueryWrapper<OrderGoodsRefund>().eq(OrderGoodsRefund::getRefundSn, bo.getRefundSn()));
+                    if (DateUtils.getNowTime() - refund.getCreateTime() < 1800L){
+                        throw new CustomException("订单时间大于30分钟才能退款,请稍后!");
+                    }
                     Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, bo.getOrderSn()));
-                    Map<String, String> payResult =  iWxPayService.refund(bo.getOrderSn(),order.getTransid(),bo.getRealRefundFee(),order.getPayPrice());
+                    Map<String, String> payResult =  iWxPayService.refund(bo.getRefundSn(),order.getTransid(),bo.getRealRefundFee(),order.getPayPrice());
                     if("OK".equals(payResult.get("return_msg"))&&Validator.isNotEmpty(payResult.get("refund_id"))){
                         OrderGoods orderGoods = iOrderGoodsService.getById(bo.getOrderGoodsId());
                         Goods goods = iGoodsService.getById(bo.getGoodsId());
@@ -571,7 +581,7 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
                 //修改订单商品退款状态
                 OrderGoods orderGoodsUpdate = new OrderGoods();
                 orderGoodsUpdate.setOrderGoodsId(orderGoodsRefund.getOrderGoodsId());
-                orderGoodsUpdate.setRefundStatus(3); //拒绝退款
+                orderGoodsUpdate.setRefundStatus(ObjectUtils.isNotNull(bo.getType()) && bo.getType() == 2 ? 3:0); //拒绝退款
                 orderGoodsUpdate.setUpdateTime(DateUtils.getNowTime());
                 iOrderGoodsService.updateById(orderGoodsUpdate);
             }
@@ -618,7 +628,7 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
                 //修改订单商品退款状态
                 OrderGoods orderGoodsUpdate = new OrderGoods();
                 orderGoodsUpdate.setOrderGoodsId(orderGoodsRefund.getOrderGoodsId());
-                orderGoodsUpdate.setRefundStatus(3); //拒绝退款
+                orderGoodsUpdate.setRefundStatus(ObjectUtils.isNotNull(bo.getType()) && bo.getType() == 2 ? 3:0); //拒绝退款
                 orderGoodsUpdate.setUpdateTime(DateUtils.getNowTime());
                 iOrderGoodsService.updateById(orderGoodsUpdate);
             }

+ 137 - 131
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -20,6 +20,7 @@ import com.zhongzheng.modules.bank.domain.QuestionChapterExam;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
 import com.zhongzheng.modules.base.service.IProfileTpService;
 import com.zhongzheng.modules.base.service.IShoppingCartService;
+import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
 import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
 import com.zhongzheng.modules.course.domain.CourseBusiness;
 import com.zhongzheng.modules.course.domain.CourseEducationType;
@@ -183,18 +184,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     @Override
     public List<OrderListVo> selectList(OrderQueryBo bo) {
-        if(Validator.isNotEmpty(bo.getOrderGoodsStatus())){
-            if(bo.getOrderGoodsStatus()==-1){
-                Integer[] orderStatus = new Integer []{-2,-1};
+        if (Validator.isNotEmpty(bo.getOrderGoodsStatus())) {
+            if (bo.getOrderGoodsStatus() == -1) {
+                Integer[] orderStatus = new Integer[]{-2, -1};
                 bo.setOrderStatus(orderStatus);
-            }
-            else if(bo.getOrderGoodsStatus()==0){
+            } else if (bo.getOrderGoodsStatus() == 0) {
                 bo.setGoodsPayStatus(1);
-            }
-            else if(bo.getOrderGoodsStatus()==1){
+            } else if (bo.getOrderGoodsStatus() == 1) {
                 //已支付 sql实现
-            }
-            else if(bo.getOrderGoodsStatus()==2){
+            } else if (bo.getOrderGoodsStatus() == 2) {
                 bo.setRefundStatus(2);
             }
         }
@@ -244,9 +242,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     @Override
     public List<OrderUserCheckBuyBo> userCheckBuyList(List<OrderUserCheckBuyBo> list) {
-        for(OrderUserCheckBuyBo bo : list){
+        for (OrderUserCheckBuyBo bo : list) {
             bo.setBuy(false);
-            if(Validator.isEmpty(bo.getTel())||Validator.isEmpty(bo.getGradeId())||Validator.isEmpty(bo.getGoodsId())){
+            if (Validator.isEmpty(bo.getTel()) || Validator.isEmpty(bo.getGradeId()) || Validator.isEmpty(bo.getGoodsId())) {
                 bo.setMsg("参数缺失");
                 continue;
             }
@@ -254,7 +252,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, bo.getGoodsId()));
             User user = iUserService.getOne(new LambdaQueryWrapper<User>()
                     .eq(User::getTelphone, EncryptHandler.encrypt(bo.getTel())).last("limit 1"));
-            if(Validator.isNull(user)){
+            if (Validator.isNull(user)) {
                 bo.setMsg("该手机号码用户不存在");
                 continue;
             }
@@ -274,10 +272,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             payStatusList.add(4);
             orderGoodsQueryBo.setPayStatusList(payStatusList);
             List<OrderGoodsVo> list1 = iOrderGoodsService.selectList(orderGoodsQueryBo);
-            if(Validator.isNotEmpty(list1)&&list1.size()>0){
+            if (Validator.isNotEmpty(list1) && list1.size() > 0) {
                 bo.setBuy(true);
             }
-            for(OrderGoodsVo vo : list1){
+            for (OrderGoodsVo vo : list1) {
                 bo.setServiceEndTime(vo.getServiceEndTime());
                 bo.setServiceStartTime(vo.getServiceStartTime());
             }
@@ -439,7 +437,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //订单商品
             Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
             if (goods.getGoodsStatus() != 1) {
-                throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
             }
             OrderGoods orderGoods = BeanUtil.toBean(g, OrderGoods.class);
             orderGoods.setOrderSn(out_trade_no);
@@ -467,7 +465,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             payPrice = payPrice.add(g.getGoodsPrice());
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
             boolean canRepeatBuy = false;
-            validUserBeforeBuy(goods,bo.getUserId());
+            validUserBeforeBuy(goods, bo.getUserId());
             //判断视频/题库商品是否有购买过,服务期是否过期
             Long oldOrderGoodsId = getHaveBuyGoods(g.getGoodsId(), bo.getUserId());
             //视频商品安排班级
@@ -497,7 +495,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                     isArrange = arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
                     redisCache.unlockLua(redisLockEntity);
                 }
-                if(!isArrange){
+                if (!isArrange) {
                     throw new CustomException("分班错误");
                 }
                 iOrderGoodsService.updateById(orderGoods);
@@ -509,7 +507,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
             if (goods.getGoodsType() == 6) {
                 //直播商品
-                if(Validator.isNotEmpty(oldOrderGoodsId)&&oldOrderGoodsId.longValue()>0){
+                if (Validator.isNotEmpty(oldOrderGoodsId) && oldOrderGoodsId.longValue() > 0) {
                     throw new CustomException("直播商品不允许复购");
                 }
             }
@@ -552,14 +550,14 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     public Map<String, Object> placePlatInputOrder(OrderAddBo bo) {
         List<OrderGoodsAddBo> goodsList = bo.getGoodsList();
         if (goodsList == null || goodsList.size() < 1) {
-            throw new CustomException("商品列表为空",510);
+            throw new CustomException("商品列表为空", 510);
         }
         if (Validator.isEmpty(bo.getInputOrderSn())) {
-            throw new CustomException("录单单号为空",510);
+            throw new CustomException("录单单号为空", 510);
         }
         OrderInput orderInput = iOrderInputService.queryBySn(bo.getInputOrderSn());
         if (Validator.isEmpty(orderInput)) {
-            throw new CustomException("录单单号不存在",510);
+            throw new CustomException("录单单号不存在", 510);
         }
         Order add = BeanUtil.toBean(bo, Order.class);
         validEntityBeforeSave(add);
@@ -608,7 +606,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             receivedPrice = receivedPrice.add(g.getGoodsReceived());
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
             boolean canRepeatBuy = false;
-            validUserBeforeBuy(goods,bo.getUserId());
+            validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
             Long oldOrderGoodsId = getHaveBuyGoods(g.getGoodsId(), bo.getUserId());
             //视频商品安排班级
@@ -638,8 +636,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                     isArrange = arrangeGrade(goods.getGoodsName(), goods.getGoodsId(), orderGoods.getOrderGoodsId(), gradeId, add.getUserId(), out_trade_no, goods.getBusinessId());
                     redisCache.unlockLua(redisLockEntity);
                 }
-                if(!isArrange){
-                    throw new CustomException("分班错误",510);
+                if (!isArrange) {
+                    throw new CustomException("分班错误", 510);
                 }
                 iOrderGoodsService.updateById(orderGoods);
                 newFreeBankGoods(goods.getGoodsId(), orderGoods.getOrderGoodsId());
@@ -650,7 +648,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
             if (goods.getGoodsType() == 6) {
                 //直播商品
-                if(Validator.isNotEmpty(oldOrderGoodsId)&&oldOrderGoodsId.longValue()>0){
+                if (Validator.isNotEmpty(oldOrderGoodsId) && oldOrderGoodsId.longValue() > 0) {
                     throw new CustomException("直播商品不允许复购");
                 }
             }
@@ -665,9 +663,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
 
         add.setOrderSn(out_trade_no);
-        if(Validator.isNotEmpty(bo.getOrderFrom())&&bo.getOrderFrom()==6){
+        if (Validator.isNotEmpty(bo.getOrderFrom()) && bo.getOrderFrom() == 6) {
             add.setOrderFrom(bo.getOrderFrom());
-        }else{
+        } else {
             add.setOrderFrom(Order.FROM_INPUT);
         }
         add.setPayPrice(payPrice);//需要支付价格
@@ -769,7 +767,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //订单商品
             Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
             if (goods.getGoodsStatus() != 1) {
-                throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
             }
             body = "中正祥粤云-" + goods.getGoodsName();
             OrderGoods orderGoods = BeanUtil.toBean(g, OrderGoods.class);
@@ -799,7 +797,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
 
             boolean canRepeatBuy = false;
-            validUserBeforeBuy(goods,bo.getUserId());
+            validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
             Long oldOrderGoodsId = getHaveBuyGoods(g.getGoodsId(), bo.getUserId());
             //视频商品安排班级
@@ -836,7 +834,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
             if (goods.getGoodsType() == 6) {
                 //直播商品
-                if(Validator.isNotEmpty(oldOrderGoodsId)&&oldOrderGoodsId.longValue()>0){
+                if (Validator.isNotEmpty(oldOrderGoodsId) && oldOrderGoodsId.longValue() > 0) {
                     throw new CustomException("直播商品不允许复购");
                 }
             }
@@ -871,7 +869,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         this.save(add);
 
         //判断是否红包活动订单
-        if (org.apache.commons.lang3.StringUtils.isNotBlank(add.getShareActivityCode())){
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(add.getShareActivityCode())) {
             ActivityOrder activityOrder = new ActivityOrder();
             activityOrder.setOrderSn(out_trade_no);
             activityOrder.setType(1);//分销红包活动
@@ -930,7 +928,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //订单商品
             Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
             if (goods.getGoodsStatus() != 1) {
-                throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
             }
             body = "中正祥粤云-" + goods.getGoodsName();
             OrderGoods orderGoods = BeanUtil.toBean(g, OrderGoods.class);
@@ -960,7 +958,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
 
             boolean canRepeatBuy = false;
-            validUserBeforeBuy(goods,bo.getUserId());
+            validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
             Long oldOrderGoodsId = getHaveBuyGoods(g.getGoodsId(), bo.getUserId());
             //视频商品安排班级
@@ -997,7 +995,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
             if (goods.getGoodsType() == 6) {
                 //直播商品
-                if(Validator.isNotEmpty(oldOrderGoodsId)&&oldOrderGoodsId.longValue()>0){
+                if (Validator.isNotEmpty(oldOrderGoodsId) && oldOrderGoodsId.longValue() > 0) {
                     throw new CustomException("直播商品不允许复购");
                 }
             }
@@ -1043,10 +1041,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         Map<String, String> payResult = new HashMap<>();
         //大于0元,获取微信支付信息
         if (payPrice.compareTo(BigDecimal.ZERO) != 0) {
-            if(Validator.isEmpty(userVo.getGzhOpenId())){
+            if (Validator.isEmpty(userVo.getGzhOpenId())) {
                 throw new CustomException("请先授权绑定公众号信息");
             }
-            payResult = iWxPayService.paymentGzh(pay_no, userVo.getGzhOpenId(), body, payPrice,bo.getUrl());
+            payResult = iWxPayService.paymentGzh(pay_no, userVo.getGzhOpenId(), body, payPrice, bo.getUrl());
         }
 
         payResult.put("orderSn", out_trade_no);
@@ -1083,7 +1081,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //订单商品
             Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
             if (goods.getGoodsStatus() != 1) {
-                throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
             }
             body = "中正祥粤云-" + goods.getGoodsName();
             OrderGoods orderGoods = BeanUtil.toBean(g, OrderGoods.class);
@@ -1113,7 +1111,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
 
             boolean canRepeatBuy = false;
-            validUserBeforeBuy(goods,bo.getUserId());
+            validUserBeforeBuy(goods, bo.getUserId());
             //判断是否有购买过
             Long oldOrderGoodsId = getHaveBuyGoods(g.getGoodsId(), bo.getUserId());
             //视频商品安排班级
@@ -1150,7 +1148,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
             if (goods.getGoodsType() == 6) {
                 //直播商品
-                if(Validator.isNotEmpty(oldOrderGoodsId)&&oldOrderGoodsId.longValue()>0){
+                if (Validator.isNotEmpty(oldOrderGoodsId) && oldOrderGoodsId.longValue() > 0) {
                     throw new CustomException("直播商品不允许复购");
                 }
             }
@@ -1204,12 +1202,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         return payResult;
     }
 
-    private Boolean validUserBeforeBuy(Goods goods ,Long userId){
-        if(goods.getGoodsType()==3||goods.getGoodsType()==4){
+    private Boolean validUserBeforeBuy(Goods goods, Long userId) {
+        if (goods.getGoodsType() == 3 || goods.getGoodsType() == 4) {
             Long makeGoodsId = goods.getMakeGoodsId();
-            UserExamGoods entity = userExamGoodsService.getOne(new LambdaQueryWrapper<UserExamGoods>().eq(UserExamGoods::getUserId,userId).eq(UserExamGoods::getGoodsId,makeGoodsId).last("limit 1"));
-            if(Validator.isEmpty(entity)){
-                throw new CustomException("请先购买此补考前培商品的绑定商品",510);
+            UserExamGoods entity = userExamGoodsService.getOne(new LambdaQueryWrapper<UserExamGoods>().eq(UserExamGoods::getUserId, userId).eq(UserExamGoods::getGoodsId, makeGoodsId).last("limit 1"));
+            if (Validator.isEmpty(entity)) {
+                throw new CustomException("请先购买此补考前培商品的绑定商品", 510);
             }
 
         }
@@ -1230,7 +1228,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             for (OrderGoods g : goodsList) {
                 Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
                 if (goods.getGoodsStatus() != 1) {
-                    throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                    throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
                 }
                 body = "中正祥粤云-" + goods.getGoodsName();
                 break;
@@ -1266,7 +1264,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             for (OrderGoods g : goodsList) {
                 Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
                 if (goods.getGoodsStatus() != 1) {
-                    throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                    throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
                 }
                 body = "中正祥粤云-" + goods.getGoodsName();
                 break;
@@ -1283,7 +1281,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         payAddBo.setStatus(0);
         payAddBo.setPayPrice(order.getPayPrice());
         iOrderPayService.insertByAddBo(payAddBo);
-        Map<String, String> payResult = iWxPayService.paymentGzh(pay_no, userVo.getGzhOpenId(), body, order.getPayPrice(),bo.getUrl());
+        Map<String, String> payResult = iWxPayService.paymentGzh(pay_no, userVo.getGzhOpenId(), body, order.getPayPrice(), bo.getUrl());
         payResult.put("orderSn", bo.getOrderSn());
         return payResult;
     }
@@ -1292,7 +1290,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Override
     public Boolean updateByEditBo(OrderEditBo bo) {
         Order order = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderId, bo.getOrderId()));
-        if (order.getOrderStatus() >0) {
+        if (order.getOrderStatus() > 0) {
             throw new CustomException("订单无法取消");
         }
 
@@ -1300,7 +1298,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
         //待支付手动关闭
-        if (Validator.isNotEmpty(update.getOrderStatus())&&update.getOrderStatus() == -1 &&order.getOrderStatus()==0) {
+        if (Validator.isNotEmpty(update.getOrderStatus()) && update.getOrderStatus() == -1 && order.getOrderStatus() == 0) {
             update.setCancelTime(DateUtils.getNowTime());
             //手动关闭订单
             OrderVo orderVo = this.queryById(bo.getOrderId());
@@ -1387,7 +1385,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             for (OrderGoods g : goodsList) {
                 Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, g.getGoodsId()));
                 if (goods.getGoodsStatus() != 1) {
-                    throw new CustomException(goods.getGoodsName()+"商品已下架,请重新选择商品下单");
+                    throw new CustomException(goods.getGoodsName() + "商品已下架,请重新选择商品下单");
                 }
                 body = "中正祥粤云-" + goods.getGoodsName();
                 break;
@@ -1444,6 +1442,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     /**
      * 课程商品ID产生免费的题库商品
+     *
      * @param goodsId
      * @return
      */
@@ -1454,15 +1453,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         Long value = redisCache.getCacheObject(key);
         if (Validator.isNotEmpty(value)) {
             freeBankGoodsId = value;
-            if(freeBankGoodsId.longValue()<0){
+            if (freeBankGoodsId.longValue() < 0) {
                 freeBankGoodsId = null;
             }
         }
-        if(Validator.isEmpty(freeBankGoodsId)){
+        if (Validator.isEmpty(freeBankGoodsId)) {
             List<CourseModuleFreeExamVo> moduleExamList = iGoodsService.moduleFreeExamList(goodsId);
             //课程模块有赠送的试卷
-            if(moduleExamList.size()>0){
-                for(CourseModuleFreeExamVo examVo : moduleExamList){
+            if (moduleExamList.size() > 0) {
+                for (CourseModuleFreeExamVo examVo : moduleExamList) {
                     examVo.setFreeExamName(null);//MD5去除名称影响
                 }
                 String jsonList = JSON.toJSONString(moduleExamList);
@@ -1470,15 +1469,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 //判断该课程商品是否已经存在相同结构的赠送卷商品
                 GoodsFreeBank freeBank = iGoodsFreeBankService.getOne(new LambdaQueryWrapper<GoodsFreeBank>().eq(GoodsFreeBank::getFromGoodsId, goodsId)
                         .eq(GoodsFreeBank::getMd5, examListMd5));
-                if(Validator.isNotEmpty(freeBank)){
+                if (Validator.isNotEmpty(freeBank)) {
                     freeBankGoodsId = freeBank.getGoodsId();//赠送的商品ID
-                }else{
+                } else {
                     Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsId));//获取课程商品
                     String code = ServletUtils.getEncoded("ZS");
                     //创建赠送卷商品
                     GoodsBankAddBo addBo = new GoodsBankAddBo();
                     addBo.setGoodsType(5);
-                    String goodsName = goods.getGoodsName()+"-"+code;
+                    String goodsName = goods.getGoodsName() + "-" + code;
                     addBo.setGoodsName(goodsName);
                     addBo.setEducationTypeId(goods.getEducationTypeId());
                     addBo.setProjectId(goods.getProjectId());
@@ -1487,7 +1486,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                     addBo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
                     List<GoodsAttachedAddBo> bankList = new ArrayList<>();
                     int sort = 1;
-                    for(CourseModuleFreeExamVo menuVo :moduleExamList){
+                    for (CourseModuleFreeExamVo menuVo : moduleExamList) {
                         GoodsAttachedAddBo attachedAddBo = new GoodsAttachedAddBo();
                         attachedAddBo.setType(menuVo.getExamType());
                         attachedAddBo.setMajorId(menuVo.getFreeExamId());
@@ -1509,12 +1508,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 }
             }
         }
-        if(Validator.isNotEmpty(freeBankGoodsId)){
+        if (Validator.isNotEmpty(freeBankGoodsId)) {
             OrderGoodsFreeAddBo goodsFreeAddBo = new OrderGoodsFreeAddBo();
             goodsFreeAddBo.setFreeGoodsId(freeBankGoodsId);
             goodsFreeAddBo.setOrderGoodsId(orderGoodsId);
             iOrderGoodsFreeService.insertByAddBo(goodsFreeAddBo);
-        }else{
+        } else {
             freeBankGoodsId = -1L; //课程商品不存在免费题库商品
         }
         redisCache.setCacheObject(key, freeBankGoodsId, 10, TimeUnit.SECONDS);
@@ -1544,25 +1543,26 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         payStatusList.add(4);
         orderGoodsQueryBo.setPayStatusList(payStatusList);
         List<OrderGoodsVo> list1 = iOrderGoodsService.selectList(orderGoodsQueryBo);
-        for(OrderGoodsVo goodsVo : list1){
-            if(Validator.isNotEmpty(goodsVo.getServiceEndTime())&&(goodsVo.getServiceEndTime().longValue()>(System.currentTimeMillis()/1000))){
-                if(goodsVo.getGoodsType()==1){
-                    if(Validator.isNotEmpty(goodsVo.getGradeId())){
+        for (OrderGoodsVo goodsVo : list1) {
+            if (Validator.isNotEmpty(goodsVo.getServiceEndTime()) && (goodsVo.getServiceEndTime().longValue() > (System.currentTimeMillis() / 1000))) {
+                if (goodsVo.getGoodsType() == 1) {
+                    if (Validator.isNotEmpty(goodsVo.getGradeId())) {
                         ClassGrade grade = iClassGradeService.getOne(new LambdaQueryWrapper<ClassGrade>()
                                 .eq(ClassGrade::getGradeId, goodsVo.getGradeId()));
                         //不存在班级有效期才校验服务期是否过期
-                        if(Validator.isEmpty(grade.getClassEndTime())){
+                        if (Validator.isEmpty(grade.getClassEndTime())) {
                             return goodsVo;
                         }
                     }
                 }
-                if(goodsVo.getGoodsType()==2){
+                if (goodsVo.getGoodsType() == 2) {
                     return goodsVo;
                 }
             }
         }
         return null;
     }
+
     //判断视频商品是否购买过且服务期是否过期
     public Long getHaveBuyGoods(Long goodsId, Long userId) {
         OrderGoodsQueryBo orderGoodsQueryBo = new OrderGoodsQueryBo();
@@ -1579,19 +1579,19 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         payStatusList.add(4);
         orderGoodsQueryBo.setPayStatusList(payStatusList);
         List<OrderGoodsVo> list1 = iOrderGoodsService.selectList(orderGoodsQueryBo);
-        for(OrderGoodsVo goodsVo : list1){
-            if(Validator.isNotEmpty(goodsVo.getServiceEndTime())&&(goodsVo.getServiceEndTime().longValue()>(System.currentTimeMillis()/1000))){
-                if(goodsVo.getGoodsType()==1){
-                    if(Validator.isNotEmpty(goodsVo.getGradeId())){
+        for (OrderGoodsVo goodsVo : list1) {
+            if (Validator.isNotEmpty(goodsVo.getServiceEndTime()) && (goodsVo.getServiceEndTime().longValue() > (System.currentTimeMillis() / 1000))) {
+                if (goodsVo.getGoodsType() == 1) {
+                    if (Validator.isNotEmpty(goodsVo.getGradeId())) {
                         ClassGrade grade = iClassGradeService.getOne(new LambdaQueryWrapper<ClassGrade>()
                                 .eq(ClassGrade::getGradeId, goodsVo.getGradeId()));
                         //不存在班级有效期才校验服务期是否过期
-                        if(Validator.isEmpty(grade.getClassEndTime())){
+                        if (Validator.isEmpty(grade.getClassEndTime())) {
                             throw new CustomException("存在已购买【学习服务期未过期】的视频商品,不可以重复购买商品", 511);
                         }
                     }
                 }
-                if(goodsVo.getGoodsType()==2){
+                if (goodsVo.getGoodsType() == 2) {
                     throw new CustomException("存在已购买【学习服务期未过期】的题库商品,不可以重复购买商品", 511);
                 }
             }
@@ -1611,8 +1611,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         bo.setPastDue(1L);
         List<ClassGradeVo> list = iClassGradeService.queryList(bo);
         if (list != null && list.size() > 0) {
-            for(ClassGradeVo gradeVo : list){
-                if(Validator.isNotEmpty(gradeVo.getClassEndTime())){
+            for (ClassGradeVo gradeVo : list) {
+                if (Validator.isNotEmpty(gradeVo.getClassEndTime())) {
                     throw new CustomException("存在已购买【班级有效期未过期】的商品,不可以重复购买商品", 511);
                 }
             }
@@ -1692,9 +1692,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getGradeId, gradeId)
                         .eq(ClassGradeUser::getUserId, userId));
                 //不在此班级内
-                if(Validator.isEmpty(gradeUser)){
+                if (Validator.isEmpty(gradeUser)) {
                     //班级还有剩位,直接锁定班级
-                    if(iClassGradeService.checkEjjjPeopleNumLimit(businessId,gradeId)){ //判断全系统平台二建班级人数是否超300
+                    if (iClassGradeService.checkEjjjPeopleNumLimit(businessId, gradeId)) { //判断全系统平台二建班级人数是否超300
                         return lockGrade(orderGoodsId, gradeId, userId, goodsId, orderSn);
                     }
 
@@ -1722,8 +1722,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getGradeId, gradeId)
                         .eq(ClassGradeUser::getUserId, userId));
                 //不在此班级内
-                if(Validator.isEmpty(gradeUser)){
-                    if(iClassGradeService.checkEjjjPeopleNumLimit(businessId,gradeId)){ //判断全系统平台二建班级人数是否超300
+                if (Validator.isEmpty(gradeUser)) {
+                    if (iClassGradeService.checkEjjjPeopleNumLimit(businessId, gradeId)) { //判断全系统平台二建班级人数是否超300
                         return lockGrade(orderGoodsId, gradeId, userId, goodsId, orderSn);
                     }
                 }
@@ -1742,8 +1742,15 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             classGrade.setClassStatus(0);
             classGrade.setLearningStatus(2);//待定
             classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
-            //生成预开班编号
-            classGrade.setOfficialName( createGradeCode(goodsId,businessVo));
+
+            CourseBusinessQueryBo businessQueryBo = new CourseBusinessQueryBo();
+            businessQueryBo.setId(businessId);
+            String fullName = iCourseBusinessService.queryFullName(businessQueryBo);
+            if (("继续教育二级建造师".equals(fullName)) || ("继续教育二级造价师".equals(fullName))) {
+                //生成预开班编号
+                classGrade.setOfficialName(createGradeCode(goodsId, businessVo));
+            }
+
         } else {
             classGrade.setLearningStatus(1);//即刻
             classGrade.setStudentUpper(ClassGrade.INIT_UPPER2); //上限1000000
@@ -1759,28 +1766,28 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         CourseEducationType educationType = courseEducationTypeService.getById(goods.getEducationTypeId());
         String educationName = educationType.getEducationName();
         String className = businessName + educationName;
-        if (StringUtils.isNotBlank(goods.getSubjectIds())){
+        if (StringUtils.isNotBlank(goods.getSubjectIds())) {
             List<CourseSubject> subjects = courseSubjectService.listByIds(Arrays.stream(goods.getSubjectIds().split(",")).collect(Collectors.toList()));
             List<String> names = subjects.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
-            className = String.format("%s(%s)",className,org.apache.commons.lang3.StringUtils.join(names,'+'));
+            className = String.format("%s(%s)", className, org.apache.commons.lang3.StringUtils.join(names, '+'));
         }
         Integer nameSort = 1;
         //获取排序值
         List<ClassGrade> list = iClassGradeService
                 .list(new LambdaQueryWrapper<ClassGrade>()
-                .like(ClassGrade::getClassName, className));
-        if (CollectionUtils.isNotEmpty(list)){
+                        .like(ClassGrade::getClassName, className));
+        if (CollectionUtils.isNotEmpty(list)) {
             List<Integer> collect = list.stream().filter(x -> x.getClassName().contains("第") && x.getClassName().contains("期")).map(item -> {
                 String name = item.getClassName();
                 String substring = name.substring(name.indexOf("第") + 1, name.indexOf("期"));
                 return Integer.parseInt(substring);
             }).collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(collect)){
+            if (CollectionUtils.isNotEmpty(collect)) {
                 Integer integer = collect.stream().sorted(Comparator.reverseOrder()).findFirst().get();
                 nameSort = integer + 1;
             }
         }
-        classGrade.setClassName(String.format("%s年第%s期%s",goods.getYear(),nameSort,className));
+        classGrade.setClassName(String.format("%s年第%s期%s", goods.getYear(), nameSort, className));
 
         boolean save = iClassGradeService.save(classGrade);
         //绑定班级商品
@@ -1795,47 +1802,46 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         return true;
     }
 
-    private String createGradeCode(Long goodsId,CourseBusinessVo business) {
+    private String createGradeCode(Long goodsId, CourseBusinessVo business) {
 
         Goods goods = iGoodsService.getById(goodsId);
-        if (StringUtils.isNotBlank(business.getAliasName()) && (business.getAliasName().equals("二级建造师") || business.getAliasName().equals("二级造价工程师"))){
-            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.getClassGradeByIds(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> list = iClassGradeService.listByIds(classGradesMax.stream().map(ClassGradeGoods::getGradeId).collect(Collectors.toList()));
-                    //获取当前机构商品下的班级
-                    List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goods.getGoodsId());
-                    if (gradeGoods.size() < list.size()) {
-                        ClassGrade grade = list.get(gradeGoods.size());
-                        if (iClassGradeService.checkEjjjPeopleNumLimit(business.getId(),grade.getGradeId())){
-                            return grade.getOfficialName();
-                        }
-                        return ServletUtils.getEncoded("PIY");
+        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.getClassGradeByIds(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> list = iClassGradeService.listByIds(classGradesMax.stream().map(ClassGradeGoods::getGradeId).collect(Collectors.toList()));
+                //获取当前机构商品下的班级
+                List<ClassGradeGoods> gradeGoods = iClassGradeGoodsService.getGradeGoodsList(goods.getGoodsId());
+                if (gradeGoods.size() < list.size()) {
+                    ClassGrade grade = list.get(gradeGoods.size());
+                    if (iClassGradeService.checkEjjjPeopleNumLimit(business.getId(), grade.getGradeId())) {
+                        return grade.getOfficialName();
                     }
+                    return ServletUtils.getEncoded("PIY");
                 }
             }
         }
+
         List<CourseSubject> courseSubjectList = courseSubjectService.listByIds(Arrays.asList(goods.getSubjectIds().split(",")));
         List<String> subNames = courseSubjectList.stream().map(CourseSubject::getSubjectName).collect(Collectors.toList());
         List<Long> subIds = courseSubjectService.getIdsByTenant(subNames);
@@ -1862,7 +1868,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //去重
             List<String> codeStrs = new ArrayList<>();
             for (ClassGrade gradesMax : classGradesMax) {
-                if (codeStrs.contains(gradesMax.getOfficialName())){
+                if (codeStrs.contains(gradesMax.getOfficialName())) {
                     continue;
                 }
                 codeStrs.add(gradesMax.getOfficialName());
@@ -1902,8 +1908,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 throw new CustomException("该班级不支持该商品使用");
             }
             //判断用户是否在此班过
-            ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getUserId,userId).eq(ClassGradeUser::getGradeId,gradeId).last("limit 1"));
-            if(Validator.isEmpty(gradeUser)){
+            ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getUserId, userId).eq(ClassGradeUser::getGradeId, gradeId).last("limit 1"));
+            if (Validator.isEmpty(gradeUser)) {
                 LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
                 lqw.eq(ClassGradeUser::getGradeId, gradeId);
                 lqw.eq(ClassGradeUser::getStatus, 1);
@@ -1916,7 +1922,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 //预留0空位避免超人数
                 if ((classGradeVo.getStudentUpper() - studentNum - locakStudentNum) > 0) {
                     //班级还有剩位,直接加入班级
-                    if(iClassGradeService.checkEjjjPeopleNumLimit(businessId,gradeId)) { //判断全系统平台二建班级人数是否超300
+                    if (iClassGradeService.checkEjjjPeopleNumLimit(businessId, gradeId)) { //判断全系统平台二建班级人数是否超300
                         joinGrade(orderGoodsId, gradeId, userId);
                         return gradeId;
                     }
@@ -1942,10 +1948,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 //有空位则进入班级
                 gradeId = classGradeVo.getGradeId();
                 //判断用户是否在此班过
-                ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getUserId,userId).eq(ClassGradeUser::getGradeId,gradeId).last("limit 1"));
-                if(Validator.isEmpty(gradeUser)){
+                ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getUserId, userId).eq(ClassGradeUser::getGradeId, gradeId).last("limit 1"));
+                if (Validator.isEmpty(gradeUser)) {
                     //班级还有剩位,直接加入班级
-                    if(iClassGradeService.checkEjjjPeopleNumLimit(businessId,gradeId)) { //判断全系统平台二建班级人数是否超300
+                    if (iClassGradeService.checkEjjjPeopleNumLimit(businessId, gradeId)) { //判断全系统平台二建班级人数是否超300
                         joinGrade(orderGoodsId, gradeId, userId);
                         return gradeId;
                     }
@@ -2025,10 +2031,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             if ((classGradeVo.getStudentUpper() - studentNum - locakStudentNum) > 0) {
                 //班级还有剩位,直接加入班级
                 Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsId));
-                if(iClassGradeService.checkEjjjPeopleNumLimit(goods.getBusinessId(),gradeId)) { //判断全系统平台二建班级人数是否超300
+                if (iClassGradeService.checkEjjjPeopleNumLimit(goods.getBusinessId(), gradeId)) { //判断全系统平台二建班级人数是否超300
                     joinGrade(orderGoodsId, gradeId, userId);
                     return gradeId;
-                }else {
+                } else {
                     throw new CustomException("该二建班级学员已满,请重新选班");
                 }
 
@@ -2088,7 +2094,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //通知外部系统
         OrderGoods orderGoods = iOrderGoodsService.getById(orderGoodsId);
         Goods goods = iGoodsService.getById(orderGoods.getGoodsId());
-        iClassGradeService.gradeChangeEjjjPeople(goods.getBusinessId(),gradeId);
+        iClassGradeService.gradeChangeEjjjPeople(goods.getBusinessId(), gradeId);
         return true;
     }
 }

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

@@ -123,7 +123,7 @@
         FROM
         order_goods og
         LEFT JOIN goods g ON og.goods_id = g.goods_id
-        LEFT JOIN order_goods_refund ogr ON og.order_sn = ogr.order_sn
+        LEFT JOIN order_goods_refund ogr ON og.order_goods_id = ogr.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
         LEFT JOIN course_business cb ON g.business_id = cb.id

+ 2 - 3
zhongzheng-system/src/main/resources/mapper/modules/order/OrderMapper.xml

@@ -322,10 +322,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     <select id="selectListApp" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
         SELECT
-            o.*,
-            ogr.period_status
+            o.*
         FROM
-            `order` o LEFT JOIN order_goods_refund ogr on o.order_sn = ogr.order_sn
+            `order` o
         where 1=1
         <if test="userId != null">
             AND o.user_id = #{userId}